Subversion Repositories spacemission

Compare Revisions

No changes between revisions

Regard whitespace Rev HEAD → Rev 1

/VCL_DELPHIX_D6/DelphiX140.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX250.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX160.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX270.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX180.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX290.dproj
File deleted
/VCL_DELPHIX_D6/Dcu190
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DelphiX200.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX120.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX240.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/turbopixels.pas
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX160.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX280.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DxPathEdit.dfm
File deleted
/VCL_DELPHIX_D6/Dcu120
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DelphiX110.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX230.dpk
File deleted
/VCL_DELPHIX_D6/DelphiX150.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX270.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX190.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX160_Icon.ico
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX40.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX60.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX210.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX250.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX170.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX290.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXGlueItEdit.pas
File deleted
/VCL_DELPHIX_D6/DXGlueItEdit.dfm
File deleted
/VCL_DELPHIX_D6/DelphiX30.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX50.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX70.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX90.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/Dcu200
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DXMapEdit.dfm
File deleted
/VCL_DELPHIX_D6/Colli3DX.pas
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/Dcu140
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/SXLib.pas
File deleted
/VCL_DELPHIX_D6/DXMisc.pas
File deleted
/VCL_DELPHIX_D6/Dcu60
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/Dcu40
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DelphiX200.dpk
File deleted
/VCL_DELPHIX_D6/DelphiX120.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX240.dpk
File deleted
/VCL_DELPHIX_D6/DirectPlay.pas
File deleted
/VCL_DELPHIX_D6/DelphiX160.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DxPathEdit.pas
File deleted
/VCL_DELPHIX_D6/DelphiX280.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DXMapEditProperties.dfm
File deleted
/VCL_DELPHIX_D6/DelphiX200.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX110.dproj
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX220.dproj
File deleted
/VCL_DELPHIX_D6/Dcu210
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DelphiX240.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX150.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX260.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX170.dproj
File deleted
/VCL_DELPHIX_D6/DXMidiEdit.dfm
File deleted
/VCL_DELPHIX_D6/Dcu150
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DelphiX280.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX190.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX140_Icon.ico
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX100.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX220.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXDIBEffectEdit.dfm
File deleted
/VCL_DELPHIX_D6/DelphiX140.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX260.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX180.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/Dcu220
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/Dcu160
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/SXMedia/SXAbout.pas
File deleted
/VCL_DELPHIX_D6/SXMedia/SXModPlayer.pas
File deleted
/VCL_DELPHIX_D6/SXMedia/SXAbout.dfm
File deleted
/VCL_DELPHIX_D6/SXMedia/SXReg.pas
File deleted
/VCL_DELPHIX_D6/SXMedia/SXMovie.pas
File deleted
/VCL_DELPHIX_D6/SXMedia/SxSample/MPPSDK.DLL
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/SXMedia/SxSample/main.dfm
File deleted
/VCL_DELPHIX_D6/SXMedia/SxSample/SXMedia.dpr
File deleted
/VCL_DELPHIX_D6/SXMedia/SxSample/SXMedia.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/SXMedia/SxSample/main.pas
File deleted
/VCL_DELPHIX_D6/SXMedia/SxSample
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/SXMedia/SXReg.dcr
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/SXMedia/SXEngine.pas
File deleted
/VCL_DELPHIX_D6/SXMedia/MpSndSys.pas
File deleted
/VCL_DELPHIX_D6/SXMedia/SXEditor.pas
File deleted
/VCL_DELPHIX_D6/SXMedia
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DXMapEdit.pas
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX210.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX.bdsproj
File deleted
/VCL_DELPHIX_D6/DelphiX250.dpk
File deleted
/VCL_DELPHIX_D6/DelphiX170.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX290.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/Dcu170
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DelphiX30.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX50.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX70.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX90.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX110.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX230.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX150.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX270.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX190.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX40.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX60.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/Dcu100
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/Colli3DX.dcr
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXMidiEdit.pas
File deleted
/VCL_DELPHIX_D6/Dcu180
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DXMapEditProperties.pas
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX100.bdsproj
File deleted
/VCL_DELPHIX_D6/Dcu90
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/Dcu70
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/Dcu50
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/D3DUtils.pas
File deleted
/VCL_DELPHIX_D6/Dcu30
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DelphiX100.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DXSpriteEdit.pas
File deleted
/VCL_DELPHIX_D6/DXWave.pas
File deleted
/VCL_DELPHIX_D6/DelphiX220.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DXSpriteEdit.dfm
File deleted
/VCL_DELPHIX_D6/DelphiX140.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX.dproj
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX260.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX180.dpk
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DXDIBEffectEdit.pas
File deleted
\ No newline at end of file
/VCL_DELPHIX_D6/DelphiX210.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX120.dproj
File deleted
/VCL_DELPHIX_D6/DelphiX230.dproj
File deleted
/VCL_DELPHIX_D6/Dcu110
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe
/VCL_DELPHIX_D6/DXConsts.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DirectX.txt
0,0 → 1,121
-- English -------------------------------------------------------------------
 
DirectX header for Delphi 3, 4, 5.
 
Present unit:
DirectX unit DirectX 7 (DirectX 7 SDK)
DShow unit DirectShow (DirectX Media SDK 5.1)
DAnim unit DirectAnimation (DirectX Media SDK 5.1)
 
Hiroyuki Hori
@hori@ingjapan.ne.jp
@http://www.yks.ne.jp/~hori/
 
-- Japanese -------------------------------------------------------------------
 
Delphi 3, 4, 5 —p‚ÌŠ®‘S‚È DirectX ƒwƒbƒ_[‚Å‚·B
 
Œ»Ý‚̃†ƒjƒbƒgF
DirectX ƒ†ƒjƒbƒg DirectX 7 (DirectX 7 SDK)
DShow ƒ†ƒjƒbƒg DirectShow (DirectX Media SDK 5.1)
DAnim ƒ†ƒjƒbƒg DirectAnimation (DirectX Media SDK 5.1)
 
–x@_s(Hiroyuki Hori)
@hori@ingjapan.ne.jp
@http://www.yks.ne.jp/~hori/
 
 
XV‹L˜^F
 
2000/07/17 EIDirectDrawSurface4.Lock ƒƒ\ƒbƒh‚̈ø”‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EIDirect3DDevice7.DrawIndexedPrimitiveVB ƒƒ\ƒbƒh‚̈ø”‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1999/11/20 EDirectX7 ‚ɑΉž‚µ‚½B
EIDirectDrawSurface ƒCƒ“ƒ^[ƒtƒF[ƒX‚Ì EnumAttachedSurfaces, EnumOverlayZOrders ƒƒ\ƒbƒh‚Ì
ˆø”‚ÌŒ^‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EIDirect3DRMFrame3 ƒCƒ“ƒ^[ƒtƒF[ƒX‚Ì GetTransForm ƒƒ\ƒbƒh‚̈ø”‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EDDSPD_VOLATILE ’萔‚Ì’l‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EDShow.pas ‚Å Delphi 3 ‚̏ꍇAInt64 Œ^‚ðéŒ¾‚µ‚Ä‚¢‚½‚Ì‚ð‚â‚ß‚Ä LONGLONG Œ^‚ðŽg‚¤‚悤‚É‚µ‚½B
ETDPMsg_SendComplete Œ^‚Å dwPriority ‚ª”²‚¯‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1999/09/27 EDelphi 5 ‚ŃŒƒR[ƒh‚̉•ϕ”•ª‚ɃCƒ“ƒ^[ƒtƒF[ƒX‚ð‚¨‚¯‚È‚­‚È‚Á‚½‚½‚߁A
TDDBltFX, TDDOverlayFx \‘¢‘Ì‚Ì‚È‚©‚̃Cƒ“ƒ^[ƒtƒF[ƒX‚ðƒ|ƒCƒ“ƒ^‚ɕύX‚µ‚½B
 
1999/08/21 EDirectXFileCreate ŠÖ”‚Ì DLL ƒtƒ@ƒCƒ‹–¼‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EIID_IDirectXFile ’萔‚È‚Ç‚ª•¶Žš—ñ’萔‚Æ‚µ‚Đ錾‚³‚ê‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
ED3DRM_XTEMPLATE_BYTES ’萔‚ðéŒ¾‚µ–Y‚ê‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EIDirect3DRMMeshBuilder3 ƒCƒ“ƒ^[ƒtƒF[ƒX‚̐錾‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1999/02/21 EIDirect3DRM3 ƒCƒ“ƒ^[ƒtƒF[ƒX‚̐錾‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EIDirect3DDevice3 ƒCƒ“ƒ^[ƒtƒF[ƒX‚̐錾‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1998/10/05@EIDirect3D3.CreateDevice ƒƒ\ƒbƒh‚̈ø”‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1998/08/28@EIDirect3D3.CreateVertexBuffer ƒƒ\ƒbƒh‚ðéŒ¾‚µ–Y‚ê‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EIDirect3D3.CreateMaterial ƒƒ\ƒbƒh‚̈ø”‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1998/08/25 EIDirect3DRM ƒCƒ“ƒ^[ƒtƒF[ƒX‚ð’è‹`‚µ–Y‚ê‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EIDirect3DRM2, IDirect3DRM3 ‚Ì LoadTextureFromResource ƒƒ\ƒbƒh‚̈ø”‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1998/08/24 EDirectX 5 ƒwƒbƒ_[‚ƌ݊·«‚ª‚È‚©‚Á‚½‚Ì‚ðC³‚µ‚½B
‹ï‘Ì“I‚É‚Í PDInputState ‚ð’è‹`‚µ‚Ä‚¢‚È‚©‚Á‚½B
 
1998/08/08 EIBasicVideo.get_BitRate ƒƒ\ƒbƒh‚̐錾‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1998/08/07 EDirectX 6 ‚É‚à‘Ήž‚µ‚½B
EŒ^‚Ì–½–¼‹K‘¥‚ð Delphi •W€‚É•Ï‚¦‚½B
EInteger Œ^‚Ő錾‚µ‚Ä‚ ‚Á‚½‚Ì‚ð DWORD ‚© Longint Œ^‚Ő錾‚·‚é‚悤‚É‚µ‚½B
EƒrƒfƒIƒ|[ƒgŠÖ˜A‚̐錾‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
ETD3DRMLoadTextureCallback Œ^‚̈ø”‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EIDirect3DRMPicked2Array.GetPick ƒƒ\ƒbƒh‚̐錾‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
ETDSEnumCallbackX Œ^‚É stdcall ‚ª–³‚©‚Á‚½‚Ì‚ðC³‚µ‚½B
EDShow ƒ†ƒjƒbƒg‚Å 64ƒrƒbƒg®”Œ^‚Í Comp ‚Å‚Í‚È‚­ATInt64 Œ^‚É‚µ‚½B
Delphi3 ‚Å‚Í type TInt64=Comp ‚Æ‚µ‚Ä’è‹`‚³‚ê‚éB
 
1998/06/03 EVectorCrossProduct ŠÖ”‚ÌŒvŽZŽ®‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1998/05/29 ED3DRMQuaternionFromRotation ŠÖ”‚̈ø”‚̐錾‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1998/04/29 EDIK_? ‚Ő錾‚µ–Y‚ê‚Ä‚¢‚½‚Ì‚ð’ljÁ‚µ‚½B
 
1998/04/02 EIDirect3DRMFrame2 ‚̃ƒ\ƒbƒh‚ðC³‚µ‚½B
 
1998/04/02 EDirectPlay ŠÖ˜A‚ð‚¿‚å‚Á‚ƏC³‚µ‚½B
 
1998/03/02 EIFilterMapper2.EnumMatchingFilters ‚̐錾‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
EIEnumXX.Next ƒƒ\ƒbƒh‚Ì‘æ“ñˆø” ‚Å out XXX: Ixxx ‚Æ‚È‚Á‚Ä‚¢‚½‚Ì‚ð out XXX ‚Æ‚µ‚½B
 
1998/03/01 EˆÈ‰º‚̃†ƒjƒbƒg‚ð’ljÁ‚µ‚½B
DShow ƒ†ƒjƒbƒg DirectShow(ActiveMovie)
DAnim ƒ†ƒjƒbƒg DirectAnimation
 
1998/02/06 EDirectX ƒ†ƒjƒbƒg‚É‚·‚ׂẴ†ƒjƒbƒg‚ð‚Ü‚Æ‚ß‚½B
 
1998/01/31 E‚·‚ׂẴ†ƒjƒbƒg‚É $WEAKPACKAGEUNIT Žw—ß‚ð‰Á‚¦‚½B
ED3DTypes ƒ†ƒjƒbƒg‚Ì D3DRGBA ŠÖ”‚ðC³‚µ‚½B
 
1998/01/22 E‚Ù‚Æ‚ñ‚ǂ̃†ƒjƒbƒg‚É $WEAKPACKAGEUNIT Žw—ß‚ð‰Á‚¦‚½B
 
1998/01/04 EDInput.pas ‚Ì DIK_xxx ‚Ő錾‚µ–Y‚ê‚Ä‚¢‚½‚Ì‚ª‚ ‚Á‚½‚Ì‚ðC³‚µ‚½B
 
1997/12/27 EIDirect3DRMDevice2 ‚ð IDirect3DRMDevice ‚ðŒp³‚·‚é‚悤‚É‚µ‚½B
EIDirect3DViewport2 ‚ð Direct3DViewport ‚ðŒp³‚·‚é‚悤‚É‚µ‚½B
EIDirectPlay3 ‚Å IDirectPlay2 ‚Ì•”•ª‚ªéŒ¾‚³‚ê‚Ä‚¢‚½‚Ì‚ðíœ‚µ‚½B
EIDirectPlayLobby2 ‚Å IDirectPlayLobby ‚Ì•”•ª‚ªéŒ¾‚³‚ê‚Ä‚¢‚½‚Ì‚ðíœ‚µ‚½B
EIDirectInputDevice2 ‚Å IDirectInputDevice ‚Ì•”•ª‚ªéŒ¾‚³‚ê‚Ä‚¢‚½‚Ì‚ðíœ‚µ‚½B
EƒR[ƒ‹ƒoƒbƒNŠÖ”‚Ì–ß‚è’l‚ð BOOL ‚©‚ç HRESULT ‚É‚µ‚½B
Ec_dfDIMouse, c_dfDIKeyboard ‚Ì’è‹`‚ª³‚µ‚­‚È‚©‚Á‚½‚Ì‚ð‚È‚¨‚µ‚½B
 
1997/12/16 EIDirect3DRM2.CreateDeviceFromD3D ƒƒ\ƒbƒh‚̈ø”‚ð•ÏX‚µ‚½B
EIDirect3DRMMeshBuilder2 ‚ð IDirect3DRMMeshBuilder ‚ðŒp³‚·‚é‚悤‚É‚µ‚½B
ED3DRMObj ƒ†ƒjƒbƒg‚Å Boolean ‚Æ‚È‚Á‚Ä‚¢‚½‚Ì‚ð Bool ‚Æ‚µ‚½B
 
1997/12/09 EIDirect3DRMFrame2 ‚ð IDirect3DRMFrame ‚ðŒp³‚·‚é‚悤‚É‚µ‚½B
EIDirect3DRMTexture2 ‚ð IDirect3DRMTexture ‚ðŒp³‚·‚é‚悤‚É‚µ‚½B
 
EIDirect3DDevice2 ‚Ì DrawPrimitve, DrawIndexedPrimitve ƒƒ\ƒbƒh‚̈ø”‚ð•ÏX‚µ‚½B
EIDirect3DRMFace ‚Ì SetColor ƒƒ\ƒbƒh‚̐錾‚ª”²‚¯—Ž‚¿‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
 
1997/11/25 ED3DTypes ƒ†ƒjƒbƒg‚Ì D3DRGB, D3DRGBA ŠÖ”‚ðC³‚µ‚½B
 
1997/11/21 EIDirect3DRMObject.Clone ƒƒ\ƒbƒh‚̐錾‚ªŠÔˆá‚Á‚Ä‚¢‚½‚Ì‚ðC³‚µ‚½B
/VCL_DELPHIX_D6/DIB.pas
1,81 → 1,35
{*******************************************************}
{ }
{ DIB and PAINTBOX componets }
{ }
{ Copyright (C) 1997-2000 Hiroyuki Hori }
{ base components and effects }
{ Copyright (C) 2000 Keith Murray }
{ supernova effect }
{ Copyright (C) 2000 Michel Hibon }
{ new special effects added for DIB }
{ Copyright (C) 2001 Joakim Back }
{ conFusion effects (as DxFusion) }
{ Copyright (C) 2003 Babak Sateli }
{ 24-bit DIB effect as supplement ones }
{ Copyright (C) 2004-2012 Jaro Benes }
{ 32-bit DIB effect with alphachannel }
{ direct works with texture buffer }
{ modified and adapted all adopted functions }
{ }
{*******************************************************}
 
unit DIB;
 
interface
 
{$INCLUDE DelphiXcfg.inc}
{$DEFINE USE_SCANLINE}
 
uses
Windows, SysUtils, Classes, Graphics, Controls,
{$IFDEF VER7UP} Types, {$ENDIF}
{$IFDEF VER9UP} GraphUtil, {$ENDIF}
{$IFDEF VER17UP} UITypes,{$ENDIF}
Math;
Windows, SysUtils, Classes, Graphics, Controls;
 
type
TColorLineStyle = (csSolid, csGradient, csRainbow);
TColorLinePixelGeometry = (pgPoint, pgCircular, pgRectangular);
PRGBQuads = ^TRGBQuads;
TRGBQuads = array[0..255] of TRGBQuad;
 
TPaletteEntries = array[0..255] of TPaletteEntry;
 
PBGRA = ^TBGRA;
TBGRA = packed record
B, G, R, A: Byte;
end;
TLinesA = array[0..0] of TBGRA;
PLinesA = ^TLinesA;
 
PBGR = ^TBGR;
TBGR = packed record
B, G, R: Byte;
end;
 
{ Added this type for New SPecial Effect }
TFilter = array[0..2, 0..2] of SmallInt;
TLines = array[0..0] of TBGR;
PLines = ^TLines;
TBytes = array[0..0] of Byte;
PBytes = ^TBytes;
TPBytes = array[0..0] of PBytes;
PPBytes = ^TPBytes;
{ End of type's }
 
PArrayBGR = ^TArrayBGR;
TArrayBGR = array[0..0] of TBGR;
TArrayBGR = array[0..10000] of TBGR;
 
PArrayByte = ^TArrayByte;
TArrayByte = array[0..0] of Byte;
TArrayByte = array[0..10000] of Byte;
 
PArrayWord = ^TArrayWord;
TArrayWord = array[0..0] of Word;
TArrayWord = array[0..10000] of Word;
 
PArrayDWord = ^TArrayDWord;
TArrayDWord = array[0..0] of DWord;
TArrayDWord = array[0..10000] of DWord;
 
{ TDIBPixelFormat }
{ TDIB }
 
TDIBPixelFormat = record
RBitMask, GBitMask, BBitMask: DWORD;
84,8 → 38,6
RBitCount2, GBitCount2, BBitCount2: DWORD;
end;
 
{ TDIBSharedImage }
 
TDIBSharedImage = class(TSharedImage)
private
FBitCount: Integer;
112,7 → 64,7
constructor Create;
procedure NewImage(AWidth, AHeight, ABitCount: Integer;
const PixelFormat: TDIBPixelFormat; const ColorTable: TRGBQuads; MemoryImage, Compressed: Boolean);
procedure Duplicate(Source: TDIBSharedImage; MemoryImage: Boolean); {$IFDEF VER9UP}inline;{$ENDIF}
procedure Duplicate(Source: TDIBSharedImage; MemoryImage: Boolean);
procedure Compress(Source: TDIBSharedImage);
procedure Decompress(Source: TDIBSharedImage; MemoryImage: Boolean);
procedure ReadData(Stream: TStream; MemoryImage: Boolean);
124,33 → 76,6
destructor Destroy; override;
end;
 
{ TFilterTypeResample }
 
TFilterTypeResample = (ftrBox, ftrTriangle, ftrHermite, ftrBell, ftrBSpline,
ftrLanczos3, ftrMitchell);
 
TDistortType = (dtFast, dtSlow);
{DXFusion effect type}
TFilterMode = (fmNormal, fmMix50, fmMix25, fmMix75);
 
{ TLightSource }
 
TLightSource = record
X, Y: Integer;
Size1, Size2: Integer;
Color: TColor;
end;
 
{ TLightArray }
 
TLightArray = array{$IFNDEF VER4UP}[0..0]{$ENDIF} of TLightsource;
 
{ TMatrixSetting }
 
TMatrixSetting = array[0..9] of Integer;
 
{ TDIB }
 
TDIB = class(TGraphic)
private
FCanvas: TCanvas;
171,10 → 96,6
FTopPBits: Pointer;
FWidth: Integer;
FWidthBytes: Integer;
FLUTDist: array[0..255, 0..255] of Integer;
LG_COUNT: Integer;
LG_DETAIL: Integer;
FFreeList: TList;
procedure AllocHandle;
procedure CanvasChanging(Sender: TObject);
procedure Changing(MemoryImage: Boolean);
192,28 → 113,15
function GetTopPBits: Pointer;
function GetTopPBitsReadOnly: Pointer;
procedure SetBitCount(Value: Integer);
procedure SetImage(Value: TDIBSharedImage); {$IFDEF VER9UP}inline;{$ENDIF}
procedure SetImage(Value: TDIBSharedImage);
procedure SetNowPixelFormat(const Value: TDIBPixelFormat);
procedure SetPixel(X, Y: Integer; Value: DWORD);
procedure StartProgress(const Name: string);
procedure EndProgress;
procedure UpdateProgress(PercentY: Integer);
 
{ Added these 3 functions for New Specials Effects }
function Interval(iMin, iMax, iValue: Integer; iMark: Boolean): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
function IntToByte(i: Integer): Byte; {$IFDEF VER9UP}inline;{$ENDIF}
function TrimInt(i, Min, Max: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
{ End of 3 functions for New Special Effect }
 
procedure Darkness(Amount: Integer);
function GetAlphaChannel: TDIB;
procedure SetAlphaChannel(const Value: TDIB);
function GetClientRect: TRect;
function GetRGBChannel: TDIB;
procedure SetRGBChannel(const Value: TDIB);
protected
procedure DefineProperties(Filer: TFiler); override;
procedure Draw(ACanvas: TCanvas; const ARect: TRect); override;
procedure Draw(ACanvas: TCanvas; const Rect: TRect); override;
function GetEmpty: Boolean; override;
function GetHeight: Integer; override;
function GetPalette: HPalette; override;
223,10 → 131,6
procedure SetPalette(Value: HPalette); override;
procedure SetWidth(Value: Integer); override;
procedure WriteData(Stream: TStream); override;
{$IFDEF VER16UP}
function GetSupportsPartialTransparency: Boolean; override;
{$ENDIF}
function GetTransparent: Boolean; override;
public
ColorTable: TRGBQuads;
PixelFormat: TDIBPixelFormat;
237,9 → 141,6
procedure Compress;
procedure Decompress;
procedure FreeHandle;
function HasAlphaChannel: Boolean;
function AssignAlphaChannel(ALPHA: TDIB; ForceResize: Boolean{$IFDEF VER4UP} = False{$ENDIF}): Boolean;
procedure RetAlphaChannel(out oDIB: TDIB);
procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle;
APalette: HPALETTE); override;
procedure LoadFromStream(Stream: TStream); override;
246,168 → 147,14
procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle;
var APalette: HPALETTE); override;
procedure SaveToStream(Stream: TStream); override;
procedure SetSize(AWidth, AHeight, ABitCount: Integer); {$IFDEF VER5UP}reintroduce;{$ENDIF} //{$IFDEF VER9UP} overload;{$ENDIF}
procedure SetSize(AWidth, AHeight, ABitCount: Integer);
procedure UpdatePalette;
{ Special effect }
procedure Blur(ABitCount: Integer; Radius: Integer);
procedure Greyscale(ABitCount: Integer);
procedure Mirror(MirrorX, MirrorY: Boolean);
procedure Negative; {$IFDEF VER9UP}inline;{$ENDIF}
procedure Negative;
 
{ Added New Special Effect }
procedure Spray(Amount: Integer);
procedure Emboss;
procedure AddMonoNoise(Amount: Integer);
procedure AddGradiantNoise(Amount: byte);
function Twist(bmp: TDIB; Amount: byte): Boolean;
function FishEye(bmp: TDIB): Boolean;
function SmoothRotateWrap(Bmp: TDIB; cx, cy: Integer; Degree: Extended): Boolean;
procedure Lightness(Amount: Integer);
procedure Saturation(Amount: Integer);
procedure Contrast(Amount: Integer);
procedure AddRGB(aR, aG, aB: Byte);
function Filter(Dest: TDIB; Filter: TFilter): Boolean;
procedure Sharpen(Amount: Integer);
function IntToColor(i: Integer): TBGR; {$IFDEF VER9UP}inline;{$ENDIF}
function Rotate(Dst: TDIB; cx, cy: Integer; Angle: Double): Boolean;
procedure SplitBlur(Amount: Integer);
procedure GaussianBlur(Bmp: TDIB; Amount: Integer);
{ End of New Special Effect }
{
New effect for TDIB
with Some Effects like AntiAlias, Contrast,
Lightness, Saturation, GaussianBlur, Mosaic,
Twist, Splitlight, Trace, Emboss, etc.
Works with 24bit color DIBs.
 
This component is based on TProEffectImage component version 1.0 by
Written By Babak Sateli (babak_sateli@yahoo.com, http://raveland.netfirms.com)
 
and modified by (c) 2004 Jaro Benes
for DelphiX use.
 
Demo was modified into DXForm with function like original
 
DISCLAIMER
This component is provided AS-IS without any warranty of any kind, either express or
implied. This component is freeware and can be used in any software product.
}
procedure DoInvert;
procedure DoAddColorNoise(Amount: Integer);
procedure DoAddMonoNoise(Amount: Integer);
procedure DoAntiAlias;
procedure DoContrast(Amount: Integer);
procedure DoFishEye(Amount: Integer);
procedure DoGrayScale;
procedure DoLightness(Amount: Integer);
procedure DoDarkness(Amount: Integer);
procedure DoSaturation(Amount: Integer);
procedure DoSplitBlur(Amount: Integer);
procedure DoGaussianBlur(Amount: Integer);
procedure DoMosaic(Size: Integer);
procedure DoTwist(Amount: Integer);
procedure DoSplitlight(Amount: Integer);
procedure DoTile(Amount: Integer);
procedure DoSpotLight(Amount: Integer; Spot: TRect);
procedure DoTrace(Amount: Integer);
procedure DoEmboss;
procedure DoSolorize(Amount: Integer);
procedure DoPosterize(Amount: Integer);
procedure DoBrightness(Amount: Integer);
procedure DoResample(AmountX, AmountY: Integer; TypeResample: TFilterTypeResample);
{rotate}
procedure DoSmoothRotate(Src: TDIB; cx, cy: Integer; Angle: Extended);
procedure DoColorize(ForeColor, BackColor: TColor);
{Simple explosion spoke effect}
procedure DoNovaEffect(const sr, sg, sb, cx, cy, radius,
nspokes, randomhue, randomspok, randgauss: Integer; onProgress: TProgressEvent);
 
{Simple Mandelbrot-set drawing}
procedure DrawMandelbrot(ao, au: Integer; bo, bu: Double);
 
{Sephia effect}
procedure SephiaEffect(Depth: Integer{$IFDEF VER4UP} = 20{$ENDIF});
 
{Simple blend pixel}
procedure BlendPixel(const X, Y: Integer; aColor: Cardinal; Alpha: Byte); {$IFDEF VER9UP}inline;{$ENDIF}
{Line in polar system}
procedure LinePolar(x, y: Integer; AngleInDegree, Length: extended;
Color: cardinal);
 
{special version Dark/Light procedure in percent}
procedure Darker(Percent: Integer);
procedure Lighter(Percent: Integer);
 
{Simple graphical crypt}
procedure EncryptDecrypt(const Key: Integer);
 
{ Standalone DXFusion }
{--- c o n F u s i o n ---}
{By Joakim Back, www.back.mine.nu}
{Huge thanks to Ilkka Tuomioja for helping out with the project.}
 
{
modified by (c) 2005 Jaro Benes for DelphiX use.
}
 
procedure CreateDIBFromBitmap(const Bitmap: TBitmap);
{Drawing Methods.}
procedure DrawOn(Dest: TRect; DestCanvas: TCanvas;
Xsrc, Ysrc: Integer);
procedure DrawTo(SrcDIB: TDIB; X, Y, Width, Height, SourceX,
SourceY: Integer);
procedure DrawTransparent(SrcDIB: TDIB; const X, Y, Width, Height,
SourceX, SourceY: Integer; const Color: TColor); {$IFDEF VER5UP} reintroduce;{$ENDIF} //{$IFDEF VER9UP} overload;{$ENDIF}
procedure DrawShadow(SrcDIB: TDIB; X, Y, Width, Height, Frame: Integer;
FilterMode: TFilterMode);
procedure DrawShadows(SrcDIB: TDIB; X, Y, Width, Height, Frame: Integer;
Alpha: Byte);
procedure DrawDarken(SrcDIB: TDIB; X, Y, Width, Height,
Frame: Integer);
procedure DrawAdditive(SrcDIB: TDIB; X, Y, Width, Height: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF};
Frame: Integer{$IFDEF VER4UP} = 0{$ENDIF});
procedure DrawQuickAlpha(SrcDIB: TDIB; const X, Y, Width, Height,
SourceX, SourceY: Integer; const Color: TColor;
FilterMode: TFilterMode);
procedure DrawTranslucent(SrcDIB: TDIB; const X, Y, Width, Height,
SourceX, SourceY: Integer; const Color: TColor);
procedure DrawMorphed(SrcDIB: TDIB; const X, Y, Width, Height, SourceX,
SourceY: Integer; const Color: TColor);
procedure DrawAlpha(SrcDIB: TDIB; const X, Y, Width, Height, SourceX,
SourceY, Alpha: Integer; const Color: TColor);
procedure DrawAlphaMask(SrcDIB, MaskDIB: TDIB; const X, Y, Width,
Height, SourceX, SourceY: Integer);
procedure DrawAntialias(SrcDIB: TDIB);
procedure Draw3x3Matrix(SrcDIB: TDIB; Setting: TMatrixSetting);
procedure DrawMono(SrcDIB: TDIB; const X, Y, Width, Height, SourceX,
SourceY: Integer; const TransColor, ForeColor, BackColor: TColor);
{One-color Filters.}
procedure FilterLine(X1, Y1, X2, Y2: Integer; Color: TColor;
FilterMode: TFilterMode); {$IFDEF VER9UP}inline;{$ENDIF}
procedure FilterRect(X, Y, Width, Height: Integer; Color: TColor;
FilterMode: TFilterMode); {$IFDEF VER9UP}inline;{$ENDIF}
{ Lightsource. }
procedure InitLight(Count, Detail: Integer);
procedure DrawLights(FLight: TLightArray; AmbientLight: TColor);
//
// effect for special purpose
//
procedure FadeOut(DIB2: TDIB; Step: Byte); {$IFDEF VER9UP} inline; {$ENDIF}
procedure DoZoom(DIB2: TDIB; ZoomRatio: Real);
procedure DoBlur(DIB2: TDIB);
procedure FadeIn(DIB2: TDIB; Step: Byte); {$IFDEF VER9UP} inline; {$ENDIF}
procedure FillDIB8(Color: Byte); {$IFDEF VER9UP} inline; {$ENDIF}
procedure DoRotate(DIB1: TDIB; cX, cY, Angle: Integer);
procedure Distort(DIB1: TDIB; dt: TDistortType; cX, cY, Angle: Integer; Factor: Real);
function Ink(DIB: TDIB; const SprayInit: Boolean; const AmountSpray: Integer): Boolean;
// lines
procedure AntialiasedLine(x1, y1, x2, y2: Integer; color: TColor); {$IFDEF VER9UP} inline; {$ENDIF}
function GetColorBetween(StartColor, EndColor: TColor; Pointvalue,
FromPoint, ToPoint: Extended): TColor;
procedure ColoredLine(const iStart, iEnd: TPoint; iColorStyle: TColorLineStyle;
iGradientFrom, iGradientTo: TColor; iPixelGeometry: TColorLinePixelGeometry;
iRadius: WORD);
// standard property
property BitCount: Integer read FBitCount write SetBitCount;
property BitmapInfo: PBitmapInfo read GetBitmapInfo;
property BitmapInfoSize: Integer read GetBitmapInfoSize;
427,15 → 174,8
property TopPBitsReadOnly: Pointer read GetTopPBitsReadOnly;
property Width: Integer read FWidth write SetWidth;
property WidthBytes: Integer read FWidthBytes;
property AlphaChannel: TDIB read GetAlphaChannel write SetAlphaChannel;
property RGBChannel: TDIB read GetRGBChannel write SetRGBChannel;
function CreateBitmapFromDIB: TBitmap;
procedure Fill(aColor: TColor);
property ClientRect: TRect read GetClientRect;
end;
 
{ TDIBitmap }
 
TDIBitmap = class(TDIB) end;
 
{ TCustomDXDIB }
495,10 → 235,10
 
TDXPaintBox = class(TCustomDXPaintBox)
published
{$IFDEF VER4UP}property Anchors; {$ENDIF}
{$IFDEF DelphiX_Spt4}property Anchors;{$ENDIF}
property AutoStretch;
property Center;
{$IFDEF VER4UP}property Constraints; {$ENDIF}
{$IFDEF DelphiX_Spt4}property Constraints;{$ENDIF}
property DIB;
property KeepAspect;
property Stretch;
521,140 → 261,34
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
{$IFDEF VER9UP}property OnMouseWheel; {$ENDIF}
{$IFDEF VER9UP}property OnResize; {$ENDIF}
{$IFDEF VER9UP}property OnCanResize; {$ENDIF}
{$IFDEF VER9UP}property OnContextPopup; {$ENDIF}
property OnStartDrag;
end;
 
const
DefaultFilterRadius: array[TFilterTypeResample] of Single = (0.5, 1, 1, 1.5, 2, 3, 2);
function MakeDIBPixelFormat(RBitCount, GBitCount, BBitCount: Integer): TDIBPixelFormat;
function MakeDIBPixelFormatMask(RBitMask, GBitMask, BBitMask: Integer): TDIBPixelFormat;
function pfRGB(const PixelFormat: TDIBPixelFormat; R, G, B: Byte): DWORD;
procedure pfGetRGB(const PixelFormat: TDIBPixelFormat; Color: DWORD; var R, G, B: Byte);
function pfGetRValue(const PixelFormat: TDIBPixelFormat; Color: DWORD): Byte;
function pfGetGValue(const PixelFormat: TDIBPixelFormat; Color: DWORD): Byte;
function pfGetBValue(const PixelFormat: TDIBPixelFormat; Color: DWORD): Byte;
 
function MakeDIBPixelFormat(RBitCount, GBitCount, BBitCount: Integer): TDIBPixelFormat; {$IFDEF VER9UP}inline;{$ENDIF}
function MakeDIBPixelFormatMask(RBitMask, GBitMask, BBitMask: Integer): TDIBPixelFormat; {$IFDEF VER9UP}inline;{$ENDIF}
function pfRGB(const PixelFormat: TDIBPixelFormat; R, G, B: Byte): DWORD; {$IFDEF VER9UP}inline;{$ENDIF}
procedure pfGetRGB(const PixelFormat: TDIBPixelFormat; Color: DWORD; var R, G, B: Byte); {$IFDEF VER9UP}inline;{$ENDIF}
function pfGetRValue(const PixelFormat: TDIBPixelFormat; Color: DWORD): Byte; {$IFDEF VER9UP}inline;{$ENDIF}
function pfGetGValue(const PixelFormat: TDIBPixelFormat; Color: DWORD): Byte; {$IFDEF VER9UP}inline;{$ENDIF}
function pfGetBValue(const PixelFormat: TDIBPixelFormat; Color: DWORD): Byte; {$IFDEF VER9UP}inline;{$ENDIF}
 
function GreyscaleColorTable: TRGBQuads;
 
function RGBQuad(R, G, B: Byte): TRGBQuad; {$IFDEF VER9UP}inline;{$ENDIF}
function PaletteEntryToRGBQuad(const Entry: TPaletteEntry): TRGBQuad; {$IFDEF VER9UP}inline;{$ENDIF}
function PaletteEntriesToRGBQuads(const Entries: TPaletteEntries): TRGBQuads; {$IFDEF VER9UP}inline;{$ENDIF}
function RGBQuadToPaletteEntry(const RGBQuad: TRGBQuad): TPaletteEntry; {$IFDEF VER9UP}inline;{$ENDIF}
function RGBQuadsToPaletteEntries(const RGBQuads: TRGBQuads): TPaletteEntries; {$IFDEF VER9UP}inline;{$ENDIF}
function RGBQuad(R, G, B: Byte): TRGBQuad;
function PaletteEntryToRGBQuad(const Entry: TPaletteEntry): TRGBQuad;
function PaletteEntriesToRGBQuads(const Entries: TPaletteEntries): TRGBQuads;
function RGBQuadToPaletteEntry(const RGBQuad: TRGBQuad): TPaletteEntry;
function RGBQuadsToPaletteEntries(const RGBQuads: TRGBQuads): TPaletteEntries;
 
function PosValue(Value: Integer): Integer;
 
type
TOC = 0..511;
function DSin(const C: TOC): Single; {$IFDEF VER9UP}inline; {$ENDIF}
function DCos(const C: TOC): Single; {$IFDEF VER9UP}inline; {$ENDIF}
 
{ Added Constants for TFilter Type }
const
EdgeFilter: TFilter = ((-1, -1, -1), (-1, 8, -1), (-1, -1, -1));
StrongOutlineFilter: TFilter = ((-100, 0, 0), (0, 0, 0), (0, 0, 100));
Enhance3DFilter: TFilter = ((-100, 5, 5), (5, 5, 5), (5, 5, 100));
LinearFilter: TFilter = ((-40, -40, -40), (-40, 255, -40), (-40, -40, -40));
GranularFilter: TFilter = ((-20, 5, 20), (5, -10, 5), (100, 5, -100));
SharpFilter: TFilter = ((-2, -2, -2), (-2, 20, -2), (-2, -2, -2));
{ End of constants }
 
{ Added Constants for DXFusion Type }
const
{ 3x3 Matrix Presets. }
msEmboss: TMatrixSetting = (-1, -1, 0, -1, 6, 1, 0, 1, 1, 6);
msHardEmboss: TMatrixSetting = (-4, -2, -1, -2, 10, 2, -1, 2, 4, 8);
msBlur: TMatrixSetting = (1, 2, 1, 2, 4, 2, 1, 2, 1, 16);
msSharpen: TMatrixSetting = (-1, -1, -1, -1, 15, -1, -1, -1, -1, 7);
msEdgeDetect: TMatrixSetting = (-1, -1, -1, -1, 8, -1, -1, -1, -1, 1);
 
{Proportionaly scale of size, for recountin image sizes}
function GetScale(SourceWidth, SourceHeight, TargetWidth, TargetHeight: Integer): Single; {$IFDEF VER9UP}inline;{$ENDIF}
 
procedure MakeDib(out DIB: TDIB; const iWidth, iHeight, iBitCount: Integer; iFillColor: TColor{$IFDEF VER4UP} = clBlack{$ENDIF}); {$IFDEF VER4UP}overload; {$ENDIF}
procedure{$IFDEF VER4UP}MakeDib{$ELSE}MakeDIB2{$ENDIF}(out DIB: TDIB; iBitmap: TBitmap); {$IFDEF VER4UP}overload; {$ENDIF}
procedure MakeDIB32MaskByColor(var D: TDIB; const MaskColor: TColor{$IFDEF VER4UP} = clWhite{$ENDIF});
 
function BGR(B, G, R: Byte): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
 
implementation
 
uses DXConsts, {$IFDEF PNG_GRAPHICS}pngimage,{$ENDIF} jpeg;
uses DXConsts;
 
function BGR(B, G, R: Byte): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
begin
Result := (B shl 16) or (G shl 8) or R;
end;
 
procedure MakeDIB32MaskByColor(var D: TDIB; const MaskColor: TColor{$IFDEF VER4UP} = clWhite{$ENDIF});
type
PRGBA = ^TRGBA;
TRGBA = array[0..0] of Windows.TRGBQuad;
var
p: PRGBA;
y: Integer;
x: Integer;
B: TDIB;
begin
MakeDib(B, D.Width, D.Height, 32, $FFFFFF);
B.RGBChannel := D.RGBChannel;
if B.BitCount = 32 then
for Y := 0 to B.Height - 1 do
begin
p := B.ScanLine[Y];
for X := 0 to B.Width - 1 do
begin
if (p[X].rgbBlue = GetBValue(MaskColor)) and (p[X].rgbGreen = GetGValue(MaskColor)) and (p[X].rgbRed = GetRValue(MaskColor)) then
p[X].rgbReserved := 0
else
p[X].rgbReserved := $FF
end
end;
d.Assign(B);
end;
 
function GetScale(SourceWidth, SourceHeight, TargetWidth, TargetHeight: Integer): Single;
var
XScale, YScale: Single;
begin
XScale := 1;
YScale := 1;
if TargetWidth < SourceWidth then
XScale := TargetWidth / SourceWidth;
if TargetHeight < SourceHeight then
YScale := TargetHeight / SourceHeight;
Result := XScale;
if YScale < Result then
Result := YScale;
end;
 
{$IFNDEF VER4UP}
function Max(B1, B2: Integer): Integer;
begin
if B1 >= B2 then Result := B1 else Result := B2;
end;
 
function Min(B1, B2: Integer): Integer;
begin
if B1 <= B2 then Result := B1 else Result := B2;
end;
{$ENDIF}
 
function DSin(const C: TOC): Single; {$IFDEF VER9UP}inline; {$ENDIF}
begin
Result := sin(((c * 360) / 511) * Pi / 180);
end;
 
function DCos(const C: TOC): Single; {$IFDEF VER9UP}inline; {$ENDIF}
begin
Result := cos(((c * 360) / 511) * Pi / 180);
end;
 
function MakeDIBPixelFormat(RBitCount, GBitCount, BBitCount: Integer): TDIBPixelFormat;
begin
Result.RBitMask := ((1 shl RBitCount) - 1) shl (GBitCount + BBitCount);
671,7 → 305,9
Result.BShift := 8 - BBitCount;
end;
 
function GetBitCount(b: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
function MakeDIBPixelFormatMask(RBitMask, GBitMask, BBitMask: Integer): TDIBPixelFormat;
 
function GetBitCount(b: Integer): Integer;
var
i: Integer;
begin
686,7 → 322,6
end;
end;
 
function MakeDIBPixelFormatMask(RBitMask, GBitMask, BBitMask: Integer): TDIBPixelFormat;
begin
Result := MakeDIBPixelFormat(GetBitCount(RBitMask), GetBitCount(GBitMask),
GetBitCount(BBitMask));
717,7 → 352,7
with PixelFormat do
begin
Result := (Color and RBitMask) shr RShift;
Result := Result or (Result shr RBitCount2);
Result := Result or (Result shr RBitCount);
end;
end;
 
726,7 → 361,7
with PixelFormat do
begin
Result := (Color and GBitMask) shr GShift;
Result := Result or (Result shr GBitCount2);
Result := Result or (Result shr GBitCount);
end;
end;
 
735,7 → 370,7
with PixelFormat do
begin
Result := (Color and BBitMask) shl BShift;
Result := Result or (Result shr BBitCount2);
Result := Result or (Result shr BBitCount);
end;
end;
 
812,8 → 447,6
RBitMask, GBitMask, BBitMask: DWORD;
end;
 
{ TPaletteItem }
 
TPaletteItem = class(TCollectionItem)
private
ID: Integer;
823,11 → 456,9
ColorTableCount: Integer;
destructor Destroy; override;
procedure AddRef;
procedure Release; {$IFDEF VER17UP}reintroduce;{$ENDIF}
procedure Release;
end;
 
{ TPaletteManager }
 
TPaletteManager = class
private
FList: TCollection;
837,8 → 468,6
procedure DeletePalette(var Palette: HPalette);
end;
 
{ TPaletteItem }
 
destructor TPaletteItem.Destroy;
begin
DeleteObject(Palette);
856,8 → 485,6
if RefCount <= 0 then Free;
end;
 
{ TPaletteManager }
 
constructor TPaletteManager.Create;
begin
inherited Create;
950,8 → 577,6
Result := FPaletteManager;
end;
 
{ TDIBSharedImage }
 
constructor TDIBSharedImage.Create;
begin
inherited Create;
967,10 → 592,8
InfoOfs: Integer;
UsePixelFormat: Boolean;
begin
{$IFNDEF D17UP}
{self recreation is not allowed here}
Create;
{$ENDIF}
 
{ Pixel format check }
case ABitCount of
1: if not ((PixelFormat.RBitMask = $FF0000) and (PixelFormat.GBitMask = $00FF00) and (PixelFormat.BBitMask = $0000FF)) then
979,19 → 602,16
raise EInvalidGraphicOperation.Create(SInvalidDIBPixelFormat);
8: if not ((PixelFormat.RBitMask = $FF0000) and (PixelFormat.GBitMask = $00FF00) and (PixelFormat.BBitMask = $0000FF)) then
raise EInvalidGraphicOperation.Create(SInvalidDIBPixelFormat);
16:
begin
16: begin
if not (((PixelFormat.RBitMask = $7C00) and (PixelFormat.GBitMask = $03E0) and (PixelFormat.BBitMask = $001F)) or
((PixelFormat.RBitMask = $F800) and (PixelFormat.GBitMask = $07E0) and (PixelFormat.BBitMask = $001F))) then
raise EInvalidGraphicOperation.Create(SInvalidDIBPixelFormat);
end;
24:
begin
24: begin
if not ((PixelFormat.RBitMask = $FF0000) and (PixelFormat.GBitMask = $00FF00) and (PixelFormat.BBitMask = $0000FF)) then
raise EInvalidGraphicOperation.Create(SInvalidDIBPixelFormat);
end;
32:
begin
32: begin
if not ((PixelFormat.RBitMask = $FF0000) and (PixelFormat.GBitMask = $00FF00) and (PixelFormat.BBitMask = $0000FF)) then
raise EInvalidGraphicOperation.Create(SInvalidDIBPixelFormat);
end;
1033,13 → 653,11
biCompression := BI_BITFIELDS
else
begin
biCompression := 0; //none
if (FBitCount = 4) and (Compressed) then
biCompression := BI_RLE4
else if (FBitCount = 8) and (Compressed) then
biCompression := BI_RLE8
else
if FBitCount = 24 then
biCompression := BI_RGB;
end;
biSizeImage := FSize;
1078,8 → 696,7
FPBits := Pointer(GlobalAlloc(GMEM_FIXED, FSize));
if FPBits = nil then
OutOfMemoryError;
end
else
end else
begin
FDC := CreateCompatibleDC(0);
 
1096,17 → 713,11
 
procedure TDIBSharedImage.Duplicate(Source: TDIBSharedImage; MemoryImage: Boolean);
begin
if Source = nil then Exit; //no source
if Source.FSize = 0 then
begin
{$IFNDEF D17UP}
{self recreation is not allowed here}
Create;
{$ENDIF}
FMemoryImage := MemoryImage;
end
else
end else
begin
NewImage(Source.FWidth, Source.FHeight, Source.FBitCount,
Source.FPixelFormat, Source.FColorTable, MemoryImage, Source.FCompressed);
1115,8 → 726,7
FBitmapInfo.bmiHeader.biSizeImage := Source.FBitmapInfo.bmiHeader.biSizeImage;
GetMem(FPBits, FBitmapInfo.bmiHeader.biSizeImage);
Move(Source.FPBits^, FPBits^, FBitmapInfo.bmiHeader.biSizeImage);
end
else
end else
begin
Move(Source.FPBits^, FPBits^, FBitmapInfo.bmiHeader.biSizeImage);
end;
1179,8 → 789,7
 
AllocByte^ := B1;
AllocByte^ := B2;
end
else
end else
if (Source.FWidth - x > 5) and ((GetPixel(x) <> GetPixel(x + 2)) or (GetPixel(x + 1) <> GetPixel(x + 3))) and
((GetPixel(x + 2) = GetPixel(x + 4)) and (GetPixel(x + 3) = GetPixel(x + 5))) then
begin
1188,8 → 797,7
AllocByte^ := 2;
AllocByte^ := (GetPixel(x) shl 4) or GetPixel(x + 1);
Inc(x, 2);
end
else
end else
begin
if (Source.FWidth - x < 4) then
begin
1207,8 → 815,7
AllocByte^ := GetPixel(x) shl 4;
Inc(x);
end;
end
else
end else
begin
{ Absolute mode }
PB1 := Size; AllocByte;
1297,8 → 904,7
 
AllocByte^ := B1;
AllocByte^ := B2;
end
else
end else
if (Source.FWidth - x > 2) and (Src^ <> PByte(Integer(Src) + 1)^) and (PByte(Integer(Src) + 1)^ = PByte(Integer(Src) + 2)^) then
begin
{ Encoding mode }
1305,8 → 911,7
AllocByte^ := 1;
AllocByte^ := Src^; Inc(Src);
Inc(x);
end
else
end else
begin
if (Source.FWidth - x < 4) then
begin
1319,15 → 924,13
AllocByte^ := 1;
AllocByte^ := Src^; Inc(Src);
Inc(x, 2);
end
else
end else
begin
AllocByte^ := 1;
AllocByte^ := Src^; Inc(Src);
Inc(x);
end;
end
else
end else
begin
{ Absolute mode }
PB1 := Size; AllocByte;
1376,8 → 979,7
begin
if Source.FCompressed then
Duplicate(Source, Source.FMemoryImage)
else
begin
else begin
NewImage(Source.FWidth, Source.FHeight, Source.FBitCount,
Source.FPixelFormat, Source.FColorTable, True, True);
case FBitmapInfo.bmiHeader.biCompression of
1428,8 → 1030,7
if i and 1 = 0 then
begin
C := Src^; Inc(Src);
end
else
end else
begin
C := C shl 4;
end;
1443,8 → 1044,7
Inc(X);
end;
end;
end
else
end else
begin
{ Encoding mode }
Dest := Pointer(Longint(FPBits) + Y * FWidthBytes);
1501,8 → 1101,7
{ Absolute mode }
Move(Src^, Dest^, B2); Inc(Dest, B2); Inc(Src, B2);
end;
end
else
end else
begin
{ Encoding mode }
FillChar(Dest^, B1, B2); Inc(Dest, B1);
1516,8 → 1115,7
begin
if not Source.FCompressed then
Duplicate(Source, MemoryImage)
else
begin
else begin
NewImage(Source.FWidth, Source.FHeight, Source.FBitCount,
Source.FPixelFormat, Source.FColorTable, MemoryImage, False);
case Source.FBitmapInfo.bmiHeader.biCompression of
1538,7 → 1136,6
procedure LoadRLE4;
begin
FSize := BI.biSizeImage;
//GetMem(FPBits, FSize);
FPBits := GlobalAllocPtr(GMEM_FIXED, FSize);
FBitmapInfo.bmiHeader.biSizeImage := FSize;
Stream.ReadBuffer(FPBits^, FSize);
1547,7 → 1144,6
procedure LoadRLE8;
begin
FSize := BI.biSizeImage;
//GetMem(FPBits, FSize);
FPBits := GlobalAllocPtr(GMEM_FIXED, FSize);
FBitmapInfo.bmiHeader.biSizeImage := FSize;
Stream.ReadBuffer(FPBits^, FSize);
1561,8 → 1157,7
begin
for y := 0 to Abs(BI.biHeight) - 1 do
Stream.ReadBuffer(Pointer(Integer(FTopPBits) + y * FNextLine)^, FWidthBytes);
end
else
end else
begin
Stream.ReadBuffer(FPBits^, FSize);
end;
1575,17 → 1170,12
AColorTable: TRGBQuads;
APixelFormat: TDIBPixelFormat;
begin
if not Assigned(Stream) then Exit;
{ Header size reading }
i := Stream.Read(BI.biSize, 4);
 
if i = 0 then
begin
{$IFNDEF D17UP}
{self recreation is not allowed here}
Create;
{$ENDIF}
Exit;
end;
if i <> 4 then
1626,8 → 1216,7
Stream.ReadBuffer(Localpf, SizeOf(Localpf));
with Localpf do
APixelFormat := MakeDIBPixelFormatMask(RBitMask, GBitMask, BBitMask);
end
else
end else
begin
if BI.biBitCount = 16 then
APixelFormat := MakeDIBPixelFormat(5, 5, 5)
1654,14 → 1243,13
with BCRGB[i] do
AColorTable[i] := RGBQuad(rgbtRed, rgbtGreen, rgbtBlue);
end;
end
else
end else
begin
{ Windows type }
Stream.ReadBuffer(AColorTable, SizeOf(TRGBQuad) * PalCount);
end;
 
{ DIB compilation }
{ DIB ì¬ }
NewImage(BI.biWidth, Abs(BI.biHeight), BI.biBitCount, APixelFormat, AColorTable,
MemoryImage, BI.biCompression in [BI_RLE4, BI_RLE8]);
 
1682,9 → 1270,7
begin
if FOldHandle <> 0 then SelectObject(FDC, FOldHandle);
DeleteObject(FHandle);
end
else
// GlobalFree(THandle(FPBits));
end else
begin
if FPBits <> nil then
GlobalFreePtr(FPBits);
1747,28 → 1333,12
begin
inherited Create;
SetImage(EmptyDIBImage);
 
FFreeList := TList.Create;
end;
 
destructor TDIB.Destroy;
var
D: TDIB;
begin
SetImage(EmptyDIBImage);
FCanvas.Free;
 
while FFreeList.Count > 0 do
try
D := TDIB(FFreeList[0]);
FFreeList.Remove(D);
if (D <> nil) and (D.Height > 0) and (D.Width > 0) then //is really pointed to image?
D.Free;
except
// it is silent exception, but it can through outer (abstract) exception
end;
FFreeList.Free;
 
inherited Destroy;
end;
 
1802,14 → 1372,12
if DIBSectionRec^.dsBm.bmBitsPixel >= 24 then
begin
PixelFormat := MakeDIBPixelFormat(8, 8, 8);
end
else
end else
if DIBSectionRec^.dsBm.bmBitsPixel > 8 then
begin
PixelFormat := MakeDIBPixelFormatMask(DIBSectionRec^.dsBitfields[0], //correct I.Ceneff, thanks
PixelFormat := MakeDIBPixelFormat(DIBSectionRec^.dsBitfields[0],
DIBSectionRec^.dsBitfields[1], DIBSectionRec^.dsBitfields[2]);
end
else
end else
begin
PixelFormat := MakeDIBPixelFormat(8, 8, 8);
end;
1825,64 → 1393,14
end;
 
procedure AssignGraphic(Source: TGraphic);
{$IFDEF PNG_GRAPHICS}
var
alpha: TDIB;
png: {$IFDEF VER12UP}TPngImage{$ELSE}TPNGObject{$ENDIF};
i, j: Integer;
q: pByteArray;
{$ENDIF}
begin
{$IFDEF PNG_GRAPHICS}
if Source is {$IFDEF VER12UP}TPngImage{$ELSE}TPNGObject{$ENDIF} then
begin
alpha := TDIB.Create;
try
{png image}
png := {$IFDEF VER12UP}TPngImage{$ELSE}TPNGObject{$ENDIF}.Create;
try
png.Assign(Source);
if png.TransparencyMode = ptmPartial then
begin
Alpha.SetSize(png.Width, png.Height, 8);
{separate alpha}
for i := 0 to png.Height - 1 do
begin
q := png.AlphaScanline[i];
for j := 0 to png.Width - 1 do
alpha.Pixels[j,i] := q[j];
end;
end;
SetSize(png.Width, png.Height, 32);
FillChar(PBits^, Size, 0);
Canvas.Draw(0, 0, png);
Transparent := png.Transparent;
finally
png.Free;
end;
if not alpha.Empty then
AssignAlphaChannel(alpha);
finally
alpha.Free;
end;
end
else
{$ENDIF}
if Source is TBitmap then
AssignBitmap(TBitmap(Source))
else
begin
SetSize(Source.Width, Source.Height, 32);
FillChar(PBits^, Size, 0);
Canvas.Draw(0, 0, Source);
Transparent := Source.Transparent;
if not HasAlphaChannel then
begin
SetSize(Source.Width, Source.Height, 24);
FillChar(PBits^, Size, 0);
Canvas.Draw(0, 0, Source);
Transparent := Source.Transparent;
end
end;
end;
 
1907,7 → 1425,7
inherited Assign(Source);
end;
 
procedure TDIB.Draw(ACanvas: TCanvas; const ARect: TRect);
procedure TDIB.Draw(ACanvas: TCanvas; const Rect: TRect);
var
OldPalette: HPalette;
OldMode: Integer;
1918,8 → 1436,7
begin
OldPalette := SelectPalette(ACanvas.Handle, Palette, False);
RealizePalette(ACanvas.Handle);
end
else
end else
OldPalette := 0;
try
OldMode := SetStretchBltMode(ACanvas.Handle, COLORONCOLOR);
1927,18 → 1444,14
GdiFlush;
if FImage.FMemoryImage then
begin
with ARect do
with Rect do
StretchDIBits(ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
0, 0, Width, Height, FImage.FPBits, FImage.FBitmapInfo^, DIB_RGB_COLORS , ACanvas.CopyMode);
end else
begin
if StretchDIBits(ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
0, 0, Self.Width, Self.Height, FImage.FPBits, FImage.FBitmapInfo^, DIB_RGB_COLORS, ACanvas.CopyMode) = 0 then
MessageBeep(1);
end;
end
else
begin
with ARect do
with Rect do
StretchBlt(ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
FImage.FDC, 0, 0, Self.Width, Self.Height, ACanvas.CopyMode);
FImage.FDC, 0, 0, Width, Height, ACanvas.CopyMode);
end;
finally
SetStretchBltMode(ACanvas.Handle, OldMode);
2044,161 → 1557,6
end;
end;
 
type
PRGBA = ^TRGBA;
TRGBA = array[0..0] of Windows.TRGBQuad;
 
function TDIB.HasAlphaChannel: Boolean;
{give that DIB contain the alphachannel}
var
p: PRGBA;
X, Y: Integer;
begin
Result := True;
if BitCount = 32 then
for Y := 0 to Height - 1 do
begin
p := ScanLine[Y];
for X := 0 to Width - 1 do
begin
if p[X].rgbReserved <> $0 then Exit;
end
end;
Result := False;
end;
 
function TDIB.AssignAlphaChannel(ALPHA: TDIB; ForceResize: Boolean{$IFDEF VER4UP} = False{$ENDIF}): Boolean;
{copy alphachannel from other DIB or add from DIB8}
var
p32_0, p32_1: PRGBA;
p24: Pointer;
pB: PArrayByte;
X, Y: Integer;
tmpDIB, qAlpha: TDIB;
begin
Result := False;
if GetEmpty then Exit;
{Alphachannel can be copy into 32bit DIB only!}
if BitCount <> 32 then
begin
tmpDIB := TDIB.Create;
try
tmpDIB.Assign(Self);
Clear;
SetSize(tmpDIB.Width, tmpDIB.Height, 32);
Canvas.Draw(0, 0, tmpDIB);
finally
tmpDIB.Free;
end;
end;
qAlpha := TDIB.Create;
try
if not Assigned(Alpha) then Exit;
if ForceResize then
begin
{create temp}
tmpDIB := TDIB.Create;
try
{picture}
tmpDIB.Assign(ALPHA);
{resample size}
tmpDIB.DoResample(Width, Height, ftrBSpline);
{convert to greyscale}
tmpDIB.Greyscale(8);
{return picture to qAlpha}
qAlpha.Assign(tmpDIB);
finally
tmpDIB.Free;
end;
end
else
{Must be the same size!}
if not ((Width = ALPHA.Width) and (Height = ALPHA.Height)) then Exit
else qAlpha.Assign(ALPHA);
{It works now with qAlpha only}
case qAlpha.BitCount of
24:
begin
for Y := 0 to Height - 1 do
begin
p32_0 := ScanLine[Y];
p24 := qAlpha.ScanLine[Y];
for X := 0 to Width - 1 do with PBGR(p24)^ do
begin
p32_0[X].rgbReserved := Round(0.30 * R + 0.59 * G + 0.11 * B);
end
end;
end;
32:
begin
for Y := 0 to Height - 1 do
begin
p32_0 := ScanLine[Y];
p32_1 := qAlpha.ScanLine[Y];
for X := 0 to Width - 1 do
begin
p32_0[X].rgbReserved := p32_1[X].rgbReserved;
end
end;
end;
8:
begin
for Y := 0 to Height - 1 do
begin
p32_0 := ScanLine[Y];
pB := qAlpha.ScanLine[Y];
for X := 0 to Width - 1 do
begin
p32_0[X].rgbReserved := pB[X];
end
end;
end;
1:
begin
for Y := 0 to Height - 1 do
begin
p32_0 := ScanLine[Y];
pB := qAlpha.ScanLine[Y];
for X := 0 to Width - 1 do
begin
if pB[X] = 0 then
p32_0[X].rgbReserved := $FF
else
p32_0[X].rgbReserved := 0
end
end;
end;
else
Exit;
end;
Result := True;
finally
qAlpha.Free;
end;
end;
 
procedure TDIB.RetAlphaChannel(out oDIB: TDIB);
{Store alphachannel information into DIB8}
var
p0: PRGBA;
pB: PArrayByte;
X, Y: Integer;
begin
oDIB := nil;
if not HasAlphaChannel then Exit;
oDIB := TDIB.Create;
oDIB.SetSize(Width, Height, 8);
for Y := 0 to Height - 1 do
begin
p0 := ScanLine[Y];
pB := oDIB.ScanLine[Y];
for X := 0 to Width - 1 do
begin
pB[X] := p0[X].rgbReserved;
end
end;
end;
 
function TDIB.GetBitmapInfo: PBitmapInfo;
begin
Result := FImage.FBitmapInfo;
2285,13 → 1643,6
Result := Pointer(Integer(FTopPBits) + Y * FNextLine);
end;
 
{$IFDEF VER16UP}
function TDIB.GetSupportsPartialTransparency: Boolean;
begin
Result := (FBitCount = 32) and HasAlphaChannel;
end;
{$ENDIF}
 
function TDIB.GetTopPBits: Pointer;
begin
Changing(True);
2308,11 → 1659,6
Result := FTopPBits;
end;
 
function TDIB.GetTransparent: Boolean;
begin
Result := (FBitCount = 32) and HasAlphaChannel;
end;
 
function TDIB.GetWidth: Integer;
begin
Result := FWidth;
2337,7 → 1683,7
begin
case FBitCount of
1: Result := (PArrayByte(Integer(FTopPBits) + Y * FNextLine)[X shr 3] and Mask1[X and 7]) shr Shift1[X and 7];
4: Result := ((PArrayByte(Integer(FTopPBits) + Y * FNextLine)[X shr 1] and Mask4[X and 1]) shr Shift4[X and 1]);
4 : Result := (PArrayByte(Integer(FTopPBits)+Y*FNextLine)[X shr 1] and Mask4[X and 1]) shr Shift4[X and 1];
8: Result := PArrayByte(Integer(FTopPBits) + Y * FNextLine)[X];
16: Result := PArrayWord(Integer(FTopPBits) + Y * FNextLine)[X];
24: with PArrayBGR(Integer(FTopPBits) + Y * FNextLine)[X] do
2347,17 → 1693,6
end;
end;
 
function TDIB.GetRGBChannel: TDIB;
{Store RGB channel information into DIB24}
begin
Result := nil;
if Self.Empty then Exit;
Result := TDIB.Create;
Result.SetSize(Width, Height, 24);
Self.DrawOn(Bounds(0,0, Self.Width, Self.Height), Result.Canvas, 0, 0);
FFreeList.Add(Result);
end;
 
procedure TDIB.SetPixel(X, Y: Integer; Value: DWORD);
var
P: PByte;
2372,8 → 1707,8
P^ := (P^ and Mask1n[X and 7]) or ((Value and 1) shl Shift1[X and 7]);
end;
4: begin
P := (@PArrayByte(Integer(FTopPBits) + Y * FNextLine)[X shr 3]);
P^ := ((P^ and Mask4n[X and 1]) or ((Value and 15) shl Shift4[X and 1]));
P := @PArrayByte(Integer(FTopPBits)+Y*FNextLine)[X shr 3];
P^ := (P^ and Mask4n[X and 1]) or ((Value and 15) shl Shift4[X and 1]);
end;
8: PArrayByte(Integer(FTopPBits) + Y * FNextLine)[X] := Value;
16: PArrayWord(Integer(FTopPBits) + Y * FNextLine)[X] := Value;
2388,23 → 1723,6
end;
end;
 
procedure TDIB.SetRGBChannel(const Value: TDIB);
var
alpha: TDIB;
begin
if Self.HasAlphaChannel then
try
RetAlphaChannel(alpha);
Self.SetSize(Value.Width, Value.Height, 32);
Value.DrawOn(Bounds(0,0,Value.Width, Value.Height), Self.Canvas, 0, 0);
Self.AssignAlphaChannel(alpha, True);
finally
alpha.Free;
end
else
Self.Assign(Value);
end;
 
procedure TDIB.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
2413,8 → 1731,6
end;
 
type
{ TGlobalMemoryStream }
 
TGlobalMemoryStream = class(TMemoryStream)
private
FHandle: THandle;
2457,7 → 1773,6
var
BF: TBitmapFileHeader;
i: Integer;
ImageJPEG: TJPEGImage;
begin
{ File header reading }
i := Stream.Read(BF, SizeOf(TBitmapFileHeader));
2465,30 → 1780,6
if i <> SizeOf(TBitmapFileHeader) then
raise EInvalidGraphic.Create(SInvalidDIB);
 
{ Is the head jpeg ?}
 
if BF.bfType = $D8FF then
begin
ImageJPEG := TJPEGImage.Create;
try
try
Stream.Position := 0;
ImageJPEG.LoadFromStream(Stream);
except
on EInvalidGraphic do ImageJPEG := nil;
end;
if ImageJPEG <> nil then
begin
{set size and bitcount in natural units of jpeg}
SetSize(ImageJPEG.Width, ImageJPEG.Height, 24);
Canvas.Draw(0, 0, ImageJPEG);
Exit
end;
finally
ImageJPEG.Free;
end;
end
else
{ Is the head 'BM'? }
if BF.bfType <> BitmapFileType then
raise EInvalidGraphic.Create(SInvalidDIB);
2547,9 → 1838,7
bfSize := bfOffBits + FImage.FBitmapInfo^.bmiHeader.biSizeImage;
bfReserved1 := 0;
bfReserved2 := 0;
if (FBitCount = 32) and (FImage.FBitmapInfo^.bmiHeader.biCompression <> 0) then FImage.FBitmapInfo^.bmiHeader.biCompression := 0; //corrext RGB error to RGBA
end;
 
Stream.WriteBuffer(BF, SizeOf(TBitmapFileHeader));
 
WriteData(Stream);
2575,8 → 1864,7
if Empty then
begin
SetSize(Max(Width, 1), Max(Height, 1), Value)
end
else
end else
begin
ConvertBitCount(Value);
end;
2743,16 → 2031,13
for x := 0 to Width - 1 do
begin
case Temp.BitCount of
1:
begin
1 : begin
i := (PArrayByte(SrcP)[X shr 3] and Mask1[X and 7]) shr Shift1[X and 7];
end;
4:
begin
4 : begin
i := (PArrayByte(SrcP)[X and 1] and Mask4[X and 1]) shr Shift4[X and 1];
end;
8:
begin
8 : begin
i := PByte(SrcP)^;
Inc(PByte(SrcP));
end;
2759,18 → 2044,15
end;
 
case BitCount of
1:
begin
1 : begin
P := @PArrayByte(DestP)[X shr 3];
P^ := (P^ and Mask1n[X and 7]) or (i shl Shift1[X shr 3]);
end;
4:
begin
4 : begin
P := @PArrayByte(DestP)[X shr 1];
P^ := (P^ and Mask4n[X and 1]) or (i shl Shift4[X and 1]);
end;
8:
begin
8 : begin
PByte(DestP)^ := i;
Inc(PByte(DestP));
end;
2797,8 → 2079,7
for x := 0 to Width - 1 do
begin
case Temp.BitCount of
1:
begin
1 : begin
with Temp.ColorTable[(PArrayByte(SrcP)[X shr 3] and Mask1[X and 7]) shr Shift1[X and 7]] do
begin
cR := rgbRed;
2806,8 → 2087,7
cB := rgbBlue;
end;
end;
4:
begin
4 : begin
with Temp.ColorTable[(PArrayByte(SrcP)[X shr 1] and Mask4[X and 1]) shr Shift4[X and 1]] do
begin
cR := rgbRed;
2815,8 → 2095,7
cB := rgbBlue;
end;
end;
8:
begin
8 : begin
with Temp.ColorTable[PByte(SrcP)^] do
begin
cR := rgbRed;
2825,13 → 2104,11
end;
Inc(PByte(SrcP));
end;
16:
begin
16: begin
pfGetRGB(Temp.NowPixelFormat, PWord(SrcP)^, cR, cG, cB);
Inc(PWord(SrcP));
end;
24:
begin
24: begin
with PBGR(SrcP)^ do
begin
cR := R;
2841,8 → 2118,7
 
Inc(PBGR(SrcP));
end;
32:
begin
32: begin
pfGetRGB(Temp.NowPixelFormat, PDWORD(SrcP)^, cR, cG, cB);
Inc(PDWORD(SrcP));
end;
2849,13 → 2125,11
end;
 
case BitCount of
16:
begin
16: begin
PWord(DestP)^ := pfRGB(NowPixelFormat, cR, cG, cB);
Inc(PWord(DestP));
end;
24:
begin
24: begin
with PBGR(DestP)^ do
begin
R := cR;
2864,8 → 2138,7
end;
Inc(PBGR(DestP));
end;
32:
begin
32: begin
PDWORD(DestP)^ := pfRGB(NowPixelFormat, cR, cG, cB);
Inc(PDWORD(DestP));
end;
2890,8 → 2163,7
if Temp.BitCount <= BitCount then
begin
PaletteToPalette_Inc;
end
else
end else
begin
case BitCount of
1: begin
2905,14 → 2177,12
 
Canvas.Draw(0, 0, Temp);
end;
end
else
end else
if (Temp.BitCount <= 8) and (BitCount > 8) then
begin
{ The image is converted from the palette color image into the rgb color image. }
PaletteToRGB_or_RGBToRGB;
end
else
end else
if (Temp.BitCount > 8) and (BitCount <= 8) then
begin
{ The image is converted from the rgb color image into the palette color image. }
2927,8 → 2197,7
UpdatePalette;
 
Canvas.Draw(0, 0, Temp);
end
else
end else
if (Temp.BitCount > 8) and (BitCount > 8) then
begin
{ The image is converted from the rgb color image into the rgb color image. }
2982,211 → 2251,6
Inc(FProgressY);
end;
 
procedure TDIB.Mirror(MirrorX, MirrorY: Boolean);
var
x, y, Width2, c: Integer;
P1, P2, TempBuf: Pointer;
begin
if Empty then Exit;
if (not MirrorX) and (not MirrorY) then Exit;
 
if (not MirrorX) and (MirrorY) then
begin
GetMem(TempBuf, WidthBytes);
try
StartProgress('Mirror');
try
for y := 0 to Height shr 1 - 1 do
begin
P1 := ScanLine[y];
P2 := ScanLine[Height - y - 1];
 
Move(P1^, TempBuf^, WidthBytes);
Move(P2^, P1^, WidthBytes);
Move(TempBuf^, P2^, WidthBytes);
 
UpdateProgress(y * 2);
end;
finally
EndProgress;
end;
finally
FreeMem(TempBuf, WidthBytes);
end;
end
else
if (MirrorX) and (not MirrorY) then
begin
Width2 := Width shr 1;
 
StartProgress('Mirror');
try
for y := 0 to Height - 1 do
begin
P1 := ScanLine[y];
 
case BitCount of
1:
begin
for x := 0 to Width2 - 1 do
begin
c := Pixels[x, y];
Pixels[x, y] := Pixels[Width - x - 1, y];
Pixels[Width - x - 1, y] := c;
end;
end;
4:
begin
for x := 0 to Width2 - 1 do
begin
c := Pixels[x, y];
Pixels[x, y] := Pixels[Width - x - 1, y];
Pixels[Width - x - 1, y] := c;
end;
end;
8:
begin
P2 := Pointer(Integer(P1) + Width - 1);
for x := 0 to Width2 - 1 do
begin
PByte(@c)^ := PByte(P1)^;
PByte(P1)^ := PByte(P2)^;
PByte(P2)^ := PByte(@c)^;
Inc(PByte(P1));
Dec(PByte(P2));
end;
end;
16:
begin
P2 := Pointer(Integer(P1) + (Width - 1) * 2);
for x := 0 to Width2 - 1 do
begin
PWord(@c)^ := PWord(P1)^;
PWord(P1)^ := PWord(P2)^;
PWord(P2)^ := PWord(@c)^;
Inc(PWord(P1));
Dec(PWord(P2));
end;
end;
24:
begin
P2 := Pointer(Integer(P1) + (Width - 1) * 3);
for x := 0 to Width2 - 1 do
begin
PBGR(@c)^ := PBGR(P1)^;
PBGR(P1)^ := PBGR(P2)^;
PBGR(P2)^ := PBGR(@c)^;
Inc(PBGR(P1));
Dec(PBGR(P2));
end;
end;
32:
begin
P2 := Pointer(Integer(P1) + (Width - 1) * 4);
for x := 0 to Width2 - 1 do
begin
PDWORD(@c)^ := PDWORD(P1)^;
PDWORD(P1)^ := PDWORD(P2)^;
PDWORD(P2)^ := PDWORD(@c)^;
Inc(PDWORD(P1));
Dec(PDWORD(P2));
end;
end;
end;
 
UpdateProgress(y);
end;
finally
EndProgress;
end;
end
else
if (MirrorX) and (MirrorY) then
begin
StartProgress('Mirror');
try
for y := 0 to Height shr 1 - 1 do
begin
P1 := ScanLine[y];
P2 := ScanLine[Height - y - 1];
 
case BitCount of
1:
begin
for x := 0 to Width - 1 do
begin
c := Pixels[x, y];
Pixels[x, y] := Pixels[Width - x - 1, Height - y - 1];
Pixels[Width - x - 1, Height - y - 1] := c;
end;
end;
4:
begin
for x := 0 to Width - 1 do
begin
c := Pixels[x, y];
Pixels[x, y] := Pixels[Width - x - 1, Height - y - 1];
Pixels[Width - x - 1, Height - y - 1] := c;
end;
end;
8:
begin
P2 := Pointer(Integer(P2) + Width - 1);
for x := 0 to Width - 1 do
begin
PByte(@c)^ := PByte(P1)^;
PByte(P1)^ := PByte(P2)^;
PByte(P2)^ := PByte(@c)^;
Inc(PByte(P1));
Dec(PByte(P2));
end;
end;
16:
begin
P2 := Pointer(Integer(P2) + (Width - 1) * 2);
for x := 0 to Width - 1 do
begin
PWord(@c)^ := PWord(P1)^;
PWord(P1)^ := PWord(P2)^;
PWord(P2)^ := PWord(@c)^;
Inc(PWord(P1));
Dec(PWord(P2));
end;
end;
24:
begin
P2 := Pointer(Integer(P2) + (Width - 1) * 3);
for x := 0 to Width - 1 do
begin
PBGR(@c)^ := PBGR(P1)^;
PBGR(P1)^ := PBGR(P2)^;
PBGR(P2)^ := PBGR(@c)^;
Inc(PBGR(P1));
Dec(PBGR(P2));
end;
end;
32:
begin
P2 := Pointer(Integer(P2) + (Width - 1) * 4);
for x := 0 to Width - 1 do
begin
PDWORD(@c)^ := PDWORD(P1)^;
PDWORD(P1)^ := PDWORD(P2)^;
PDWORD(P2)^ := PDWORD(@c)^;
Inc(PDWORD(P1));
Dec(PDWORD(P2));
end;
end;
end;
 
UpdateProgress(y * 2);
end;
finally
EndProgress;
end;
end;
end;
 
procedure TDIB.Blur(ABitCount: Integer; Radius: Integer);
type
TAve = record
3206,8 → 2270,7
R, G, B: Byte;
begin
case Temp.BitCount of
1:
begin
1 : begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3222,8 → 2285,7
Inc(AveP);
end;
end;
4:
begin
4 : begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3238,8 → 2300,7
Inc(AveP);
end;
end;
8:
begin
8 : begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3255,8 → 2316,7
Inc(AveP);
end;
end;
16:
begin
16: begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3273,8 → 2333,7
Inc(AveP);
end;
end;
24:
begin
24: begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3290,8 → 2349,7
Inc(AveP);
end;
end;
32:
begin
32: begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3319,8 → 2377,7
R, G, B: Byte;
begin
case Temp.BitCount of
1:
begin
1 : begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3335,8 → 2392,7
Inc(AveP);
end;
end;
4:
begin
4 : begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3351,8 → 2407,7
Inc(AveP);
end;
end;
8:
begin
8 : begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3368,8 → 2423,7
Inc(AveP);
end;
end;
16:
begin
16: begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3386,8 → 2440,7
Inc(AveP);
end;
end;
24:
begin
24: begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3403,8 → 2456,7
Inc(AveP);
end;
end;
32:
begin
32: begin
SrcP := Pointer(Integer(Temp.TopPBits) + Y * Temp.NextLine);
AveP := @Ave;
for x := 0 to XCount - 1 do
3527,32 → 2579,27
 
{ The average is written. }
case BitCount of
1:
begin
1 : begin
P := @PArrayByte(DestP)[X shr 3];
with Ave do
P^ := (P^ and Mask1n[X and 7]) or (DWORD(Ord(((cR + cG + cB) div c) div 3 > 127)) shl Shift1[X and 7]);
end;
4:
begin
4 : begin
P := @PArrayByte(DestP)[X shr 1];
with Ave do
P^ := (P^ and Mask4n[X and 1]) or (((((cR + cG + cB) div c) div 3) shr 4) shl Shift4[X and 1]);
end;
8:
begin
8 : begin
with Ave do
PByte(DestP)^ := ((cR + cG + cB) div c) div 3;
Inc(PByte(DestP));
end;
16:
begin
16: begin
with Ave do
PWORD(DestP)^ := pfRGB(NowPixelFormat, cR div c, cG div c, cB div c);
Inc(PWORD(DestP));
end;
24:
begin
24: begin
with PBGR(DestP)^, Ave do
begin
R := cR div c;
3561,8 → 2608,7
end;
Inc(PBGR(DestP));
end;
32:
begin
32: begin
with Ave do
PDWORD(DestP)^ := pfRGB(NowPixelFormat, cR div c, cG div c, cB div c);
Inc(PDWORD(DestP));
3611,95 → 2657,7
EndProgress;
end;
end;
(*
procedure TDIB.Negative;
var
i, i2: Integer;
P: Pointer;
begin
if Empty then exit;
 
if BitCount <= 8 then
begin
for i := 0 to 255 do
with ColorTable[i] do
begin
rgbRed := 255 - rgbRed;
rgbGreen := 255 - rgbGreen;
rgbBlue := 255 - rgbBlue;
end;
UpdatePalette;
end else
begin
P := PBits;
i2 := Size;
asm
mov ecx,i2
mov eax,P
mov edx,ecx
 
{ Unit of DWORD. }
@@qword_skip:
shr ecx,2
jz @@dword_skip
 
dec ecx
@@dword_loop:
not dword ptr [eax+ecx*4]
dec ecx
jnl @@dword_loop
 
mov ecx,edx
shr ecx,2
add eax,ecx*4
 
{ Unit of Byte. }
@@dword_skip:
mov ecx,edx
and ecx,3
jz @@byte_skip
 
dec ecx
@@loop_byte:
not byte ptr [eax+ecx]
dec ecx
jnl @@loop_byte
 
@@byte_skip:
end;
end;
end;
*)
procedure TDIB.Negative;
var
i: Integer;
P: Pointer;
i2: Integer;
begin
if Empty then Exit;
 
if BitCount <= 8 then
begin
for i := 0 to 255 do
with ColorTable[i] do
begin
rgbRed := 255 - rgbRed;
rgbGreen := 255 - rgbGreen;
rgbBlue := 255 - rgbBlue;
end;
UpdatePalette;
end
else
begin
P := PBits;
i2 := Size;
for i := 0 to i2-1 do
begin
PByteArray(P)^[i] := not PByteArray(P)^[i];
end;
end;
end;
 
procedure TDIB.Greyscale(ABitCount: Integer);
var
YTblR, YTblG, YTblB: array[0..255] of Byte;
3710,7 → 2668,7
DestP, SrcP: Pointer;
P: PByte;
begin
if Empty then Exit;
if Empty then exit;
 
Temp := TDIB.Create;
try
3748,36 → 2706,30
for x := 0 to Width - 1 do
begin
case Temp.BitCount of
1:
begin
1 : begin
with Temp.ColorTable[(PArrayByte(SrcP)[X shr 3] and Mask1[X and 7]) shr Shift1[X and 7]] do
c := YTblR[rgbRed] + YTblG[rgbGreen] + YTblB[rgbBlue];
end;
4:
begin
4 : begin
with Temp.ColorTable[(PArrayByte(SrcP)[X shr 1] and Mask4[X and 1]) shr Shift4[X and 1]] do
c := YTblR[rgbRed] + YTblG[rgbGreen] + YTblB[rgbBlue];
end;
8:
begin
8 : begin
with Temp.ColorTable[PByte(SrcP)^] do
c := YTblR[rgbRed] + YTblG[rgbGreen] + YTblB[rgbBlue];
Inc(PByte(SrcP));
end;
16:
begin
16: begin
pfGetRGB(Temp.NowPixelFormat, PWord(SrcP)^, R, G, B);
c := YTblR[R] + YTblR[G] + YTblR[B];
Inc(PWord(SrcP));
end;
24:
begin
24: begin
with PBGR(SrcP)^ do
c := YTblR[R] + YTblG[G] + YTblB[B];
Inc(PBGR(SrcP));
end;
32:
begin
32: begin
pfGetRGB(Temp.NowPixelFormat, PDWORD(SrcP)^, R, G, B);
c := YTblR[R] + YTblR[G] + YTblR[B];
Inc(PDWORD(SrcP));
3785,28 → 2737,23
end;
 
case BitCount of
1:
begin
1 : begin
P := @PArrayByte(DestP)[X shr 3];
P^ := (P^ and Mask1n[X and 7]) or (DWORD(Ord(c > 127)) shl Shift1[X and 7]);
end;
4:
begin
4 : begin
P := @PArrayByte(DestP)[X shr 1];
P^ := (P^ and Mask4n[X and 1]) or ((c shr 4) shl Shift4[X and 1]);
end;
8:
begin
8 : begin
PByte(DestP)^ := c;
Inc(PByte(DestP));
end;
16:
begin
16: begin
PWord(DestP)^ := pfRGB(NowPixelFormat, c, c, c);
Inc(PWord(DestP));
end;
24:
begin
24: begin
with PBGR(DestP)^ do
begin
R := c;
3815,8 → 2762,7
end;
Inc(PBGR(DestP));
end;
32:
begin
32: begin
PDWORD(DestP)^ := pfRGB(NowPixelFormat, c, c, c);
Inc(PDWORD(DestP));
end;
3833,1597 → 2779,253
end;
end;
 
//--------------------------------------------------------------------------------------------------
// Version : 0.1 - 26/06/2000 //
// Version : 0.2 - 04/07/2000 //
// At someone's request, i have added 3 news effects : //
// 1 - Rotate //
// 2 - SplitBlur //
// 3 - GaussianBlur //
//--------------------------------------------------------------------------------------------------
// - NEW SPECIAL EFFECT - (English) //
//--------------------------------------------------------------------------------------------------
// At the start, my idea was to create a component derived from TCustomDXDraw. Unfortunately, //
// it's impossible to run a graphic component (derived from TCustomDXDraw) in a conception's //
// mode (i don't success, but perhaps, somebody know how doing ! In that case, please help me !!!)//
// Then, i'm used the DIB's unit for my work, but this unit is poor in special effect. Knowing a //
// library with more effect, i'm undertaked to import this library in DIB's unit. You can see the //
// FastLib library at : //
// //
// -> Gordon Alex Cowie <gfody@jps.net> www.jps.net/gfody //
// //
// It was very difficult, because implementation's graphic was very different that DIB's unit. //
// Sometimes, i'm deserted the possibility of original effect, particularly in conversion of DIB //
// whith 256, 16 and 2 colors. If someone can implement this fonctionnality, thanks to tell me //
// how this miracle is possible !!! //
// All these procedures are translated and adapted by : //
// //
// -> Mickey (Michel HIBON) <mhibon@ifrance.com> http://mickey.tsx.org //
// //
// IMPORTANT : These procedures don't modify the DIB's unit structure //
// Nota Bene : I don't implement these type of graphics (32 and 16 bit per pixels), //
// for one reason : I haven't bitmaps of this type !!! //
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// - NOUVEAUX EFFETS SPECIAUX - (Français) //
//--------------------------------------------------------------------------------------------------
// Au commencement, mon idée était de dériver un composant de TCustomDXDraw. Malheureusement, //
// c'est impossible de faire fonctionner un composant graphique (derivé de TCustomDXDraw) en mode //
// conception (je n'y suis pas parvenu, mais peut-être, que quelqu'un sait comment faire ! Dans //
// ce cas, vous seriez aimable de m'aider !!!) //
// Alors, j'ai utilisé l'unité DIB pour mon travail,mais celle-ci est pauvre en effet spéciaux. //
// Connaissant une librairie avec beaucoup plus d'effets spéciaux, j'ai entrepris d'importer //
// cette librairie dans l'unité DIB. Vous pouvez voir la librairie FastLib à : //
// //
// -> Gordon Alex Cowie <gfody@jps.net> www.jps.net/gfody //
// //
// C'était très difficile car l'implémentation graphique est très différente de l'unité DIB. //
// Parfois, j'ai abandonné les possibilités de l'effet original, particulièrement dans la //
// conversion des DIB avec 256, 16 et 2 couleurs. Si quelqu'un arrive à implémenter ces //
// fonctionnalités, merci de me dire comment ce miracle est possible !!! //
// Toutes ces procédures ont été traduites et adaptées par: //
// //
// -> Mickey (Michel HIBON) <mhibon@ifrance.com> http://mickey.tsx.org //
// //
// IMPORTANT : Ces procédures ne modifient pas la structure de l'unité DIB //
// Nota Bene : Je n'ai pas implémenté ces types de graphiques (32 et 16 bit par pixels), //
// pour une raison : je n'ai pas de bitmap de ce type !!! //
//--------------------------------------------------------------------------------------------------
 
function TDIB.IntToColor(i: Integer): TBGR;
procedure TDIB.Mirror(MirrorX, MirrorY: Boolean);
var
x, y, Width2, c: Integer;
P1, P2, TempBuf: Pointer;
begin
Result.b := i shr 16;
Result.g := i shr 8;
Result.r := i;
end;
if Empty then exit;
if (not MirrorX) and (not MirrorY) then Exit;
 
function TDIB.Interval(iMin, iMax, iValue: Integer; iMark: Boolean): Integer;
if (not MirrorX) and (MirrorY) then
begin
if iMark then
GetMem(TempBuf, WidthBytes);
try
StartProgress('Mirror');
try
for y:=0 to Height shr 1-1 do
begin
if iValue < iMin then
Result := iMin
else
if iValue > iMax then
Result := iMax
else
Result := iValue;
end
else
begin
if iValue < iMin then
Result := iMin
else
if iValue > iMax then
Result := iMin
else
Result := iValue;
end;
end;
P1 := ScanLine[y];
P2 := ScanLine[Height-y-1];
 
procedure TDIB.Contrast(Amount: Integer);
var
x, y: Integer;
Table1: array[0..255] of Byte;
i: Byte;
S, D: pointer;
Temp1: TDIB;
color: DWORD;
P: PByte;
R, G, B: Byte;
begin
D := nil;
S := nil;
Temp1 := nil;
for i := 0 to 126 do
begin
y := (Abs(128 - i) * Amount) div 256;
Table1[i] := IntToByte(i - y);
Move(P1^, TempBuf^, WidthBytes);
Move(P2^, P1^, WidthBytes);
Move(TempBuf^, P2^, WidthBytes);
 
UpdateProgress(y*2);
end;
for i := 127 to 255 do
begin
y := (Abs(128 - i) * Amount) div 256;
Table1[i] := IntToByte(i + y);
finally
EndProgress;
end;
case BitCount of
32: Exit; // I haven't bitmap of this type ! Sorry
24: ; // nothing to do
16: ; // I have an artificial bitmap for this type ! i don't sure that it works
8, 4:
begin
Temp1 := TDIB.Create;
Temp1.Assign(self);
Temp1.SetSize(Width, Height, BitCount);
for i := 0 to 255 do
begin
with ColorTable[i] do
begin
rgbRed := IntToByte(Table1[rgbRed]);
rgbGreen := IntToByte(Table1[rgbGreen]);
rgbBlue := IntToByte(Table1[rgbBlue]);
finally
FreeMem(TempBuf, WidthBytes);
end;
end;
UpdatePalette;
end;
else
// if the number of pixel is equal to 1 then exit of procedure
Exit;
end;
for y := 0 to Pred(Height) do
end else if (MirrorX) and (not MirrorY) then
begin
case BitCount of
24, 16: D := ScanLine[y];
8, 4:
begin
D := Temp1.ScanLine[y];
S := Temp1.ScanLine[y];
end;
else
end;
for x := 0 to Pred(Width) do
begin
case BitCount of
32: ;
24:
begin
PBGR(D)^.B := Table1[PBGR(D)^.B];
PBGR(D)^.G := Table1[PBGR(D)^.G];
PBGR(D)^.R := Table1[PBGR(D)^.R];
Inc(PBGR(D));
end;
16:
begin
pfGetRGB(NowPixelFormat, PWord(D)^, R, G, B);
PWord(D)^ := Table1[R] + Table1[G] + Table1[B];
Inc(PWord(D));
end;
8:
begin
with Temp1.ColorTable[PByte(S)^] do
color := rgbRed + rgbGreen + rgbBlue;
Inc(PByte(S));
PByte(D)^ := color;
Inc(PByte(D));
end;
4:
begin
with Temp1.ColorTable[PByte(S)^] do
color := rgbRed + rgbGreen + rgbBlue;
Inc(PByte(S));
P := @PArrayByte(D)[X shr 1];
P^ := (P^ and Mask4n[X and 1]) or (color shl Shift4[X and 1]);
end;
else
end;
end;
end;
case BitCount of
8, 4: Temp1.Free;
else
end;
end;
Width2 := Width shr 1;
 
procedure TDIB.Saturation(Amount: Integer);
var
Grays: array[0..767] of Integer;
Alpha: array[0..255] of Word;
Gray, x, y: Integer;
i: Byte;
S, D: pointer;
Temp1: TDIB;
color: DWORD;
P: PByte;
R, G, B: Byte;
StartProgress('Mirror');
try
for y:=0 to Height-1 do
begin
D := nil;
S := nil;
Temp1 := nil;
for i := 0 to 255 do
Alpha[i] := (i * Amount) shr 8;
x := 0;
for i := 0 to 255 do
begin
Gray := i - Alpha[i];
Grays[x] := Gray;
Inc(x);
Grays[x] := Gray;
Inc(x);
Grays[x] := Gray;
Inc(x);
end;
case BitCount of
32: Exit; // I haven't bitmap of this type ! Sorry
24: ; // nothing to do
16: ; // I have an artificial bitmap for this type ! i don't sure that it works
8, 4:
begin
Temp1 := TDIB.Create;
Temp1.Assign(self);
Temp1.SetSize(Width, Height, BitCount);
for i := 0 to 255 do
begin
with ColorTable[i] do
begin
Gray := Grays[rgbRed + rgbGreen + rgbBlue];
rgbRed := IntToByte(Gray + Alpha[rgbRed]);
rgbGreen := IntToByte(Gray + Alpha[rgbGreen]);
rgbBlue := IntToByte(Gray + Alpha[rgbBlue]);
end;
end;
UpdatePalette;
end;
else
// if the number of pixel is equal to 1 then exit of procedure
Exit;
end;
for y := 0 to Pred(Height) do
begin
case BitCount of
24, 16: D := ScanLine[y];
8, 4:
begin
D := Temp1.ScanLine[y];
S := Temp1.ScanLine[y];
end;
else
end;
for x := 0 to Pred(Width) do
begin
case BitCount of
32: ;
24:
begin
Gray := Grays[PBGR(D)^.R + PBGR(D)^.G + PBGR(D)^.B];
PBGR(D)^.B := IntToByte(Gray + Alpha[PBGR(D)^.B]);
PBGR(D)^.G := IntToByte(Gray + Alpha[PBGR(D)^.G]);
PBGR(D)^.R := IntToByte(Gray + Alpha[PBGR(D)^.R]);
Inc(PBGR(D));
end;
16:
begin
pfGetRGB(NowPixelFormat, PWord(D)^, R, G, B);
PWord(D)^ := IntToByte(Gray + Alpha[B]) + IntToByte(Gray + Alpha[G]) +
IntToByte(Gray + Alpha[R]);
Inc(PWord(D));
end;
8:
begin
with Temp1.ColorTable[PByte(S)^] do
color := rgbRed + rgbGreen + rgbBlue;
Inc(PByte(S));
PByte(D)^ := color;
Inc(PByte(D));
end;
4:
begin
with Temp1.ColorTable[PByte(S)^] do
color := rgbRed + rgbGreen + rgbBlue;
Inc(PByte(S));
P := @PArrayByte(D)[X shr 1];
P^ := (P^ and Mask4n[X and 1]) or (color shl Shift4[X and 1]);
end;
else
end;
end;
end;
case BitCount of
8, 4: Temp1.Free;
else
end;
end;
P1 := ScanLine[y];
 
procedure TDIB.Lightness(Amount: Integer);
var
x, y: Integer;
Table1: array[0..255] of Byte;
i: Byte;
S, D: pointer;
Temp1: TDIB;
color: DWORD;
P: PByte;
R, G, B: Byte;
begin
D := nil;
S := nil;
Temp1 := nil;
if Amount < 0 then
begin
Amount := -Amount;
for i := 0 to 255 do
Table1[i] := IntToByte(i - ((Amount * i) shr 8));
end
else
for i := 0 to 255 do
Table1[i] := IntToByte(i + ((Amount * (i xor 255)) shr 8));
case BitCount of
32: Exit; // I haven't bitmap of this type ! Sorry
24: ; // nothing to do
16: ; // I have an artificial bitmap for this type ! i don't sure that it works
8, 4:
1 : begin
for x:=0 to Width2-1 do
begin
Temp1 := TDIB.Create;
Temp1.Assign(self);
Temp1.SetSize(Width, Height, BitCount);
for i := 0 to 255 do
begin
with ColorTable[i] do
begin
rgbRed := IntToByte(Table1[rgbRed]);
rgbGreen := IntToByte(Table1[rgbGreen]);
rgbBlue := IntToByte(Table1[rgbBlue]);
c := Pixels[x, y];
Pixels[x, y] := Pixels[Width-x-1, y];
Pixels[Width-x-1, y] := c;
end;
end;
UpdatePalette;
end;
else
// if the number of pixel is equal to 1 then exit of procedure
Exit;
end;
for y := 0 to Pred(Height) do
4 : begin
for x:=0 to Width2-1 do
begin
case BitCount of
24, 16: D := ScanLine[y];
8, 4:
begin
D := Temp1.ScanLine[y];
S := Temp1.ScanLine[y];
c := Pixels[x, y];
Pixels[x, y] := Pixels[Width-x-1, y];
Pixels[Width-x-1, y] := c;
end;
else
end;
for x := 0 to Pred(Width) do
8 : begin
P2 := Pointer(Integer(P1)+Width-1);
for x:=0 to Width2-1 do
begin
case BitCount of
32: ;
24:
begin
PBGR(D)^.B := Table1[PBGR(D)^.B];
PBGR(D)^.G := Table1[PBGR(D)^.G];
PBGR(D)^.R := Table1[PBGR(D)^.R];
Inc(PBGR(D));
PByte(@c)^ := PByte(P1)^;
PByte(P1)^ := PByte(P2)^;
PByte(P2)^ := PByte(@c)^;
Inc(PByte(P1));
Dec(PByte(P2));
end;
16:
begin
pfGetRGB(NowPixelFormat, PWord(D)^, R, G, B);
PWord(D)^ := Table1[R] + Table1[G] + Table1[B];
Inc(PWord(D));
end;
8:
16: begin
P2 := Pointer(Integer(P1)+(Width-1)*2);
for x:=0 to Width2-1 do
begin
with Temp1.ColorTable[PByte(S)^] do
color := rgbRed + rgbGreen + rgbBlue;
Inc(PByte(S));
PByte(D)^ := color;
Inc(PByte(D));
PWord(@c)^ := PWord(P1)^;
PWord(P1)^ := PWord(P2)^;
PWord(P2)^ := PWord(@c)^;
Inc(PWord(P1));
Dec(PWord(P2));
end;
4:
begin
with Temp1.ColorTable[PByte(S)^] do
color := rgbRed + rgbGreen + rgbBlue;
Inc(PByte(S));
P := @PArrayByte(D)[X shr 1];
P^ := (P^ and Mask4n[X and 1]) or (color shl Shift4[X and 1]);
end;
else
end;
end;
end;
case BitCount of
8, 4: Temp1.Free;
else
end;
end;
 
procedure TDIB.AddRGB(aR, aG, aB: Byte);
var
Table: array[0..255] of TBGR;
x, y: Integer;
i: Byte;
D: pointer;
P: PByte;
color: DWORD;
Temp1: TDIB;
R, G, B: Byte;
24: begin
P2 := Pointer(Integer(P1)+(Width-1)*3);
for x:=0 to Width2-1 do
begin
color := 0;
D := nil;
Temp1 := nil;
case BitCount of
32: Exit; // I haven't bitmap of this type ! Sorry
24, 16:
begin
for i := 0 to 255 do
begin
Table[i].b := IntToByte(i + aB);
Table[i].g := IntToByte(i + aG);
Table[i].r := IntToByte(i + aR);
PBGR(@c)^ := PBGR(P1)^;
PBGR(P1)^ := PBGR(P2)^;
PBGR(P2)^ := PBGR(@c)^;
Inc(PBGR(P1));
Dec(PBGR(P2));
end;
end;
8, 4:
32: begin
P2 := Pointer(Integer(P1)+(Width-1)*4);
for x:=0 to Width2-1 do
begin
Temp1 := TDIB.Create;
Temp1.Assign(self);
Temp1.SetSize(Width, Height, BitCount);
for i := 0 to 255 do
begin
with ColorTable[i] do
begin
rgbRed := IntToByte(rgbRed + aR);
rgbGreen := IntToByte(rgbGreen + aG);
rgbBlue := IntToByte(rgbBlue + aB);
PDWORD(@c)^ := PDWORD(P1)^;
PDWORD(P1)^ := PDWORD(P2)^;
PDWORD(P2)^ := PDWORD(@c)^;
Inc(PDWORD(P1));
Dec(PDWORD(P2));
end;
end;
UpdatePalette;
end;
else
// if the number of pixel is equal to 1 then exit of procedure
Exit;
end;
for y := 0 to Pred(Height) do
begin
case BitCount of
24, 16: D := ScanLine[y];
8, 4:
begin
D := Temp1.ScanLine[y];
end;
else
end;
for x := 0 to Pred(Width) do
begin
case BitCount of
32: ; // I haven't bitmap of this type ! Sorry
24:
begin
PBGR(D)^.B := Table[PBGR(D)^.B].b;
PBGR(D)^.G := Table[PBGR(D)^.G].g;
PBGR(D)^.R := Table[PBGR(D)^.R].r;
Inc(PBGR(D));
end;
16:
begin
pfGetRGB(NowPixelFormat, PWord(D)^, R, G, B);
PWord(D)^ := Table[R].r + Table[G].g + Table[B].b;
Inc(PWord(D));
end;
8:
begin
Inc(PByte(D));
end;
4:
begin
P := @PArrayByte(D)[X shr 1];
P^ := (P^ and Mask4n[X and 1]) or (color shl Shift4[X and 1]);
end;
else
end;
end;
end;
case BitCount of
8, 4: Temp1.Free;
else
end;
end;
 
function TDIB.Filter(Dest: TDIB; Filter: TFilter): Boolean;
var
Sum, r, g, b, x, y: Integer;
a, i, j: byte;
tmp: TBGR;
Col: PBGR;
D: Pointer;
begin
Result := True;
Sum := Filter[0, 0] + Filter[1, 0] + Filter[2, 0] +
Filter[0, 1] + Filter[1, 1] + Filter[2, 1] +
Filter[0, 2] + Filter[1, 2] + Filter[2, 2];
if Sum = 0 then
Sum := 1;
Col := PBits;
for y := 0 to Pred(Height) do
begin
D := Dest.ScanLine[y];
for x := 0 to Pred(Width) do
begin
r := 0; g := 0; b := 0;
case BitCount of
32, 16, 4, 1:
begin
Result := False;
Exit;
UpdateProgress(y);
end;
24:
begin
for i := 0 to 2 do
begin
for j := 0 to 2 do
begin
Tmp := IntToColor(Pixels[Interval(0, Pred(Width), x + Pred(i), True),
Interval(0, Pred(Height), y + Pred(j), True)]);
Inc(b, Filter[i, j] * Tmp.b);
Inc(g, Filter[i, j] * Tmp.g);
Inc(r, Filter[i, j] * Tmp.r);
finally
EndProgress;
end;
end;
Col.b := IntToByte(b div Sum);
Col.g := IntToByte(g div Sum);
Col.r := IntToByte(r div Sum);
Dest.Pixels[x, y] := rgb(Col.r, Col.g, Col.b);
end;
8:
end else if (MirrorX) and (MirrorY) then
begin
for i := 0 to 2 do
StartProgress('Mirror');
try
for y:=0 to Height shr 1-1 do
begin
for j := 0 to 2 do
begin
a := (Pixels[Interval(0, Pred(Width), x + Pred(i), True),
Interval(0, Pred(Height), y + Pred(j), True)]);
tmp.r := ColorTable[a].rgbRed;
tmp.g := ColorTable[a].rgbGreen;
tmp.b := ColorTable[a].rgbBlue;
Inc(b, Filter[i, j] * Tmp.b);
Inc(g, Filter[i, j] * Tmp.g);
Inc(r, Filter[i, j] * Tmp.r);
end;
end;
Col.b := IntToByte(b div Sum);
Col.g := IntToByte(g div Sum);
Col.r := IntToByte(r div Sum);
PByte(D)^ := rgb(Col.r, Col.g, Col.b);
Inc(PByte(D));
end;
end;
end;
end;
end;
P1 := ScanLine[y];
P2 := ScanLine[Height-y-1];
 
procedure TDIB.Spray(Amount: Integer);
var
value, x, y: Integer;
D: Pointer;
color: DWORD;
P: PByte;
begin
for y := Pred(Height) downto 0 do
begin
D := ScanLine[y];
for x := 0 to Pred(Width) do
begin
value := Random(Amount);
color := Pixels[Interval(0, Pred(Width), x + (value - Random(value * 2)), True),
Interval(0, Pred(Height), y + (value - Random(value * 2)), True)];
case BitCount of
32:
1 : begin
for x:=0 to Width-1 do
begin
PDWord(D)^ := color;
Inc(PDWord(D));
c := Pixels[x, y];
Pixels[x, y] := Pixels[Width-x-1, Height-y-1];
Pixels[Width-x-1, Height-y-1] := c;
end;
24:
begin
PBGR(D)^ := IntToColor(color);
Inc(PBGR(D));
end;
16:
4 : begin
for x:=0 to Width-1 do
begin
PWord(D)^ := color;
Inc(PWord(D));
c := Pixels[x, y];
Pixels[x, y] := Pixels[Width-x-1, Height-y-1];
Pixels[Width-x-1, Height-y-1] := c;
end;
8:
begin
PByte(D)^ := color;
Inc(PByte(D));
end;
4:
8 : begin
P2 := Pointer(Integer(P2)+Width-1);
for x:=0 to Width-1 do
begin
P := @PArrayByte(D)[X shr 1];
P^ := (P^ and Mask4n[X and 1]) or (color shl Shift4[X and 1]);
PByte(@c)^ := PByte(P1)^;
PByte(P1)^ := PByte(P2)^;
PByte(P2)^ := PByte(@c)^;
Inc(PByte(P1));
Dec(PByte(P2));
end;
1:
begin
P := @PArrayByte(D)[X shr 3];
P^ := (P^ and Mask1n[X and 7]) or (color shl Shift1[X and 7]);
end;
else
end;
end;
end;
end;
 
procedure TDIB.Sharpen(Amount: Integer);
var
Lin0, Lin1, Lin2: PLines;
pc: PBGR;
cx, x, y: Integer;
Buf: array[0..8] of TBGR;
D: pointer;
c: DWORD;
i: byte;
P1: PByte;
Temp1: TDIB;
 
16: begin
P2 := Pointer(Integer(P2)+(Width-1)*2);
for x:=0 to Width-1 do
begin
D := nil;
GetMem(pc, SizeOf(TBGR));
c := 0;
Temp1 := nil;
case Bitcount of
32, 16, 1: Exit;
24:
begin
Temp1 := TDIB.Create;
Temp1.Assign(self);
Temp1.SetSize(Width, Height, bitCount);
PWord(@c)^ := PWord(P1)^;
PWord(P1)^ := PWord(P2)^;
PWord(P2)^ := PWord(@c)^;
Inc(PWord(P1));
Dec(PWord(P2));
end;
8:
begin
Temp1 := TDIB.Create;
Temp1.Assign(self);
Temp1.SetSize(Width, Height, bitCount);
for i := 0 to 255 do
begin
with Temp1.ColorTable[i] do
begin
Buf[0].B := ColorTable[i - Amount].rgbBlue;
Buf[0].G := ColorTable[i - Amount].rgbGreen;
Buf[0].R := ColorTable[i - Amount].rgbRed;
Buf[1].B := ColorTable[i].rgbBlue;
Buf[1].G := ColorTable[i].rgbGreen;
Buf[1].R := ColorTable[i].rgbRed;
Buf[2].B := ColorTable[i + Amount].rgbBlue;
Buf[2].G := ColorTable[i + Amount].rgbGreen;
Buf[2].R := ColorTable[i + Amount].rgbRed;
Buf[3].B := ColorTable[i - Amount].rgbBlue;
Buf[3].G := ColorTable[i - Amount].rgbGreen;
Buf[3].R := ColorTable[i - Amount].rgbRed;
Buf[4].B := ColorTable[i].rgbBlue;
Buf[4].G := ColorTable[i].rgbGreen;
Buf[4].R := ColorTable[i].rgbRed;
Buf[5].B := ColorTable[i + Amount].rgbBlue;
Buf[5].G := ColorTable[i + Amount].rgbGreen;
Buf[5].R := ColorTable[i + Amount].rgbRed;
Buf[6].B := ColorTable[i - Amount].rgbBlue;
Buf[6].G := ColorTable[i - Amount].rgbGreen;
Buf[6].R := ColorTable[i - Amount].rgbRed;
Buf[7].B := ColorTable[i].rgbBlue;
Buf[7].G := ColorTable[i].rgbGreen;
Buf[7].R := ColorTable[i].rgbRed;
Buf[8].B := ColorTable[i + Amount].rgbBlue;
Buf[8].G := ColorTable[i + Amount].rgbGreen;
Buf[8].R := ColorTable[i + Amount].rgbRed;
Temp1.colorTable[i].rgbBlue := IntToByte((256 * Buf[4].b - (Buf[0].b + Buf[1].b + Buf[2].b + Buf[3].b +
Buf[5].b + Buf[6].b + Buf[7].b + Buf[8].b) * 16) div 128);
Temp1.colorTable[i].rgbGreen := IntToByte((256 * Buf[4].g - (Buf[0].g + Buf[1].g + Buf[2].g + Buf[3].g +
Buf[5].g + Buf[6].g + Buf[7].g + Buf[8].g) * 16) div 128);
Temp1.colorTable[i].rgbRed := IntToByte((256 * Buf[4].r - (Buf[0].r + Buf[1].r + Buf[2].r + Buf[3].r +
Buf[5].r + Buf[6].r + Buf[7].r + Buf[8].r) * 16) div 128);
 
end;
end;
Temp1.UpdatePalette;
end;
4:
24: begin
P2 := Pointer(Integer(P2)+(Width-1)*3);
for x:=0 to Width-1 do
begin
Temp1 := TDIB.Create;
Temp1.Assign(self);
Temp1.SetSize(Width, Height, bitCount);
for i := 0 to 255 do
begin
with Temp1.ColorTable[i] do
begin
Buf[0].B := ColorTable[i - Amount].rgbBlue;
Buf[0].G := ColorTable[i - Amount].rgbGreen;
Buf[0].R := ColorTable[i - Amount].rgbRed;
Buf[1].B := ColorTable[i].rgbBlue;
Buf[1].G := ColorTable[i].rgbGreen;
Buf[1].R := ColorTable[i].rgbRed;
Buf[2].B := ColorTable[i + Amount].rgbBlue;
Buf[2].G := ColorTable[i + Amount].rgbGreen;
Buf[2].R := ColorTable[i + Amount].rgbRed;
Buf[3].B := ColorTable[i - Amount].rgbBlue;
Buf[3].G := ColorTable[i - Amount].rgbGreen;
Buf[3].R := ColorTable[i - Amount].rgbRed;
Buf[4].B := ColorTable[i].rgbBlue;
Buf[4].G := ColorTable[i].rgbGreen;
Buf[4].R := ColorTable[i].rgbRed;
Buf[5].B := ColorTable[i + Amount].rgbBlue;
Buf[5].G := ColorTable[i + Amount].rgbGreen;
Buf[5].R := ColorTable[i + Amount].rgbRed;
Buf[6].B := ColorTable[i - Amount].rgbBlue;
Buf[6].G := ColorTable[i - Amount].rgbGreen;
Buf[6].R := ColorTable[i - Amount].rgbRed;
Buf[7].B := ColorTable[i].rgbBlue;
Buf[7].G := ColorTable[i].rgbGreen;
Buf[7].R := ColorTable[i].rgbRed;
Buf[8].B := ColorTable[i + Amount].rgbBlue;
Buf[8].G := ColorTable[i + Amount].rgbGreen;
Buf[8].R := ColorTable[i + Amount].rgbRed;
colorTable[i].rgbBlue := IntToByte((256 * Buf[4].b - (Buf[0].b + Buf[1].b + Buf[2].b + Buf[3].b +
Buf[5].b + Buf[6].b + Buf[7].b + Buf[8].b) * 16) div 128);
colorTable[i].rgbGreen := IntToByte((256 * Buf[4].g - (Buf[0].g + Buf[1].g + Buf[2].g + Buf[3].g +
Buf[5].g + Buf[6].g + Buf[7].g + Buf[8].g) * 16) div 128);
colorTable[i].rgbRed := IntToByte((256 * Buf[4].r - (Buf[0].r + Buf[1].r + Buf[2].r + Buf[3].r +
Buf[5].r + Buf[6].r + Buf[7].r + Buf[8].r) * 16) div 128);
PBGR(@c)^ := PBGR(P1)^;
PBGR(P1)^ := PBGR(P2)^;
PBGR(P2)^ := PBGR(@c)^;
Inc(PBGR(P1));
Dec(PBGR(P2));
end;
end;
UpdatePalette;
end;
end;
for y := 0 to Pred(Height) do
32: begin
P2 := Pointer(Integer(P2)+(Width-1)*4);
for x:=0 to Width-1 do
begin
Lin0 := ScanLine[Interval(0, Pred(Height), y - Amount, True)];
Lin1 := ScanLine[y];
Lin2 := ScanLine[Interval(0, Pred(Height), y + Amount, True)];
case Bitcount of
24, 8, 4: D := Temp1.ScanLine[y];
PDWORD(@c)^ := PDWORD(P1)^;
PDWORD(P1)^ := PDWORD(P2)^;
PDWORD(P2)^ := PDWORD(@c)^;
Inc(PDWORD(P1));
Dec(PDWORD(P2));
end;
for x := 0 to Pred(Width) do
begin
case BitCount of
24:
begin
cx := Interval(0, Pred(Width), x - Amount, True);
Buf[0] := Lin0[cx];
Buf[1] := Lin1[cx];
Buf[2] := Lin2[cx];
Buf[3] := Lin0[x];
Buf[4] := Lin1[x];
Buf[5] := Lin2[x];
cx := Interval(0, Pred(Width), x + Amount, true);
Buf[6] := Lin0[cx];
Buf[7] := Lin1[cx];
Buf[8] := Lin0[cx];
pc.b := IntToByte((256 * Buf[4].b - (Buf[0].b + Buf[1].b + Buf[2].b + Buf[3].b +
Buf[5].b + Buf[6].b + Buf[7].b + Buf[8].b) * 16) div 128);
pc.g := IntToByte((256 * Buf[4].g - (Buf[0].g + Buf[1].g + Buf[2].g + Buf[3].g +
Buf[5].g + Buf[6].g + Buf[7].g + Buf[8].g) * 16) div 128);
pc.r := IntToByte((256 * Buf[4].r - (Buf[0].r + Buf[1].r + Buf[2].r + Buf[3].r +
Buf[5].r + Buf[6].r + Buf[7].r + Buf[8].r) * 16) div 128);
PBGR(D)^.B := pc.b;
PBGR(D)^.G := pc.g;
PBGR(D)^.R := pc.r;
Inc(PBGR(D));
end;
8:
begin
Inc(PByte(D));
end;
4:
begin
P1 := @PArrayByte(D)[X shr 1];
P1^ := ((P1^ and Mask4n[X and 1]) or ((c shl Shift4[X and 1])));
end;
end;
end;
end;
case BitCount of
24, 8:
begin
Assign(Temp1);
Temp1.Free;
end;
4: Temp1.Free;
end;
FreeMem(pc, SizeOf(TBGR));
end;
 
procedure TDIB.Emboss;
var
x, y: longint;
D, D1, P: pointer;
color: TBGR;
c: DWORD;
P1: PByte;
 
begin
D := nil;
D1 := nil;
P := nil;
case BitCount of
32, 16, 1: Exit;
24:
begin
D := PBits;
D1 := Ptr(Integer(D) + 3);
UpdateProgress(y*2);
end;
else
finally
EndProgress;
end;
for y := 0 to Pred(Height) do
begin
case Bitcount of
8, 4:
begin
P := ScanLine[y];
end;
end;
for x := 0 to Pred(Width) do
begin
case BitCount of
24:
begin
PBGR(D)^.B := ((PBGR(D)^.B + (PBGR(D1)^.B xor $FF)) shr 1);
PBGR(D)^.G := ((PBGR(D)^.G + (PBGR(D1)^.G xor $FF)) shr 1);
PBGR(D)^.R := ((PBGR(D)^.R + (PBGR(D1)^.R xor $FF)) shr 1);
Inc(PBGR(D));
if (y < Height - 2) and (x < Width - 2) then
Inc(PBGR(D1));
end;
8:
begin
color.R := (((Pixels[x, y] + (Pixels[x + 3, y] xor $FF)) shr 1) + 30) div 3;
color.G := (((Pixels[x, y] + (Pixels[x + 3, y] xor $FF)) shr 1) + 30) div 3;
color.B := (((Pixels[x, y] + (Pixels[x + 3, y] xor $FF)) shr 1) + 30) div 3;
c := (color.R + color.G + color.B) shr 1;
PByte(P)^ := c;
Inc(PByte(P));
end;
4:
begin
color.R := (((Pixels[x, y] + (Pixels[x + 3, y] xor $FF) + 1) shr 1) + 30) div 3;
color.G := (((Pixels[x, y] + (Pixels[x + 3, y] xor $FF) - 1) shr 1) + 30) div 3;
color.B := (((Pixels[x, y] + (Pixels[x + 3, y] xor $FF) + 1) shr 1) + 30) div 3;
c := (color.R + color.G + color.B) shr 1;
if c > 64 then
c := c - 8;
P1 := @PArrayByte(P)[X shr 1];
P1^ := (P1^ and Mask4n[X and 1]) or ((c) shl Shift4[X and 1]);
end;
else
end;
end;
case BitCount of
24:
begin
D := Ptr(Integer(D1));
if y < Height - 2 then
D1 := Ptr(Integer(D1) + 6)
else
D1 := Ptr(Integer(ScanLine[Pred(Height)]) + 3);
end;
else
end;
end;
end;
 
procedure TDIB.AddMonoNoise(Amount: Integer);
procedure TDIB.Negative;
var
value: cardinal;
x, y: longint;
a: byte;
D: pointer;
color: DWORD;
P: PByte;
i, i2: Integer;
P: Pointer;
begin
for y := 0 to Pred(Height) do
begin
D := ScanLine[y];
for x := 0 to Pred(Width) do
begin
case BitCount of
32: Exit; // I haven't bitmap of this type ! Sorry
24:
begin
value := Random(Amount) - (Amount shr 1);
PBGR(D)^.B := IntToByte(PBGR(D)^.B + value);
PBGR(D)^.G := IntToByte(PBGR(D)^.G + value);
PBGR(D)^.R := IntToByte(PBGR(D)^.R + value);
Inc(PBGR(D));
end;
16: Exit; // I haven't bitmap of this type ! Sorry
8:
begin
a := ((Random(Amount shr 1) - (Amount div 4))) div 8;
color := Interval(0, 255, (pixels[x, y] - a), True);
PByte(D)^ := color;
Inc(PByte(D));
end;
4:
begin
a := ((Random(Amount shr 1) - (Amount div 4))) div 16;
color := Interval(0, 15, (pixels[x, y] - a), True);
P := @PArrayByte(D)[X shr 1];
P^ := ((P^ and Mask4n[X and 1]) or ((color shl Shift4[X and 1])));
end;
1:
begin
a := ((Random(Amount shr 1) - (Amount div 4))) div 32;
color := Interval(0, 1, (pixels[x, y] - a), True);
P := @PArrayByte(D)[X shr 3];
P^ := (P^ and Mask1n[X and 7]) or (color shl Shift1[X and 7]);
end;
else
end;
end;
end;
end;
if Empty then exit;
 
procedure TDIB.AddGradiantNoise(Amount: byte);
var
a, i: byte;
x, y: Integer;
Table: array[0..255] of TBGR;
S, D: pointer;
color: DWORD;
Temp1: TDIB;
P: PByte;
 
if BitCount<=8 then
begin
D := nil;
S := nil;
Temp1 := nil;
case BitCount of
32: Exit; // I haven't bitmap of this type ! Sorry
24:
begin
for i := 0 to 255 do
begin
a := Random(Amount);
Table[i].b := IntToByte(i + a);
Table[i].g := IntToByte(i + a);
Table[i].r := IntToByte(i + a);
end;
end;
16: Exit; // I haven't bitmap of this type ! Sorry
8, 4:
begin
Temp1 := TDIB.Create;
Temp1.Assign(self);
Temp1.SetSize(Width, Height, BitCount);
for i := 0 to 255 do
begin
with ColorTable[i] do
begin
a := Random(Amount);
rgbRed := IntToByte(rgbRed + a);
rgbGreen := IntToByte(rgbGreen + a);
rgbBlue := IntToByte(rgbBlue + a);
rgbRed := 255-rgbRed;
rgbGreen := 255-rgbGreen;
rgbBlue := 255-rgbBlue;
end;
end;
UpdatePalette;
end;
else
// if the number of pixel is equal to 1 then exit of procedure
Exit;
end;
for y := 0 to Pred(Height) do
end else
begin
case BitCount of
24: D := ScanLine[y];
8, 4:
begin
D := Temp1.ScanLine[y];
S := Temp1.ScanLine[y];
end;
else
end;
for x := 0 to Pred(Width) do
begin
case BitCount of
32: ; // I haven't bitmap of this type ! Sorry
24:
begin
PBGR(D)^.B := Table[PBGR(D)^.B].b;
PBGR(D)^.G := Table[PBGR(D)^.G].g;
PBGR(D)^.R := Table[PBGR(D)^.R].r;
Inc(PBGR(D));
end;
16: ; // I haven't bitmap of this type ! Sorry
8:
begin
with Temp1.ColorTable[PByte(S)^] do
color := rgbRed + rgbGreen + rgbBlue;
Inc(PByte(S));
PByte(D)^ := color;
Inc(PByte(D));
end;
4:
begin
with Temp1.ColorTable[PByte(S)^] do
color := rgbRed + rgbGreen + rgbBlue;
Inc(PByte(S));
P := @PArrayByte(D)[X shr 1];
P^ := (P^ and Mask4n[X and 1]) or (color shl Shift4[X and 1]);
end;
else
end;
end;
end;
case BitCount of
8, 4: Temp1.Free;
else
end;
end;
P := PBits;
i2 := Size;
asm
mov ecx,i2
mov eax,P
mov edx,ecx
 
function TDIB.FishEye(bmp: TDIB): Boolean;
var
weight, xmid, ymid, fx, fy, r1, r2, dx, dy, rmax: Double;
Amount, ifx, ify, ty, tx, new_red, new_green, new_blue, ix, iy: Integer;
weight_x, weight_y: array[0..1] of Double;
total_red, total_green, total_blue: Double;
sli, slo: PLines;
//D: Pointer;
begin
Result := True;
case BitCount of
32, 16, 8, 4, 1:
begin
Result := False;
Exit;
end;
end;
Amount := 1;
xmid := Width / 2;
ymid := Height / 2;
rmax := Max(Bmp.Width, Bmp.Height) * Amount;
for ty := 0 to Pred(Height) do
begin
for tx := 0 to Pred(Width) do
begin
dx := tx - xmid;
dy := ty - ymid;
r1 := Sqrt(Sqr(dx) + Sqr(dy));
if r1 <> 0 then
begin
r2 := rmax / 2 * (1 / (1 - r1 / rmax) - 1);
fx := dx * r2 / r1 + xmid;
fy := dy * r2 / r1 + ymid;
end
else
begin
fx := xmid;
fy := ymid;
end;
ify := Trunc(fy);
ifx := Trunc(fx);
if fy >= 0 then
begin
weight_y[1] := fy - ify;
weight_y[0] := 1 - weight_y[1];
end
else
begin
weight_y[0] := -(fy - ify);
weight_y[1] := 1 - weight_y[0];
end;
if fx >= 0 then
begin
weight_x[1] := fx - ifx;
weight_x[0] := 1 - weight_x[1];
end
else
begin
weight_x[0] := -(fx - ifx);
Weight_x[1] := 1 - weight_x[0];
end;
if ifx < 0 then
ifx := Pred(Width) - (-ifx mod Width)
else
if ifx > Pred(Width) then
ifx := ifx mod Width;
if ify < 0 then
ify := Pred(Height) - (-ify mod Height)
else
if ify > Pred(Height) then
ify := ify mod Height;
total_red := 0.0;
total_green := 0.0;
total_blue := 0.0;
for ix := 0 to 1 do
begin
for iy := 0 to 1 do
begin
if ify + iy < Height then
sli := ScanLine[ify + iy]
else
sli := ScanLine[Height - ify - iy];
if ifx + ix < Width then
begin
new_red := sli^[ifx + ix].r;
new_green := sli^[ifx + ix].g;
new_blue := sli^[ifx + ix].b;
end
else
begin
new_red := sli^[Width - ifx - ix].r;
new_green := sli^[Width - ifx - ix].g;
new_blue := sli^[Width - ifx - ix].b;
end;
weight := weight_x[ix] * weight_y[iy];
total_red := total_red + new_red * weight;
total_green := total_green + new_green * weight;
total_blue := total_blue + new_blue * weight;
end;
end;
case bitCount of
24:
begin
slo := Bmp.ScanLine[ty];
slo^[tx].r := Round(total_red);
slo^[tx].g := Round(total_green);
slo^[tx].b := Round(total_blue);
end;
else
// You can implement this procedure for 16,8,4,2 and 32 BitCount's DIB
Exit;
end;
end;
end;
end;
{ Unit of DWORD. }
@@qword_skip:
shr ecx,2
jz @@dword_skip
 
function TDIB.SmoothRotateWrap(Bmp: TDIB; cx, cy: Integer; Degree: Extended): Boolean;
var
weight, Theta, cosTheta, sinTheta, sfrom_y, sfrom_x: Double;
ifrom_y, ifrom_x, xDiff, yDiff, to_y, to_x: Integer;
weight_x, weight_y: array[0..1] of Double;
ix, iy, new_red, new_green, new_blue: Integer;
total_red, total_green, total_blue: Double;
sli, slo: PLines;
begin
Result := True;
case BitCount of
32, 16, 8, 4, 1:
begin
Result := False;
Exit;
end;
end;
Theta := -Degree * Pi / 180;
sinTheta := Sin(Theta);
cosTheta := Cos(Theta);
xDiff := (Bmp.Width - Width) div 2;
yDiff := (Bmp.Height - Height) div 2;
for to_y := 0 to Pred(Bmp.Height) do
begin
for to_x := 0 to Pred(Bmp.Width) do
begin
sfrom_x := (cx + (to_x - cx) * cosTheta - (to_y - cy) * sinTheta) - xDiff;
ifrom_x := Trunc(sfrom_x);
sfrom_y := (cy + (to_x - cx) * sinTheta + (to_y - cy) * cosTheta) - yDiff;
ifrom_y := Trunc(sfrom_y);
if sfrom_y >= 0 then
begin
weight_y[1] := sfrom_y - ifrom_y;
weight_y[0] := 1 - weight_y[1];
end
else
begin
weight_y[0] := -(sfrom_y - ifrom_y);
weight_y[1] := 1 - weight_y[0];
end;
if sfrom_x >= 0 then
begin
weight_x[1] := sfrom_x - ifrom_x;
weight_x[0] := 1 - weight_x[1];
end
else
begin
weight_x[0] := -(sfrom_x - ifrom_x);
Weight_x[1] := 1 - weight_x[0];
end;
if ifrom_x < 0 then
ifrom_x := Pred(Width) - (-ifrom_x mod Width)
else
if ifrom_x > Pred(Width) then
ifrom_x := ifrom_x mod Width;
if ifrom_y < 0 then
ifrom_y := Pred(Height) - (-ifrom_y mod Height)
else
if ifrom_y > Pred(Height) then
ifrom_y := ifrom_y mod Height;
total_red := 0.0;
total_green := 0.0;
total_blue := 0.0;
for ix := 0 to 1 do
begin
for iy := 0 to 1 do
begin
if ifrom_y + iy < Height then
sli := ScanLine[ifrom_y + iy]
else
sli := ScanLine[Height - ifrom_y - iy];
if ifrom_x + ix < Width then
begin
new_red := sli^[ifrom_x + ix].r;
new_green := sli^[ifrom_x + ix].g;
new_blue := sli^[ifrom_x + ix].b;
end
else
begin
new_red := sli^[Width - ifrom_x - ix].r;
new_green := sli^[Width - ifrom_x - ix].g;
new_blue := sli^[Width - ifrom_x - ix].b;
end;
weight := weight_x[ix] * weight_y[iy];
total_red := total_red + new_red * weight;
total_green := total_green + new_green * weight;
total_blue := total_blue + new_blue * weight;
end;
end;
case bitCount of
24:
begin
slo := Bmp.ScanLine[to_y];
slo^[to_x].r := Round(total_red);
slo^[to_x].g := Round(total_green);
slo^[to_x].b := Round(total_blue);
end;
else
// You can implement this procedure for 16,8,4,2 and 32 BitCount's DIB
Exit;
end;
end;
end;
end;
dec ecx
@@dword_loop:
not dword ptr [eax+ecx*4]
dec ecx
jnl @@dword_loop
 
function TDIB.Rotate(Dst: TDIB; cx, cy: Integer; Angle: Double): Boolean;
var
x, y, dx, dy, sdx, sdy, xDiff, yDiff, isinTheta, icosTheta: Integer;
D, S: Pointer;
sinTheta, cosTheta, Theta: Double;
Col: TBGR;
i: byte;
color: DWORD;
P: PByte;
begin
D := nil;
S := nil;
Result := True;
dst.SetSize(Width, Height, Bitcount);
dst.Canvas.Brush.Color := clBlack;
Dst.Canvas.FillRect(Bounds(0, 0, Width, Height));
case BitCount of
32, 16:
begin
Result := False;
Exit;
end;
8, 4, 1:
begin
for i := 0 to 255 do
Dst.ColorTable[i] := ColorTable[i];
Dst.UpdatePalette;
end;
end;
Theta := -Angle * Pi / 180;
sinTheta := Sin(Theta);
cosTheta := Cos(Theta);
xDiff := (Dst.Width - Width) div 2;
yDiff := (Dst.Height - Height) div 2;
isinTheta := Round(sinTheta * $10000);
icosTheta := Round(cosTheta * $10000);
for y := 0 to Pred(Dst.Height) do
begin
case BitCount of
4, 1:
begin
D := Dst.ScanLine[y];
S := ScanLine[y];
end;
else
end;
sdx := Round(((cx + (-cx) * cosTheta - (y - cy) * sinTheta) - xDiff) * $10000);
sdy := Round(((cy + (-cy) * sinTheta + (y - cy) * cosTheta) - yDiff) * $10000);
for x := 0 to Pred(Dst.Width) do
begin
dx := (sdx shr 16);
dy := (sdy shr 16);
if (dx > -1) and (dx < Width) and (dy > -1) and (dy < Height) then
begin
case bitcount of
8, 24: Dst.pixels[x, y] := Pixels[dx, dy];
4:
begin
pfGetRGB(NowPixelFormat, Pixels[dx, dy], col.r, col.g, col.b);
color := col.r + col.g + col.b;
Inc(PByte(S));
P := @PArrayByte(D)[x shr 1];
P^ := (P^ and Mask4n[x and 1]) or (color shl Shift4[x and 1]);
end;
1:
begin
pfGetRGB(NowPixelFormat, Pixels[dx, dy], col.r, col.g, col.b);
color := col.r + col.g + col.b;
Inc(PByte(S));
P := @PArrayByte(D)[X shr 3];
P^ := (P^ and Mask1n[X and 7]) or (color shl Shift1[X and 7]);
end;
end;
end;
Inc(sdx, icosTheta);
Inc(sdy, isinTheta);
end;
end;
end;
mov ecx,edx
shr ecx,2
add eax,ecx*4
 
procedure TDIB.GaussianBlur(Bmp: TDIB; Amount: Integer);
var
i: Integer;
begin
for i := 1 to Amount do
Bmp.SplitBlur(i);
end;
{ Unit of Byte. }
@@dword_skip:
mov ecx,edx
and ecx,3
jz @@byte_skip
 
procedure TDIB.SplitBlur(Amount: Integer);
var
Lin1, Lin2: PLines;
cx, x, y: Integer;
Buf: array[0..3] of TBGR;
D: Pointer;
dec ecx
@@loop_byte:
not byte ptr [eax+ecx]
dec ecx
jnl @@loop_byte
 
begin
case Bitcount of
32, 16, 8, 4, 1: Exit;
@@byte_skip:
end;
for y := 0 to Pred(Height) do
begin
Lin1 := ScanLine[TrimInt(y + Amount, 0, Pred(Height))];
Lin2 := ScanLine[TrimInt(y - Amount, 0, Pred(Height))];
D := ScanLine[y];
for x := 0 to Pred(Width) do
begin
cx := TrimInt(x + Amount, 0, Pred(Width));
Buf[0] := Lin1[cx];
Buf[1] := Lin2[cx];
cx := TrimInt(x - Amount, 0, Pred(Width));
Buf[2] := Lin1[cx];
Buf[3] := Lin2[cx];
PBGR(D)^.b := (Buf[0].b + Buf[1].b + Buf[2].b + Buf[3].b) shr 2;
PBGR(D)^.g := (Buf[0].g + Buf[1].g + Buf[2].g + Buf[3].g) shr 2;
PBGR(D)^.r := (Buf[0].r + Buf[1].r + Buf[2].r + Buf[3].r) shr 2;
Inc(PBGR(D));
end;
end;
end;
 
function TDIB.Twist(bmp: TDIB; Amount: byte): Boolean;
var
fxmid, fymid: Single;
txmid, tymid: Single;
fx, fy: Single;
tx2, ty2: Single;
r: Single;
theta: Single;
ifx, ify: Integer;
dx, dy: Single;
OFFSET: Single;
ty, tx, ix, iy: Integer;
weight_x, weight_y: array[0..1] of Single;
weight: Single;
new_red, new_green, new_blue: Integer;
total_red, total_green, total_blue: Single;
sli, slo: PLines;
 
function ArcTan2(xt, yt: Single): Single; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if xt = 0 then
if yt > 0 then
Result := Pi / 2
else
Result := -(Pi / 2)
else
begin
Result := ArcTan(yt / xt);
if xt < 0 then
Result := Pi + ArcTan(yt / xt);
end;
end;
 
begin
Result := True;
case BitCount of
32, 16, 8, 4, 1:
begin
Result := False;
Exit;
end;
end;
if Amount = 0 then
Amount := 1;
OFFSET := -(Pi / 2);
dx := Pred(Width);
dy := Pred(Height);
r := Sqrt(dx * dx + dy * dy);
tx2 := r;
ty2 := r;
txmid := (Pred(Width)) / 2;
tymid := (Pred(Height)) / 2;
fxmid := (Pred(Width)) / 2;
fymid := (Pred(Height)) / 2;
if tx2 >= Width then
tx2 := Pred(Width);
if ty2 >= Height then
ty2 := Pred(Height);
for ty := 0 to Round(ty2) do
begin
for tx := 0 to Round(tx2) do
begin
dx := tx - txmid;
dy := ty - tymid;
r := Sqrt(dx * dx + dy * dy);
if r = 0 then
begin
fx := 0;
fy := 0;
end
else
begin
theta := ArcTan2(dx, dy) - r / Amount - OFFSET;
fx := r * Cos(theta);
fy := r * Sin(theta);
end;
fx := fx + fxmid;
fy := fy + fymid;
ify := Trunc(fy);
ifx := Trunc(fx);
if fy >= 0 then
begin
weight_y[1] := fy - ify;
weight_y[0] := 1 - weight_y[1];
end
else
begin
weight_y[0] := -(fy - ify);
weight_y[1] := 1 - weight_y[0];
end;
if fx >= 0 then
begin
weight_x[1] := fx - ifx;
weight_x[0] := 1 - weight_x[1];
end
else
begin
weight_x[0] := -(fx - ifx);
Weight_x[1] := 1 - weight_x[0];
end;
if ifx < 0 then
ifx := Pred(Width) - (-ifx mod Width)
else
if ifx > Pred(Width) then
ifx := ifx mod Width;
if ify < 0 then
ify := Pred(Height) - (-ify mod Height)
else
if ify > Pred(Height) then
ify := ify mod Height;
total_red := 0.0;
total_green := 0.0;
total_blue := 0.0;
for ix := 0 to 1 do
begin
for iy := 0 to 1 do
begin
if ify + iy < Height then
sli := ScanLine[ify + iy]
else
sli := ScanLine[Height - ify - iy];
if ifx + ix < Width then
begin
new_red := sli^[ifx + ix].r;
new_green := sli^[ifx + ix].g;
new_blue := sli^[ifx + ix].b;
end
else
begin
new_red := sli^[Width - ifx - ix].r;
new_green := sli^[Width - ifx - ix].g;
new_blue := sli^[Width - ifx - ix].b;
end;
weight := weight_x[ix] * weight_y[iy];
total_red := total_red + new_red * weight;
total_green := total_green + new_green * weight;
total_blue := total_blue + new_blue * weight;
end;
end;
case bitCount of
24:
begin
slo := bmp.ScanLine[ty];
slo^[tx].r := Round(total_red);
slo^[tx].g := Round(total_green);
slo^[tx].b := Round(total_blue);
end;
else
// You can implement this procedure for 16,8,4,2 and 32 BitCount's DIB
Exit;
end;
end;
end;
end;
 
function TDIB.TrimInt(i, Min, Max: Integer): Integer;
begin
if i > Max then
Result := Max
else
if i < Min then
Result := Min
else
Result := i;
end;
 
function TDIB.IntToByte(i: Integer): Byte;
begin
if i > 255 then
Result := 255
else
if i < 0 then
Result := 0
else
Result := i;
end;
 
//--------------------------------------------------------------------------------------------------
// End of these New Special Effect //
// Please contributes to add effects and filters to this collection //
// Please, work to implement 32,16,8,4,2 BitCount's DIB //
// Have fun - Mickey - Good job //
//--------------------------------------------------------------------------------------------------
 
function TDIB.GetAlphaChannel: TDIB;
var
I: Integer;
begin
RetAlphaChannel(Result);
if Result = nil then Exit;
 
if FFreeList.Count > 0 then
for I := 0 to FFreeList.Count - 1 do
if FFreeList[I] = Result then Exit;
 
FFreeList.Add(Result);
end;
 
procedure TDIB.SetAlphaChannel(const Value: TDIB);
begin
if not AssignAlphaChannel(Value{$IFNDEF VER4UP}, False{$ENDIF}) then
Exception.Create('Cannot set alphachannel from DIB.');
end;
 
procedure TDIB.Fill(aColor: TColor);
var
p: PRGBA;
y: Integer;
x: Integer;
begin
Canvas.Brush.Color := aColor;
Canvas.FillRect(ClientRect);
if Self.BitCount = 32 then
begin
//fill alpha chanell too with $FF
for Y := 0 to Self.Height - 1 do
begin
p := Self.ScanLine[Y];
for X := 0 to Self.Width - 1 do
begin
p[X].rgbReserved := $FF
end;
end;
end;
end;
 
function TDIB.GetClientRect: TRect;
begin
Result := Bounds(0, 0, Width, Height);
end;
 
{ TCustomDXDIB }
 
constructor TCustomDXDIB.Create(AOnwer: TComponent);
5476,20 → 3078,17
begin
inherited Canvas.StretchDraw(Bounds(-(Width - ClientWidth) div 2,
-(Height - ClientHeight) div 2, Width, Height), FDIB);
end
else
end else
begin
inherited Canvas.StretchDraw(Bounds(0, 0, Width, Height), FDIB);
end;
end
else
end else
begin
if FCenter then
begin
inherited Canvas.Draw(-(Width - ClientWidth) div 2, -(Height - ClientHeight) div 2,
FDIB);
end
else
end else
begin
inherited Canvas.Draw(0, 0, FDIB);
end;
5529,14 → 3128,11
if r > r2 then
r := r2;
Draw2(Round(r * ClientWidth), Round(r * ClientHeight));
end
else
end else
Draw2(ViewWidth2, ViewHeight2);
end
else
end else
Draw2(ViewWidth2, ViewHeight2);
end
else
end else
begin
if FAutoStretch then
begin
5547,11 → 3143,9
if r > r2 then
r := r2;
Draw2(Round(r * FDIB.Width), Round(r * FDIB.Height));
end
else
end else
Draw2(FDIB.Width, FDIB.Height);
end
else
end else
if FStretch then
begin
if FKeepAspect then
5561,11 → 3155,9
if r > r2 then
r := r2;
Draw2(Round(r * FDIB.Width), Round(r * FDIB.Height));
end
else
end else
Draw2(ClientWidth, ClientHeight);
end
else
end else
Draw2(FDIB.Width, FDIB.Height);
end;
end;
5636,4548 → 3228,6
end;
end;
 
{ DXFusion -> }
 
function PosValue(Value: Integer): Integer;
begin
if Value < 0 then result := 0 else result := Value;
end;
 
procedure TDIB.CreateDIBFromBitmap(const Bitmap: TBitmap);
var
pf: Integer;
X, Y: Integer;
P: PLinesA;
q: PRGBA;
begin
if Bitmap.PixelFormat = pf32bit then pf := 32 else pf := 24;
SetSize(Bitmap.Width, Bitmap.Height, pf); {always >=24}
Canvas.Brush.Color := clWhite;
Canvas.FillRect(Bounds(0, 0, Width, Height));
Canvas.Draw(0, 0, Bitmap);
//Note. Transparent background from bitmap is not drawed when is alphalayer active
if (pf = 32) {and (Bitmap.AlphaFormat <> afIgnored)} then
begin
for y := 0 to Bitmap.Height-1 do
begin
p := Bitmap.ScanLine[y]; //BGRA
q := Self.ScanLine[y]; //ARGB
for x := 0 to Width-1 do //copy only alphachannel
q[x].rgbReserved := P[x].A;
end;
end;
end;
 
function TDIB.CreateBitmapFromDIB: TBitmap;
var
ach: Boolean;
X, Y: Integer;
P: PLinesA;
q: PRGBA;
begin
ach := False;
Result := TBitmap.Create;
case BitCount of
32:
begin
Result.PixelFormat := pf32bit;
ach := HasAlphaChannel;
end;
24: Result.PixelFormat := pf24bit;
15: Result.PixelFormat := pf16bit;
8: Result.PixelFormat := pf8bit;
else
Result.PixelFormat := pf24bit;
end;
 
Result.Width := Width;
Result.Height := Height;
Result.Canvas.Draw(0, 0, Self);
if (BitCount = 32) then
begin
if ach then
begin
{$IFDEF VER16UP}
Result.AlphaFormat := afDefined;
{$ENDIF}
for y := 0 to Height-1 do
begin
p := Result.ScanLine[y]; //BGRA
q := Self.ScanLine[y]; //ARGB
for x := 0 to Width-1 do //copy only alphachannel
P[x].A := q[x].rgbReserved;
end;
end;
end;
end;
 
procedure TDIB.DrawTo(SrcDIB: TDIB; X, Y, Width, Height,
SourceX, SourceY: Integer);
begin
SrcDIB.DrawOn(Rect(X, Y, Width, Height), Self.Canvas, SourceX, SourceY);
end;
 
procedure TDIB.DrawTransparent(SrcDIB: TDIB; const X, Y, Width, Height,
SourceX, SourceY: Integer; const Color: TColor);
var
i, j: Integer;
k1, k2: Integer;
n: Integer;
p1, p2: PByteArray;
 
Startk1, Startk2: Integer;
 
StartY: Integer;
EndY: Integer;
 
DestStartY: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
Startk1 := 3 * SourceX;
Startk2 := 3 * X;
 
DestStartY := Y - SourceY;
 
StartY := SourceY;
EndY := SourceY + Height;
 
if (StartY + DestStartY < 0) then
StartY := -DestStartY;
if (EndY + DestStartY > Self.Height) then
EndY := Self.Height - DestStartY;
 
if (StartY < 0) then
StartY := 0;
if (EndY > SrcDIB.Height) then
EndY := SrcDIB.Height;
 
for j := StartY to EndY - 1 do
begin
p1 := Self.Scanline[j + DestStartY];
p2 := SrcDIB.Scanline[j];
 
k1 := Startk1;
k2 := Startk2;
 
for i := SourceX to SourceX + Width - 1 do
begin
n := (p2[k1] shl 16) + (p2[k1 + 1] shl 8) + p2[k1 + 2];
 
if not (n = Color) then
begin
p1[k2] := p2[k1];
p1[k2 + 1] := p2[k1 + 1];
p1[k2 + 2] := p2[k1 + 2];
end;
 
k1 := k1 + 3;
k2 := k2 + 3;
end;
end;
end;
 
procedure TDIB.DrawShadow(SrcDIB: TDIB; X, Y, Width, Height,
Frame: Integer; FilterMode: TFilterMode);
var
i, j: Integer;
p1, p2: PByte;
FW: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
FW := Frame * Width;
for i := 1 to Height - 1 do
begin
p1 := Self.Scanline[i + Y];
p2 := SrcDIB.Scanline[i];
Inc(p1, 3 * (X + 1));
Inc(p2, 3 * (FW + 1));
for j := 1 to Width - 1 do
begin
if (p2^ = 0) then
begin
case FilterMode of
fmNormal, fmMix50:
begin
p1^ := p1^ shr 1; // Blue
Inc(p1);
p1^ := p1^ shr 1; // Green
Inc(p1);
p1^ := p1^ shr 1; // Red
Inc(p1);
end;
fmMix25:
begin
p1^ := p1^ - p1^ shr 2; // Blue
Inc(p1);
p1^ := p1^ - p1^ shr 2; // Green
Inc(p1);
p1^ := p1^ - p1^ shr 2; // Red
Inc(p1);
end;
fmMix75:
begin
p1^ := p1^ shr 2; // Blue
Inc(p1);
p1^ := p1^ shr 2; // Green
Inc(p1);
p1^ := p1^ shr 2; // Red
Inc(p1);
end;
end;
end
else
Inc(p1, 3); // Not in the loop...
Inc(p2, 3);
end;
end;
end;
 
procedure TDIB.DrawShadows(SrcDIB: TDIB; X, Y, Width, Height,
Frame: Integer; Alpha: Byte);
{plynule nastavovani stiny dle alpha}
type
P3ByteArray = ^T3ByteArray;
T3ByteArray = array[0..32767] of TBGR;
var
i, j, l1, l2: Integer;
p1, p2: P3ByteArray;
FW: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
FW := Frame * Width;
for i := 0 to Height - 1 do
begin
p1 := Self.Scanline[i + Y];
p2 := SrcDIB.Scanline[i];
l1 := X;
l2 := FW;
for j := 0 to Width - 1 do
begin
if (p2[j + l2].B = 0) and (p2[j + l2].G = 0) and (p2[j + l2].R = 0) then
begin
p1[J + l1].B := Round(p1[J + l1].B / $FF * Alpha);
p1[J + l1].G := Round(p1[J + l1].G / $FF * Alpha);
p1[J + l1].R := Round(p1[J + l1].R / $FF * Alpha);
end
end;
end;
end;
 
procedure TDIB.DrawDarken(SrcDIB: TDIB; X, Y, Width, Height,
Frame: Integer);
var
frameoffset, i, j: Integer;
p1, p2: pByte;
XOffset: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
frameoffset := 3 * (Frame * Width) + 3;
XOffset := 3 * X + 3;
for i := 1 to Height - 1 do
begin
p1 := Self.Scanline[i + Y];
p2 := SrcDIB.Scanline[i];
inc(p1, XOffset);
inc(p2, frameoffset);
for j := 1 to Width - 1 do
begin
p1^ := (p2^ * p1^) shr 8; // R
inc(p1);
inc(p2);
p1^ := (p2^ * p1^) shr 8; // G
inc(p1);
inc(p2);
p1^ := (p2^ * p1^) shr 8; // B
inc(p1);
inc(p2);
end;
end;
end;
 
procedure TDIB.DrawQuickAlpha(SrcDIB: TDIB; const X, Y, Width, Height,
SourceX, SourceY: Integer; const Color: TColor; FilterMode: TFilterMode);
var
i, j: Integer;
k1, k2: Integer;
n: Integer;
p1, p2: PByteArray;
BitSwitch1, BitSwitch2: Boolean;
 
Startk1, Startk2: Integer;
StartY: Integer;
EndY: Integer;
 
DestStartY: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
Startk1 := 3 * SourceX;
Startk2 := 3 * X;
 
DestStartY := Y - SourceY;
 
StartY := SourceY;
EndY := SourceY + Height;
 
if (StartY + DestStartY < 0) then
StartY := -DestStartY;
if (EndY + DestStartY > Self.Height) then
EndY := Self.Height - DestStartY;
 
if (StartY < 0) then
StartY := 0;
if (EndY > SrcDIB.Height) then
EndY := SrcDIB.Height;
 
if Odd(Y) then BitSwitch1 := true else BitSwitch1 := false;
if Odd(X) then BitSwitch2 := true else BitSwitch2 := false;
 
for j := StartY to EndY - 1 do
begin
BitSwitch1 := not BitSwitch1;
p1 := Self.Scanline[j + DestStartY];
p2 := SrcDIB.Scanline[j];
 
k1 := Startk1;
k2 := Startk2;
 
for i := SourceX to SourceX + Width - 1 do
begin
BitSwitch2 := not BitSwitch2;
 
n := (p2[k1] shl 16) + (p2[k1 + 1] shl 8) + p2[k1 + 2];
 
case FilterMode of
fmNormal, fmMix50: if not (n = Color) and (BitSwitch1 xor BitSwitch2) then
begin
p1[k2] := p2[k1];
p1[k2 + 1] := p2[k1 + 1];
p1[k2 + 2] := p2[k1 + 2];
end;
fmMix25: if not (n = Color) and (BitSwitch1 and BitSwitch2) then
begin
p1[k2] := p2[k1];
p1[k2 + 1] := p2[k1 + 1];
p1[k2 + 2] := p2[k1 + 2];
end;
fmMix75: if not (n = Color) and (BitSwitch1 or BitSwitch2) then
begin
p1[k2] := p2[k1];
p1[k2 + 1] := p2[k1 + 1];
p1[k2 + 2] := p2[k1 + 2];
end;
end;
 
k1 := k1 + 3;
k2 := k2 + 3;
end;
end;
end;
 
procedure TDIB.DrawAdditive(SrcDIB: TDIB; X, Y, Width, Height, Alpha, Frame:
Integer);
var
frameoffset, i, j, Wid: Integer;
p1, p2: pByte;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
if (Alpha < 1) or (Alpha > 256) then Exit;
Wid := Width shl 1 + Width;
frameoffset := Wid * Frame;
for i := 1 to Height - 1 do
begin
if (i + Y) > (Self.Height - 1) then Break; //add 25.5.2004 JB.
p1 := Self.Scanline[i + Y];
p2 := SrcDIB.Scanline[i];
inc(p1, X shl 1 + X + 3);
inc(p2, frameoffset + 3);
for j := 3 to Wid - 4 do
begin
inc(p1^, (Alpha - p1^) * p2^ shr 8);
inc(p1);
inc(p2);
end;
end;
end;
 
procedure TDIB.DrawTranslucent(SrcDIB: TDIB; const X, Y, Width, Height,
SourceX, SourceY: Integer; const Color: TColor);
var
i, j: Integer;
k1, k2: Integer;
n: Integer;
p1, p2: PByteArray;
 
Startk1, Startk2: Integer;
StartY: Integer;
EndY: Integer;
 
DestStartY: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
Startk1 := 3 * SourceX;
Startk2 := 3 * X;
 
DestStartY := Y - SourceY;
 
StartY := SourceY;
EndY := SourceY + Height;
 
if (StartY + DestStartY < 0) then
StartY := -DestStartY;
if (EndY + DestStartY > Self.Height) then
EndY := Self.Height - DestStartY;
 
if (StartY < 0) then
StartY := 0;
if (EndY > SrcDIB.Height) then
EndY := SrcDIB.Height;
 
for j := StartY to EndY - 1 do
begin
p1 := Self.Scanline[j + DestStartY];
p2 := SrcDIB.Scanline[j];
 
k1 := Startk1;
k2 := Startk2;
 
for i := SourceX to SourceX + Width - 1 do
begin
n := (p2[k1] shl 16) + (p2[k1 + 1] shl 8) + p2[k1 + 2];
 
if not (n = Color) then
begin
p1[k2] := (p1[k2] + p2[k1]) shr 1;
p1[k2 + 1] := (p1[k2 + 1] + p2[k1 + 1]) shr 1;
p1[k2 + 2] := (p1[k2 + 2] + p2[k1 + 2]) shr 1;
end;
 
k1 := k1 + 3;
k2 := k2 + 3;
end;
end;
end;
 
procedure TDIB.DrawAlpha(SrcDIB: TDIB; const X, Y, Width, Height,
SourceX, SourceY, Alpha: Integer; const Color: TColor);
var
i, j: Integer;
k1, k2: Integer;
n: Integer;
p1, p2: PByteArray;
 
Startk1, Startk2: Integer;
StartY: Integer;
EndY: Integer;
 
DestStartY: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
Startk1 := 3 * SourceX;
Startk2 := 3 * x;
 
DestStartY := Y - SourceY;
 
StartY := SourceY;
EndY := SourceY + Height;
 
if (EndY + DestStartY > Self.Height) then
EndY := Self.Height - DestStartY;
 
if (EndY > SrcDIB.Height) then
EndY := SrcDIB.Height;
 
if (StartY < 0) then
StartY := 0;
 
if (StartY + DestStartY < 0) then
StartY := DestStartY;
 
for j := StartY to EndY - 1 do
begin
p1 := Self.Scanline[j + DestStartY];
p2 := SrcDIB.Scanline[j];
 
k1 := Startk1;
k2 := Startk2;
 
for i := SourceX to SourceX + Width - 1 do
begin
n := (p2[k1] shl 16) + (p2[k1 + 1] shl 8) + p2[k1 + 2];
 
if not (n = Color) then
begin
p1[k2] := (p1[k2] * (256 - Alpha) + p2[k1] * Alpha) shr 8;
p1[k2 + 1] := (p1[k2 + 1] * (256 - Alpha) + p2[k1 + 1] * Alpha) shr 8;
p1[k2 + 2] := (p1[k2 + 2] * (256 - Alpha) + p2[k1 + 2] * Alpha) shr 8;
end;
 
k1 := k1 + 3;
k2 := k2 + 3;
end;
end;
end;
 
procedure TDIB.DrawAlphaMask(SrcDIB, MaskDIB: TDIB; const X, Y,
Width, Height, SourceX, SourceY: Integer);
var
i, j: Integer;
k1, k2, k3: Integer;
p1, p2, p3: PByteArray;
 
Startk1, Startk2: Integer;
StartY: Integer;
EndY: Integer;
 
DestStartY: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
Startk1 := 3 * SourceX;
Startk2 := 3 * x;
 
DestStartY := Y - SourceY;
 
StartY := SourceY;
EndY := SourceY + Height;
 
if (EndY + DestStartY > Self.Height) then
EndY := Self.Height - DestStartY;
 
if (EndY > SrcDIB.Height) then
EndY := SrcDIB.Height;
 
if (StartY < 0) then
StartY := 0;
 
if (StartY + DestStartY < 0) then
StartY := DestStartY;
 
for j := StartY to EndY - 1 do
begin
p1 := Self.Scanline[j + DestStartY];
p2 := SrcDIB.Scanline[j];
p3 := MaskDIB.Scanline[j];
 
k1 := Startk1;
k2 := Startk2;
k3 := 0;
 
for i := SourceX to SourceX + Width - 1 do
begin
p1[k2] := (p1[k2] * (256 - p3[k3]) + p2[k1] * p3[k3]) shr 8;
p1[k2 + 1] := (p1[k2 + 1] * (256 - p3[k3]) + p2[k1 + 1] * p3[k3]) shr 8;
p1[k2 + 2] := (p1[k2 + 2] * (256 - p3[k3]) + p2[k1 + 2] * p3[k3]) shr 8;
 
k1 := k1 + 3;
k2 := k2 + 3;
k3 := k3 + 3;
end;
end;
end;
 
procedure TDIB.DrawMorphed(SrcDIB: TDIB; const X, Y, Width, Height,
SourceX, SourceY: Integer; const Color: TColor);
var
i, j, r, g, b: Integer;
k1, k2: Integer;
n: Integer;
p1, p2: PByteArray;
 
Startk1, Startk2: Integer;
StartY: Integer;
EndY: Integer;
 
DestStartY: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
Startk1 := 3 * SourceX;
Startk2 := 3 * x;
 
DestStartY := Y - SourceY;
 
StartY := SourceY;
EndY := SourceY + Height;
 
if (EndY + DestStartY > Self.Height) then
EndY := Self.Height - DestStartY;
 
if (EndY > SrcDIB.Height) then
EndY := SrcDIB.Height;
 
if (StartY < 0) then
StartY := 0;
 
if (StartY + DestStartY < 0) then
StartY := DestStartY;
 
r := 0;
g := 0;
b := 0;
 
for j := StartY to EndY - 1 do
begin
p1 := Self.Scanline[j + DestStartY];
p2 := SrcDIB.Scanline[j];
 
k1 := Startk1;
k2 := Startk2;
 
for i := SourceX to SourceX + Width - 1 do
begin
n := (p2[k1] shl 16) + (p2[k1 + 1] shl 8) + p2[k1 + 2];
 
if Random(100) < 50 then
begin
b := p1[k2];
g := p1[k2 + 1];
r := p1[k2 + 2];
end;
 
if not (n = Color) then
begin
p1[k2] := b;
p1[k2 + 1] := g;
p1[k2 + 2] := r;
end;
 
k1 := k1 + 3;
k2 := k2 + 3;
end;
end;
end;
 
procedure TDIB.DrawMono(SrcDIB: TDIB; const X, Y, Width, Height,
SourceX, SourceY: Integer; const TransColor, ForeColor, BackColor: TColor);
var
i, j, r1, g1, b1, r2, g2, b2: Integer;
k1, k2: Integer;
n: Integer;
p1, p2: PByteArray;
Startk1, Startk2, StartY, EndY, DestStartY: Integer;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
Startk1 := 3 * SourceX;
Startk2 := 3 * x;
 
DestStartY := Y - SourceY;
 
StartY := SourceY;
EndY := SourceY + Height;
 
if (EndY + DestStartY > Self.Height) then
EndY := Self.Height - DestStartY;
 
if (EndY > SrcDIB.Height) then
EndY := SrcDIB.Height;
 
if (StartY < 0) then
StartY := 0;
 
if (StartY + DestStartY < 0) then
StartY := DestStartY;
 
r1 := GetRValue(BackColor);
g1 := GetGValue(BackColor);
b1 := GetBValue(BackColor);
 
r2 := GetRValue(ForeColor);
g2 := GetGValue(ForeColor);
b2 := GetBValue(ForeColor);
 
 
for j := StartY to EndY - 1 do
begin
p1 := Self.Scanline[j + DestStartY];
p2 := SrcDIB.Scanline[j];
 
k1 := Startk1;
k2 := Startk2;
 
for i := SourceX to SourceX + Width - 1 do
begin
n := (p2[k1] shl 16) + (p2[k1 + 1] shl 8) + p2[k1 + 2];
 
if (n = TransColor) then
begin
p1[k2] := b1;
p1[k2 + 1] := g1;
p1[k2 + 2] := r1;
end
else
begin
p1[k2] := b2;
p1[k2 + 1] := g2;
p1[k2 + 2] := r2;
end;
 
k1 := k1 + 3;
k2 := k2 + 3;
end;
end;
end;
 
procedure TDIB.Draw3x3Matrix(SrcDIB: TDIB; Setting: TMatrixSetting);
var i, j, k: Integer;
p1, p2, p3, p4: PByteArray;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
for i := 1 to SrcDIB.Height - 2 do
begin
p1 := SrcDIB.ScanLine[i - 1];
p2 := SrcDIB.ScanLine[i];
p3 := SrcDIB.ScanLine[i + 1];
p4 := Self.ScanLine[i];
for j := 3 to 3 * SrcDIB.Width - 4 do
begin
k := (p1[j - 3] * Setting[0] + p1[j] * Setting[1] + p1[j + 3] * Setting[2] +
p2[j - 3] * Setting[3] + p2[j] * Setting[4] + p2[j + 3] * Setting[5] +
p3[j - 3] * Setting[6] + p3[j] * Setting[7] + p3[j + 3] * Setting[8])
div Setting[9];
if k < 0 then k := 0;
if k > 255 then k := 255;
p4[j] := k;
end;
end;
end;
 
procedure TDIB.DrawAntialias(SrcDIB: TDIB);
var i, j, k, l, m: Integer;
p1, p2, p3: PByteArray;
begin
if Self.BitCount <> 24 then Exit;
if SrcDIB.BitCount <> 24 then Exit;
 
for i := 1 to Self.Height - 1 do
begin
k := i shl 1;
p1 := SrcDIB.Scanline[k];
p2 := SrcDIB.Scanline[k + 1];
p3 := Self.Scanline[i];
for j := 1 to Self.Width - 1 do
begin
m := 3 * j;
l := m shl 1;
p3[m] := (p1[l] + p1[l + 3] + p2[l] + p2[l + 3]) shr 2;
p3[m + 1] := (p1[l + 1] + p1[l + 4] + p2[l + 1] + p2[l + 4]) shr 2;
p3[m + 2] := (p1[l + 2] + p1[l + 5] + p2[l + 2] + p2[l + 5]) shr 2;
end;
end;
end;
 
procedure TDIB.FilterLine(X1, Y1, X2, Y2: Integer; Color: TColor;
FilterMode: TFilterMode);
var
i, j: Integer;
t: TColor;
r1, g1, b1, r2, g2, b2: Integer;
begin
j := ROUND(Sqrt(Sqr(ABS(X2 - X1)) + Sqr(ABS(Y2 - Y1))));
if j < 1 then Exit;
 
r1 := GetRValue(Color);
g1 := GetGValue(Color);
b1 := GetBValue(Color);
 
for i := 0 to j do
begin
t := Self.Pixels[X1 + ((X2 - X1) * i div j), Y1 + ((Y2 - Y1) * i div j)];
r2 := GetRValue(t);
g2 := GetGValue(t);
b2 := GetBValue(t);
case FilterMode of
fmNormal: t := RGB(r1 + (((256 - r1) * r2) shr 8),
g1 + (((256 - g1) * g2) shr 8),
b1 + (((256 - b1) * b2) shr 8));
fmMix25: t := RGB((r1 + r2 * 3) shr 2, (g1 + g2 * 3) shr 2, (b1 + b2 * 3) shr 2);
fmMix50: t := RGB((r1 + r2) shr 1, (g1 + g2) shr 1, (b1 + b2) shr 1);
fmMix75: t := RGB((r1 * 3 + r2) shr 2, (g1 * 3 + g2) shr 2, (b1 * 3 + b2) shr 2);
end;
Self.Pixels[X1 + ((X2 - X1) * i div j), Y1 + ((Y2 - Y1) * i div j)] := t;
end;
end;
 
procedure TDIB.FilterRect(X, Y, Width, Height: Integer;
Color: TColor; FilterMode: TFilterMode);
var
i, j, r, g, b, C1: Integer;
p1, p2, p3: pByte;
begin
if Self.BitCount <> 24 then Exit;
 
r := GetRValue(Color);
g := GetGValue(Color);
b := GetBValue(Color);
 
for i := 0 to Height - 1 do
begin
p1 := Self.Scanline[i + Y];
Inc(p1, (3 * X));
for j := 0 to Width - 1 do
begin
case FilterMode of
fmNormal:
begin
p2 := p1;
Inc(p2);
p3 := p2;
Inc(p3);
C1 := (p1^ + p2^ + p3^) div 3;
 
p1^ := (C1 * b) shr 8;
Inc(p1);
p1^ := (C1 * g) shr 8;
Inc(p1);
p1^ := (C1 * r) shr 8;
Inc(p1);
end;
fmMix25:
begin
p1^ := (3 * p1^ + b) shr 2;
Inc(p1);
p1^ := (3 * p1^ + g) shr 2;
Inc(p1);
p1^ := (3 * p1^ + r) shr 2;
Inc(p1);
end;
fmMix50:
begin
p1^ := (p1^ + b) shr 1;
Inc(p1);
p1^ := (p1^ + g) shr 1;
Inc(p1);
p1^ := (p1^ + r) shr 1;
Inc(p1);
end;
fmMix75:
begin
p1^ := (p1^ + 3 * b) shr 2;
Inc(p1);
p1^ := (p1^ + 3 * g) shr 2;
Inc(p1);
p1^ := (p1^ + 3 * r) shr 2;
Inc(p1);
end;
end;
end;
end;
end;
 
procedure TDIB.InitLight(Count, Detail: Integer);
var
i, j: Integer;
begin
LG_COUNT := Count;
LG_DETAIL := Detail;
 
for i := 0 to 255 do // Build Lightning LUT
for j := 0 to 255 do
FLUTDist[i, j] := ROUND(Sqrt(Sqr(i * 10) + Sqr(j * 10)));
end;
 
procedure TDIB.DrawLights(FLight: TLightArray;
AmbientLight: TColor);
var
i, j, l, m, n, o, q, D1, D2, R, G, B, AR, AG, AB: Integer;
P: array{$IFNDEF VER4UP} [0..4096]{$ENDIF} of PByteArray;
begin
if Self.BitCount <> 24 then Exit;
 
{$IFDEF VER4UP}
SetLength(P, LG_DETAIL);
{$ENDIF}
AR := GetRValue(AmbientLight);
AG := GetGValue(AmbientLight);
AB := GetBValue(AmbientLight);
 
for i := (Self.Height div (LG_DETAIL + 1)) downto 1 do
begin
for o := 0 to LG_DETAIL do
P[o] := Self.Scanline[(LG_DETAIL + 1) * i - o];
 
for j := (Self.Width div (LG_DETAIL + 1)) downto 1 do
begin
R := AR;
G := AG;
B := AB;
 
for l := LG_COUNT - 1 downto 0 do // Check the lightsources
begin
D1 := ABS(j * (LG_DETAIL + 1) - FLight[l].X) div FLight[l].Size1;
D2 := ABS(i * (LG_DETAIL + 1) - FLight[l].Y) div FLight[l].Size2;
if D1 > 255 then D1 := 255;
if D2 > 255 then D2 := 255;
 
m := 255 - FLUTDist[D1, D2];
if m < 0 then m := 0;
 
Inc(R, (PosValue(GetRValue(FLight[l].Color) - R) * m shr 8));
Inc(G, (PosValue(GetGValue(FLight[l].Color) - G) * m shr 8));
Inc(B, (PosValue(GetBValue(FLight[l].Color) - B) * m shr 8));
end;
 
for q := LG_DETAIL downto 0 do
begin
n := 3 * (j * (LG_DETAIL + 1) - q);
 
for o := LG_DETAIL downto 0 do
begin
P[o][n] := (P[o][n] * B) shr 8;
P[o][n + 1] := (P[o][n + 1] * G) shr 8;
P[o][n + 2] := (P[o][n + 2] * R) shr 8;
end;
end;
end;
end;
{$IFDEF VER4UP}
SetLength(P, 0);
{$ENDIF}
end;
 
procedure TDIB.DrawOn(Dest: TRect; DestCanvas: TCanvas; Xsrc, Ysrc: Integer);
{procedure is supplement of original TDIBUltra function}
begin
//if not AsSigned(SrcCanvas) then Exit;
if (Xsrc < 0) then
begin
Dec(Dest.Left, Xsrc);
Inc(Dest.Right {Width }, Xsrc);
Xsrc := 0
end;
if (Ysrc < 0) then
begin
Dec(Dest.Top, Ysrc);
Inc(Dest.Bottom {Height}, Ysrc);
Ysrc := 0
end;
BitBlt(DestCanvas.Handle, Dest.Left, Dest.Top, Dest.Right, Dest.Bottom, Self.Canvas.Handle, Xsrc, Ysrc, SRCCOPY);
end;
 
{ DXFusion <- }
 
{ added effect for DIB }
 
function IntToByte(i: Integer): Byte;
begin
if i > 255 then Result := 255
else if i < 0 then Result := 0
else Result := i;
end;
 
{standalone routine}
 
procedure TDIB.Darker(Percent: Integer);
{color to dark in percent}
var
p0: pbytearray;
r, g, b, x, y: Integer;
begin
if Self.BitCount <> 24 then Exit;
for y := 0 to Self.Height - 1 do
begin
p0 := Self.ScanLine[y];
for x := 0 to Self.Width - 1 do
begin
r := p0[x * 3];
g := p0[x * 3 + 1];
b := p0[x * 3 + 2];
p0[x * 3] := Round(R * Percent / 100);
p0[x * 3 + 1] := Round(G * Percent / 100);
p0[x * 3 + 2] := Round(B * Percent / 100);
end;
end;
end;
 
procedure TDIB.Lighter(Percent: Integer);
var
p0: pbytearray;
r, g, b, x, y: Integer;
begin
if Self.BitCount <> 24 then Exit;
for y := 0 to Self.Height - 1 do
begin
p0 := Self.ScanLine[y];
for x := 0 to Self.Width - 1 do
begin
r := p0[x * 3];
g := p0[x * 3 + 1];
b := p0[x * 3 + 2];
p0[x * 3] := Round(R * Percent / 100) + Round(255 - Percent / 100 * 255);
p0[x * 3 + 1] := Round(G * Percent / 100) + Round(255 - Percent / 100 * 255);
p0[x * 3 + 2] := Round(B * Percent / 100) + Round(255 - Percent / 100 * 255);
end;
end;
end;
 
procedure TDIB.Darkness(Amount: Integer);
var
p0: pbytearray;
r, g, b, x, y: Integer;
begin
if Self.BitCount <> 24 then Exit;
for y := 0 to Self.Height - 1 do
begin
p0 := Self.ScanLine[y];
for x := 0 to Self.Width - 1 do
begin
r := p0[x * 3];
g := p0[x * 3 + 1];
b := p0[x * 3 + 2];
p0[x * 3] := IntToByte(r - ((r) * Amount) div 255);
p0[x * 3 + 1] := IntToByte(g - ((g) * Amount) div 255);
p0[x * 3 + 2] := IntToByte(b - ((b) * Amount) div 255);
end;
end;
end;
 
function TrimInt(i, Min, Max: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if i > Max then Result := Max
else if i < Min then Result := Min
else Result := i;
end;
 
procedure TDIB.DoSmoothRotate(Src: TDIB; cx, cy: Integer; Angle: Extended);
var
Top, Bottom, eww, nsw, fx, fy: Extended;
cAngle, sAngle: Double;
xDiff, yDiff, ifx, ify, px, py, ix, iy, x, y: Integer;
nw, ne, sw, se: TBGR;
P1, P2, P3: Pbytearray;
begin
Angle := angle;
Angle := -Angle * Pi / 180;
sAngle := Sin(Angle);
cAngle := Cos(Angle);
xDiff := (Self.Width - Src.Width) div 2;
yDiff := (Self.Height - Src.Height) div 2;
for y := 0 to Self.Height - 1 do
begin
P3 := Self.scanline[y];
py := 2 * (y - cy) + 1;
for x := 0 to Self.Width - 1 do
begin
px := 2 * (x - cx) + 1;
fx := (((px * cAngle - py * sAngle) - 1) / 2 + cx) - xDiff;
fy := (((px * sAngle + py * cAngle) - 1) / 2 + cy) - yDiff;
ifx := Round(fx);
ify := Round(fy);
 
if (ifx > -1) and (ifx < Src.Width) and (ify > -1) and (ify < Src.Height) then
begin
eww := fx - ifx;
nsw := fy - ify;
iy := TrimInt(ify + 1, 0, Src.Height - 1);
ix := TrimInt(ifx + 1, 0, Src.Width - 1);
P1 := Src.scanline[ify];
P2 := Src.scanline[iy];
nw.r := P1[ifx * 3];
nw.g := P1[ifx * 3 + 1];
nw.b := P1[ifx * 3 + 2];
ne.r := P1[ix * 3];
ne.g := P1[ix * 3 + 1];
ne.b := P1[ix * 3 + 2];
sw.r := P2[ifx * 3];
sw.g := P2[ifx * 3 + 1];
sw.b := P2[ifx * 3 + 2];
se.r := P2[ix * 3];
se.g := P2[ix * 3 + 1];
se.b := P2[ix * 3 + 2];
 
Top := nw.b + eww * (ne.b - nw.b);
Bottom := sw.b + eww * (se.b - sw.b);
P3[x * 3 + 2] := IntToByte(Round(Top + nsw * (Bottom - Top)));
 
Top := nw.g + eww * (ne.g - nw.g);
Bottom := sw.g + eww * (se.g - sw.g);
P3[x * 3 + 1] := IntToByte(Round(Top + nsw * (Bottom - Top)));
 
Top := nw.r + eww * (ne.r - nw.r);
Bottom := sw.r + eww * (se.r - sw.r);
P3[x * 3] := IntToByte(Round(Top + nsw * (Bottom - Top)));
end;
end;
end;
end;
 
//----------------------
//--- 24 bit count routines ----------------------
//----------------------
 
procedure TDIB.DoInvert;
procedure PicInvert(src: TDIB);
var w, h, x, y: Integer;
p: pbytearray;
begin
w := src.width;
h := src.height;
src.BitCount := 24;
for y := 0 to h - 1 do
begin
p := src.scanline[y];
for x := 0 to w - 1 do
begin
p[x * 3] := not p[x * 3];
p[x * 3 + 1] := not p[x * 3 + 1];
p[x * 3 + 2] := not p[x * 3 + 2];
end;
end;
end;
begin
PicInvert(Self);
end;
 
procedure TDIB.DoAddColorNoise(Amount: Integer);
procedure AddColorNoise(var clip: TDIB; Amount: Integer);
var
p0: pbytearray;
x, y, r, g, b: Integer;
begin
for y := 0 to clip.Height - 1 do
begin
p0 := clip.ScanLine[y];
for x := 0 to clip.Width - 1 do
begin
r := p0[x * 3] + (Random(Amount) - (Amount shr 1));
g := p0[x * 3 + 1] + (Random(Amount) - (Amount shr 1));
b := p0[x * 3 + 2] + (Random(Amount) - (Amount shr 1));
p0[x * 3] := IntToByte(r);
p0[x * 3 + 1] := IntToByte(g);
p0[x * 3 + 2] := IntToByte(b);
end;
end;
end;
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.Assign(Self);
AddColorNoise(bb, Amount);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoAddMonoNoise(Amount: Integer);
procedure _AddMonoNoise(var clip: TDIB; Amount: Integer);
var
p0: pbytearray;
x, y, a, r, g, b: Integer;
begin
for y := 0 to clip.Height - 1 do
begin
p0 := clip.scanline[y];
for x := 0 to clip.Width - 1 do
begin
a := Random(Amount) - (Amount shr 1);
r := p0[x * 3] + a;
g := p0[x * 3 + 1] + a;
b := p0[x * 3 + 2] + a;
p0[x * 3] := IntToByte(r);
p0[x * 3 + 1] := IntToByte(g);
p0[x * 3 + 2] := IntToByte(b);
end;
end;
end;
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.Assign(Self);
_AddMonoNoise(bb, Amount);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoAntiAlias;
procedure AntiAlias(clip: TDIB);
procedure AntiAliasRect(clip: TDIB; XOrigin, YOrigin, XFinal, YFinal: Integer);
var Memo, x, y: Integer; (* Composantes primaires des points environnants *)
p0, p1, p2: pbytearray;
begin
if XFinal < XOrigin then begin Memo := XOrigin; XOrigin := XFinal; XFinal := Memo; end; (* Inversion des valeurs *)
if YFinal < YOrigin then begin Memo := YOrigin; YOrigin := YFinal; YFinal := Memo; end; (* si diff‚rence n‚gative*)
XOrigin := max(1, XOrigin);
YOrigin := max(1, YOrigin);
XFinal := min(clip.width - 2, XFinal);
YFinal := min(clip.height - 2, YFinal);
clip.BitCount := 24;
for y := YOrigin to YFinal do
begin
p0 := clip.ScanLine[y - 1];
p1 := clip.scanline[y];
p2 := clip.ScanLine[y + 1];
for x := XOrigin to XFinal do
begin
p1[x * 3] := (p0[x * 3] + p2[x * 3] + p1[(x - 1) * 3] + p1[(x + 1) * 3]) div 4;
p1[x * 3 + 1] := (p0[x * 3 + 1] + p2[x * 3 + 1] + p1[(x - 1) * 3 + 1] + p1[(x + 1) * 3 + 1]) div 4;
p1[x * 3 + 2] := (p0[x * 3 + 2] + p2[x * 3 + 2] + p1[(x - 1) * 3 + 2] + p1[(x + 1) * 3 + 2]) div 4;
end;
end;
end;
begin
AntiAliasRect(clip, 0, 0, clip.width, clip.height);
end;
begin
AntiAlias(Self);
end;
 
procedure TDIB.DoContrast(Amount: Integer);
procedure _Contrast(var clip: TDIB; Amount: Integer);
var
p0: pbytearray;
rg, gg, bg, r, g, b, x, y: Integer;
begin
for y := 0 to clip.Height - 1 do
begin
p0 := clip.scanline[y];
for x := 0 to clip.Width - 1 do
begin
r := p0[x * 3];
g := p0[x * 3 + 1];
b := p0[x * 3 + 2];
rg := (Abs(127 - r) * Amount) div 255;
gg := (Abs(127 - g) * Amount) div 255;
bg := (Abs(127 - b) * Amount) div 255;
if r > 127 then r := r + rg else r := r - rg;
if g > 127 then g := g + gg else g := g - gg;
if b > 127 then b := b + bg else b := b - bg;
p0[x * 3] := IntToByte(r);
p0[x * 3 + 1] := IntToByte(g);
p0[x * 3 + 2] := IntToByte(b);
end;
end;
end;
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.Assign(Self);
_Contrast(bb, Amount);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoFishEye(Amount: Integer);
procedure _FishEye(var Bmp, Dst: TDIB; Amount: Extended);
var
xmid, ymid: Single;
fx, fy: Single;
r1, r2: Single;
ifx, ify: Integer;
dx, dy: Single;
rmax: Single;
ty, tx: Integer;
weight_x, weight_y: array[0..1] of Single;
weight: Single;
new_red, new_green: Integer;
new_blue: Integer;
total_red, total_green: Single;
total_blue: Single;
ix, iy: Integer;
sli, slo: PByteArray;
begin
xmid := Bmp.Width / 2;
ymid := Bmp.Height / 2;
rmax := Dst.Width * Amount;
 
for ty := 0 to Dst.Height - 1 do
begin
for tx := 0 to Dst.Width - 1 do
begin
dx := tx - xmid;
dy := ty - ymid;
r1 := Sqrt(dx * dx + dy * dy);
if r1 = 0 then
begin
fx := xmid;
fy := ymid;
end
else
begin
r2 := rmax / 2 * (1 / (1 - r1 / rmax) - 1);
fx := dx * r2 / r1 + xmid;
fy := dy * r2 / r1 + ymid;
end;
ify := Trunc(fy);
ifx := Trunc(fx);
// Calculate the weights.
if fy >= 0 then
begin
weight_y[1] := fy - ify;
weight_y[0] := 1 - weight_y[1];
end
else
begin
weight_y[0] := -(fy - ify);
weight_y[1] := 1 - weight_y[0];
end;
if fx >= 0 then
begin
weight_x[1] := fx - ifx;
weight_x[0] := 1 - weight_x[1];
end
else
begin
weight_x[0] := -(fx - ifx);
Weight_x[1] := 1 - weight_x[0];
end;
 
if ifx < 0 then
ifx := Bmp.Width - 1 - (-ifx mod Bmp.Width)
else if ifx > Bmp.Width - 1 then
ifx := ifx mod Bmp.Width;
if ify < 0 then
ify := Bmp.Height - 1 - (-ify mod Bmp.Height)
else if ify > Bmp.Height - 1 then
ify := ify mod Bmp.Height;
 
total_red := 0.0;
total_green := 0.0;
total_blue := 0.0;
for ix := 0 to 1 do
begin
for iy := 0 to 1 do
begin
if ify + iy < Bmp.Height then
sli := Bmp.scanline[ify + iy]
else
sli := Bmp.scanline[Bmp.Height - ify - iy];
if ifx + ix < Bmp.Width then
begin
new_red := sli[(ifx + ix) * 3];
new_green := sli[(ifx + ix) * 3 + 1];
new_blue := sli[(ifx + ix) * 3 + 2];
end
else
begin
new_red := sli[(Bmp.Width - ifx - ix) * 3];
new_green := sli[(Bmp.Width - ifx - ix) * 3 + 1];
new_blue := sli[(Bmp.Width - ifx - ix) * 3 + 2];
end;
weight := weight_x[ix] * weight_y[iy];
total_red := total_red + new_red * weight;
total_green := total_green + new_green * weight;
total_blue := total_blue + new_blue * weight;
end;
end;
slo := Dst.scanline[ty];
slo[tx * 3] := Round(total_red);
slo[tx * 3 + 1] := Round(total_green);
slo[tx * 3 + 2] := Round(total_blue);
 
end;
end;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.BitCount := 24;
BB2.Assign(BB1);
_FishEye(BB1, BB2, Amount);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoGrayScale;
procedure GrayScale(var clip: TDIB);
var
p0: pbytearray;
Gray, x, y: Integer;
begin
for y := 0 to clip.Height - 1 do
begin
p0 := clip.scanline[y];
for x := 0 to clip.Width - 1 do
begin
Gray := Round(p0[x * 3] * 0.3 + p0[x * 3 + 1] * 0.59 + p0[x * 3 + 2] * 0.11);
p0[x * 3] := Gray;
p0[x * 3 + 1] := Gray;
p0[x * 3 + 2] := Gray;
end;
end;
end;
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.Assign(Self);
GrayScale(BB);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoLightness(Amount: Integer);
procedure _Lightness(var clip: TDIB; Amount: Integer);
var
p0: pbytearray;
r, g, b, x, y: Integer;
begin
for y := 0 to clip.Height - 1 do
begin
p0 := clip.scanline[y];
for x := 0 to clip.Width - 1 do
begin
r := p0[x * 3];
g := p0[x * 3 + 1];
b := p0[x * 3 + 2];
p0[x * 3] := IntToByte(r + ((255 - r) * Amount) div 255);
p0[x * 3 + 1] := IntToByte(g + ((255 - g) * Amount) div 255);
p0[x * 3 + 2] := IntToByte(b + ((255 - b) * Amount) div 255);
end;
end;
end;
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.Assign(Self);
_Lightness(BB, Amount);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoDarkness(Amount: Integer);
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.Assign(Self);
BB.Darkness(Amount);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoSaturation(Amount: Integer);
procedure _Saturation(var clip: TDIB; Amount: Integer);
var
p0: pbytearray;
Gray, r, g, b, x, y: Integer;
begin
for y := 0 to clip.Height - 1 do
begin
p0 := clip.scanline[y];
for x := 0 to clip.Width - 1 do
begin
r := p0[x * 3];
g := p0[x * 3 + 1];
b := p0[x * 3 + 2];
Gray := (r + g + b) div 3;
p0[x * 3] := IntToByte(Gray + (((r - Gray) * Amount) div 255));
p0[x * 3 + 1] := IntToByte(Gray + (((g - Gray) * Amount) div 255));
p0[x * 3 + 2] := IntToByte(Gray + (((b - Gray) * Amount) div 255));
end;
end;
end;
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.Assign(Self);
_Saturation(BB, Amount);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoSplitBlur(Amount: Integer);
{NOTE: For a gaussian blur is amount 3}
procedure _SplitBlur(var clip: TDIB; Amount: Integer);
var
p0, p1, p2: pbytearray;
cx, x, y: Integer;
Buf: array[0..3, 0..2] of byte;
begin
if Amount = 0 then Exit;
for y := 0 to clip.Height - 1 do
begin
p0 := clip.scanline[y];
if y - Amount < 0 then p1 := clip.scanline[y]
else {y-Amount>0} p1 := clip.ScanLine[y - Amount];
if y + Amount < clip.Height then p2 := clip.ScanLine[y + Amount]
else {y+Amount>=Height} p2 := clip.ScanLine[clip.Height - y];
 
for x := 0 to clip.Width - 1 do
begin
if x - Amount < 0 then cx := x
else {x-Amount>0} cx := x - Amount;
Buf[0, 0] := p1[cx * 3];
Buf[0, 1] := p1[cx * 3 + 1];
Buf[0, 2] := p1[cx * 3 + 2];
Buf[1, 0] := p2[cx * 3];
Buf[1, 1] := p2[cx * 3 + 1];
Buf[1, 2] := p2[cx * 3 + 2];
if x + Amount < clip.Width then cx := x + Amount
else {x+Amount>=Width} cx := clip.Width - x;
Buf[2, 0] := p1[cx * 3];
Buf[2, 1] := p1[cx * 3 + 1];
Buf[2, 2] := p1[cx * 3 + 2];
Buf[3, 0] := p2[cx * 3];
Buf[3, 1] := p2[cx * 3 + 1];
Buf[3, 2] := p2[cx * 3 + 2];
p0[x * 3] := (Buf[0, 0] + Buf[1, 0] + Buf[2, 0] + Buf[3, 0]) shr 2;
p0[x * 3 + 1] := (Buf[0, 1] + Buf[1, 1] + Buf[2, 1] + Buf[3, 1]) shr 2;
p0[x * 3 + 2] := (Buf[0, 2] + Buf[1, 2] + Buf[2, 2] + Buf[3, 2]) shr 2;
end;
end;
end;
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.Assign(Self);
_SplitBlur(BB, Amount);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoGaussianBlur(Amount: Integer);
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.BitCount := 24;
BB.Assign(Self);
GaussianBlur(BB, Amount);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoMosaic(Size: Integer);
procedure Mosaic(var Bm: TDIB; size: Integer);
var
x, y, i, j: Integer;
p1, p2: pbytearray;
r, g, b: byte;
begin
y := 0;
repeat
p1 := bm.scanline[y];
repeat
j := 1;
repeat
p2 := bm.scanline[y];
x := 0;
repeat
r := p1[x * 3];
g := p1[x * 3 + 1];
b := p1[x * 3 + 2];
i := 1;
repeat
p2[x * 3] := r;
p2[x * 3 + 1] := g;
p2[x * 3 + 2] := b;
inc(x);
inc(i);
until (x >= bm.width) or (i > size);
until x >= bm.width;
inc(j);
inc(y);
until (y >= bm.height) or (j > size);
until (y >= bm.height) or (x >= bm.width);
until y >= bm.height;
end;
var BB: TDIB;
begin
BB := TDIB.Create;
BB.BitCount := 24;
BB.Assign(Self);
Mosaic(BB, Size);
Self.Assign(BB);
BB.Free;
end;
 
procedure TDIB.DoTwist(Amount: Integer);
procedure _Twist(var Bmp, Dst: TDIB; Amount: Integer);
var
fxmid, fymid: Single;
txmid, tymid: Single;
fx, fy: Single;
tx2, ty2: Single;
r: Single;
theta: Single;
ifx, ify: Integer;
dx, dy: Single;
OFFSET: Single;
ty, tx: Integer;
weight_x, weight_y: array[0..1] of Single;
weight: Single;
new_red, new_green: Integer;
new_blue: Integer;
total_red, total_green: Single;
total_blue: Single;
ix, iy: Integer;
sli, slo: PBytearray;
 
function ArcTan2(xt, yt: Single): Single; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if xt = 0 then
if yt > 0 then
Result := Pi / 2
else
Result := -(Pi / 2)
else
begin
Result := ArcTan(yt / xt);
if xt < 0 then
Result := Pi + ArcTan(yt / xt);
end;
end;
 
begin
OFFSET := -(Pi / 2);
dx := Bmp.Width - 1;
dy := Bmp.Height - 1;
r := Sqrt(dx * dx + dy * dy);
tx2 := r;
ty2 := r;
txmid := (Bmp.Width - 1) / 2; //Adjust these to move center of rotation
tymid := (Bmp.Height - 1) / 2; //Adjust these to move ......
fxmid := (Bmp.Width - 1) / 2;
fymid := (Bmp.Height - 1) / 2;
if tx2 >= Bmp.Width then tx2 := Bmp.Width - 1;
if ty2 >= Bmp.Height then ty2 := Bmp.Height - 1;
 
for ty := 0 to Round(ty2) do
begin
for tx := 0 to Round(tx2) do
begin
dx := tx - txmid;
dy := ty - tymid;
r := Sqrt(dx * dx + dy * dy);
if r = 0 then
begin
fx := 0;
fy := 0;
end
else
begin
theta := ArcTan2(dx, dy) - r / Amount - OFFSET;
fx := r * Cos(theta);
fy := r * Sin(theta);
end;
fx := fx + fxmid;
fy := fy + fymid;
 
ify := Trunc(fy);
ifx := Trunc(fx);
// Calculate the weights.
if fy >= 0 then
begin
weight_y[1] := fy - ify;
weight_y[0] := 1 - weight_y[1];
end
else
begin
weight_y[0] := -(fy - ify);
weight_y[1] := 1 - weight_y[0];
end;
if fx >= 0 then
begin
weight_x[1] := fx - ifx;
weight_x[0] := 1 - weight_x[1];
end
else
begin
weight_x[0] := -(fx - ifx);
Weight_x[1] := 1 - weight_x[0];
end;
 
if ifx < 0 then
ifx := Bmp.Width - 1 - (-ifx mod Bmp.Width)
else if ifx > Bmp.Width - 1 then
ifx := ifx mod Bmp.Width;
if ify < 0 then
ify := Bmp.Height - 1 - (-ify mod Bmp.Height)
else if ify > Bmp.Height - 1 then
ify := ify mod Bmp.Height;
 
total_red := 0.0;
total_green := 0.0;
total_blue := 0.0;
for ix := 0 to 1 do
begin
for iy := 0 to 1 do
begin
if ify + iy < Bmp.Height then
sli := Bmp.scanline[ify + iy]
else
sli := Bmp.scanline[Bmp.Height - ify - iy];
if ifx + ix < Bmp.Width then
begin
new_red := sli[(ifx + ix) * 3];
new_green := sli[(ifx + ix) * 3 + 1];
new_blue := sli[(ifx + ix) * 3 + 2];
end
else
begin
new_red := sli[(Bmp.Width - ifx - ix) * 3];
new_green := sli[(Bmp.Width - ifx - ix) * 3 + 1];
new_blue := sli[(Bmp.Width - ifx - ix) * 3 + 2];
end;
weight := weight_x[ix] * weight_y[iy];
total_red := total_red + new_red * weight;
total_green := total_green + new_green * weight;
total_blue := total_blue + new_blue * weight;
end;
end;
slo := Dst.scanline[ty];
slo[tx * 3] := Round(total_red);
slo[tx * 3 + 1] := Round(total_green);
slo[tx * 3 + 2] := Round(total_blue);
end;
end;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.BitCount := 24;
BB2.Assign(BB1);
_Twist(BB1, BB2, Amount);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoTrace(Amount: Integer);
procedure Trace(src: TDIB; intensity: Integer);
var
x, y, i: Integer;
P1, P2, P3, P4: PByteArray;
tb, TraceB: byte;
hasb: Boolean;
bitmap: TDIB;
begin
bitmap := TDIB.create;
bitmap.width := src.width;
bitmap.height := src.height;
bitmap.canvas.draw(0, 0, src);
bitmap.BitCount := 8;
src.BitCount := 24;
hasb := false;
TraceB := $00; tb := 0;
for i := 1 to Intensity do
begin
for y := 0 to BitMap.height - 2 do
begin
P1 := BitMap.ScanLine[y];
P2 := BitMap.scanline[y + 1];
P3 := src.scanline[y];
P4 := src.scanline[y + 1];
x := 0;
repeat
if p1[x] <> p1[x + 1] then
begin
if not hasb then
begin
tb := p1[x + 1];
hasb := true;
p3[x * 3] := TraceB;
p3[x * 3 + 1] := TraceB;
p3[x * 3 + 2] := TraceB;
end
else
begin
if p1[x] <> tb then
begin
p3[x * 3] := TraceB;
p3[x * 3 + 1] := TraceB;
p3[x * 3 + 2] := TraceB;
end
else
begin
p3[(x + 1) * 3] := TraceB;
p3[(x + 1) * 3 + 1] := TraceB;
p3[(x + 1) * 3 + 1] := TraceB;
end;
end;
end;
if p1[x] <> p2[x] then
begin
if not hasb then
begin
tb := p2[x];
hasb := true;
p3[x * 3] := TraceB;
p3[x * 3 + 1] := TraceB;
p3[x * 3 + 2] := TraceB;
end
else
begin
if p1[x] <> tb then
begin
p3[x * 3] := TraceB;
p3[x * 3 + 1] := TraceB;
p3[x * 3 + 2] := TraceB;
end
else
begin
p4[x * 3] := TraceB;
p4[x * 3 + 1] := TraceB;
p4[x * 3 + 2] := TraceB;
end;
end;
end;
inc(x);
until x >= (BitMap.width - 2);
end;
if i > 1 then
for y := BitMap.height - 1 downto 1 do
begin
P1 := BitMap.ScanLine[y];
P2 := BitMap.scanline[y - 1];
P3 := src.scanline[y];
P4 := src.scanline[y - 1];
x := Bitmap.width - 1;
repeat
if p1[x] <> p1[x - 1] then
begin
if not hasb then
begin
tb := p1[x - 1];
hasb := true;
p3[x * 3] := TraceB;
p3[x * 3 + 1] := TraceB;
p3[x * 3 + 2] := TraceB;
end
else
begin
if p1[x] <> tb then
begin
p3[x * 3] := TraceB;
p3[x * 3 + 1] := TraceB;
p3[x * 3 + 2] := TraceB;
end
else
begin
p3[(x - 1) * 3] := TraceB;
p3[(x - 1) * 3 + 1] := TraceB;
p3[(x - 1) * 3 + 2] := TraceB;
end;
end;
end;
if p1[x] <> p2[x] then
begin
if not hasb then
begin
tb := p2[x];
hasb := true;
p3[x * 3] := TraceB;
p3[x * 3 + 1] := TraceB;
p3[x * 3 + 2] := TraceB;
end
else
begin
if p1[x] <> tb then
begin
p3[x * 3] := TraceB;
p3[x * 3 + 1] := TraceB;
p3[x * 3 + 2] := TraceB;
end
else
begin
p4[x * 3] := TraceB;
p4[x * 3 + 1] := TraceB;
p4[x * 3 + 2] := TraceB;
end;
end;
end;
dec(x);
until x <= 1;
end;
end;
bitmap.free;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.BitCount := 24;
BB2.Assign(BB1);
Trace(BB2, Amount);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoSplitlight(Amount: Integer);
procedure Splitlight(var clip: TDIB; amount: Integer);
var
x, y, i: Integer;
p1: pbytearray;
 
function sinpixs(a: Integer): Integer;
begin
result := variant(sin(a / 255 * pi / 2) * 255);
end;
begin
for i := 1 to amount do
for y := 0 to clip.height - 1 do
begin
p1 := clip.scanline[y];
for x := 0 to clip.width - 1 do
begin
p1[x * 3] := sinpixs(p1[x * 3]);
p1[x * 3 + 1] := sinpixs(p1[x * 3 + 1]);
p1[x * 3 + 2] := sinpixs(p1[x * 3 + 2]);
end;
end;
end;
var BB1 {,BB2}: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
// BB2 := TDIB.Create;
// BB2.BitCount := 24;
// BB2.Assign (BB1);
Splitlight(BB1, Amount);
Self.Assign(BB1);
BB1.Free;
// BB2.Free;
end;
 
procedure TDIB.DoTile(Amount: Integer);
procedure SmoothResize(var Src, Dst: TDIB);
var
x, y, xP, yP,
yP2, xP2: Integer;
Read, Read2: PByteArray;
t, z, z2, iz2: Integer;
pc: PBytearray;
w1, w2, w3, w4: Integer;
Col1r, col1g, col1b, Col2r, col2g, col2b: byte;
begin
xP2 := ((src.Width - 1) shl 15) div Dst.Width;
yP2 := ((src.Height - 1) shl 15) div Dst.Height;
yP := 0;
for y := 0 to Dst.Height - 1 do
begin
xP := 0;
Read := src.ScanLine[yP shr 15];
if yP shr 16 < src.Height - 1 then
Read2 := src.ScanLine[yP shr 15 + 1]
else
Read2 := src.ScanLine[yP shr 15];
pc := Dst.scanline[y];
z2 := yP and $7FFF;
iz2 := $8000 - z2;
for x := 0 to Dst.Width - 1 do
begin
t := xP shr 15;
Col1r := Read[t * 3];
Col1g := Read[t * 3 + 1];
Col1b := Read[t * 3 + 2];
Col2r := Read2[t * 3];
Col2g := Read2[t * 3 + 1];
Col2b := Read2[t * 3 + 2];
z := xP and $7FFF;
w2 := (z * iz2) shr 15;
w1 := iz2 - w2;
w4 := (z * z2) shr 15;
w3 := z2 - w4;
pc[x * 3 + 2] :=
(Col1b * w1 + Read[(t + 1) * 3 + 2] * w2 +
Col2b * w3 + Read2[(t + 1) * 3 + 2] * w4) shr 15;
pc[x * 3 + 1] :=
(Col1g * w1 + Read[(t + 1) * 3 + 1] * w2 +
Col2g * w3 + Read2[(t + 1) * 3 + 1] * w4) shr 15;
pc[x * 3] :=
(Col1r * w1 + Read2[(t + 1) * 3] * w2 +
Col2r * w3 + Read2[(t + 1) * 3] * w4) shr 15;
Inc(xP, xP2);
end;
Inc(yP, yP2);
end;
end;
procedure Tile(src, dst: TDIB; amount: Integer);
var
w, h, w2, h2, i, j: Integer;
bm: TDIB;
begin
w := src.width;
h := src.height;
dst.width := w;
dst.height := h;
dst.Canvas.draw(0, 0, src);
if (amount <= 0) or ((w div amount) < 5) or ((h div amount) < 5) then exit;
h2 := h div amount;
w2 := w div amount;
bm := TDIB.create;
bm.width := w2;
bm.height := h2;
bm.BitCount := 24;
smoothresize(src, bm);
for j := 0 to amount - 1 do
for i := 0 to amount - 1 do
dst.canvas.Draw(i * w2, j * h2, bm);
bm.free;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.BitCount := 24;
BB2.Assign(BB1);
Tile(BB1, BB2, Amount);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoSpotLight(Amount: Integer; Spot: TRect);
procedure SpotLight(var src: TDIB; Amount: Integer; Spot: TRect);
var
bm, z: TDIB;
w, h: Integer;
begin
z := TDIB.Create;
try
z.SetSize(src.Width, src.Height, 24);
z.DrawTo(src, 0, 0, src.Width, src.Height, 0, 0);
w := z.Width;
h := z.Height;
bm := TDIB.create;
try
bm.Width := w;
bm.Height := h;
bm.Canvas.Brush.color := clblack;
bm.Canvas.FillRect(rect(0, 0, w, h));
bm.Canvas.Brush.Color := clwhite;
bm.Canvas.Ellipse(Spot.left, spot.top, spot.right, spot.bottom);
bm.Transparent := true;
z.Canvas.CopyMode := cmSrcAnd; {as transparentcolor for white}
z.Canvas.Draw(0, 0, src);
z.Canvas.Draw(0, 0, bm);
src.Darkness(Amount);
src.Canvas.CopyMode := cmSrcPaint;
src.DrawTransparent(z, 0, 0, z.Width, z.Height, 0, 0, clBlack);
finally
bm.Free;
end;
finally
z.Free
end;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.BitCount := 24;
BB2.Assign(BB1);
SpotLight(BB2, Amount, Spot);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoEmboss;
procedure Emboss(var Bmp: TDIB);
var
x, y: Integer;
p1, p2: Pbytearray;
begin
for y := 0 to Bmp.Height - 2 do
begin
p1 := bmp.scanline[y];
p2 := bmp.scanline[y + 1];
for x := 0 to Bmp.Width - 4 do
begin
p1[x * 3] := (p1[x * 3] + (p2[(x + 3) * 3] xor $FF)) shr 1;
p1[x * 3 + 1] := (p1[x * 3 + 1] + (p2[(x + 3) * 3 + 1] xor $FF)) shr 1;
p1[x * 3 + 2] := (p1[x * 3 + 2] + (p2[(x + 3) * 3 + 2] xor $FF)) shr 1;
end;
end;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.BitCount := 24;
BB2.Assign(BB1);
Emboss(BB2);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoSolorize(Amount: Integer);
procedure Solorize(src, dst: TDIB; amount: Integer);
var
w, h, x, y: Integer;
ps, pd: pbytearray;
c: Integer;
begin
w := src.width;
h := src.height;
src.BitCount := 24;
dst.BitCount := 24;
for y := 0 to h - 1 do
begin
ps := src.scanline[y];
pd := dst.scanline[y];
for x := 0 to w - 1 do
begin
c := (ps[x * 3] + ps[x * 3 + 1] + ps[x * 3 + 2]) div 3;
if c > amount then
begin
pd[x * 3] := 255 - ps[x * 3];
pd[x * 3 + 1] := 255 - ps[x * 3 + 1];
pd[x * 3 + 2] := 255 - ps[x * 3 + 2];
end
else
begin
pd[x * 3] := ps[x * 3];
pd[x * 3 + 1] := ps[x * 3 + 1];
pd[x * 3 + 2] := ps[x * 3 + 2];
end;
end;
end;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.BitCount := 24;
BB2.Assign(BB1);
Solorize(BB1, BB2, Amount);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoPosterize(Amount: Integer);
procedure Posterize(src, dst: TDIB; amount: Integer);
var
w, h, x, y: Integer;
ps, pd: pbytearray;
begin
w := src.width;
h := src.height;
src.BitCount := 24;
dst.BitCount := 24;
for y := 0 to h - 1 do
begin
ps := src.scanline[y];
pd := dst.scanline[y];
for x := 0 to w - 1 do
begin
pd[x * 3] := round(ps[x * 3] / amount) * amount;
pd[x * 3 + 1] := round(ps[x * 3 + 1] / amount) * amount;
pd[x * 3 + 2] := round(ps[x * 3 + 2] / amount) * amount;
end;
end;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.BitCount := 24;
BB2.Assign(BB1);
Posterize(BB1, BB2, Amount);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoBrightness(Amount: Integer);
procedure Brightness(src, dst: TDIB; level: Integer);
const
MaxPixelCount = 32768;
type
pRGBArray = ^TRGBArray;
TRGBArray = array[0..MaxPixelCount - 1] of TRGBTriple;
var
i, j, value: Integer;
OrigRow, DestRow: pRGBArray;
begin
// get brightness increment value
value := level;
src.BitCount := 24;
dst.BitCount := 24;
// for each row of pixels
for i := 0 to src.Height - 1 do
begin
OrigRow := src.ScanLine[i];
DestRow := dst.ScanLine[i];
// for each pixel in row
for j := 0 to src.Width - 1 do
begin
// add brightness value to pixel's RGB values
if value > 0 then
begin
// RGB values must be less than 256
DestRow[j].rgbtRed := Min(255, OrigRow[j].rgbtRed + value);
DestRow[j].rgbtGreen := Min(255, OrigRow[j].rgbtGreen + value);
DestRow[j].rgbtBlue := Min(255, OrigRow[j].rgbtBlue + value);
end
else
begin
// RGB values must be greater or equal than 0
DestRow[j].rgbtRed := Max(0, OrigRow[j].rgbtRed + value);
DestRow[j].rgbtGreen := Max(0, OrigRow[j].rgbtGreen + value);
DestRow[j].rgbtBlue := Max(0, OrigRow[j].rgbtBlue + value);
end;
end;
end;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.BitCount := 24;
BB2.Assign(BB1);
Brightness(BB1, BB2, Amount);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoResample(AmountX, AmountY: Integer; TypeResample: TFilterTypeResample);
procedure Resample(Src, Dst: TDIB; filtertype: TFilterTypeResample; fwidth: single);
// -----------------------------------------------------------------------------
//
// Filter functions
//
// -----------------------------------------------------------------------------
 
// Hermite filter
function HermiteFilter(Value: Single): Single; {$IFDEF VER9UP}inline;{$ENDIF}
begin
// f(t) = 2|t|^3 - 3|t|^2 + 1, -1 <= t <= 1
if (Value < 0.0) then
Value := -Value;
if (Value < 1.0) then
Result := (2.0 * Value - 3.0) * Sqr(Value) + 1.0
else
Result := 0.0;
end;
 
// Box filter
// a.k.a. "Nearest Neighbour" filter
// anme: I have not been able to get acceptable
// results with this filter for subsampling.
function BoxFilter(Value: Single): Single; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if (Value > -0.5) and (Value <= 0.5) then
Result := 1.0
else
Result := 0.0;
end;
 
// Triangle filter
// a.k.a. "Linear" or "Bilinear" filter
function TriangleFilter(Value: Single): Single; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if (Value < 0.0) then
Value := -Value;
if (Value < 1.0) then
Result := 1.0 - Value
else
Result := 0.0;
end;
 
// Bell filter
function BellFilter(Value: Single): Single; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if (Value < 0.0) then
Value := -Value;
if (Value < 0.5) then
Result := 0.75 - Sqr(Value)
else
if (Value < 1.5) then
begin
Value := Value - 1.5;
Result := 0.5 * Sqr(Value);
end
else
Result := 0.0;
end;
 
// B-spline filter
function SplineFilter(Value: Single): Single; {$IFDEF VER9UP}inline;{$ENDIF}
var
tt: single;
begin
if (Value < 0.0) then
Value := -Value;
if (Value < 1.0) then
begin
tt := Sqr(Value);
Result := 0.5 * tt * Value - tt + 2.0 / 3.0;
end
else
if (Value < 2.0) then
begin
Value := 2.0 - Value;
Result := 1.0 / 6.0 * Sqr(Value) * Value;
end
else
Result := 0.0;
end;
 
// Lanczos3 filter
function Lanczos3Filter(Value: Single): Single;
function SinC(Value: Single): Single; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if (Value <> 0.0) then
begin
Value := Value * Pi;
Result := sin(Value) / Value
end
else
Result := 1.0;
end;
begin
if (Value < 0.0) then
Value := -Value;
if (Value < 3.0) then
Result := SinC(Value) * SinC(Value / 3.0)
else
Result := 0.0;
end;
 
function MitchellFilter(Value: Single): Single; {$IFDEF VER9UP}inline;{$ENDIF}
const
B = (1.0 / 3.0);
C = (1.0 / 3.0);
var
tt: single;
begin
if (Value < 0.0) then
Value := -Value;
tt := Sqr(Value);
if (Value < 1.0) then
begin
Value := (((12.0 - 9.0 * B - 6.0 * C) * (Value * tt))
+ ((-18.0 + 12.0 * B + 6.0 * C) * tt)
+ (6.0 - 2 * B));
Result := Value / 6.0;
end
else
if (Value < 2.0) then
begin
Value := (((-1.0 * B - 6.0 * C) * (Value * tt))
+ ((6.0 * B + 30.0 * C) * tt)
+ ((-12.0 * B - 48.0 * C) * Value)
+ (8.0 * B + 24 * C));
Result := Value / 6.0;
end
else
Result := 0.0;
end;
 
// -----------------------------------------------------------------------------
//
// Interpolator
//
// -----------------------------------------------------------------------------
type
// Contributor for a pixel
TContributor = packed record
pixel: Integer; // Source pixel
weight: single; // Pixel weight
end;
 
TContributorList = array[0..0] of TContributor;
PContributorList = ^TContributorList;
 
// List of source pixels contributing to a destination pixel
TCList = packed record
n: Integer;
p: PContributorList;
end;
 
TCListList = array[0..0] of TCList;
PCListList = ^TCListList;
 
TRGB = packed record
r, g, b: single;
end;
 
// Physical bitmap pixel
TColorRGB = packed record
r, g, b: BYTE;
end;
PColorRGB = ^TColorRGB;
 
// Physical bitmap scanline (row)
TRGBList = packed array[0..0] of TColorRGB;
PRGBList = ^TRGBList;
 
var
xscale, yscale: single; // Zoom scale factors
i, j, k: Integer; // Loop variables
center: single; // Filter calculation variables
width, fscale, weight: single; // Filter calculation variables
left, right: Integer; // Filter calculation variables
n: Integer; // Pixel number
Work: TDIB;
contrib: PCListList;
rgb: TRGB;
color: TColorRGB;
{$IFDEF USE_SCANLINE}
SourceLine,
DestLine: PRGBList;
//SourcePixel,
DestPixel: PColorRGB;
Delta,
DestDelta: Integer;
{$ENDIF}
SrcWidth,
SrcHeight,
DstWidth,
DstHeight: Integer;
 
function Color2RGB(Color: TColor): TColorRGB; {$IFDEF VER9UP}inline;{$ENDIF}
begin
Result.r := Color and $000000FF;
Result.g := (Color and $0000FF00) shr 8;
Result.b := (Color and $00FF0000) shr 16;
end;
 
function RGB2Color(Color: TColorRGB): TColor; {$IFDEF VER9UP}inline;{$ENDIF}
begin
Result := Color.r or (Color.g shl 8) or (Color.b shl 16);
end;
 
begin
DstWidth := Dst.Width;
DstHeight := Dst.Height;
SrcWidth := Src.Width;
SrcHeight := Src.Height;
if (SrcWidth < 1) or (SrcHeight < 1) then
raise Exception.Create('Source bitmap too small');
 
// Create intermediate image to hold horizontal zoom
Work := TDIB.Create;
try
Work.Height := SrcHeight;
Work.Width := DstWidth;
// xscale := DstWidth / SrcWidth;
// yscale := DstHeight / SrcHeight;
// Improvement suggested by David Ullrich:
if (SrcWidth = 1) then
xscale := DstWidth / SrcWidth
else
xscale := (DstWidth - 1) / (SrcWidth - 1);
if (SrcHeight = 1) then
yscale := DstHeight / SrcHeight
else
yscale := (DstHeight - 1) / (SrcHeight - 1);
// This implementation only works on 24-bit images because it uses
// TDIB.Scanline
{$IFDEF USE_SCANLINE}
//Src.PixelFormat := pf24bit;
Src.BitCount := 24;
//Dst.PixelFormat := Src.PixelFormat;
dst.BitCount := 24;
//Work.PixelFormat := Src.PixelFormat;
work.BitCount := 24;
{$ENDIF}
 
// --------------------------------------------
// Pre-calculate filter contributions for a row
// -----------------------------------------------
GetMem(contrib, DstWidth * sizeof(TCList));
// Horizontal sub-sampling
// Scales from bigger to smaller width
if (xscale < 1.0) then
begin
width := fwidth / xscale;
fscale := 1.0 / xscale;
for i := 0 to DstWidth - 1 do
begin
contrib^[i].n := 0;
GetMem(contrib^[i].p, trunc(width * 2.0 + 1) * sizeof(TContributor));
center := i / xscale;
// Original code:
// left := ceil(center - width);
// right := floor(center + width);
left := floor(center - width);
right := ceil(center + width);
for j := left to right do
begin
case filtertype of
ftrBox: weight := boxfilter((center - j) / fscale) / fscale;
ftrTriangle: weight := trianglefilter((center - j) / fscale) / fscale;
ftrHermite: weight := hermitefilter((center - j) / fscale) / fscale;
ftrBell: weight := bellfilter((center - j) / fscale) / fscale;
ftrBSpline: weight := splinefilter((center - j) / fscale) / fscale;
ftrLanczos3: weight := Lanczos3filter((center - j) / fscale) / fscale;
ftrMitchell: weight := Mitchellfilter((center - j) / fscale) / fscale;
else
weight := 0
end;
if (weight = 0.0) then
continue;
if (j < 0) then
n := -j
else if (j >= SrcWidth) then
n := SrcWidth - j + SrcWidth - 1
else
n := j;
k := contrib^[i].n;
contrib^[i].n := contrib^[i].n + 1;
contrib^[i].p^[k].pixel := n;
contrib^[i].p^[k].weight := weight;
end;
end;
end
else
// Horizontal super-sampling
// Scales from smaller to bigger width
begin
for i := 0 to DstWidth - 1 do
begin
contrib^[i].n := 0;
GetMem(contrib^[i].p, trunc(fwidth * 2.0 + 1) * sizeof(TContributor));
center := i / xscale;
// Original code:
// left := ceil(center - fwidth);
// right := floor(center + fwidth);
left := floor(center - fwidth);
right := ceil(center + fwidth);
for j := left to right do
begin
case filtertype of
ftrBox: weight := boxfilter(center - j);
ftrTriangle: weight := trianglefilter(center - j);
ftrHermite: weight := hermitefilter(center - j);
ftrBell: weight := bellfilter(center - j);
ftrBSpline: weight := splinefilter(center - j);
ftrLanczos3: weight := Lanczos3filter(center - j);
ftrMitchell: weight := Mitchellfilter(center - j);
else
weight := 0
end;
if (weight = 0.0) then
continue;
if (j < 0) then
n := -j
else if (j >= SrcWidth) then
n := SrcWidth - j + SrcWidth - 1
else
n := j;
k := contrib^[i].n;
contrib^[i].n := contrib^[i].n + 1;
contrib^[i].p^[k].pixel := n;
contrib^[i].p^[k].weight := weight;
end;
end;
end;
 
// ----------------------------------------------------
// Apply filter to sample horizontally from Src to Work
// ----------------------------------------------------
for k := 0 to SrcHeight - 1 do
begin
{$IFDEF USE_SCANLINE}
SourceLine := Src.ScanLine[k];
DestPixel := Work.ScanLine[k];
{$ENDIF}
for i := 0 to DstWidth - 1 do
begin
rgb.r := 0.0;
rgb.g := 0.0;
rgb.b := 0.0;
for j := 0 to contrib^[i].n - 1 do
begin
{$IFDEF USE_SCANLINE}
color := SourceLine^[contrib^[i].p^[j].pixel];
{$ELSE}
color := Color2RGB(Src.Canvas.Pixels[contrib^[i].p^[j].pixel, k]);
{$ENDIF}
weight := contrib^[i].p^[j].weight;
if (weight = 0.0) then
continue;
rgb.r := rgb.r + color.r * weight;
rgb.g := rgb.g + color.g * weight;
rgb.b := rgb.b + color.b * weight;
end;
if (rgb.r > 255.0) then
color.r := 255
else if (rgb.r < 0.0) then
color.r := 0
else
color.r := round(rgb.r);
if (rgb.g > 255.0) then
color.g := 255
else if (rgb.g < 0.0) then
color.g := 0
else
color.g := round(rgb.g);
if (rgb.b > 255.0) then
color.b := 255
else if (rgb.b < 0.0) then
color.b := 0
else
color.b := round(rgb.b);
{$IFDEF USE_SCANLINE}
// Set new pixel value
DestPixel^ := color;
// Move on to next column
inc(DestPixel);
{$ELSE}
Work.Canvas.Pixels[i, k] := RGB2Color(color);
{$ENDIF}
end;
end;
 
// Free the memory allocated for horizontal filter weights
for i := 0 to DstWidth - 1 do
FreeMem(contrib^[i].p);
 
FreeMem(contrib);
 
// -----------------------------------------------
// Pre-calculate filter contributions for a column
// -----------------------------------------------
GetMem(contrib, DstHeight * sizeof(TCList));
// Vertical sub-sampling
// Scales from bigger to smaller height
if (yscale < 1.0) then
begin
width := fwidth / yscale;
fscale := 1.0 / yscale;
for i := 0 to DstHeight - 1 do
begin
contrib^[i].n := 0;
GetMem(contrib^[i].p, trunc(width * 2.0 + 1) * sizeof(TContributor));
center := i / yscale;
// Original code:
// left := ceil(center - width);
// right := floor(center + width);
left := floor(center - width);
right := ceil(center + width);
for j := left to right do
begin
case filtertype of
ftrBox: weight := boxfilter((center - j) / fscale) / fscale;
ftrTriangle: weight := trianglefilter((center - j) / fscale) / fscale;
ftrHermite: weight := hermitefilter((center - j) / fscale) / fscale;
ftrBell: weight := bellfilter((center - j) / fscale) / fscale;
ftrBSpline: weight := splinefilter((center - j) / fscale) / fscale;
ftrLanczos3: weight := Lanczos3filter((center - j) / fscale) / fscale;
ftrMitchell: weight := Mitchellfilter((center - j) / fscale) / fscale;
else
weight := 0
end;
if (weight = 0.0) then
continue;
if (j < 0) then
n := -j
else if (j >= SrcHeight) then
n := SrcHeight - j + SrcHeight - 1
else
n := j;
k := contrib^[i].n;
contrib^[i].n := contrib^[i].n + 1;
contrib^[i].p^[k].pixel := n;
contrib^[i].p^[k].weight := weight;
end;
end
end
else
// Vertical super-sampling
// Scales from smaller to bigger height
begin
for i := 0 to DstHeight - 1 do
begin
contrib^[i].n := 0;
GetMem(contrib^[i].p, trunc(fwidth * 2.0 + 1) * sizeof(TContributor));
center := i / yscale;
// Original code:
// left := ceil(center - fwidth);
// right := floor(center + fwidth);
left := floor(center - fwidth);
right := ceil(center + fwidth);
for j := left to right do
begin
case filtertype of
ftrBox: weight := boxfilter(center - j);
ftrTriangle: weight := trianglefilter(center - j);
ftrHermite: weight := hermitefilter(center - j);
ftrBell: weight := bellfilter(center - j);
ftrBSpline: weight := splinefilter(center - j);
ftrLanczos3: weight := Lanczos3filter(center - j);
ftrMitchell: weight := Mitchellfilter(center - j);
else
weight := 0
end;
if (weight = 0.0) then
continue;
if (j < 0) then
n := -j
else if (j >= SrcHeight) then
n := SrcHeight - j + SrcHeight - 1
else
n := j;
k := contrib^[i].n;
contrib^[i].n := contrib^[i].n + 1;
contrib^[i].p^[k].pixel := n;
contrib^[i].p^[k].weight := weight;
end;
end;
end;
 
// --------------------------------------------------
// Apply filter to sample vertically from Work to Dst
// --------------------------------------------------
{$IFDEF USE_SCANLINE}
SourceLine := Work.ScanLine[0];
Delta := Integer(Work.ScanLine[1]) - Integer(SourceLine);
DestLine := Dst.ScanLine[0];
DestDelta := Integer(Dst.ScanLine[1]) - Integer(DestLine);
{$ENDIF}
for k := 0 to DstWidth - 1 do
begin
{$IFDEF USE_SCANLINE}
DestPixel := pointer(DestLine);
{$ENDIF}
for i := 0 to DstHeight - 1 do
begin
rgb.r := 0;
rgb.g := 0;
rgb.b := 0;
// weight := 0.0;
for j := 0 to contrib^[i].n - 1 do
begin
{$IFDEF USE_SCANLINE}
//color := PColorRGB(PByte(SourceLine) + contrib^[i].p^[j].pixel * Delta)^;
Move(Pointer(Integer(SourceLine) + contrib^[i].p^[j].pixel * Delta)^, Color, SizeOf(Color));
{$ELSE}
color := Color2RGB(Work.Canvas.Pixels[k, contrib^[i].p^[j].pixel]);
{$ENDIF}
weight := contrib^[i].p^[j].weight;
if (weight = 0.0) then
continue;
rgb.r := rgb.r + color.r * weight;
rgb.g := rgb.g + color.g * weight;
rgb.b := rgb.b + color.b * weight;
end;
if (rgb.r > 255.0) then
color.r := 255
else if (rgb.r < 0.0) then
color.r := 0
else
color.r := round(rgb.r);
if (rgb.g > 255.0) then
color.g := 255
else if (rgb.g < 0.0) then
color.g := 0
else
color.g := round(rgb.g);
if (rgb.b > 255.0) then
color.b := 255
else if (rgb.b < 0.0) then
color.b := 0
else
color.b := round(rgb.b);
{$IFDEF USE_SCANLINE}
DestPixel^ := color;
{$IFDEF WIN64}
inc(PByte(DestPixel), DestDelta);
{$ELSE}
inc(Integer(DestPixel), DestDelta);
{$ENDIF}
{$ELSE}
Dst.Canvas.Pixels[k, i] := RGB2Color(color);
{$ENDIF}
end;
{$IFDEF USE_SCANLINE}
Inc(SourceLine, 1);
Inc(DestLine, 1);
{$ENDIF}
end;
 
// Free the memory allocated for vertical filter weights
for i := 0 to DstHeight - 1 do
FreeMem(contrib^[i].p);
 
FreeMem(contrib);
 
finally
Work.Free;
end;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
BB2.SetSize(AmountX, AmountY, 24);
Resample(BB1, BB2, TypeResample, DefaultFilterRadius[TypeResample]);
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
procedure TDIB.DoColorize(ForeColor, BackColor: TColor);
procedure Colorize(src, dst: TDIB; iForeColor, iBackColor: TColor; iDither: Boolean{$IFDEF VER4UP} = False{$ENDIF});
{for monochromatic picture change colors}
procedure InvertBitmap(Bmp: TDIB);
begin
Bmp.Canvas.CopyMode := cmDstInvert;
Bmp.Canvas.CopyRect(rect(0, 0, Bmp.Width, Bmp.Height),
Bmp.Canvas, rect(0, 0, Bmp.Width, Bmp.Height));
end;
var
fForeColor: TColor;
fForeDither: Boolean;
lTempBitmap: TDIB;
lTempBitmap2: TDIB;
lDitherBitmap: TDIB;
lCRect: TRect;
x, y, w, h: Integer;
begin
{--}
//fColor := iBackColor; ;
fForeColor := iForeColor;
fForeDither := iDither;
w := src.Width;
h := src.Height;
lDitherBitmap := nil;
lTempBitmap := TDIB.Create;
lTempBitmap.SetSize(w, h, 24);
lTempBitmap2 := TDIB.Create;
lTempBitmap2.SetSize(w, h, 24);
lCRect := rect(0, 0, w, h);
with lTempBitmap.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := iBackColor;
FillRect(lCRect);
CopyMode := cmSrcInvert;
CopyRect(lCRect, src.Canvas, lCRect);
InvertBitmap(src);
CopyMode := cmSrcPaint;
CopyRect(lCRect, src.Canvas, lCRect);
InvertBitmap(lTempBitmap);
CopyMode := cmSrcInvert;
CopyRect(lCRect, src.Canvas, lCRect);
InvertBitmap(src);
end;
with lTempBitmap2.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := clBlack;
FillRect(lCRect);
if fForeDither then
begin
InvertBitmap(src);
lDitherBitmap := TDIB.Create;
lDitherBitmap.SetSize(8, 8, 24);
with lDitherBitmap.Canvas do
begin
for x := 0 to 7 do
for y := 0 to 7 do
if ((x mod 2 = 0) and (y mod 2 > 0)) or ((x mod 2 > 0) and (y mod 2 = 0)) then
pixels[x, y] := fForeColor
else
pixels[x, y] := iBackColor;
end;
Brush.Bitmap.Assign(lDitherBitmap);
end
else
begin
Brush.Style := bsSolid;
Brush.Color := fForeColor;
end;
if not fForeDither then
InvertBitmap(src);
CopyMode := cmPatPaint;
CopyRect(lCRect, src.Canvas, lCRect);
if fForeDither then
if Assigned(lDitherBitmap) then
lDitherBitmap.Free;
CopyMode := cmSrcInvert;
CopyRect(lCRect, src.Canvas, lCRect);
end;
lTempBitmap.Canvas.CopyMode := cmSrcInvert;
lTempBitmap.Canvas.Copyrect(lCRect, lTempBitmap2.Canvas, lCRect);
InvertBitmap(src);
lTempBitmap.Canvas.CopyMode := cmSrcErase;
lTempBitmap.Canvas.Copyrect(lCRect, src.Canvas, lCRect);
InvertBitmap(src);
lTempBitmap.Canvas.CopyMode := cmSrcInvert;
lTempBitmap.Canvas.Copyrect(lCRect, lTempBitmap2.Canvas, lCRect);
InvertBitmap(lTempBitmap);
InvertBitmap(src);
dst.Assign(lTempBitmap);
lTempBitmap.Free;
end;
var BB1, BB2: TDIB;
begin
BB1 := TDIB.Create;
BB1.BitCount := 24;
BB1.Assign(Self);
BB2 := TDIB.Create;
Colorize(BB1, BB2, ForeColor, BackColor{$IFNDEF VER4UP}, False{$ENDIF});
Self.Assign(BB2);
BB1.Free;
BB2.Free;
end;
 
{ procedure for special purpose }
(*
procedure TDIB.FadeOut(DIB2: TDIB; Step: Byte);
var
P1, P2: PByteArray;
W, H: Integer;
begin
P1 := ScanLine[DIB2.Height - 1];
P2 := DIB2.ScanLine[DIB2.Height - 1];
W := WidthBytes;
H := Height;
asm
PUSH ESI
PUSH EDI
MOV ESI, P1
MOV EDI, P2
MOV EDX, W
MOV EAX, H
IMUL EDX
MOV ECX, EAX
@@1:
MOV AL, Step
MOV AH, [ESI]
CMP AL, AH
JA @@2
MOV AL, AH
@@2:
MOV [EDI], AL
INC ESI
INC EDI
DEC ECX
JNZ @@1
POP EDI
POP ESI
end;
end;
*)
procedure TDIB.FadeOut(DIB2: TDIB; Step: Byte);
var
P1, P2: PByteArray;
W, H, i: Integer;
begin
P1 := ScanLine[DIB2.Height - 1];
P2 := DIB2.ScanLine[DIB2.Height - 1];
W := WidthBytes;
H := Height;
for i := 0 to W * H - 1 do
begin
if P1[i] < Step then P2[i] := P1[i]
else P2[i] := Step;
end;
end;
 
procedure TDIB.DoZoom(DIB2: TDIB; ZoomRatio: Real);
var
P1, P2: PByteArray;
W, H: Integer;
x, y: Integer;
xr, yr, xstep, ystep: real;
xstart: real;
begin
W := WidthBytes;
H := Height;
xstart := (W - (W * ZoomRatio)) / 2;
 
xr := xstart;
yr := (H - (H * ZoomRatio)) / 2;
xstep := ZoomRatio;
ystep := ZoomRatio;
 
for y := 1 to Height - 1 do
begin
P2 := DIB2.ScanLine[y];
if (yr >= 0) and (yr <= H) then
begin
P1 := ScanLine[Trunc(yr)];
for x := 1 to Width - 1 do
begin
if (xr >= 0) and (xr <= W) then
begin
P2[x] := P1[Trunc(xr)];
end
else
begin
P2[x] := 0;
end;
xr := xr + xstep;
end;
end
else
begin
for x := 1 to Width - 1 do
begin
P2[x] := 0;
end;
end;
xr := xstart;
yr := yr + ystep;
end;
end;
 
procedure TDIB.DoBlur(DIB2: TDIB);
var
P1, P2: PByteArray;
W: Integer;
x, y: Integer;
begin
W := WidthBytes;
for y := 1 to Height - 1 do
begin
P1 := ScanLine[y];
P2 := DIB2.ScanLine[y];
for x := 1 to Width - 1 do
begin
P2[x] := (P1[x] + P1[x - 1] + P1[x + 1] + P1[x + W] + P1[x - W]) div 5;
end;
end;
end;
(*
procedure TDIB.FadeIn(DIB2: TDIB; Step: Byte);
var
P1, P2: PByteArray;
W, H: Integer;
begin
P1 := ScanLine[DIB2.Height - 1];
P2 := DIB2.ScanLine[DIB2.Height - 1];
W := WidthBytes;
H := Height;
asm
PUSH ESI
PUSH EDI
MOV ESI, P1
MOV EDI, P2
MOV EDX, W
MOV EAX, H
IMUL EDX
MOV ECX, EAX
@@1:
MOV AL, Step
MOV AH, [ESI]
CMP AL, AH
JB @@2
MOV AL, AH
@@2:
MOV [EDI], AL
INC ESI
INC EDI
DEC ECX
JNZ @@1
POP EDI
POP ESI
end;
end;
*)
procedure TDIB.FadeIn(DIB2: TDIB; Step: Byte);
var
P1, P2: PByteArray;
W, H, i: Integer;
begin
P1 := ScanLine[DIB2.Height - 1];
P2 := DIB2.ScanLine[DIB2.Height - 1];
W := WidthBytes;
H := Height;
for i := 0 to W * H - 1 do
begin
if P1[i] > Step then P2[i] := P1[i]
else P2[i] := Step;
end;
end;
 
(*
procedure TDIB.FillDIB8(Color: Byte);
var
P: PByteArray;
W, H: Integer;
begin
P := ScanLine[Height - 1];
W := WidthBytes;
H := Height;
asm
PUSH ESI
MOV ESI, P
MOV EDX, W
MOV EAX, H
IMUL EDX
MOV ECX, EAX
MOV AL, Color
@@1:
MOV [ESI], AL
INC ESI
DEC ECX
JNZ @@1
POP ESI
end;
end;
*)
 
procedure TDIB.FillDIB8(Color: Byte);
var
P: PByteArray;
W, H, I: Integer;
begin
P := ScanLine[Height - 1];
W := WidthBytes;
H := Height;
for I := 0 to W * H - 1 do
P[I] := Color;
end;
 
 
procedure TDIB.DoRotate(DIB1: TDIB; cX, cY, Angle: Integer);
type
T3Byte = array[0..2] of Byte;
P3ByteArray = ^T3ByteArray;
T3ByteArray = array[0..32767] of T3Byte;
PLongArray = ^TLongArray;
TLongArray = array[0..32767] of LongInt;
var
p, p2: PByteArray;
x, y, x2, y2, angled: Integer;
cosy, siny: real;
begin
angled := 384 + Angle;
for y := 0 to Height - 1 do
begin
p := DIB1.ScanLine[y];
cosy := (y - cY) * dcos(angled and $1FF);
siny := (y - cY) * dsin(angled and $1FF);
for x := 0 to Width - 1 do
begin
x2 := Trunc((x - cX) * dsin(angled and $1FF) + cosy) + cX;
y2 := Trunc((x - cX) * dcos(angled and $1FF) - siny) + cY;
case bitcount of
8:
begin
if (y2 >= 0) and (y2 < Height) and (x2 >= 0) and (x2 < Width) then
begin
p2 := ScanLine[y2];
p[x] := p2[Width - x2];
end
else
begin
if p[x] > 4 then
p[x] := p[x] - 4
else
p[x] := 0;
end;
end;
16:
begin
if (y2 >= 0) and (y2 < Height) and (x2 >= 0) and (x2 < Width) then
begin
PWordArray(p2) := ScanLine[y2];
PWordArray(p)[x] := PWordArray(p2)[Width - x2];
end
else
begin
if PWordArray(p)[x] > 4 then
PWordArray(p)[x] := PWordArray(p)[x] - 4
else
PWordArray(p)[x] := 0;
end;
end;
24:
begin
if (y2 >= 0) and (y2 < Height) and (x2 >= 0) and (x2 < Width) then
begin
P3ByteArray(p2) := ScanLine[y2];
P3ByteArray(p)[x] := P3ByteArray(p2)[Width - x2];
end
else
begin
if P3ByteArray(p)[x][0] > 4 then
P3ByteArray(p)[x][0] := P3ByteArray(p)[x][0] - 4
else if P3ByteArray(p)[x][1] > 4 then
P3ByteArray(p)[x][1] := P3ByteArray(p)[x][1] - 4
else if P3ByteArray(p)[x][2] > 4 then
P3ByteArray(p)[x][2] := P3ByteArray(p)[x][2] - 4
else
begin
P3ByteArray(p)[x][0] := 0;
P3ByteArray(p)[x][1] := 0;
P3ByteArray(p)[x][2] := 0;
end;
end;
end;
32: begin
if (y2 >= 0) and (y2 < Height) and (x2 >= 0) and (x2 < Width) then
begin
plongarray(p2) := ScanLine[y2];
plongarray(p)[x] := plongarray(p2)[Width - x2];
end
else
begin
if plongarray(p)[x] > 4 then
plongarray(p)[x] := plongarray(p)[x] - 4
else
plongarray(p)[x] := 0;
end;
end;
end
end;
end;
end;
 
function TDIB.Ink(DIB: TDIB; const SprayInit: Boolean; const AmountSpray: Integer): Boolean;
type
T3Byte = array[0..2] of Byte;
P3ByteArray = ^T3ByteArray;
T3ByteArray = array[0..32767] of T3Byte;
PLongArray = ^TLongArray;
TLongArray = array[0..32767] of LongInt;
function ColorToRGBTriple(const Color: TColor): TRGBTriple;
begin
with RESULT do
begin
rgbtRed := GetRValue(Color);
rgbtGreen := GetGValue(Color);
rgbtBlue := GetBValue(Color)
end
end {ColorToRGBTriple};
 
function TestQuad(T: T3Byte; Color: Integer): Boolean;
begin
Result := (T[0] > GetRValue(Color)) and
(T[1] > GetGValue(Color)) and
(T[2] > GetBValue(Color))
end;
var
p0, p, p2: PByteArray;
x, y, c: Integer;
z: Integer;
begin
if SprayInit then
begin
DIB.Assign(Self);
{ Spray seeds }
for c := 0 to AmountSpray do
begin
DIB.Pixels[Random(Width - 1), Random(Height - 1)] := 0;
end;
end;
Result := True; {all is black}
for y := 0 to DIB.Height - 1 do
begin
p := DIB.ScanLine[y];
for x := 0 to DIB.Width - 1 do
begin
case bitcount of
8:
begin
if p[x] < 16 then
begin
if p[x] > 0 then Result := False;
if y > 0 then
begin
p0 := DIB.ScanLine[y - 1];
if p0[x] > 4 then
p0[x] := p0[x] - 4
else
p0[x] := 0;
if x > 0 then
if p0[x - 1] > 2 then
p0[x - 1] := p0[x - 1] - 2
else
p0[x - 1] := 0;
if x < (DIB.Width - 1) then
if p0[x + 1] > 2 then
p0[x + 1] := p0[x + 1] - 2
else
p0[x + 1] := 0;
end;
if y < (DIB.Height - 1) then
begin
p2 := DIB.ScanLine[y + 1];
if p2[x] > 4 then
p2[x] := p2[x] - 4
else
p2[x] := 0;
if x > 0 then
if p2[x - 1] > 2 then
p2[x - 1] := p2[x - 1] - 2
else
p2[x - 1] := 0;
if x < (DIB.Width - 1) then
if p2[x + 1] > 2 then
p2[x + 1] := p2[x + 1] - 2
else
p2[x + 1] := 0;
end;
if p[x] > 8 then
p[x] := p[x] - 8
else
p[x] := 0;
if x > 0 then
if p[x - 1] > 4 then
p[x - 1] := p[x - 1] - 4
else
p[x - 1] := 0;
if x < (DIB.Width - 1) then
if p[x + 1] > 4 then
p[x + 1] := p[x + 1] - 4
else
p[x + 1] := 0;
end;
end;
16:
begin
if pwordarray(p)[x] < 16 then
begin
if pwordarray(p)[x] > 0 then Result := False;
if y > 0 then
begin
pwordarray(p0) := DIB.ScanLine[y - 1];
if pwordarray(p0)[x] > 4 then
pwordarray(p0)[x] := pwordarray(p0)[x] - 4
else
pwordarray(p0)[x] := 0;
if x > 0 then
if pwordarray(p0)[x - 1] > 2 then
pwordarray(p0)[x - 1] := pwordarray(p0)[x - 1] - 2
else
pwordarray(p0)[x - 1] := 0;
if x < (DIB.Width - 1) then
if pwordarray(p0)[x + 1] > 2 then
pwordarray(p0)[x + 1] := pwordarray(p0)[x + 1] - 2
else
pwordarray(p0)[x + 1] := 0;
end;
if y < (DIB.Height - 1) then
begin
pwordarray(p2) := DIB.ScanLine[y + 1];
if pwordarray(p2)[x] > 4 then
pwordarray(p2)[x] := pwordarray(p2)[x] - 4
else
pwordarray(p2)[x] := 0;
if x > 0 then
if pwordarray(p2)[x - 1] > 2 then
pwordarray(p2)[x - 1] := pwordarray(p2)[x - 1] - 2
else
pwordarray(p2)[x - 1] := 0;
if x < (DIB.Width - 1) then
if pwordarray(p2)[x + 1] > 2 then
pwordarray(p2)[x + 1] := pwordarray(p2)[x + 1] - 2
else
pwordarray(p2)[x + 1] := 0;
end;
if pwordarray(p)[x] > 8 then
pwordarray(p)[x] := pwordarray(p)[x] - 8
else
pwordarray(p)[x] := 0;
if x > 0 then
if pwordarray(p)[x - 1] > 4 then
pwordarray(p)[x - 1] := pwordarray(p)[x - 1] - 4
else
pwordarray(p)[x - 1] := 0;
if x < (DIB.Width - 1) then
if pwordarray(p)[x + 1] > 4 then
pwordarray(p)[x + 1] := pwordarray(p)[x + 1] - 4
else
pwordarray(p)[x + 1] := 0;
end;
end;
24:
begin
if not TestQuad(P3ByteArray(p)[x], 16) then
begin
if TestQuad(P3ByteArray(p)[x], 0) then Result := False;
if y > 0 then
begin
P3ByteArray(p0) := DIB.ScanLine[y - 1];
if TestQuad(P3ByteArray(p0)[x], 4) then
begin
for z := 0 to 2 do
if P3ByteArray(p0)[x][z] > 4 then
P3ByteArray(p0)[x][z] := P3ByteArray(p0)[x][z] - 4
end
else
for z := 0 to 2 do
P3ByteArray(p0)[x][z] := 0;
if x > 0 then
if TestQuad(P3ByteArray(p0)[x - 1], 2) then
begin
for z := 0 to 2 do
if P3ByteArray(p0)[x - 1][z] > 2 then
P3ByteArray(p0)[x - 1][z] := P3ByteArray(p0)[x - 1][z] - 2
end
else
for z := 0 to 2 do
P3ByteArray(p0)[x - 1][z] := 0;
if x < (DIB.Width - 1) then
if TestQuad(P3ByteArray(p0)[x + 1], 2) then
begin
for z := 0 to 2 do
if P3ByteArray(p0)[x + 1][z] > 2 then
P3ByteArray(p0)[x + 1][z] := P3ByteArray(p0)[x + 1][z] - 2
end
else
for z := 0 to 2 do
P3ByteArray(p0)[x + 1][z] := 0;
end;
if y < (DIB.Height - 1) then
begin
P3ByteArray(p2) := DIB.ScanLine[y + 1];
if TestQuad(P3ByteArray(p2)[x], 4) then
begin
for z := 0 to 2 do
if P3ByteArray(p2)[x][z] > 4 then
P3ByteArray(p2)[x][z] := P3ByteArray(p2)[x][z] - 4
end
else
for z := 0 to 2 do
P3ByteArray(p2)[x][z] := 0;
if x > 0 then
if TestQuad(P3ByteArray(p2)[x - 1], 2) then
begin
for z := 0 to 2 do
if P3ByteArray(p2)[x - 1][z] > 2 then
P3ByteArray(p2)[x - 1][z] := P3ByteArray(p2)[x - 1][z] - 2
end
else
for z := 0 to 2 do
P3ByteArray(p2)[x - 1][z] := 0;
if x < (DIB.Width - 1) then
if TestQuad(P3ByteArray(p2)[x + 1], 2) then
begin
for z := 0 to 2 do
if P3ByteArray(p2)[x + 1][z] > 2 then
P3ByteArray(p2)[x + 1][z] := P3ByteArray(p2)[x + 1][z] - 2
end
else
for z := 0 to 2 do
P3ByteArray(p2)[x + 1][z] := 0;
end;
if TestQuad(P3ByteArray(p)[x], 8) then
begin
for z := 0 to 2 do
if P3ByteArray(p)[x][z] > 8 then
P3ByteArray(p)[x][z] := P3ByteArray(p)[x][z] - 8
end
else
for z := 0 to 2 do
P3ByteArray(p)[x][z] := 0;
if x > 0 then
if TestQuad(P3ByteArray(p)[x - 1], 4) then
begin
for z := 0 to 2 do
if P3ByteArray(p)[x - 1][z] > 4 then
P3ByteArray(p)[x - 1][z] := P3ByteArray(p)[x - 1][z] - 4
end
else
for z := 0 to 2 do
P3ByteArray(p)[x - 1][z] := 0;
if x < (DIB.Width - 1) then
if TestQuad(P3ByteArray(p)[x + 1], 4) then
begin
for z := 0 to 2 do
if P3ByteArray(p)[x + 1][z] > 4 then
P3ByteArray(p)[x + 1][z] := P3ByteArray(p)[x + 1][z] - 4
end
else
for z := 0 to 2 do
P3ByteArray(p)[x + 1][z] := 0;
end;
end;
32:
begin
if plongarray(p)[x] < 16 then
begin
if plongarray(p)[x] > 0 then Result := False;
if y > 0 then
begin
plongarray(p0) := DIB.ScanLine[y - 1];
if plongarray(p0)[x] > 4 then
plongarray(p0)[x] := plongarray(p0)[x] - 4
else
plongarray(p0)[x] := 0;
if x > 0 then
if plongarray(p0)[x - 1] > 2 then
plongarray(p0)[x - 1] := plongarray(p0)[x - 1] - 2
else
plongarray(p0)[x - 1] := 0;
if x < (DIB.Width - 1) then
if plongarray(p0)[x + 1] > 2 then
plongarray(p0)[x + 1] := plongarray(p0)[x + 1] - 2
else
plongarray(p0)[x + 1] := 0;
end;
if y < (DIB.Height - 1) then
begin
plongarray(p2) := DIB.ScanLine[y + 1];
if plongarray(p2)[x] > 4 then
plongarray(p2)[x] := plongarray(p2)[x] - 4
else
plongarray(p2)[x] := 0;
if x > 0 then
if plongarray(p2)[x - 1] > 2 then
plongarray(p2)[x - 1] := plongarray(p2)[x - 1] - 2
else
plongarray(p2)[x - 1] := 0;
if x < (DIB.Width - 1) then
if plongarray(p2)[x + 1] > 2 then
plongarray(p2)[x + 1] := plongarray(p2)[x + 1] - 2
else
plongarray(p2)[x + 1] := 0;
end;
if plongarray(p)[x] > 8 then
plongarray(p)[x] := plongarray(p)[x] - 8
else
plongarray(p)[x] := 0;
if x > 0 then
if plongarray(p)[x - 1] > 4 then
plongarray(p)[x - 1] := plongarray(p)[x - 1] - 4
else
plongarray(p)[x - 1] := 0;
if x < (DIB.Width - 1) then
if plongarray(p)[x + 1] > 4 then
plongarray(p)[x + 1] := plongarray(p)[x + 1] - 4
else
plongarray(p)[x + 1] := 0;
end;
end;
end {case};
end;
end;
end;
 
procedure TDIB.Distort(DIB1: TDIB; dt: TDistortType; cX, cY, Angle: Integer; Factor: Real);
type
T3Byte = array[0..2] of Byte;
P3ByteArray = ^T3ByteArray;
T3ByteArray = array[0..32767] of T3Byte;
PLongArray = ^TLongArray;
TLongArray = array[0..32767] of LongInt;
var
p, p2: PByteArray;
x, y, x2, y2, angled, ysqr: Integer;
actdist, dist, cosy, siny: real;
begin
dist := Factor * sqrt(sqr(cX) + sqr(cY));
for y := 0 to DIB1.Height - 1 do
begin
p := DIB1.ScanLine[y];
ysqr := sqr(y - cY);
for x := 0 to (DIB1.Width) - 1 do
begin
actdist := (sqrt((sqr(x - cX) + ysqr)) / dist);
if dt = dtSlow then
actdist := dsin((Trunc(actdist * 1024)) and $1FF);
angled := 384 + Trunc((actdist) * Angle);
 
cosy := (y - cY) * dcos(angled and $1FF);
siny := (y - cY) * dsin(angled and $1FF);
 
x2 := Trunc((x - cX) * dsin(angled and $1FF) + cosy) + cX;
y2 := Trunc((x - cX) * dcos(angled and $1FF) - siny) + cY;
case bitcount of
8:
begin
if (y2 >= 0) and (y2 < Height) and (x2 >= 0) and (x2 < Width) then
begin
p2 := ScanLine[y2];
p[x] := p2[Width - x2];
end
else
begin
if p[x] > 2 then
p[x] := p[x] - 2
else
p[x] := 0;
end;
end;
16:
begin
if (y2 >= 0) and (y2 < Height) and (x2 >= 0) and (x2 < Width) then
begin
pwordarray(p2) := ScanLine[y2];
pwordarray(p)[x] := pwordarray(p2)[Width - x2];
end
else
begin
if pwordarray(p)[x] > 2 then
pwordarray(p)[x] := pwordarray(p)[x] - 2
else
pwordarray(p)[x] := 0;
end;
end;
24:
begin
if (y2 >= 0) and (y2 < Height) and (x2 >= 0) and (x2 < Width) then
begin
P3ByteArray(p2) := ScanLine[y2];
P3ByteArray(p)[x] := P3ByteArray(p2)[Width - x2];
end
else
begin
if P3ByteArray(p)[x][0] > 2 then
P3ByteArray(p)[x][0] := P3ByteArray(p)[x][0] - 2
else if P3ByteArray(p)[x][1] > 2 then
P3ByteArray(p)[x][1] := P3ByteArray(p)[x][1] - 2
else if P3ByteArray(p)[x][2] > 2 then
P3ByteArray(p)[x][2] := P3ByteArray(p)[x][2] - 2
else
begin
P3ByteArray(p)[x][0] := 0;
P3ByteArray(p)[x][1] := 0;
P3ByteArray(p)[x][2] := 0;
end;
end;
end;
32:
begin
if (y2 >= 0) and (y2 < Height) and (x2 >= 0) and (x2 < Width) then
begin
plongarray(p2) := ScanLine[y2];
plongarray(p)[x] := plongarray(p2)[Width - x2];
end
else
begin
if p[x] > 2 then
plongarray(p)[x] := plongarray(p)[x] - 2
else
plongarray(p)[x] := 0;
end;
end;
end {case}
end;
end;
end;
 
procedure TDIB.AntialiasedLine(x1, y1, x2, y2: Integer; color: TColor);
//anti-aliased line using the Wu algorithm by Peter Bone
var
dX, dY, X, Y, start, finish: Integer;
LM, LR: Integer;
dxi, dyi, dydxi: Integer;
P: PLines;
R, G, B: byte;
begin
R := GetRValue(Color);
G := GetGValue(Color);
B := GetBValue(Color);
dX := abs(x2 - x1); // Calculate deltax and deltay for initialisation
dY := abs(y2 - y1);
if (dX = 0) or (dY = 0) then
begin
Canvas.Pen.Color := (B shl 16) + (G shl 8) + R;
Canvas.MoveTo(x1, y1);
Canvas.LineTo(x2, y2);
exit;
end;
if dX > dY then
begin // horizontal or vertical
if y2 > y1 then // determine rise and run
dydxi := -dY shl 16 div dX
else
dydxi := dY shl 16 div dX;
if x2 < x1 then
begin
start := x2; // right to left
finish := x1;
dyi := y2 shl 16;
end
else
begin
start := x1; // left to right
finish := x2;
dyi := y1 shl 16;
dydxi := -dydxi; // inverse slope
end;
if finish >= Width then finish := Width - 1;
for X := start to finish do
begin
Y := dyi shr 16;
if (X < 0) or (Y < 0) or (Y > Height - 2) then
begin
Inc(dyi, dydxi);
Continue;
end;
LM := dyi - Y shl 16; // fractional part of dyi - in fixed-point
LR := 65536 - LM;
P := Scanline[Y];
P^[X].B := (B * LR + P^[X].B * LM) shr 16;
P^[X].G := (G * LR + P^[X].G * LM) shr 16;
P^[X].R := (R * LR + P^[X].R * LM) shr 16;
//Inc(Y);
P^[X].B := (B * LM + P^[X].B * LR) shr 16;
P^[X].G := (G * LM + P^[X].G * LR) shr 16;
P^[X].R := (R * LM + P^[X].R * LR) shr 16;
Inc(dyi, dydxi); // next point
end;
end
else
begin
if x2 > x1 then // determine rise and run
dydxi := -dX shl 16 div dY
else
dydxi := dX shl 16 div dY;
if y2 < y1 then
begin
start := y2; // right to left
finish := y1;
dxi := x2 shl 16;
end
else
begin
start := y1; // left to right
finish := y2;
dxi := x1 shl 16;
dydxi := -dydxi; // inverse slope
end;
if finish >= Height then finish := Height - 1;
for Y := start to finish do
begin
X := dxi shr 16;
if (Y < 0) or (X < 0) or (X > Width - 2) then
begin
Inc(dxi, dydxi);
Continue;
end;
LM := dxi - X shl 16;
LR := 65536 - LM;
P := Scanline[Y];
P^[X].B := (B * LR + P^[X].B * LM) shr 16;
P^[X].G := (G * LR + P^[X].G * LM) shr 16;
P^[X].R := (R * LR + P^[X].R * LM) shr 16;
Inc(X);
P^[X].B := (B * LM + P^[X].B * LR) shr 16;
P^[X].G := (G * LM + P^[X].G * LR) shr 16;
P^[X].R := (R * LM + P^[X].R * LR) shr 16;
Inc(dxi, dydxi); // next point
end;
end;
end;
(*
function TDIB.GetColorBetween(StartColor, EndColor: TColor; Pointvalue,
FromPoint, ToPoint: Extended): TColor;
var F: Extended; r1, r2, r3, g1, g2, g3, b1, b2, b3: Byte;
function CalcColorBytes(fb1, fb2: Byte): Byte;
begin
result := fb1;
if fb1 < fb2 then Result := FB1 + Trunc(F * (fb2 - fb1));
if fb1 > fb2 then Result := FB1 - Trunc(F * (fb1 - fb2));
end;
begin
if Pointvalue <= FromPoint then
begin
result := StartColor;
exit;
end;
if Pointvalue >= ToPoint then
begin
result := EndColor;
exit;
end;
F := (Pointvalue - FromPoint) / (ToPoint - FromPoint);
asm
mov EAX, Startcolor
cmp EAX, EndColor
je @@exit //when equal then exit
mov r1, AL
shr EAX,8
mov g1, AL
shr EAX,8
mov b1, AL
mov EAX, Endcolor
mov r2, AL
shr EAX,8
mov g2, AL
shr EAX,8
mov b2, AL
push ebp
mov AL, r1
mov DL, r2
call CalcColorBytes
pop ECX
push EBP
Mov r3, AL
mov DL, g2
mov AL, g1
call CalcColorBytes
pop ECX
push EBP
mov g3, Al
mov DL, B2
mov Al, B1
call CalcColorBytes
pop ECX
mov b3, AL
XOR EAX,EAX
mov AL, B3
shl EAX,8
mov AL, G3
shl EAX,8
mov AL, R3
@@Exit:
mov @result, EAX
end;
end;
*)
function TDIB.GetColorBetween(StartColor, EndColor: TColor; Pointvalue, FromPoint, ToPoint: Extended): TColor;
var
F: Extended;
r1, g1, b1, r2, g2, b2, r3, g3, b3: Byte;
 
function CalcColorBytes(const factor: Extended; const fb1, fb2: Byte): Byte; {$IFDEF VER9UP}inline;{$ENDIF}
begin
Result := fb1;
if fb1 < fb2 then Result := fb1 + Trunc(factor * (fb2 - fb1));
if fb1 > fb2 then Result := fb1 - Trunc(factor * (fb1 - fb2));
end;
 
procedure GetRGB(const AColor: TColor; var R, G, B: Byte); {$IFDEF VER9UP}inline;{$ENDIF}
begin
R := AColor and $FF;
G := (AColor shr 8) and $FF;
B := (AColor shr 16) and $FF;
end;
 
begin
if Pointvalue <= FromPoint then
begin
Result := StartColor;
Exit;
end;
if Pointvalue >= ToPoint then
begin
Result := EndColor;
Exit;
end;
 
F := (Pointvalue - FromPoint) / (ToPoint - FromPoint);
 
GetRGB(StartColor, r1, g1, b1);
// r1 := StartColor and $FF;
// g1 := (StartColor shr 8) and $FF;
// b1 := (StartColor shr 16) and $FF;
GetRGB(StartColor, r2, g2, b2);
// r2 := EndColor and $FF;
// g2 := (EndColor shr 8) and $FF;
// b2 := (EndColor shr 16) and $FF;
 
r3 := CalcColorBytes(F, r1, r2);
g3 := CalcColorBytes(F, g1, g2);
b3 := CalcColorBytes(F, b1, b2);
 
Result := (b3 shl 16) or (g3 shl 8) or r3;
end;
 
procedure TDIB.ColoredLine(const iStart, iEnd: TPoint; iColorStyle: TColorLineStyle;
iGradientFrom, iGradientTo: TColor; iPixelGeometry: TColorLinePixelGeometry; iRadius: Word);
var
tempColor: TColor;
const
WavelengthMinimum = 380;
WavelengthMaximum = 780;
 
procedure SetColor(Color: TColor);
begin
Canvas.Pen.Color := Color;
Canvas.Brush.Color := Color;
tempColor := Color
end {SetColor};
 
function WL2RGB(const Wavelength: Double): TColor; {$IFDEF VER9UP}inline;{$ENDIF}
const
Gamma = 0.80;
IntensityMax = 255;
var
Red, Blue, Green, Factor: Double;
 
function Adjust(const Color, Factor: Double): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if Color = 0.0 then Result := 0
else Result := Round(IntensityMax * Power(Color * Factor, Gamma))
end {Adjust};
begin
case Trunc(Wavelength) of
380..439:
begin
Red := -(Wavelength - 440) / (440 - 380);
Green := 0.0;
Blue := 1.0
end;
440..489:
begin
Red := 0.0;
Green := (Wavelength - 440) / (490 - 440);
Blue := 1.0
end;
490..509:
begin
Red := 0.0;
Green := 1.0;
Blue := -(Wavelength - 510) / (510 - 490)
end;
510..579:
begin
Red := (Wavelength - 510) / (580 - 510);
Green := 1.0;
Blue := 0.0
end;
580..644:
begin
Red := 1.0;
Green := -(Wavelength - 645) / (645 - 580);
Blue := 0.0
end;
645..780:
begin
Red := 1.0;
Green := 0.0;
Blue := 0.0
end;
else
Red := 0.0;
Green := 0.0;
Blue := 0.0
end;
case Trunc(Wavelength) of
380..419: factor := 0.3 + 0.7 * (Wavelength - 380) / (420 - 380);
420..700: factor := 1.0;
701..780: factor := 0.3 + 0.7 * (780 - Wavelength) / (780 - 700)
else
factor := 0.0
end;
Result := RGB(Adjust(Red, Factor), Adjust(Green, Factor), Adjust(Blue, Factor));
end;
 
function Rainbow(const fraction: Double): TColor; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if (fraction < 0.0) or (fraction > 1.0) then Result := clBlack
else
Result := WL2RGB(WavelengthMinimum + Fraction * (WavelengthMaximum - WavelengthMinimum))
end {Raindbow};
 
function ColorInterpolate(const fraction: Double; const Color1, Color2: TColor): TColor; {$IFDEF VER9UP}inline;{$ENDIF}
var
complement: Double;
R1, R2, G1, G2, B1, B2: BYTE;
begin
if fraction <= 0 then Result := Color1
else
if fraction >= 1.0 then Result := Color2
else
begin
R1 := GetRValue(Color1);
G1 := GetGValue(Color1);
B1 := GetBValue(Color1);
R2 := GetRValue(Color2);
G2 := GetGValue(Color2);
B2 := GetBValue(Color2);
complement := 1.0 - fraction;
Result := RGB(Round(complement * R1 + fraction * R2),
Round(complement * G1 + fraction * G2),
Round(complement * B1 + fraction * B2))
end
end {ColorInterpolate};
 
// Conversion utility routines
function ColorToRGBTriple(const Color: TColor): TRGBTriple; {$IFDEF VER9UP}inline;{$ENDIF}
begin
with Result do
begin
rgbtRed := GetRValue(Color);
rgbtGreen := GetGValue(Color);
rgbtBlue := GetBValue(Color)
end
end {ColorToRGBTriple};
 
function RGBTripleToColor(const Triple: TRGBTriple): TColor; {$IFDEF VER9UP}inline;{$ENDIF}
begin
Result := RGB(Triple.rgbtRed, Triple.rgbtGreen, Triple.rgbtBlue)
end {RGBTripleToColor};
// Bresenham's Line Algorithm. Byte, March 1988, pp. 249-253.
var
a, b, d, diag_inc, dXdg, dXndg, dYdg, dYndg, i, nDginc, nDswap, x, y: Integer;
begin {DrawLine}
x := iStart.X;
y := iStart.Y;
a := iEnd.X - iStart.X;
b := iEnd.Y - iStart.Y;
if a < 0 then
begin
a := -a;
dXdg := -1
end
else dXdg := 1;
if b < 0 then
begin
b := -b;
dYdg := -1
end
else dYdg := 1;
if a < b then
begin
nDswap := a;
a := b;
b := nDswap;
dXndg := 0;
dYndg := dYdg
end
else
begin
dXndg := dXdg;
dYndg := 0
end;
d := b + b - a;
nDginc := b + b;
diag_inc := b + b - a - a;
for i := 0 to a do
begin
case iPixelGeometry of
pgPoint:
case iColorStyle of
csSolid:
Canvas.Pixels[x, y] := tempColor;
csGradient:
Canvas.Pixels[x, y] := ColorInterpolate(i / a, iGradientFrom, iGradientTo);
csRainbow:
Canvas.Pixels[x, y] := Rainbow(i / a)
end;
pgCircular:
begin
case iColorStyle of
csSolid: ;
csGradient: SetColor(ColorInterpolate(i / a, iGradientFrom, iGradientTo));
csRainbow: SetColor(Rainbow(i / a))
end;
Canvas.Ellipse(x - iRadius, y - iRadius, x + iRadius, y + iRadius)
end;
pgRectangular:
begin
case iColorStyle of
csSolid: ;
csGradient: SetColor(ColorInterpolate(i / a, iGradientFrom, iGradientTo));
csRainbow: SetColor(Rainbow(i / a))
end;
Canvas.Rectangle(x - iRadius, y - iRadius, x + iRadius, y + iRadius)
end
end;
if d < 0 then
begin
Inc(x, dXndg);
Inc(y, dYndg);
Inc(d, nDginc);
end
else
begin
Inc(x, dXdg);
Inc(y, dYdg);
Inc(d, diag_inc);
end
end
end {Line};
 
procedure TDIB.DoNovaEffect(const sr, sg, sb, cx, cy, radius,
nspokes, randomhue, randomspok, randgauss: Integer; onProgress: TProgressEvent);
// Copyright (c) 2000 by Keith Murray (kmurray@hotfreeware.com)
// All rights reserved.
// Adapted for DIB by JB.
type
PByteArray = ^TByteArray;
TByteArray = array[0..32767] of Byte;
PDoubleArray = ^TDoubleArray;
TDoubleArray = array[0..0] of Double;
PIntegerArray = ^TIntegerArray;
TIntegerArray = array[0..0] of Integer;
type
TProgressEvent = procedure(progress: Integer; message: string;
var cancel: Boolean) of object;
const
M_PI = 3.14159265358979323846;
RAND_MAX = 2147483647;
 
function Gauss(const randgauss: Integer): double; {$IFDEF VER9UP}inline;{$ENDIF}
const magnitude = 6;
var
sum: double;
i: Integer;
begin
sum := 0;
for i := 1 to magnitude do
sum := sum + (randgauss / 2147483647);
result := sum / magnitude;
end;
 
function Clamp(const i, l, h: double): double; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if i < l then
result := l
else
if i > h then
result := h
else
result := i;
end;
 
function IClamp(const i, l, h: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
begin
if i < l then
result := l
else if i > h then
result := h
else result := i;
end;
{$IFNDEF VER9UP}
procedure rgb_to_hsl(const r, g, b: Double; var h, s, l: Double); {$IFDEF VER9UP}inline;{$ENDIF}
{$IFNDEF VER4UP}
function Max(a, b: Double): Double;
begin
Result := a; if b > a then Result := b;
end;
function Min(a, b: Double): Double;
begin
Result := a; if b < a then Result := b;
end;
{$ENDIF}
var
v, m, vm: Double;
r2, g2, b2: Double;
begin
h := 0;
s := 0;
l := 0;
v := Max(r, g);
v := Max(v, b);
m := Min(r, g);
m := Min(m, b);
l := (m + v) / 2.0;
if l <= 0.0 then
exit;
vm := v - m;
s := vm;
if s > 0.0 then
begin
if l <= 0.5 then
s := s / (v + m)
else s := s / (2.0 - v - m);
end
else exit;
r2 := (v - 4) / vm;
g2 := (v - g) / vm;
b2 := (v - b) / vm;
if r = v then
begin
if g = m then
h := b2 + 5.0
else h := 1.0 - g2;
end
else if g = v then
begin
if b = m then
h := 1.0 + r2
else h := 3.0 - b2;
end
else
begin
if r = m then
h := 3.0 + g2
else h := 5.0 - r2;
end;
h := h / 6;
end;
 
procedure hsl_to_rgb(h, sl, l: Double; var r, g, b: Double); {$IFDEF VER9UP}inline;{$ENDIF}
var
v: Double;
m, sv: Double;
sextant: Integer;
fract, vsf, mid1, mid2: Double;
begin
if l <= 0.5 then
v := l * (1.0 + sl)
else v := l + sl - l * sl;
if v <= 0 then
begin
r := 0.0;
g := 0.0;
b := 0.0;
end
else
begin
m := l + l - v;
sv := (v - m) / v;
h := h * 6.0;
sextant := Trunc(h);
fract := h - sextant;
vsf := v * sv * fract;
mid1 := m + vsf;
mid2 := v - vsf;
case sextant of
0:
begin
r := v; g := mid1; b := m;
end;
1:
begin
r := mid2; g := v; b := m;
end;
2:
begin
r := m; g := v; b := mid1;
end;
3:
begin
r := m; g := mid2; b := v;
end;
4:
begin
r := mid1; g := m; b := v;
end;
5:
begin
r := v; g := m; b := mid2;
end;
end;
end;
end;
{$ELSE}
procedure rgb_to_hsl(const r, g, b: Double; var h, s, l: Double); {$IFDEF VER9UP}inline;{$ENDIF}
var
h0, s0, l0: Word;
begin //procedure ColorRGBToHLS(clrRGB: TColorRef; var Hue, Luminance, Saturation: Word);
GraphUtil.ColorRGBToHLS(RGB(Trunc(r),Trunc(g),Trunc(b)), h0, s0, l0);
h := h0;
s := s0;
l := l0;
end;
 
procedure hsl_to_rgb(h, sl, l: Double; var r, g, b: Double); {$IFDEF VER9UP}inline;{$ENDIF}
var X: TColorRef;
begin //function ColorHLSToRGB(Hue, Luminance, Saturation: Word): TColorRef;
X := GraphUtil.ColorHLSToRGB(Trunc(h), Trunc(l), Trunc(sl));
r := GetRValue(X);
g := GetGValue(X);
b := GetBValue(X);
end;
{$ENDIF}
 
var
src_row, dest_row: PByte;
src, dest: PByteArray;
color, colors: array[0..3] of Integer;
SpokeColor: PIntegerArray;
spoke: PDoubleArray;
x2, row, col, x, y, alpha, has_alpha, bpp, xc, yc, i, j: Integer;
u, v, l, l0, w, w1, c, nova_alpha, new_alpha, compl_ratio, ratio, r, g, b, h, s, lu, SpokeCol: Double;
dstDIB: TDIB;
begin
colors[0] := sr;
colors[1] := sg;
colors[2] := sb;
new_alpha := 0;
 
GetMem(spoke, NSpokes * sizeof(Double));
GetMem(spokecolor, NSpokes * sizeof(Integer) * 3);
dstDIB := TDIB.Create;
try
dstDIB.Assign(Self);
dstDIB.Canvas.Brush.Color := clBlack;
dstDIB.Canvas.FillRect(dstDIB.Canvas.ClipRect);
// R G B
rgb_to_hsl(colors[0] / 255.0, colors[1] / 255.0, colors[2] / 255.0, h, s, lu);
 
for i := 0 to NSpokes - 1 do
begin
spoke[i] := gauss(randgauss);
h := h + randomhue / 360.0 * ({Random(RAND_MAX)}RandomSpok / RAND_MAX - 0.5);
if h < 0 then
h := h + 1.0
else if h > 1.0 then
h := h - 1.0;
hsl_to_rgb(h, s, lu, r, g, b);
spokecolor[3 * i + 0] := Trunc(255 * r);
spokecolor[3 * i + 1] := Trunc(255 * g);
spokecolor[3 * i + 2] := Trunc(255 * b);
end;
 
xc := cx;
yc := cy;
l0 := (x2 - xc) / 4 + 1;
bpp := Self.BitCount div 8;
has_alpha := 0;
alpha := bpp;
y := 0;
for row := 0 to Self.Height - 1 do
begin
src_row := Self.ScanLine[row];
dest_row := dstDIB.ScanLine[row];
src := Pointer(src_row);
dest := Pointer(dest_row);
x := 0;
for col := 0 to Self.Width - 1 do
begin
u := (x - xc) / radius;
v := (y - yc) / radius;
l := sqrt(sqr(u) + sqr(v));
c := (arctan2(u, v) / (2 * M_PI) + 0.51) * NSpokes;
i := floor(c);
c := c - i;
i := i mod NSpokes;
w1 := spoke[i] * (1 - c) + spoke[(i + 1) mod NSpokes] * c;
w1 := w1 * w1;
w := 1 / (l + 0.001) * 0.9;
nova_alpha := Clamp(w, 0.0, 1.0);
ratio := nova_alpha;
compl_ratio := 1.0 - ratio;
for j := 0 to alpha - 1 do
begin
spokecol := spokecolor[3 * i + j] * (1.0 - c) + spokecolor[3 * ((i + 1) mod nspokes) + j] * c;
if w > 1.0 then
color[j] := IClamp(Trunc(spokecol * w), 0, 255)
else
color[j] := Trunc(src[j] * compl_ratio + spokecol * ratio);
color[j] := Trunc(color[j] + 255 * Clamp(w1 * w, 0.0, 1.0));
dest[j] := IClamp(color[j], 0, 255);
end;
{$IFDEF WIN64}
Inc(PByte(src), bpp);
Inc(PBYTE(dest), bpp);
{$ELSE}
Inc(Integer(src), bpp);
Inc(Integer(dest), bpp);
{$ENDIF}
Inc(x);
end;
Inc(y);
end;
Self.Assign(dstDIB);
finally
dstDIB.Free;
FreeMem(Spoke);
FreeMem(SpokeColor);
end;
end;
 
procedure TDIB.DrawMandelbrot(ao, au: Integer; bo, bu: Double);
var
c1, c2, z1, z2, tmp: Double;
i, j, Count: Integer;
dstDIB: TDIB;
X, Y: Double;
X2, Y2: Integer;
begin
dstDIB := TDIB.Create;
dstDIB.Assign(Self);
X2 := dstDIB.FWidth;
Y2 := dstDIB.FHeight;
{as Example
ao := 1;
au := -2;
bo := 1.5;
bu := -1.5;
}
X := (ao - au) / dstDIB.FWidth;
Y := (bo - bu) / dstDIB.FHeight;
try
c2 := bu;
for i := 10 to X2 do
begin
c1 := au;
for j := 0 to Y2 do
begin
z1 := 0;
z2 := 0;
Count := 0;
{count is deep of iteration of the mandelbrot set
if |z| >=2 then z is not a member of a mandelset}
while (((z1 * z1 + z2 * z2 < 4) and (Count <= 90))) do
begin
tmp := z1;
z1 := z1 * z1 - z2 * z2 + c1;
z2 := 2 * tmp * z2 + c2;
Inc(Count);
end;
//the color-palette depends on TColor(n*count mod t)
dstDIB.Canvas.Pixels[j, i] := (16 * Count mod 255);
c1 := c1 + X;
end;
c2 := c2 + Y;
end;
finally
Self.Assign(dstDIB);
dstDIB.Free;
end;
end;
 
procedure TDIB.SephiaEffect(Depth: Integer{$IFDEF VER4UP} = 20{$ENDIF});
{Note: when depth parameter set to 0 will produce black and white picture only}
var
color, color2: LongInt;
r, g, b, rr, gg: byte;
h, w: Integer;
p0: PByteArray;
x, y: Integer;
begin
if Self.BitCount = 24 then
begin
Self.DoGrayScale;
for y := 0 to Self.Height - 1 do
begin
p0 := Self.ScanLine[y];
for x := 0 to Self.Width - 1 do
begin
r := p0[x * 3];
g := p0[x * 3 + 1];
b := p0[x * 3 + 2];
rr := r + (depth * 2);
gg := g + depth;
if rr <= ((depth * 2) - 1) then
rr := 255;
if gg <= (depth - 1) then
gg := 255;
p0[x * 3] := rr;
p0[x * 3 + 1] := gg;
p0[x * 3 + 2] := b;
end;
end;
Exit
end;
{this alogorithm is slower because does not use scanline property}
for h := 0 to Self.Height-1 do
begin
for w := 0 to Self.Width-1 do
begin
//first convert the bitmap to greyscale
color := ColorToRGB(Self.Canvas.Pixels[w, h]);
r := GetRValue(color);
g := GetGValue(color);
b := GetBValue(color);
color2 := (r + g + b) div 3;
Self.Canvas.Pixels[w, h] := RGB(color2, color2, color2);
//then convert it to sepia
color := ColorToRGB(Self.Canvas.Pixels[w, h]);
r := GetRValue(color);
g := GetGValue(color);
b := GetBValue(color);
rr := r + (depth * 2);
gg := g + depth;
if rr <= ((depth * 2) - 1) then
rr := 255;
if gg <= (depth - 1) then
gg := 255;
Self.Canvas.Pixels[w, h] := RGB(rr, gg, b);
end;
end;
 
end;
 
procedure TDIB.EncryptDecrypt(const Key: Integer);
{for decript call it again}
var
BytesPorScan: Integer;
w, h: Integer;
p: pByteArray;
begin
try
BytesPorScan := Abs(Integer(Self.ScanLine[1]) -
Integer(Self.ScanLine[0]));
except
raise Exception.Create('Error ');
end;
RandSeed := Key;
for h := 0 to Self.Height - 1 do
begin
P := Self.ScanLine[h];
for w := 0 to BytesPorScan - 1 do
P^[w] := P^[w] xor Random(256);
end;
end;
 
procedure TDIB.LinePolar(x, y: Integer; AngleInDegree, Length: extended; Color: cardinal);
var
xp, yp: Integer;
begin
xp := Round(Sin(AngleInDegree * Pi / 180) * Length) + x;
yp := Round(Cos(AngleInDegree * Pi / 180) * Length) + y;
AntialiasedLine(x, y, xp, yp, Color);
end;
 
//y = 0.299*g + 0.587*b + 0.114*r;
 
procedure TDIB.BlendPixel(const X, Y: Integer; aColor: Cardinal; Alpha: byte);
var
cR, cG, cB: byte;
aR, aG, aB: byte;
dColor: Cardinal;
begin
aR := GetRValue(aColor);
aG := GetGValue(aColor);
aB := GetBValue(aColor);
dColor := Self.Canvas.Pixels[x, y];
cR := GetRValue(dColor);
cG := GetGValue(dColor);
cB := GetBValue(dColor);
Canvas.Pixels[x, y] := RGB((Alpha * (aR - cR) shr 8) + cR, // R alpha
(Alpha * (aG - cG) shr 8) + cG, // G alpha
(Alpha * (aB - cB) shr 8) + cB); // B alpha
end;
 
 
procedure MakeDib(out DIB: TDIB; const iWidth, iHeight, iBitCount: Integer; iFillColor: TColor{$IFDEF VER4UP} = clBlack{$ENDIF}); {$IFDEF VER4UP} overload; {$ENDIF}
begin
DIB := TDIB.Create;
DIB.SetSize(iWidth, iHeight, iBitCount);
DIB.Fill(iFillColor);
end;
 
procedure{$IFDEF VER4UP}MakeDib{$ELSE}MakeDib2{$ENDIF}(out DIB: TDIB; iBitmap: TBitmap); {$IFDEF VER4UP} overload; {$ENDIF}
begin
DIB := TDIB.Create;
if Assigned(iBitmap) then
DIB.CreateDIBFromBitmap(iBitmap)
else
DIB.Fill(clBlack);
end;
 
initialization
TPicture.RegisterClipBoardFormat(CF_DIB, TDIB);
TPicture.RegisterFileFormat('dib', 'Device Independent Bitmap', TDIB);
/VCL_DELPHIX_D6/DXInptEdit.dfm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/VCL_DELPHIX_D6/DXClass.pas
5,15 → 5,7
{$INCLUDE DelphiXcfg.inc}
 
uses
Windows, Messages, SysUtils, Classes, Controls, Forms, MMSystem, Graphics, {$IFDEF _DMO_}MultiMon,{$ENDIF}
{$IfDef StandardDX}
{$IfDef DX9}
Direct3D, DirectInput,
{$EndIf}
DirectDraw, DirectSound;
{$Else}
DirectX;
{$EndIf}
Windows, Messages, SysUtils, Classes, Controls, Forms, MMSystem, DirectX;
 
type
 
58,46 → 50,6
property Drivers[Index: Integer]: TDirectXDriver read GetDriver; default;
end;
 
{$IFDEF _DMO_}
{ TDirectXDriverEx }
 
TDirectXDriverEx = class(TCollectionItem)
private
FGUID: PGUID;
FGUID2: TGUID;
FDescription: string;
FDriverName: string;
FMonitor: HMonitor;
FMonitorInfo: TMonitorInfo;
procedure SetGUID(Value: PGUID);
function ConvertHMonitor(iMonitor: HMonitor): TMonitorInfo;
function GetMonitorInfo: TMonitorInfo;
function GetFlags: DWORD;
function GetTempSpace: TRect;
function GetWorkSpace: TRect;
public
property GUID: PGUID read FGUID write SetGUID;
property Monitor: HMonitor read FMonitor write FMonitor;
property MonitorInfo: TMonitorInfo read GetMonitorInfo;
published
property Description: string read FDescription write FDescription;
property DriverName: string read FDriverName write FDriverName;
property WorkSpace: TRect read GetWorkSpace;
property TempSpace: TRect read GetTempSpace;
property Flags: DWORD read GetFlags;
end;
 
{ TDirectXDriversEx }
 
TDirectXDriversEx = class(TCollection)
private
function GetDriver(Index: Integer): TDirectXDriverEx;
public
constructor Create;
property Drivers[Index: Integer]: TDirectXDriverEx read GetDriver; default;
end;
{$ENDIF}
{ TDXForm }
 
TDXForm = class(TForm)
218,137 → 170,20
function IndexOf(const Name: string): Integer;
end;
 
{Addapted from RXLib.PicClip}
function Max(Val1, Val2: Integer): Integer;
function Min(Val1, Val2: Integer): Integer;
 
{ TPicClip }
TCellRange = 1..MaxInt;
 
TDXPictureClip = class(TComponent)
private
FPicture: TPicture;
FRows: TCellRange;
FCols: TCellRange;
FBitmap: TBitmap;
FMasked: Boolean;
FMaskColor: TColor;
FOnChange: TNotifyEvent;
procedure CheckIndex(Index: Integer);
function GetCell(Col, Row: Cardinal): TBitmap;
function GetGraphicCell(Index: Integer): TBitmap;
function GetDefaultMaskColor: TColor;
function GetIsEmpty: Boolean;
function GetCount: Integer;
function GetHeight: Integer;
function GetWidth: Integer;
function IsMaskStored: Boolean;
procedure PictureChanged(Sender: TObject);
procedure SetHeight(Value: Integer);
procedure SetPicture(Value: TPicture);
procedure SetWidth(Value: Integer);
procedure SetMaskColor(Value: TColor);
protected
procedure AssignTo(Dest: TPersistent); override;
procedure Changed; dynamic;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function GetIndex(Col, Row: Cardinal): Integer;
procedure Draw(Canvas: TCanvas; X, Y, Index: Integer);
procedure DrawCenter(Canvas: TCanvas; Rect: TRect; Index: Integer);
property Cells[Col, Row: Cardinal]: TBitmap read GetCell;
property GraphicCell[Index: Integer]: TBitmap read GetGraphicCell;
property IsEmpty: Boolean read GetIsEmpty;
property Count: Integer read GetCount;
published
property Cols: TCellRange read FCols write FCols default 1;
property Height: Integer read GetHeight write SetHeight stored False;
property Masked: Boolean read FMasked write FMasked default True;
property Rows: TCellRange read FRows write FRows default 1;
property Picture: TPicture read FPicture write SetPicture;
property MaskColor: TColor read FMaskColor write SetMaskColor stored IsMaskStored;
property Width: Integer read GetWidth write SetWidth stored False;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
 
function Max(Val1, Val2: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
function Min(Val1, Val2: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
 
function Cos256(i: Integer): Double;
function Sin256(i: Integer): Double;
 
function PointInRect(const Point: TPoint; const Rect: TRect): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function RectInRect(const Rect1, Rect2: TRect): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function OverlapRect(const Rect1, Rect2: TRect): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function PointInRect(const Point: TPoint; const Rect: TRect): Boolean;
function RectInRect(const Rect1, Rect2: TRect): Boolean;
function OverlapRect(const Rect1, Rect2: TRect): Boolean;
 
function WideRect(ALeft, ATop, AWidth, AHeight: Integer): TRect; {$IFDEF VER9UP}inline;{$ENDIF}
 
{ Transformations routines}
 
const
L_Curve = 0;//The left curve
R_Curve = 1;//The right curve
 
C_Add = 0;//Increase (BTC)
C_Dec = 1;//Decrease (ETC)
 
Type
TDblPoint = packed record
X, Y: Double;
end;
TSngPoint = packed record //SinglePoint
X, Y: Single;
end;
 
 
//Transformation matrix
T2DRowCol = Array[1..3] of Array[1..3] of Double;
T2DVector = Array[1..3] of Double;
//Distance between 2 points
function Get2PointRange(a,b: TDblPoint):Double;
//From vector angular calculation
function Get256(dX,dY: Double):Double;
//The angular calculation of the A from B
function GetARadFromB(A,B: TDblPoint):Double;
 
//It calculates the TDblPoint
function DblPoint(a,b:Double):TDblPoint;
//It converts the TDboPoint to the TPoint
function TruncDblPoint(DblPos: TDblPoint): TPoint;
 
function GetPointFromRangeAndAngle(SP: TDblPoint; Range,Angle: Double): TDblPoint;
 
function Ini2DRowCol: T2DRowCol;
function Trans2DRowCol(x,y:double):T2DRowCol;
function Scale2DRowCol(x,y:double):T2DRowCol;
function Rotate2DRowCol(Theta:double):T2DRowCol;
function RotateIntoX2DRowCol(x,y: double):T2DRowCol;
function Multiply2DRowCol(A,B:T2DRowCol):T2DRowCol;
function ScaleAt2DRowCol(x,y,Sx,Sy:double):T2DRowCol;
function ReflectAcross2DRowCol(x,y,dx,dy:Double): T2DRowCol;
function Apply2DVector(V:T2DVector; M:T2DRowCol): T2DVector;
function RotateAround2DRowCol(x,y,Theta:Double): T2DRowCol;
 
//Collision decision
function PointInCircle(PPos,CPos: TPoint; R: integer): Boolean;
function CircleInCircle(C1Pos,C2Pos: TPoint; R1,R2:Integer): Boolean;
function SegmentInCircle(SPos,EPos,CPos: TPoint; R: Integer): Boolean;
 
//If A is closer than B from starting point S, the True is returned.
function CheckNearAThanB(S,A,B: TDblPoint): Boolean;
 
//The Angle of 256 period is returned
function Angle256(Angle: Single): Single;
 
{ Support functions }
 
function WideRect(ALeft, ATop, AWidth, AHeight: Integer): TRect;
procedure ReleaseCom(out Com);
function DXLoadLibrary(const FileName, FuncName: string): TFarProc;
 
{ Simple helper }
 
procedure Log(const Co: string; const FName: string{$IFDEF VER4UP} = 'c:\logerr.txt'{$ENDIF});
 
implementation
 
uses DXConsts;
855,763 → 690,8
Result := -1;
end;
 
{ TDXPictureClip }
 
constructor TDXPictureClip.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FPicture := TPicture.Create;
FPicture.OnChange := PictureChanged;
FBitmap := TBitmap.Create;
FRows := 1;
FCols := 1;
FMaskColor := GetDefaultMaskColor;
FMasked := True;
end;
 
destructor TDXPictureClip.Destroy;
begin
FOnChange := nil;
FPicture.OnChange := nil;
FBitmap.Free;
FPicture.Free;
inherited Destroy;
end;
 
procedure TDXPictureClip.Assign(Source: TPersistent);
begin
if Source is TDXPictureClip then begin
with TDXPictureClip(Source) do begin
Self.FRows := Rows;
Self.FCols := Cols;
Self.FMasked := Masked;
Self.FMaskColor := MaskColor;
Self.FPicture.Assign(FPicture);
end;
end
else if (Source is TPicture) or (Source is TGraphic) then
FPicture.Assign(Source)
else inherited Assign(Source);
end;
 
type
THack = class(TImageList);
 
procedure TDXPictureClip.AssignTo(Dest: TPersistent);
var
I: Integer;
SaveChange: TNotifyEvent;
begin
if (Dest is TPicture) then Dest.Assign(FPicture)
else if (Dest is TImageList) and not IsEmpty then begin
with TImageList(Dest) do begin
SaveChange := OnChange;
try
OnChange := nil;
Clear;
Width := Self.Width;
Height := Self.Height;
for I := 0 to Self.Count - 1 do begin
if Self.Masked and (MaskColor <> clNone) then
TImageList(Dest).AddMasked(GraphicCell[I], MaskColor)
else TImageList(Dest).Add(GraphicCell[I], nil);
end;
Masked := Self.Masked;
finally
OnChange := SaveChange;
end;
THack(Dest).Change;
end;
end
else inherited AssignTo(Dest);
end;
 
procedure TDXPictureClip.Changed;
begin
if Assigned(FOnChange) then FOnChange(Self);
end;
 
function TDXPictureClip.GetIsEmpty: Boolean;
begin
Result := not Assigned(Picture) or Picture.Graphic.Empty;
end;
 
function TDXPictureClip.GetCount: Integer;
begin
if IsEmpty then Result := 0
else Result := Cols * Rows;
end;
const
{ TBitmap.GetTransparentColor from GRAPHICS.PAS uses this value }
PaletteMask = $02000000;
 
procedure TDXPictureClip.Draw(Canvas: TCanvas; X, Y, Index: Integer);
 
function PaletteColor(Color: TColor): Longint;
begin
Result := ColorToRGB(Color) or PaletteMask;
end;
procedure StretchBltTransparent(DstDC: HDC; DstX, DstY, DstW, DstH: Integer;
SrcDC: HDC; SrcX, SrcY, SrcW, SrcH: Integer; Palette: HPalette;
TransparentColor: TColorRef);
var
Color: TColorRef;
bmAndBack, bmAndObject, bmAndMem, bmSave: HBitmap;
bmBackOld, bmObjectOld, bmMemOld, bmSaveOld: HBitmap;
MemDC, BackDC, ObjectDC, SaveDC: HDC;
palDst, palMem, palSave, palObj: HPalette;
begin
{ Create some DCs to hold temporary data }
BackDC := CreateCompatibleDC(DstDC);
ObjectDC := CreateCompatibleDC(DstDC);
MemDC := CreateCompatibleDC(DstDC);
SaveDC := CreateCompatibleDC(DstDC);
{ Create a bitmap for each DC }
bmAndObject := CreateBitmap(SrcW, SrcH, 1, 1, nil);
bmAndBack := CreateBitmap(SrcW, SrcH, 1, 1, nil);
bmAndMem := CreateCompatibleBitmap(DstDC, DstW, DstH);
bmSave := CreateCompatibleBitmap(DstDC, SrcW, SrcH);
{ Each DC must select a bitmap object to store pixel data }
bmBackOld := SelectObject(BackDC, bmAndBack);
bmObjectOld := SelectObject(ObjectDC, bmAndObject);
bmMemOld := SelectObject(MemDC, bmAndMem);
bmSaveOld := SelectObject(SaveDC, bmSave);
{ Select palette }
palDst := 0; palMem := 0; palSave := 0; palObj := 0;
if Palette <> 0 then begin
palDst := SelectPalette(DstDC, Palette, True);
RealizePalette(DstDC);
palSave := SelectPalette(SaveDC, Palette, False);
RealizePalette(SaveDC);
palObj := SelectPalette(ObjectDC, Palette, False);
RealizePalette(ObjectDC);
palMem := SelectPalette(MemDC, Palette, True);
RealizePalette(MemDC);
end;
{ Set proper mapping mode }
SetMapMode(SrcDC, GetMapMode(DstDC));
SetMapMode(SaveDC, GetMapMode(DstDC));
{ Save the bitmap sent here }
BitBlt(SaveDC, 0, 0, SrcW, SrcH, SrcDC, SrcX, SrcY, SRCCOPY);
{ Set the background color of the source DC to the color, }
{ contained in the parts of the bitmap that should be transparent }
Color := SetBkColor(SaveDC, PaletteColor(TransparentColor));
{ Create the object mask for the bitmap by performing a BitBlt() }
{ from the source bitmap to a monochrome bitmap }
BitBlt(ObjectDC, 0, 0, SrcW, SrcH, SaveDC, 0, 0, SRCCOPY);
{ Set the background color of the source DC back to the original }
SetBkColor(SaveDC, Color);
{ Create the inverse of the object mask }
BitBlt(BackDC, 0, 0, SrcW, SrcH, ObjectDC, 0, 0, NOTSRCCOPY);
{ Copy the background of the main DC to the destination }
BitBlt(MemDC, 0, 0, DstW, DstH, DstDC, DstX, DstY, SRCCOPY);
{ Mask out the places where the bitmap will be placed }
StretchBlt(MemDC, 0, 0, DstW, DstH, ObjectDC, 0, 0, SrcW, SrcH, SRCAND);
{ Mask out the transparent colored pixels on the bitmap }
BitBlt(SaveDC, 0, 0, SrcW, SrcH, BackDC, 0, 0, SRCAND);
{ XOR the bitmap with the background on the destination DC }
StretchBlt(MemDC, 0, 0, DstW, DstH, SaveDC, 0, 0, SrcW, SrcH, SRCPAINT);
{ Copy the destination to the screen }
BitBlt(DstDC, DstX, DstY, DstW, DstH, MemDC, 0, 0,
SRCCOPY);
{ Restore palette }
if Palette <> 0 then begin
SelectPalette(MemDC, palMem, False);
SelectPalette(ObjectDC, palObj, False);
SelectPalette(SaveDC, palSave, False);
SelectPalette(DstDC, palDst, True);
end;
{ Delete the memory bitmaps }
DeleteObject(SelectObject(BackDC, bmBackOld));
DeleteObject(SelectObject(ObjectDC, bmObjectOld));
DeleteObject(SelectObject(MemDC, bmMemOld));
DeleteObject(SelectObject(SaveDC, bmSaveOld));
{ Delete the memory DCs }
DeleteDC(MemDC);
DeleteDC(BackDC);
DeleteDC(ObjectDC);
DeleteDC(SaveDC);
end;
procedure StretchBitmapTransparent(Dest: TCanvas; Bitmap: TBitmap;
TransparentColor: TColor; DstX, DstY, DstW, DstH, SrcX, SrcY,
SrcW, SrcH: Integer);
var
CanvasChanging: TNotifyEvent;
begin
if DstW <= 0 then DstW := Bitmap.Width;
if DstH <= 0 then DstH := Bitmap.Height;
if (SrcW <= 0) or (SrcH <= 0) then begin
SrcX := 0; SrcY := 0;
SrcW := Bitmap.Width;
SrcH := Bitmap.Height;
end;
if not Bitmap.Monochrome then
SetStretchBltMode(Dest.Handle, STRETCH_DELETESCANS);
CanvasChanging := Bitmap.Canvas.OnChanging;
Bitmap.Canvas.Lock;
try
Bitmap.Canvas.OnChanging := nil;
if TransparentColor = clNone then begin
StretchBlt(Dest.Handle, DstX, DstY, DstW, DstH, Bitmap.Canvas.Handle,
SrcX, SrcY, SrcW, SrcH, Dest.CopyMode);
end
else begin
if TransparentColor = clDefault then
TransparentColor := Bitmap.Canvas.Pixels[0, Bitmap.Height - 1];
if Bitmap.Monochrome then TransparentColor := clWhite
else TransparentColor := ColorToRGB(TransparentColor);
StretchBltTransparent(Dest.Handle, DstX, DstY, DstW, DstH,
Bitmap.Canvas.Handle, SrcX, SrcY, SrcW, SrcH, Bitmap.Palette,
TransparentColor);
end;
finally
Bitmap.Canvas.OnChanging := CanvasChanging;
Bitmap.Canvas.Unlock;
end;
end;
procedure DrawBitmapTransparent(Dest: TCanvas; DstX, DstY: Integer;
Bitmap: TBitmap; TransparentColor: TColor);
begin
StretchBitmapTransparent(Dest, Bitmap, TransparentColor, DstX, DstY,
Bitmap.Width, Bitmap.Height, 0, 0, Bitmap.Width, Bitmap.Height);
end;
var
Image: TGraphic;
begin
if Index < 0 then Image := Picture.Graphic
else Image := GraphicCell[Index];
if (Image <> nil) and not Image.Empty then begin
if FMasked and (FMaskColor <> clNone) and
(Picture.Graphic is TBitmap) then
DrawBitmapTransparent(Canvas, X, Y, TBitmap(Image), FMaskColor)
else Canvas.Draw(X, Y, Image);
end;
end;
 
procedure TDXPictureClip.DrawCenter(Canvas: TCanvas; Rect: TRect; Index: Integer);
var
X, Y: Integer;
begin
X := (Rect.Left + Rect.Right - Width) div 2;
Y := (Rect.Bottom + Rect.Top - Height) div 2;
Draw(Canvas, X, Y, Index);
end;
 
procedure TDXPictureClip.CheckIndex(Index: Integer);
begin
if (Index >= Cols * Rows) or (Index < 0) then
raise EListError.CreateFmt('%s (%d)', ['Load list error', Index]);
end;
 
function TDXPictureClip.GetIndex(Col, Row: Cardinal): Integer;
begin
Result := Col + (Row * Cols);
if (Result >= Cols * Rows) or IsEmpty then Result := -1;
end;
 
function TDXPictureClip.GetCell(Col, Row: Cardinal): TBitmap;
begin
Result := GetGraphicCell(GetIndex(Col, Row));
end;
 
function TDXPictureClip.GetGraphicCell(Index: Integer): TBitmap;
procedure AssignBitmapCell(Source: TGraphic; Dest: TBitmap; Cols, Rows,
Index: Integer);
var
CellWidth, CellHeight: Integer;
begin
if (Source <> nil) and (Dest <> nil) then begin
if Cols <= 0 then Cols := 1;
if Rows <= 0 then Rows := 1;
if Index < 0 then Index := 0;
CellWidth := Source.Width div Cols;
CellHeight := Source.Height div Rows;
with Dest do begin
Width := CellWidth; Height := CellHeight;
end;
if Source is TBitmap then begin
Dest.Canvas.CopyRect(Bounds(0, 0, CellWidth, CellHeight),
TBitmap(Source).Canvas, Bounds((Index mod Cols) * CellWidth,
(Index div Cols) * CellHeight, CellWidth, CellHeight));
Dest.TransparentColor := TBitmap(Source).TransparentColor;
end
else begin
Dest.Canvas.Brush.Color := clSilver;
Dest.Canvas.FillRect(Bounds(0, 0, CellWidth, CellHeight));
Dest.Canvas.Draw(-(Index mod Cols) * CellWidth,
-(Index div Cols) * CellHeight, Source);
end;
Dest.Transparent := Source.Transparent;
end;
end;
begin
CheckIndex(Index);
AssignBitmapCell(Picture.Graphic, FBitmap, Cols, Rows, Index);
if Picture.Graphic is TBitmap then
if FBitmap.PixelFormat <> pfDevice then
FBitmap.PixelFormat := TBitmap(Picture.Graphic).PixelFormat;
FBitmap.TransparentColor := FMaskColor or PaletteMask;
FBitmap.Transparent := (FMaskColor <> clNone) and Masked;
Result := FBitmap;
end;
 
function TDXPictureClip.GetDefaultMaskColor: TColor;
begin
Result := clOlive;
if (Picture.Graphic <> nil) and (Picture.Graphic is TBitmap) then
Result := TBitmap(Picture.Graphic).TransparentColor and
not PaletteMask;
end;
 
function TDXPictureClip.GetHeight: Integer;
begin
Result := Picture.Height div FRows;
end;
 
function TDXPictureClip.GetWidth: Integer;
begin
Result := Picture.Width div FCols;
end;
 
function TDXPictureClip.IsMaskStored: Boolean;
begin
Result := MaskColor <> GetDefaultMaskColor;
end;
 
procedure TDXPictureClip.SetMaskColor(Value: TColor);
begin
if Value <> FMaskColor then begin
FMaskColor := Value;
Changed;
end;
end;
 
procedure TDXPictureClip.PictureChanged(Sender: TObject);
begin
FMaskColor := GetDefaultMaskColor;
if not (csReading in ComponentState) then Changed;
end;
 
procedure TDXPictureClip.SetHeight(Value: Integer);
begin
if (Value > 0) and (Picture.Height div Value > 0) then
Rows := Picture.Height div Value;
end;
 
procedure TDXPictureClip.SetWidth(Value: Integer);
begin
if (Value > 0) and (Picture.Width div Value > 0) then
Cols := Picture.Width div Value;
end;
 
procedure TDXPictureClip.SetPicture(Value: TPicture);
begin
FPicture.Assign(Value);
end;
 
{ Transformations routines }
{ Authorisation: Mr. Takanori Kawasaki}
 
//Distance between 2 points is calculated
function Get2PointRange(a,b: TDblPoint):Double;
var
x,y: Double;
begin
x := a.X - b.X;
y := a.Y - b.Y;
Result := Sqrt(x*x+y*y);
end;
 
//Direction angle in the coordinate A which was seen from coordinate B is calculated
function GetARadFromB(A,B: TDblPoint):Double;
var
dX,dY: Double;
begin
dX := A.X - B.X;
dY := A.Y - B.Y;
Result := Get256(dX,dY);
end;
 
//Direction angle is returned with 0 - 255.
function Get256(dX,dY:Double):Double;
begin
Result := 0;
if dX > 0 then
begin//0-63
if dY > 0 then Result := ArcTan(dY / dX) // 0 < Res < 90
else//0
if dY = 0 then Result := 0 // 0
else//192-255
if dY < 0 then Result := 2*Pi + ArcTan(dY / dX) // 270 < Res < 360
end else
if dX = 0 then
begin//64
if dY > 0 then Result := 1 / 2 * Pi // 90
else//0
if dY = 0 then Result := 0 // 0
else//192
if dY < 0 then Result := 3 / 2 * Pi // 270
end else
if dX < 0 then
begin//64-127
if dY > 0 then Result := Pi + ArcTan(dY / dX) // 90 < Res < 180
else//128
if dY = 0 then Result := Pi // 180
else//128-191
if dY < 0 then Result := Pi + ArcTan(dY / dX) // 180 < Res < 270
end;
Result := 256 * Result / (2*Pi);
end;
 
//From the coordinate SP the Range it calculates the point which leaves with the angular Angle
function GetPointFromRangeAndAngle(SP: TDblPoint; Range,Angle: Double): TDblPoint;
begin
Result.X := SP.X + Range * Cos(Angle);
Result.Y := SP.Y + Range * Sin(Angle);
end;
 
//* As for coordinate transformation coordinate for mathematics is used
//Identity matrix for the 2d is returned.
function Ini2DRowCol: T2DRowCol;
var
i,ii:integer;
begin
for i := 1 to 3 do
for ii := 1 to 3 do
if i = ii then Result[i,ii] := 1 else Result[i,ii] := 0;
end;
 
//Transformation matrix of the portable quantity
//where the one for 2d is appointed is returned.
function Trans2DRowCol(x,y:double):T2DRowCol;
begin
Result := Ini2DRowCol;
Result[3,1] := x;
Result[3,2] := y;
end;
 
//Conversion coordinate of the expansion and contraction
//quantity where the one for 2d is appointed is returned.
function Scale2DRowCol(x,y:double):T2DRowCol;
begin
Result := Ini2DRowCol;
Result[1,1] := x;
Result[2,2] := y;
end;
 
//Coordinate transformation of the rotary quantity
//where the one for 2d is appointed is returned.
function Rotate2DRowCol(Theta:double):T2DRowCol;
begin
Result := Ini2DRowCol;
Result[1,1] := Cos256(Trunc(Theta));
Result[1,2] := Sin256(Trunc(Theta));
Result[2,1] := -1 * Result[1,2];
Result[2,2] := Result[1,1];
end;
 
//You apply two conversion coordinates and adjust.
function Multiply2DRowCol(A,B:T2DRowCol):T2DRowCol;
begin
Result[1,1] := A[1,1] * B[1,1] + A[1,2] * B[2,1];
Result[1,2] := A[1,1] * B[1,2] + A[1,2] * B[2,2];
Result[1,3] := 0;
Result[2,1] := A[2,1] * B[1,1] + A[2,2] * B[2,1];
Result[2,2] := A[2,1] * B[1,2] + A[2,2] * B[2,2];
Result[2,3] := 0;
Result[3,1] := A[3,1] * B[1,1] + A[3,2] * B[2,1] + B[3,1];
Result[3,2] := A[3,1] * B[1,2] + A[3,2] * B[2,2] + B[3,2];
Result[3,3] := 1;
end;
 
//Until coordinate (the X and the Y) comes on the X axis,
//the conversion coordinate which turns the position
//of the point is returned.
function RotateIntoX2DRowCol(x,y: double):T2DRowCol;
var
d: double;
begin
Result := Ini2DRowCol;
d := sqrt(x*x+y*y);
Result[1,1] := x / d;
Result[1,2] := y / d;
Result[2,1] := -1 * Result[1,2];
Result[2,2] := Result[1,1];
end;
 
//Coordinate (the X and the Y) as a center, the conversion
//coordinate which does the scaling of the magnification ratio
//which is appointed with the Sx and the Sy is returned.
function ScaleAt2DRowCol(x,y,Sx,Sy:double):T2DRowCol;
var
T,S,TInv,M:T2DRowCol;
begin
T := Trans2DRowCol(-x,-y);
TInv := Trans2DRowCol(x,y);
S := Scale2DRowCol(Sx,Sy);
M := Multiply2DRowCol(T,S);
Result := Multiply2DRowCol(M,T);
end;
 
//Coordinate (the X and the Y) it passes, comes hard and
//(DX and the dy) with the direction which is shown it
//returns the transformation matrix which does the reflected
//image conversion which centers the line which faces.
function ReflectAcross2DRowCol(x,y,dx,dy:Double): T2DRowCol;
var
T,R,S,RInv,TInv,M1,M2,M3: T2DRowCol;
begin
T := Trans2DRowCol(-x,-y);
TInv := Trans2DRowCol(x,y);
R := RotateIntoX2DRowCol(dx,dy);
RInv := RotateIntoX2DRowCol(dx,-dy);
S := Scale2DRowCol(1,-1);
M1 := Multiply2DRowCol(T,R);
M2 := Multiply2DRowCol(S,RInv);
M3 := Multiply2DRowCol(M1,M2);
Result := Multiply2DRowCol(M3,TInv);
end;
 
//Coordinate focusing on (the X and the Y) the transformation
//matrix which turns the position of the point with angle Theta is returned.
function RotateAround2DRowCol(x,y,Theta:Double): T2DRowCol;
var
T,R,TInv,M: T2DRowCol;
begin
T := Trans2DRowCol(-x,-y);
TInv := Trans2DRowCol(x,y);
R := Rotate2DRowCol(Theta);
M := Multiply2DRowCol(T,R);
Result := Multiply2DRowCol(M,TInv);
end;
 
//Transformation matrix is applied to the point.
function Apply2DVector(V:T2DVector; M:T2DRowCol): T2DVector;
begin
Result[1] := V[1] * M[1,1] + V[2] * M[2,1] + M[3,1];
Result[2] := V[1] * M[1,2] + V[2] * M[2,2] + M[3,2];
Result[3] := 1;
end;
 
//The TDblPoint is returned
function DblPoint(a,b:Double):TDblPoint;
begin
Result.X := a;
Result.Y := b;
end;
 
function TruncDblPoint(DblPos: TDblPoint): TPoint;
begin
Result.X := Trunc(DblPos.X);
Result.Y := Trunc(DblPos.Y);
end;
{
+-----------------------------------------------------------------------------+
|Collision decision |
+-----------------------------------------------------------------------------+}
 
//Point and circle
function PointInCircle(PPos,CPos: TPoint; R: integer): Boolean;
begin
Result := (PPos.X - CPos.X)*(PPos.X - CPos.X)+(PPos.Y - CPos.Y)*(PPos.Y - CPos.Y)<= R*R;
end;
 
//Circle and circle
function CircleInCircle(C1Pos,C2Pos: TPoint; R1,R2:Integer): Boolean;
begin
Result := (C1Pos.X - C2Pos.X)*(C1Pos.X - C2Pos.X)+(C1Pos.Y - C2Pos.Y)*(C1Pos.Y - C2Pos.Y) <= (R1+R2)*(R1+R2);
end;
 
//Circle and line segment
function SegmentInCircle(SPos,EPos,CPos: TPoint; R: Integer): Boolean;
var
V,C: TPoint;
VC,VV,CC:integer;
begin
Result := False;
V.X := EPos.X - SPos.X; V.Y := EPos.Y - SPos.Y;
C.X := CPos.X - SPos.X; C.Y := CPos.Y - SPos.Y;
VC := V.X * C.X + V.Y * C.Y;
if VC < 0 then
begin
Result := (C.X * C.X + C.Y * C.Y) <= R*R;
end
else
begin
VV := V.X * V.X + V.Y * V.Y;
if VC >= VV then
begin
Result := (EPos.X - CPos.X)*(EPos.X - CPos.X)+(EPos.Y - CPos.Y)*(EPos.Y - CPos.Y) <= R * R;
end
else
if VC < VV then
begin
CC := C.X * C.X + C.Y * C.Y;
Result := CC - (VC div VV)* VC <= R*R;
end;
end;
end;
 
//Angle recalc
function Angle256(Angle: Single): Single;
begin
Result := Angle;
While Result < 0 do Result := Result + 256;
While Result >= 256 do Result := Result -256;
end;
 
//If A is closer than B from starting point S, the True is returned.
function CheckNearAThanB(S,A,B: TDblPoint): Boolean;
begin
Result := (S.X-A.X)*(S.X-A.X)+(S.Y-A.Y)*(S.Y-A.Y) <= (S.X-B.X)*(S.X-B.X)+(S.Y-B.Y)*(S.Y-B.Y);
end;
 
function CircumCenter3Pt(const x1, y1, x2, y2, x3, y3: Single; out Px, Py: Single): Boolean;
var
A,B,C,D,E,F,G: Single;
begin
A := x2 - x1;
B := y2 - y1;
C := x3 - x1;
D := y3 - y1;
E := A * (x1 + x2) + B * (y1 + y2);
F := C * (x1 + x3) + D * (y1 + y3);
G := 2.0 * (A * (y3 - y2) - B * (x3 - x2));
Result := G <> 0.0;
if Result then begin
Px := (D * E - B * F) / G;
Py := (A * F - C * E) / G;
end;
end;
 
function Distance(const x1, y1, x2, y2: Double): Double;
begin
Result := Sqrt(Sqr(y2 - y1) + Sqr(x2 - x1));
end;
 
procedure InCenter(const x1, y1, x2, y2, x3, y3: Double; out Px, Py: Double);
var
Perim: Double;
Side12: Double;
Side23: Double;
Side31: Double;
begin
Side12 := Distance(x1, y1, x2, y2);
Side23 := Distance(x2, y2, x3, y3);
Side31 := Distance(x3, y3, x1, y1);
{ Using Heron's S=UR }
Perim := 1.0 / (Side12 + Side23 + Side31);
Px := (Side23 * x1 + Side31 * x2 + Side12 * x3) * Perim;
Py := (Side23 * y1 + Side31 * y2 + Side12 * y3) * Perim;
end;
 
function PointInTriangle(const Px, Py, x1, y1, x2, y2, x3, y3: Double): Boolean;
function Orientation(const x1, y1, x2, y2, Px, Py: Double): Integer;
var
Orin: Double;
begin
(* Linear determinant of the 3 points *)
Orin := (x2 - x1) * (py - y1) - (px - x1) * (y2 - y1);
 
if Orin > 0.0 then
Result := +1 (* Orientaion is to the right-hand side *)
else if Orin < 0.0 then
Result := -1 (* Orientaion is to the left-hand side *)
else
Result := 0; (* Orientaion is neutral aka collinear *)
end;
var
Or1, Or2, Or3: Integer;
begin
Or1 := Orientation(x1, y1, x2, y2, Px, Py);
Or2 := Orientation(x2, y2, x3, y3, Px, Py);
Or3 := Orientation(x3, y3, x1, y1, Px, Py);
 
if (Or1 = Or2) and (Or2 = Or3) then
Result := True
else if Or1 = 0 then
Result := (Or2 = 0) or (Or3 = 0)
else if Or2 = 0 then
Result := (Or1 = 0) or (Or3 = 0)
else if Or3 = 0 then
Result := (Or2 = 0) or (Or1 = 0)
else
Result := False;
end;
 
procedure Log(const Co: string; const FName: string);
var F: Text; D: TDateTime;
Hour, Minute, Second, MSec: Word;
begin
AsSignFile(F, FName);
if FileExists(FName) then Append(F)
else ReWrite(F);
try
D := Now;
DecodeTime(D, Hour, Minute, Second, MSec);
WriteLn(F, DateToStr(D) + ' ' + IntToStr(Hour)+':'+IntToStr(Minute)+':'+IntToStr(Second)+ '.'+IntToStr(MSec) +' ' + Co);
finally
CloseFile(F);
end;
end;
 
{$IFDEF _DMO_}
 
{ TDirectXDriverEx }
 
function TDirectXDriverEx.ConvertHMonitor(iMonitor: HMonitor): TMonitorInfo;
begin
ZeroMemory(@Result, sizeof(Result));
Result.cbSize := SizeOf(Result);
MultiMon.GetMonitorInfo(iMonitor, @Result);
end;
 
function TDirectXDriverEx.GetFlags: DWORD;
begin
Result := ConvertHMonitor(FMonitor).dwFlags;
end;
 
function TDirectXDriverEx.GetMonitorInfo: TMonitorInfo;
begin
Result:= ConvertHMonitor(FMonitor);
end;
 
function TDirectXDriverEx.GetTempSpace: TRect;
begin
Result := ConvertHMonitor(FMonitor).rcWork
end;
 
function TDirectXDriverEx.GetWorkSpace: TRect;
begin
Result := ConvertHMonitor(FMonitor).rcMonitor
end;
 
procedure TDirectXDriverEx.SetGUID(Value: PGUID);
begin
if not IsBadHugeReadPtr(Value, SizeOf(TGUID)) then
begin
FGUID2 := Value^;
FGUID := @FGUID2;
end else
FGUID := Value;
end;
 
{ TDirectXDriversEx }
 
constructor TDirectXDriversEx.Create;
begin
inherited Create(TDirectXDriverEx);
end;
 
function TDirectXDriversEx.GetDriver(Index: Integer): TDirectXDriverEx;
begin
Result := (inherited Items[Index]) as TDirectXDriverEx;
end;
 
{$ENDIF}
 
initialization
InitCosinTable;
finalization
FreeLibList;
end.
end.
/VCL_DELPHIX_D6/Wave.pas
0,0 → 1,726
unit Wave;
 
interface
 
{$INCLUDE DelphiXcfg.inc}
 
uses
Windows, SysUtils, Classes, MMSystem;
 
type
 
{ EWaveError }
 
EWaveError = class(Exception);
 
{ TWave }
 
TWave = class(TPersistent)
private
FData: Pointer;
FFormat: PWaveFormatEx;
FFormatSize: Integer;
FSize: Integer;
procedure SetFormatSize(Value: Integer);
procedure SetSize(Value: Integer);
protected
procedure DefineProperties(Filer: TFiler); override;
procedure ReadData(Stream: TStream); virtual;
procedure WriteData(Stream: TStream); virtual;
public
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure Clear;
procedure LoadFromFile(const FileName : string);
procedure LoadFromStream(Stream: TStream);
procedure SaveToFile(const FileName : string);
procedure SaveToStream(Stream: TStream);
procedure SetPCMFormat(SamplesPerSec, BitsPerSample, Channels: Integer);
property Data: Pointer read FData;
property Format: PWaveFormatEx read FFormat;
property FormatSize: Integer read FFormatSize write SetFormatSize;
property Size: Integer read FSize write SetSize;
end;
 
{ TCustomDXWave }
 
TCustomDXWave = class(TComponent)
private
FWave: TWave;
procedure SetWave(Value: TWave);
public
constructor Create(AOnwer: TComponent); override;
destructor Destroy; override;
property Wave: TWave read FWave write SetWave;
end;
 
{ TDXWave }
 
TDXWave = class(TCustomDXWave)
published
property Wave;
end;
 
{ EWaveStreamError }
 
EWaveStreamError = class(Exception);
 
{ TCustomWaveStream }
 
TCustomWaveStream = class(TStream)
private
FPosition: Integer;
protected
function GetFilledSize: Integer; virtual;
function GetFormat: PWaveFormatEx; virtual; abstract;
function GetFormatSize: Integer; virtual;
function GetSize: Integer; virtual;
function ReadWave(var Buffer; Count: Integer): Integer; virtual;
procedure SetFormatSize(Value: Integer); virtual; abstract;
procedure SetSize(Value: Integer); override;
function WriteWave(const Buffer; Count: Integer): Integer; virtual;
public
function Read(var Buffer; Count: Longint): Longint; override;
function Seek(Offset: Longint; Origin: Word): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
procedure SetPCMFormat(SamplesPerSec, BitsPerSample, Channels: Integer);
property FilledSize: Integer read GetFilledSize;
property Format: PWaveFormatEx read GetFormat;
property FormatSize: Integer read GetFormatSize write SetFormatSize;
property Size: Integer read GetSize write SetSize;
end;
 
{ TCustomWaveStream2 }
 
TCustomWaveStream2 = class(TCustomWaveStream)
private
FFormat: PWaveFormatEx;
FFormatSize: Integer;
protected
function GetFormat: PWaveFormatEx; override;
function GetFormatSize: Integer; override;
procedure SetFormatSize(Value: Integer); override;
public
destructor Destroy; override;
end;
 
{ TWaveObjectStream }
 
TWaveObjectStream = class(TCustomWaveStream)
private
FWave: TWave;
protected
function GetFormat: PWaveFormatEx; override;
function GetFormatSize: Integer; override;
function GetSize: Integer; override;
function ReadWave(var Buffer; Count: Integer): Integer; override;
procedure SetFormatSize(Value: Integer); override;
procedure SetSize(Value: Integer); override;
function WriteWave(const Buffer; Count: Integer): Integer; override;
public
constructor Create(AWave: TWave);
end;
 
{ TWaveStream }
 
TWaveStream = class(TCustomWaveStream2)
private
FDataPosition: Integer;
FDataHeaderPosition: Integer;
FOpened: Boolean;
FOriPosition: Integer;
FReadMode: Boolean;
FSize: Integer;
FStream: TStream;
procedure CloseWriteMode;
procedure OpenReadMode;
procedure OpenWriteMode;
protected
function GetSize: Integer; override;
function ReadWave(var Buffer; Count: Integer): Integer; override;
function WriteWave(const Buffer; Count: Integer): Integer; override;
public
constructor Create(AStream: TStream);
destructor Destroy; override;
procedure Open(WriteMode: Boolean);
end;
 
{ TWaveFileStream }
 
TWaveFileStream = class(TWaveStream)
private
FFileStream: TFileStream;
public
constructor Create(const FileName: string; FileMode: Integer);
destructor Destroy; override;
end;
 
procedure MakePCMWaveFormatEx(var Format: TWaveFormatEx;
SamplesPerSec, BitsPerSample, Channels: Integer);
 
implementation
 
uses DXConsts;
 
procedure MakePCMWaveFormatEx(var Format: TWaveFormatEx;
SamplesPerSec, BitsPerSample, Channels: Integer);
begin
with Format do
begin
wFormatTag := WAVE_FORMAT_PCM;
nChannels := Channels;
nSamplesPerSec := SamplesPerSec;
wBitsPerSample := BitsPerSample;
nBlockAlign := nChannels*(wBitsPerSample div 8);
nAvgBytesPerSec := nBlockAlign*nSamplesPerSec;
cbSize := 0;
end;
end;
 
{ TWave }
 
const
WavePoolSize = 8096;
 
destructor TWave.Destroy;
begin
Clear;
inherited Destroy;
end;
 
procedure TWave.Assign(Source: TPersistent);
var
AWave: TWave;
begin
if Source=nil then
begin
Clear;
end else if Source is TWave then
begin
if Source<>Self then
begin
AWave := TWave(Source);
Size := AWave.Size;
FormatSize := AWave.FormatSize;
Move(AWave.Data^, FData^, FSize);
Move(AWave.Format^, FFormat^, FFormatSize);
end;
end else
inherited Assign(Source);
end;
 
procedure TWave.Clear;
begin
FreeMem(FData, 0); FData := nil;
FreeMem(FFormat, 0); FFormat := nil;
 
FSize := 0;
FFormatSize := 0;
end;
 
procedure TWave.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineBinaryProperty('WAVE', ReadData, WriteData, True);
end;
 
procedure TWave.LoadFromFile(const FileName : string);
var
Stream: TFileStream;
begin
Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
 
procedure TWave.LoadFromStream(Stream: TStream);
var
WaveStream: TWaveStream;
begin
Clear;
 
WaveStream := TWaveStream.Create(Stream);
try
WaveStream.Open(False);
 
FormatSize := WaveStream.FormatSize;
Move(WaveStream.Format^, Format^, FormatSize);
Size := WaveStream.Size;
WaveStream.ReadBuffer(FData^, Size);
finally
WaveStream.Free;
end;
end;
 
procedure TWave.ReadData(Stream: TStream);
begin
LoadFromStream(Stream);
end;
 
procedure TWave.SaveToFile(const FileName : string);
var
Stream: TFileStream;
begin
Stream := TFileStream.Create(FileName, fmCreate);
try
SaveToStream(Stream);
finally
Stream.Free;
end;
end;
 
procedure TWave.SaveToStream(Stream: TStream);
var
WaveStream: TWaveStream;
begin
if (FFormatSize<=0) or (FSize<=0) then Exit;
 
WaveStream := TWaveStream.Create(Stream);
try
WaveStream.FormatSize := FormatSize;
Move(Format^, WaveStream.Format^, FormatSize);
 
WaveStream.Open(True);
WaveStream.WriteBuffer(FData^, Size);
finally
WaveStream.Free;
end;
end;
 
procedure TWave.SetFormatSize(Value: Integer);
begin
if Value<=0 then Value := 0;
ReAllocMem(FFormat, Value);
FFormatSize := Value;
end;
 
procedure TWave.SetPCMFormat(SamplesPerSec, BitsPerSample, Channels: Integer);
begin
FormatSize := SizeOf(TWaveFormatEx);
MakePCMWaveFormatEx(Format^, SamplesPerSec, BitsPerSample, Channels);
end;
 
procedure TWave.SetSize(Value: Integer);
var
i: Integer;
begin
if Value<=0 then Value := 0;
 
i := (Value+WavePoolSize-1) div WavePoolSize;
if i<>(FSize+WavePoolSize-1) div WavePoolSize then
ReAllocMem(FData, i*WavePoolSize);
 
FSize := Value;
end;
 
procedure TWave.WriteData(Stream: TStream);
begin
SaveToStream(Stream);
end;
 
{ TCustomDXWave }
 
constructor TCustomDXWave.Create(AOnwer: TComponent);
begin
inherited Create(AOnwer);
FWave := TWave.Create;
end;
 
destructor TCustomDXWave.Destroy;
begin
FWave.Free;
inherited Destroy;
end;
 
procedure TCustomDXWave.SetWave(Value: TWave);
begin
FWave.Assign(Value);
end;
 
{ TCustomWaveStream }
 
function TCustomWaveStream.GetFilledSize: Longint;
begin
Result := -1;
end;
 
function TCustomWaveStream.GetFormatSize: Integer;
begin
Result := 0;
end;
 
function TCustomWaveStream.GetSize: Integer;
begin
Result := -1;
end;
 
function TCustomWaveStream.Read(var Buffer; Count: Longint): Longint;
begin
if GetSize<0 then
Result := ReadWave(Buffer, Count)
else
begin
if FPosition>Size then
FPosition := Size;
if FPosition+Count>Size then
Result := Size-FPosition
else
Result := Count;
 
Result := ReadWave(Buffer, Result);
end;
 
Inc(FPosition, Result);
end;
 
function TCustomWaveStream.ReadWave(var Buffer; Count: Integer): Integer;
begin
Result := 0;
end;
 
function TCustomWaveStream.Seek(Offset: Longint; Origin: Word): Longint;
begin
case Origin of
soFromBeginning: FPosition := Offset;
soFromCurrent : FPosition := FPosition + Offset;
soFromEnd : FPosition := GetSize + Offset;
end;
if FPosition<0 then FPosition := 0;
if FPosition>GetSize then FPosition := GetSize;
 
Result := FPosition;
end;
 
procedure TCustomWaveStream.SetPCMFormat(SamplesPerSec, BitsPerSample, Channels: Integer);
begin
FormatSize := SizeOf(TWaveFormatEx);
MakePCMWaveFormatEx(Format^, SamplesPerSec, BitsPerSample, Channels);
end;
 
procedure TCustomWaveStream.SetSize(Value: Integer);
begin
end;
 
function TCustomWaveStream.Write(const Buffer; Count: Longint): Longint;
begin
if FPosition>Size then
FPosition := Size;
Result := WriteWave(Buffer, Count);
Inc(FPosition, Result);
end;
 
function TCustomWaveStream.WriteWave(const Buffer; Count: Integer): Integer;
begin
Result := 0;
end;
 
{ TCustomWaveStream2 }
 
destructor TCustomWaveStream2.Destroy;
begin
FormatSize := 0;
inherited Destroy;
end;
 
function TCustomWaveStream2.GetFormat: PWaveFormatEx;
begin
Result := FFormat;
end;
 
function TCustomWaveStream2.GetFormatSize: Integer;
begin
Result := FFormatSize;
end;
 
procedure TCustomWaveStream2.SetFormatSize(Value: Integer);
begin
ReAllocMem(FFormat, Value);
FFormatSize := Value;
end;
 
{ TWaveObjectStream }
 
constructor TWaveObjectStream.Create(AWave: TWave);
begin
inherited Create;
FWave := AWave;
 
FormatSize := FWave.FormatSize;
Move(FWave.Format^, Format^, FormatSize);
end;
 
function TWaveObjectStream.GetFormat: PWaveFormatEx;
begin
Result := FWave.Format;
end;
 
function TWaveObjectStream.GetFormatSize: Integer;
begin
Result := FWave.FormatSize;
end;
 
function TWaveObjectStream.GetSize: Integer;
begin
Result := FWave.Size;
end;
 
function TWaveObjectStream.ReadWave(var Buffer; Count: Integer): Integer;
begin
Result := Count;
Move(Pointer(Integer(FWave.Data)+Position)^, Buffer, Count);
end;
 
procedure TWaveObjectStream.SetFormatSize(Value: Integer);
begin
FWave.FormatSize := Value;
end;
 
procedure TWaveObjectStream.SetSize(Value: Integer);
begin
FWave.Size := Value;
end;
 
function TWaveObjectStream.WriteWave(const Buffer; Count: Integer): Integer;
begin
Result := Count;
if Position+Count>Size then
SetSize(Size+(Position+Count+Size));
Move(Buffer, Pointer(Integer(FWave.Data)+Position)^, Count);
end;
 
{ TWaveStream }
 
const
ID_RIFF = Ord('R') + Ord('I')*$100 + Ord('F')*$10000 + Ord('F')*$1000000;
ID_WAVE = Ord('W') + Ord('A')*$100 + Ord('V')*$10000 + Ord('E')*$1000000;
ID_FMT = Ord('f') + Ord('m')*$100 + Ord('t')*$10000 + Ord(' ')*$1000000;
ID_FACT = Ord('f') + Ord('a')*$100 + Ord('c')*$10000 + Ord('t')*$1000000;
ID_DATA = Ord('d') + Ord('a')*$100 + Ord('t')*$10000 + Ord('a')*$1000000;
 
type
TWaveFileHeader = packed record
FType: Integer;
Size: Longint;
RType: Integer;
end;
 
TWaveChunkHeader = packed record
CType: Longint;
Size: Longint;
end;
 
constructor TWaveStream.Create(AStream: TStream);
begin
inherited Create;
FStream := AStream;
 
FOriPosition := FStream.Position;
end;
 
destructor TWaveStream.Destroy;
begin
if FOpened and (not FReadMode) then
CloseWriteMode;
inherited Destroy;
end;
 
function TWaveStream.GetSize: Integer;
begin
if FOpened then
begin
if not FReadMode then
Result := FStream.Size-FDataPosition
else
Result := FSize;
end else
Result := 0;
end;
 
function TWaveStream.ReadWave(var Buffer; Count: Integer): Integer;
begin
if not FOpened then
raise EWaveStreamError.Create(SStreamNotOpend);
 
FStream.Position := FDataPosition+Position;
Result := FStream.Read(Buffer, Count);
end;
 
function TWaveStream.WriteWave(const Buffer; Count: Integer): Integer;
begin
if not FOpened then
raise EWaveStreamError.Create(SStreamNotOpend);
 
if FReadMode then
begin
if Position+Count>FSize then
Count := FSize-Position;
end;
 
FStream.Position := FDataPosition+Position;
Result := FStream.Write(Buffer, Count);
end;
 
procedure TWaveStream.Open(WriteMode: Boolean);
begin
if WriteMode then
OpenWriteMode
else
OpenReadMode;
end;
 
procedure TWaveStream.OpenReadMode;
var
WF: TWaveFileHeader;
WC: TWaveChunkHeader;
 
procedure Readfmt; { fmt }
begin
FormatSize := WC.Size;
FStream.ReadBuffer(Format^, WC.Size);
end;
 
procedure Readdata; { data }
begin
FSize := WC.Size;
FDataPosition := FStream.Position;
FStream.Seek(FSize, 1);
end;
 
begin
if FOpened then
raise EWaveStreamError.Create(SStreamOpend);
 
FOpened := True;
FReadMode := True;
 
FStream.Position := FOriPosition;
 
//if FStream.Size-FStream.Position<=0 then Exit;
 
{ File header reading. }
FStream.ReadBuffer(WF, SizeOf(TWaveFileHeader));
 
{ Is it Wave file of the file? }
if (WF.FType<>ID_RIFF) or (WF.RType<>ID_WAVE) then
raise EWaveStreamError.Create(SInvalidWave);
 
{ Chunk reading. }
FillChar(WC, SizeOf(WC), 0);
FStream.Read(WC, SizeOf(TWaveChunkHeader));
while WC.CType<>0 do
begin
case WC.CType of
ID_FMT : Readfmt;
ID_DATA: Readdata;
else
{ Chunk which does not correspond is disregarded. }
FStream.Seek(WC.Size, 1);
end;
 
FillChar(WC, SizeOf(WC), 0);
FStream.Read(WC, SizeOf(TWaveChunkHeader));
end;
end;
 
procedure TWaveStream.OpenWriteMode;
 
procedure WriteFmt; { fmt }
var
WC: TWaveChunkHeader;
begin
with WC do
begin
CType := ID_FMT;
Size := FFormatSize;
end;
 
FStream.WriteBuffer(WC, SizeOf(WC));
FStream.WriteBuffer(FFormat^, FFormatSize);
end;
 
procedure WriteData; { data }
var
WC: TWaveChunkHeader;
begin
FDataHeaderPosition := FStream.Position;
 
with WC do
begin
CType := ID_DATA;
Size := 0;
end;
 
FStream.WriteBuffer(WC, SizeOf(WC));
 
FDataPosition := FStream.Position;
end;
 
var
WF: TWaveFileHeader;
begin
if FOpened then
raise EWaveStreamError.Create(SStreamOpend);
 
if FormatSize=0 then
raise EWaveStreamError.Create(SInvalidWaveFormat);
 
FOpened := True;
FStream.Position := FOriPosition;
 
FStream.WriteBuffer(WF, SizeOf(TWaveFileHeader));
 
{ Chunk writing. }
WriteFmt;
WriteData;
end;
 
procedure TWaveStream.CloseWriteMode;
 
procedure WriteDataHeader; { data }
var
WC: TWaveChunkHeader;
begin
FStream.Position := FDataHeaderPosition;
 
with WC do
begin
CType := ID_DATA;
Size := Self.Size;
end;
 
FStream.WriteBuffer(WC, SizeOf(WC));
end;
 
var
WF: TWaveFileHeader;
begin
with WF do
begin
FType := ID_RIFF;
Size := (FStream.Size-FOriPosition)-SizeOf(TWaveChunkHeader);
RType := ID_WAVE;
end;
FStream.Position := FOriPosition;
FStream.WriteBuffer(WF, SizeOf(TWaveFileHeader));
WriteDataHeader;
FStream.Position := FStream.Size;
end;
 
{ TWaveFileStream }
 
constructor TWaveFileStream.Create(const FileName: string; FileMode: Integer);
begin
FFileStream := TFileStream.Create(FileName, FileMode);
inherited Create(FFileStream);
end;
 
destructor TWaveFileStream.Destroy;
begin
inherited Destroy;
FFileStream.Free;
end;
 
end.
/VCL_DELPHIX_D6/DirectX.pas
25,119 → 25,118
* URL : http://www.infosakyu.ne.jp/~kazuya-y/index.html
*
***************************************************************************)
{
(c)2004 Jaro Benes Recompilation with Erik Unger's headers
 
Join in order:
1) DirectDraw
2) Direct3D
3) Direct3DRM
4) DirectInput
5) DirectPlay
6) DirectSetup
7) DirectSound
8) DirectMusic
}
Unit DirectX;
unit DirectX;
 
Interface
interface
 
{Delphi version marks}
{$Z4}
{$A+}
{$WEAKPACKAGEUNIT}
 
{$I DelphiXcfg.inc}
{$IFNDEF DirectX3}
{$IFNDEF DirectX5}
{$IFNDEF DirectX6}
{$IFNDEF DirectX7}
{$DEFINE DirectX7}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
 
{$MINENUMSIZE 4}
{$ALIGN ON}
{$IFDEF DirectX3}
{$UNDEF DirectX5}
{$UNDEF DirectX6}
{$UNDEF DirectX7}
{$DEFINE SupportDirectX3}
{$ENDIF}
 
uses
Windows, MMSystem;
{$IFDEF DirectX5}
{$UNDEF DirectX3}
{$UNDEF DirectX6}
{$UNDEF DirectX7}
{$DEFINE SupportDirectX3}
{$DEFINE SupportDirectX5}
{$ENDIF}
 
type
{$IFDEF UNICODE}
PCharAW = PWideChar;
{$ELSE}
PCharAW = PAnsiChar;
{$IFDEF DirectX6}
{$UNDEF DirectX3}
{$UNDEF DirectX5}
{$UNDEF DirectX7}
{$DEFINE SupportDirectX3}
{$DEFINE SupportDirectX5}
{$DEFINE SupportDirectX6}
{$ENDIF}
 
//DirectDraw file
{$IFDEF DirectX7}
{$UNDEF DirectX3}
{$UNDEF DirectX5}
{$UNDEF DirectX6}
{$DEFINE SupportDirectX3}
{$DEFINE SupportDirectX5}
{$DEFINE SupportDirectX6}
{$DEFINE SupportDirectX7}
{$ENDIF}
 
uses Windows, MMSystem, ActiveX;
 
const
{$IFDEF DirectX3}
DirectXUnitVersion = 3;
{$ENDIF}{$IFDEF DirectX5}
DirectXUnitVersion = 5;
{$ENDIF}{$IFDEF DirectX6}
DirectXUnitVersion = 6;
{$ENDIF}{$IFDEF DirectX7}
DirectXUnitVersion = 7;
{$ENDIF}
 
(*==========================================================================;
*
* Copyright (C) 1994-1997 Microsoft Corporation. All Rights Reserved.
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* Files: ddraw.h dvp.h
* Content: DirectDraw and DirectDrawVideoPort include files
* File: ddraw.h
* Content: DirectDraw include file
*
* DirectX 7.0 Delphi adaptation by Erik Unger
*
* Modified: 10-Sep-2000
*
* Download: http://www.delphi-jedi.org/DelphiGraphics/
* E-Mail: DelphiDirectX@next-reality.com
*
*
***************************************************************************)
 
var
DDrawDLL : HMODULE = 0;
{ FOURCC codes for DX compressed-texture pixel formats }
 
function DDErrorString(Value: HResult) : string;
const
FOURCC_DXT1 = Ord('D') + Ord('X') shl 8 + Ord('T') shl 16 + Ord('1') shl 24;
FOURCC_DXT2 = Ord('D') + Ord('X') shl 8 + Ord('T') shl 16 + Ord('2') shl 24;
FOURCC_DXT3 = Ord('D') + Ord('X') shl 8 + Ord('T') shl 16 + Ord('3') shl 24;
FOURCC_DXT4 = Ord('D') + Ord('X') shl 8 + Ord('T') shl 16 + Ord('4') shl 24;
FOURCC_DXT5 = Ord('D') + Ord('X') shl 8 + Ord('T') shl 16 + Ord('5') shl 24;
 
function MAKEFOURCC(ch0, ch1, ch2, ch3: Char) : DWORD;
{ GUIDS used by DirectDraw objects }
 
(*
* FOURCC codes for DX compressed-texture pixel formats
*)
const
FOURCC_DXT1 = 'DXT1';
FOURCC_DXT2 = 'DXT2';
FOURCC_DXT3 = 'DXT3';
FOURCC_DXT4 = 'DXT4';
FOURCC_DXT5 = 'DXT5';
 
(*
* GUIDS used by DirectDraw objects
*)
const
CLSID_DirectDraw: TGUID = '{D7B70EE0-4340-11CF-B063-0020AFC2CD35}';
CLSID_DirectDraw7: TGUID = '{3c305196-50db-11d3-9cfe-00c04fd930c5}';
CLSID_DirectDrawClipper: TGUID = '{593817A0-7DB3-11CF-A2DE-00AA00b93356}';
CLSID_DirectDraw7: TGUID = '{3C305196-50DB-11D3-9CFE-00C04FD930C5}';
CLSID_DirectDrawClipper: TGUID = '{593817A0-7DB3-11CF-A2DE-00AA00B93356}';
IID_IDirectDraw: TGUID = '{6C14DB80-A733-11CE-A521-0020AF0BE560}';
IID_IDirectDraw2: TGUID = '{B3A6F3E0-2B43-11CF-A2DE-00AA00B93356}';
IID_IDirectDraw4: TGUID = '{9C59509A-39BD-11D1-8C4A-00C04FD930C5}';
IID_IDirectDraw7: TGUID = '{15E65EC0-3B9C-11D2-B92F-00609797EA5B}';
IID_IDirectDrawSurface: TGUID = '{6C14DB81-A733-11CE-A521-0020AF0BE560}';
IID_IDirectDrawSurface2: TGUID = '{57805885-6EEC-11CF-9441-A82303C10E27}';
IID_IDirectDrawSurface3: TGUID = '{DA044E00-69B2-11D0-A1D5-00AA00B8DFBB}';
IID_IDirectDrawSurface4: TGUID = '{0B2B8630-AD35-11D0-8EA6-00609797EA5B}';
IID_IDirectDrawSurface7: TGUID = '{06675A80-3B9B-11D2-B92F-00609797EA5B}';
IID_IDirectDrawPalette: TGUID = '{6C14DB84-A733-11CE-A521-0020AF0BE560}';
IID_IDirectDrawClipper: TGUID = '{6C14DB85-A733-11CE-A521-0020AF0BE560}';
IID_IDirectDrawColorControl: TGUID = '{4B9F0EE0-0D7E-11D0-9B06-00A0C903A3B8}';
IID_IDirectDrawGammaControl: TGUID = '{69C11C3E-B46B-11D1-AD7A-00C04FC29B4E}';
 
const
DD_ROP_SPACE = (256 div 32); // space required to store ROP array
DD_ROP_SPACE = 256 div 32; // space required to store ROP array
 
MAX_DDDEVICEID_STRING = 512;
 
(*
* Flags for the IDirectDraw4::GetDeviceIdentifier method
*)
{ DirectDraw Structures }
 
(*
* This flag causes GetDeviceIdentifier to return information about the host (typically 2D) adapter in a system equipped
* with a stacked secondary 3D adapter. Such an adapter appears to the application as if it were part of the
* host adapter, but is typically physcially located on a separate card. The stacked secondary's information is
* returned when GetDeviceIdentifier's dwFlags field is zero, since this most accurately reflects the qualities
* of the DirectDraw object involved.
*)
DDGDI_GETHOSTIDENTIFIER = $00000001;
 
(*============================================================================
*
* DirectDraw Structures
*
* Various structures used to invoke DirectDraw.
*
*==========================================================================*)
 
var
NilGUID : TGUID{$IfNDef VER6UP} absolute 0{$EndIf};
 
type
TRefGUID = packed record
case integer of
1: (guid : PGUID);
2: (dwFlags : DWORD);
end;
 
IDirectDraw = interface;
IDirectDraw2 = interface;
IDirectDraw4 = interface;
147,40 → 146,41
IDirectDrawSurface3 = interface;
IDirectDrawSurface4 = interface;
IDirectDrawSurface7 = interface;
 
IDirectDrawPalette = interface;
IDirectDrawClipper = interface;
IDirectDrawColorControl = interface;
IDirectDrawGammaControl = interface;
 
(*
* Generic pixel format with 8-bit RGB and alpha components
*)
{ TDDARGB structure }
 
PDDARGB = ^TDDARGB;
TDDARGB = packed record
blue: BYTE;
green: BYTE;
red: BYTE;
alpha: BYTE;
TDDARGB = record
Blue: Byte;
Green: Byte;
Red: Byte;
Alpha: Byte;
end;
 
(*
* This version of the structure remains for backwards source compatibility.
* The DDARGB structure is the one that should be used for all DirectDraw APIs.
*)
DDARGB = TDDARGB;
LPDDARGB = PDDARGB;
 
{ TDDRGBA structure }
 
PDDRGBA = ^TDDRGBA;
TDDRGBA = packed record
red : BYTE;
green : BYTE;
blue : BYTE;
alpha : BYTE;
TDDRGBA = record
Red: Byte;
Green: Byte;
Blue: Byte;
Alpha: Byte;
end;
 
(*
* TDDColorKey
*)
DDRGBA = TDDRGBA;
LPDDRGBA = PDDRGBA;
 
{ TDDColorKey structure }
 
PDDColorKey = ^TDDColorKey;
TDDColorKey = packed record
TDDColorKey = record
dwColorSpaceLowValue: DWORD; // low boundary of color space that is to
// be treated as Color Key, inclusive
dwColorSpaceHighValue: DWORD; // high boundary of color space that is
187,21 → 187,13
// to be treated as Color Key, inclusive
end;
 
// Delphi 5 can't handle interface in variant records
// so we have to use pointers instead (which can be type-casted into interfaces):
DDCOLORKEY = TDDColorKey;
LPDDCOLORKEY = PDDColorKey;
 
{$IFDEF VER5UP}
PDirectDrawSurface = Pointer;
{$ELSE}
PDirectDrawSurface = IDirectDrawSurface;
{$ENDIF}
{ TDDBltFX structure }
 
(*
* TDDBltFX
* Used to pass override information to the DIRECTDRAWSURFACE callback Blt.
*)
PDDBltFX = ^TDDBltFX;
TDDBltFX = packed record
TDDBltFX = record
dwSize : DWORD; // size of structure
dwDDFX : DWORD; // FX operations
dwROP : DWORD; // Win32 raster operations
212,88 → 204,89
dwZBufferHigh : DWORD; // High limit of Z buffer
dwZBufferBaseDest : DWORD; // Destination base value
dwZDestConstBitDepth : DWORD; // Bit depth used to specify Z constant for destination
case integer of
case Integer of
0: (
dwZDestConst : DWORD // Constant to use as Z buffer for dest
);
1: (
lpDDSZBufferDest : PDirectDrawSurface; // Surface to use as Z buffer for dest
dwZDestConst: DWORD; // Constant to use as Z buffer for dest
dwZSrcConstBitDepth : DWORD; // Bit depth used to specify Z constant for source
case integer of
0: (
dwZSrcConst : DWORD; // Constant to use as Z buffer for src
);
1: (
lpDDSZBufferSrc : PDirectDrawSurface; // Surface to use as Z buffer for src
dwAlphaEdgeBlendBitDepth : DWORD; // Bit depth used to specify constant for alpha edge blend
dwAlphaEdgeBlend : DWORD; // Alpha for edge blending
dwReserved : DWORD;
dwAlphaDestConstBitDepth : DWORD; // Bit depth used to specify alpha constant for destination
case integer of
0: (
dwAlphaDestConst : DWORD; // Constant to use as Alpha Channel
);
1: (
lpDDSAlphaDest : PDirectDrawSurface; // Surface to use as Alpha Channel
dwAlphaSrcConstBitDepth : DWORD; // Bit depth used to specify alpha constant for source
case integer of
0: (
dwAlphaSrcConst : DWORD; // Constant to use as Alpha Channel
);
1: (
lpDDSAlphaSrc : PDirectDrawSurface; // Surface to use as Alpha Channel
case integer of
0: (
dwFillColor : DWORD; // color in RGB or Palettized
ddckDestColorkey: TDDColorKey; // DestColorkey override
ddckSrcColorkey: TDDColorKey; // SrcColorkey override
);
1: (
lpDDSZBufferDest: Pointer{IDirectDrawSurface}; // Surface to use as Z buffer for dest
_union1b: DWORD;
lpDDSZBufferSrc: Pointer{IDirectDrawSurface}; // Surface to use as Z buffer for src
_union1d: DWORD;
_union1e: DWORD;
_union1f: DWORD;
_union1g: DWORD;
lpDDSAlphaDest: Pointer{IDirectDrawSurface}; // Surface to use as Alpha Channel
_union1i: DWORD;
lpDDSAlphaSrc: Pointer{IDirectDrawSurface}; // Surface to use as Alpha Channel
dwFillDepth : DWORD; // depth value for z-buffer
);
2: (
dwFillPixel : DWORD; // pixel value
_union2a: DWORD;
_union2b: DWORD;
_union2c: DWORD;
_union2d: DWORD;
_union2e: DWORD;
_union2f: DWORD;
_union2g: DWORD;
_union2h: DWORD;
_union2i: DWORD;
_union2j: DWORD;
lpDDSPattern: Pointer{IDirectDrawSurface}; // Surface to use as pattern
);
3: (
lpDDSPattern : PDirectDrawSurface; // Surface to use as pattern
ddckDestColorkey : TDDColorKey; // DestColorkey override
ddckSrcColorkey : TDDColorKey; // SrcColorkey override
)
)
)
)
)
end;
 
(*
* TDDSCaps
*)
DDBLTFX = TDDBltFX;
LPDDBLTFX = PDDBltFX;
 
{ TDDSCaps structure }
 
PDDSCaps = ^TDDSCaps;
TDDSCaps = packed record
TDDSCaps = record
dwCaps: DWORD; // capabilities of surface wanted
end;
 
(*
* TDDOSCaps
*)
DDSCAPS = TDDSCaps;
LPDDSCAPS = PDDSCaps;
{ TDDOSCaps structure }
 
PDDOSCaps = ^TDDOSCaps;
TDDOSCaps = packed record
TDDOSCaps = record
dwCaps: DWORD; // capabilities of surface wanted
end;
 
(*
* This structure is used internally by DirectDraw.
*)
DDOSCAPS = TDDOSCaps;
LPDDOSCAPS = PDDOSCaps;
 
 
{ TDDSCapsEx structure }
 
PDDSCapsEx = ^TDDSCapsEx;
TDDSCapsEx = packed record
TDDSCapsEx = record
dwCaps2 : DWORD;
dwCaps3 : DWORD;
dwCaps4 : DWORD;
end;
 
(*
* TDDSCaps2
*)
DDSCAPSEX = TDDSCapsEx;
LPDDSCAPSEX = PDDSCapsEx;
 
{ TDDSCaps2 structure }
 
PDDSCaps2 = ^TDDSCaps2;
TDDSCaps2 = packed record
TDDSCaps2 = record
dwCaps: DWORD; // capabilities of surface wanted
dwCaps2 : DWORD;
dwCaps3 : DWORD;
300,15 → 293,53
dwCaps4 : DWORD;
end;
 
(*
* TDDCaps
*)
(*
* This structure is the TDDCaps structure as it was in version 2 and 3 of Direct X.
* It is present for back compatability.
*)
DDSCAPS2 = TDDSCaps2;
LPDDSCAPS2 = PDDSCaps2;
 
{ TDDCaps structure }
 
PDDCaps_DX1 = ^TDDCaps_DX1;
TDDCaps_DX1 = record
dwSize: DWORD; // size of the DDDRIVERCAPS structure
dwCaps: DWORD; // driver specific capabilities
dwCaps2: DWORD; // more driver specific capabilites
dwCKeyCaps: DWORD; // color key capabilities of the surface
dwFXCaps: DWORD; // driver specific stretching and effects capabilites
dwFXAlphaCaps: DWORD; // alpha driver specific capabilities
dwPalCaps: DWORD; // palette capabilities
dwSVCaps: DWORD; // stereo vision capabilities
dwAlphaBltConstBitDepths: DWORD; // DDBD_2,4,8
dwAlphaBltPixelBitDepths: DWORD; // DDBD_1,2,4,8
dwAlphaBltSurfaceBitDepths: DWORD; // DDBD_1,2,4,8
dwAlphaOverlayConstBitDepths: DWORD; // DDBD_2,4,8
dwAlphaOverlayPixelBitDepths: DWORD; // DDBD_1,2,4,8
dwAlphaOverlaySurfaceBitDepths: DWORD; // DDBD_1,2,4,8
dwZBufferBitDepths: DWORD; // DDBD_8,16,24,32
dwVidMemTotal: DWORD; // total amount of video memory
dwVidMemFree: DWORD; // amount of free video memory
dwMaxVisibleOverlays: DWORD; // maximum number of visible overlays
dwCurrVisibleOverlays: DWORD; // current number of visible overlays
dwNumFourCCCodes: DWORD; // number of four cc codes
dwAlignBoundarySrc: DWORD; // source rectangle alignment
dwAlignSizeSrc: DWORD; // source rectangle byte size
dwAlignBoundaryDest: DWORD; // dest rectangle alignment
dwAlignSizeDest: DWORD; // dest rectangle byte size
dwAlignStrideAlign: DWORD; // stride alignment
dwRops: array[0..DD_ROP_SPACE-1] of DWORD; // ROPS supported
ddsCaps: TDDSCaps; // TDDSCaps structure has all the general capabilities
dwMinOverlayStretch: DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxOverlayStretch: DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMinLiveVideoStretch: DWORD; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxLiveVideoStretch: DWORD; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMinHwCodecStretch: DWORD; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxHwCodecStretch: DWORD; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwReserved1: DWORD; // reserved
dwReserved2: DWORD; // reserved
dwReserved3: DWORD; // reserved
end;
 
PDDCaps_DX3 = ^TDDCaps_DX3;
TDDCaps_DX3 = packed record
TDDCaps_DX3 = record
dwSize: DWORD; // size of the DDDRIVERCAPS structure
dwCaps: DWORD; // driver specific capabilities
dwCaps2: DWORD; // more driver specific capabilites
334,7 → 365,7
dwAlignBoundaryDest: DWORD; // dest rectangle alignment
dwAlignSizeDest: DWORD; // dest rectangle byte size
dwAlignStrideAlign: DWORD; // stride alignment
dwRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported
dwRops: array[0..DD_ROP_SPACE-1] of DWORD; // ROPS supported
ddsCaps: TDDSCaps; // TDDSCaps structure has all the general capabilities
dwMinOverlayStretch: DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxOverlayStretch: DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
348,26 → 379,22
dwSVBCaps: DWORD; // driver specific capabilities for System->Vmem blts
dwSVBCKeyCaps: DWORD; // driver color key capabilities for System->Vmem blts
dwSVBFXCaps: DWORD; // driver FX capabilities for System->Vmem blts
dwSVBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts
dwSVBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts
dwVSBCaps: DWORD; // driver specific capabilities for Vmem->System blts
dwVSBCKeyCaps: DWORD; // driver color key capabilities for Vmem->System blts
dwVSBFXCaps: DWORD; // driver FX capabilities for Vmem->System blts
dwVSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts
dwVSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts
dwSSBCaps: DWORD; // driver specific capabilities for System->System blts
dwSSBCKeyCaps: DWORD; // driver color key capabilities for System->System blts
dwSSBFXCaps: DWORD; // driver FX capabilities for System->System blts
dwSSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts
dwReserved4 : DWORD;
dwReserved5 : DWORD;
dwReserved6 : DWORD;
dwSSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts
dwReserved4: DWORD; // reserved
dwReserved5: DWORD; // reserved
dwReserved6: DWORD; // reserved
end;
 
(*
* This structure is the TDDCaps structure as it was in version 5 of Direct X.
* It is present for back compatability.
*)
PDDCaps_DX5 = ^TDDCaps_DX5;
TDDCaps_DX5 = packed record
TDDCaps_DX5 = record
dwSize: DWORD; // size of the DDDRIVERCAPS structure
dwCaps: DWORD; // driver specific capabilities
dwCaps2: DWORD; // more driver specific capabilites
393,7 → 420,7
dwAlignBoundaryDest: DWORD; // dest rectangle alignment
dwAlignSizeDest: DWORD; // dest rectangle byte size
dwAlignStrideAlign: DWORD; // stride alignment
dwRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported
dwRops: array[0..DD_ROP_SPACE-1] of DWORD; // ROPS supported
ddsCaps: TDDSCaps; // TDDSCaps structure has all the general capabilities
dwMinOverlayStretch: DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxOverlayStretch: DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
407,16 → 434,16
dwSVBCaps: DWORD; // driver specific capabilities for System->Vmem blts
dwSVBCKeyCaps: DWORD; // driver color key capabilities for System->Vmem blts
dwSVBFXCaps: DWORD; // driver FX capabilities for System->Vmem blts
dwSVBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts
dwSVBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts
dwVSBCaps: DWORD; // driver specific capabilities for Vmem->System blts
dwVSBCKeyCaps: DWORD; // driver color key capabilities for Vmem->System blts
dwVSBFXCaps: DWORD; // driver FX capabilities for Vmem->System blts
dwVSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts
dwVSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts
dwSSBCaps: DWORD; // driver specific capabilities for System->System blts
dwSSBCKeyCaps: DWORD; // driver color key capabilities for System->System blts
dwSSBFXCaps: DWORD; // driver FX capabilities for System->System blts
dwSSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts
// Members added for DX5:
dwSSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts
{ Members added for DX5 }
dwMaxVideoPorts: DWORD; // maximum number of usable video ports
dwCurrVideoPorts: DWORD; // current number of video ports used
dwSVBCaps2: DWORD; // more driver specific capabilities for System->Vmem blts
424,16 → 451,79
dwNLVBCaps2: DWORD; // more driver specific capabilities non-local->local vidmem blts
dwNLVBCKeyCaps: DWORD; // driver color key capabilities for non-local->local vidmem blts
dwNLVBFXCaps: DWORD; // driver FX capabilities for non-local->local blts
dwNLVBRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported for non-local->local blts
dwNLVBRops: array[0..DD_ROP_SPACE-1] of DWORD; // ROPS supported for non-local->local blts
end;
 
PDDCaps_DX6 = ^TDDCaps_DX6;
TDDCaps_DX6 = packed record
TDDCaps_DX6 = record
dwSize: DWORD; // size of the DDDRIVERCAPS structure
dwCaps: DWORD; // driver specific capabilities
dwCaps2: DWORD; // more driver specific capabilites
dwCKeyCaps: DWORD; // color key capabilities of the surface
dwFXCaps: DWORD; // driver specific stretching and effects capabilites
dwFXAlphaCaps: DWORD; // alpha caps
dwPalCaps: DWORD; // palette capabilities
dwSVCaps: DWORD; // stereo vision capabilities
dwAlphaBltConstBitDepths: DWORD; // DDBD_2,4,8
dwAlphaBltPixelBitDepths: DWORD; // DDBD_1,2,4,8
dwAlphaBltSurfaceBitDepths: DWORD; // DDBD_1,2,4,8
dwAlphaOverlayConstBitDepths: DWORD; // DDBD_2,4,8
dwAlphaOverlayPixelBitDepths: DWORD; // DDBD_1,2,4,8
dwAlphaOverlaySurfaceBitDepths: DWORD; // DDBD_1,2,4,8
dwZBufferBitDepths: DWORD; // DDBD_8,16,24,32
dwVidMemTotal: DWORD; // total amount of video memory
dwVidMemFree: DWORD; // amount of free video memory
dwMaxVisibleOverlays: DWORD; // maximum number of visible overlays
dwCurrVisibleOverlays: DWORD; // current number of visible overlays
dwNumFourCCCodes: DWORD; // number of four cc codes
dwAlignBoundarySrc: DWORD; // source rectangle alignment
dwAlignSizeSrc: DWORD; // source rectangle byte size
dwAlignBoundaryDest: DWORD; // dest rectangle alignment
dwAlignSizeDest: DWORD; // dest rectangle byte size
dwAlignStrideAlign: DWORD; // stride alignment
dwRops: array[0..DD_ROP_SPACE-1] of DWORD; // ROPS supported
ddsOldCaps: TDDSCaps; // Was TDDSCaps ddsCaps. ddsCaps is of type DDSCAPS2 for DX6
dwMinOverlayStretch: DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxOverlayStretch: DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMinLiveVideoStretch: DWORD; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxLiveVideoStretch: DWORD; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMinHwCodecStretch: DWORD; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxHwCodecStretch: DWORD; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwReserved1: DWORD; // reserved
dwReserved2: DWORD; // reserved
dwReserved3: DWORD; // reserved
dwSVBCaps: DWORD; // driver specific capabilities for System->Vmem blts
dwSVBCKeyCaps: DWORD; // driver color key capabilities for System->Vmem blts
dwSVBFXCaps: DWORD; // driver FX capabilities for System->Vmem blts
dwSVBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts
dwVSBCaps: DWORD; // driver specific capabilities for Vmem->System blts
dwVSBCKeyCaps: DWORD; // driver color key capabilities for Vmem->System blts
dwVSBFXCaps: DWORD; // driver FX capabilities for Vmem->System blts
dwVSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts
dwSSBCaps: DWORD; // driver specific capabilities for System->System blts
dwSSBCKeyCaps: DWORD; // driver color key capabilities for System->System blts
dwSSBFXCaps: DWORD; // driver FX capabilities for System->System blts
dwSSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts
{ Members added for DX5 }
dwMaxVideoPorts: DWORD; // maximum number of usable video ports
dwCurrVideoPorts: DWORD; // current number of video ports used
dwSVBCaps2: DWORD; // more driver specific capabilities for System->Vmem blts
dwNLVBCaps: DWORD; // driver specific capabilities for non-local->local vidmem blts
dwNLVBCaps2: DWORD; // more driver specific capabilities non-local->local vidmem blts
dwNLVBCKeyCaps: DWORD; // driver color key capabilities for non-local->local vidmem blts
dwNLVBFXCaps: DWORD; // driver FX capabilities for non-local->local blts
dwNLVBRops: array[0..DD_ROP_SPACE-1] of DWORD; // ROPS supported for non-local->local blts
{ Members added for DX6 }
ddsCaps: TDDSCaps2; // Surface Caps
end;
 
PDDCaps_DX7 = ^TDDCaps_DX7;
TDDCaps_DX7 = record
dwSize: DWORD; // size of the DDDRIVERCAPS structure
dwCaps: DWORD; // driver specific capabilities
dwCaps2: DWORD; // more driver specific capabilites
dwCKeyCaps: DWORD; // color key capabilities of the surface
dwFXCaps: DWORD; // driver specific stretching and effects capabilites
dwFXAlphaCaps: DWORD; // alpha driver specific capabilities
dwPalCaps: DWORD; // palette capabilities
dwSVCaps: DWORD; // stereo vision capabilities
454,8 → 544,8
dwAlignBoundaryDest: DWORD; // dest rectangle alignment
dwAlignSizeDest: DWORD; // dest rectangle byte size
dwAlignStrideAlign: DWORD; // stride alignment
dwRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported
ddsOldCaps: TDDSCaps; // Was dssCaps: TDDSCaps. ddsCaps is of type TDDScaps2 for DX6
dwRops: array[0..DD_ROP_SPACE-1] of DWORD; // ROPS supported
ddsOldCaps: TDDSCaps; // Was TDDSCaps ddsCaps. ddsCaps is of type DDSCAPS2 for DX6
dwMinOverlayStretch: DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxOverlayStretch: DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMinLiveVideoStretch: DWORD; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
468,16 → 558,16
dwSVBCaps: DWORD; // driver specific capabilities for System->Vmem blts
dwSVBCKeyCaps: DWORD; // driver color key capabilities for System->Vmem blts
dwSVBFXCaps: DWORD; // driver FX capabilities for System->Vmem blts
dwSVBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts
dwSVBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts
dwVSBCaps: DWORD; // driver specific capabilities for Vmem->System blts
dwVSBCKeyCaps: DWORD; // driver color key capabilities for Vmem->System blts
dwVSBFXCaps: DWORD; // driver FX capabilities for Vmem->System blts
dwVSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts
dwVSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts
dwSSBCaps: DWORD; // driver specific capabilities for System->System blts
dwSSBCKeyCaps: DWORD; // driver color key capabilities for System->System blts
dwSSBFXCaps: DWORD; // driver FX capabilities for System->System blts
dwSSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts
// Members added for DX5:
dwSSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts
{ Members added for DX5 }
dwMaxVideoPorts: DWORD; // maximum number of usable video ports
dwCurrVideoPorts: DWORD; // current number of video ports used
dwSVBCaps2: DWORD; // more driver specific capabilities for System->Vmem blts
485,48 → 575,40
dwNLVBCaps2: DWORD; // more driver specific capabilities non-local->local vidmem blts
dwNLVBCKeyCaps: DWORD; // driver color key capabilities for non-local->local vidmem blts
dwNLVBFXCaps: DWORD; // driver FX capabilities for non-local->local blts
dwNLVBRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported for non-local->local blts
// Members added for DX6 release
dwNLVBRops: array[0..DD_ROP_SPACE-1] of DWORD; // ROPS supported for non-local->local blts
{ Members added for DX6 }
ddsCaps : TDDSCaps2 ; // Surface Caps
end;
 
TDDCaps_DX7 = TDDCaps_DX6;
PDDCaps = ^TDDCaps;
 
{$IFDEF DIRECTX3}
{$IFDEF DirectX1}
TDDCaps = TDDCaps_DX1;
PDDCaps = PDDCaps_DX1;
{$ENDIF}{$IFDEF DirectX3}
TDDCaps = TDDCaps_DX3;
{$ELSE}
{$IFDEF DIRECTX5}
PDDCaps = PDDCaps_DX3;
{$ENDIF}{$IFDEF DirectX5}
TDDCaps = TDDCaps_DX5;
{$ELSE}
{$IFDEF DIRECTX6}
PDDCaps = PDDCaps_DX5;
{$ENDIF}{$IFDEF DirectX6}
TDDCaps = TDDCaps_DX6;
{$ELSE}
PDDCaps = PDDCaps_DX6;
{$ENDIF}{$IFDEF DirectX7}
TDDCaps = TDDCaps_DX7;
PDDCaps = PDDCaps_DX7;
{$ENDIF}
{$ENDIF}
{$ENDIF}
 
DDCAPS = TDDCaps;
LPDDCAPS = PDDCaps;
 
{ TDDPixelFormat structure }
 
 
(*
* TDDPixelFormat
*)
PDDPixelFormat_DX5 = ^TDDPixelFormat_DX5;
TDDPixelFormat_DX5 = packed record
PDDPixelFormat = ^TDDPixelFormat;
TDDPixelFormat = record
dwSize: DWORD; // size of structure
dwFlags: DWORD; // pixel format flags
dwFourCC: DWORD; // (FOURCC code)
case Integer of
0: (
dwZBufferBitDepth: DWORD; // how many bits for z buffers
);
1: (
dwAlphaBitDepth: DWORD; // how many bits for alpha channels
);
2: (
dwRGBBitCount: DWORD; // how many bits per pixel
dwRBitMask: DWORD; // mask for red bit
dwGBitMask: DWORD; // mask for green bits
533,38 → 615,14
dwBBitMask: DWORD; // mask for blue bits
dwRGBAlphaBitMask: DWORD; // mask for alpha channel
);
3: (
dwYUVBitCount: DWORD; // how many bits per pixel
dwYBitMask: DWORD; // mask for Y bits
dwUBitMask: DWORD; // mask for U bits
dwVBitMask: DWORD; // mask for V bits
case Integer of
0: (
dwYUVAlphaBitMask: DWORD; // mask for alpha channel
);
1: (
dwRGBZBitMask: DWORD;
_union1a: DWORD;
_union1b: DWORD;
_union1c: DWORD;
_union1d: DWORD;
dwRGBZBitMask: DWORD; // mask for Z channel
);
2: (
dwYUVZBitMask: DWORD;
);
);
end;
 
PDDPixelFormat_DX6 = ^TDDPixelFormat_DX6;
TDDPixelFormat_DX6 = packed record
dwSize: DWORD; // size of structure
dwFlags: DWORD; // pixel format flags
dwFourCC: DWORD; // (FOURCC code)
case Integer of
1: (
dwRGBBitCount : DWORD; // how many bits per pixel
dwRBitMask : DWORD; // mask for red bit
dwGBitMask : DWORD; // mask for green bits
dwBBitMask : DWORD; // mask for blue bits
dwRGBAlphaBitMask : DWORD; // mask for alpha channel
);
2: (
dwYUVBitCount : DWORD; // how many bits per pixel
dwYBitMask : DWORD; // mask for Y bits
dwUBitMask : DWORD; // mask for U bits
572,52 → 630,43
dwYUVAlphaBitMask : DWORD; // mask for alpha channel
);
3: (
dwZBufferBitDepth : DWORD; // how many total bits/pixel in z buffer (including any stencil bits)
_union3a: DWORD;
_union3b: DWORD;
_union3c: DWORD;
_union3d: DWORD;
dwYUVZBitMask: DWORD; // mask for Z channel
);
4: (
dwZBufferBitDepth: DWORD; // how many bits for z buffers
dwStencilBitDepth : DWORD; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits)
dwZBitMask : DWORD; // mask for Z bits
dwStencilBitMask : DWORD; // mask for stencil bits
dwLuminanceAlphaBitMask : DWORD;// mask for alpha channel
);
4: (
5: (
dwAlphaBitDepth : DWORD; // how many bits for alpha channels
);
6: (
dwLuminanceBitCount: DWORD; // how many bits per pixel
dwLuminanceBitMask : DWORD; // mask for luminance bits
_union6c: DWORD;
_union6d: DWORD;
dwLuminanceAlphaBitMask: DWORD;
);
7: (
dwBumpBitCount: DWORD; // how many bits per "buxel", total
dwBumpDuBitMask: DWORD; // mask for bump map U delta bits
dwBumpDvBitMask : DWORD; // mask for bump map V delta bits
dwBumpLuminanceBitMask : DWORD; // mask for luminance in bump map
dwRGBZBitMask : DWORD; // mask for Z channel
);
5: (
dwLuminanceBitCount : DWORD; // how many bits per pixel
dwBumpDuBitMask : DWORD; // mask for bump map U delta bits
Fill1, Fill2 : DWORD;
dwYUVZBitMask : DWORD; // mask for Z channel
);
6: ( dwBumpBitCount : DWORD; // how many bits per "buxel", total
);
end;
 
TDDPixelFormat_DX3 = TDDPixelFormat_DX5;
TDDPixelFormat_DX7 = TDDPixelFormat_DX6;
DDPIXELFORMAT = TDDPixelFormat;
LPDDPIXELFORMAT = PDDPixelFormat;
 
PDDPixelFormat = ^TDDPixelFormat;
{$IFDEF DIRECTX3}
TDDPixelFormat = TDDPixelFormat_DX3;
{$ELSE}
{$IFDEF DIRECTX5}
TDDPixelFormat = TDDPixelFormat_DX5;
{$ELSE}
{$IFDEF DIRECTX6}
TDDPixelFormat = TDDPixelFormat_DX6;
{$ELSE}
TDDPixelFormat = TDDPixelFormat_DX7;
{$ENDIF}
{$ENDIF}
{$ENDIF}
{ DDOVERLAYFX structure }
 
(*
* TDDOverlayFX
*)
PDDOverlayFX = ^TDDOverlayFX;
TDDOverlayFX = packed record
PDDOverlayFx = ^TDDOverlayFx;
TDDOverlayFx = record
dwSize: DWORD; // size of structure
dwAlphaEdgeBlendBitDepth: DWORD; // Bit depth used to specify constant for alpha edge blend
dwAlphaEdgeBlend: DWORD; // Constant to use as alpha for edge blend
634,40 → 683,157
dwFlags: DWORD; // flags
);
1: (
lpDDSAlphaDest: PDirectDrawSurface; // Surface to use as alpha channel for dest
filler: DWORD;
lpDDSAlphaSrc: PDirectDrawSurface; // Surface to use as alpha channel for src
lpDDSAlphaDest: Pointer{IDirectDrawSurface}; // Surface to use as alpha channel for dest
_union1b: DWORD;
lpDDSAlphaSrc: Pointer{IDirectDrawSurface}; // Surface to use as alpha channel for src
);
end;
 
(*
* TDDBltBatch: BltBatch entry structure
*)
DDOVERLAYFX = TDDOverlayFx;
LPDDOVERLAYFX = PDDOverlayFx;
 
{ TDDBltBatch structure }
 
PDDBltBatch = ^TDDBltBatch;
TDDBltBatch = packed record
TDDBltBatch = record
lprDest: PRect;
lpDDSSrc: IDirectDrawSurface;
lprSrc: PRect;
dwFlags: DWORD;
lpDDBltFx: TDDBltFX;
lpDDBltFx: PDDBltFX;
end;
 
(*
* TDDGammaRamp
*)
DDBLTBATCH = TDDBltBatch;
LPDDBLTBATCH = PDDBltBatch;
 
{ TDDSurfaceDesc structure }
 
PDDSurfaceDesc = ^TDDSurfaceDesc;
TDDSurfaceDesc = record
dwSize: DWORD; // size of the TDDSurfaceDesc structure
dwFlags: DWORD; // determines what fields are valid
dwHeight: DWORD; // height of surface to be created
dwWidth: DWORD; // width of input surface
case Integer of
0: (
lPitch: Longint;
dwBackBufferCount: DWORD; // number of back buffers requested
case Integer of
0: (
dwMipMapCount: DWORD; // number of mip-map levels requested
dwAlphaBitDepth: DWORD; // depth of alpha buffer requested
dwReserved: DWORD; // reserved
lpSurface: Pointer; // pointer to the associated surface memory
ddckCKDestOverlay: TDDColorKey;// color key for destination overlay use
ddckCKDestBlt: TDDColorKey; // color key for destination blt use
ddckCKSrcOverlay: TDDColorKey; // color key for source overlay use
ddckCKSrcBlt: TDDColorKey; // color key for source blt use
ddpfPixelFormat: TDDPixelFormat;// pixel format description of the surface
ddsCaps: TDDSCaps; // direct draw surface capabilities
);
1: (
dwZBufferBitDepth: DWORD; // depth of Z buffer requested
);
2: (
dwRefreshRate: DWORD; // refresh rate (used when display mode is described)
);
);
1: (
dwLinearSize: DWORD
);
end;
 
DDSURFACEDESC = TDDSurfaceDesc;
LPDDSURFACEDESC = PDDSurfaceDesc;
 
{ TDDSurfaceDesc2 structure }
 
PDDSurfaceDesc2 = ^TDDSurfaceDesc2;
TDDSurfaceDesc2 = record
dwSize: DWORD; // size of the TDDSurfaceDesc2 structure
dwFlags: DWORD; // determines what fields are valid
dwHeight: DWORD; // height of surface to be created
dwWidth: DWORD; // width of input surface
case Integer of
0: (
lPitch: Longint;
dwBackBufferCount: DWORD; // number of back buffers requested
case Integer of
0: (
dwMipMapCount: DWORD; // number of mip-map levels requested
dwAlphaBitDepth: DWORD; // depth of alpha buffer requested
dwReserved: DWORD; // reserved
lpSurface: Pointer; // pointer to the associated surface memory
ddckCKDestOverlay: TDDColorKey;// color key for destination overlay use
ddckCKDestBlt: TDDColorKey; // color key for destination blt use
ddckCKSrcOverlay: TDDColorKey; // color key for source overlay use
ddckCKSrcBlt: TDDColorKey; // color key for source blt use
ddpfPixelFormat: TDDPixelFormat;// pixel format description of the surface
ddsCaps: TDDSCaps2; // direct draw surface capabilities
dwTextureStage: DWORD; // stage in multitexture cascade
);
1: (
dwRefreshRate: DWORD; // refresh rate (used when display mode is described)
);
);
1: (
dwLinearSize: DWORD
);
end;
 
DDSURFACEDESC2 = TDDSurfaceDesc2;
LPDDSURFACEDESC2 = PDDSurfaceDesc2;
 
{ TDDOptSurfaceDesc structure }
 
PDDOptSurfaceDesc = ^TDDOptSurfaceDesc;
TDDOptSurfaceDesc = record
dwSize: DWORD; // size of the DDOPTSURFACEDESC structure
dwFlags: DWORD; // determines what fields are valid
ddSCaps: TDDSCaps2; // Common caps like: Memory type
ddOSCaps: TDDOSCaps; // Common caps like: Memory type
guid: TGUID; // Compression technique GUID
dwCompressionRatio: DWORD; // Compression ratio
end;
 
DDOPTSURFACEDESC = TDDOptSurfaceDesc;
LPDDOPTSURFACEDESC = PDDOptSurfaceDesc;
 
{ TDDColorControl structure }
 
PDDColorControl = ^TDDColorControl;
TDDColorControl = record
dwSize: DWORD;
dwFlags: DWORD;
lBrightness: Longint;
lContrast: Longint;
lHue: Longint;
lSaturation: Longint;
lSharpness: Longint;
lGamma: Longint;
lColorEnable: Longint;
dwReserved1: DWORD;
end;
 
DDCOLORCONTROL = TDDColorControl;
LPDDCOLORCONTROL = PDDCOLORCONTROL;
 
{ TDDGammaRamp structure }
 
PDDGammaRamp = ^TDDGammaRamp;
TDDGammaRamp = packed record
red : array[0..255] of WORD;
green : array[0..255] of WORD;
blue : array[0..255] of WORD;
TDDGammaRamp = record
Red: array[0..255] of Word;
Green: array[0..255] of Word;
Blue: array[0..255] of Word;
end;
 
(*
* This is the structure within which DirectDraw returns data about the current graphics driver and chipset
*)
DDGAMMARAMP = TDDGammaRamp;
LPDDGAMMARAMP = PDDGammaRamp;
 
{ TDDDeviceIdentifier structure }
 
PDDDeviceIdentifier = ^TDDDeviceIdentifier;
TDDDeviceIdentifier = packed record
TDDDeviceIdentifier = record
//
// These elements are for presentation to the user only. They should not be used to identify particular
// drivers, since this is unreliable and many different strings may be associated with the same
710,8 → 876,13
guidDeviceIdentifier: TGUID;
end;
 
DDDEVICEIDENTIFIER = TDDDeviceIdentifier;
LPDDDEVICEIDENTIFIER = PDDDeviceIdentifier;
 
{ TDDDeviceIdentifier2 structure }
 
PDDDeviceIdentifier2 = ^TDDDeviceIdentifier2;
TDDDeviceIdentifier2 = packed record
TDDDeviceIdentifier2 = record
//
// These elements are for presentation to the user only. They should not be used to identify particular
// drivers, since this is unreliable and many different strings may be associated with the same
753,432 → 924,247
//
guidDeviceIdentifier: TGUID;
 
(*
* This element is used to determine the Windows Hardware Quality Lab (WHQL)
* certification level for this driver/device pair.
*)
//
// This element is used to determine the Windows Hardware Quality Lab (WHQL)
// certification level for this driver/device pair.
//
dwWHQLLevel: DWORD;
end;
 
(*
* callbacks
*)
DDDEVICEIDENTIFIER2 = TDDDeviceIdentifier2;
LPDDDEVICEIDENTIFIER2 = PDDDeviceIdentifier2;
 
{ Callbacks }
 
TClipperCallback = function(lpDDClipper: IDirectDrawClipper; hWnd: HWND;
Code: DWORD; lpContext: Pointer): HResult; stdcall;
LPCLIPPERCALLBACK = TClipperCallback;
 
TSurfacesStreamingCallback = function(Arg: DWORD): HResult; stdcall;
LPSURFACESTREAMINGCALLBACK =TSurfacesStreamingCallback;
 
(*
* TDDSurfaceDesc
*)
PDDSurfaceDesc_DX5 = ^TDDSurfaceDesc_DX5;
TDDSurfaceDesc_DX5 = packed record
dwSize: DWORD; // size of the TDDSurfaceDesc structure
dwFlags: DWORD; // determines what fields are valid
dwHeight: DWORD; // height of surface to be created
dwWidth: DWORD; // width of input surface
case Integer of
0: (
dwLinearSize : DWORD; // unused at the moment
);
1: (
lPitch: LongInt; // distance to start of next line (return value only)
dwBackBufferCount: DWORD; // number of back buffers requested
case Integer of
0: (
dwMipMapCount: DWORD; // number of mip-map levels requested
dwAlphaBitDepth: DWORD; // depth of alpha buffer requested
dwReserved: DWORD; // reserved
lpSurface: Pointer; // pointer to the associated surface memory
ddckCKDestOverlay: TDDColorKey; // color key for destination overlay use
ddckCKDestBlt: TDDColorKey; // color key for destination blt use
ddckCKSrcOverlay: TDDColorKey; // color key for source overlay use
ddckCKSrcBlt: TDDColorKey; // color key for source blt use
ddpfPixelFormat: TDDPixelFormat_DX5; // pixel format description of the surface
ddsCaps: TDDSCaps; // direct draw surface capabilities
);
1: (
dwZBufferBitDepth: DWORD; // depth of Z buffer requested
);
2: (
dwRefreshRate: DWORD; // refresh rate (used when display mode is described)
);
);
end;
 
PDDSurfaceDesc_DX6 = ^TDDSurfaceDesc_DX6;
TDDSurfaceDesc_DX6 = packed record
dwSize: DWORD; // size of the TDDSurfaceDesc structure
dwFlags: DWORD; // determines what fields are valid
dwHeight: DWORD; // height of surface to be created
dwWidth: DWORD; // width of input surface
case Integer of
0: (
dwLinearSize : DWORD; // unused at the moment
);
1: (
lPitch: LongInt; // distance to start of next line (return value only)
dwBackBufferCount: DWORD; // number of back buffers requested
case Integer of
0: (
dwMipMapCount: DWORD; // number of mip-map levels requested
dwAlphaBitDepth: DWORD; // depth of alpha buffer requested
dwReserved: DWORD; // reserved
lpSurface: Pointer; // pointer to the associated surface memory
ddckCKDestOverlay: TDDColorKey; // color key for destination overlay use
ddckCKDestBlt: TDDColorKey; // color key for destination blt use
ddckCKSrcOverlay: TDDColorKey; // color key for source overlay use
ddckCKSrcBlt: TDDColorKey; // color key for source blt use
ddpfPixelFormat: TDDPixelFormat_DX6; // pixel format description of the surface
ddsCaps: TDDSCaps; // direct draw surface capabilities
);
1: (
dwZBufferBitDepth: DWORD; // depth of Z buffer requested
);
2: (
dwRefreshRate: DWORD; // refresh rate (used when display mode is described)
);
);
end;
 
PDDSurfaceDesc = ^TDDSurfaceDesc;
{$IFDEF DIRECTX5}
TDDSurfaceDesc = TDDSurfaceDesc_DX5;
{$ELSE}
TDDSurfaceDesc = TDDSurfaceDesc_DX6;
{$ENDIF}
 
 
(*
* TDDSurfaceDesc2
*)
PDDSurfaceDesc2 = ^TDDSurfaceDesc2;
TDDSurfaceDesc2 = packed record
dwSize: DWORD; // size of the TDDSurfaceDesc structure
dwFlags: DWORD; // determines what fields are valid
dwHeight: DWORD; // height of surface to be created
dwWidth: DWORD; // width of input surface
case Integer of
0: (
lPitch : LongInt; // distance to start of next line (return value only)
);
1: (
dwLinearSize : DWORD; // Formless late-allocated optimized surface size
dwBackBufferCount: DWORD; // number of back buffers requested
case Integer of
0: (
dwMipMapCount: DWORD; // number of mip-map levels requested
dwAlphaBitDepth: DWORD; // depth of alpha buffer requested
dwReserved: DWORD; // reserved
lpSurface: Pointer; // pointer to the associated surface memory
ddckCKDestOverlay: TDDColorKey; // color key for destination overlay use
ddckCKDestBlt: TDDColorKey; // color key for destination blt use
ddckCKSrcOverlay: TDDColorKey; // color key for source overlay use
ddckCKSrcBlt: TDDColorKey; // color key for source blt use
ddpfPixelFormat: TDDPixelFormat; // pixel format description of the surface
ddsCaps: TDDSCaps2; // direct draw surface capabilities
dwTextureStage: DWORD; // stage in multitexture cascade
);
1: (
dwRefreshRate: DWORD; // refresh rate (used when display mode is described)
);
);
end;
 
(*
* TDDOptSurfaceDesc
*)
 
PDDOptSurfaceDesc = ^TDDOptSurfaceDesc;
TDDOptSurfaceDesc = packed record
dwSize : DWORD; // size of the DDOPTSURFACEDESC structure
dwFlags : DWORD; // determines what fields are valid
ddSCaps : TDDSCaps2; // Common caps like: Memory type
ddOSCaps : TDDOSCaps; // Common caps like: Memory type
guid : TGUID; // Compression technique GUID
dwCompressionRatio : DWORD; // Compression ratio
end;
 
(*
* DDCOLORCONTROL
*)
PDDColorControl = ^TDDColorControl;
TDDColorControl = packed record
dwSize: DWORD;
dwFlags: DWORD;
lBrightness: LongInt;
lContrast: LongInt;
lHue: LongInt;
lSaturation: LongInt;
lSharpness: LongInt;
lGamma: LongInt;
lColorEnable: LongInt;
dwReserved1: DWORD;
end;
 
(*
* callbacks
*)
 
{$IFNDEF WINNT}
TDDEnumModesCallback = function (const lpDDSurfaceDesc: TDDSurfaceDesc;
lpContext: Pointer) : HResult; stdcall;
LPDDENUMMODESCALLBACK = TDDEnumModesCallback;
 
TDDEnumModesCallback2 = function (const lpDDSurfaceDesc: TDDSurfaceDesc2;
lpContext: Pointer) : HResult; stdcall;
LPDDENUMMODESCALLBACK2 = TDDEnumModesCallback2;
 
TDDEnumSurfacesCallback = function (lpDDSurface: IDirectDrawSurface;
const lpDDSurfaceDesc: TDDSurfaceDesc; lpContext: Pointer) : HResult; stdcall;
LPDDENUMSURFACESCALLBACK = TDDEnumSurfacesCallback;
 
TDDEnumSurfacesCallback2 = function (lpDDSurface: IDirectDrawSurface4;
const lpDDSurfaceDesc: TDDSurfaceDesc2; lpContext: Pointer) : HResult; stdcall;
LPDDENUMSURFACESCALLBACK2 = TDDEnumSurfacesCallback2;
 
TDDEnumSurfacesCallback7 = function (lpDDSurface: IDirectDrawSurface7;
const lpDDSurfaceDesc: TDDSurfaceDesc2; lpContext: Pointer) : HResult; stdcall;
{$ENDIF}
LPDDENUMSURFACESCALLBACK7 = TDDEnumSurfacesCallback7;
 
(*
* INTERACES FOLLOW:
* IDirectDraw
* IDirectDrawClipper
* IDirectDrawPalette
* IDirectDrawSurface
*)
{ IDirectDraw Interface }
 
(*
* IDirectDraw
*)
 
IDirectDraw = interface (IUnknown)
['{6C14DB80-A733-11CE-A521-0020AF0BE560}']
(*** IDirectDraw methods ***)
// IDirectDraw methods
function Compact: HResult; stdcall;
function CreateClipper (dwFlags: DWORD;
out lplpDDClipper: IDirectDrawClipper;
function CreateClipper(dwFlags: DWORD; out lplpDDClipper: IDirectDrawClipper;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreatePalette (dwFlags: DWORD; lpColorTable: pointer;
out lplpDDPalette: IDirectDrawPalette;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreateSurface (var lpDDSurfaceDesc: TDDSurfaceDesc;
out lplpDDSurface: IDirectDrawSurface;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreatePalette(dwFlags: DWORD; lpColorTable: PPaletteEntry;
out lplpDDPalette: IDirectDrawPalette; pUnkOuter: IUnknown): HResult; stdcall;
function CreateSurface(const lpDDSurfaceDesc: TDDSurfaceDesc;
out lplpDDSurface: IDirectDrawSurface; pUnkOuter: IUnknown): HResult; stdcall;
function DuplicateSurface (lpDDSurface: IDirectDrawSurface;
out lplpDupDDSurface: IDirectDrawSurface) : HResult; stdcall;
function EnumDisplayModes (dwFlags: DWORD;
lpDDSurfaceDesc: PDDSurfaceDesc; lpContext: Pointer;
const lpDDSurfaceDesc: TDDSurfaceDesc; lpContext: Pointer;
lpEnumModesCallback: TDDEnumModesCallback) : HResult; stdcall;
function EnumSurfaces (dwFlags: DWORD; const lpDDSD: TDDSurfaceDesc;
lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback) :
HResult; stdcall;
lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback): HResult; stdcall;
function FlipToGDISurface: HResult; stdcall;
function GetCaps (lpDDDriverCaps: PDDCaps; lpDDHELCaps: PDDCaps) : HResult; stdcall;
function GetDisplayMode (out lpDDSurfaceDesc: TDDSurfaceDesc) : HResult; stdcall;
function GetFourCCCodes (var lpNumCodes: DWORD; lpCodes: PDWORD) : HResult; stdcall;
function GetGDISurface (out lplpGDIDDSSurface: IDirectDrawSurface) :
HResult; stdcall;
function GetMonitorFrequency (out lpdwFrequency: DWORD) : HResult; stdcall;
function GetScanLine (out lpdwScanLine: DWORD) : HResult; stdcall;
function GetVerticalBlankStatus (out lpbIsInVB: BOOL) : HResult; stdcall;
function GetCaps(var lpDDDriverCaps: TDDCaps; var lpDDHELCaps: TDDCaps): HResult; stdcall;
function GetDisplayMode(var lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall;
function GetFourCCCodes(var lpNumCodes, lpCodes: DWORD): HResult; stdcall;
function GetGDISurface(out lplpGDIDDSSurface: IDirectDrawSurface): HResult; stdcall;
function GetMonitorFrequency(var lpdwFrequency: DWORD): HResult; stdcall;
function GetScanLine(var lpdwScanLine: DWORD): HResult; stdcall;
function GetVerticalBlankStatus(var lpbIsInVB: BOOL): HResult; stdcall;
function Initialize (lpGUID: PGUID) : HResult; stdcall;
function RestoreDisplayMode: HResult; stdcall;
function SetCooperativeLevel (hWnd: HWND; dwFlags: DWORD) : HResult; stdcall;
(*** Warning! SetDisplayMode differs between DirectDraw 1 and DirectDraw 2 ***)
function SetDisplayMode (dwWidth: DWORD; dwHeight: DWORD;
dwBpp: DWORD) : HResult; stdcall;
function WaitForVerticalBlank (dwFlags: DWORD; hEvent: THandle) :
HResult; stdcall;
function SetDisplayMode(dwWidth, dwHeight, dwBpp: DWORD): HResult; stdcall;
function WaitForVerticalBlank(dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
end;
 
{ IDirectDraw2 Interface }
 
IDirectDraw2 = interface (IUnknown)
['{B3A6F3E0-2B43-11CF-A2DE-00AA00B93356}']
(*** IDirectDraw methods ***)
// IDirectDraw methods
function Compact: HResult; stdcall;
function CreateClipper (dwFlags: DWORD;
out lplpDDClipper: IDirectDrawClipper;
function CreateClipper(dwFlags: DWORD; out lplpDDClipper: IDirectDrawClipper;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreatePalette (dwFlags: DWORD; lpColorTable: pointer;
out lplpDDPalette: IDirectDrawPalette;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreateSurface (var lpDDSurfaceDesc: TDDSurfaceDesc;
out lplpDDSurface: IDirectDrawSurface;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreatePalette(dwFlags: DWORD; lpColorTable: PPaletteEntry;
out lplpDDPalette: IDirectDrawPalette; pUnkOuter: IUnknown): HResult; stdcall;
function CreateSurface(const lpDDSurfaceDesc: TDDSurfaceDesc;
out lplpDDSurface: IDirectDrawSurface; pUnkOuter: IUnknown): HResult; stdcall;
function DuplicateSurface (lpDDSurface: IDirectDrawSurface;
out lplpDupDDSurface: IDirectDrawSurface) : HResult; stdcall;
function EnumDisplayModes (dwFlags: DWORD;
lpDDSurfaceDesc: PDDSurfaceDesc; lpContext: Pointer;
const lpDDSurfaceDesc: TDDSurfaceDesc; lpContext: Pointer;
lpEnumModesCallback: TDDEnumModesCallback) : HResult; stdcall;
function EnumSurfaces (dwFlags: DWORD; var lpDDSD: TDDSurfaceDesc;
lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback) :
HResult; stdcall;
function EnumSurfaces(dwFlags: DWORD; const lpDDSD: TDDSurfaceDesc;
lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback): HResult; stdcall;
function FlipToGDISurface: HResult; stdcall;
function GetCaps (lpDDDriverCaps: PDDCaps; lpDDHELCaps: PDDCaps) : HResult; stdcall;
function GetDisplayMode (out lpDDSurfaceDesc: TDDSurfaceDesc) : HResult; stdcall;
function GetFourCCCodes (var lpNumCodes: DWORD; lpCodes: PDWORD) : HResult; stdcall;
function GetCaps(var lpDDDriverCaps: TDDCaps; var lpDDHELCaps: TDDCaps): HResult; stdcall;
function GetDisplayMode(var lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall;
function GetFourCCCodes(var lpNumCodes, lpCodes: DWORD): HResult; stdcall;
function GetGDISurface (out lplpGDIDDSSurface: IDirectDrawSurface) : HResult; stdcall;
function GetMonitorFrequency (out lpdwFrequency: DWORD) : HResult; stdcall;
function GetScanLine (out lpdwScanLine: DWORD) : HResult; stdcall;
function GetVerticalBlankStatus (out lpbIsInVB: BOOL) : HResult; stdcall;
function GetMonitorFrequency(var lpdwFrequency: DWORD): HResult; stdcall;
function GetScanLine(var lpdwScanLine: DWORD): HResult; stdcall;
function GetVerticalBlankStatus(var lpbIsInVB: BOOL): HResult; stdcall;
function Initialize (lpGUID: PGUID) : HResult; stdcall;
function RestoreDisplayMode: HResult; stdcall;
function SetCooperativeLevel (hWnd: HWND; dwFlags: DWORD) : HResult; stdcall;
(*** Warning! SetDisplayMode differs between DirectDraw 1 and DirectDraw 2 ***)
function SetDisplayMode (dwWidth: DWORD; dwHeight: DWORD; dwBPP: DWORD;
dwRefreshRate: DWORD; dwFlags: DWORD) : HResult; stdcall;
function WaitForVerticalBlank (dwFlags: DWORD; hEvent: THandle) :
HResult; stdcall;
(*** Added in the v2 interface ***)
function SetDisplayMode(dwWidth, dwHeight, dwBPP, dwRefreshRate: DWORD;
dwFlags: DWORD): HResult; stdcall;
function WaitForVerticalBlank(dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
// IDirectDraw2 methods
function GetAvailableVidMem (var lpDDSCaps: TDDSCaps;
out lpdwTotal, lpdwFree: DWORD) : HResult; stdcall;
var lpdwTotal, lpdwFree: DWORD): HResult; stdcall;
end;
 
{ IDirectDraw4 Interface }
 
IDirectDraw4 = interface (IUnknown)
['{9c59509a-39bd-11d1-8c4a-00c04fd930c5}']
(*** IDirectDraw methods ***)
['{9C59509A-39BD-11D1-8C4A-00C04FD930C5}']
// IDirectDraw methods
function Compact: HResult; stdcall;
function CreateClipper (dwFlags: DWORD;
out lplpDDClipper: IDirectDrawClipper;
function CreateClipper(dwFlags: DWORD; out lplpDDClipper: IDirectDrawClipper;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreatePalette (dwFlags: DWORD; lpColorTable: pointer;
out lplpDDPalette: IDirectDrawPalette;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreatePalette(dwFlags: DWORD; lpColorTable: PPaletteEntry;
out lplpDDPalette: IDirectDrawPalette; pUnkOuter: IUnknown): HResult; stdcall;
function CreateSurface (const lpDDSurfaceDesc: TDDSurfaceDesc2;
out lplpDDSurface: IDirectDrawSurface4;
pUnkOuter: IUnknown) : HResult; stdcall;
out lplpDDSurface: IDirectDrawSurface4; pUnkOuter: IUnknown): HResult; stdcall;
function DuplicateSurface (lpDDSurface: IDirectDrawSurface4;
out lplpDupDDSurface: IDirectDrawSurface4) : HResult; stdcall;
function EnumDisplayModes (dwFlags: DWORD;
lpDDSurfaceDesc: PDDSurfaceDesc2; lpContext: Pointer;
const lpDDSurfaceDesc: TDDSurfaceDesc2; lpContext: Pointer;
lpEnumModesCallback: TDDEnumModesCallback2) : HResult; stdcall;
function EnumSurfaces (dwFlags: DWORD; const lpDDSD: TDDSurfaceDesc2;
lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback2) :
HResult; stdcall;
lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback2): HResult; stdcall;
function FlipToGDISurface: HResult; stdcall;
function GetCaps (lpDDDriverCaps: PDDCaps; lpDDHELCaps: PDDCaps) : HResult; stdcall;
function GetDisplayMode (out lpDDSurfaceDesc: TDDSurfaceDesc2) : HResult; stdcall;
function GetFourCCCodes (var lpNumCodes: DWORD; lpCodes: PDWORD) : HResult; stdcall;
function GetGDISurface (out lplpGDIDDSSurface: IDirectDrawSurface4) :
HResult; stdcall;
function GetMonitorFrequency (out lpdwFrequency: DWORD) : HResult; stdcall;
function GetScanLine (out lpdwScanLine: DWORD) : HResult; stdcall;
function GetVerticalBlankStatus (out lpbIsInVB: BOOL) : HResult; stdcall;
function GetCaps(var lpDDDriverCaps: TDDCaps; var lpDDHELCaps: TDDCaps): HResult; stdcall;
function GetDisplayMode(var lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall;
function GetFourCCCodes(var lpNumCodes, lpCodes: DWORD): HResult; stdcall;
function GetGDISurface(out lplpGDIDDSSurface: IDirectDrawSurface2): HResult; stdcall;
function GetMonitorFrequency(var lpdwFrequency: DWORD): HResult; stdcall;
function GetScanLine(var lpdwScanLine: DWORD): HResult; stdcall;
function GetVerticalBlankStatus(var lpbIsInVB: BOOL): HResult; stdcall;
function Initialize (lpGUID: PGUID) : HResult; stdcall;
function RestoreDisplayMode: HResult; stdcall;
function SetCooperativeLevel (hWnd: HWND; dwFlags: DWORD) : HResult; stdcall;
(*** Warning! SetDisplayMode differs between DirectDraw 1 and DirectDraw 2 ***)
function SetDisplayMode (dwWidth: DWORD; dwHeight: DWORD; dwBPP: DWORD;
dwRefreshRate: DWORD; dwFlags: DWORD) : HResult; stdcall;
function WaitForVerticalBlank (dwFlags: DWORD; hEvent: THandle) :
HResult; stdcall;
(*** Added in the v2 interface ***)
function GetAvailableVidMem (const lpDDSCaps: TDDSCaps2;
out lpdwTotal, lpdwFree: DWORD) : HResult; stdcall;
(*** Added in the V4 Interface ***)
function GetSurfaceFromDC (hdc : Windows.HDC;
out lpDDS4: IDirectDrawSurface4) : HResult; stdcall;
function SetDisplayMode(dwWidth, dwHeight, dwBPP, dwRefreshRate: DWORD;
dwFlags: DWORD): HResult; stdcall;
function WaitForVerticalBlank(dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
// IDirectDraw2 methods
function GetAvailableVidMem(var lpDDSCaps: TDDSCaps;
var lpdwTotal, lpdwFree: DWORD): HResult; stdcall;
// IDirectDraw4 methods
function GetSurfaceFromDC(hdc: HDC; lpDDS: IDirectDrawSurface4): HResult; stdcall;
function RestoreAllSurfaces : HResult; stdcall;
function TestCooperativeLevel : HResult; stdcall;
function GetDeviceIdentifier (out lpdddi: TDDDeviceIdentifier;
dwFlags: DWORD) : HResult; stdcall;
function GetDeviceIdentifier(var lpdddi: TDDDeviceIdentifier; dwFlags: DWORD): HResult; stdcall;
end;
 
{ IDirectDraw7 Interface }
 
IDirectDraw7 = interface (IUnknown)
['{15e65ec0-3b9c-11d2-b92f-00609797ea5b}']
(*** IDirectDraw methods ***)
['{15E65EC0-3B9C-11D2-B92F-00609797EA5B}']
// IDirectDraw methods
function Compact: HResult; stdcall;
function CreateClipper (dwFlags: DWORD;
out lplpDDClipper: IDirectDrawClipper;
function CreateClipper(dwFlags: DWORD; out lplpDDClipper: IDirectDrawClipper;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreatePalette (dwFlags: DWORD; lpColorTable: pointer;
out lplpDDPalette: IDirectDrawPalette;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreatePalette(dwFlags: DWORD; lpColorTable: PPaletteEntry;
out lplpDDPalette: IDirectDrawPalette; pUnkOuter: IUnknown): HResult; stdcall;
function CreateSurface (const lpDDSurfaceDesc: TDDSurfaceDesc2;
out lplpDDSurface: IDirectDrawSurface7;
pUnkOuter: IUnknown) : HResult; stdcall;
out lplpDDSurface: IDirectDrawSurface7; pUnkOuter: IUnknown): HResult; stdcall;
function DuplicateSurface (lpDDSurface: IDirectDrawSurface7;
out lplpDupDDSurface: IDirectDrawSurface7) : HResult; stdcall;
function EnumDisplayModes (dwFlags: DWORD;
lpDDSurfaceDesc: PDDSurfaceDesc2; lpContext: Pointer;
const lpDDSurfaceDesc: TDDSurfaceDesc2; lpContext: Pointer;
lpEnumModesCallback: TDDEnumModesCallback2) : HResult; stdcall;
function EnumSurfaces (dwFlags: DWORD; const lpDDSD: TDDSurfaceDesc2;
lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback7) :
HResult; stdcall;
lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback7): HResult; stdcall;
function FlipToGDISurface: HResult; stdcall;
function GetCaps (lpDDDriverCaps: PDDCaps; lpDDHELCaps: PDDCaps) : HResult; stdcall;
function GetDisplayMode (out lpDDSurfaceDesc: TDDSurfaceDesc2) : HResult; stdcall;
function GetFourCCCodes (var lpNumCodes: DWORD; lpCodes: PDWORD) : HResult; stdcall;
function GetGDISurface (out lplpGDIDDSSurface: IDirectDrawSurface7) :
HResult; stdcall;
function GetMonitorFrequency (out lpdwFrequency: DWORD) : HResult; stdcall;
function GetScanLine (out lpdwScanLine: DWORD) : HResult; stdcall;
function GetVerticalBlankStatus (out lpbIsInVB: BOOL) : HResult; stdcall;
function GetCaps(var lpDDDriverCaps: TDDCaps; var lpDDHELCaps: TDDCaps): HResult; stdcall;
function GetDisplayMode(var lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall;
function GetFourCCCodes(var lpNumCodes, lpCodes: DWORD): HResult; stdcall;
function GetGDISurface(out lplpGDIDDSSurface: IDirectDrawSurface7): HResult; stdcall;
function GetMonitorFrequency(var lpdwFrequency: DWORD): HResult; stdcall;
function GetScanLine(var lpdwScanLine: DWORD): HResult; stdcall;
function GetVerticalBlankStatus(var lpbIsInVB: BOOL): HResult; stdcall;
function Initialize (lpGUID: PGUID) : HResult; stdcall;
function RestoreDisplayMode: HResult; stdcall;
function SetCooperativeLevel (hWnd: HWND; dwFlags: DWORD) : HResult; stdcall;
function SetDisplayMode (dwWidth: DWORD; dwHeight: DWORD; dwBPP: DWORD;
dwRefreshRate: DWORD; dwFlags: DWORD) : HResult; stdcall;
function WaitForVerticalBlank (dwFlags: DWORD; hEvent: THandle) :
HResult; stdcall;
(*** Added in the v2 interface ***)
function GetAvailableVidMem (const lpDDSCaps: TDDSCaps2;
out lpdwTotal, lpdwFree: DWORD) : HResult; stdcall;
(*** Added in the V4 Interface ***)
function GetSurfaceFromDC (hdc : Windows.HDC;
out lpDDS: IDirectDrawSurface7) : HResult; stdcall;
function SetDisplayMode(dwWidth, dwHeight, dwBPP, dwRefreshRate: DWORD;
dwFlags: DWORD): HResult; stdcall;
function WaitForVerticalBlank(dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
// IDirectDraw2 methods
function GetAvailableVidMem(var lpDDSCaps: TDDSCaps;
var lpdwTotal, lpdwFree: DWORD): HResult; stdcall;
// IDirectDraw4 methods
function GetSurfaceFromDC(hdc: HDC; lpDDS: IDirectDrawSurface4): HResult; stdcall;
function RestoreAllSurfaces : HResult; stdcall;
function TestCooperativeLevel : HResult; stdcall;
function GetDeviceIdentifier (out lpdddi: TDDDeviceIdentifier2;
dwFlags: DWORD) : HResult; stdcall;
function StartModeTest(const lpModesToTest; dwNumEntries, dwFlags: DWORD) : HResult; stdcall;
function EvaluateMode(dwFlags: DWORD; out pSecondsUntilTimeout: DWORD) : HResult; stdcall;
function GetDeviceIdentifier(var lpdddi: TDDDeviceIdentifier; dwFlags: DWORD): HResult; stdcall;
// IDirectDraw7 methods
function StartModeTest(var lpModesToTest: TSize; dwNumEntries: DWORD; dwFlags: DWORD): HResult; stdcall;
function EvaluateMode(dwFlags: DWORD; var pSecondsUntilTimeout: DWORD): HResult; stdcall;
end;
 
{ IDirectDrawPalette Interface }
 
 
(*
* IDirectDrawPalette
*)
 
IDirectDrawPalette = interface (IUnknown)
['{6C14DB84-A733-11CE-A521-0020AF0BE560}']
(*** IDirectDrawPalette methods ***)
function GetCaps (out lpdwCaps: DWORD) : HResult; stdcall;
// IDirectDrawPalette methods
function GetCaps(varlpdwCaps: DWORD): HResult; stdcall;
function GetEntries (dwFlags: DWORD; dwBase: DWORD; dwNumEntries: DWORD;
lpEntries: pointer) : HResult; stdcall;
lpEntries: PPaletteEntry): HResult; stdcall;
function Initialize (lpDD: IDirectDraw; dwFlags: DWORD;
lpDDColorTable: pointer) : HResult; stdcall;
lpDDColorTable: PPaletteEntry): HResult; stdcall;
function SetEntries (dwFlags: DWORD; dwStartingEntry: DWORD;
dwCount: DWORD; lpEntries: pointer) : HResult; stdcall;
dwCount: DWORD; lpEntries: PPaletteEntry): HResult; stdcall;
end;
 
(*
* IDirectDrawClipper
*)
{ IDirectDrawClipper Interface }
 
IDirectDrawClipper = interface (IUnknown)
['{6C14DB85-A733-11CE-A521-0020AF0BE560}']
(*** IDirectDrawClipper methods ***)
function GetClipList (lpRect: PRect; lpClipList: PRgnData;
// IDirectDrawClipper methods
function GetClipList(const lpRect: TRect; lpClipList: PRgnData;
var lpdwSize: DWORD) : HResult; stdcall;
function GetHWnd (out lphWnd: HWND) : HResult; stdcall;
function GetHWnd(var lphWnd: HWND): HResult; stdcall;
function Initialize (lpDD: IDirectDraw; dwFlags: DWORD) : HResult; stdcall;
function IsClipListChanged (out lpbChanged: BOOL) : HResult; stdcall;
function IsClipListChanged(var lpbChanged: BOOL): HResult; stdcall;
function SetClipList (lpClipList: PRgnData; dwFlags: DWORD) : HResult; stdcall;
function SetHWnd (dwFlags: DWORD; hWnd: HWND) : HResult; stdcall;
end;
 
(*
* IDirectDrawSurface and related interfaces
*)
{ IDirectDrawSurface Interface }
 
IDirectDrawSurface = interface (IUnknown)
['{6C14DB81-A733-11CE-A521-0020AF0BE560}']
(*** IDirectDrawSurface methods ***)
function AddAttachedSurface (lpDDSAttachedSurface: IDirectDrawSurface) :
HResult; stdcall;
// IDirectDrawSurface methods
function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface): HResult; stdcall;
function AddOverlayDirtyRect (const lpRect: TRect) : HResult; stdcall;
function Blt (lpDestRect: PRect;
lpDDSrcSurface: IDirectDrawSurface; lpSrcRect: PRect;
dwFlags: DWORD; lpDDBltFx: PDDBltFX) : HResult; stdcall;
function Blt(const lpDestRect: TRect; lpDDSrcSurface: IDirectDrawSurface;
const lpSrcRect: TRect; dwFlags: DWORD; const lpDDBltFx: TDDBltFX): HResult; stdcall;
function BltBatch (const lpDDBltBatch: TDDBltBatch; dwCount: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function BltFast (dwX: DWORD; dwY: DWORD;
lpDDSrcSurface: IDirectDrawSurface; lpSrcRect: PRect;
dwTrans: DWORD) : HResult; stdcall;
function BltFast(dwX, dwY: DWORD; lpDDSrcSurface: IDirectDrawSurface;
const lpSrcRect: TRect; dwTrans: DWORD): HResult; stdcall;
function DeleteAttachedSurface (dwFlags: DWORD;
lpDDSAttachedSurface: IDirectDrawSurface) : HResult; stdcall;
function EnumAttachedSurfaces (lpContext: Pointer;
1188,57 → 1174,50
function Flip (lpDDSurfaceTargetOverride: IDirectDrawSurface;
dwFlags: DWORD) : HResult; stdcall;
function GetAttachedSurface (var lpDDSCaps: TDDSCaps;
(*out*)var lplpDDAttachedSurface: IDirectDrawSurface) : HResult; stdcall;
out lplpDDAttachedSurface: IDirectDrawSurface): HResult; stdcall;
function GetBltStatus (dwFlags: DWORD) : HResult; stdcall;
function GetCaps (out lpDDSCaps: TDDSCaps) : HResult; stdcall;
function GetCaps(var lpDDSCaps: TDDSCaps): HResult; stdcall;
function GetClipper (out lplpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function GetColorKey (dwFlags: DWORD; out lpDDColorKey: TDDColorKey) :
HResult; stdcall;
function GetDC (out lphDC: HDC) : HResult; stdcall;
function GetColorKey(dwFlags: DWORD; var lpDDColorKey: TDDColorKey): HResult; stdcall;
function GetDC(var lphDC: HDC): HResult; stdcall;
function GetFlipStatus (dwFlags: DWORD) : HResult; stdcall;
function GetOverlayPosition (out lplX, lplY: LongInt) : HResult; stdcall;
function GetOverlayPosition(var lplX, lplY: Longint): HResult; stdcall;
function GetPalette (out lplpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function GetPixelFormat (out lpDDPixelFormat: TDDPixelFormat) : HResult; stdcall;
function GetSurfaceDesc (out lpDDSurfaceDesc: TDDSurfaceDesc) : HResult; stdcall;
function GetPixelFormat(var lpDDPixelFormat: TDDPixelFormat): HResult; stdcall;
function GetSurfaceDesc(var lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall;
function Initialize (lpDD: IDirectDraw;
out lpDDSurfaceDesc: TDDSurfaceDesc) : HResult; stdcall;
const lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall;
function IsLost: HResult; stdcall;
function Lock (lpDestRect: PRect; out lpDDSurfaceDesc:
TDDSurfaceDesc; dwFlags: DWORD; hEvent: THandle) : HResult; stdcall;
function ReleaseDC (hDC: Windows.HDC) : HResult; stdcall;
function _Restore: HResult; stdcall;
function Lock(lpDestRect: PRect; var lpDDSurfaceDesc: TDDSurfaceDesc;
dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
function ReleaseDC(hDC: HDC): HResult; stdcall;
function Restore: HResult; stdcall;
function SetClipper (lpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function SetColorKey (dwFlags: DWORD; lpDDColorKey: PDDColorKey) :
HResult; stdcall;
function SetOverlayPosition (lX, lY: LongInt) : HResult; stdcall;
function SetColorKey(dwFlags: DWORD; const lpDDColorKey: TDDColorKey): HResult; stdcall;
function SetOverlayPosition(lX, lY: Longint): HResult; stdcall;
function SetPalette (lpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function Unlock (lpSurfaceData: Pointer) : HResult; stdcall;
function UpdateOverlay (lpSrcRect: PRect;
lpDDDestSurface: IDirectDrawSurface; lpDestRect: PRect;
dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX) : HResult; stdcall;
function UpdateOverlay(const lpSrcRect: TRect;
lpDDDestSurface: IDirectDrawSurface; const lpDestRect: TRect;
dwFlags: DWORD; const lpDDOverlayFx: TDDOverlayFX): HResult; stdcall;
function UpdateOverlayDisplay (dwFlags: DWORD) : HResult; stdcall;
function UpdateOverlayZOrder (dwFlags: DWORD;
lpDDSReference: IDirectDrawSurface) : HResult; stdcall;
end;
 
(*
* IDirectDrawSurface2 and related interfaces
*)
{ IDirectDrawSurface2 Interface }
 
IDirectDrawSurface2 = interface (IUnknown)
['{57805885-6eec-11cf-9441-a82303c10e27}']
(*** IDirectDrawSurface methods ***)
function AddAttachedSurface (lpDDSAttachedSurface: IDirectDrawSurface2) :
HResult; stdcall;
['{57805885-6EEC-11CF-9441-A82303C10E27}']
// IDirectDrawSurface methods
function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface2): HResult; stdcall;
function AddOverlayDirtyRect (const lpRect: TRect) : HResult; stdcall;
function Blt (lpDestRect: PRect;
lpDDSrcSurface: IDirectDrawSurface2; lpSrcRect: PRect;
dwFlags: DWORD; lpDDBltFx: PDDBltFX) : HResult; stdcall;
function Blt(const lpDestRect: TRect; lpDDSrcSurface: IDirectDrawSurface2;
const lpSrcRect: TRect; dwFlags: DWORD; const lpDDBltFx: TDDBltFX): HResult; stdcall;
function BltBatch (const lpDDBltBatch: TDDBltBatch; dwCount: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function BltFast (dwX: DWORD; dwY: DWORD;
lpDDSrcSurface: IDirectDrawSurface2; lpSrcRect: PRect;
dwTrans: DWORD) : HResult; stdcall;
function BltFast(dwX, dwY: DWORD; lpDDSrcSurface: IDirectDrawSurface2;
const lpSrcRect: TRect; dwTrans: DWORD): HResult; stdcall;
function DeleteAttachedSurface (dwFlags: DWORD;
lpDDSAttachedSurface: IDirectDrawSurface2) : HResult; stdcall;
function EnumAttachedSurfaces (lpContext: Pointer;
1250,56 → 1229,51
function GetAttachedSurface (var lpDDSCaps: TDDSCaps;
out lplpDDAttachedSurface: IDirectDrawSurface2) : HResult; stdcall;
function GetBltStatus (dwFlags: DWORD) : HResult; stdcall;
function GetCaps (out lpDDSCaps: TDDSCaps) : HResult; stdcall;
function GetCaps(var lpDDSCaps: TDDSCaps): HResult; stdcall;
function GetClipper (out lplpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function GetColorKey (dwFlags: DWORD; out lpDDColorKey: TDDColorKey) :
HResult; stdcall;
function GetDC (out lphDC: HDC) : HResult; stdcall;
function GetColorKey(dwFlags: DWORD; var lpDDColorKey: TDDColorKey): HResult; stdcall;
function GetDC(var lphDC: HDC): HResult; stdcall;
function GetFlipStatus (dwFlags: DWORD) : HResult; stdcall;
function GetOverlayPosition (out lplX, lplY: LongInt) : HResult; stdcall;
function GetOverlayPosition(var lplX, lplY: Longint): HResult; stdcall;
function GetPalette (out lplpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function GetPixelFormat (out lpDDPixelFormat: TDDPixelFormat) : HResult; stdcall;
function GetSurfaceDesc (out lpDDSurfaceDesc: TDDSurfaceDesc) : HResult; stdcall;
function Initialize (lpDD: IDirectDraw;
out lpDDSurfaceDesc: TDDSurfaceDesc) : HResult; stdcall;
function GetPixelFormat(var lpDDPixelFormat: TDDPixelFormat): HResult; stdcall;
function GetSurfaceDesc(var lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall;
function Initialize(lpDD: IDirectDraw; const lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall;
function IsLost: HResult; stdcall;
function Lock (lpDestRect: PRect;
out lpDDSurfaceDesc: TDDSurfaceDesc; dwFlags: DWORD;
hEvent: THandle) : HResult; stdcall;
function ReleaseDC (hDC: Windows.HDC) : HResult; stdcall;
function _Restore: HResult; stdcall;
function Lock(lpDestRect: PRect; const lpDDSurfaceDesc: TDDSurfaceDesc;
dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
function ReleaseDC(hDC: HDC): HResult; stdcall;
function Restore: HResult; stdcall;
function SetClipper (lpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function SetColorKey (dwFlags: DWORD; lpDDColorKey: PDDColorKey) :
HResult; stdcall;
function SetOverlayPosition (lX, lY: LongInt) : HResult; stdcall;
function SetColorKey(dwFlags: DWORD; const lpDDColorKey: TDDColorKey): HResult; stdcall;
function SetOverlayPosition(lX, lY: Longint): HResult; stdcall;
function SetPalette (lpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function Unlock (lpSurfaceData: Pointer) : HResult; stdcall;
function UpdateOverlay (lpSrcRect: PRect;
lpDDDestSurface: IDirectDrawSurface2; lpDestRect: PRect;
dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX) : HResult; stdcall;
function UpdateOverlay(const lpSrcRect: TRect;
lpDDDestSurface: IDirectDrawSurface2; const lpDestRect: TRect;
dwFlags: DWORD; const lpDDOverlayFx: TDDOverlayFX): HResult; stdcall;
function UpdateOverlayDisplay (dwFlags: DWORD) : HResult; stdcall;
function UpdateOverlayZOrder (dwFlags: DWORD;
lpDDSReference: IDirectDrawSurface2) : HResult; stdcall;
(*** Added in the v2 interface ***)
function GetDDInterface (var lplpDD: IDirectDraw) : HResult; stdcall;
// IDirectDrawSurface2 methods
function GetDDInterface(out lplpDD: IUnknown): HResult; stdcall;
function PageLock (dwFlags: DWORD) : HResult; stdcall;
function PageUnlock (dwFlags: DWORD) : HResult; stdcall;
end;
 
{ IDirectDrawSurface3 Interface }
 
IDirectDrawSurface3 = interface (IUnknown)
['{DA044E00-69B2-11D0-A1D5-00AA00B8DFBB}']
(*** IDirectDrawSurface methods ***)
function AddAttachedSurface (lpDDSAttachedSurface: IDirectDrawSurface3) :
HResult; stdcall;
// IDirectDrawSurface methods
function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface3): HResult; stdcall;
function AddOverlayDirtyRect (const lpRect: TRect) : HResult; stdcall;
function Blt (lpDestRect: PRect;
lpDDSrcSurface: IDirectDrawSurface3; lpSrcRect: PRect;
dwFlags: DWORD; lpDDBltFx: PDDBltFX) : HResult; stdcall;
function Blt(const lpDestRect: TRect; lpDDSrcSurface: IDirectDrawSurface3;
const lpSrcRect: TRect; dwFlags: DWORD; const lpDDBltFx: TDDBltFX): HResult; stdcall;
function BltBatch (const lpDDBltBatch: TDDBltBatch; dwCount: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function BltFast (dwX: DWORD; dwY: DWORD;
lpDDSrcSurface: IDirectDrawSurface3; lpSrcRect: PRect;
dwTrans: DWORD) : HResult; stdcall;
function BltFast(dwX, dwY: DWORD; lpDDSrcSurface: IDirectDrawSurface3;
const lpSrcRect: TRect; dwTrans: DWORD): HResult; stdcall;
function DeleteAttachedSurface (dwFlags: DWORD;
lpDDSAttachedSurface: IDirectDrawSurface3) : HResult; stdcall;
function EnumAttachedSurfaces (lpContext: Pointer;
1311,61 → 1285,53
function GetAttachedSurface (var lpDDSCaps: TDDSCaps;
out lplpDDAttachedSurface: IDirectDrawSurface3) : HResult; stdcall;
function GetBltStatus (dwFlags: DWORD) : HResult; stdcall;
function GetCaps (out lpDDSCaps: TDDSCaps) : HResult; stdcall;
function GetCaps(var lpDDSCaps: TDDSCaps): HResult; stdcall;
function GetClipper (out lplpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function GetColorKey (dwFlags: DWORD; out lpDDColorKey: TDDColorKey) :
HResult; stdcall;
function GetDC (out lphDC: HDC) : HResult; stdcall;
function GetColorKey(dwFlags: DWORD; var lpDDColorKey: TDDColorKey): HResult; stdcall;
function GetDC(var lphDC: HDC): HResult; stdcall;
function GetFlipStatus (dwFlags: DWORD) : HResult; stdcall;
function GetOverlayPosition (out lplX, lplY: LongInt) : HResult; stdcall;
function GetOverlayPosition(var lplX, lplY: Longint): HResult; stdcall;
function GetPalette (out lplpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function GetPixelFormat (out lpDDPixelFormat: TDDPixelFormat) : HResult; stdcall;
function GetSurfaceDesc (out lpDDSurfaceDesc: TDDSurfaceDesc) : HResult; stdcall;
function Initialize (lpDD: IDirectDraw;
out lpDDSurfaceDesc: TDDSurfaceDesc) : HResult; stdcall;
function GetPixelFormat(var lpDDPixelFormat: TDDPixelFormat): HResult; stdcall;
function GetSurfaceDesc(var lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall;
function Initialize(lpDD: IDirectDraw; const lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall;
function IsLost: HResult; stdcall;
function Lock (lpDestRect: PRect;
out lpDDSurfaceDesc: TDDSurfaceDesc; dwFlags: DWORD;
hEvent: THandle) : HResult; stdcall;
function ReleaseDC (hDC: Windows.HDC) : HResult; stdcall;
function _Restore: HResult; stdcall;
function Lock(lpDestRect: PRect; const lpDDSurfaceDesc: TDDSurfaceDesc;
dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
function ReleaseDC(hDC: HDC): HResult; stdcall;
function Restore: HResult; stdcall;
function SetClipper (lpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function SetColorKey (dwFlags: DWORD; lpDDColorKey: PDDColorKey) :
HResult; stdcall;
function SetOverlayPosition (lX, lY: LongInt) : HResult; stdcall;
function SetColorKey(dwFlags: DWORD; const lpDDColorKey: TDDColorKey): HResult; stdcall;
function SetOverlayPosition(lX, lY: Longint): HResult; stdcall;
function SetPalette (lpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function Unlock (lpSurfaceData: Pointer) : HResult; stdcall;
function UpdateOverlay (lpSrcRect: PRect;
lpDDDestSurface: IDirectDrawSurface3; lpDestRect: PRect;
dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX) : HResult; stdcall;
function UpdateOverlay(const lpSrcRect: TRect;
lpDDDestSurface: IDirectDrawSurface3; const lpDestRect: TRect;
dwFlags: DWORD; const lpDDOverlayFx: TDDOverlayFX): HResult; stdcall;
function UpdateOverlayDisplay (dwFlags: DWORD) : HResult; stdcall;
function UpdateOverlayZOrder (dwFlags: DWORD;
lpDDSReference: IDirectDrawSurface3) : HResult; stdcall;
(*** Added in the v2 interface ***)
function GetDDInterface (out lplpDD: IDirectDraw) : HResult; stdcall;
// IDirectDrawSurface2 methods
function GetDDInterface(out lplpDD: IUnknown): HResult; stdcall;
function PageLock (dwFlags: DWORD) : HResult; stdcall;
function PageUnlock (dwFlags: DWORD) : HResult; stdcall;
(*** Added in the V3 interface ***)
// IDirectDrawSurface3 methods
function SetSurfaceDesc(const lpddsd: TDDSurfaceDesc; dwFlags: DWORD) : HResult; stdcall;
end;
 
(*
* IDirectDrawSurface4 and related interfaces
*)
{ IDirectDrawSurface4 Interface }
 
IDirectDrawSurface4 = interface (IUnknown)
['{0B2B8630-AD35-11D0-8EA6-00609797EA5B}']
(*** IDirectDrawSurface methods ***)
function AddAttachedSurface (lpDDSAttachedSurface: IDirectDrawSurface4) :
HResult; stdcall;
// IDirectDrawSurface methods
function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface4): HResult; stdcall;
function AddOverlayDirtyRect (const lpRect: TRect) : HResult; stdcall;
function Blt (lpDestRect: PRect;
lpDDSrcSurface: IDirectDrawSurface4; lpSrcRect: PRect;
dwFlags: DWORD; lpDDBltFx: PDDBltFX) : HResult; stdcall;
function Blt(const lpDestRect: TRect; lpDDSrcSurface: IDirectDrawSurface4;
const lpSrcRect: TRect; dwFlags: DWORD; const lpDDBltFx: TDDBltFX): HResult; stdcall;
function BltBatch (const lpDDBltBatch: TDDBltBatch; dwCount: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function BltFast (dwX: DWORD; dwY: DWORD;
lpDDSrcSurface: IDirectDrawSurface4; lpSrcRect: PRect;
dwTrans: DWORD) : HResult; stdcall;
function BltFast(dwX, dwY: DWORD; lpDDSrcSurface: IDirectDrawSurface4;
const lpSrcRect: TRect; dwTrans: DWORD): HResult; stdcall;
function DeleteAttachedSurface (dwFlags: DWORD;
lpDDSAttachedSurface: IDirectDrawSurface4) : HResult; stdcall;
function EnumAttachedSurfaces (lpContext: Pointer;
1374,69 → 1340,62
lpfnCallback: TDDEnumSurfacesCallback2) : HResult; stdcall;
function Flip (lpDDSurfaceTargetOverride: IDirectDrawSurface4;
dwFlags: DWORD) : HResult; stdcall;
function GetAttachedSurface (const lpDDSCaps: TDDSCaps2;
function GetAttachedSurface(var lpDDSCaps: TDDSCaps2;
out lplpDDAttachedSurface: IDirectDrawSurface4) : HResult; stdcall;
function GetBltStatus (dwFlags: DWORD) : HResult; stdcall;
function GetCaps (out lpDDSCaps: TDDSCaps2) : HResult; stdcall;
function GetCaps(var lpDDSCaps: TDDSCaps2): HResult; stdcall;
function GetClipper (out lplpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function GetColorKey (dwFlags: DWORD; out lpDDColorKey: TDDColorKey) :
HResult; stdcall;
function GetDC (out lphDC: HDC) : HResult; stdcall;
function GetColorKey(dwFlags: DWORD; var lpDDColorKey: TDDColorKey): HResult; stdcall;
function GetDC(var lphDC: HDC): HResult; stdcall;
function GetFlipStatus (dwFlags: DWORD) : HResult; stdcall;
function GetOverlayPosition (out lplX, lplY: LongInt) : HResult; stdcall;
function GetOverlayPosition(var lplX, lplY: Longint): HResult; stdcall;
function GetPalette (out lplpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function GetPixelFormat (out lpDDPixelFormat: TDDPixelFormat) : HResult; stdcall;
function GetSurfaceDesc (out lpDDSurfaceDesc: TDDSurfaceDesc2) : HResult; stdcall;
function Initialize (lpDD: IDirectDraw;
out lpDDSurfaceDesc: TDDSurfaceDesc2) : HResult; stdcall;
function GetPixelFormat(var lpDDPixelFormat: TDDPixelFormat): HResult; stdcall;
function GetSurfaceDesc(var lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall;
function Initialize(lpDD: IDirectDraw; const lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall;
function IsLost: HResult; stdcall;
function Lock (lpDestRect: PRect;
out lpDDSurfaceDesc: TDDSurfaceDesc2; dwFlags: DWORD;
hEvent: THandle) : HResult; stdcall;
function ReleaseDC (hDC: Windows.HDC) : HResult; stdcall;
function _Restore: HResult; stdcall;
function Lock(lpDestRect: PRect; const lpDDSurfaceDesc: TDDSurfaceDesc2;
dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
function ReleaseDC(hDC: HDC): HResult; stdcall;
function Restore: HResult; stdcall;
function SetClipper (lpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function SetColorKey (dwFlags: DWORD; lpDDColorKey: PDDColorKey) :
HResult; stdcall;
function SetOverlayPosition (lX, lY: LongInt) : HResult; stdcall;
function SetColorKey(dwFlags: DWORD; const lpDDColorKey: TDDColorKey): HResult; stdcall;
function SetOverlayPosition(lX, lY: Longint): HResult; stdcall;
function SetPalette (lpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function Unlock (lpRect: PRect) : HResult; stdcall;
function UpdateOverlay (lpSrcRect: PRect;
lpDDDestSurface: IDirectDrawSurface4; lpDestRect: PRect;
dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX) : HResult; stdcall;
function Unlock(lpSurfaceData: Pointer): HResult; stdcall;
function UpdateOverlay(const lpSrcRect: TRect; lpDDDestSurface: IDirectDrawSurface4;
const lpDestRect: TRect; dwFlags: DWORD; const lpDDOverlayFx: TDDOverlayFX): HResult; stdcall;
function UpdateOverlayDisplay (dwFlags: DWORD) : HResult; stdcall;
function UpdateOverlayZOrder (dwFlags: DWORD;
lpDDSReference: IDirectDrawSurface4) : HResult; stdcall;
(*** Added in the v2 interface ***)
function UpdateOverlayZOrder(dwFlags: DWORD; lpDDSReference: IDirectDrawSurface4): HResult; stdcall;
// IDirectDrawSurface2 methods
function GetDDInterface (out lplpDD: IUnknown) : HResult; stdcall;
function PageLock (dwFlags: DWORD) : HResult; stdcall;
function PageUnlock (dwFlags: DWORD) : HResult; stdcall;
(*** Added in the V3 interface ***)
function SetSurfaceDesc(const lpddsd2: TDDSurfaceDesc2; dwFlags: DWORD) : HResult; stdcall;
(*** Added in the v4 interface ***)
function SetPrivateData(const guidTag: TGUID; lpData: pointer;
// IDirectDrawSurface3 methods
function SetSurfaceDesc(const lpddsd: TDDSurfaceDesc2; dwFlags: DWORD): HResult; stdcall;
// IDirectDrawSurface4 methods
function SetPrivateData(const guidTag: TGUID; lpData: Pointer;
cbSize: DWORD; dwFlags: DWORD) : HResult; stdcall;
function GetPrivateData(const guidTag: TGUID; lpBuffer: pointer;
var lpcbBufferSize: DWORD) : HResult; stdcall;
function GetPrivateData(const guidTag: TGUID; lpData: Pointer;
var cbSize: DWORD): HResult; stdcall;
function FreePrivateData(const guidTag: TGUID) : HResult; stdcall;
function GetUniquenessValue(out lpValue: DWORD) : HResult; stdcall;
function GetUniquenessValue(var lpValue: DWORD): HResult; stdcall;
function ChangeUniquenessValue : HResult; stdcall;
end;
 
{ IDirectDrawSurface7 Interface }
 
IDirectDrawSurface7 = interface (IUnknown)
['{06675a80-3b9b-11d2-b92f-00609797ea5b}']
(*** IDirectDrawSurface methods ***)
function AddAttachedSurface (lpDDSAttachedSurface: IDirectDrawSurface7) :
HResult; stdcall;
['{06675A80-3B9B-11D2-B92F-00609797EA5B}']
// IDirectDrawSurface methods
function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface7): HResult; stdcall;
function AddOverlayDirtyRect (const lpRect: TRect) : HResult; stdcall;
function Blt (lpDestRect: PRect;
lpDDSrcSurface: IDirectDrawSurface7; lpSrcRect: PRect;
dwFlags: DWORD; lpDDBltFx: PDDBltFX) : HResult; stdcall;
function Blt(const lpDestRect: TRect; lpDDSrcSurface: IDirectDrawSurface7;
const lpSrcRect: TRect; dwFlags: DWORD; const lpDDBltFx: TDDBltFX): HResult; stdcall;
function BltBatch (const lpDDBltBatch: TDDBltBatch; dwCount: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function BltFast (dwX: DWORD; dwY: DWORD;
lpDDSrcSurface: IDirectDrawSurface7; lpSrcRect: PRect;
dwTrans: DWORD) : HResult; stdcall;
function BltFast(dwX, dwY: DWORD; lpDDSrcSurface: IDirectDrawSurface7;
const lpSrcRect: TRect; dwTrans: DWORD): HResult; stdcall;
function DeleteAttachedSurface (dwFlags: DWORD;
lpDDSAttachedSurface: IDirectDrawSurface7) : HResult; stdcall;
function EnumAttachedSurfaces (lpContext: Pointer;
1445,2038 → 1404,438
lpfnCallback: TDDEnumSurfacesCallback7) : HResult; stdcall;
function Flip (lpDDSurfaceTargetOverride: IDirectDrawSurface7;
dwFlags: DWORD) : HResult; stdcall;
function GetAttachedSurface (const lpDDSCaps: TDDSCaps2;
function GetAttachedSurface(var lpDDSCaps: TDDSCaps2;
out lplpDDAttachedSurface: IDirectDrawSurface7) : HResult; stdcall;
function GetBltStatus (dwFlags: DWORD) : HResult; stdcall;
function GetCaps (out lpDDSCaps: TDDSCaps2) : HResult; stdcall;
function GetCaps(var lpDDSCaps: TDDSCaps2): HResult; stdcall;
function GetClipper (out lplpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function GetColorKey (dwFlags: DWORD; out lpDDColorKey: TDDColorKey) :
HResult; stdcall;
function GetDC (out lphDC: HDC) : HResult; stdcall;
function GetColorKey(dwFlags: DWORD; var lpDDColorKey: TDDColorKey): HResult; stdcall;
function GetDC(var lphDC: HDC): HResult; stdcall;
function GetFlipStatus (dwFlags: DWORD) : HResult; stdcall;
function GetOverlayPosition (out lplX, lplY: LongInt) : HResult; stdcall;
function GetOverlayPosition(var lplX, lplY: Longint): HResult; stdcall;
function GetPalette (out lplpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function GetPixelFormat (out lpDDPixelFormat: TDDPixelFormat) : HResult; stdcall;
function GetSurfaceDesc (out lpDDSurfaceDesc: TDDSurfaceDesc2) : HResult; stdcall;
function Initialize (lpDD: IDirectDraw;
out lpDDSurfaceDesc: TDDSurfaceDesc2) : HResult; stdcall;
function GetPixelFormat(var lpDDPixelFormat: TDDPixelFormat): HResult; stdcall;
function GetSurfaceDesc(var lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall;
function Initialize(lpDD: IDirectDraw; const lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall;
function IsLost: HResult; stdcall;
function Lock (lpDestRect: PRect;
out lpDDSurfaceDesc: TDDSurfaceDesc2; dwFlags: DWORD;
hEvent: THandle) : HResult; stdcall;
function ReleaseDC (hDC: Windows.HDC) : HResult; stdcall;
function _Restore: HResult; stdcall;
function Lock(lpDestRect: PRect; const lpDDSurfaceDesc: TDDSurfaceDesc2;
dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
function ReleaseDC(hDC: HDC): HResult; stdcall;
function Restore: HResult; stdcall;
function SetClipper (lpDDClipper: IDirectDrawClipper) : HResult; stdcall;
function SetColorKey (dwFlags: DWORD; lpDDColorKey: PDDColorKey) :
HResult; stdcall;
function SetOverlayPosition (lX, lY: LongInt) : HResult; stdcall;
function SetColorKey(dwFlags: DWORD; const lpDDColorKey: TDDColorKey): HResult; stdcall;
function SetOverlayPosition(lX, lY: Longint): HResult; stdcall;
function SetPalette (lpDDPalette: IDirectDrawPalette) : HResult; stdcall;
function Unlock (lpRect: PRect) : HResult; stdcall;
function UpdateOverlay (lpSrcRect: PRect;
lpDDDestSurface: IDirectDrawSurface7; lpDestRect: PRect;
dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX) : HResult; stdcall;
function Unlock(lpSurfaceData: Pointer): HResult; stdcall;
function UpdateOverlay(const lpSrcRect: TRect; lpDDDestSurface: IDirectDrawSurface7;
const lpDestRect: TRect; dwFlags: DWORD; const lpDDOverlayFx: TDDOverlayFX): HResult; stdcall;
function UpdateOverlayDisplay (dwFlags: DWORD) : HResult; stdcall;
function UpdateOverlayZOrder (dwFlags: DWORD;
lpDDSReference: IDirectDrawSurface7) : HResult; stdcall;
(*** Added in the v2 interface ***)
function UpdateOverlayZOrder(dwFlags: DWORD; lpDDSReference: IDirectDrawSurface7): HResult; stdcall;
// IDirectDrawSurface2 methods
function GetDDInterface (out lplpDD: IUnknown) : HResult; stdcall;
function PageLock (dwFlags: DWORD) : HResult; stdcall;
function PageUnlock (dwFlags: DWORD) : HResult; stdcall;
(*** Added in the V3 interface ***)
function SetSurfaceDesc(const lpddsd2: TDDSurfaceDesc2; dwFlags: DWORD) : HResult; stdcall;
(*** Added in the v4 interface ***)
function SetPrivateData(const guidTag: TGUID; lpData: pointer;
// IDirectDrawSurface3 methods
function SetSurfaceDesc(const lpddsd: TDDSurfaceDesc2; dwFlags: DWORD): HResult; stdcall;
// IDirectDrawSurface4 methods
function SetPrivateData(const guidTag: TGUID; lpData: Pointer;
cbSize: DWORD; dwFlags: DWORD) : HResult; stdcall;
function GetPrivateData(const guidTag: TGUID; lpBuffer: pointer;
var lpcbBufferSize: DWORD) : HResult; stdcall;
function GetPrivateData(const guidTag: TGUID; lpData: Pointer;
var cbSize: DWORD): HResult; stdcall;
function FreePrivateData(const guidTag: TGUID) : HResult; stdcall;
function GetUniquenessValue(out lpValue: DWORD) : HResult; stdcall;
function GetUniquenessValue(var lpValue: DWORD): HResult; stdcall;
function ChangeUniquenessValue : HResult; stdcall;
(*** Moved Texture7 methods here ***)
// Moved Texture7 methods here
function SetPriority(dwPriority: DWORD) : HResult; stdcall;
function GetPriority(out lpdwPriority: DWORD) : HResult; stdcall;
function GetPriority(var lpdwPriority: DWORD): HResult; stdcall;
function SetLOD(dwMaxLOD: DWORD) : HResult; stdcall;
function GetLOD(out lpdwMaxLOD: DWORD) : HResult; stdcall;
function GetLOD(var lpdwMaxLOD: DWORD): HResult; stdcall;
end;
 
{ IDirectDrawColorControl Interface }
 
IDirectDrawColorControl = interface (IUnknown)
['{4B9F0EE0-0D7E-11D0-9B06-00A0C903A3B8}']
function GetColorControls(out lpColorControl: TDDColorControl) : HResult; stdcall;
// IDirectDrawColorControl methods
function GetColorControls(var lpColorControl: TDDColorControl): HResult; stdcall;
function SetColorControls(const lpColorControl: TDDColorControl) : HResult; stdcall;
end;
 
(*
* IDirectDrawGammaControl
*)
{ IDirectDrawGammaControl Interface }
 
IDirectDrawGammaControl = interface (IUnknown)
['{69C11C3E-B46B-11D1-AD7A-00C04FC29B4E}']
function GetGammaRamp (dwFlags: DWORD; out lpRampData: TDDGammaRamp)
: HResult; stdcall;
function SetGammaRamp (dwFlags: DWORD; const lpRampData: TDDGammaRamp)
: HResult; stdcall;
// IDirectDrawGammaControl methods
function GetGammaRamp(dwFlags: DWORD; var lpRampData: TDDGammaRamp): HResult; stdcall;
function SetGammaRamp(dwFlags: DWORD; const lpRampData: TDDGammaRamp): HResult; stdcall;
end;
 
type
IID_IDirectDraw = IDirectDraw;
IID_IDirectDraw2 = IDirectDraw2;
IID_IDirectDraw4 = IDirectDraw4;
IID_IDirectDraw7 = IDirectDraw7;
IID_IDirectDrawSurface = IDirectDrawSurface;
IID_IDirectDrawSurface2 = IDirectDrawSurface2;
IID_IDirectDrawSurface3 = IDirectDrawSurface3;
IID_IDirectDrawSurface4 = IDirectDrawSurface4;
IID_IDirectDrawSurface7 = IDirectDrawSurface7;
const
{ Flags for DirectDrawEnumerateEx }
DDENUM_ATTACHEDSECONDARYDEVICES = $00000001;
DDENUM_DETACHEDSECONDARYDEVICES = $00000002;
DDENUM_NONDISPLAYDEVICES = $00000004;
 
IID_IDirectDrawPalette = IDirectDrawPalette;
IID_IDirectDrawClipper = IDirectDrawClipper;
IID_IDirectDrawColorControl = IDirectDrawColorControl;
IID_IDirectDrawGammaControl = IDirectDrawGammaControl;
{ Flags for the IDirectDraw4.GetDeviceIdentifier method }
DDGDI_GETHOSTIDENTIFIER = $00000001;
 
const
(*
* ddsCaps field is valid.
*)
{ ddsCaps field is valid. }
DDSD_CAPS = $00000001; // default
 
(*
* dwHeight field is valid.
*)
DDSD_HEIGHT = $00000002;
 
(*
* dwWidth field is valid.
*)
DDSD_WIDTH = $00000004;
 
(*
* lPitch is valid.
*)
DDSD_PITCH = $00000008;
 
(*
* dwBackBufferCount is valid.
*)
DDSD_BACKBUFFERCOUNT = $00000020;
 
(*
* dwZBufferBitDepth is valid. (shouldnt be used in DDSURFACEDESC2)
*)
DDSD_ZBUFFERBITDEPTH = $00000040;
 
(*
* dwAlphaBitDepth is valid.
*)
DDSD_ALPHABITDEPTH = $00000080;
 
(*
* lpSurface is valid.
*)
DDSD_LPSURFACE = $00000800;
 
(*
* ddpfPixelFormat is valid.
*)
DDSD_PIXELFORMAT = $00001000;
 
(*
* ddckCKDestOverlay is valid.
*)
DDSD_CKDESTOVERLAY = $00002000;
 
(*
* ddckCKDestBlt is valid.
*)
DDSD_CKDESTBLT = $00004000;
 
(*
* ddckCKSrcOverlay is valid.
*)
DDSD_CKSRCOVERLAY = $00008000;
 
(*
* ddckCKSrcBlt is valid.
*)
DDSD_CKSRCBLT = $00010000;
 
(*
* dwMipMapCount is valid.
*)
DDSD_MIPMAPCOUNT = $00020000;
 
(*
* dwRefreshRate is valid
*)
DDSD_REFRESHRATE = $00040000;
 
(*
* dwLinearSize is valid
*)
DDSD_LINEARSIZE = $00080000;
 
(*
* dwTextureStage is valid
*)
DDSD_TEXTURESTAGE = $00100000;
DDSD_FVF = $00200000;
DDSD_SRCVBHANDLE = $00400000;
DDSD_ALL = $007ff9ee;
 
(*
* All input fields are valid.
*)
DDSD_ALL = $001ff9ee;
{ DirectDraw Driver Capability Flags }
 
 
(*
* guid field is valid.
*)
DDOSD_GUID = $00000001;
 
(*
* dwCompressionRatio field is valid.
*)
DDOSD_COMPRESSION_RATIO = $00000002;
 
(*
* ddSCaps field is valid.
*)
DDOSD_SCAPS = $00000004;
 
(*
* ddOSCaps field is valid.
*)
DDOSD_OSCAPS = $00000008;
 
(*
* All input fields are valid.
*)
DDOSD_ALL = $0000000f;
 
(*
* The surface's optimized pixelformat is compressed
*)
DDOSDCAPS_OPTCOMPRESSED = $00000001;
 
(*
* The surface's optimized pixelformat is reordered
*)
DDOSDCAPS_OPTREORDERED = $00000002;
 
(*
* The opt surface is a monolithic mipmap
*)
DDOSDCAPS_MONOLITHICMIPMAP = $00000004;
 
(*
* The valid Surf caps:
* DDSCAPS_SYSTEMMEMORY = $00000800;
* DDSCAPS_VIDEOMEMORY = $00004000;
* DDSCAPS_LOCALVIDMEM = $10000000;
* DDSCAPS_NONLOCALVIDMEM = $20000000;
*)
DDOSDCAPS_VALIDSCAPS = $30004800;
 
(*
* The valid OptSurf caps
*)
DDOSDCAPS_VALIDOSCAPS = $00000007;
 
 
(*
* DDCOLORCONTROL
*)
 
(*
* lBrightness field is valid.
*)
DDCOLOR_BRIGHTNESS = $00000001;
 
(*
* lContrast field is valid.
*)
DDCOLOR_CONTRAST = $00000002;
 
(*
* lHue field is valid.
*)
DDCOLOR_HUE = $00000004;
 
(*
* lSaturation field is valid.
*)
DDCOLOR_SATURATION = $00000008;
 
(*
* lSharpness field is valid.
*)
DDCOLOR_SHARPNESS = $00000010;
 
(*
* lGamma field is valid.
*)
DDCOLOR_GAMMA = $00000020;
 
(*
* lColorEnable field is valid.
*)
DDCOLOR_COLORENABLE = $00000040;
 
 
 
(*============================================================================
*
* Direct Draw Capability Flags
*
* These flags are used to describe the capabilities of a given Surface.
* All flags are bit flags.
*
*==========================================================================*)
 
(****************************************************************************
*
* DIRECTDRAWSURFACE CAPABILITY FLAGS
*
****************************************************************************)
(*
* This bit currently has no meaning.
*)
DDSCAPS_RESERVED1 = $00000001;
 
(*
* Indicates that this surface contains alpha-only information.
* (To determine if a surface is RGBA/YUVA, the pixel format must be
* interrogated.)
*)
DDSCAPS_ALPHA = $00000002;
 
(*
* Indicates that this surface is a backbuffer. It is generally
* set by CreateSurface when the DDSCAPS_FLIP capability bit is set.
* It indicates that this surface is THE back buffer of a surface
* flipping structure. DirectDraw supports N surfaces in a
* surface flipping structure. Only the surface that immediately
* precedeces the DDSCAPS_FRONTBUFFER has this capability bit set.
* The other surfaces are identified as back buffers by the presence
* of the DDSCAPS_FLIP capability, their attachment order, and the
* absence of the DDSCAPS_FRONTBUFFER and DDSCAPS_BACKBUFFER
* capabilities. The bit is sent to CreateSurface when a standalone
* back buffer is being created. This surface could be attached to
* a front buffer and/or back buffers to form a flipping surface
* structure after the CreateSurface call. See AddAttachments for
* a detailed description of the behaviors in this case.
*)
DDSCAPS_BACKBUFFER = $00000004;
 
(*
* Indicates a complex surface structure is being described. A
* complex surface structure results in the creation of more than
* one surface. The additional surfaces are attached to the root
* surface. The complex structure can only be destroyed by
* destroying the root.
*)
DDSCAPS_COMPLEX = $00000008;
 
(*
* Indicates that this surface is a part of a surface flipping structure.
* When it is passed to CreateSurface the DDSCAPS_FRONTBUFFER and
* DDSCAP_BACKBUFFER bits are not set. They are set by CreateSurface
* on the resulting creations. The dwBackBufferCount field in the
* TDDSurfaceDesc structure must be set to at least 1 in order for
* the CreateSurface call to succeed. The DDSCAPS_COMPLEX capability
* must always be set with creating multiple surfaces through CreateSurface.
*)
DDSCAPS_FLIP = $00000010;
 
(*
* Indicates that this surface is THE front buffer of a surface flipping
* structure. It is generally set by CreateSurface when the DDSCAPS_FLIP
* capability bit is set.
* If this capability is sent to CreateSurface then a standalonw front buffer
* is created. This surface will not have the DDSCAPS_FLIP capability.
* It can be attached to other back buffers to form a flipping structure.
* See AddAttachments for a detailed description of the behaviors in this
* case.
*)
DDSCAPS_FRONTBUFFER = $00000020;
 
(*
* Indicates that this surface is any offscreen surface that is not an overlay,
* texture, zbuffer, front buffer, back buffer, or alpha surface. It is used
* to identify plain vanilla surfaces.
*)
DDSCAPS_OFFSCREENPLAIN = $00000040;
 
(*
* Indicates that this surface is an overlay. It may or may not be directly visible
* depending on whether or not it is currently being overlayed onto the primary
* surface. DDSCAPS_VISIBLE can be used to determine whether or not it is being
* overlayed at the moment.
*)
DDSCAPS_OVERLAY = $00000080;
 
(*
* Indicates that unique DirectDrawPalette objects can be created and
* attached to this surface.
*)
DDSCAPS_PALETTE = $00000100;
 
(*
* Indicates that this surface is the primary surface. The primary
* surface represents what the user is seeing at the moment.
*)
DDSCAPS_PRIMARYSURFACE = $00000200;
 
(*
* This flag used to be DDSCAPS_PRIMARYSURFACELEFT, which is now
* obsolete.
*)
DDSCAPS_RESERVED3 = $00000400;
(*
* Indicates that this surface is the primary surface for the left eye.
* The primary surface for the left eye represents what the user is seeing
* at the moment with the users left eye. When this surface is created the
* DDSCAPS_PRIMARYSURFACE represents what the user is seeing with the users
* right eye.
*)
DDSCAPS_PRIMARYSURFACELEFT = DDSCAPS_RESERVED3;
 
(*
* Indicates that this surface memory was allocated in system memory
*)
DDSCAPS_SYSTEMMEMORY = $00000800;
 
(*
* Indicates that this surface can be used as a 3D texture. It does not
* indicate whether or not the surface is being used for that purpose.
*)
DDSCAPS_TEXTURE = $00001000;
 
(*
* Indicates that a surface may be a destination for 3D rendering. This
* bit must be set in order to query for a Direct3D Device Interface
* from this surface.
*)
DDSCAPS_3DDEVICE = $00002000;
 
(*
* Indicates that this surface exists in video memory.
*)
DDSCAPS_VIDEOMEMORY = $00004000;
 
(*
* Indicates that changes made to this surface are immediately visible.
* It is always set for the primary surface and is set for overlays while
* they are being overlayed and texture maps while they are being textured.
*)
DDSCAPS_VISIBLE = $00008000;
 
(*
* Indicates that only writes are permitted to the surface. Read accesses
* from the surface may or may not generate a protection fault, but the
* results of a read from this surface will not be meaningful. READ ONLY.
*)
DDSCAPS_WRITEONLY = $00010000;
 
(*
* Indicates that this surface is a z buffer. A z buffer does not contain
* displayable information. Instead it contains bit depth information that is
* used to determine which pixels are visible and which are obscured.
*)
DDSCAPS_ZBUFFER = $00020000;
 
(*
* Indicates surface will have a DC associated long term
*)
DDSCAPS_OWNDC = $00040000;
 
(*
* Indicates surface should be able to receive live video
*)
DDSCAPS_LIVEVIDEO = $00080000;
 
(*
* Indicates surface should be able to have a stream decompressed
* to it by the hardware.
*)
DDSCAPS_HWCODEC = $00100000;
 
(*
* Surface is a ModeX surface.
*
*)
DDSCAPS_MODEX = $00200000;
 
(*
* Indicates surface is one level of a mip-map. This surface will
* be attached to other DDSCAPS_MIPMAP surfaces to form the mip-map.
* This can be done explicitly, by creating a number of surfaces and
* attaching them with AddAttachedSurface or by implicitly by CreateSurface.
* If this bit is set then DDSCAPS_TEXTURE must also be set.
*)
DDSCAPS_MIPMAP = $00400000;
 
(*
* This bit is reserved. It should not be specified.
*)
DDSCAPS_RESERVED2 = $00800000;
 
(*
* Indicates that memory for the surface is not allocated until the surface
* is loaded (via the Direct3D texture Load() function).
*)
DDSCAPS_ALLOCONLOAD = $04000000;
 
(*
* Indicates that the surface will recieve data from a video port.
*)
DDSCAPS_VIDEOPORT = $08000000;
 
(*
* Indicates that a video memory surface is resident in true, local video
* memory rather than non-local video memory. If this flag is specified then
* so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with
* DDSCAPS_NONLOCALVIDMEM.
*)
DDSCAPS_LOCALVIDMEM = $10000000;
 
(*
* Indicates that a video memory surface is resident in non-local video
* memory rather than true, local video memory. If this flag is specified
* then so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with
* DDSCAPS_LOCALVIDMEM.
*)
DDSCAPS_NONLOCALVIDMEM = $20000000;
 
(*
* Indicates that this surface is a standard VGA mode surface, and not a
* ModeX surface. (This flag will never be set in combination with the
* DDSCAPS_MODEX flag).
*)
DDSCAPS_STANDARDVGAMODE = $40000000;
 
(*
* Indicates that this surface will be an optimized surface. This flag is
* currently only valid in conjunction with the DDSCAPS_TEXTURE flag. The surface
* will be created without any underlying video memory until loaded.
*)
DDSCAPS_OPTIMIZED = $80000000;
 
 
 
(*
* Indicates that this surface will receive data from a video port using
* the de-interlacing hardware. This allows the driver to allocate memory
* for any extra buffers that may be required. The DDSCAPS_VIDEOPORT and
* DDSCAPS_OVERLAY flags must also be set.
*)
DDSCAPS2_HARDWAREDEINTERLACE = $00000002;
 
(*
* Indicates to the driver that this surface will be locked very frequently
* (for procedural textures, dynamic lightmaps, etc). Surfaces with this cap
* set must also have DDSCAPS_TEXTURE. This cap cannot be used with
* DDSCAPS2_HINTSTATIC and DDSCAPS2_OPAQUE.
*)
DDSCAPS2_HINTDYNAMIC = $00000004;
 
(*
* Indicates to the driver that this surface can be re-ordered/retiled on
* load. This operation will not change the size of the texture. It is
* relatively fast and symmetrical, since the application may lock these
* bits (although it will take a performance hit when doing so). Surfaces
* with this cap set must also have DDSCAPS_TEXTURE. This cap cannot be
* used with DDSCAPS2_HINTDYNAMIC and DDSCAPS2_OPAQUE.
*)
DDSCAPS2_HINTSTATIC = $00000008;
 
(*
* Indicates that the client would like this texture surface to be managed by the
* DirectDraw/Direct3D runtime. Surfaces with this cap set must also have
* DDSCAPS_TEXTURE and DDSCAPS_SYSTEMMEMORY.
*)
DDSCAPS2_TEXTUREMANAGE = $00000010;
 
(*
* These bits are reserved for internal use *)
DDSCAPS2_RESERVED1 = $00000020;
DDSCAPS2_RESERVED2 = $00000040;
 
(*
* Indicates to the driver that this surface will never be locked again.
* The driver is free to optimize this surface via retiling and actual compression.
* All calls to Lock() or Blts from this surface will fail. Surfaces with this
* cap set must also have DDSCAPS_TEXTURE. This cap cannot be used with
* DDSCAPS2_HINTDYNAMIC and DDSCAPS2_HINTSTATIC.
*)
DDSCAPS2_OPAQUE = $00000080;
 
(*
* Applications should set this bit at CreateSurface time to indicate that they
* intend to use antialiasing. Only valid if DDSCAPS_3DDEVICE is also set.
*)
DDSCAPS2_HINTANTIALIASING = $00000100;
 
(*
* This flag is used at CreateSurface time to indicate that this set of
* surfaces is a cubic environment map
*)
DDSCAPS2_CUBEMAP = $00000200;
 
(*
* These flags preform two functions:
* - At CreateSurface time, they define which of the six cube faces are
* required by the application.
* - After creation, each face in the cubemap will have exactly one of these
* bits set.
*)
DDSCAPS2_CUBEMAP_POSITIVEX = $00000400;
DDSCAPS2_CUBEMAP_NEGATIVEX = $00000800;
DDSCAPS2_CUBEMAP_POSITIVEY = $00001000;
DDSCAPS2_CUBEMAP_NEGATIVEY = $00002000;
DDSCAPS2_CUBEMAP_POSITIVEZ = $00004000;
DDSCAPS2_CUBEMAP_NEGATIVEZ = $00008000;
 
(*
* This macro may be used to specify all faces of a cube map at CreateSurface time
*)
DDSCAPS2_CUBEMAP_ALLFACES = ( DDSCAPS2_CUBEMAP_POSITIVEX or
DDSCAPS2_CUBEMAP_NEGATIVEX or
DDSCAPS2_CUBEMAP_POSITIVEY or
DDSCAPS2_CUBEMAP_NEGATIVEY or
DDSCAPS2_CUBEMAP_POSITIVEZ or
DDSCAPS2_CUBEMAP_NEGATIVEZ );
 
 
(*
* This flag is an additional flag which is present on mipmap sublevels from DX7 onwards
* It enables easier use of GetAttachedSurface rather than EnumAttachedSurfaces for surface
* constructs such as Cube Maps, wherein there are more than one mipmap surface attached
* to the root surface.
* This caps bit is ignored by CreateSurface
*)
DDSCAPS2_MIPMAPSUBLEVEL = $00010000;
 
(* This flag indicates that the texture should be managed by D3D only *)
DDSCAPS2_D3DTEXTUREMANAGE = $00020000;
 
(* This flag indicates that the managed surface can be safely lost *)
DDSCAPS2_DONOTPERSIST = $00040000;
 
(* indicates that this surface is part of a stereo flipping chain *)
DDSCAPS2_STEREOSURFACELEFT = $00080000;
 
 
 
(****************************************************************************
*
* DIRECTDRAW DRIVER CAPABILITY FLAGS
*
****************************************************************************)
 
(*
* Display hardware has 3D acceleration.
*)
DDCAPS_3D = $00000001;
 
(*
* Indicates that DirectDraw will support only dest rectangles that are aligned
* on DIRECTDRAWCAPS.dwAlignBoundaryDest boundaries of the surface, respectively.
* READ ONLY.
*)
DDCAPS_ALIGNBOUNDARYDEST = $00000002;
 
(*
* Indicates that DirectDraw will support only source rectangles whose sizes in
* BYTEs are DIRECTDRAWCAPS.dwAlignSizeDest multiples, respectively. READ ONLY.
*)
DDCAPS_ALIGNSIZEDEST = $00000004;
(*
* Indicates that DirectDraw will support only source rectangles that are aligned
* on DIRECTDRAWCAPS.dwAlignBoundarySrc boundaries of the surface, respectively.
* READ ONLY.
*)
DDCAPS_ALIGNBOUNDARYSRC = $00000008;
 
(*
* Indicates that DirectDraw will support only source rectangles whose sizes in
* BYTEs are DIRECTDRAWCAPS.dwAlignSizeSrc multiples, respectively. READ ONLY.
*)
DDCAPS_ALIGNSIZESRC = $00000010;
 
(*
* Indicates that DirectDraw will create video memory surfaces that have a stride
* alignment equal to DIRECTDRAWCAPS.dwAlignStride. READ ONLY.
*)
DDCAPS_ALIGNSTRIDE = $00000020;
 
(*
* Display hardware is capable of blt operations.
*)
DDCAPS_BLT = $00000040;
 
(*
* Display hardware is capable of asynchronous blt operations.
*)
DDCAPS_BLTQUEUE = $00000080;
 
(*
* Display hardware is capable of color space conversions during the blt operation.
*)
DDCAPS_BLTFOURCC = $00000100;
 
(*
* Display hardware is capable of stretching during blt operations.
*)
DDCAPS_BLTSTRETCH = $00000200;
 
(*
* Display hardware is shared with GDI.
*)
DDCAPS_GDI = $00000400;
 
(*
* Display hardware can overlay.
*)
DDCAPS_OVERLAY = $00000800;
 
(*
* Set if display hardware supports overlays but can not clip them.
*)
DDCAPS_OVERLAYCANTCLIP = $00001000;
 
(*
* Indicates that overlay hardware is capable of color space conversions during
* the overlay operation.
*)
DDCAPS_OVERLAYFOURCC = $00002000;
 
(*
* Indicates that stretching can be done by the overlay hardware.
*)
DDCAPS_OVERLAYSTRETCH = $00004000;
 
(*
* Indicates that unique DirectDrawPalettes can be created for DirectDrawSurfaces
* other than the primary surface.
*)
DDCAPS_PALETTE = $00008000;
 
(*
* Indicates that palette changes can be syncd with the veritcal refresh.
*)
DDCAPS_PALETTEVSYNC = $00010000;
 
(*
* Display hardware can return the current scan line.
*)
DDCAPS_READSCANLINE = $00020000;
 
(*
* Display hardware has stereo vision capabilities. DDSCAPS_PRIMARYSURFACELEFT
* can be created.
*)
DDCAPS_STEREOVIEW = $00040000;
 
(*
* Display hardware is capable of generating a vertical blank interrupt.
*)
DDCAPS_VBI = $00080000;
 
(*
* Supports the use of z buffers with blt operations.
*)
DDCAPS_ZBLTS = $00100000;
 
(*
* Supports Z Ordering of overlays.
*)
DDCAPS_ZOVERLAYS = $00200000;
 
(*
* Supports color key
*)
DDCAPS_COLORKEY = $00400000;
 
(*
* Supports alpha surfaces
*)
DDCAPS_ALPHA = $00800000;
 
(*
* colorkey is hardware assisted(DDCAPS_COLORKEY will also be set)
*)
DDCAPS_COLORKEYHWASSIST = $01000000;
 
(*
* no hardware support at all
*)
DDCAPS_NOHARDWARE = $02000000;
 
(*
* Display hardware is capable of color fill with bltter
*)
DDCAPS_BLTCOLORFILL = $04000000;
 
(*
* Display hardware is bank switched, and potentially very slow at
* random access to VRAM.
*)
DDCAPS_BANKSWITCHED = $08000000;
 
(*
* Display hardware is capable of depth filling Z-buffers with bltter
*)
DDCAPS_BLTDEPTHFILL = $10000000;
 
(*
* Display hardware is capable of clipping while bltting.
*)
DDCAPS_CANCLIP = $20000000;
 
(*
* Display hardware is capable of clipping while stretch bltting.
*)
DDCAPS_CANCLIPSTRETCHED = $40000000;
 
(*
* Display hardware is capable of bltting to or from system memory
*)
DDCAPS_CANBLTSYSMEM = $80000000;
 
{ More DirectDraw Driver Capability Flags (dwCaps2) }
 
(****************************************************************************
*
* MORE DIRECTDRAW DRIVER CAPABILITY FLAGS (dwCaps2)
*
****************************************************************************)
 
(*
* Display hardware is certified
*)
DDCAPS2_CERTIFIED = $00000001;
 
(*
* Driver cannot interleave 2D operations (lock and blt) to surfaces with
* Direct3D rendering operations between calls to BeginScene() and EndScene()
*)
DDCAPS2_NO2DDURING3DSCENE = $00000002;
 
(*
* Display hardware contains a video port
*)
DDCAPS2_VIDEOPORT = $00000004;
 
(*
* The overlay can be automatically flipped according to the video port
* VSYNCs, providing automatic doubled buffered display of video port
* data using an overlay
*)
DDCAPS2_AUTOFLIPOVERLAY = $00000008;
 
(*
* Overlay can display each field of interlaced data individually while
* it is interleaved in memory without causing jittery artifacts.
*)
DDCAPS2_CANBOBINTERLEAVED = $00000010;
 
(*
* Overlay can display each field of interlaced data individually while
* it is not interleaved in memory without causing jittery artifacts.
*)
DDCAPS2_CANBOBNONINTERLEAVED = $00000020;
 
(*
* The overlay surface contains color controls (brightness, sharpness, etc.)
*)
DDCAPS2_COLORCONTROLOVERLAY = $00000040;
 
(*
* The primary surface contains color controls (gamma, etc.)
*)
DDCAPS2_COLORCONTROLPRIMARY = $00000080;
 
(*
* RGBZ -> RGB supported for 16:16 RGB:Z
*)
DDCAPS2_CANDROPZ16BIT = $00000100;
 
(*
* Driver supports non-local video memory.
*)
DDCAPS2_NONLOCALVIDMEM = $00000200;
 
(*
* Dirver supports non-local video memory but has different capabilities for
* non-local video memory surfaces. If this bit is set then so must
* DDCAPS2_NONLOCALVIDMEM.
*)
DDCAPS2_NONLOCALVIDMEMCAPS = $00000400;
 
(*
* Driver neither requires nor prefers surfaces to be pagelocked when performing
* blts involving system memory surfaces
*)
DDCAPS2_NOPAGELOCKREQUIRED = $00000800;
 
(*
* Driver can create surfaces which are wider than the primary surface
*)
DDCAPS2_WIDESURFACES = $00001000;
 
(*
* Driver supports bob without using a video port by handling the
* DDFLIP_ODD and DDFLIP_EVEN flags specified in Flip.
*)
DDCAPS2_CANFLIPODDEVEN = $00002000;
 
(*
* Driver supports bob using hardware
*)
DDCAPS2_CANBOBHARDWARE = $00004000;
 
(*
* Driver supports bltting any FOURCC surface to another surface of the same FOURCC
*)
DDCAPS2_COPYFOURCC = $00008000;
DDCAPS2_PRIMARYGAMMA = $00020000;
DDCAPS2_CANRENDERWINDOWED = $00080000;
DDCAPS2_CANCALIBRATEGAMMA = $00100000;
DDCAPS2_FLIPINTERVAL = $00200000;
DDCAPS2_FLIPNOVSYNC = $00400000;
DDCAPS2_CANMANAGETEXTURE = $00800000;
DDCAPS2_TEXMANINNONLOCALVIDMEM = $01000000;
DDCAPS2_STEREO = $02000000;
DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL = $04000000;
 
{ DirectDrawSurface Capability Flags }
 
(*
* Driver supports loadable gamma ramps for the primary surface
*)
DDCAPS2_PRIMARYGAMMA = $00020000;
DDSCAPS_RESERVED1 = $00000001; { DDSCAPS_3D }
DDSCAPS_ALPHA = $00000002;
DDSCAPS_BACKBUFFER = $00000004;
DDSCAPS_COMPLEX = $00000008;
DDSCAPS_FLIP = $00000010;
DDSCAPS_FRONTBUFFER = $00000020;
DDSCAPS_OFFSCREENPLAIN = $00000040;
DDSCAPS_OVERLAY = $00000080;
DDSCAPS_PALETTE = $00000100;
DDSCAPS_PRIMARYSURFACE = $00000200;
DDSCAPS_RESERVED3 = $00000400; { DDSCAPS_PRIMARYSURFACELEFT }
DDSCAPS_SYSTEMMEMORY = $00000800;
DDSCAPS_TEXTURE = $00001000;
DDSCAPS_3DDEVICE = $00002000;
DDSCAPS_VIDEOMEMORY = $00004000;
DDSCAPS_VISIBLE = $00008000;
DDSCAPS_WRITEONLY = $00010000;
DDSCAPS_ZBUFFER = $00020000;
DDSCAPS_OWNDC = $00040000;
DDSCAPS_LIVEVIDEO = $00080000;
DDSCAPS_HWCODEC = $00100000;
DDSCAPS_MODEX = $00200000;
DDSCAPS_MIPMAP = $00400000;
DDSCAPS_RESERVED2 = $00800000;
DDSCAPS_ALLOCONLOAD = $04000000;
DDSCAPS_VIDEOPORT = $08000000;
DDSCAPS_LOCALVIDMEM = $10000000;
DDSCAPS_NONLOCALVIDMEM = $20000000;
DDSCAPS_STANDARDVGAMODE = $40000000;
DDSCAPS_OPTIMIZED = $80000000;
 
(*
* Driver can render in windowed mode.
*)
DDCAPS2_CANRENDERWINDOWED = $00080000;
{ DirectDrawSurface Capability Flags 2 }
 
(*
* A calibrator is available to adjust the gamma ramp according to the
* physical display properties so that the result will be identical on
* all calibrated systems.
*)
DDCAPS2_CANCALIBRATEGAMMA = $00100000;
DDSCAPS2_HARDWAREDEINTERLACE = $00000002;
DDSCAPS2_HINTDYNAMIC = $00000004;
DDSCAPS2_HINTSTATIC = $00000008;
DDSCAPS2_TEXTUREMANAGE = $00000010;
DDSCAPS2_RESERVED1 = $00000020;
DDSCAPS2_RESERVED2 = $00000040;
DDSCAPS2_OPAQUE = $00000080;
DDSCAPS2_HINTANTIALIASING = $00000100;
DDSCAPS2_CUBEMAP = $00000200;
DDSCAPS2_CUBEMAP_POSITIVEX = $00000400;
DDSCAPS2_CUBEMAP_NEGATIVEX = $00000800;
DDSCAPS2_CUBEMAP_POSITIVEY = $00001000;
DDSCAPS2_CUBEMAP_NEGATIVEY = $00002000;
DDSCAPS2_CUBEMAP_POSITIVEZ = $00004000;
DDSCAPS2_CUBEMAP_NEGATIVEZ = $00008000;
 
(*
* Indicates that the driver will respond to DDFLIP_INTERVALn flags
*)
DDCAPS2_FLIPINTERVAL = $00200000;
DDSCAPS2_CUBEMAP_ALLFACES =
DDSCAPS2_CUBEMAP_POSITIVEX or DDSCAPS2_CUBEMAP_NEGATIVEX or
DDSCAPS2_CUBEMAP_POSITIVEY or DDSCAPS2_CUBEMAP_NEGATIVEY or
DDSCAPS2_CUBEMAP_POSITIVEZ or DDSCAPS2_CUBEMAP_NEGATIVEZ;
 
(*
* Indicates that the driver will respond to DDFLIP_NOVSYNC
*)
DDCAPS2_FLIPNOVSYNC = $00400000;
DDSCAPS2_MIPMAPSUBLEVEL = $00010000;
DDSCAPS2_D3DTEXTUREMANAGE = $00020000;
DDSCAPS2_DONOTPERSIST = $00040000;
DDSCAPS2_STEREOSURFACELEFT = $00080000;
 
(*
* Driver supports management of video memory, if this flag is ON,
* driver manages the texture if requested with DDSCAPS2_TEXTUREMANAGE on
* DirectX manages the texture if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on
*)
DDCAPS2_CANMANAGETEXTURE = $00800000;
{ TDDOptSurfaceDesc flags }
 
(*
* The Direct3D texture manager uses this cap to decide whether to put managed
* surfaces in non-local video memory. If the cap is set, the texture manager will
* put managed surfaces in non-local vidmem. Drivers that cannot texture from
* local vidmem SHOULD NOT set this cap.
*)
DDCAPS2_TEXMANINNONLOCALVIDMEM = $01000000;
DDOSD_GUID = $00000001;
DDOSD_COMPRESSION_RATIO = $00000002;
DDOSD_SCAPS = $00000004;
DDOSD_OSCAPS = $00000008;
DDOSD_ALL = $0000000F;
 
(*
* Indicates that the driver supports DX7 type of stereo in at least one mode (which may
* not necessarily be the current mode). Applications should use IDirectDraw7 (or higher)
* ::EnumDisplayModes and check the DDSURFACEDESC.ddsCaps.dwCaps2 field for the presence of
* DDSCAPS2_STEREOSURFACELEFT to check if a particular mode supports stereo. The application
* can also use IDirectDraw7(or higher)::GetDisplayMode to check the current mode.
*)
DDCAPS2_STEREO = $02000000;
{ ddOSCaps field is valid. }
 
(*
* This caps bit is intended for internal DirectDraw use.
* -It is only valid if DDCAPS2_NONLOCALVIDMEMCAPS is set.
* -If this bit is set, then DDCAPS_CANBLTSYSMEM MUST be set by the driver (and
* all the assoicated system memory blt caps must be correct).
* -It implies that the system->video blt caps in DDCAPS also apply to system to
* nonlocal blts. I.e. the dwSVBCaps, dwSVBCKeyCaps, dwSVBFXCaps and dwSVBRops
* members of DDCAPS (DDCORECAPS) are filled in correctly.
* -Any blt from system to nonlocal memory that matches these caps bits will
* be passed to the driver.
*
* NOTE: This is intended to enable the driver itself to do efficient reordering
* of textures. This is NOT meant to imply that hardware can write into AGP memory.
* This operation is not currently supported.
*)
DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL = $04000000;
DDOSDCAPS_OPTCOMPRESSED = $00000001;
DDOSDCAPS_OPTREORDERED = $00000002;
DDOSDCAPS_MONOLITHICMIPMAP = $00000004;
DDOSDCAPS_VALIDSCAPS = $30004800;
DDOSDCAPS_VALIDOSCAPS = $00000007;
 
(****************************************************************************
*
* DIRECTDRAW FX ALPHA CAPABILITY FLAGS
*
****************************************************************************)
{ DirectDraw FX Alpha Capability Flags }
 
(*
* Supports alpha blending around the edge of a source color keyed surface.
* For Blt.
*)
DDFXALPHACAPS_BLTALPHAEDGEBLEND = $00000001;
 
(*
* Supports alpha information in the pixel format. The bit depth of alpha
* information in the pixel format can be 1,2,4, or 8. The alpha value becomes
* more opaque as the alpha value increases. (0 is transparent.)
* For Blt.
*)
DDFXALPHACAPS_BLTALPHAPIXELS = $00000002;
 
(*
* Supports alpha information in the pixel format. The bit depth of alpha
* information in the pixel format can be 1,2,4, or 8. The alpha value
* becomes more transparent as the alpha value increases. (0 is opaque.)
* This flag can only be set if DDCAPS_ALPHA is set.
* For Blt.
*)
DDFXALPHACAPS_BLTALPHAPIXELSNEG = $00000004;
 
(*
* Supports alpha only surfaces. The bit depth of an alpha only surface can be
* 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases.
* (0 is transparent.)
* For Blt.
*)
DDFXALPHACAPS_BLTALPHASURFACES = $00000008;
 
(*
* The depth of the alpha channel data can range can be 1,2,4, or 8.
* The NEG suffix indicates that this alpha channel becomes more transparent
* as the alpha value increases. (0 is opaque.) This flag can only be set if
* DDCAPS_ALPHA is set.
* For Blt.
*)
DDFXALPHACAPS_BLTALPHASURFACESNEG = $00000010;
 
(*
* Supports alpha blending around the edge of a source color keyed surface.
* For Overlays.
*)
DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND = $00000020;
 
(*
* Supports alpha information in the pixel format. The bit depth of alpha
* information in the pixel format can be 1,2,4, or 8. The alpha value becomes
* more opaque as the alpha value increases. (0 is transparent.)
* For Overlays.
*)
DDFXALPHACAPS_OVERLAYALPHAPIXELS = $00000040;
 
(*
* Supports alpha information in the pixel format. The bit depth of alpha
* information in the pixel format can be 1,2,4, or 8. The alpha value
* becomes more transparent as the alpha value increases. (0 is opaque.)
* This flag can only be set if DDCAPS_ALPHA is set.
* For Overlays.
*)
DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG = $00000080;
 
(*
* Supports alpha only surfaces. The bit depth of an alpha only surface can be
* 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases.
* (0 is transparent.)
* For Overlays.
*)
DDFXALPHACAPS_OVERLAYALPHASURFACES = $00000100;
 
(*
* The depth of the alpha channel data can range can be 1,2,4, or 8.
* The NEG suffix indicates that this alpha channel becomes more transparent
* as the alpha value increases. (0 is opaque.) This flag can only be set if
* DDCAPS_ALPHA is set.
* For Overlays.
*)
DDFXALPHACAPS_OVERLAYALPHASURFACESNEG = $00000200;
 
(****************************************************************************
*
* DIRECTDRAW FX CAPABILITY FLAGS
*
****************************************************************************)
{ DirectDraw FX Capability Flags }
 
(*
* Uses arithmetic operations to stretch and shrink surfaces during blt
* rather than pixel doubling techniques. Along the Y axis.
*)
DDFXCAPS_BLTARITHSTRETCHY = $00000020;
 
(*
* Uses arithmetic operations to stretch during blt
* rather than pixel doubling techniques. Along the Y axis. Only
* works for x1, x2, etc.
*)
DDFXCAPS_BLTARITHSTRETCHYN = $00000010;
 
(*
* Supports mirroring left to right in blt.
*)
DDFXCAPS_BLTMIRRORLEFTRIGHT = $00000040;
 
(*
* Supports mirroring top to bottom in blt.
*)
DDFXCAPS_BLTMIRRORUPDOWN = $00000080;
 
(*
* Supports arbitrary rotation for blts.
*)
DDFXCAPS_BLTROTATION = $00000100;
 
(*
* Supports 90 degree rotations for blts.
*)
DDFXCAPS_BLTROTATION90 = $00000200;
 
(*
* DirectDraw supports arbitrary shrinking of a surface along the
* x axis (horizontal direction) for blts.
*)
DDFXCAPS_BLTSHRINKX = $00000400;
 
(*
* DirectDraw supports integer shrinking (1x,2x,) of a surface
* along the x axis (horizontal direction) for blts.
*)
DDFXCAPS_BLTSHRINKXN = $00000800;
 
(*
* DirectDraw supports arbitrary shrinking of a surface along the
* y axis (horizontal direction) for blts.
*)
DDFXCAPS_BLTSHRINKY = $00001000;
 
(*
* DirectDraw supports integer shrinking (1x,2x,) of a surface
* along the y axis (vertical direction) for blts.
*)
DDFXCAPS_BLTSHRINKYN = $00002000;
 
(*
* DirectDraw supports arbitrary stretching of a surface along the
* x axis (horizontal direction) for blts.
*)
DDFXCAPS_BLTSTRETCHX = $00004000;
 
(*
* DirectDraw supports integer stretching (1x,2x,) of a surface
* along the x axis (horizontal direction) for blts.
*)
DDFXCAPS_BLTSTRETCHXN = $00008000;
 
(*
* DirectDraw supports arbitrary stretching of a surface along the
* y axis (horizontal direction) for blts.
*)
DDFXCAPS_BLTSTRETCHY = $00010000;
 
(*
* DirectDraw supports integer stretching (1x,2x,) of a surface
* along the y axis (vertical direction) for blts.
*)
DDFXCAPS_BLTSTRETCHYN = $00020000;
 
(*
* Uses arithmetic operations to stretch and shrink surfaces during
* overlay rather than pixel doubling techniques. Along the Y axis
* for overlays.
*)
DDFXCAPS_OVERLAYARITHSTRETCHY = $00040000;
 
(*
* Uses arithmetic operations to stretch surfaces during
* overlay rather than pixel doubling techniques. Along the Y axis
* for overlays. Only works for x1, x2, etc.
*)
DDFXCAPS_OVERLAYARITHSTRETCHYN = $00000008;
 
(*
* DirectDraw supports arbitrary shrinking of a surface along the
* x axis (horizontal direction) for overlays.
*)
DDFXCAPS_OVERLAYSHRINKX = $00080000;
 
(*
* DirectDraw supports integer shrinking (1x,2x,) of a surface
* along the x axis (horizontal direction) for overlays.
*)
DDFXCAPS_OVERLAYSHRINKXN = $00100000;
 
(*
* DirectDraw supports arbitrary shrinking of a surface along the
* y axis (horizontal direction) for overlays.
*)
DDFXCAPS_OVERLAYSHRINKY = $00200000;
 
(*
* DirectDraw supports integer shrinking (1x,2x,) of a surface
* along the y axis (vertical direction) for overlays.
*)
DDFXCAPS_OVERLAYSHRINKYN = $00400000;
 
(*
* DirectDraw supports arbitrary stretching of a surface along the
* x axis (horizontal direction) for overlays.
*)
DDFXCAPS_OVERLAYSTRETCHX = $00800000;
 
(*
* DirectDraw supports integer stretching (1x,2x,) of a surface
* along the x axis (horizontal direction) for overlays.
*)
DDFXCAPS_OVERLAYSTRETCHXN = $01000000;
 
(*
* DirectDraw supports arbitrary stretching of a surface along the
* y axis (horizontal direction) for overlays.
*)
DDFXCAPS_OVERLAYSTRETCHY = $02000000;
 
(*
* DirectDraw supports integer stretching (1x,2x,) of a surface
* along the y axis (vertical direction) for overlays.
*)
DDFXCAPS_OVERLAYSTRETCHYN = $04000000;
 
(*
* DirectDraw supports mirroring of overlays across the vertical axis
*)
DDFXCAPS_OVERLAYMIRRORLEFTRIGHT = $08000000;
 
(*
* DirectDraw supports mirroring of overlays across the horizontal axis
*)
DDFXCAPS_OVERLAYMIRRORUPDOWN = $10000000;
 
(*
* Driver can do alpha blending for blits.
*)
DDFXCAPS_BLTALPHA = $00000001;
 
(*
* Driver can do geometric transformations (or warps) for blits.
*)
DDFXCAPS_BLTTRANSFORM = $00000002;
 
(*
* Driver can do surface-reconstruction filtering for warped blits.
*)
DDFXCAPS_BLTFILTER = DDFXCAPS_BLTARITHSTRETCHY;
 
(*
* Driver can do alpha blending for overlays.
*)
DDFXCAPS_OVERLAYALPHA = $00000004;
 
(*
* Driver can do geometric transformations (or warps) for overlays.
*)
DDFXCAPS_OVERLAYTRANSFORM = $20000000;
 
(*
* Driver can do surface-reconstruction filtering for warped overlays.
*)
DDFXCAPS_OVERLAYFILTER = DDFXCAPS_OVERLAYARITHSTRETCHY;
 
(****************************************************************************
*
* DIRECTDRAW STEREO VIEW CAPABILITIES
*
****************************************************************************)
{ DirectDraw Stereo View Capabilities }
 
(*
* This flag used to be DDSVCAPS_ENIGMA, which is now obsolete
* The stereo view is accomplished via enigma encoding.
*)
DDSVCAPS_RESERVED1 = $00000001;
DDSVCAPS_ENIGMA = DDSVCAPS_RESERVED1;
 
(*
* This flag used to be DDSVCAPS_FLICKER, which is now obsolete
* The stereo view is accomplished via high frequency flickering.
*)
DDSVCAPS_RESERVED2 = $00000002;
DDSVCAPS_FLICKER = DDSVCAPS_RESERVED2;
 
(*
* This flag used to be DDSVCAPS_REDBLUE, which is now obsolete
* The stereo view is accomplished via red and blue filters applied
* to the left and right eyes. All images must adapt their colorspaces
* for this process.
*)
DDSVCAPS_RESERVED3 = $00000004;
DDSVCAPS_REDBLUE = DDSVCAPS_RESERVED3;
 
(*
* This flag used to be DDSVCAPS_SPLIT, which is now obsolete
* The stereo view is accomplished with split screen technology.
*)
DDSVCAPS_RESERVED4 = $00000008;
DDSVCAPS_SPLIT = DDSVCAPS_RESERVED4;
 
(*
* The stereo view is accomplished with switching technology
*)
DDSVCAPS_STEREOSEQUENTIAL = $00000010;
 
(****************************************************************************
*
* DIRECTDRAWPALETTE CAPABILITIES
*
****************************************************************************)
{ DirectDrawPalette Capabilities }
 
(*
* Index is 4 bits. There are sixteen color entries in the palette table.
*)
DDPCAPS_4BIT = $00000001;
 
(*
* Index is onto a 8 bit color index. This field is only valid with the
* DDPCAPS_1BIT, DDPCAPS_2BIT or DDPCAPS_4BIT capability and the target
* surface is in 8bpp. Each color entry is one byte long and is an index
* into destination surface's 8bpp palette.
*)
DDPCAPS_8BITENTRIES = $00000002;
 
(*
* Index is 8 bits. There are 256 color entries in the palette table.
*)
DDPCAPS_8BIT = $00000004;
 
(*
* Indicates that this DIRECTDRAWPALETTE should use the palette color array
* passed into the lpDDColorArray parameter to initialize the DIRECTDRAWPALETTE
* object.
* This flag is obsolete. DirectDraw always initializes the color array from
* the lpDDColorArray parameter. The definition remains for source-level
* compatibility.
*)
DDPCAPS_INITIALIZE = $00000008;
 
(*
* This palette is the one attached to the primary surface. Changing this
* table has immediate effect on the display unless DDPSETPAL_VSYNC is specified
* and supported.
*)
DDPCAPS_PRIMARYSURFACE = $00000010;
 
(*
* This palette is the one attached to the primary surface left. Changing
* this table has immediate effect on the display for the left eye unless
* DDPSETPAL_VSYNC is specified and supported.
*)
DDPCAPS_PRIMARYSURFACELEFT = $00000020;
 
(*
* This palette can have all 256 entries defined
*)
DDPCAPS_ALLOW256 = $00000040;
 
(*
* This palette can have modifications to it synced with the monitors
* refresh rate.
*)
DDPCAPS_VSYNC = $00000080;
 
(*
* Index is 1 bit. There are two color entries in the palette table.
*)
DDPCAPS_1BIT = $00000100;
 
(*
* Index is 2 bit. There are four color entries in the palette table.
*)
DDPCAPS_2BIT = $00000200;
 
(*
* The peFlags member of PALETTEENTRY denotes an 8 bit alpha value
*)
DDPCAPS_ALPHA = $00000400;
 
(****************************************************************************
*
* DIRECTDRAWPALETTE SETENTRY CONSTANTS
*
****************************************************************************)
{ DirectDraw BitDepth Constants }
 
 
(****************************************************************************
*
* DIRECTDRAWPALETTE GETENTRY CONSTANTS
*
****************************************************************************)
 
(* 0 is the only legal value *)
 
(****************************************************************************
*
* DIRECTDRAWSURFACE SETPALETTE CONSTANTS
*
****************************************************************************)
 
(*
* The passed pointer is an IUnknown ptr. The cbData argument to SetPrivateData
* must be set to sizeof(IUnknown^). DirectDraw will call AddRef through this
* pointer and Release when the private data is destroyed. This includes when
* the surface or palette is destroyed before such priovate data is destroyed.
*)
DDSPD_IUNKNOWNPOINTER = $00000001;
 
(*
* Private data is only valid for the current state of the object,
* as determined by the uniqueness value.
*)
DDSPD_VOLATILE = $00000002;
 
(****************************************************************************
*
* DIRECTDRAWSURFACE SETPALETTE CONSTANTS
*
****************************************************************************)
 
 
(****************************************************************************
*
* DIRECTDRAW BITDEPTH CONSTANTS
*
* NOTE: These are only used to indicate supported bit depths. These
* are flags only, they are not to be used as an actual bit depth. The
* absolute numbers 1, 2, 4, 8, 16, 24 and 32 are used to indicate actual
* bit depths in a surface or for changing the display mode.
*
****************************************************************************)
 
(*
* 1 bit per pixel.
*)
DDBD_1 = $00004000;
 
(*
* 2 bits per pixel.
*)
DDBD_2 = $00002000;
 
(*
* 4 bits per pixel.
*)
DDBD_4 = $00001000;
 
(*
* 8 bits per pixel.
*)
DDBD_8 = $00000800;
 
(*
* 16 bits per pixel.
*)
DDBD_16 = $00000400;
 
(*
* 24 bits per pixel.
*)
DDBD_24 = $00000200;
 
(*
* 32 bits per pixel.
*)
DDBD_32 = $00000100;
 
(****************************************************************************
*
* DIRECTDRAWSURFACE SET/GET COLOR KEY FLAGS
*
****************************************************************************)
{ DirectDraw Set/Get Color Key Flags }
 
(*
* Set if the structure contains a color space. Not set if the structure
* contains a single color key.
*)
DDCKEY_COLORSPACE = $00000001;
 
(*
* Set if the structure specifies a color key or color space which is to be
* used as a destination color key for blt operations.
*)
DDCKEY_DESTBLT = $00000002;
 
(*
* Set if the structure specifies a color key or color space which is to be
* used as a destination color key for overlay operations.
*)
DDCKEY_DESTOVERLAY = $00000004;
 
(*
* Set if the structure specifies a color key or color space which is to be
* used as a source color key for blt operations.
*)
DDCKEY_SRCBLT = $00000008;
 
(*
* Set if the structure specifies a color key or color space which is to be
* used as a source color key for overlay operations.
*)
DDCKEY_SRCOVERLAY = $00000010;
 
{ DirectDraw Color Key Capability Flags }
 
(****************************************************************************
*
* DIRECTDRAW COLOR KEY CAPABILITY FLAGS
*
****************************************************************************)
 
(*
* Supports transparent blting using a color key to identify the replaceable
* bits of the destination surface for RGB colors.
*)
DDCKEYCAPS_DESTBLT = $00000001;
 
(*
* Supports transparent blting using a color space to identify the replaceable
* bits of the destination surface for RGB colors.
*)
DDCKEYCAPS_DESTBLTCLRSPACE = $00000002;
 
(*
* Supports transparent blting using a color space to identify the replaceable
* bits of the destination surface for YUV colors.
*)
DDCKEYCAPS_DESTBLTCLRSPACEYUV = $00000004;
 
(*
* Supports transparent blting using a color key to identify the replaceable
* bits of the destination surface for YUV colors.
*)
DDCKEYCAPS_DESTBLTYUV = $00000008;
 
(*
* Supports overlaying using colorkeying of the replaceable bits of the surface
* being overlayed for RGB colors.
*)
DDCKEYCAPS_DESTOVERLAY = $00000010;
 
(*
* Supports a color space as the color key for the destination for RGB colors.
*)
DDCKEYCAPS_DESTOVERLAYCLRSPACE = $00000020;
 
(*
* Supports a color space as the color key for the destination for YUV colors.
*)
DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV = $00000040;
 
(*
* Supports only one active destination color key value for visible overlay
* surfaces.
*)
DDCKEYCAPS_DESTOVERLAYONEACTIVE = $00000080;
 
(*
* Supports overlaying using colorkeying of the replaceable bits of the
* surface being overlayed for YUV colors.
*)
DDCKEYCAPS_DESTOVERLAYYUV = $00000100;
 
(*
* Supports transparent blting using the color key for the source with
* this surface for RGB colors.
*)
DDCKEYCAPS_SRCBLT = $00000200;
 
(*
* Supports transparent blting using a color space for the source with
* this surface for RGB colors.
*)
DDCKEYCAPS_SRCBLTCLRSPACE = $00000400;
 
(*
* Supports transparent blting using a color space for the source with
* this surface for YUV colors.
*)
DDCKEYCAPS_SRCBLTCLRSPACEYUV = $00000800;
 
(*
* Supports transparent blting using the color key for the source with
* this surface for YUV colors.
*)
DDCKEYCAPS_SRCBLTYUV = $00001000;
 
(*
* Supports overlays using the color key for the source with this
* overlay surface for RGB colors.
*)
DDCKEYCAPS_SRCOVERLAY = $00002000;
 
(*
* Supports overlays using a color space as the source color key for
* the overlay surface for RGB colors.
*)
DDCKEYCAPS_SRCOVERLAYCLRSPACE = $00004000;
 
(*
* Supports overlays using a color space as the source color key for
* the overlay surface for YUV colors.
*)
DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV = $00008000;
 
(*
* Supports only one active source color key value for visible
* overlay surfaces.
*)
DDCKEYCAPS_SRCOVERLAYONEACTIVE = $00010000;
 
(*
* Supports overlays using the color key for the source with this
* overlay surface for YUV colors.
*)
DDCKEYCAPS_SRCOVERLAYYUV = $00020000;
 
(*
* there are no bandwidth trade-offs for using colorkey with an overlay
*)
DDCKEYCAPS_NOCOSTOVERLAY = $00040000;
 
{ DirectDraw PixelFormat Flags }
 
(****************************************************************************
*
* DIRECTDRAW PIXELFORMAT FLAGS
*
****************************************************************************)
 
(*
* The surface has alpha channel information in the pixel format.
*)
DDPF_ALPHAPIXELS = $00000001;
 
(*
* The pixel format contains alpha only information
*)
DDPF_ALPHA = $00000002;
 
(*
* The FourCC code is valid.
*)
DDPF_FOURCC = $00000004;
 
(*
* The surface is 4-bit color indexed.
*)
DDPF_PALETTEINDEXED4 = $00000008;
 
(*
* The surface is indexed into a palette which stores indices
* into the destination surface's 8-bit palette.
*)
DDPF_PALETTEINDEXEDTO8 = $00000010;
 
(*
* The surface is 8-bit color indexed.
*)
DDPF_PALETTEINDEXED8 = $00000020;
 
(*
* The RGB data in the pixel format structure is valid.
*)
DDPF_RGB = $00000040;
 
(*
* The surface will accept pixel data in the format specified
* and compress it during the write.
*)
DDPF_COMPRESSED = $00000080;
 
(*
* The surface will accept RGB data and translate it during
* the write to YUV data. The format of the data to be written
* will be contained in the pixel format structure. The DDPF_RGB
* flag will be set.
*)
DDPF_RGBTOYUV = $00000100;
 
(*
* pixel format is YUV - YUV data in pixel format struct is valid
*)
DDPF_YUV = $00000200;
 
(*
* pixel format is a z buffer only surface
*)
DDPF_ZBUFFER = $00000400;
 
(*
* The surface is 1-bit color indexed.
*)
DDPF_PALETTEINDEXED1 = $00000800;
 
(*
* The surface is 2-bit color indexed.
*)
DDPF_PALETTEINDEXED2 = $00001000;
 
(*
* The surface contains Z information in the pixels
*)
DDPF_ZPIXELS = $00002000;
 
(*
* The surface contains stencil information along with Z
*)
DDPF_STENCILBUFFER = $00004000;
 
(*
* Premultiplied alpha format -- the color components have been
* premultiplied by the alpha component.
*)
DDPF_ALPHAPREMULT = $00008000;
DDPF_LUMINANCE = $00020000;
DDPF_BUMPLUMINANCE = $00040000;
DDPF_BUMPDUDV = $00080000;
 
{ DirectDraw SetDisplayMode Flags }
 
(*
* Luminance data in the pixel format is valid.
* Use this flag for luminance-only or luminance+alpha surfaces,
* the bit depth is then ddpf.dwLuminanceBitCount.
*)
DDPF_LUMINANCE = $00020000;
DDSDM_STANDARDVGAMODE = $00000001;
 
(*
* Luminance data in the pixel format is valid.
* Use this flag when hanging luminance off bumpmap surfaces,
* the bit mask for the luminance portion of the pixel is then
* ddpf.dwBumpLuminanceBitMask
*)
DDPF_BUMPLUMINANCE = $00040000;
{ DirectDraw EnumDisplayModes Flags }
 
(*
* Bump map dUdV data in the pixel format is valid.
*)
DDPF_BUMPDUDV = $00080000;
DDEDM_REFRESHRATES = $00000001;
DDEDM_STANDARDVGAMODES = $00000002;
 
(*===========================================================================
*
*
* DIRECTDRAW CALLBACK FLAGS
*
*
*==========================================================================*)
{ DirectDraw EnumSurfaces Flags }
 
(****************************************************************************
*
* DIRECTDRAW ENUMSURFACES FLAGS
*
****************************************************************************)
 
(*
* Enumerate all of the surfaces that meet the search criterion.
*)
DDENUMSURFACES_ALL = $00000001;
 
(*
* A search hit is a surface that matches the surface description.
*)
DDENUMSURFACES_MATCH = $00000002;
 
(*
* A search hit is a surface that does not match the surface description.
*)
DDENUMSURFACES_NOMATCH = $00000004;
 
(*
* Enumerate the first surface that can be created which meets the search criterion.
*)
DDENUMSURFACES_CANBECREATED = $00000008;
 
(*
* Enumerate the surfaces that already exist that meet the search criterion.
*)
DDENUMSURFACES_DOESEXIST = $00000010;
 
(****************************************************************************
*
* DIRECTDRAW SETDISPLAYMODE FLAGS
*
****************************************************************************)
{ DirectDraw SetCooperativeLevel Flags }
 
(*
* The desired mode is a standard VGA mode
*)
DDSDM_STANDARDVGAMODE = $00000001;
 
(****************************************************************************
*
* DIRECTDRAW ENUMDISPLAYMODES FLAGS
*
****************************************************************************)
 
(*
* Enumerate Modes with different refresh rates. EnumDisplayModes guarantees
* that a particular mode will be enumerated only once. This flag specifies whether
* the refresh rate is taken into account when determining if a mode is unique.
*)
DDEDM_REFRESHRATES = $00000001;
 
(*
* Enumerate VGA modes. Specify this flag if you wish to enumerate supported VGA
* modes such as mode 0x13 in addition to the usual ModeX modes (which are always
* enumerated if the application has previously called SetCooperativeLevel with the
* DDSCL_ALLOWMODEX flag set).
*)
DDEDM_STANDARDVGAMODES = $00000002;
 
 
(****************************************************************************
*
* DIRECTDRAW SETCOOPERATIVELEVEL FLAGS
*
****************************************************************************)
 
(*
* Exclusive mode owner will be responsible for the entire primary surface.
* GDI can be ignored. used with DD
*)
DDSCL_FULLSCREEN = $00000001;
 
(*
* allow CTRL_ALT_DEL to work while in fullscreen exclusive mode
*)
DDSCL_ALLOWREBOOT = $00000002;
 
(*
* prevents DDRAW from modifying the application window.
* prevents DDRAW from minimize/restore the application window on activation.
*)
DDSCL_NOWINDOWCHANGES = $00000004;
 
(*
* app wants to work as a regular Windows application
*)
DDSCL_NORMAL = $00000008;
 
(*
* app wants exclusive access
*)
DDSCL_EXCLUSIVE = $00000010;
 
 
(*
* app can deal with non-windows display modes
*)
DDSCL_ALLOWMODEX = $00000040;
 
(*
* this window will receive the focus messages
*)
DDSCL_SETFOCUSWINDOW = $00000080;
 
(*
* this window is associated with the DDRAW object and will
* cover the screen in fullscreen mode
*)
DDSCL_SETDEVICEWINDOW = $00000100;
 
(*
* app wants DDRAW to create a window to be associated with the
* DDRAW object
*)
DDSCL_CREATEDEVICEWINDOW = $00000200;
 
(*
* App explicitly asks DDRAW/D3D to be multithread safe. This makes D3D
* take the global crtisec more frequently.
*)
DDSCL_MULTITHREADED = $00000400;
 
(*
* App hints that it would like to keep the FPU set up for optimal Direct3D
* performance (single precision and exceptions disabled) so Direct3D
* does not need to explicitly set the FPU each time
*)
DDSCL_FPUSETUP = $00000800;
 
(*
* App specifies that it needs either double precision FPU or FPU exceptions
* enabled. This makes Direct3D explicitly set the FPU state eah time it is
* called. Setting the flag will reduce Direct3D performance. The flag is
* assumed by default in DirectX 6 and earlier. See also DDSCL_FPUSETUP
*)
DDSCL_FPUPRESERVE = $00001000;
 
(****************************************************************************
*
* DIRECTDRAW BLT FLAGS
*
****************************************************************************)
{ DirectDraw Blt Flags }
 
(*
* Use the alpha information in the pixel format or the alpha channel surface
* attached to the destination surface as the alpha channel for this blt.
*)
DDBLT_ALPHADEST = $00000001;
 
(*
* Use the dwConstAlphaDest field in the TDDBltFX structure as the alpha channel
* for the destination surface for this blt.
*)
DDBLT_ALPHADESTCONSTOVERRIDE = $00000002;
 
(*
* The NEG suffix indicates that the destination surface becomes more
* transparent as the alpha value increases. (0 is opaque)
*)
DDBLT_ALPHADESTNEG = $00000004;
 
(*
* Use the lpDDSAlphaDest field in the TDDBltFX structure as the alpha
* channel for the destination for this blt.
*)
DDBLT_ALPHADESTSURFACEOVERRIDE = $00000008;
 
(*
* Use the dwAlphaEdgeBlend field in the TDDBltFX structure as the alpha channel
* for the edges of the image that border the color key colors.
*)
DDBLT_ALPHAEDGEBLEND = $00000010;
 
(*
* Use the alpha information in the pixel format or the alpha channel surface
* attached to the source surface as the alpha channel for this blt.
*)
DDBLT_ALPHASRC = $00000020;
 
(*
* Use the dwConstAlphaSrc field in the TDDBltFX structure as the alpha channel
* for the source for this blt.
*)
DDBLT_ALPHASRCCONSTOVERRIDE = $00000040;
 
(*
* The NEG suffix indicates that the source surface becomes more transparent
* as the alpha value increases. (0 is opaque)
*)
DDBLT_ALPHASRCNEG = $00000080;
 
(*
* Use the lpDDSAlphaSrc field in the TDDBltFX structure as the alpha channel
* for the source for this blt.
*)
DDBLT_ALPHASRCSURFACEOVERRIDE = $00000100;
 
(*
* Do this blt asynchronously through the FIFO in the order received. If
* there is no room in the hardware FIFO fail the call.
*)
DDBLT_ASYNC = $00000200;
 
(*
* Uses the dwFillColor field in the TDDBltFX structure as the RGB color
* to fill the destination rectangle on the destination surface with.
*)
DDBLT_COLORFILL = $00000400;
 
(*
* Uses the dwDDFX field in the TDDBltFX structure to specify the effects
* to use for the blt.
*)
DDBLT_DDFX = $00000800;
 
(*
* Uses the dwDDROPS field in the TDDBltFX structure to specify the ROPS
* that are not part of the Win32 API.
*)
DDBLT_DDROPS = $00001000;
 
(*
* Use the color key associated with the destination surface.
*)
DDBLT_KEYDEST = $00002000;
 
(*
* Use the dckDestColorkey field in the TDDBltFX structure as the color key
* for the destination surface.
*)
DDBLT_KEYDESTOVERRIDE = $00004000;
 
(*
* Use the color key associated with the source surface.
*)
DDBLT_KEYSRC = $00008000;
 
(*
* Use the dckSrcColorkey field in the TDDBltFX structure as the color key
* for the source surface.
*)
DDBLT_KEYSRCOVERRIDE = $00010000;
 
(*
* Use the dwROP field in the TDDBltFX structure for the raster operation
* for this blt. These ROPs are the same as the ones defined in the Win32 API.
*)
DDBLT_ROP = $00020000;
 
(*
* Use the dwRotationAngle field in the TDDBltFX structure as the angle
* (specified in 1/100th of a degree) to rotate the surface.
*)
DDBLT_ROTATIONANGLE = $00040000;
 
(*
* Z-buffered blt using the z-buffers attached to the source and destination
* surfaces and the dwZBufferOpCode field in the TDDBltFX structure as the
* z-buffer opcode.
*)
DDBLT_ZBUFFER = $00080000;
 
(*
* Z-buffered blt using the dwConstDest Zfield and the dwZBufferOpCode field
* in the TDDBltFX structure as the z-buffer and z-buffer opcode respectively
* for the destination.
*)
DDBLT_ZBUFFERDESTCONSTOVERRIDE = $00100000;
 
(*
* Z-buffered blt using the lpDDSDestZBuffer field and the dwZBufferOpCode
* field in the TDDBltFX structure as the z-buffer and z-buffer opcode
* respectively for the destination.
*)
DDBLT_ZBUFFERDESTOVERRIDE = $00200000;
 
(*
* Z-buffered blt using the dwConstSrcZ field and the dwZBufferOpCode field
* in the TDDBltFX structure as the z-buffer and z-buffer opcode respectively
* for the source.
*)
DDBLT_ZBUFFERSRCCONSTOVERRIDE = $00400000;
 
(*
* Z-buffered blt using the lpDDSSrcZBuffer field and the dwZBufferOpCode
* field in the TDDBltFX structure as the z-buffer and z-buffer opcode
* respectively for the source.
*)
DDBLT_ZBUFFERSRCOVERRIDE = $00800000;
 
(*
* wait until the device is ready to handle the blt
* this will cause blt to not return DDERR_WASSTILLDRAWING
*)
DDBLT_WAIT = $01000000;
 
(*
* Uses the dwFillDepth field in the TDDBltFX structure as the depth value
* to fill the destination rectangle on the destination Z-buffer surface
* with.
*)
DDBLT_DEPTHFILL = $02000000;
 
(*
* wait until the device is ready to handle the blt
* this will cause blt to not return DDERR_WASSTILLDRAWING
*)
DDBLT_DONOTWAIT = $08000000;
 
(****************************************************************************
*
* BLTFAST FLAGS
*
****************************************************************************)
{ BltFast Flags }
 
DDBLTFAST_NOCOLORKEY = $00000000;
DDBLTFAST_SRCCOLORKEY = $00000001;
3484,1387 → 1843,310
DDBLTFAST_WAIT = $00000010;
DDBLTFAST_DONOTWAIT = $00000020;
 
(****************************************************************************
*
* FLIP FLAGS
*
****************************************************************************)
{ Flip Flags }
 
 
DDFLIP_WAIT = $00000001;
 
(*
* Indicates that the target surface contains the even field of video data.
* This flag is only valid with an overlay surface.
*)
DDFLIP_EVEN = $00000002;
 
(*
* Indicates that the target surface contains the odd field of video data.
* This flag is only valid with an overlay surface.
*)
DDFLIP_ODD = $00000004;
 
(*
* Causes DirectDraw to perform the physical flip immediately and return
* to the application. Typically, what was the front buffer but is now the back
* buffer will still be visible (depending on timing) until the next vertical
* retrace. Subsequent operations involving the two flipped surfaces will
* not check to see if the physical flip has finished (i.e. will not return
* DDERR_WASSTILLDRAWING for that reason (but may for other reasons)).
* This allows an application to perform Flips at a higher frequency than the
* monitor refresh rate, but may introduce visible artifacts.
* Only effective if DDCAPS2_FLIPNOVSYNC is set. If that bit is not set,
* DDFLIP_NOVSYNC has no effect.
*)
DDFLIP_NOVSYNC = $00000008;
 
 
(*
* Flip Interval Flags. These flags indicate how many vertical retraces to wait between
* each flip. The default is one. DirectDraw will return DDERR_WASSTILLDRAWING for each
* surface involved in the flip until the specified number of vertical retraces has
* ocurred. Only effective if DDCAPS2_FLIPINTERVAL is set. If that bit is not set,
* DDFLIP_INTERVALn has no effect.
*)
 
(*
* DirectDraw will flip on every other vertical sync
*)
DDFLIP_INTERVAL2 = $02000000;
 
 
(*
* DirectDraw will flip on every third vertical sync
*)
DDFLIP_INTERVAL3 = $03000000;
 
 
(*
* DirectDraw will flip on every fourth vertical sync
*)
DDFLIP_INTERVAL4 = $04000000;
 
(*
* DirectDraw will flip and display a main stereo surface
*)
DDFLIP_STEREO = $00000010;
 
(*
* On IDirectDrawSurface7 and higher interfaces, the default is DDFLIP_WAIT. If you wish
* to override the default and use time when the accelerator is busy (as denoted by
* the DDERR_WASSTILLDRAWING return code) then use DDFLIP_DONOTWAIT.
*)
DDFLIP_DONOTWAIT = $00000020;
 
(****************************************************************************
*
* DIRECTDRAW SURFACE OVERLAY FLAGS
*
****************************************************************************)
{ DirectDraw Surface Overlay Flags }
 
(*
* Use the alpha information in the pixel format or the alpha channel surface
* attached to the destination surface as the alpha channel for the
* destination overlay.
*)
DDOVER_ALPHADEST = $00000001;
 
(*
* Use the dwConstAlphaDest field in the TDDOverlayFX structure as the
* destination alpha channel for this overlay.
*)
DDOVER_ALPHADESTCONSTOVERRIDE = $00000002;
 
(*
* The NEG suffix indicates that the destination surface becomes more
* transparent as the alpha value increases.
*)
DDOVER_ALPHADESTNEG = $00000004;
 
(*
* Use the lpDDSAlphaDest field in the TDDOverlayFX structure as the alpha
* channel destination for this overlay.
*)
DDOVER_ALPHADESTSURFACEOVERRIDE = $00000008;
 
(*
* Use the dwAlphaEdgeBlend field in the TDDOverlayFX structure as the alpha
* channel for the edges of the image that border the color key colors.
*)
DDOVER_ALPHAEDGEBLEND = $00000010;
 
(*
* Use the alpha information in the pixel format or the alpha channel surface
* attached to the source surface as the source alpha channel for this overlay.
*)
DDOVER_ALPHASRC = $00000020;
 
(*
* Use the dwConstAlphaSrc field in the TDDOverlayFX structure as the source
* alpha channel for this overlay.
*)
DDOVER_ALPHASRCCONSTOVERRIDE = $00000040;
 
(*
* The NEG suffix indicates that the source surface becomes more transparent
* as the alpha value increases.
*)
DDOVER_ALPHASRCNEG = $00000080;
 
(*
* Use the lpDDSAlphaSrc field in the TDDOverlayFX structure as the alpha channel
* source for this overlay.
*)
DDOVER_ALPHASRCSURFACEOVERRIDE = $00000100;
 
(*
* Turn this overlay off.
*)
DDOVER_HIDE = $00000200;
 
(*
* Use the color key associated with the destination surface.
*)
DDOVER_KEYDEST = $00000400;
 
(*
* Use the dckDestColorkey field in the TDDOverlayFX structure as the color key
* for the destination surface
*)
DDOVER_KEYDESTOVERRIDE = $00000800;
 
(*
* Use the color key associated with the source surface.
*)
DDOVER_KEYSRC = $00001000;
 
(*
* Use the dckSrcColorkey field in the TDDOverlayFX structure as the color key
* for the source surface.
*)
DDOVER_KEYSRCOVERRIDE = $00002000;
 
(*
* Turn this overlay on.
*)
DDOVER_SHOW = $00004000;
 
(*
* Add a dirty rect to an emulated overlayed surface.
*)
DDOVER_ADDDIRTYRECT = $00008000;
 
(*
* Redraw all dirty rects on an emulated overlayed surface.
*)
DDOVER_REFRESHDIRTYRECTS = $00010000;
 
(*
* Redraw the entire surface on an emulated overlayed surface.
*)
DDOVER_REFRESHALL = $00020000;
 
(*
* Use the overlay FX flags to define special overlay FX
*)
DDOVER_DDFX = $00080000;
 
(*
* Autoflip the overlay when ever the video port autoflips
*)
DDOVER_AUTOFLIP = $00100000;
 
(*
* Display each field of video port data individually without
* causing any jittery artifacts
*)
DDOVER_BOB = $00200000;
 
(*
* Indicates that bob/weave decisions should not be overridden by other
* interfaces.
*)
DDOVER_OVERRIDEBOBWEAVE = $00400000;
 
(*
* Indicates that the surface memory is composed of interleaved fields.
*)
DDOVER_INTERLEAVED = $00800000;
 
(*
* Indicates that bob will be performed using hardware rather than
* software or emulated.
*)
DDOVER_BOBHARDWARE = $01000000;
 
(*
* Indicates that overlay FX structure contains valid ARGB scaling factors.
*)
DDOVER_ARGBSCALEFACTORS = $02000000;
 
(*
* Indicates that ARGB scaling factors can be degraded to fit driver capabilities.
*)
DDOVER_DEGRADEARGBSCALING = $04000000;
 
(****************************************************************************
*
* DIRECTDRAWSURFACE LOCK FLAGS
*
****************************************************************************)
{ DirectDrawSurface Lock Flags }
 
(*
* The default. Set to indicate that Lock should return a valid memory pointer
* to the top of the specified rectangle. If no rectangle is specified then a
* pointer to the top of the surface is returned.
*)
DDLOCK_SURFACEMEMORYPTR = $00000000; // = default
 
(*
* Set to indicate that Lock should wait until it can obtain a valid memory
* pointer before returning. If this bit is set, Lock will never return
* DDERR_WASSTILLDRAWING.
*)
DDLOCK_SURFACEMEMORYPTR = $00000000; // default
DDLOCK_WAIT = $00000001;
 
(*
* Set if an event handle is being passed to Lock. Lock will trigger the event
* when it can return the surface memory pointer requested.
*)
DDLOCK_EVENT = $00000002;
 
(*
* Indicates that the surface being locked will only be read from.
*)
DDLOCK_READONLY = $00000010;
 
(*
* Indicates that the surface being locked will only be written to
*)
DDLOCK_WRITEONLY = $00000020;
 
(*
* Indicates that a system wide lock should not be taken when this surface
* is locked. This has several advantages (cursor responsiveness, ability
* to call more Windows functions, easier debugging) when locking video
* memory surfaces. However, an application specifying this flag must
* comply with a number of conditions documented in the help file.
* Furthermore, this flag cannot be specified when locking the primary.
*)
DDLOCK_NOSYSLOCK = $00000800;
 
(*
* Used only with Direct3D Vertex Buffer Locks. Indicates that no vertices
* that were referred to in Draw*PrimtiveVB calls since the start of the
* frame (or the last lock without this flag) will be modified during the
* lock. This can be useful when one is only appending data to the vertex
* buffer
*)
DDLOCK_NOOVERWRITE = $00001000;
 
(*
* Indicates that no assumptions will be made about the contents of the
* surface or vertex buffer during this lock.
* This enables two things:
* - Direct3D or the driver may provide an alternative memory
* area as the vertex buffer. This is useful when one plans to clear the
* contents of the vertex buffer and fill in new data.
* - Drivers sometimes store surface data in a re-ordered format.
* When the application locks the surface, the driver is forced to un-re-order
* the surface data before allowing the application to see the surface contents.
* This flag is a hint to the driver that it can skip the un-re-ordering process
* since the application plans to overwrite every single pixel in the surface
* or locked rectangle (and so erase any un-re-ordered pixels anyway).
* Applications should always set this flag when they intend to overwrite the entire
* surface or locked rectangle.
*)
DDLOCK_DISCARDCONTENTS = $00002000;
(*
* DDLOCK_OKTOSWAP is an older, less informative name for DDLOCK_DISCARDCONTENTS
*)
DDLOCK_OKTOSWAP = $00002000;
 
(*
* On IDirectDrawSurface7 and higher interfaces, the default is DDLOCK_WAIT. If you wish
* to override the default and use time when the accelerator is busy (as denoted by
* the DDERR_WASSTILLDRAWING return code) then use DDLOCK_DONOTWAIT.
*)
DDLOCK_DONOTWAIT = $00004000;
 
{ DirectDrawSurface Blt FX Flags }
 
(****************************************************************************
*
* DIRECTDRAWSURFACE PAGELOCK FLAGS
*
****************************************************************************)
 
(*
* No flags defined at present
*)
 
 
(****************************************************************************
*
* DIRECTDRAWSURFACE PAGEUNLOCK FLAGS
*
****************************************************************************)
 
(*
* No flags defined at present
*)
 
 
(****************************************************************************
*
* DIRECTDRAWSURFACE BLT FX FLAGS
*
****************************************************************************)
 
(*
* If stretching, use arithmetic stretching along the Y axis for this blt.
*)
DDBLTFX_ARITHSTRETCHY = $00000001;
 
(*
* Do this blt mirroring the surface left to right. Spin the
* surface around its y-axis.
*)
DDBLTFX_MIRRORLEFTRIGHT = $00000002;
 
(*
* Do this blt mirroring the surface up and down. Spin the surface
* around its x-axis.
*)
DDBLTFX_MIRRORUPDOWN = $00000004;
 
(*
* Schedule this blt to avoid tearing.
*)
DDBLTFX_NOTEARING = $00000008;
 
(*
* Do this blt rotating the surface one hundred and eighty degrees.
*)
DDBLTFX_ROTATE180 = $00000010;
 
(*
* Do this blt rotating the surface two hundred and seventy degrees.
*)
DDBLTFX_ROTATE270 = $00000020;
 
(*
* Do this blt rotating the surface ninety degrees.
*)
DDBLTFX_ROTATE90 = $00000040;
 
(*
* Do this z blt using dwZBufferLow and dwZBufferHigh as range values
* specified to limit the bits copied from the source surface.
*)
DDBLTFX_ZBUFFERRANGE = $00000080;
 
(*
* Do this z blt adding the dwZBufferBaseDest to each of the sources z values
* before comparing it with the desting z values.
*)
DDBLTFX_ZBUFFERBASEDEST = $00000100;
 
(****************************************************************************
*
* DIRECTDRAWSURFACE OVERLAY FX FLAGS
*
****************************************************************************)
{ DirectDrawSurface Overlay FX Flags }
 
(*
* If stretching, use arithmetic stretching along the Y axis for this overlay.
*)
DDOVERFX_ARITHSTRETCHY = $00000001;
 
(*
* Mirror the overlay across the vertical axis
*)
DDOVERFX_MIRRORLEFTRIGHT = $00000002;
 
(*
* Mirror the overlay across the horizontal axis
*)
DDOVERFX_MIRRORUPDOWN = $00000004;
 
(****************************************************************************
*
* Flags for dwDDFX member of DDSPRITEFX structure
*
****************************************************************************)
(*
* Use affine transformation matrix in fTransform member.
*)
{ Flags for dwDDFX member of DDSPRITEFX structure }
 
DDSPRITEFX_AFFINETRANSFORM = $00000001;
 
(*
* Use RGBA scaling factors in ddrgbaScaleFactors member.
*)
DDSPRITEFX_RGBASCALING = $00000002;
 
(*
* Degrade RGBA scaling factors to accommodate driver's capabilities.
*)
DDSPRITEFX_DEGRADERGBASCALING = $00000004;
 
(*
* Do bilinear filtering of stretched or warped sprite.
*)
DDSPRITEFX_BILINEARFILTER = $00000008;
 
(*
* Do "blur" filtering of stretched or warped sprite.
*)
DDSPRITEFX_BLURFILTER = $00000010;
 
(*
* Do "flat" filtering of stretched or warped sprite.
*)
DDSPRITEFX_FLATFILTER = $00000020;
 
(*
* Degrade filtering operation to accommodate driver's capabilities.
*)
DDSPRITEFX_DEGRADEFILTER = $00000040;
 
(****************************************************************************
*
* DIRECTDRAW WAITFORVERTICALBLANK FLAGS
*
****************************************************************************)
{ DirectDraw WaitForVerticalBlank Flags }
 
(*
* return when the vertical blank interval begins
*)
DDWAITVB_BLOCKBEGIN = $00000001;
 
(*
* set up an event to trigger when the vertical blank begins
*)
DDWAITVB_BLOCKBEGINEVENT = $00000002;
 
(*
* return when the vertical blank interval ends and display begins
*)
DDWAITVB_BLOCKEND = $00000004;
 
(****************************************************************************
*
* DIRECTDRAW GETFLIPSTATUS FLAGS
*
****************************************************************************)
{ DirectDraw GetFlipStatus Flags }
 
(*
* is it OK to flip now?
*)
DDGFS_CANFLIP = $00000001;
 
(*
* is the last flip finished?
*)
DDGFS_ISFLIPDONE = $00000002;
 
(****************************************************************************
*
* DIRECTDRAW GETBLTSTATUS FLAGS
*
****************************************************************************)
{ DirectDraw GetBltStatus Flags }
 
(*
* is it OK to blt now?
*)
DDGBS_CANBLT = $00000001;
 
(*
* is the blt to the surface finished?
*)
DDGBS_ISBLTDONE = $00000002;
 
{ DirectDraw EnumOverlayZOrder Flags }
 
(****************************************************************************
*
* DIRECTDRAW ENUMOVERLAYZORDER FLAGS
*
****************************************************************************)
 
(*
* Enumerate overlays back to front.
*)
DDENUMOVERLAYZ_BACKTOFRONT = $00000000;
 
(*
* Enumerate overlays front to back
*)
DDENUMOVERLAYZ_FRONTTOBACK = $00000001;
 
(****************************************************************************
*
* DIRECTDRAW UPDATEOVERLAYZORDER FLAGS
*
****************************************************************************)
{ DirectDraw UpdateOverlayZOrder Flags }
 
(*
* Send overlay to front
*)
DDOVERZ_SENDTOFRONT = $00000000;
 
(*
* Send overlay to back
*)
DDOVERZ_SENDTOBACK = $00000001;
 
(*
* Move Overlay forward
*)
DDOVERZ_MOVEFORWARD = $00000002;
 
(*
* Move Overlay backward
*)
DDOVERZ_MOVEBACKWARD = $00000003;
 
(*
* Move Overlay in front of relative surface
*)
DDOVERZ_INSERTINFRONTOF = $00000004;
 
(*
* Move Overlay in back of relative surface
*)
DDOVERZ_INSERTINBACKOF = $00000005;
 
(****************************************************************************
*
* DIRECTDRAW SETGAMMARAMP FLAGS
*
****************************************************************************)
{ DirectDrawSurface SetPrivateData Constants }
 
(*
* Request calibrator to adjust the gamma ramp according to the physical
* properties of the display so that the result should appear identical
* on all systems.
*)
DDSPD_IUNKNOWNPOINTER = $00000001;
DDSPD_VOLATILE = $00000002;
 
{ TDDColorControl flags }
 
DDCOLOR_BRIGHTNESS = $00000001;
DDCOLOR_CONTRAST = $00000002;
DDCOLOR_HUE = $00000004;
DDCOLOR_SATURATION = $00000008;
DDCOLOR_SHARPNESS = $00000010;
DDCOLOR_GAMMA = $00000020;
DDCOLOR_COLORENABLE = $00000040;
 
{ DirectDraw SetGammaRamp Flags }
 
DDSGR_CALIBRATE = $00000001;
 
(****************************************************************************
*
* DIRECTDRAW STARTMODETEST FLAGS
*
****************************************************************************)
{ DirectDraw StartModeTest Flags }
 
(*
* Indicates that the mode being tested has passed
*)
DDSMT_ISTESTREQUIRED = $00000001;
 
{ DirectDraw EvaluateMode Flags }
 
(****************************************************************************
*
* DIRECTDRAW EVALUATEMODE FLAGS
*
****************************************************************************)
 
(*
* Indicates that the mode being tested has passed
*)
DDEM_MODEPASSED = $00000001;
 
(*
* Indicates that the mode being tested has failed
*)
DDEM_MODEFAILED = $00000002;
 
(*===========================================================================
*
*
* DIRECTDRAW RETURN CODES
*
* The return values from DirectDraw Commands and Surface that return an HResult
* are codes from DirectDraw concerning the results of the action
* requested by DirectDraw.
*
*==========================================================================*)
{ DirectDraw Return Codes }
 
(*
* Status is OK
*
* Issued by: DirectDraw Commands and all callbacks
*)
DD_OK = 0;
DD_FALSE = S_FALSE;
DD_OK = HResult(0);
DD_FALSE = HResult(S_FALSE);
 
(****************************************************************************
*
* DIRECTDRAW ENUMCALLBACK RETURN VALUES
*
* EnumCallback returns are used to control the flow of the DIRECTDRAW and
* DIRECTDRAWSURFACE object enumerations. They can only be returned by
* enumeration callback routines.
*
****************************************************************************)
{ DirectDraw EnumCallback Return Values }
 
(*
* stop the enumeration
*)
DDENUMRET_CANCEL = 0;
 
(*
* continue the enumeration
*)
DDENUMRET_OK = 1;
 
(****************************************************************************
*
* DIRECTDRAW ERRORS
*
* Errors are represented by negative values and cannot be combined.
*
****************************************************************************)
{ DirectDraw Error Codes }
 
_FACDD = $876;
MAKE_DDHRESULT = HResult(1 shl 31) or HResult(_FACDD shl 16);
DDERR_ALREADYINITIALIZED = HResult($88760000 + 5);
DDERR_CANNOTATTACHSURFACE = HResult($88760000 + 10);
DDERR_CANNOTDETACHSURFACE = HResult($88760000 + 20);
DDERR_CURRENTLYNOTAVAIL = HResult($88760000 + 40);
DDERR_EXCEPTION = HResult($88760000 + 55);
DDERR_GENERIC = HResult(E_FAIL);
DDERR_HEIGHTALIGN = HResult($88760000 + 90);
DDERR_INCOMPATIBLEPRIMARY = HResult($88760000 + 95);
DDERR_INVALIDCAPS = HResult($88760000 + 100);
DDERR_INVALIDCLIPLIST = HResult($88760000 + 110);
DDERR_INVALIDMODE = HResult($88760000 + 120);
DDERR_INVALIDOBJECT = HResult($88760000 + 130);
DDERR_INVALIDPARAMS = HResult(E_INVALIDARG);
DDERR_INVALIDPIXELFORMAT = HResult($88760000 + 145);
DDERR_INVALIDRECT = HResult($88760000 + 150);
DDERR_LOCKEDSURFACES = HResult($88760000 + 160);
DDERR_NO3D = HResult($88760000 + 170);
DDERR_NOALPHAHW = HResult($88760000 + 180);
DDERR_NOSTEREOHARDWARE = HResult($88760000 + 181);
DDERR_NOSURFACELEFT = HResult($88760000 + 182);
DDERR_NOCLIPLIST = HResult($88760000 + 205);
DDERR_NOCOLORCONVHW = HResult($88760000 + 210);
DDERR_NOCOOPERATIVELEVELSET = HResult($88760000 + 212);
DDERR_NOCOLORKEY = HResult($88760000 + 215);
DDERR_NOCOLORKEYHW = HResult($88760000 + 220);
DDERR_NODIRECTDRAWSUPPORT = HResult($88760000 + 222);
DDERR_NOEXCLUSIVEMODE = HResult($88760000 + 225);
DDERR_NOFLIPHW = HResult($88760000 + 230);
DDERR_NOGDI = HResult($88760000 + 240);
DDERR_NOMIRRORHW = HResult($88760000 + 250);
DDERR_NOTFOUND = HResult($88760000 + 255);
DDERR_NOOVERLAYHW = HResult($88760000 + 260);
DDERR_OVERLAPPINGRECTS = HResult($88760000 + 270);
DDERR_NORASTEROPHW = HResult($88760000 + 280);
DDERR_NOROTATIONHW = HResult($88760000 + 290);
DDERR_NOSTRETCHHW = HResult($88760000 + 310);
DDERR_NOT4BITCOLOR = HResult($88760000 + 316);
DDERR_NOT4BITCOLORINDEX = HResult($88760000 + 317);
DDERR_NOT8BITCOLOR = HResult($88760000 + 320);
DDERR_NOTEXTUREHW = HResult($88760000 + 330);
DDERR_NOVSYNCHW = HResult($88760000 + 335);
DDERR_NOZBUFFERHW = HResult($88760000 + 340);
DDERR_NOZOVERLAYHW = HResult($88760000 + 350);
DDERR_OUTOFCAPS = HResult($88760000 + 360);
DDERR_OUTOFMEMORY = HResult(E_OUTOFMEMORY);
DDERR_OUTOFVIDEOMEMORY = HResult($88760000 + 380);
DDERR_OVERLAYCANTCLIP = HResult($88760000 + 382);
DDERR_OVERLAYCOLORKEYONLYONEACTIVE = HResult($88760000 + 384);
DDERR_PALETTEBUSY = HResult($88760000 + 387);
DDERR_COLORKEYNOTSET = HResult($88760000 + 400);
DDERR_SURFACEALREADYATTACHED = HResult($88760000 + 410);
DDERR_SURFACEALREADYDEPENDENT = HResult($88760000 + 420);
DDERR_SURFACEBUSY = HResult($88760000 + 430);
DDERR_CANTLOCKSURFACE = HResult($88760000 + 435);
DDERR_SURFACEISOBSCURED = HResult($88760000 + 440);
DDERR_SURFACELOST = HResult($88760000 + 450);
DDERR_SURFACENOTATTACHED = HResult($88760000 + 460);
DDERR_TOOBIGHEIGHT = HResult($88760000 + 470);
DDERR_TOOBIGSIZE = HResult($88760000 + 480);
DDERR_TOOBIGWIDTH = HResult($88760000 + 490);
DDERR_UNSUPPORTED = HResult(E_NOTIMPL);
DDERR_UNSUPPORTEDFORMAT = HResult($88760000 + 510);
DDERR_UNSUPPORTEDMASK = HResult($88760000 + 520);
DDERR_INVALIDSTREAM = HResult($88760000 + 521);
DDERR_VERTICALBLANKINPROGRESS = HResult($88760000 + 537);
DDERR_WASSTILLDRAWING = HResult($88760000 + 540);
DDERR_DDSCAPSCOMPLEXREQUIRED = HResult($88760000 + 542);
DDERR_XALIGN = HResult($88760000 + 560);
DDERR_INVALIDDIRECTDRAWGUID = HResult($88760000 + 561);
DDERR_DIRECTDRAWALREADYCREATED = HResult($88760000 + 562);
DDERR_NODIRECTDRAWHW = HResult($88760000 + 563);
DDERR_PRIMARYSURFACEALREADYEXISTS = HResult($88760000 + 564);
DDERR_NOEMULATION = HResult($88760000 + 565);
DDERR_REGIONTOOSMALL = HResult($88760000 + 566);
DDERR_CLIPPERISUSINGHWND = HResult($88760000 + 567);
DDERR_NOCLIPPERATTACHED = HResult($88760000 + 568);
DDERR_NOHWND = HResult($88760000 + 569);
DDERR_HWNDSUBCLASSED = HResult($88760000 + 570);
DDERR_HWNDALREADYSET = HResult($88760000 + 571);
DDERR_NOPALETTEATTACHED = HResult($88760000 + 572);
DDERR_NOPALETTEHW = HResult($88760000 + 573);
DDERR_BLTFASTCANTCLIP = HResult($88760000 + 574);
DDERR_NOBLTHW = HResult($88760000 + 575);
DDERR_NODDROPSHW = HResult($88760000 + 576);
DDERR_OVERLAYNOTVISIBLE = HResult($88760000 + 577);
DDERR_NOOVERLAYDEST = HResult($88760000 + 578);
DDERR_INVALIDPOSITION = HResult($88760000 + 579);
DDERR_NOTAOVERLAYSURFACE = HResult($88760000 + 580);
DDERR_EXCLUSIVEMODEALREADYSET = HResult($88760000 + 581);
DDERR_NOTFLIPPABLE = HResult($88760000 + 582);
DDERR_CANTDUPLICATE = HResult($88760000 + 583);
DDERR_NOTLOCKED = HResult($88760000 + 584);
DDERR_CANTCREATEDC = HResult($88760000 + 585);
DDERR_NODC = HResult($88760000 + 586);
DDERR_WRONGMODE = HResult($88760000 + 587);
DDERR_IMPLICITLYCREATED = HResult($88760000 + 588);
DDERR_NOTPALETTIZED = HResult($88760000 + 589);
DDERR_UNSUPPORTEDMODE = HResult($88760000 + 590);
DDERR_NOMIPMAPHW = HResult($88760000 + 591);
DDERR_INVALIDSURFACETYPE = HResult($88760000 + 592);
DDERR_NOOPTIMIZEHW = HResult($88760000 + 600);
DDERR_NOTLOADED = HResult($88760000 + 601);
DDERR_NOFOCUSWINDOW = HResult($88760000 + 602);
DDERR_NOTONMIPMAPSUBLEVEL = HResult($88760000 + 603);
DDERR_DCALREADYCREATED = HResult($88760000 + 620);
DDERR_NONONLOCALVIDMEM = HResult($88760000 + 630);
DDERR_CANTPAGELOCK = HResult($88760000 + 640);
DDERR_CANTPAGEUNLOCK = HResult($88760000 + 660);
DDERR_NOTPAGELOCKED = HResult($88760000 + 680);
DDERR_MOREDATA = HResult($88760000 + 690);
DDERR_EXPIRED = HResult($88760000 + 691);
DDERR_TESTFINISHED = HResult($88760000 + 692);
DDERR_NEWMODE = HResult($88760000 + 693);
DDERR_D3DNOTINITIALIZED = HResult($88760000 + 694);
DDERR_VIDEONOTACTIVE = HResult($88760000 + 695);
DDERR_NOMONITORINFORMATION = HResult($88760000 + 696);
DDERR_NODRIVERSUPPORT = HResult($88760000 + 697);
DDERR_DEVICEDOESNTOWNSURFACE = HResult($88760000 + 699);
DDERR_NOTINITIALIZED = HResult(CO_E_NOTINITIALIZED);
 
{ API's }
 
(*
* This object is already initialized
*)
DDERR_ALREADYINITIALIZED = MAKE_DDHRESULT + 5;
function GET_WHQL_YEAR(dwWHQLLevel: DWORD): DWORD;
function GET_WHQL_MONTH(dwWHQLLevel: DWORD): DWORD;
function GET_WHQL_DAY(dwWHQLLevel: DWORD): DWORD;
 
(*
* This surface can not be attached to the requested surface.
*)
DDERR_CANNOTATTACHSURFACE = MAKE_DDHRESULT + 10;
 
(*
* This surface can not be detached from the requested surface.
*)
DDERR_CANNOTDETACHSURFACE = MAKE_DDHRESULT + 20;
 
(*
* Support is currently not available.
*)
DDERR_CURRENTLYNOTAVAIL = MAKE_DDHRESULT + 40;
 
(*
* An exception was encountered while performing the requested operation
*)
DDERR_EXCEPTION = MAKE_DDHRESULT + 55;
 
(*
* Generic failure.
*)
DDERR_GENERIC = E_FAIL;
 
(*
* Height of rectangle provided is not a multiple of reqd alignment
*)
DDERR_HEIGHTALIGN = MAKE_DDHRESULT + 90;
 
(*
* Unable to match primary surface creation request with existing
* primary surface.
*)
DDERR_INCOMPATIBLEPRIMARY = MAKE_DDHRESULT + 95;
 
(*
* One or more of the caps bits passed to the callback are incorrect.
*)
DDERR_INVALIDCAPS = MAKE_DDHRESULT + 100;
 
(*
* DirectDraw does not support provided Cliplist.
*)
DDERR_INVALIDCLIPLIST = MAKE_DDHRESULT + 110;
 
(*
* DirectDraw does not support the requested mode
*)
DDERR_INVALIDMODE = MAKE_DDHRESULT + 120;
 
(*
* DirectDraw received a pointer that was an invalid DIRECTDRAW object.
*)
DDERR_INVALIDOBJECT = MAKE_DDHRESULT + 130;
 
(*
* One or more of the parameters passed to the callback function are
* incorrect.
*)
DDERR_INVALIDPARAMS = E_INVALIDARG;
 
(*
* pixel format was invalid as specified
*)
DDERR_INVALIDPIXELFORMAT = MAKE_DDHRESULT + 145;
 
(*
* Rectangle provided was invalid.
*)
DDERR_INVALIDRECT = MAKE_DDHRESULT + 150;
 
(*
* Operation could not be carried out because one or more surfaces are locked
*)
DDERR_LOCKEDSURFACES = MAKE_DDHRESULT + 160;
 
(*
* There is no 3D present.
*)
DDERR_NO3D = MAKE_DDHRESULT + 170;
 
(*
* Operation could not be carried out because there is no alpha accleration
* hardware present or available.
*)
DDERR_NOALPHAHW = MAKE_DDHRESULT + 180;
 
(*
* Operation could not be carried out because there is no stereo
* hardware present or available.
*)
DDERR_NOSTEREOHARDWARE = MAKE_DDHRESULT + 181;
 
(*
* Operation could not be carried out because there is no hardware
* present which supports stereo surfaces
*)
DDERR_NOSURFACELEFT = MAKE_DDHRESULT + 182;
 
(*
* no clip list available
*)
DDERR_NOCLIPLIST = MAKE_DDHRESULT + 205;
 
(*
* Operation could not be carried out because there is no color conversion
* hardware present or available.
*)
DDERR_NOCOLORCONVHW = MAKE_DDHRESULT + 210;
 
(*
* Create function called without DirectDraw object method SetCooperativeLevel
* being called.
*)
DDERR_NOCOOPERATIVELEVELSET = MAKE_DDHRESULT + 212;
 
(*
* Surface doesn't currently have a color key
*)
DDERR_NOCOLORKEY = MAKE_DDHRESULT + 215;
 
(*
* Operation could not be carried out because there is no hardware support
* of the dest color key.
*)
DDERR_NOCOLORKEYHW = MAKE_DDHRESULT + 220;
 
(*
* No DirectDraw support possible with current display driver
*)
DDERR_NODIRECTDRAWSUPPORT = MAKE_DDHRESULT + 222;
 
(*
* Operation requires the application to have exclusive mode but the
* application does not have exclusive mode.
*)
DDERR_NOEXCLUSIVEMODE = MAKE_DDHRESULT + 225;
 
(*
* Flipping visible surfaces is not supported.
*)
DDERR_NOFLIPHW = MAKE_DDHRESULT + 230;
 
(*
* There is no GDI present.
*)
DDERR_NOGDI = MAKE_DDHRESULT + 240;
 
(*
* Operation could not be carried out because there is no hardware present
* or available.
*)
DDERR_NOMIRRORHW = MAKE_DDHRESULT + 250;
 
(*
* Requested item was not found
*)
DDERR_NOTFOUND = MAKE_DDHRESULT + 255;
 
(*
* Operation could not be carried out because there is no overlay hardware
* present or available.
*)
DDERR_NOOVERLAYHW = MAKE_DDHRESULT + 260;
 
(*
* Operation could not be carried out because the source and destination
* rectangles are on the same surface and overlap each other.
*)
DDERR_OVERLAPPINGRECTS = MAKE_DDHRESULT + 270;
 
(*
* Operation could not be carried out because there is no appropriate raster
* op hardware present or available.
*)
DDERR_NORASTEROPHW = MAKE_DDHRESULT + 280;
 
(*
* Operation could not be carried out because there is no rotation hardware
* present or available.
*)
DDERR_NOROTATIONHW = MAKE_DDHRESULT + 290;
 
(*
* Operation could not be carried out because there is no hardware support
* for stretching
*)
DDERR_NOSTRETCHHW = MAKE_DDHRESULT + 310;
 
(*
* DirectDrawSurface is not in 4 bit color palette and the requested operation
* requires 4 bit color palette.
*)
DDERR_NOT4BITCOLOR = MAKE_DDHRESULT + 316;
 
(*
* DirectDrawSurface is not in 4 bit color index palette and the requested
* operation requires 4 bit color index palette.
*)
DDERR_NOT4BITCOLORINDEX = MAKE_DDHRESULT + 317;
 
(*
* DirectDraw Surface is not in 8 bit color mode and the requested operation
* requires 8 bit color.
*)
DDERR_NOT8BITCOLOR = MAKE_DDHRESULT + 320;
 
(*
* Operation could not be carried out because there is no texture mapping
* hardware present or available.
*)
DDERR_NOTEXTUREHW = MAKE_DDHRESULT + 330;
 
(*
* Operation could not be carried out because there is no hardware support
* for vertical blank synchronized operations.
*)
DDERR_NOVSYNCHW = MAKE_DDHRESULT + 335;
 
(*
* Operation could not be carried out because there is no hardware support
* for zbuffer blting.
*)
DDERR_NOZBUFFERHW = MAKE_DDHRESULT + 340;
 
(*
* Overlay surfaces could not be z layered based on their BltOrder because
* the hardware does not support z layering of overlays.
*)
DDERR_NOZOVERLAYHW = MAKE_DDHRESULT + 350;
 
(*
* The hardware needed for the requested operation has already been
* allocated.
*)
DDERR_OUTOFCAPS = MAKE_DDHRESULT + 360;
 
(*
* DirectDraw does not have enough memory to perform the operation.
*)
DDERR_OUTOFMEMORY = E_OUTOFMEMORY;
 
(*
* DirectDraw does not have enough memory to perform the operation.
*)
DDERR_OUTOFVIDEOMEMORY = MAKE_DDHRESULT + 380;
 
(*
* hardware does not support clipped overlays
*)
DDERR_OVERLAYCANTCLIP = MAKE_DDHRESULT + 382;
 
(*
* Can only have ony color key active at one time for overlays
*)
DDERR_OVERLAYCOLORKEYONLYONEACTIVE = MAKE_DDHRESULT + 384;
 
(*
* Access to this palette is being refused because the palette is already
* locked by another thread.
*)
DDERR_PALETTEBUSY = MAKE_DDHRESULT + 387;
 
(*
* No src color key specified for this operation.
*)
DDERR_COLORKEYNOTSET = MAKE_DDHRESULT + 400;
 
(*
* This surface is already attached to the surface it is being attached to.
*)
DDERR_SURFACEALREADYATTACHED = MAKE_DDHRESULT + 410;
 
(*
* This surface is already a dependency of the surface it is being made a
* dependency of.
*)
DDERR_SURFACEALREADYDEPENDENT = MAKE_DDHRESULT + 420;
 
(*
* Access to this surface is being refused because the surface is already
* locked by another thread.
*)
DDERR_SURFACEBUSY = MAKE_DDHRESULT + 430;
 
(*
* Access to this surface is being refused because no driver exists
* which can supply a pointer to the surface.
* This is most likely to happen when attempting to lock the primary
* surface when no DCI provider is present.
* Will also happen on attempts to lock an optimized surface.
*)
DDERR_CANTLOCKSURFACE = MAKE_DDHRESULT + 435;
 
(*
* Access to Surface refused because Surface is obscured.
*)
DDERR_SURFACEISOBSCURED = MAKE_DDHRESULT + 440;
 
(*
* Access to this surface is being refused because the surface is gone.
* The DIRECTDRAWSURFACE object representing this surface should
* have Restore called on it.
*)
DDERR_SURFACELOST = MAKE_DDHRESULT + 450;
 
(*
* The requested surface is not attached.
*)
DDERR_SURFACENOTATTACHED = MAKE_DDHRESULT + 460;
 
(*
* Height requested by DirectDraw is too large.
*)
DDERR_TOOBIGHEIGHT = MAKE_DDHRESULT + 470;
 
(*
* Size requested by DirectDraw is too large -- The individual height and
* width are OK.
*)
DDERR_TOOBIGSIZE = MAKE_DDHRESULT + 480;
 
(*
* Width requested by DirectDraw is too large.
*)
DDERR_TOOBIGWIDTH = MAKE_DDHRESULT + 490;
 
(*
* Action not supported.
*)
DDERR_UNSUPPORTED = E_NOTIMPL;
 
(*
* FOURCC format requested is unsupported by DirectDraw
*)
DDERR_UNSUPPORTEDFORMAT = MAKE_DDHRESULT + 510;
 
(*
* Bitmask in the pixel format requested is unsupported by DirectDraw
*)
DDERR_UNSUPPORTEDMASK = MAKE_DDHRESULT + 520;
 
(*
* The specified stream contains invalid data
*)
DDERR_INVALIDSTREAM = MAKE_DDHRESULT + 521;
 
(*
* vertical blank is in progress
*)
DDERR_VERTICALBLANKINPROGRESS = MAKE_DDHRESULT + 537;
 
(*
* Informs DirectDraw that the previous Blt which is transfering information
* to or from this Surface is incomplete.
*)
DDERR_WASSTILLDRAWING = MAKE_DDHRESULT + 540;
 
(*
* The specified surface type requires specification of the COMPLEX flag
*)
DDERR_DDSCAPSCOMPLEXREQUIRED = MAKE_DDHRESULT + 542;
 
(*
* Rectangle provided was not horizontally aligned on reqd. boundary
*)
DDERR_XALIGN = MAKE_DDHRESULT + 560;
 
(*
* The GUID passed to DirectDrawCreate is not a valid DirectDraw driver
* identifier.
*)
DDERR_INVALIDDIRECTDRAWGUID = MAKE_DDHRESULT + 561;
 
(*
* A DirectDraw object representing this driver has already been created
* for this process.
*)
DDERR_DIRECTDRAWALREADYCREATED = MAKE_DDHRESULT + 562;
 
(*
* A hardware only DirectDraw object creation was attempted but the driver
* did not support any hardware.
*)
DDERR_NODIRECTDRAWHW = MAKE_DDHRESULT + 563;
 
(*
* this process already has created a primary surface
*)
DDERR_PRIMARYSURFACEALREADYEXISTS = MAKE_DDHRESULT + 564;
 
(*
* software emulation not available.
*)
DDERR_NOEMULATION = MAKE_DDHRESULT + 565;
 
(*
* region passed to Clipper::GetClipList is too small.
*)
DDERR_REGIONTOOSMALL = MAKE_DDHRESULT + 566;
 
(*
* an attempt was made to set a clip list for a clipper objec that
* is already monitoring an hwnd.
*)
DDERR_CLIPPERISUSINGHWND = MAKE_DDHRESULT + 567;
 
(*
* No clipper object attached to surface object
*)
DDERR_NOCLIPPERATTACHED = MAKE_DDHRESULT + 568;
 
(*
* Clipper notification requires an HWND or
* no HWND has previously been set as the CooperativeLevel HWND.
*)
DDERR_NOHWND = MAKE_DDHRESULT + 569;
 
(*
* HWND used by DirectDraw CooperativeLevel has been subclassed,
* this prevents DirectDraw from restoring state.
*)
DDERR_HWNDSUBCLASSED = MAKE_DDHRESULT + 570;
 
(*
* The CooperativeLevel HWND has already been set.
* It can not be reset while the process has surfaces or palettes created.
*)
DDERR_HWNDALREADYSET = MAKE_DDHRESULT + 571;
 
(*
* No palette object attached to this surface.
*)
DDERR_NOPALETTEATTACHED = MAKE_DDHRESULT + 572;
 
(*
* No hardware support for 16 or 256 color palettes.
*)
DDERR_NOPALETTEHW = MAKE_DDHRESULT + 573;
 
(*
* If a clipper object is attached to the source surface passed into a
* BltFast call.
*)
DDERR_BLTFASTCANTCLIP = MAKE_DDHRESULT + 574;
 
(*
* No blter.
*)
DDERR_NOBLTHW = MAKE_DDHRESULT + 575;
 
(*
* No DirectDraw ROP hardware.
*)
DDERR_NODDROPSHW = MAKE_DDHRESULT + 576;
 
(*
* returned when GetOverlayPosition is called on a hidden overlay
*)
DDERR_OVERLAYNOTVISIBLE = MAKE_DDHRESULT + 577;
 
(*
* returned when GetOverlayPosition is called on a overlay that UpdateOverlay
* has never been called on to establish a destionation.
*)
DDERR_NOOVERLAYDEST = MAKE_DDHRESULT + 578;
 
(*
* returned when the position of the overlay on the destionation is no longer
* legal for that destionation.
*)
DDERR_INVALIDPOSITION = MAKE_DDHRESULT + 579;
 
(*
* returned when an overlay member is called for a non-overlay surface
*)
DDERR_NOTAOVERLAYSURFACE = MAKE_DDHRESULT + 580;
 
(*
* An attempt was made to set the cooperative level when it was already
* set to exclusive.
*)
DDERR_EXCLUSIVEMODEALREADYSET = MAKE_DDHRESULT + 581;
 
(*
* An attempt has been made to flip a surface that is not flippable.
*)
DDERR_NOTFLIPPABLE = MAKE_DDHRESULT + 582;
 
(*
* Can't duplicate primary & 3D surfaces, or surfaces that are implicitly
* created.
*)
DDERR_CANTDUPLICATE = MAKE_DDHRESULT + 583;
 
(*
* Surface was not locked. An attempt to unlock a surface that was not
* locked at all, or by this process, has been attempted.
*)
DDERR_NOTLOCKED = MAKE_DDHRESULT + 584;
 
(*
* Windows can not create any more DCs, or a DC was requested for a paltte-indexed
* surface when the surface had no palette AND the display mode was not palette-indexed
* (in this case DirectDraw cannot select a proper palette into the DC)
*)
DDERR_CANTCREATEDC = MAKE_DDHRESULT + 585;
 
(*
* No DC was ever created for this surface.
*)
DDERR_NODC = MAKE_DDHRESULT + 586;
 
(*
* This surface can not be restored because it was created in a different
* mode.
*)
DDERR_WRONGMODE = MAKE_DDHRESULT + 587;
 
(*
* This surface can not be restored because it is an implicitly created
* surface.
*)
DDERR_IMPLICITLYCREATED = MAKE_DDHRESULT + 588;
 
(*
* The surface being used is not a palette-based surface
*)
DDERR_NOTPALETTIZED = MAKE_DDHRESULT + 589;
 
(*
* The display is currently in an unsupported mode
*)
DDERR_UNSUPPORTEDMODE = MAKE_DDHRESULT + 590;
 
(*
* Operation could not be carried out because there is no mip-map
* texture mapping hardware present or available.
*)
DDERR_NOMIPMAPHW = MAKE_DDHRESULT + 591;
 
(*
* The requested action could not be performed because the surface was of
* the wrong type.
*)
DDERR_INVALIDSURFACETYPE = MAKE_DDHRESULT + 592;
 
(*
* Device does not support optimized surfaces, therefore no video memory optimized surfaces
*)
DDERR_NOOPTIMIZEHW = MAKE_DDHRESULT + 600;
 
(*
* Surface is an optimized surface, but has not yet been allocated any memory
*)
DDERR_NOTLOADED = MAKE_DDHRESULT + 601;
 
(*
* Attempt was made to create or set a device window without first setting
* the focus window
*)
DDERR_NOFOCUSWINDOW = MAKE_DDHRESULT + 602;
 
(*
* Attempt was made to set a palette on a mipmap sublevel
*)
DDERR_NOTONMIPMAPSUBLEVEL = MAKE_DDHRESULT + 603;
 
(*
* A DC has already been returned for this surface. Only one DC can be
* retrieved per surface.
*)
DDERR_DCALREADYCREATED = MAKE_DDHRESULT + 620;
 
(*
* An attempt was made to allocate non-local video memory from a device
* that does not support non-local video memory.
*)
DDERR_NONONLOCALVIDMEM = MAKE_DDHRESULT + 630;
 
(*
* The attempt to page lock a surface failed.
*)
DDERR_CANTPAGELOCK = MAKE_DDHRESULT + 640;
 
(*
* The attempt to page unlock a surface failed.
*)
DDERR_CANTPAGEUNLOCK = MAKE_DDHRESULT + 660;
 
(*
* An attempt was made to page unlock a surface with no outstanding page locks.
*)
DDERR_NOTPAGELOCKED = MAKE_DDHRESULT + 680;
 
(*
* There is more data available than the specified buffer size could hold
*)
DDERR_MOREDATA = MAKE_DDHRESULT + 690;
 
(*
* The data has expired and is therefore no longer valid.
*)
DDERR_EXPIRED = MAKE_DDHRESULT + 691;
 
(*
* The mode test has finished executing.
*)
DDERR_TESTFINISHED = MAKE_DDHRESULT + 692;
 
(*
* The mode test has switched to a new mode.
*)
DDERR_NEWMODE = MAKE_DDHRESULT + 693;
 
(*
* D3D has not yet been initialized.
*)
DDERR_D3DNOTINITIALIZED = MAKE_DDHRESULT + 694;
 
(*
* The video port is not active
*)
DDERR_VIDEONOTACTIVE = MAKE_DDHRESULT + 695;
 
(*
* The monitor does not have EDID data.
*)
DDERR_NOMONITORINFORMATION = MAKE_DDHRESULT + 696;
 
(*
* The driver does not enumerate display mode refresh rates.
*)
DDERR_NODRIVERSUPPORT = MAKE_DDHRESULT + 697;
 
(*
* Surfaces created by one direct draw device cannot be used directly by
* another direct draw device.
*)
DDERR_DEVICEDOESNTOWNSURFACE = MAKE_DDHRESULT + 699;
 
(*
* An attempt was made to invoke an interface member of a DirectDraw object
* created by CoCreateInstance() before it was initialized.
*)
DDERR_NOTINITIALIZED = CO_E_NOTINITIALIZED;
 
(* Alpha bit depth constants *)
 
(*
* API's
*)
 
type
HMonitor = THandle;
 
TDDEnumCallbackA = function (lpGUID: PGUID; lpDriverDescription: PAnsiChar;
lpDriverName: PAnsiChar; lpContext: Pointer) : BOOL; stdcall;
TDDEnumCallbackW = function (lpGUID: PGUID; lpDriverDescription: PWideChar;
lpDriverName: PWideChar; lpContext: Pointer) : BOOL; stdcall;
{$IFDEF UNICODE}
TDDEnumCallback = TDDEnumCallbackW;
{$ELSE}
TDDEnumCallback = TDDEnumCallbackA;
{$ENDIF}
TDDEnumCallbackA = function(lpGUID: PGUID; lpDriverDescription: LPSTR;
lpDriverName: LPSTR; lpContext: Pointer): BOOL; stdcall;
LPDDENUMCALLBACKA = TDDEnumCallbackA;
 
TDDEnumCallbackExA = function (lpGUID: PGUID; lpDriverDescription: PAnsiChar;
lpDriverName: PAnsiChar; lpContext: Pointer; Monitor: HMonitor) : BOOL;
stdcall;
TDDEnumCallbackExW = function (lpGUID: PGUID; lpDriverDescription: PWideChar;
lpDriverName: PWideChar; lpContext: Pointer; Monitor: HMonitor) : BOOL;
stdcall;
TDDEnumCallbackW = function(lpGUID: PGUID; lpDriverDescription: LPWSTR;
lpDriverName: LPWSTR; lpContext: Pointer): BOOL; stdcall;
LPDDENUMCALLBACKW = TDDEnumCallbackW;
{$IFDEF UNICODE}
TDDEnumCallbackEx = TDDEnumCallbackExW;
{$ELSE}
TDDEnumCallbackEx = TDDEnumCallbackExA;
{$ENDIF}
TDDEnumCallback = TDDEnumCallbackA;
LPDDENUMCALLBACK = TDDEnumCallback;
 
var
DirectDrawEnumerateA : function (lpCallback: TDDEnumCallbackA;
lpContext: Pointer) : HResult; stdcall;
DirectDrawEnumerateW : function (lpCallback: TDDEnumCallbackW;
lpContext: Pointer) : HResult; stdcall;
DirectDrawEnumerate : function (lpCallback: TDDEnumCallback;
lpContext: Pointer) : HResult; stdcall;
TDDEnumCallbackExA = function(lpGUID: PGUID; lpDriverDescription: LPSTR;
lpDriverName: LPSTR; lpContext: Pointer; Monitor: HMonitor): BOOL; stdcall;
LPDDENUMCALLBACKEXA = TDDEnumCallbackExA;
 
DirectDrawEnumerateExA : function (lpCallback: TDDEnumCallbackExA;
lpContext: Pointer; dwFlags: DWORD) : HResult; stdcall;
DirectDrawEnumerateExW : function (lpCallback: TDDEnumCallbackExW;
lpContext: Pointer; dwFlags: DWORD) : HResult; stdcall;
DirectDrawEnumerateEx : function (lpCallback: TDDEnumCallbackEx;
lpContext: Pointer; dwFlags: DWORD) : HResult; stdcall;
TDDEnumCallbackExW = function(lpGUID: PGUID; lpDriverDescription: LPWSTR;
lpDriverName: LPWSTR; lpContext: Pointer; Monitor: HMonitor): BOOL; stdcall;
LPDDENUMCALLBACKEXW = TDDEnumCallbackExW;
 
DirectDrawCreate : function (lpGUID: PGUID;
out lplpDD: IDirectDraw;
pUnkOuter: IUnknown) : HResult; stdcall;
DirectDrawCreateEx : function (lpGUID: PGUID;
out lplpDD: IDirectDraw7; const iid: TGUID;
pUnkOuter: IUnknown) : HResult; stdcall;
DirectDrawCreateClipper : function (dwFlags: DWORD;
out lplpDDClipper: IDirectDrawClipper;
pUnkOuter: IUnknown) : HResult; stdcall;
TDDEnumCallbackEx = TDDEnumCallbackExA;
LPDDENUMCALLBACKEX = TDDEnumCallbackEx;
 
const
(*
* Flags for DirectDrawEnumerateEx
* DirectDrawEnumerateEx supercedes DirectDrawEnumerate. You must use GetProcAddress to
* obtain a function pointer (of type LPDIRECTDRAWENUMERATEEX) to DirectDrawEnumerateEx.
* By default, only the primary display device is enumerated.
* DirectDrawEnumerate is equivalent to DirectDrawEnumerate(,,DDENUM_NONDISPLAYDEVICES)
*)
 
(*
* This flag causes enumeration of any GDI display devices which are part of
* the Windows Desktop
*)
DDENUM_ATTACHEDSECONDARYDEVICES = $00000001;
 
(*
* This flag causes enumeration of any GDI display devices which are not
* part of the Windows Desktop
*)
DDENUM_DETACHEDSECONDARYDEVICES = $00000002;
 
(*
* This flag causes enumeration of non-display devices
*)
DDENUM_NONDISPLAYDEVICES = $00000004;
 
REGSTR_KEY_DDHW_DESCRIPTION = 'Description';
REGSTR_KEY_DDHW_DRIVERNAME = 'DriverName';
REGSTR_PATH_DDHW = 'Hardware\DirectDrawDrivers';
4872,14 → 2154,21
DDCREATE_HARDWAREONLY = $00000001;
DDCREATE_EMULATIONONLY = $00000002;
 
(*
* Macros for interpretting DDEVICEIDENTIFIER2.dwWHQLLevel
*)
function GET_WHQL_YEAR(dwWHQLLevel: DWORD) : DWORD;
function GET_WHQL_MONTH(dwWHQLLevel: DWORD) : DWORD;
function GET_WHQL_DAY(dwWHQLLevel: DWORD) : DWORD;
function DirectDrawEnumerateA(lpCallback: TDDEnumCallbackA; lpContext: Pointer): HResult; stdcall;
function DirectDrawEnumerateW(lpCallback: TDDEnumCallbackW; lpContext: Pointer): HResult; stdcall;
function DirectDrawEnumerate(lpCallback: TDDEnumCallbackA; lpContext: Pointer): HResult; stdcall;
 
function DirectDrawEnumerateExA(lpCallback: TDDEnumCallbackExA; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
function DirectDrawEnumerateExW(lpCallback: TDDEnumCallbackExW; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
function DirectDrawEnumerateEx(lpCallback: TDDEnumCallbackExA; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
 
function DirectDrawCreate(lpGUID: PGUID; out lplpDD: IDirectDraw;
pUnkOuter: IUnknown): HResult; stdcall;
function DirectDrawCreateEx(lpGUID: PGUID; out lplpDD; const iid: TGUID;
pUnkOuter: IUnknown): HResult; stdcall;
function DirectDrawCreateClipper(dwFlags: DWORD; out lplpDDClipper: IDirectDrawClipper;
pUnkOuter: IUnknown): HResult; stdcall;
 
(*==========================================================================;
*
* Copyright (C) 1996-1997 Microsoft Corporation. All Rights Reserved.
4889,45 → 2178,31
*
***************************************************************************)
 
{ GUIDS used by DirectDrawVideoPort objects }
 
const
(*
* GUIDS used by DirectDrawVideoPort objects
*)
DDVPTYPE_E_HREFH_VREFH: TGUID =
(D1:$54F39980;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8));
DDVPTYPE_E_HREFH_VREFL: TGUID =
(D1:$92783220;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8));
DDVPTYPE_E_HREFL_VREFH: TGUID =
(D1:$A07A02E0;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8));
DDVPTYPE_E_HREFL_VREFL: TGUID =
(D1:$E09C77E0;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8));
DDVPTYPE_CCIR656: TGUID =
(D1:$FCA326A0;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8));
DDVPTYPE_BROOKTREE: TGUID =
(D1:$1352A560;D2:$DA61;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8));
DDVPTYPE_PHILIPS: TGUID =
(D1:$332CF160;D2:$DA61;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8));
IID_IDDVideoPortContainer: TGUID = '{6C142760-A733-11CE-A521-0020AF0BE560}';
IID_IDirectDrawVideoPort: TGUID = '{B36D93E0-2B43-11CF-A2DE-00AA00B93356}';
 
(*
* GUIDS used to describe connections
*)
DDVPTYPE_E_HREFH_VREFH: TGUID = '{54F39980-DA60-11CF-9B06-00A0C903A3B8}';
DDVPTYPE_E_HREFH_VREFL: TGUID = '{92783220-DA60-11CF-9B06-00A0C903A3B8}';
DDVPTYPE_E_HREFL_VREFH: TGUID = '{A07A02E0-DA60-11CF-9B06-00A0C903A3B8}';
DDVPTYPE_E_HREFL_VREFL: TGUID = '{E09C77E0-DA60-11CF-9B06-00A0C903A3B8}';
DDVPTYPE_CCIR656: TGUID = '{FCA326A0-DA60-11CF-9B06-00A0C903A3B8}';
DDVPTYPE_BROOKTREE: TGUID = '{1352A560-DA61-11CF-9B06-00A0C903A3B8}';
DDVPTYPE_PHILIPS: TGUID = '{332CF160-DA61-11CF-9B06-00A0C903A3B8}';
 
(*============================================================================
*
* DirectDraw Structures
*
* Various structures used to invoke DirectDraw.
*
*==========================================================================*)
{ DirectDraw Structures }
 
type
IDDVideoPortContainer = interface;
IDirectDrawVideoPort = interface;
 
(*
* TDDVideoPortConnect
*)
PDDVideoPortConnect = ^TDDVideoPortConnect;
TDDVideoPortConnect = packed record
dwSize: DWORD; // size of the TDDVideoPortConnect structure
{ TDDVideoportConnect structure }
 
PDDVideoportConnect = ^TDDVideoportConnect;
TDDVideoportConnect = record
dwSize: DWORD; // size of the TDDVideoportConnect structure
dwPortWidth: DWORD; // Width of the video port
guidTypeID: TGUID; // Description of video port connection
dwFlags: DWORD; // Connection flags
4934,12 → 2209,14
dwReserved1: DWORD; // Reserved, set to zero.
end;
 
(*
* TDDVideoPortCaps
*)
PDDVideoPortCaps = ^TDDVideoPortCaps;
TDDVideoPortCaps = packed record
dwSize: DWORD; // size of the TDDVideoPortCaps structure
DDVIDEOPORTCONNECT = TDDVideoportConnect;
LPDDVIDEOPORTCONNECT = PDDVideoportConnect;
 
{ TDDVideoportCaps structure }
 
PDDVideoportCaps = ^TDDVideoportCaps;
TDDVideoportCaps = record
dwSize: DWORD; // size of the TDDVideoportCaps structure
dwFlags: DWORD; // indicates which fields contain data
dwMaxWidth: DWORD; // max width of the video port field
dwMaxVBIWidth: DWORD; // max width of the VBI data
4960,59 → 2237,14
wNumFilterTapsY: WORD; // Number of taps the prescaler uses in the Y direction (0 - no prescale, 1 - replication, etc.)
end;
 
const
(*
* The dwMaxWidth and dwMaxVBIWidth members are valid
*)
DDVPD_WIDTH = $00000001;
DDVIDEOPORTCAPS = TDDVideoportCaps;
LPDDVIDEOPORTCAPS = PDDVideoportCaps;
 
(*
* The dwMaxHeight member is valid
*)
DDVPD_HEIGHT = $00000002;
{ TDDVideoportDesc structure }
 
(*
* The dwVideoPortID member is valid
*)
DDVPD_ID = $00000004;
 
(*
* The dwCaps member is valid
*)
DDVPD_CAPS = $00000008;
 
(*
* The dwFX member is valid
*)
DDVPD_FX = $00000010;
 
(*
* The dwNumAutoFlipSurfaces member is valid
*)
DDVPD_AUTOFLIP = $00000020;
 
(*
* All of the alignment members are valid
*)
DDVPD_ALIGN = $00000040;
 
(*
* The dwNumPreferredAutoflip member is valid
*)
DDVPD_PREFERREDAUTOFLIP = $00000080;
 
(*
* The wNumFilterTapsX and wNumFilterTapsY fields are valid
*)
DDVPD_FILTERQUALITY = $00000100;
 
type
(*
* TDDVideoPortDesc
*)
PDDVideoPortDesc = ^TDDVideoPortDesc;
TDDVideoPortDesc = packed record
dwSize: DWORD; // size of the TDDVideoPortDesc structure
PDDVideoportDesc = ^TDDVideoportDesc;
TDDVideoportDesc = record
dwSize: DWORD; // size of the TDDVideoportDesc structure
dwFieldWidth: DWORD; // width of the video port field
dwVBIWidth: DWORD; // width of the VBI data
dwFieldHeight: DWORD; // height of the video port field
5020,16 → 2252,18
dwMaxPixelsPerSecond: DWORD; // Maximum pixel rate per second
dwVideoPortID: DWORD; // Video port ID (0 - (dwMaxVideoPorts -1))
dwReserved1: DWORD; // Reserved for future use - set to zero
VideoPortType: TDDVideoPortConnect; // Description of video port connection
VideoPortType: TDDVideoportConnect; // Description of video port connection
dwReserved2: DWORD; // Reserved for future use - set to zero
dwReserved3: DWORD; // Reserved for future use - set to zero
end;
 
(*
* TDDVideoPortInfo
*)
PDDVideoPortInfo = ^TDDVideoPortInfo;
TDDVideoPortInfo = packed record
DDVIDEOPORTDESC = TDDVideoportDesc;
LPDDVIDEOPORTDESC = PDDVideoportDesc;
 
{ TDDVideoportInfo structure }
 
PDDVideoportInfo = ^TDDVideoportInfo;
TDDVideoportInfo = record
dwSize: DWORD; // Size of the structure
dwOriginX: DWORD; // Placement of the video data within the surface.
dwOriginY: DWORD; // Placement of the video data within the surface.
5045,11 → 2279,13
dwReserved2: DWORD; // Reserved for future use - set to zero
end;
 
(*
* TDDVideoPortBandWidth
*)
PDDVideoPortBandWidth = ^TDDVideoPortBandWidth;
TDDVideoPortBandWidth = packed record
DDVIDEOPORTINFO = TDDVideoportInfo;
LPDDVIDEOPORTINFO = PDDVideoportInfo;
 
{ TDDVideoportBandWidth structure }
 
PDDVideoportBandWidth = ^TDDVideoportBandWidth;
TDDVideoportBandWidth = record
dwSize: DWORD; // Size of the structure
dwCaps: DWORD;
dwOverlay: DWORD; // Zoom factor at which overlay is supported
5060,669 → 2296,226
dwReserved2: DWORD; // Reserved for future use - set to zero
end;
 
(*
* TDDVideoPortStatus
*)
PDDVideoPortStatus = ^TDDVideoPortStatus;
TDDVideoPortStatus = record
DDVIDEOPORTBANDWIDTH = TDDVideoportBandWidth;
LPDDVIDEOPORTBANDWIDTH = PDDVideoportBandWidth;
 
{ TDDVideoportStatus structure }
 
PDDVideoportStatus = ^TDDVideoportStatus;
TDDVideoportStatus = record
dwSize: DWORD; // Size of the structure
bInUse: BOOL; // TRUE if video port is currently being used
dwFlags: DWORD; // Currently not used
dwReserved1: DWORD; // Reserved for future use
VideoPortType: TDDVideoPortConnect; // Information about the connection
VideoPortType: TDDVideoportConnect; // Information about the connection
dwReserved2: DWORD; // Reserved for future use
dwReserved3: DWORD; // Reserved for future use
end;
 
DDVIDEOPORTSTATUS = TDDVideoportStatus;
LPDDVIDEOPORTSTATUS = PDDVideoportStatus;
 
{ API's }
 
TDDEnumVideoCallback = function(const lpDDVideoPortCaps: TDDVideoportCaps;
lpContext: Pointer): HResult; stdcall;
LPDDENUMVIDEOCALLBACK = TDDEnumVideoCallback;
 
{ IDirectDrawVideoPortContainer Interface }
 
IDDVideoPortContainer = interface(IUnknown)
['{6C142760-A733-11CE-A521-0020AF0BE560}']
// IDDVideoPortContainer methods
function CreateVideoPort(dwFlags: DWORD; const lpDDVideoPortDesc:
TDDVideoportDesc; out lplpDDVideoPort: IDirectDrawVideoPort;
pUnkOuter: IUnknown): HResult; stdcall;
function EnumVideoPorts(dwFlags: DWORD;
const lpDDVideoPortCaps: TDDVideoportCaps; lpContext: Pointer;
lpEnumVideoCallback: TDDEnumVideoCallback): HResult; stdcall;
function GetVideoPortConnectInfo(dwPortId: DWORD; var lpNumEntries: DWORD;
var lpConnectInfo: TDDVideoportConnect): HResult; stdcall;
function QueryVideoPortStatus(dwPortId: DWORD;
var lpVPStatus: TDDVideoportStatus): HResult; stdcall;
end;
 
{ IDirectDrawVideoPort Interface }
 
IDirectDrawVideoPort = interface(IUnknown)
['{B36D93E0-2B43-11CF-A2DE-00AA00B93356}']
// IDirectDrawVideoPort methods
function Flip(lpDDSurface: IDirectDrawSurface; dwFlags: DWORD): HResult; stdcall;
function GetBandwidthInfo(const lpddpfFormat: TDDPixelFormat; dwWidth: DWORD;
dwHeight: DWORD; dwFlags: DWORD; var lpBandwidth: TDDVideoportBandWidth): HResult; stdcall;
function GetColorControls(var lpColorControl: TDDColorControl): HResult; stdcall;
function GetInputFormats(var lpNumFormats: DWORD; var lpFormats:
TDDPixelFormat; dwFlags: DWORD): HResult; stdcall;
function GetOutputFormats(const lpInputFormat: TDDPixelFormat;
var lpNumFormats: DWORD; var lpFormats: TDDPixelFormat; dwFlags: DWORD): HResult; stdcall;
function GetFieldPolarity(var lpbVideoField: BOOL): HResult; stdcall;
function GetVideoLine(var lpdwLine: DWORD): HResult; stdcall;
function GetVideoSignalStatus(varlpdwStatus: DWORD): HResult; stdcall;
function SetColorControls(const lpColorControl: TDDColorControl): HResult; stdcall;
function SetTargetSurface(lpDDSurface: IDirectDrawSurface; dwFlags: DWORD): HResult; stdcall;
function StartVideo(const lpVideoInfo: TDDVideoportInfo): HResult; stdcall;
function StopVideo: HResult; stdcall;
function UpdateVideo(const lpVideoInfo: TDDVideoportInfo): HResult; stdcall;
function WaitForSync(dwFlags: DWORD; dwLine: DWORD; dwTimeout: DWORD): HResult; stdcall;
end;
 
 
const
(*============================================================================
*
* Video Port Flags
*
* All flags are bit flags.
*
*==========================================================================*)
{ Video Port Flags }
 
(****************************************************************************
*
* VIDEOPORT TDDVideoPortConnect FLAGS
*
****************************************************************************)
DDVPD_WIDTH = $00000001;
DDVPD_HEIGHT = $00000002;
DDVPD_ID = $00000004;
DDVPD_CAPS = $00000008;
DDVPD_FX = $00000010;
DDVPD_AUTOFLIP = $00000020;
DDVPD_ALIGN = $00000040;
DDVPD_PREFERREDAUTOFLIP = $00000080;
DDVPD_FILTERQUALITY = $00000100;
 
(*
* When this is set by the driver and passed to the client, this
* indicates that the video port is capable of double clocking the data.
* When this is set by the client, this indicates that the video port
* should enable double clocking. This flag is only valid with external
* syncs.
*)
{ TDDVideoportConnect flags }
 
DDVPCONNECT_DOUBLECLOCK = $00000001;
 
(*
* When this is set by the driver and passed to the client, this
* indicates that the video port is capable of using an external VACT
* signal. When this is set by the client, this indicates that the
* video port should use the external VACT signal.
*)
DDVPCONNECT_VACT = $00000002;
 
(*
* When this is set by the driver and passed to the client, this
* indicates that the video port is capable of treating even fields
* like odd fields and visa versa. When this is set by the client,
* this indicates that the video port should treat even fields like odd
* fields.
*)
DDVPCONNECT_INVERTPOLARITY = $00000004;
 
(*
* Indicates that any data written to the video port during the VREF
* period will not be written into the frame buffer. This flag is read only.
*)
DDVPCONNECT_DISCARDSVREFDATA = $00000008;
 
(*
* When this is set be the driver and passed to the client, this
* indicates that the device will write half lines into the frame buffer
* if half lines are provided by the decoder. If this is set by the client,
* this indicates that the decoder will be supplying half lines.
*)
DDVPCONNECT_HALFLINE = $00000010;
 
(*
* Indicates that the signal is interlaced. This flag is only
* set by the client.
*)
DDVPCONNECT_INTERLACED = $00000020;
 
(*
* Indicates that video port is shareable and that this video port
* will use the even fields. This flag is only set by the client.
*)
DDVPCONNECT_SHAREEVEN = $00000040;
 
(*
* Indicates that video port is shareable and that this video port
* will use the odd fields. This flag is only set by the client.
*)
DDVPCONNECT_SHAREODD = $00000080;
 
(****************************************************************************
*
* VIDEOPORT TDDVideoPortDesc CAPS
*
****************************************************************************)
{ TDDVideoportDesc caps }
 
(*
* Flip can be performed automatically to avoid tearing.
*)
DDVPCAPS_AUTOFLIP = $00000001;
 
(*
* Supports interlaced video
*)
DDVPCAPS_INTERLACED = $00000002;
 
(*
* Supports non-interlaced video
*)
DDVPCAPS_NONINTERLACED = $00000004;
 
(*
* Indicates that the device can return whether the current field
* of an interlaced signal is even or odd.
*)
DDVPCAPS_READBACKFIELD = $00000008;
 
(*
* Indicates that the device can return the current line of video
* being written into the frame buffer.
*)
DDVPCAPS_READBACKLINE = $00000010;
 
(*
* Allows two gen-locked video streams to share a single video port,
* where one stream uses the even fields and the other uses the odd
* fields. Separate parameters (including address, scaling,
* cropping, etc.) are maintained for both fields.)
*)
DDVPCAPS_SHAREABLE = $00000020;
 
(*
* Even fields of video can be automatically discarded.
*)
DDVPCAPS_SKIPEVENFIELDS = $00000040;
 
(*
* Odd fields of video can be automatically discarded.
*)
DDVPCAPS_SKIPODDFIELDS = $00000080;
 
(*
* Indicates that the device is capable of driving the graphics
* VSYNC with the video port VSYNC.
*)
DDVPCAPS_SYNCMASTER = $00000100;
 
(*
* Indicates that data within the vertical blanking interval can
* be written to a different surface.
*)
DDVPCAPS_VBISURFACE = $00000200;
 
(*
* Indicates that the video port can perform color operations
* on the incoming data before it is written to the frame buffer.
*)
DDVPCAPS_COLORCONTROL = $00000400;
 
(*
* Indicates that the video port can accept VBI data in a different
* width or format than the regular video data.
*)
DDVPCAPS_OVERSAMPLEDVBI = $00000800;
 
(*
* Indicates that the video port can write data directly to system memory
*)
DDVPCAPS_SYSTEMMEMORY = $00001000;
 
(*
* Indicates that the VBI and video portions of the video stream can
* be controlled by an independent processes.
*)
DDVPCAPS_VBIANDVIDEOINDEPENDENT = $00002000;
 
(*
* Indicates that the video port contains high quality hardware
* de-interlacing hardware that should be used instead of the
* bob/weave algorithms.
*)
DDVPCAPS_HARDWAREDEINTERLACE = $00004000;
 
(****************************************************************************
*
* VIDEOPORT TDDVideoPortDesc FX
*
****************************************************************************)
{ TDDVideoportDesc FX }
 
(*
* Limited cropping is available to crop out the vertical interval data.
*)
DDVPFX_CROPTOPDATA = $00000001;
 
(*
* Incoming data can be cropped in the X direction before it is written
* to the surface.
*)
DDVPFX_CROPX = $00000002;
 
(*
* Incoming data can be cropped in the Y direction before it is written
* to the surface.
*)
DDVPFX_CROPY = $00000004;
 
(*
* Supports interleaving interlaced fields in memory.
*)
DDVPFX_INTERLEAVE = $00000008;
 
(*
* Supports mirroring left to right as the video data is written
* into the frame buffer.
*)
DDVPFX_MIRRORLEFTRIGHT = $00000010;
 
(*
* Supports mirroring top to bottom as the video data is written
* into the frame buffer.
*)
DDVPFX_MIRRORUPDOWN = $00000020;
 
(*
* Data can be arbitrarily shrunk in the X direction before it
* is written to the surface.
*)
DDVPFX_PRESHRINKX = $00000040;
 
(*
* Data can be arbitrarily shrunk in the Y direction before it
* is written to the surface.
*)
DDVPFX_PRESHRINKY = $00000080;
 
(*
* Data can be binary shrunk (1/2, 1/4, 1/8, etc.) in the X
* direction before it is written to the surface.
*)
DDVPFX_PRESHRINKXB = $00000100;
 
(*
* Data can be binary shrunk (1/2, 1/4, 1/8, etc.) in the Y
* direction before it is written to the surface.
*)
DDVPFX_PRESHRINKYB = $00000200;
 
(*
* Data can be shrunk in increments of 1/x in the X direction
* (where X is specified in the TDDVideoPortCaps.dwPreshrinkXStep)
* before it is written to the surface.
*)
DDVPFX_PRESHRINKXS = $00000400;
 
(*
* Data can be shrunk in increments of 1/x in the Y direction
* (where X is specified in the TDDVideoPortCaps.dwPreshrinkYStep)
* before it is written to the surface.
*)
DDVPFX_PRESHRINKYS = $00000800;
 
(*
* Data can be arbitrarily stretched in the X direction before
* it is written to the surface.
*)
DDVPFX_PRESTRETCHX = $00001000;
 
(*
* Data can be arbitrarily stretched in the Y direction before
* it is written to the surface.
*)
DDVPFX_PRESTRETCHY = $00002000;
 
(*
* Data can be integer stretched in the X direction before it is
* written to the surface.
*)
DDVPFX_PRESTRETCHXN = $00004000;
 
(*
* Data can be integer stretched in the Y direction before it is
* written to the surface.
*)
DDVPFX_PRESTRETCHYN = $00008000;
 
(*
* Indicates that data within the vertical blanking interval can
* be converted independently of the remaining video data.
*)
DDVPFX_VBICONVERT = $00010000;
 
(*
* Indicates that scaling can be disabled for data within the
* vertical blanking interval.
*)
DDVPFX_VBINOSCALE = $00020000;
 
(*
* Indicates that the video data can ignore the left and right
* cropping coordinates when cropping oversampled VBI data.
*)
DDVPFX_IGNOREVBIXCROP = $00040000;
 
(*
* Indicates that interleaving can be disabled for data within the
* vertical blanking interval.
*)
DDVPFX_VBINOINTERLEAVE = $00080000;
 
(****************************************************************************
*
* VIDEOPORT TDDVideoPortInfo FLAGS
*
****************************************************************************)
{ TDDVideoportInfo flags }
 
(*
* Perform automatic flipping. Auto-flipping is performed between
* the overlay surface that was attached to the video port using
* IDirectDrawVideoPort::AttachSurface and the overlay surfaces that
* are attached to the surface via the IDirectDrawSurface::AttachSurface
* method. The flip order is the order in which the overlay surfaces
* were. attached.
*)
DDVP_AUTOFLIP = $00000001;
 
(*
* Perform conversion using the ddpfOutputFormat information.
*)
DDVP_CONVERT = $00000002;
 
(*
* Perform cropping using the specified rectangle.
*)
DDVP_CROP = $00000004;
 
(*
* Indicates that interlaced fields should be interleaved in memory.
*)
DDVP_INTERLEAVE = $00000008;
 
(*
* Indicates that the data should be mirrored left to right as it's
* written into the frame buffer.
*)
DDVP_MIRRORLEFTRIGHT = $00000010;
 
(*
* Indicates that the data should be mirrored top to bottom as it's
* written into the frame buffer.
*)
DDVP_MIRRORUPDOWN = $00000020;
 
(*
* Perform pre-scaling/zooming based on the pre-scale parameters.
*)
DDVP_PRESCALE = $00000040;
 
(*
* Ignore input of even fields.
*)
DDVP_SKIPEVENFIELDS = $00000080;
 
(*
* Ignore input of odd fields.
*)
DDVP_SKIPODDFIELDS = $00000100;
 
(*
* Drive the graphics VSYNCs using the video port VYSNCs.
*)
DDVP_SYNCMASTER = $00000200;
 
(*
* The ddpfVBIOutputFormatFormat member contains data that should be used
* to convert the data within the vertical blanking interval.
*)
DDVP_VBICONVERT = $00000400;
 
(*
* Indicates that data within the vertical blanking interval
* should not be scaled.
*)
DDVP_VBINOSCALE = $00000800;
 
(*
* Indicates that these bob/weave decisions should not be
* overriden by other interfaces.
*)
DDVP_OVERRIDEBOBWEAVE = $00001000;
 
(*
* Indicates that the video data should ignore the left and right
* cropping coordinates when cropping the VBI data.
*)
DDVP_IGNOREVBIXCROP = $00002000;
 
(*
* Indicates that interleaving can be disabled for data within the
* vertical blanking interval.
*)
DDVP_VBINOINTERLEAVE = $00004000;
 
(*
* Indicates that the video port should use the hardware
* de-interlacing hardware.
*)
DDVP_HARDWAREDEINTERLACE = $00008000;
 
(****************************************************************************
*
* DIRIRECTDRAWVIDEOPORT GETINPUTFORMAT/GETOUTPUTFORMAT FLAGS
*
****************************************************************************)
{ DirectDrawVideoport GetInputFormat/GetOutputFormat flags }
 
(*
* Return formats for the video data
*)
DDVPFORMAT_VIDEO = $00000001;
 
(*
* Return formats for the VBI data
*)
DDVPFORMAT_VBI = $00000002;
 
(****************************************************************************
*
* DIRIRECTDRAWVIDEOPORT SETTARGETSURFACE FLAGS
*
****************************************************************************)
{ DirectDrawVideoport SetTargetSurface flags }
 
(*
* Surface should receive video data (and VBI data if a surface
* is not explicitly attached for that purpose)
*)
DDVPTARGET_VIDEO = $00000001;
 
(*
* Surface should receive VBI data
*)
DDVPTARGET_VBI = $00000002;
 
(****************************************************************************
*
* DIRIRECTDRAWVIDEOPORT WAITFORSYNC FLAGS
*
****************************************************************************)
{ DirectDrawVideoport WaitForSync flags }
 
(*
* Waits until the beginning of the next VSYNC
*)
DDVPWAIT_BEGIN = $00000001;
 
(*
* Waits until the end of the next/current VSYNC
*)
DDVPWAIT_END = $00000002;
 
(*
* Waits until the beginning of the specified line
*)
DDVPWAIT_LINE = $00000003;
 
(****************************************************************************
*
* DIRECTDRAWVIDEOPORT FLIP FLAGS
*
****************************************************************************)
{ DirectDrawVideoport flip flags }
 
(*
* Flips the normal video surface
*)
DDVPFLIP_VIDEO = $00000001;
 
(*
* Flips the VBI surface
*)
DDVPFLIP_VBI = $00000002;
 
(****************************************************************************
*
* DIRIRECTDRAWVIDEOPORT GETVIDEOSIGNALSTATUS VALUES
*
****************************************************************************)
{ DirectDrawVideoport GetVideoSiginalStatus values }
 
(*
* No video signal is present at the video port
*)
DDVPSQ_NOSIGNAL = $00000001;
 
(*
* A valid video signal is present at the video port
*)
DDVPSQ_SIGNALOK = $00000002;
 
(****************************************************************************
*
* VIDEOPORTBANDWIDTH Flags
*
****************************************************************************)
{ TDDVideoportBandWidth Flags }
 
(*
* The specified height/width refer to the size of the video port data
* written into memory, after prescaling has occured.
*)
DDVPB_VIDEOPORT = $00000001;
 
(*
* The specified height/width refer to the source size of the overlay.
*)
DDVPB_OVERLAY = $00000002;
 
(*
* This is a query for the device to return which caps this device requires.
*)
DDVPB_TYPE = $00000004;
 
(****************************************************************************
*
* VIDEOPORTBANDWIDTH Caps
*
****************************************************************************)
{ TDDVideoportBandWidth Caps }
 
(*
* The bandwidth for this device is dependant on the overlay source size.
*)
DDVPBCAPS_SOURCE = $00000001;
 
(*
* The bandwidth for this device is dependant on the overlay destination
* size.
*)
DDVPBCAPS_DESTINATION = $00000002;
 
(****************************************************************************
*
* DDVIDEOPORTCONTAINER CreateVideoPort flags
*
****************************************************************************)
{ IDDVideoportContainer.CreateVideoPort flags }
 
(*
* The process only wants to control the VBI portion of the video stream.
*)
DDVPCREATE_VBIONLY = $00000001;
 
(*
* The process only wants to control the non-VBI (video) portion of
* the video stream.
*)
DDVPCREATE_VIDEOONLY = $00000002;
 
(****************************************************************************
*
* DDVIDEOPORTSTATUS flags
*
****************************************************************************)
{ TDDVideoportStatus flags }
 
(*
* The video port interface is only controlling the VBI portion of the
* video stream
*)
DDVPSTATUS_VBIONLY = $00000001;
 
(*
* The video port interface is only controlling the video portion of the
* video stream
*)
DDVPSTATUS_VIDEOONLY = $00000002;
 
 
type
(*
* API's
*)
 
TDDEnumVideoCallback = function (lpTDDVideoPortCaps: PDDVideoPortCaps;
lpContext: Pointer) : HResult; stdcall;
 
(*
* INTERACES FOLLOW:
* IDirectDrawVideoPort
* IVideoPort
*)
 
 
(*
* IDirectDrawVideoPort
*)
IDirectDrawVideoPort = interface (IUnknown)
['{B36D93E0-2B43-11CF-A2DE-00AA00B93356}']
(*** IDirectDrawVideoPort methods ***)
function Flip(lpDDSurface: IDirectDrawSurface; dwFlags: DWORD) : HResult; stdcall;
function GetBandwidthInfo(var lpddpfFormat: TDDPixelFormat;
dwWidth: DWORD; dwHeight: DWORD; dwFlags: DWORD;
var lpBandwidth: TDDVideoPortBandWidth) : HResult; stdcall;
function GetColorControls(var lpColorControl: TDDColorControl) : HResult; stdcall;
function GetInputFormats(var lpNumFormats: DWORD; var lpFormats:
TDDPixelFormat; dwFlags: DWORD) : HResult; stdcall;
function GetOutputFormats(var lpInputFormat: TDDPixelFormat;
var lpNumFormats: DWORD; lpFormats: PDDPixelFormat; dwFlags: DWORD)
: HResult; stdcall;
function GetFieldPolarity(var lpbVideoField: BOOL) : HResult; stdcall;
function GetVideoLine(var lpdwLine: DWORD) : HResult; stdcall;
function GetVideoSignalStatus(varlpdwStatus: DWORD) : HResult; stdcall;
function SetColorControls(var lpColorControl: TDDColorControl) : HResult; stdcall;
function SetTargetSurface(lpDDSurface: IDirectDrawSurface; dwFlags: DWORD) :
HResult; stdcall;
function StartVideo(var lpVideoInfo: TDDVideoPortInfo) : HResult; stdcall;
function StopVideo: HResult; stdcall;
function UpdateVideo(var lpVideoInfo: TDDVideoPortInfo) : HResult; stdcall;
function WaitForSync(dwFlags: DWORD; dwLine: DWORD; dwTimeout: DWORD) :
HResult; stdcall;
end;
 
(*
* IDirectDrawVideoPortContainer
*)
IDDVideoPortContainer = interface (IUnknown)
['{6C142760-A733-11CE-A521-0020AF0BE560}']
(*** IDDVideoPortContainer methods ***)
function CreateVideoPort(dwFlags: DWORD; var lpTDDVideoPortDesc:
TDDVideoPortDesc; var lplpDDVideoPort: IDirectDrawVideoPort;
pUnkOuter: IUnknown) : HResult; stdcall;
function EnumVideoPorts(dwFlags: DWORD;
lpTDDVideoPortCaps: PDDVideoPortCaps; lpContext: Pointer;
lpEnumVideoCallback: TDDEnumVideoCallback) : HResult; stdcall;
function GetVideoPortConnectInfo(dwPortId: DWORD; var lpNumEntries: DWORD;
lpConnectInfo: PDDVideoPortConnect) : HResult; stdcall;
function QueryVideoPortStatus(dwPortId: DWORD;
var lpVPStatus: TDDVideoPortStatus) : HResult; stdcall;
end;
 
IID_IDDVideoPortContainer = IDDVideoPortContainer;
IID_IDirectDrawVideoPort = IDirectDrawVideoPort;
 
 
//Direct3D file
(*==========================================================================;
*
* Copyright (C) 1995-1998 Microsoft Corporation. All Rights Reserved.
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* Files: d3dtypes.h d3dcaps.h d3d.h
* File: d3dtypes.h
* Content: Direct3D types include file
*
* DirectX 7.0 Delphi adaptation by Erik Unger
*
* Modyfied: 26-Jun-2000
*
* Download: http://www.delphi-jedi.org/DelphiGraphics/
* E-Mail: DelphiDirectX@next-reality.com
*
***************************************************************************)
 
(* TD3DValue is the fundamental Direct3D fractional data type *)
 
type
TRefClsID = TGUID;
TD3DValue = Single;
D3DValue = TD3DValue;
 
type
TD3DValue = Single;
TD3DFixed = LongInt;
float = TD3DValue;
PD3DColor = ^TD3DColor;
TD3DFixed = Longint;
D3DFIXED = TD3DFixed;
 
TD3DColor = DWORD;
D3DCOLOR = TD3DColor;
 
function D3DVal(val: variant) : float;
function D3DDivide(a,b: double) : float;
function D3DMultiply(a,b: double) : float;
function D3DVALP(val: TD3DValue; prec: Integer): TD3DValue;
function D3DVAL(val: TD3DValue): TD3DValue;
function D3DDivide(a, b: TD3DValue): TD3DValue;
function D3DMultiply(a, b: TD3DValue): TD3DValue;
 
(*
* Format of CI colors is
5731,24 → 2524,13
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*)
 
// #define CI_GETALPHA(ci) ((ci) >> 24)
function CI_GETALPHA(ci: DWORD) : DWORD;
function CI_GETALPHA(ci: Integer): Byte;
function CI_GETINDEX(ci: Integer): Word;
function CI_GETFRACTION(ci: Integer): Byte;
function CI_ROUNDINDEX(ci: Integer): Integer;
function CI_MASKALPHA(ci: Integer): Integer;
function CI_MAKE(a: Byte; i: Word; f: Byte): Integer;
 
// #define CI_GETINDEX(ci) (((ci) >> 8) & 0xffff)
function CI_GETINDEX(ci: DWORD) : DWORD;
 
// #define CI_GETFRACTION(ci) ((ci) & 0xff)
function CI_GETFRACTION(ci: DWORD) : DWORD;
 
// #define CI_ROUNDINDEX(ci) CI_GETINDEX((ci) + 0x80)
function CI_ROUNDINDEX(ci: DWORD) : DWORD;
 
// #define CI_MASKALPHA(ci) ((ci) & 0xffffff)
function CI_MASKALPHA(ci: DWORD) : DWORD;
 
// #define CI_MAKE(a, i, f) (((a) << 24) | ((i) << 8) | (f))
function CI_MAKE(a,i,f: DWORD) : DWORD;
 
(*
* Format of RGBA colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5756,35 → 2538,19
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*)
 
// #define RGBA_GETALPHA(rgb) ((rgb) >> 24)
function RGBA_GETALPHA(rgb: TD3DColor) : DWORD;
function RGBA_GETALPHA(rgb: TD3DColor): Byte;
function RGBA_GETRED(rgb: TD3DColor): Byte;
function RGBA_GETGREEN(rgb: TD3DColor): Byte;
function RGBA_GETBLUE(rgb: TD3DColor): Byte;
function RGBA_MAKE(r, g, b, a: Byte): TD3DColor;
 
// #define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff)
function RGBA_GETRED(rgb: TD3DColor) : DWORD;
 
// #define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
function RGBA_GETGREEN(rgb: TD3DColor) : DWORD;
 
// #define RGBA_GETBLUE(rgb) ((rgb) & 0xff)
function RGBA_GETBLUE(rgb: TD3DColor) : DWORD;
 
// #define RGBA_MAKE(r, g, b, a) ((TD3DColor) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
function RGBA_MAKE(r, g, b, a: DWORD) : TD3DColor;
 
(* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
* The float values must be in the range 0..1
*)
 
// #define D3DRGB(r, g, b) \
// (0xff000000L | (((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
function D3DRGB(r, g, b: float) : TD3DColor;
function D3DRGB(r, g, b: TD3DValue): TD3DColor;
function D3DRGBA(r, g, b, a: TD3DValue): TD3DColor;
 
// #define D3DRGBA(r, g, b, a) \
// ( (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
// | (((long)((g) * 255)) << 8) | (long)((b) * 255) \
// )
function D3DRGBA(r, g, b, a: float) : TD3DColor;
 
(*
* Format of RGB colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
5792,64 → 2558,44
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*)
 
// #define RGB_GETRED(rgb) (((rgb) >> 16) & 0xff)
function RGB_GETRED(rgb: TD3DColor) : DWORD;
 
// #define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
function RGB_GETGREEN(rgb: TD3DColor) : DWORD;
 
// #define RGB_GETBLUE(rgb) ((rgb) & 0xff)
function RGB_GETBLUE(rgb: TD3DColor) : DWORD;
 
// #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
function RGBA_SETALPHA(rgba: TD3DColor; x: DWORD) : TD3DColor;
 
// #define RGB_MAKE(r, g, b) ((TD3DColor) (((r) << 16) | ((g) << 8) | (b)))
function RGB_MAKE(r, g, b: DWORD) : TD3DColor;
 
// #define RGBA_TORGB(rgba) ((TD3DColor) ((rgba) & 0xffffff))
function RGB_GETRED(rgb: TD3DColor): Byte;
function RGB_GETGREEN(rgb: TD3DColor): Byte;
function RGB_GETBLUE(rgb: TD3DColor): Byte;
function RGBA_SETALPHA(rgba: TD3DColor; x: Byte): TD3DColor;
function RGB_MAKE(r, g, b: Byte): TD3DColor;
function RGBA_TORGB(rgba: TD3DColor) : TD3DColor;
 
// #define RGB_TORGBA(rgb) ((TD3DColor) ((rgb) | 0xff000000))
function RGB_TORGBA(rgb: TD3DColor) : TD3DColor;
 
(*
* Flags for Enumerate functions
*)
const
{ Flags for Enumerate functions }
 
(*
* Stop the enumeration
*)
 
D3DENUMRET_CANCEL = DDENUMRET_CANCEL;
 
(*
* Continue the enumeration
*)
 
D3DENUMRET_OK = DDENUMRET_OK;
 
type
TD3DValidateCallback = function (lpUserArg: Pointer;
dwOffset: DWORD): HResult; stdcall;
TD3DEnumTextureFormatsCallback = function (var lpDdsd: TDDSurfaceDesc;
TD3DValidateCallback = function(lpUserArg: Pointer; dwOffset: DWORD): HResult; stdcall;
LPD3DVALIDATECALLBACK = TD3DValidateCallback;
 
TD3DEnumTextureFormatsCalback = function(const lpDdsd: TDDSurfaceDesc;
lpContext: Pointer): HResult; stdcall;
TD3DEnumPixelFormatsCallback = function (var lpDDPixFmt: TDDPixelFormat;
LPD3DENUMTEXTUREFORMATSCALLBACK = TD3DEnumTextureFormatsCalback;
 
TD3DEnumPixelFormatsCallback = function(const lpDDPixFmt: TDDPixelFormat;
lpContext: Pointer): HResult; stdcall;
 
 
PD3DMaterialHandle = ^TD3DMaterialHandle;
TD3DMaterialHandle = DWORD;
D3DMATERIALHANDLE = TD3DMaterialHandle;
 
PD3DTextureHandle = ^TD3DTextureHandle;
TD3DTextureHandle = DWORD;
D3DTEXTUREHANDLE = TD3DTextureHandle;
 
PD3DMatrixHandle = ^TD3DMatrixHandle;
TD3DMatrixHandle = DWORD;
D3DMATRIXHANDLE = TD3DMatrixHandle;
 
{ TD3DColorValue structure }
 
PD3DColorValue = ^TD3DColorValue;
TD3DColorValue = packed record
TD3DColorValue = record
case Integer of
0: (
r: TD3DValue;
5865,28 → 2611,34
);
end;
 
D3DCOLORVALUE = TD3DColorValue;
 
{ TD3DRect structure }
 
PD3DRect = ^TD3DRect;
TD3DRect = packed record
TD3DRect = record
case Integer of
0: (
x1: LongInt;
y1: LongInt;
x2: LongInt;
y2: LongInt;
x1: Longint;
y1: Longint;
x2: Longint;
y2: Longint;
);
1: (
lX1: LongInt;
lY1: LongInt;
lX2: LongInt;
lY2: LongInt;
lX1: Longint;
lY1: Longint;
lX2: Longint;
lY2: Longint;
);
2: (
a: array[0..3] of LongInt;
);
end;
 
D3DRECT = TD3DRect;
LPD3DRECT = PD3DRect;
 
{ TD3DVector structure }
 
PD3DVector = ^TD3DVector;
TD3DVector = packed record
TD3DVector = record
case Integer of
0: (
x: TD3DValue;
5900,25 → 2652,18
);
end;
 
(******************************************************************
* *
* D3DVec.inl *
* *
* Float-valued 3D vector class for Direct3D. *
* *
* Copyright (c) 1996-1998 Microsoft Corp. All rights reserved. *
* *
******************************************************************)
D3DVECTOR = TD3DVector;
LPD3DVECTOR = PD3DVector;
 
// Addition and subtraction
function VectorAdd(const v1, v2: TD3DVector) : TD3DVector;
function VectorSub(const v1, v2: TD3DVector) : TD3DVector;
function VectorAdd(v1, v2: TD3DVector) : TD3DVector;
function VectorSub(v1, v2: TD3DVector) : TD3DVector;
// Scalar multiplication and division
function VectorMulS(const v: TD3DVector; s: TD3DValue) : TD3DVector;
function VectorDivS(const v: TD3DVector; s: TD3DValue) : TD3DVector;
function VectorMulS(v: TD3DVector; s: TD3DValue) : TD3DVector;
function VectorDivS(v: TD3DVector; s: TD3DValue) : TD3DVector;
// Memberwise multiplication and division
function VectorMul(const v1, v2: TD3DVector) : TD3DVector;
function VectorDiv(const v1, v2: TD3DVector) : TD3DVector;
function VectorMul(v1, v2: TD3DVector) : TD3DVector;
function VectorDiv(v1, v2: TD3DVector) : TD3DVector;
// Vector dominance
function VectorSmaller(v1, v2: TD3DVector) : boolean;
function VectorSmallerEquel(v1, v2: TD3DVector) : boolean;
5928,29 → 2673,25
function VectorSquareMagnitude(v: TD3DVector) : TD3DValue;
function VectorMagnitude(v: TD3DVector) : TD3DValue;
// Returns vector with same direction and unit length
function VectorNormalize(const v: TD3DVector) : TD3DVector;
function VectorNormalize(v: TD3DVector) : TD3DVector;
// Return min/max component of the input vector
function VectorMin(v: TD3DVector) : TD3DValue;
function VectorMax(v: TD3DVector) : TD3DValue;
// Return memberwise min/max of input vectors
function VectorMinimize(const v1, v2: TD3DVector) : TD3DVector;
function VectorMaximize(const v1, v2: TD3DVector) : TD3DVector;
function VectorMinimize(v1, v2: TD3DVector) : TD3DVector;
function VectorMaximize(v1, v2: TD3DVector) : TD3DVector;
// Dot and cross product
function VectorDotProduct(v1, v2: TD3DVector) : TD3DValue;
function VectorCrossProduct(const v1, v2: TD3DVector) : TD3DVector;
function VectorCrossProduct(v1, v2: TD3DVector) : TD3DVector;
 
type
(*
* Vertex data types supported in an ExecuteBuffer.
*)
{ Vertex data types supported in an ExecuteBuffer. }
 
(*
* Homogeneous vertices
*)
{ TD3DHVertex structure }
 
PD3DHVertex = ^TD3DHVertex;
TD3DHVertex = packed record
dwFlags: DWORD; (* Homogeneous clipping flags *)
TD3DHVertex = record
dwFlags: DWORD; // Homogeneous clipping flags
case Integer of
0: (
hx: TD3DValue;
5964,21 → 2705,21
);
end;
 
(*
* Transformed/lit vertices
*)
D3DHVERTEX = TD3DHVertex;
 
{ TD3DTLVertex structure }
 
PD3DTLVertex = ^TD3DTLVertex;
TD3DTLVertex = packed record
TD3DTLVertex = record
case Integer of
0: (
sx: TD3DValue; (* Screen coordinates *)
sx: TD3DValue; // Screen coordinates
sy: TD3DValue;
sz: TD3DValue;
rhw: TD3DValue; (* Reciprocal of homogeneous w *)
color: TD3DColor; (* Vertex color *)
specular: TD3DColor; (* Specular component of vertex *)
tu: TD3DValue; (* Texture coordinates *)
rhw: TD3DValue; // Reciprocal of homogeneous w
color: TD3DColor; // Vertex color
specular: TD3DColor; // Specular component of vertex
tu: TD3DValue; // Texture coordinates
tv: TD3DValue;
);
1: (
5993,21 → 2734,21
);
end;
 
(*
* Untransformed/lit vertices
*)
D3DTLVERTEX = TD3DTLVertex;
 
{ TD3DLVertex structure }
 
PD3DLVertex = ^TD3DLVertex;
TD3DLVertex = packed record
TD3DLVertex = record
case Integer of
0: (
x: TD3DValue; (* Homogeneous coordinates *)
x: TD3DValue; // Homogeneous coordinates
y: TD3DValue;
z: TD3DValue;
dwReserved: DWORD;
color: TD3DColor; (* Vertex color *)
specular: TD3DColor; (* Specular component of vertex *)
tu: TD3DValue; (* Texture coordinates *)
color: TD3DColor; // Vertex color
specular: TD3DColor; // Specular component of vertex
tu: TD3DValue; // Texture coordinates
tv: TD3DValue;
);
1: (
6014,7 → 2755,7
dvX: TD3DValue;
dvY: TD3DValue;
dvZ: TD3DValue;
UNIONFILLER1d: DWORD;
_union1d: DWORD;
dcColor: TD3DColor;
dcSpecular: TD3DColor;
dvTU: TD3DValue;
6022,21 → 2763,21
);
end;
 
(*
* Untransformed/unlit vertices
*)
D3DLVERTEX = TD3DLVertex;
 
{ TD3DVertex structure }
 
PD3DVertex = ^TD3DVertex;
TD3DVertex = packed record
TD3DVertex = record
case Integer of
0: (
x: TD3DValue; (* Homogeneous coordinates *)
x: TD3DValue; // Homogeneous coordinates
y: TD3DValue;
z: TD3DValue;
nx: TD3DValue; (* Normal *)
nx: TD3DValue; // Normal
ny: TD3DValue;
nz: TD3DValue;
tu: TD3DValue; (* Texture coordinates *)
tu: TD3DValue; // Texture coordinates
tv: TD3DValue;
);
1: (
6051,78 → 2792,86
);
end;
 
(*
* Matrix, viewport, and tranformation structures and definitions.
*)
D3DVERTEX = TD3DVertex;
 
{ TD3DMatrix structure }
 
PD3DMatrix = ^TD3DMatrix;
TD3DMatrix = packed record
case integer of
0 : (_11, _12, _13, _14: TD3DValue;
TD3DMatrix = record
_11, _12, _13, _14: TD3DValue;
_21, _22, _23, _24: TD3DValue;
_31, _32, _33, _34: TD3DValue;
_41, _42, _43, _44: TD3DValue);
1 : (m : array [0..3, 0..3] of TD3DValue);
_41, _42, _43, _44: TD3DValue;
end;
 
D3DMATRIX = TD3DMatrix;
 
{ TD3DViewport structure }
 
PD3DViewport = ^TD3DViewport;
TD3DViewport = packed record
TD3DViewport = record
dwSize: DWORD;
dwX: DWORD;
dwY: DWORD; (* Top left *)
dwY: DWORD; // Top left
dwWidth: DWORD;
dwHeight: DWORD; (* Dimensions *)
dvScaleX: TD3DValue; (* Scale homogeneous to screen *)
dvScaleY: TD3DValue; (* Scale homogeneous to screen *)
dvMaxX: TD3DValue; (* Min/max homogeneous x coord *)
dvMaxY: TD3DValue; (* Min/max homogeneous y coord *)
dwHeight: DWORD; // Dimensions
dvScaleX: TD3DValue; // Scale homogeneous to screen
dvScaleY: TD3DValue; // Scale homogeneous to screen
dvMaxX: TD3DValue; // Min/max homogeneous x coord
dvMaxY: TD3DValue; // Min/max homogeneous y coord
dvMinZ: TD3DValue;
dvMaxZ: TD3DValue; (* Min/max homogeneous z coord *)
dvMaxZ: TD3DValue; // Min/max homogeneous z coord
end;
 
D3DVIEWPORT = TD3DViewport;
 
{ TD3DViewport2 structure }
 
PD3DViewport2 = ^TD3DViewport2;
TD3DViewport2 = packed record
TD3DViewport2 = record
dwSize: DWORD;
dwX: DWORD;
dwY: DWORD; (* Viewport Top left *)
dwY: DWORD; // Top left
dwWidth: DWORD;
dwHeight: DWORD; (* Viewport Dimensions *)
dvClipX: TD3DValue; (* Top left of clip volume *)
dwHeight: DWORD; // Dimensions
dvClipX: TD3DValue; // Top left of clip volume
dvClipY: TD3DValue;
dvClipWidth: TD3DValue; (* Clip Volume Dimensions *)
dvClipWidth: TD3DValue; // Clip Volume Dimensions
dvClipHeight: TD3DValue;
dvMinZ: TD3DValue; (* Min/max of clip Volume *)
dvMaxZ: TD3DValue;
dvMinZ: TD3DValue;
dvMaxZ: TD3DValue; // Min/max homogeneous z coord
end;
 
D3DVIEWPORT2 = TD3DViewport2;
 
{ TD3DViewport2 structure }
 
PD3DViewport7 = ^TD3DViewport7;
TD3DViewport7 = packed record
TD3DViewport7 = record
dwX: DWORD;
dwY: DWORD; (* Viewport Top left *)
dwY: DWORD; // Top left
dwWidth: DWORD;
dwHeight: DWORD; (* Viewport Dimensions *)
dvMinZ: TD3DValue; (* Min/max of clip Volume *)
dvMaxZ: TD3DValue;
dwHeight: DWORD; // Dimensions
dvMinZ: TD3DValue;
dvMaxZ: TD3DValue; // Min/max homogeneous z coord
end;
 
(*
* Values for clip fields.
*)
D3DVIEWPORT7 = TD3DViewport7;
 
const
// Max number of user clipping planes, supported in D3D.
{ Max number of user clipping planes, supported in D3D. }
D3DMAXUSERCLIPPLANES = 32;
 
// These bits could be ORed together to use with D3DRENDERSTATE_CLIPPLANEENABLE
//
D3DCLIPPLANE0 = (1 shl 0);
D3DCLIPPLANE1 = (1 shl 1);
D3DCLIPPLANE2 = (1 shl 2);
D3DCLIPPLANE3 = (1 shl 3);
D3DCLIPPLANE4 = (1 shl 4);
D3DCLIPPLANE5 = (1 shl 5);
{ These bits could be ORed together to use with D3DRENDERSTATE_CLIPPLANEENABLE }
D3DCLIPPLANE0 = 1 shl 0;
D3DCLIPPLANE1 = 1 shl 1;
D3DCLIPPLANE2 = 1 shl 2;
D3DCLIPPLANE3 = 1 shl 3;
D3DCLIPPLANE4 = 1 shl 4;
D3DCLIPPLANE5 = 1 shl 5;
 
const
{ Values for clip fields. }
 
D3DCLIP_LEFT = $00000001;
D3DCLIP_RIGHT = $00000002;
D3DCLIP_TOP = $00000004;
6136,9 → 2885,7
D3DCLIP_GEN4 = $00000400;
D3DCLIP_GEN5 = $00000800;
 
(*
* Values for d3d status.
*)
{ Values for d3d status. }
 
D3DSTATUS_CLIPUNIONLEFT = D3DCLIP_LEFT;
D3DSTATUS_CLIPUNIONRIGHT = D3DCLIP_RIGHT;
6166,9 → 2913,8
D3DSTATUS_CLIPINTERSECTIONGEN4 = $00400000;
D3DSTATUS_CLIPINTERSECTIONGEN5 = $00800000;
D3DSTATUS_ZNOTVISIBLE = $01000000;
(* Do not use 0x80000000 for any status flags in future as it is reserved *)
 
D3DSTATUS_CLIPUNIONALL = (
D3DSTATUS_CLIPUNIONALL =
D3DSTATUS_CLIPUNIONLEFT or
D3DSTATUS_CLIPUNIONRIGHT or
D3DSTATUS_CLIPUNIONTOP or
6180,9 → 2926,9
D3DSTATUS_CLIPUNIONGEN2 or
D3DSTATUS_CLIPUNIONGEN3 or
D3DSTATUS_CLIPUNIONGEN4 or
D3DSTATUS_CLIPUNIONGEN5);
D3DSTATUS_CLIPUNIONGEN5;
 
D3DSTATUS_CLIPINTERSECTIONALL = (
D3DSTATUS_CLIPINTERSECTIONALL =
D3DSTATUS_CLIPINTERSECTIONLEFT or
D3DSTATUS_CLIPINTERSECTIONRIGHT or
D3DSTATUS_CLIPINTERSECTIONTOP or
6194,59 → 2940,61
D3DSTATUS_CLIPINTERSECTIONGEN2 or
D3DSTATUS_CLIPINTERSECTIONGEN3 or
D3DSTATUS_CLIPINTERSECTIONGEN4 or
D3DSTATUS_CLIPINTERSECTIONGEN5);
D3DSTATUS_CLIPINTERSECTIONGEN5;
 
D3DSTATUS_DEFAULT = (
D3DSTATUS_CLIPINTERSECTIONALL or
D3DSTATUS_ZNOTVISIBLE);
 
(*
* Options for direct transform calls
*)
{ Options for direct transform calls }
 
D3DTRANSFORM_CLIPPED = $00000001;
D3DTRANSFORM_UNCLIPPED = $00000002;
 
type
{ TD3DTransformData structure }
 
PD3DTransformData = ^TD3DTransformData;
TD3DTransformData = packed record
TD3DTransformData = record
dwSize: DWORD;
lpIn: Pointer; (* Input vertices *)
dwInSize: DWORD; (* Stride of input vertices *)
lpOut: Pointer; (* Output vertices *)
dwOutSize: DWORD; (* Stride of output vertices *)
lpHOut: ^TD3DHVertex; (* Output homogeneous vertices *)
dwClip: DWORD; (* Clipping hint *)
lpIn: Pointer; // Input vertices
dwInSize: DWORD; // Stride of input vertices
lpOut: Pointer; // Output vertices
dwOutSize: DWORD; // Stride of output vertices
lpHOut: PD3DHVertex; // Output homogeneous vertices
dwClip: DWORD; // Clipping hint
dwClipIntersection: DWORD;
dwClipUnion: DWORD; (* Union of all clip flags *)
drExtent: TD3DRect; (* Extent of transformed vertices *)
dwClipUnion: DWORD; // Union of all clip flags
drExtent: TD3DRect; // Extent of transformed vertices
end;
 
(*
* Structure defining position and direction properties for lighting.
*)
D3DTRANSFORMDATA = TD3DTransformData;
LPD3DTRANSFORMDATA = PD3DTransformData;
 
{ TD3DLightingElement structure }
 
PD3DLightingElement = ^TD3DLightingElement;
TD3DLightingElement = packed record
dvPosition: TD3DVector; (* Lightable point in model space *)
dvNormal: TD3DVector; (* Normalised unit vector *)
TD3DLightingElement = record
dvPosition: TD3DVector; // Lightable point in model space
dvNormal: TD3DVector; // Normalised unit vector
end;
 
(*
* Structure defining material properties for lighting.
*)
D3DLIGHTINGELEMENT = TD3DLightingElement;
LPD3DLIGHTINGELEMENT = PD3DLightingElement;
 
{ TD3DMaterial structure }
 
PD3DMaterial = ^TD3DMaterial;
TD3DMaterial = packed record
TD3DMaterial = record
dwSize: DWORD;
case Integer of
0: (
diffuse: TD3DColorValue; (* Diffuse color RGBA *)
ambient: TD3DColorValue; (* Ambient color RGB *)
specular: TD3DColorValue; (* Specular 'shininess' *)
emissive: TD3DColorValue; (* Emissive color RGB *)
power: TD3DValue; (* Sharpness if specular highlight *)
hTexture: TD3DTextureHandle; (* Handle to texture map *)
diffuse: TD3DColorValue; // Diffuse color RGBA
ambient: TD3DColorValue; // Ambient color RGB
specular: TD3DColorValue; // Specular 'shininess'
emissive: TD3DColorValue; // Emissive color RGB
power: TD3DValue; // Sharpness if specular highlight
hTexture: TD3DTextureHandle; // Handle to texture map
dwRampSize: DWORD;
);
1: (
6258,15 → 3006,20
);
end;
 
D3DMATERIAL = TD3DMaterial;
LPD3DMATERIAL = PD3DMaterial;
 
{ TD3DMaterial7 structure }
 
PD3DMaterial7 = ^TD3DMaterial7;
TD3DMaterial7 = packed record
TD3DMaterial7 = record
case Integer of
0: (
diffuse: TD3DColorValue; (* Diffuse color RGBA *)
ambient: TD3DColorValue; (* Ambient color RGB *)
specular: TD3DColorValue; (* Specular 'shininess' *)
emissive: TD3DColorValue; (* Emissive color RGB *)
power: TD3DValue; (* Sharpness if specular highlight *)
diffuse: TD3DColorValue; // Diffuse color RGBA
ambient: TD3DColorValue; // Ambient color RGB
specular: TD3DColorValue; // Specular 'shininess'
emissive: TD3DColorValue; // Emissive color RGB
power: TD3DValue; // Sharpness if specular highlight
);
1: (
dcvDiffuse: TD3DColorValue;
6277,97 → 3030,117
);
end;
 
PD3DLightType = ^TD3DLightType;
D3DMATERIAL7 = TD3DMaterial7;
LPD3DMATERIAL7 = PD3DMaterial7;
 
{ TD3DLightType }
 
TD3DLightType = (
D3DLIGHT_INVALID_0,
D3DLIGHT_POINT,
D3DLIGHT_SPOT,
D3DLIGHT_DIRECTIONAL,
// Note: The following light type (D3DLIGHT_PARALLELPOINT)
// is no longer supported from D3D for DX7 onwards.
D3DLIGHT_PARALLELPOINT,
D3DLIGHT_GLSPOT);
D3DLIGHT_PARALLELPOINT
{$IFNDEF SupportDirectX5},D3DLIGHT_GLSPOT{$ENDIF}
);
 
(*
* Structure defining a light source and its properties.
*)
D3DLIGHTTYPE = TD3DLightType;
 
{ TD3DLight structure }
 
PD3DLight = ^TD3DLight;
TD3DLight = packed record
TD3DLight = record
dwSize: DWORD;
dltType: TD3DLightType; (* Type of light source *)
dcvColor: TD3DColorValue; (* Color of light *)
dvPosition: TD3DVector; (* Position in world space *)
dvDirection: TD3DVector; (* Direction in world space *)
dvRange: TD3DValue; (* Cutoff range *)
dvFalloff: TD3DValue; (* Falloff *)
dvAttenuation0: TD3DValue; (* Constant attenuation *)
dvAttenuation1: TD3DValue; (* Linear attenuation *)
dvAttenuation2: TD3DValue; (* Quadratic attenuation *)
dvTheta: TD3DValue; (* Inner angle of spotlight cone *)
dvPhi: TD3DValue; (* Outer angle of spotlight cone *)
dltType: TD3DLightType; // Type of light source
dcvColor: TD3DColorValue; // Color of light
dvPosition: TD3DVector; // Position in world space
dvDirection: TD3DVector; // Direction in world space
dvRange: TD3DValue; // Cutoff range
dvFalloff: TD3DValue; // Falloff
dvAttenuation0: TD3DValue; // Constant attenuation
dvAttenuation1: TD3DValue; // Linear attenuation
dvAttenuation2: TD3DValue; // Quadratic attenuation
dvTheta: TD3DValue; // Inner angle of spotlight cone
dvPhi: TD3DValue; // Outer angle of spotlight cone
end;
 
D3DLIGHT = TD3DLight;
LPD3DLIGHT = PD3DLight;
 
{ TD3DLight7 structure }
 
PD3DLight7 = ^TD3DLight7;
TD3DLight7 = packed record
dltType: TD3DLightType; (* Type of light source *)
dcvDiffuse: TD3DColorValue; (* Diffuse color of light *)
dcvSpecular: TD3DColorValue;(* Specular color of light *)
dcvAmbient: TD3DColorValue; (* Ambient color of light *)
dvPosition: TD3DVector; (* Position in world space *)
dvDirection: TD3DVector; (* Direction in world space *)
dvRange: TD3DValue; (* Cutoff range *)
dvFalloff: TD3DValue; (* Falloff *)
dvAttenuation0: TD3DValue; (* Constant attenuation *)
dvAttenuation1: TD3DValue; (* Linear attenuation *)
dvAttenuation2: TD3DValue; (* Quadratic attenuation *)
dvTheta: TD3DValue; (* Inner angle of spotlight cone *)
dvPhi: TD3DValue; (* Outer angle of spotlight cone *)
TD3DLight7 = record
dltType: TD3DLightType; // Type of light source
dcvDiffuse: TD3DColorValue; // Diffuse color of light
dcvSpecular: TD3DColorValue;// Specular color of light
dcvAmbient: TD3DColorValue; // Ambient color of light
dvPosition: TD3DVector; // Position in world space
dvDirection: TD3DVector; // Direction in world space
dvRange: TD3DValue; // Cutoff range
dvFalloff: TD3DValue; // Falloff
dvAttenuation0: TD3DValue; // Constant attenuation
dvAttenuation1: TD3DValue; // Linear attenuation
dvAttenuation2: TD3DValue; // Quadratic attenuation
dvTheta: TD3DValue; // Inner angle of spotlight cone
dvPhi: TD3DValue; // Outer angle of spotlight cone
end;
 
(*
* Structure defining a light source and its properties.
*)
D3DLIGHT7 = TD3DLight7;
LPD3DLIGHT7 = PD3DLight7;
 
(* flags bits *)
{ Structure defining a light source and its properties. }
 
const
{ flags bits }
 
D3DLIGHT_ACTIVE = $00000001;
D3DLIGHT_NO_SPECULAR = $00000002;
D3DLIGHT_ALL = D3DLIGHT_ACTIVE or D3DLIGHT_ACTIVE;
D3DLIGHT_ALL = D3DLIGHT_ACTIVE or D3DLIGHT_NO_SPECULAR;
 
(* maximum valid light range *)
D3DLIGHT_RANGE_MAX = 1.8439088915e+18; //sqrt(FLT_MAX);
{ maximum valid light range }
D3DLIGHT_RANGE_MAX: TD3DValue = 3.4 * 10e+38;
 
type
{ TD3DLight2 structure }
 
PD3DLight2 = ^TD3DLight2;
TD3DLight2 = packed record
TD3DLight2 = record
dwSize: DWORD;
dltType: TD3DLightType; (* Type of light source *)
dcvColor: TD3DColorValue; (* Color of light *)
dvPosition: TD3DVector; (* Position in world space *)
dvDirection: TD3DVector; (* Direction in world space *)
dvRange: TD3DValue; (* Cutoff range *)
dvFalloff: TD3DValue; (* Falloff *)
dvAttenuation0: TD3DValue; (* Constant attenuation *)
dvAttenuation1: TD3DValue; (* Linear attenuation *)
dvAttenuation2: TD3DValue; (* Quadratic attenuation *)
dvTheta: TD3DValue; (* Inner angle of spotlight cone *)
dvPhi: TD3DValue; (* Outer angle of spotlight cone *)
dltType: TD3DLightType; // Type of light source
dcvColor: TD3DColorValue; // Color of light
dvPosition: TD3DVector; // Position in world space
dvDirection: TD3DVector; // Direction in world space
dvRange: TD3DValue; // Cutoff range
dvFalloff: TD3DValue; // Falloff
dvAttenuation0: TD3DValue; // Constant attenuation
dvAttenuation1: TD3DValue; // Linear attenuation
dvAttenuation2: TD3DValue; // Quadratic attenuation
dvTheta: TD3DValue; // Inner angle of spotlight cone
dvPhi: TD3DValue; // Outer angle of spotlight cone
dwFlags: DWORD;
end;
 
D3DLIGHT2 = TD3DLight2;
LPD3DLIGHT2 = PD3DLight2;
 
{ TD3DLightData structure }
 
PD3DLightData = ^TD3DLightData;
TD3DLightData = packed record
TD3DLightData = record
dwSize: DWORD;
lpIn: ^TD3DLightingElement; (* Input positions and normals *)
dwInSize: DWORD; (* Stride of input elements *)
lpOut: ^TD3DTLVertex; (* Output colors *)
dwOutSize: DWORD; (* Stride of output colors *)
lpIn: PD3DLightingElement; // Input positions and normals
dwInSize: DWORD; // Stride of input elements
lpOut: PD3DTLVertex; // Output colors
dwOutSize: DWORD; // Stride of output colors
end;
 
D3DLIGHTDATA = TD3DLightData;
LPD3DLIGHTDATA = PD3DLightData;
 
(*
* Before DX5, these values were in an enum called
* TD3DColorModel. This was not correct, since they are
* D3DCOLORMODEL. This was not correct, since they are
* bit flags. A driver can surface either or both flags
* in the dcmColorModel member of D3DDEVICEDESC.
*)
6374,32 → 3147,23
 
type
TD3DColorModel = DWORD;
D3DCOLORMODEL = TD3DColorModel;
const
D3DCOLOR_INVALID_0 = 0;
D3DCOLOR_MONO = 1;
D3DCOLOR_RGB = 2;
 
(*
* Options for clearing
*)
{ Options for clearing }
 
const
D3DCLEAR_TARGET = $00000001; (* Clear target surface *)
D3DCLEAR_ZBUFFER = $00000002; (* Clear target z buffer *)
D3DCLEAR_STENCIL = $00000004; (* Clear stencil planes *)
D3DCLEAR_TARGET = $00000001; // Clear target surface
D3DCLEAR_ZBUFFER = $00000002; // Clear target z buffer
D3DCLEAR_STENCIL = $00000004; // Clear stencil planes
 
(*
* Execute buffers are allocated via Direct3D. These buffers may then
* be filled by the application with instructions to execute along with
* vertex data.
*)
{ Supported op codes for execute instructions. }
 
(*
* Supported op codes for execute instructions.
*)
 
type
PD3DOpcode = ^TD3DOpcode;
TD3DOpcode = (
D3DOP_INVALID_0,
D3DOP_POINT,
6415,63 → 3179,71
D3DOP_EXIT,
D3DOP_BRANCHFORWARD,
D3DOP_SPAN,
D3DOP_SETSTATUS);
D3DOP_SETSTATUS
);
 
PD3DInstruction = ^TD3DInstruction;
TD3DInstruction = packed record
bOpcode: BYTE; (* Instruction opcode *)
bSize: BYTE; (* Size of each instruction data unit *)
wCount: WORD; (* Count of instruction data units to follow *)
D3DOPCODE = TD3DOpcode;
 
{ TD3DInstruction structure }
 
TD3DInstruction = record
bOpcode: Byte; // Instruction opcode
bSize: Byte; // Size of each instruction data unit
wCount: WORD; // Count of instruction data units to follow
end;
D3DINSTRUCTION = TD3DInstruction;
 
(*
* Structure for texture loads
*)
{ TD3DTextureLoad structure }
 
PD3DTextureLoad = ^TD3DTextureLoad;
TD3DTextureLoad = packed record
TD3DTextureLoad = record
hDestTexture: TD3DTextureHandle;
hSrcTexture: TD3DTextureHandle;
end;
D3DTEXTURELOAD = TD3DTextureLoad;
 
(*
* Structure for picking
*)
{ TD3DPickRecord structure }
 
PD3DPickRecord = ^TD3DPickRecord;
TD3DPickRecord = packed record
TD3DPickRecord = record
bOpcode: BYTE;
bPad: BYTE;
dwOffset: DWORD;
dvZ: TD3DValue;
end;
D3DPICKRECORD = TD3DPickRecord;
 
(*
* The following defines the rendering states which can be set in the
* execute buffer.
*)
{ TD3DShadeMode }
 
PD3DShadeMode = ^TD3DShadeMode;
TD3DShadeMode = (
D3DSHADE_INVALID_0,
D3DSHADE_FLAT,
D3DSHADE_GOURAUD,
D3DSHADE_PHONG);
D3DSHADE_PHONG
);
 
PD3DFillMode = ^TD3DFillMode;
D3DSHADEMODE = TD3DShadeMode;
 
{ TD3DFillMode }
 
TD3DFillMode = (
D3DFILL_INVALID_0,
D3DFILL_POINT,
D3DFILL_WIREFRAME,
D3DFILL_SOLID);
D3DFILL_SOLID
);
 
PD3DLinePattern = ^TD3DLinePattern;
TD3DLinePattern = packed record
D3DFILLMODE = TD3DFillMode;
 
{ TD3DLinePattern structure }
 
TD3DLinePattern = record
wRepeatFactor: WORD;
wLinePattern: WORD;
end;
 
PD3DTextureFilter = ^TD3DTextureFilter;
D3DLINEPATTERN = TD3DLinePattern;
 
{ TD3DTextureFilter }
 
TD3DTextureFilter = (
D3DFILTER_INVALID_0,
D3DFILTER_NEAREST,
6479,9 → 3251,13
D3DFILTER_MIPNEAREST,
D3DFILTER_MIPLINEAR,
D3DFILTER_LINEARMIPNEAREST,
D3DFILTER_LINEARMIPLINEAR);
D3DFILTER_LINEARMIPLINEAR
);
 
PD3DBlend = ^TD3DBlend;
D3DTEXTUREFILTER = TD3DTextureFilter;
 
{ TD3DBlend }
 
TD3DBlend = (
D3DBLEND_INVALID_0,
D3DBLEND_ZERO,
6496,9 → 3272,13
D3DBLEND_INVDESTCOLOR,
D3DBLEND_SRCALPHASAT,
D3DBLEND_BOTHSRCALPHA,
D3DBLEND_BOTHINVSRCALPHA);
D3DBLEND_BOTHINVSRCALPHA
);
 
PD3DTextureBlend = ^TD3DTextureBlend;
D3DBLEND = TD3DBlend;
 
{ TD3DTextureBlend }
 
TD3DTextureBlend = (
D3DTBLEND_INVALID_0,
D3DTBLEND_DECAL,
6508,24 → 3288,36
D3DTBLEND_DECALMASK,
D3DTBLEND_MODULATEMASK,
D3DTBLEND_COPY,
D3DTBLEND_ADD);
D3DTBLEND_ADD
);
 
PD3DTextureAddress = ^TD3DTextureAddress;
D3DTEXTUREBLEND = TD3DTextureBlend;
 
{ TD3DTextureAddress }
 
TD3DTextureAddress = (
D3DTADDRESS_INVALID_0,
D3DTADDRESS_WRAP,
D3DTADDRESS_MIRROR,
D3DTADDRESS_CLAMP,
D3DTADDRESS_BORDER);
D3DTADDRESS_BORDER
);
 
PD3DCull = ^TD3DCull;
D3DTEXTUREADDRESS = TD3DTextureAddress;
 
{ TD3DCull }
 
TD3DCull = (
D3DCULL_INVALID_0,
D3DCULL_NONE,
D3DCULL_CW,
D3DCULL_CCW);
D3DCULL_CCW
);
 
PD3DCmpFunc = ^TD3DCmpFunc;
D3DCULL = TD3DCull;
 
{ TD3DCmpFunc }
 
TD3DCmpFunc = (
D3DCMP_INVALID_0,
D3DCMP_NEVER,
6535,9 → 3327,13
D3DCMP_GREATER,
D3DCMP_NOTEQUAL,
D3DCMP_GREATEREQUAL,
D3DCMP_ALWAYS);
D3DCMP_ALWAYS
);
 
PD3DStencilOp = ^TD3DStencilOp;
D3DCMPFUNC = TD3DCmpFunc;
 
{ TD3DStencilOp }
 
TD3DStencilOp = (
D3DSTENCILOP_INVALID_0,
D3DSTENCILOP_KEEP,
6547,37 → 3343,55
D3DSTENCILOP_DECRSAT,
D3DSTENCILOP_INVERT,
D3DSTENCILOP_INCR,
D3DSTENCILOP_DECR);
D3DSTENCILOP_DECR
);
PD3DFogMode = ^TD3DFogMode;
D3DSTENCILOP = TD3DStencilOp;
 
{ TD3DFogMode }
 
TD3DFogMode = (
D3DFOG_NONE,
D3DFOG_EXP,
D3DFOG_EXP2,
D3DFOG_LINEAR);
D3DFOG_LINEAR
);
 
PD3DZBufferType = ^TD3DZBufferType;
D3DFOGMODE = TD3DFogMode;
 
{ TD3DZBufferType }
 
TD3DZBufferType = (
D3DZB_FALSE,
D3DZB_TRUE, // Z buffering
D3DZB_USEW); // W buffering
D3DZB_USEW // W buffering
);
 
PD3DAntialiasMode = ^TD3DAntialiasMode;
D3DZBUFFERTYPE = TD3DZBufferType;
 
{ TD3DAntialiasMode }
 
TD3DAntialiasMode = (
D3DANTIALIAS_NONE,
D3DANTIALIAS_SORTDEPENDENT,
D3DANTIALIAS_SORTINDEPENDENT);
D3DANTIALIAS_SORTINDEPENDENT
);
 
// Vertex types supported by Direct3D
PD3DVertexType = ^TD3DVertexType;
D3DANTIALIASMODE = TD3DAntialiasMode;
 
{ TD3DVertexType }
 
TD3DVertexType = (
D3DVT_INVALID_0,
D3DVT_VERTEX,
D3DVT_LVERTEX,
D3DVT_TLVERTEX);
D3DVT_TLVERTEX
);
 
// Primitives supported by draw-primitive API
PD3DPrimitiveType = ^TD3DPrimitiveType;
D3DVERTEXTYPE = TD3DVertexType;
 
{ TD3DPrimitiveType }
 
TD3DPrimitiveType = (
D3DPT_INVALID_0,
D3DPT_POINTLIST,
6585,42 → 3399,55
D3DPT_LINESTRIP,
D3DPT_TRIANGLELIST,
D3DPT_TRIANGLESTRIP,
D3DPT_TRIANGLEFAN);
D3DPT_TRIANGLEFAN
);
 
(*
* Amount to add to a state to generate the override for that state.
*)
D3DPRIMITIVETYPE = TD3DPrimitiveType;
 
{ Amount to add to a state to generate the override for that state. }
 
const
D3DSTATE_OVERRIDE_BIAS = 256;
 
(*
* A state which sets the override flag for the specified state type.
*)
function D3DSTATE_OVERRIDE(typ: DWORD): DWORD;
 
function D3DSTATE_OVERRIDE(StateType: DWORD) : DWORD;
{ A state which sets the override flag for the specified state type. }
 
type
PD3DTransformStateType = ^TD3DTransformStateType;
TD3DTransformStateType = DWORD;
const
D3DTRANSFORMSTATE_WORLD = 1;
D3DTRANSFORMSTATE_VIEW = 2;
D3DTRANSFORMSTATE_PROJECTION = 3;
D3DTRANSFORMSTATE_WORLD1 = 4; // 2nd matrix to blend
D3DTRANSFORMSTATE_WORLD2 = 5; // 3rd matrix to blend
D3DTRANSFORMSTATE_WORLD3 = 6; // 4th matrix to blend
D3DTRANSFORMSTATE_TEXTURE0 = 16;
D3DTRANSFORMSTATE_TEXTURE1 = 17;
D3DTRANSFORMSTATE_TEXTURE2 = 18;
D3DTRANSFORMSTATE_TEXTURE3 = 19;
D3DTRANSFORMSTATE_TEXTURE4 = 20;
D3DTRANSFORMSTATE_TEXTURE5 = 21;
D3DTRANSFORMSTATE_TEXTURE6 = 22;
D3DTRANSFORMSTATE_TEXTURE7 = 23;
{ TD3DTransformStateType }
 
type
PD3DLightStateType = ^TD3DLightStateType;
TD3DTransformStateType = (
D3DTRANSFORMSTATE_INVALID_0,
D3DTRANSFORMSTATE_WORLD,
D3DTRANSFORMSTATE_VIEW,
D3DTRANSFORMSTATE_PROJECTION,
 
D3DTRANSFORMSTATE_WORLD1,
D3DTRANSFORMSTATE_WORLD2,
D3DTRANSFORMSTATE_WORLD3,
D3DTRANSFORMSTATE_INVALID_7,
D3DTRANSFORMSTATE_INVALID_8,
D3DTRANSFORMSTATE_INVALID_9,
D3DTRANSFORMSTATE_INVALID_10,
D3DTRANSFORMSTATE_INVALID_11,
D3DTRANSFORMSTATE_INVALID_12,
D3DTRANSFORMSTATE_INVALID_13,
D3DTRANSFORMSTATE_INVALID_14,
D3DTRANSFORMSTATE_INVALID_15,
D3DTRANSFORMSTATE_TEXTURE0,
D3DTRANSFORMSTATE_TEXTURE1,
D3DTRANSFORMSTATE_TEXTURE2,
D3DTRANSFORMSTATE_TEXTURE3,
D3DTRANSFORMSTATE_TEXTURE4,
D3DTRANSFORMSTATE_TEXTURE5,
D3DTRANSFORMSTATE_TEXTURE6,
D3DTRANSFORMSTATE_TEXTURE7
);
 
D3DTRANSFORMSTATETYPE = TD3DTransformStateType;
 
{ TD3DLightStateType }
 
TD3DLightStateType = (
D3DLIGHTSTATE_INVALID_0,
D3DLIGHTSTATE_MATERIAL,
6630,185 → 3457,216
D3DLIGHTSTATE_FOGSTART,
D3DLIGHTSTATE_FOGEND,
D3DLIGHTSTATE_FOGDENSITY,
D3DLIGHTSTATE_COLORVERTEX);
D3DLIGHTSTATE_COLORVERTEX
);
 
PD3DRenderStateType = ^TD3DRenderStateType;
TD3DRenderStateType = DWORD;
const
D3DRENDERSTATE_ANTIALIAS = 2; (* D3DANTIALIASMODE *)
D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4; (* TRUE for perspective correction *)
D3DRENDERSTATE_ZENABLE = 7; (* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) *)
D3DRENDERSTATE_FILLMODE = 8; (* D3DFILL_MODE *)
D3DRENDERSTATE_SHADEMODE = 9; (* D3DSHADEMODE *)
D3DRENDERSTATE_LINEPATTERN = 10; (* D3DLINEPATTERN *)
D3DRENDERSTATE_ZWRITEENABLE = 14; (* TRUE to enable z writes *)
D3DRENDERSTATE_ALPHATESTENABLE = 15; (* TRUE to enable alpha tests *)
D3DRENDERSTATE_LASTPIXEL = 16; (* TRUE for last-pixel on lines *)
D3DRENDERSTATE_SRCBLEND = 19; (* D3DBLEND *)
D3DRENDERSTATE_DESTBLEND = 20; (* D3DBLEND *)
D3DRENDERSTATE_CULLMODE = 22; (* D3DCULL *)
D3DRENDERSTATE_ZFUNC = 23; (* D3DCMPFUNC *)
D3DRENDERSTATE_ALPHAREF = 24; (* D3DFIXED *)
D3DRENDERSTATE_ALPHAFUNC = 25; (* D3DCMPFUNC *)
D3DRENDERSTATE_DITHERENABLE = 26; (* TRUE to enable dithering *)
D3DRENDERSTATE_ALPHABLENDENABLE = 27; (* TRUE to enable alpha blending *)
D3DRENDERSTATE_FOGENABLE = 28; (* TRUE to enable fog blending *)
D3DRENDERSTATE_SPECULARENABLE = 29; (* TRUE to enable specular *)
D3DRENDERSTATE_ZVISIBLE = 30; (* TRUE to enable z checking *)
D3DRENDERSTATE_STIPPLEDALPHA = 33; (* TRUE to enable stippled alpha (RGB device only) *)
D3DRENDERSTATE_FOGCOLOR = 34; (* D3DCOLOR *)
D3DRENDERSTATE_FOGTABLEMODE = 35; (* D3DFOGMODE *)
D3DRENDERSTATE_FOGSTART = 36; (* Fog start (for both vertex and pixel fog) *)
D3DRENDERSTATE_FOGEND = 37; (* Fog end *)
D3DRENDERSTATE_FOGDENSITY = 38; (* Fog density *)
D3DRENDERSTATE_EDGEANTIALIAS = 40; (* TRUE to enable edge antialiasing *)
D3DRENDERSTATE_COLORKEYENABLE = 41; (* TRUE to enable source colorkeyed textures *)
D3DRENDERSTATE_ZBIAS = 47; (* LONG Z bias *)
D3DRENDERSTATE_RANGEFOGENABLE = 48; (* Enables range-based fog *)
D3DLIGHTSTATETYPE = TD3DLightStateType;
 
D3DRENDERSTATE_STENCILENABLE = 52; (* BOOL enable/disable stenciling *)
D3DRENDERSTATE_STENCILFAIL = 53; (* D3DSTENCILOP to do if stencil test fails *)
D3DRENDERSTATE_STENCILZFAIL = 54; (* D3DSTENCILOP to do if stencil test passes and Z test fails *)
D3DRENDERSTATE_STENCILPASS = 55; (* D3DSTENCILOP to do if both stencil and Z tests pass *)
D3DRENDERSTATE_STENCILFUNC = 56; (* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true *)
D3DRENDERSTATE_STENCILREF = 57; (* Reference value used in stencil test *)
D3DRENDERSTATE_STENCILMASK = 58; (* Mask value used in stencil test *)
D3DRENDERSTATE_STENCILWRITEMASK = 59; (* Write mask applied to values written to stencil buffer *)
D3DRENDERSTATE_TEXTUREFACTOR = 60; (* D3DCOLOR used for multi-texture blend *)
{ TD3DRenderStateType }
 
(*
* 128 values [128; 255] are reserved for texture coordinate wrap flags.
* These are constructed with the D3DWRAP_U and D3DWRAP_V macros. Using
* a flags word preserves forward compatibility with texture coordinates
* that are >2D.
*)
D3DRENDERSTATE_WRAP0 = 128; (* wrap for 1st texture coord. set *)
D3DRENDERSTATE_WRAP1 = 129; (* wrap for 2nd texture coord. set *)
D3DRENDERSTATE_WRAP2 = 130; (* wrap for 3rd texture coord. set *)
D3DRENDERSTATE_WRAP3 = 131; (* wrap for 4th texture coord. set *)
D3DRENDERSTATE_WRAP4 = 132; (* wrap for 5th texture coord. set *)
D3DRENDERSTATE_WRAP5 = 133; (* wrap for 6th texture coord. set *)
D3DRENDERSTATE_WRAP6 = 134; (* wrap for 7th texture coord. set *)
D3DRENDERSTATE_WRAP7 = 135; (* wrap for 8th texture coord. set *)
D3DRENDERSTATE_CLIPPING = 136;
D3DRENDERSTATE_LIGHTING = 137;
D3DRENDERSTATE_EXTENTS = 138;
D3DRENDERSTATE_AMBIENT = 139;
D3DRENDERSTATE_FOGVERTEXMODE = 140;
D3DRENDERSTATE_COLORVERTEX = 141;
D3DRENDERSTATE_LOCALVIEWER = 142;
D3DRENDERSTATE_NORMALIZENORMALS = 143;
D3DRENDERSTATE_COLORKEYBLENDENABLE = 144;
D3DRENDERSTATE_DIFFUSEMATERIALSOURCE = 145;
D3DRENDERSTATE_SPECULARMATERIALSOURCE = 146;
D3DRENDERSTATE_AMBIENTMATERIALSOURCE = 147;
D3DRENDERSTATE_EMISSIVEMATERIALSOURCE = 148;
D3DRENDERSTATE_VERTEXBLEND = 151;
D3DRENDERSTATE_CLIPPLANEENABLE = 152;
 
TD3DRenderStateType = (
D3DRENDERSTATE_INVALID_0,
D3DRENDERSTATE_TEXTUREHANDLE, // Texture handle for legacy interfaces (Texture,Texture2)
D3DRENDERSTATE_ANTIALIAS, // TD3DAntialiasMode
D3DRENDERSTATE_TEXTUREADDRESS, // TD3DTextureAddress
D3DRENDERSTATE_TEXTUREPERSPECTIVE, // TRUE for perspective correction
D3DRENDERSTATE_WRAPU, // TRUE for wrapping in u
D3DRENDERSTATE_WRAPV, // TRUE for wrapping in v
D3DRENDERSTATE_ZENABLE, // TD3DZBufferType (or TRUE/FALSE for legacy)
D3DRENDERSTATE_FILLMODE, // TD3DFillMode
D3DRENDERSTATE_SHADEMODE, // TD3DShadeMode
D3DRENDERSTATE_LINEPATTERN, // TD3DLinePattern
D3DRENDERSTATE_MONOENABLE, // TRUE to enable mono rasterization
D3DRENDERSTATE_ROP2, // ROP2
D3DRENDERSTATE_PLANEMASK, // DWORD physical plane mask
D3DRENDERSTATE_ZWRITEENABLE, // TRUE to enable z writes
D3DRENDERSTATE_ALPHATESTENABLE, // TRUE to enable alpha tests
D3DRENDERSTATE_LASTPIXEL, // TRUE for last-pixel on lines
D3DRENDERSTATE_TEXTUREMAG, // TD3DTextureFilter
D3DRENDERSTATE_TEXTUREMIN, // TD3DTextureFilter
D3DRENDERSTATE_SRCBLEND, // TD3DBlend
D3DRENDERSTATE_DESTBLEND, // TD3DBlend
D3DRENDERSTATE_TEXTUREMAPBLEND, // TD3DTextureBlend
D3DRENDERSTATE_CULLMODE, // TD3DCull
D3DRENDERSTATE_ZFUNC, // TD3DCmpFunc
D3DRENDERSTATE_ALPHAREF, // TD3DFixed
D3DRENDERSTATE_ALPHAFUNC, // TD3DCmpFunc
D3DRENDERSTATE_DITHERENABLE, // TRUE to enable dithering
D3DRENDERSTATE_ALPHABLENDENABLE, // TRUE to enable alpha blending
D3DRENDERSTATE_FOGENABLE, // TRUE to enable fog
D3DRENDERSTATE_SPECULARENABLE, // TRUE to enable specular
D3DRENDERSTATE_ZVISIBLE, // TRUE to enable z checking
D3DRENDERSTATE_SUBPIXEL, // TRUE to enable subpixel correction
D3DRENDERSTATE_SUBPIXELX, // TRUE to enable correction in X only
D3DRENDERSTATE_STIPPLEDALPHA, // TRUE to enable stippled alpha
D3DRENDERSTATE_FOGCOLOR, // TD3DColor
D3DRENDERSTATE_FOGTABLEMODE, // TD3DFogMode
D3DRENDERSTATE_FOGSTART, // Fog start (for both vertex and pixel fog)
D3DRENDERSTATE_FOGEND, // Fog end
D3DRENDERSTATE_FOGDENSITY, // Fog density
D3DRENDERSTATE_STIPPLEENABLE, // TRUE to enable stippling
D3DRENDERSTATE_EDGEANTIALIAS, // TRUE to enable edge antialiasing
D3DRENDERSTATE_COLORKEYENABLE, // TRUE to enable source colorkeyed textures
D3DRENDERSTATE_BORDERCOLOR, // Border color for texturing w/border
D3DRENDERSTATE_TEXTUREADDRESSU, // Texture addressing mode for U coordinate
D3DRENDERSTATE_TEXTUREADDRESSV, // Texture addressing mode for V coordinate
D3DRENDERSTATE_MIPMAPLODBIAS, // TD3DValue Mipmap LOD bias
D3DRENDERSTATE_ZBIAS, // LONG Z bias
D3DRENDERSTATE_RANGEFOGENABLE, // Enables range-based fog
D3DRENDERSTATE_ANISOTROPY, // Max. anisotropy. 1 = no anisotropy
D3DRENDERSTATE_FLUSHBATCH, // Explicit flush for DP batching (DX5 Only)
D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT,// BOOL enable sort-independent transparency
D3DRENDERSTATE_STENCILENABLE, // BOOL enable/disable stenciling
D3DRENDERSTATE_STENCILFAIL, // TD3DStencilOp to do if stencil test fails
D3DRENDERSTATE_STENCILZFAIL, // TD3DStencilOp to do if stencil test passes and Z test fails
D3DRENDERSTATE_STENCILPASS, // TD3DStencilOp to do if both stencil and Z tests pass
D3DRENDERSTATE_STENCILFUNC , // TD3DCmpFunc fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true
D3DRENDERSTATE_STENCILREF, // Reference value used in stencil test
D3DRENDERSTATE_STENCILMASK, // Mask value used in stencil test
D3DRENDERSTATE_STENCILWRITEMASK, // Write mask applied to values written to stencil buffer
D3DRENDERSTATE_TEXTUREFACTOR, // TD3DColor used for multi-texture blend
D3DRENDERSTATE_INVALID_61,
D3DRENDERSTATE_INVALID_62,
D3DRENDERSTATE_INVALID_63,
D3DRENDERSTATE_STIPPLEPATTERN00, // Stipple pattern 01...
D3DRENDERSTATE_STIPPLEPATTERN01,
D3DRENDERSTATE_STIPPLEPATTERN02,
D3DRENDERSTATE_STIPPLEPATTERN03,
D3DRENDERSTATE_STIPPLEPATTERN04,
D3DRENDERSTATE_STIPPLEPATTERN05,
D3DRENDERSTATE_STIPPLEPATTERN06,
D3DRENDERSTATE_STIPPLEPATTERN07,
D3DRENDERSTATE_STIPPLEPATTERN08,
D3DRENDERSTATE_STIPPLEPATTERN09,
D3DRENDERSTATE_STIPPLEPATTERN10,
D3DRENDERSTATE_STIPPLEPATTERN11,
D3DRENDERSTATE_STIPPLEPATTERN12,
D3DRENDERSTATE_STIPPLEPATTERN13,
D3DRENDERSTATE_STIPPLEPATTERN14,
D3DRENDERSTATE_STIPPLEPATTERN15,
D3DRENDERSTATE_STIPPLEPATTERN16,
D3DRENDERSTATE_STIPPLEPATTERN17,
D3DRENDERSTATE_STIPPLEPATTERN18,
D3DRENDERSTATE_STIPPLEPATTERN19,
D3DRENDERSTATE_STIPPLEPATTERN20,
D3DRENDERSTATE_STIPPLEPATTERN21,
D3DRENDERSTATE_STIPPLEPATTERN22,
D3DRENDERSTATE_STIPPLEPATTERN23,
D3DRENDERSTATE_STIPPLEPATTERN24,
D3DRENDERSTATE_STIPPLEPATTERN25,
D3DRENDERSTATE_STIPPLEPATTERN26,
D3DRENDERSTATE_STIPPLEPATTERN27,
D3DRENDERSTATE_STIPPLEPATTERN28,
D3DRENDERSTATE_STIPPLEPATTERN29,
D3DRENDERSTATE_STIPPLEPATTERN30,
D3DRENDERSTATE_STIPPLEPATTERN31,
D3DRENDERSTATE_INVALID_95,
D3DRENDERSTATE_INVALID_96,
D3DRENDERSTATE_INVALID_97,
D3DRENDERSTATE_INVALID_98,
D3DRENDERSTATE_INVALID_99,
D3DRENDERSTATE_INVALID_100,
D3DRENDERSTATE_INVALID_101,
D3DRENDERSTATE_INVALID_102,
D3DRENDERSTATE_INVALID_103,
D3DRENDERSTATE_INVALID_104,
D3DRENDERSTATE_INVALID_105,
D3DRENDERSTATE_INVALID_106,
D3DRENDERSTATE_INVALID_107,
D3DRENDERSTATE_INVALID_108,
D3DRENDERSTATE_INVALID_109,
D3DRENDERSTATE_INVALID_110,
D3DRENDERSTATE_INVALID_111,
D3DRENDERSTATE_INVALID_112,
D3DRENDERSTATE_INVALID_113,
D3DRENDERSTATE_INVALID_114,
D3DRENDERSTATE_INVALID_115,
D3DRENDERSTATE_INVALID_116,
D3DRENDERSTATE_INVALID_117,
D3DRENDERSTATE_INVALID_118,
D3DRENDERSTATE_INVALID_119,
D3DRENDERSTATE_INVALID_120,
D3DRENDERSTATE_INVALID_121,
D3DRENDERSTATE_INVALID_122,
D3DRENDERSTATE_INVALID_123,
D3DRENDERSTATE_INVALID_124,
D3DRENDERSTATE_INVALID_125,
D3DRENDERSTATE_INVALID_126,
D3DRENDERSTATE_INVALID_127,
//
// retired renderstates - not supported for DX7 interfaces
// 128 values [128, 255] are reserved for texture coordinate wrap flags.
// These are constructed with the D3DWRAP_U and D3DWRAP_V macros. Using
// a flags word preserves forward compatibility with texture coordinates
// that are >2D.
//
D3DRENDERSTATE_TEXTUREHANDLE = 1; (* Texture handle for legacy interfaces (Texture;Texture2) *)
D3DRENDERSTATE_TEXTUREADDRESS = 3; (* D3DTEXTUREADDRESS *)
D3DRENDERSTATE_WRAPU = 5; (* TRUE for wrapping in u *)
D3DRENDERSTATE_WRAPV = 6; (* TRUE for wrapping in v *)
D3DRENDERSTATE_MONOENABLE = 11; (* TRUE to enable mono rasterization *)
D3DRENDERSTATE_ROP2 = 12; (* ROP2 *)
D3DRENDERSTATE_PLANEMASK = 13; (* DWORD physical plane mask *)
D3DRENDERSTATE_TEXTUREMAG = 17; (* D3DTEXTUREFILTER *)
D3DRENDERSTATE_TEXTUREMIN = 18; (* D3DTEXTUREFILTER *)
D3DRENDERSTATE_TEXTUREMAPBLEND = 21; (* D3DTEXTUREBLEND *)
D3DRENDERSTATE_SUBPIXEL = 31; (* TRUE to enable subpixel correction *)
D3DRENDERSTATE_SUBPIXELX = 32; (* TRUE to enable correction in X only *)
D3DRENDERSTATE_STIPPLEENABLE = 39; (* TRUE to enable stippling *)
D3DRENDERSTATE_BORDERCOLOR = 43; (* Border color for texturing w/border *)
D3DRENDERSTATE_TEXTUREADDRESSU = 44; (* Texture addressing mode for U coordinate *)
D3DRENDERSTATE_TEXTUREADDRESSV = 45; (* Texture addressing mode for V coordinate *)
D3DRENDERSTATE_MIPMAPLODBIAS = 46; (* D3DVALUE Mipmap LOD bias *)
D3DRENDERSTATE_ANISOTROPY = 49; (* Max. anisotropy. 1 = no anisotropy *)
D3DRENDERSTATE_FLUSHBATCH = 50; (* Explicit flush for DP batching (DX5 Only) *)
D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT=51; (* BOOL enable sort-independent transparency *)
D3DRENDERSTATE_STIPPLEPATTERN00 = 64; (* Stipple pattern 01... *)
D3DRENDERSTATE_STIPPLEPATTERN01 = 65;
D3DRENDERSTATE_STIPPLEPATTERN02 = 66;
D3DRENDERSTATE_STIPPLEPATTERN03 = 67;
D3DRENDERSTATE_STIPPLEPATTERN04 = 68;
D3DRENDERSTATE_STIPPLEPATTERN05 = 69;
D3DRENDERSTATE_STIPPLEPATTERN06 = 70;
D3DRENDERSTATE_STIPPLEPATTERN07 = 71;
D3DRENDERSTATE_STIPPLEPATTERN08 = 72;
D3DRENDERSTATE_STIPPLEPATTERN09 = 73;
D3DRENDERSTATE_STIPPLEPATTERN10 = 74;
D3DRENDERSTATE_STIPPLEPATTERN11 = 75;
D3DRENDERSTATE_STIPPLEPATTERN12 = 76;
D3DRENDERSTATE_STIPPLEPATTERN13 = 77;
D3DRENDERSTATE_STIPPLEPATTERN14 = 78;
D3DRENDERSTATE_STIPPLEPATTERN15 = 79;
D3DRENDERSTATE_STIPPLEPATTERN16 = 80;
D3DRENDERSTATE_STIPPLEPATTERN17 = 81;
D3DRENDERSTATE_STIPPLEPATTERN18 = 82;
D3DRENDERSTATE_STIPPLEPATTERN19 = 83;
D3DRENDERSTATE_STIPPLEPATTERN20 = 84;
D3DRENDERSTATE_STIPPLEPATTERN21 = 85;
D3DRENDERSTATE_STIPPLEPATTERN22 = 86;
D3DRENDERSTATE_STIPPLEPATTERN23 = 87;
D3DRENDERSTATE_STIPPLEPATTERN24 = 88;
D3DRENDERSTATE_STIPPLEPATTERN25 = 89;
D3DRENDERSTATE_STIPPLEPATTERN26 = 90;
D3DRENDERSTATE_STIPPLEPATTERN27 = 91;
D3DRENDERSTATE_STIPPLEPATTERN28 = 92;
D3DRENDERSTATE_STIPPLEPATTERN29 = 93;
D3DRENDERSTATE_STIPPLEPATTERN30 = 94;
D3DRENDERSTATE_STIPPLEPATTERN31 = 95;
D3DRENDERSTATE_WRAP0, // wrap for 1st texture coord. set
D3DRENDERSTATE_WRAP1, // wrap for 2nd texture coord. set
D3DRENDERSTATE_WRAP2, // wrap for 3rd texture coord. set
D3DRENDERSTATE_WRAP3, // wrap for 4th texture coord. set
D3DRENDERSTATE_WRAP4, // wrap for 5th texture coord. set
D3DRENDERSTATE_WRAP5, // wrap for 6th texture coord. set
D3DRENDERSTATE_WRAP6, // wrap for 7th texture coord. set
D3DRENDERSTATE_WRAP7, // wrap for 8th texture coord. set
D3DRENDERSTATE_CLIPPING,
D3DRENDERSTATE_LIGHTING,
D3DRENDERSTATE_EXTENTS,
D3DRENDERSTATE_AMBIENT,
D3DRENDERSTATE_FOGVERTEXMODE,
D3DRENDERSTATE_COLORVERTEX,
D3DRENDERSTATE_LOCALVIEWER,
D3DRENDERSTATE_NORMALIZENORMALS,
D3DRENDERSTATE_COLORKEYBLENDENABLE,
D3DRENDERSTATE_DIFFUSEMATERIALSOURCE,
D3DRENDERSTATE_SPECULARMATERIALSOURCE,
D3DRENDERSTATE_AMBIENTMATERIALSOURCE,
D3DRENDERSTATE_EMISSIVEMATERIALSOURCE,
D3DRENDERSTATE_INVALID_149,
D3DRENDERSTATE_INVALID_150,
D3DRENDERSTATE_VERTEXBLEND,
D3DRENDERSTATE_CLIPPLANEENABLE
);
 
//
// retired renderstate names - the values are still used under new naming conventions
//
D3DRENDERSTATE_FOGTABLESTART = 36; (* Fog table start *)
D3DRENDERSTATE_FOGTABLEEND = 37; (* Fog table end *)
D3DRENDERSTATE_FOGTABLEDENSITY = 38; (* Fog table density *)
D3DRENDERSTATETYPE = TD3DRenderStateType;
 
type
// Values for material source
PD3DMateralColorSource = ^TD3DMateralColorSource;
TD3DMateralColorSource = (
TD3DMaterialColorSource = (
D3DMCS_MATERIAL, // Color from material is used
D3DMCS_COLOR1, // Diffuse vertex color is used
D3DMCS_COLOR2 // Specular vertex color is used
);
); // force 32-bit size enum
 
const
// For back-compatibility with legacy compilations
{ For back-compatibility with legacy compilations }
D3DRENDERSTATE_BLENDENABLE = D3DRENDERSTATE_ALPHABLENDENABLE;
D3DRENDERSTATE_FOGTABLESTART = D3DRENDERSTATE_FOGSTART;
D3DRENDERSTATE_FOGTABLEEND = D3DRENDERSTATE_FOGEND;
D3DRENDERSTATE_FOGTABLEDENSITY = D3DRENDERSTATE_FOGDENSITY;
 
{ Bias to apply to the texture coordinate set to apply a wrap to. }
D3DRENDERSTATE_WRAPBIAS = TD3DRenderStateType(128);
 
// Bias to apply to the texture coordinate set to apply a wrap to.
D3DRENDERSTATE_WRAPBIAS = 128;
 
(* Flags to construct the WRAP render states *)
{ Flags to construct the WRAP render states }
D3DWRAP_U = $00000001;
D3DWRAP_V = $00000002;
 
(* Flags to construct the WRAP render states for 1D thru 4D texture coordinates *)
{ Flags to construct the WRAP render states for 1D thru 4D texture coordinates }
D3DWRAPCOORD_0 = $00000001; // same as D3DWRAP_U
D3DWRAPCOORD_1 = $00000002; // same as D3DWRAP_V
D3DWRAPCOORD_2 = $00000004;
D3DWRAPCOORD_3 = $00000008;
 
function D3DRENDERSTATE_STIPPLEPATTERN(y: integer) : TD3DRenderStateType;
function D3DRENDERSTATE_STIPPLEPATTERN(y: DWORD): TD3DRenderStateType;
 
type
PD3DState = ^TD3DState;
TD3DState = packed record
 
TD3DState = record
case Integer of
0: (
dtstTransformStateType: TD3DTransformStateType;
dwArg: Array [ 0..0 ] of DWORD;
dwArg: array[0..0] of DWORD;
);
1: (
dlstLightStateType: TD3DLightStateType;
dvArg: Array [ 0..0 ] of TD3DValue;
dvArg: array[0..0] of TD3DValue;
);
2: (
drstRenderStateType: TD3DRenderStateType;
6815,39 → 3673,39
);
end;
 
(*
* Operation used to load matrices
* hDstMat = hSrcMat
*)
PD3DMatrixLoad = ^TD3DMatrixLoad;
TD3DMatrixLoad = packed record
hDestMatrix: TD3DMatrixHandle; (* Destination matrix *)
hSrcMatrix: TD3DMatrixHandle; (* Source matrix *)
D3DSTATE = TD3DState;
 
{ TD3DMatrixLoad structure }
 
TD3DMatrixLoad = record
hDestMatrix: TD3DMatrixHandle; // Destination matrix
hSrcMatrix: TD3DMatrixHandle; // Source matrix
end;
 
(*
* Operation used to multiply matrices
* hDstMat = hSrcMat1 * hSrcMat2
*)
PD3DMatrixMultiply = ^TD3DMatrixMultiply;
TD3DMatrixMultiply = packed record
hDestMatrix: TD3DMatrixHandle; (* Destination matrix *)
hSrcMatrix1: TD3DMatrixHandle; (* First source matrix *)
hSrcMatrix2: TD3DMatrixHandle; (* Second source matrix *)
D3DMATRIXLOAD = TD3DMatrixLoad;
 
{ TD3DMatrixMultiply structure }
 
TD3DMatrixMultiply = record
hDestMatrix: TD3DMatrixHandle; // Destination matrix
hSrcMatrix1: TD3DMatrixHandle; // First source matrix
hSrcMatrix2: TD3DMatrixHandle; // Second source matrix
end;
 
(*
* Operation used to transform and light vertices.
*)
PD3DProcessVertices = ^TD3DProcessVertices;
TD3DProcessVertices = packed record
dwFlags: DWORD; (* Do we transform or light or just copy? *)
wStart: WORD; (* Index to first vertex in source *)
wDest: WORD; (* Index to first vertex in local buffer *)
dwCount: DWORD; (* Number of vertices to be processed *)
dwReserved: DWORD; (* Must be zero *)
D3DMATRIXMULTIPLY = TD3DMatrixMultiply;
 
{ TD3DProcessVertices structure }
 
TD3DProcessVertices = record
dwFlags: DWORD; // Do we transform or light or just copy?
wStart: WORD; // Index to first vertex in source
wDest: WORD; // Index to first vertex in local buffer
dwCount: DWORD; // Number of vertices to be processed
dwReserved: DWORD; // Must be zero
end;
 
D3DPROCESSVERTICES = TD3DProcessVertices;
 
const
D3DPROCESSVERTICES_TRANSFORMLIGHT = $00000000;
D3DPROCESSVERTICES_TRANSFORM = $00000001;
6857,54 → 3715,52
D3DPROCESSVERTICES_UPDATEEXTENTS = $00000008;
D3DPROCESSVERTICES_NOCOLOR = $00000010;
 
{ TD3DTextureStagesStateType }
 
(*
* State enumerants for per-stage texture processing.
*)
type
PD3DTextureStageStateType = ^TD3DTextureStageStateType;
TD3DTextureStageStateType = DWORD;
TD3DTextureStagesStateType = (
D3DTSS_INVALID_0,
D3DTSS_COLOROP, // TD3DTextureOp - per-stage blending controls for color channels
D3DTSS_COLORARG1, // D3DTA_* (texture arg)
D3DTSS_COLORARG2, // D3DTA_* (texture arg)
D3DTSS_ALPHAOP, // TD3DTextureOp - per-stage blending controls for alpha channel
D3DTSS_ALPHAARG1, // D3DTA_* (texture arg)
D3DTSS_ALPHAARG2, // D3DTA_* (texture arg)
D3DTSS_BUMPENVMAT00, // TD3DValue (bump mapping matrix)
D3DTSS_BUMPENVMAT01, // TD3DValue (bump mapping matrix)
D3DTSS_BUMPENVMAT10, // TD3DValue (bump mapping matrix)
D3DTSS_BUMPENVMAT11, // TD3DValue (bump mapping matrix)
D3DTSS_TEXCOORDINDEX, // identifies which set of texture coordinates index this texture
D3DTSS_ADDRESS, // TD3DTextureAddress for both coordinates
D3DTSS_ADDRESSU, // TD3DTextureAddress for U coordinate
D3DTSS_ADDRESSV, // TD3DTextureAddress for V coordinate
D3DTSS_BORDERCOLOR, // TD3DColor
D3DTSS_MAGFILTER, // TD3DTextureMagFilter filter to use for magnification
D3DTSS_MINFILTER, // TD3DTextureMinFilter filter to use for minification
D3DTSS_MIPFILTER, // TD3DTextureMipFilter filter to use between mipmaps during minification
D3DTSS_MIPMAPLODBIAS, // D3DVALUE Mipmap LOD bias
D3DTSS_MAXMIPLEVEL, // DWORD 0..(n-1) LOD index of largest map to use (0 == largest)
D3DTSS_MAXANISOTROPY, // DWORD maximum anisotropy
D3DTSS_BUMPENVLSCALE, // TD3DValue scale for bump map luminance
D3DTSS_BUMPENVLOFFSET, // TD3DValue offset for bump map luminance
D3DTSS_TEXTURETRANSFORMFLAGS // D3DTEXTURETRANSFORMFLAGS controls texture transform
);
 
D3DTEXTURESTAGESTATETYPE = TD3DTextureStagesStateType;
 
const
D3DTSS_COLOROP = 1; (* D3DTEXTUREOP - per-stage blending controls for color channels *)
D3DTSS_COLORARG1 = 2; (* D3DTA_* (texture arg) *)
D3DTSS_COLORARG2 = 3; (* D3DTA_* (texture arg) *)
D3DTSS_ALPHAOP = 4; (* D3DTEXTUREOP - per-stage blending controls for alpha channel *)
D3DTSS_ALPHAARG1 = 5; (* D3DTA_* (texture arg) *)
D3DTSS_ALPHAARG2 = 6; (* D3DTA_* (texture arg) *)
D3DTSS_BUMPENVMAT00 = 7; (* D3DVALUE (bump mapping matrix) *)
D3DTSS_BUMPENVMAT01 = 8; (* D3DVALUE (bump mapping matrix) *)
D3DTSS_BUMPENVMAT10 = 9; (* D3DVALUE (bump mapping matrix) *)
D3DTSS_BUMPENVMAT11 = 10; (* D3DVALUE (bump mapping matrix) *)
D3DTSS_TEXCOORDINDEX = 11; (* identifies which set of texture coordinates index this texture *)
D3DTSS_ADDRESS = 12; (* D3DTEXTUREADDRESS for both coordinates *)
D3DTSS_ADDRESSU = 13; (* D3DTEXTUREADDRESS for U coordinate *)
D3DTSS_ADDRESSV = 14; (* D3DTEXTUREADDRESS for V coordinate *)
D3DTSS_BORDERCOLOR = 15; (* D3DCOLOR *)
D3DTSS_MAGFILTER = 16; (* D3DTEXTUREMAGFILTER filter to use for magnification *)
D3DTSS_MINFILTER = 17; (* D3DTEXTUREMINFILTER filter to use for minification *)
D3DTSS_MIPFILTER = 18; (* D3DTEXTUREMIPFILTER filter to use between mipmaps during minification *)
D3DTSS_MIPMAPLODBIAS = 19; (* D3DVALUE Mipmap LOD bias *)
D3DTSS_MAXMIPLEVEL = 20; (* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) *)
D3DTSS_MAXANISOTROPY = 21; (* DWORD maximum anisotropy *)
D3DTSS_BUMPENVLSCALE = 22; (* D3DVALUE scale for bump map luminance *)
D3DTSS_BUMPENVLOFFSET = 23; (* D3DVALUE offset for bump map luminance *)
D3DTSS_TEXTURETRANSFORMFLAGS = 24; (* D3DTEXTURETRANSFORMFLAGS controls texture transform *)
{ Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position }
{ and normal in the camera space) should be taken as texture coordinates }
{ Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from }
 
// Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position
// and normal in the camera space) should be taken as texture coordinates
// Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from
//
D3DTSS_TCI_PASSTHRU = $00000000;
D3DTSS_TCI_CAMERASPACENORMAL = $00010000;
D3DTSS_TCI_CAMERASPACEPOSITION = $00020000;
D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR = $00030000;
 
{ TD3DTextureOp }
 
type
(*
* Enumerations for COLOROP and ALPHAOP texture blending operations set in
* texture processing stage controls in D3DRENDERSTATE.
*)
PD3DTextureOp = ^TD3DTextureOp;
TD3DTextureOp = (
D3DTOP_INVALID_0,
// Control
6911,12 → 3767,10
D3DTOP_DISABLE , // disables stage
D3DTOP_SELECTARG1, // the default
D3DTOP_SELECTARG2,
 
// Modulate
D3DTOP_MODULATE , // multiply args together
D3DTOP_MODULATE2X, // multiply and 1 bit
D3DTOP_MODULATE4X, // multiply and 2 bits
 
// Add
D3DTOP_ADD , // add arguments together
D3DTOP_ADDSIGNED , // add with -0.5 bias
6925,7 → 3779,6
D3DTOP_ADDSMOOTH , // add 2 args, subtract product
// Arg1 + Arg2 - Arg1*Arg2
// = Arg1 + (1-Arg1)*Arg2
 
// Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
D3DTOP_BLENDDIFFUSEALPHA , // iterated alpha
D3DTOP_BLENDTEXTUREALPHA , // texture alpha
6933,7 → 3786,6
// Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
D3DTOP_BLENDTEXTUREALPHAPM, // texture alpha
D3DTOP_BLENDCURRENTALPHA , // by alpha of current color
 
// Specular mapping
D3DTOP_PREMODULATE , // modulate with next texture before use
D3DTOP_MODULATEALPHA_ADDCOLOR, // Arg1.RGB + Arg1.A*Arg2.RGB
6944,7 → 3796,6
// COLOROP only
D3DTOP_MODULATEINVCOLOR_ADDALPHA, // (1-Arg1.RGB)*Arg2.RGB + Arg1.A
// COLOROP only
 
// Bump mapping
D3DTOP_BUMPENVMAP , // per pixel env map perturbation
D3DTOP_BUMPENVMAPLUMINANCE, // with luminance channel
6956,10 → 3807,11
D3DTOP_DOTPRODUCT3
);
 
(*
* Values for COLORARG1,2 and ALPHAARG1,2 texture blending operations
* set in texture processing stage controls in D3DRENDERSTATE.
*)
D3DTEXTUREOP = TD3DTextureOp;
 
{ Values for COLORARG1,2 and ALPHAARG1,2 texture blending operations
set in texture processing stage controls in D3DRENDERSTATE. }
 
const
D3DTA_SELECTMASK = $0000000f; // mask for arg selector
D3DTA_DIFFUSE = $00000000; // select diffuse color
6970,11 → 3822,9
D3DTA_COMPLEMENT = $00000010; // take 1.0 - x
D3DTA_ALPHAREPLICATE = $00000020; // replicate alpha to color components
 
(*
* IDirect3DTexture2 State Filter Types
*)
{ IDirect3DTexture2 State Filter Types }
 
type
PD3DTextureMagFilter = ^TD3DTextureMagFilter;
TD3DTextureMagFilter = (
D3DTFG_INVALID_0,
D3DTFG_POINT , // nearest
6984,7 → 3834,8
D3DTFG_ANISOTROPIC
);
 
PD3DTextureMinFilter = ^TD3DTextureMinFilter;
D3DTEXTUREMAGFILTER = TD3DTextureMagFilter;
 
TD3DTextureMinFilter = (
D3DTFN_INVALID_0,
D3DTFN_POINT , // nearest
6992,7 → 3843,8
D3DTFN_ANISOTROPIC
);
 
PD3DTextureMipFilter = ^TD3DTextureMipFilter;
D3DTEXTUREMINFILTER = TD3DTextureMinFilter;
 
TD3DTextureMipFilter = (
D3DTFP_INVALID_0,
D3DTFP_NONE , // mipmapping disabled (use MAG filter)
7000,55 → 3852,37
D3DTFP_LINEAR // linear interpolation
);
 
D3DTEXTUREMIPFILTER = TD3DTextureMipFilter;
 
(*
* Triangle flags
*)
{ Triangle flags }
 
(*
* Tri strip and fan flags.
* START loads all three vertices
* EVEN and ODD load just v3 with even or odd culling
* START_FLAT contains a count from 0 to 29 that allows the
* whole strip or fan to be culled in one hit.
* e.g. for a quad len = 1
*)
const
D3DTRIFLAG_START = $00000000;
// #define D3DTRIFLAG_STARTFLAT(len) (len) (* 0 < len < 30 *)
D3DTRIFLAG_ODD = $0000001e;
D3DTRIFLAG_EVEN = $0000001f;
 
function D3DTRIFLAG_STARTFLAT(len: DWORD) : DWORD;
 
{ Triangle edge flags }
 
const
D3DTRIFLAG_ODD = $0000001e;
D3DTRIFLAG_EVEN = $0000001f;
D3DTRIFLAG_EDGEENABLE1 = $00000100; // v0-v1 edge
D3DTRIFLAG_EDGEENABLE2 = $00000200; // v1-v2 edge
D3DTRIFLAG_EDGEENABLE3 = $00000400; // v2-v0 edge
D3DTRIFLAG_EDGEENABLETRIANGLE =
D3DTRIFLAG_EDGEENABLE1 or D3DTRIFLAG_EDGEENABLE2 or D3DTRIFLAG_EDGEENABLE3;
 
(*
* Triangle edge flags
* enable edges for wireframe or antialiasing
*)
D3DTRIFLAG_EDGEENABLE1 = $00000100; (* v0-v1 edge *)
D3DTRIFLAG_EDGEENABLE2 = $00000200; (* v1-v2 edge *)
D3DTRIFLAG_EDGEENABLE3 = $00000400; (* v2-v0 edge *)
D3DTRIFLAG_EDGEENABLETRIANGLE = (
D3DTRIFLAG_EDGEENABLE1 or D3DTRIFLAG_EDGEENABLE2 or D3DTRIFLAG_EDGEENABLE3);
{ TD3DTriangle structure }
 
(*
* Primitive structures and related defines. Vertex offsets are to types
* TD3DVertex, TD3DLVertex, or TD3DTLVertex.
*)
 
(*
* Triangle list primitive structure
*)
type
PD3DTriangle = ^TD3DTriangle;
TD3DTriangle = packed record
TD3DTriangle = record
case Integer of
0: (
v1: WORD; (* Vertex indices *)
v1: WORD; // Vertex indices
v2: WORD;
v3: WORD;
wFlags: WORD; (* Edge (and other) flags *)
wFlags: WORD; // Edge (and other) flags
);
1: (
wV1: WORD;
7057,15 → 3891,16
);
end;
 
(*
* Line strip structure.
* The instruction count - 1 defines the number of line segments.
*)
D3DTRIANGLE = TD3DTriangle;
LPD3DTRIANGLE = PD3DTriangle;
 
{ TD3DLine structure }
 
PD3DLine = ^TD3DLine;
TD3DLine = packed record
TD3DLine = record
case Integer of
0: (
v1: WORD; (* Vertex indices *)
v1: WORD; // Vertex indices
v2: WORD;
);
1: (
7074,77 → 3909,86
);
end;
 
(*
* Span structure
* Spans join a list of points with the same y value.
* If the y value changes, a new span is started.
*)
D3DLINE = TD3DLine;
LPD3DLINE = PD3DLine;
 
{ TD3DSpan structure }
 
PD3DSpan = ^TD3DSpan;
TD3DSpan = packed record
wCount: WORD; (* Number of spans *)
wFirst: WORD; (* Index to first vertex *)
TD3DSpan = record
wCount: WORD; // Number of spans
wFirst: WORD; // Index to first vertex
end;
 
(*
* Point structure
*)
D3DSPAN = TD3DSpan;
LPD3DSPAN = PD3DSpan;
 
{ TD3DPoint structure }
 
PD3DPoint = ^TD3DPoint;
TD3DPoint = packed record
wCount: WORD; (* number of points *)
wFirst: WORD; (* index to first vertex *)
TD3DPoint = record
wCount: WORD; // number of points
wFirst: WORD; // index to first vertex
end;
 
(*
* Forward branch structure.
* Mask is logically anded with the driver status mask
* if the result equals 'value', the branch is taken.
*)
D3DPOINT = TD3DPoint;
LPD3DPOINT = PD3DPoint;
 
{ TD3DBranch structure }
 
PD3DBranch = ^TD3DBranch;
TD3DBranch = packed record
dwMask: DWORD; (* Bitmask against D3D status *)
TD3DBranch = record
dwMask: DWORD; // Bitmask against D3D status
dwValue: DWORD;
bNegate: BOOL; (* TRUE to negate comparison *)
dwOffset: DWORD; (* How far to branch forward (0 for exit)*)
bNegate: BOOL; // TRUE to negate comparison
dwOffset: DWORD; // How far to branch forward (0 for exit)
end;
 
(*
* Status used for set status instruction.
* The D3D status is initialised on device creation
* and is modified by all execute calls.
*)
D3DBRANCH = TD3DBranch;
LPD3DBRANCH = PD3DBranch;
 
{ TD3DStatus structure }
 
PD3DStatus = ^TD3DStatus;
TD3DStatus = packed record
dwFlags: DWORD; (* Do we set extents or status *)
dwStatus: DWORD; (* D3D status *)
TD3DStatus = record
dwFlags: DWORD; // Do we set extents or status
dwStatus: DWORD; // D3D status
drExtent: TD3DRect;
end;
 
D3DSTATUS = TD3DStatus;
LPD3DSTATUS = PD3DStatus;
 
const
D3DSETSTATUS_STATUS = $00000001;
D3DSETSTATUS_EXTENTS = $00000002;
D3DSETSTATUS_ALL = (D3DSETSTATUS_STATUS or D3DSETSTATUS_EXTENTS);
D3DSETSTATUS_ALL = D3DSETSTATUS_STATUS or D3DSETSTATUS_EXTENTS;
 
{ TD3DClipStatus structure }
 
type
PD3DClipStatus = ^TD3DClipStatus;
TD3DClipStatus = packed record
dwFlags : DWORD; (* Do we set 2d extents, 3D extents or status *)
dwStatus : DWORD; (* Clip status *)
minx, maxx : float; (* X extents *)
miny, maxy : float; (* Y extents *)
minz, maxz : float; (* Z extents *)
TD3DClipStatus = record
dwFlags: DWORD; // Do we set 2d extents, 3D extents or status
dwStatus: DWORD; // Clip status
minx, maxx: Single; // X extents
miny, maxy: Single; // Y extents
minz, maxz: Single; // Z extents
end;
 
D3DCLIPSTATUS = TD3DClipStatus;
LPD3DCLIPSTATUS = PD3DClipStatus;
 
const
D3DCLIPSTATUS_STATUS = $00000001;
D3DCLIPSTATUS_EXTENTS2 = $00000002;
D3DCLIPSTATUS_EXTENTS3 = $00000004;
 
(*
* Statistics structure
*)
{ TD3DStats structure }
 
type
PD3DStats = ^TD3DStats;
TD3DStats = packed record
TD3DStats = record
dwSize: DWORD;
dwTrianglesDrawn: DWORD;
dwLinesDrawn: DWORD;
7153,18 → 3997,20
dwVerticesProcessed: DWORD;
end;
 
(*
* Execute options.
* When calling using D3DEXECUTE_UNCLIPPED all the primitives
* inside the buffer must be contained within the viewport.
*)
D3DSTATS = TD3DStats;
LPD3DSTATS = PD3DStats;
 
{ Execute options. }
 
const
D3DEXECUTE_CLIPPED = $00000001;
D3DEXECUTE_UNCLIPPED = $00000002;
 
{ TD3DExecuteData structure }
 
type
PD3DExecuteData = ^TD3DExecuteData;
TD3DExecuteData = packed record
TD3DExecuteData = record
dwSize: DWORD;
dwVertexOffset: DWORD;
dwVertexCount: DWORD;
7171,23 → 4017,24
dwInstructionOffset: DWORD;
dwInstructionLength: DWORD;
dwHVertexOffset: DWORD;
dsStatus: TD3DStatus; (* Status after execute *)
dsStatus: D3DSTATUS; // Status after execute
end;
 
(*
* Palette flags.
* This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
*)
D3DEXECUTEDATA = TD3DExecuteData;
LPD3DEXECUTEDATA = PD3DExecuteData;
 
{ Palette flags. }
 
const
D3DPAL_FREE = $00; (* Renderer may use this entry freely *)
D3DPAL_READONLY = $40; (* Renderer may not set this entry *)
D3DPAL_RESERVED = $80; (* Renderer may not use this entry *)
D3DPAL_FREE = $00; // Renderer may use this entry freely
D3DPAL_READONLY = $40; // Renderer may not set this entry
D3DPAL_RESERVED = $80; // Renderer may not use this entry
 
{ TD3DVertexBufferDesc structure }
 
type
PD3DVertexBufferDesc = ^TD3DVertexBufferDesc;
TD3DVertexBufferDesc = packed record
TD3DVertexBufferDesc = record
dwSize : DWORD;
dwCaps : DWORD;
dwFVF : DWORD;
7194,35 → 4041,36
dwNumVertices : DWORD;
end;
 
D3DVERTEXBUFFERDESC = TD3DVertexBufferDesc;
LPD3DVERTEXBUFFERDESC = PD3DVertexBufferDesc;
 
{ These correspond to DDSCAPS_* flags }
 
const
(* These correspond to DDSCAPS_* flags *)
D3DVBCAPS_SYSTEMMEMORY = $00000800;
D3DVBCAPS_WRITEONLY = $00010000;
D3DVBCAPS_OPTIMIZED = $80000000;
D3DVBCAPS_DONOTCLIP = $00000001;
 
(* Vertex Operations for ProcessVertices *)
D3DVOP_LIGHT = (1 shl 10);
D3DVOP_TRANSFORM = (1 shl 0);
D3DVOP_CLIP = (1 shl 2);
D3DVOP_EXTENTS = (1 shl 3);
{ Vertex Operations for ProcessVertices }
 
(* The maximum number of vertices user can pass to any d3d
drawing function or to create vertex buffer with
*)
D3DMAXNUMVERTICES = ((1 shl 16) - 1);
(* The maximum number of primitives user can pass to any d3d
drawing function.
*)
D3DMAXNUMPRIMITIVES = ((1 shl 16) - 1);
D3DVOP_LIGHT = 1 shl 10;
D3DVOP_TRANSFORM = 1 shl 0;
D3DVOP_CLIP = 1 shl 2;
D3DVOP_EXTENTS = 1 shl 3;
 
(* Bits for dwFlags in ProcessVertices call *)
D3DPV_DONOTCOPYDATA = (1 shl 0);
{ The maximum number of vertices user can pass to any d3d
drawing function or to create vertex buffer with }
D3DMAXNUMVERTICES = (1 shl 16)-1;
 
//-------------------------------------------------------------------
{ The maximum number of primitives user can pass to any d3d drawing function. }
D3DMAXNUMPRIMITIVES = (1 shl 16)-1;
 
// Flexible vertex format bits
//
{ Bits for dwFlags in ProcessVertices call }
D3DPV_DONOTCOPYDATA = 1 shl 0;
 
{ Flexible vertex format bits }
 
D3DFVF_RESERVED0 = $001;
D3DFVF_POSITION_MASK = $00E;
D3DFVF_XYZ = $002;
7232,12 → 4080,10
D3DFVF_XYZB3 = $00a;
D3DFVF_XYZB4 = $00c;
D3DFVF_XYZB5 = $00e;
 
D3DFVF_NORMAL = $010;
D3DFVF_RESERVED1 = $020;
D3DFVF_DIFFUSE = $040;
D3DFVF_SPECULAR = $080;
 
D3DFVF_TEXCOUNT_MASK = $f00;
D3DFVF_TEXCOUNT_SHIFT = 8;
D3DFVF_TEX0 = $000;
7250,27 → 4096,30
D3DFVF_TEX7 = $700;
D3DFVF_TEX8 = $800;
 
D3DFVF_RESERVED2 = $f000; // 4 reserved bits
D3DFVF_RESERVED2 = $F000; // 4 reserved bits
 
D3DFVF_VERTEX = ( D3DFVF_XYZ or D3DFVF_NORMAL or D3DFVF_TEX1 );
D3DFVF_LVERTEX = ( D3DFVF_XYZ or D3DFVF_RESERVED1 or D3DFVF_DIFFUSE or
D3DFVF_SPECULAR or D3DFVF_TEX1 );
D3DFVF_TLVERTEX = ( D3DFVF_XYZRHW or D3DFVF_DIFFUSE or D3DFVF_SPECULAR or
D3DFVF_TEX1 );
D3DFVF_VERTEX = D3DFVF_XYZ or D3DFVF_NORMAL or D3DFVF_TEX1;
D3DFVF_LVERTEX = D3DFVF_XYZ or D3DFVF_RESERVED1 or D3DFVF_DIFFUSE or
D3DFVF_SPECULAR or D3DFVF_TEX1;
D3DFVF_TLVERTEX = D3DFVF_XYZRHW or D3DFVF_DIFFUSE or D3DFVF_SPECULAR or
D3DFVF_TEX1;
 
{ TD3DDP_PtrStride }
 
type
PD3DDP_PtrStride = ^TD3DDP_PtrStride;
TD3DDP_PtrStride = packed record
lpvData : pointer;
TD3DDP_PtrStride = record
lpvData: Pointer;
dwStride : DWORD;
end;
 
D3DDP_PTRSTRIDE = TD3DDP_PtrStride;
 
const
D3DDP_MAXTEXCOORD = 8;
 
type
PD3DDrawPrimitiveStridedData = ^TD3DDrawPrimitiveStridedData;
TD3DDrawPrimitiveStridedData = packed record
TD3DDrawPrimitiveStridedData = record
position : TD3DDP_PtrStride;
normal : TD3DDP_PtrStride;
diffuse : TD3DDP_PtrStride;
7278,57 → 4127,62
textureCoords : array [0..D3DDP_MAXTEXCOORD-1] of TD3DDP_PtrStride;
end;
 
//---------------------------------------------------------------------
// ComputeSphereVisibility return values
//
D3DDRAWPRIMITIVESTRIDEDDATA = TD3DDrawPrimitiveStridedData;
LPD3DDRAWPRIMITIVESTRIDEDDATA = PD3DDrawPrimitiveStridedData;
 
{ ComputeSphereVisibility return values }
 
const
D3DVIS_INSIDE_FRUSTUM = 0;
D3DVIS_INTERSECT_FRUSTUM = 1;
D3DVIS_OUTSIDE_FRUSTUM = 2;
D3DVIS_INSIDE_LEFT = 0;
D3DVIS_INTERSECT_LEFT = (1 shl 2);
D3DVIS_OUTSIDE_LEFT = (2 shl 2);
D3DVIS_INTERSECT_LEFT = 1 shl 2;
D3DVIS_OUTSIDE_LEFT = 2 shl 2;
D3DVIS_INSIDE_RIGHT = 0;
D3DVIS_INTERSECT_RIGHT = (1 shl 4);
D3DVIS_OUTSIDE_RIGHT = (2 shl 4);
D3DVIS_INTERSECT_RIGHT = 1 shl 4;
D3DVIS_OUTSIDE_RIGHT = 2 shl 4;
D3DVIS_INSIDE_TOP = 0;
D3DVIS_INTERSECT_TOP = (1 shl 6);
D3DVIS_OUTSIDE_TOP = (2 shl 6);
D3DVIS_INTERSECT_TOP = 1 shl 6;
D3DVIS_OUTSIDE_TOP = 2 shl 6;
D3DVIS_INSIDE_BOTTOM = 0;
D3DVIS_INTERSECT_BOTTOM = (1 shl 8);
D3DVIS_OUTSIDE_BOTTOM = (2 shl 8);
D3DVIS_INTERSECT_BOTTOM = 1 shl 8;
D3DVIS_OUTSIDE_BOTTOM = 2 shl 8;
D3DVIS_INSIDE_NEAR = 0;
D3DVIS_INTERSECT_NEAR = (1 shl 10);
D3DVIS_OUTSIDE_NEAR = (2 shl 10);
D3DVIS_INTERSECT_NEAR = 1 shl 10;
D3DVIS_OUTSIDE_NEAR = 2 shl 10;
D3DVIS_INSIDE_FAR = 0;
D3DVIS_INTERSECT_FAR = (1 shl 12);
D3DVIS_OUTSIDE_FAR = (2 shl 12);
D3DVIS_INTERSECT_FAR = 1 shl 12;
D3DVIS_OUTSIDE_FAR = 2 shl 12;
 
D3DVIS_MASK_FRUSTUM = (3 shl 0);
D3DVIS_MASK_LEFT = (3 shl 2);
D3DVIS_MASK_RIGHT = (3 shl 4);
D3DVIS_MASK_TOP = (3 shl 6);
D3DVIS_MASK_BOTTOM = (3 shl 8);
D3DVIS_MASK_NEAR = (3 shl 10);
D3DVIS_MASK_FAR = (3 shl 12);
D3DVIS_MASK_FRUSTUM = 3 shl 0;
D3DVIS_MASK_LEFT = 3 shl 2;
D3DVIS_MASK_RIGHT = 3 shl 4;
D3DVIS_MASK_TOP = 3 shl 6;
D3DVIS_MASK_BOTTOM = 3 shl 8;
D3DVIS_MASK_NEAR = 3 shl 10;
D3DVIS_MASK_FAR = 3 shl 12;
 
// To be used with GetInfo()
{ To be used with GetInfo() }
 
D3DDEVINFOID_TEXTUREMANAGER = 1;
D3DDEVINFOID_D3DTEXTUREMANAGER = 2;
D3DDEVINFOID_TEXTURING = 3;
 
type
PD3DStateBlockType = ^TD3DStateBlockType;
 
{ TD3DStateBlockType }
 
TD3DStateBlockType = (
D3DSBT_INVALID_0 ,
D3DSBT_ALL , // capture all state
D3DBST_INVALID_0,
D3DSBT_PIXELSTATE , // capture pixel state
D3DSBT_VERTEXSTATE // capture vertex state
);
 
// The D3DVERTEXBLENDFLAGS type is used with D3DRENDERSTATE_VERTEXBLEND state.
//
PD3DVertexBlendFlags = ^TD3DVertexBlendFlags;
D3DSTATEBLOCKTYPE = TD3DStateBlockType;
 
{ TD3DVertexBlendFlags }
 
TD3DVertexBlendFlags = (
D3DVBLEND_DISABLE , // Disable vertex blending
D3DVBLEND_1WEIGHT , // blend between 2 matrices
7336,20 → 4190,273
D3DVBLEND_3WEIGHTS // blend between 4 matrices
);
 
PD3DTextureTransformFlags = ^TD3DTextureTransformFlags;
D3DVERTEXBLENDFLAGS = TD3DVertexBlendFlags;
 
{ TD3DTextureTransformFlags }
 
TD3DTextureTransformFlags = (
D3DTTFF_DISABLE , // texture coordinates are passed directly
D3DTTFF_COUNT1 , // rasterizer should expect 1-D texture coords
D3DTTFF_COUNT2 , // rasterizer should expect 2-D texture coords
D3DTTFF_COUNT3 , // rasterizer should expect 3-D texture coords
D3DTTFF_COUNT4 // rasterizer should expect 4-D texture coords
D3DTTFF_COUNT4, // rasterizer should expect 4-D texture coords
D3DTIFF_INVALID_5,
D3DTIFF_INVALID_6,
D3DTIFF_INVALID_7,
D3DTIFF_INVALID_8,
D3DTIFF_INVALID_9,
D3DTIFF_INVALID_10,
D3DTIFF_INVALID_11,
D3DTIFF_INVALID_12,
D3DTIFF_INVALID_13,
D3DTIFF_INVALID_14,
D3DTIFF_INVALID_15,
D3DTIFF_INVALID_16,
D3DTIFF_INVALID_17,
D3DTIFF_INVALID_18,
D3DTIFF_INVALID_19,
D3DTIFF_INVALID_20,
D3DTIFF_INVALID_21,
D3DTIFF_INVALID_22,
D3DTIFF_INVALID_23,
D3DTIFF_INVALID_24,
D3DTIFF_INVALID_25,
D3DTIFF_INVALID_26,
D3DTIFF_INVALID_27,
D3DTIFF_INVALID_28,
D3DTIFF_INVALID_29,
D3DTIFF_INVALID_30,
D3DTIFF_INVALID_31,
D3DTIFF_INVALID_32,
D3DTIFF_INVALID_33,
D3DTIFF_INVALID_34,
D3DTIFF_INVALID_35,
D3DTIFF_INVALID_36,
D3DTIFF_INVALID_37,
D3DTIFF_INVALID_38,
D3DTIFF_INVALID_39,
D3DTIFF_INVALID_40,
D3DTIFF_INVALID_41,
D3DTIFF_INVALID_42,
D3DTIFF_INVALID_43,
D3DTIFF_INVALID_44,
D3DTIFF_INVALID_45,
D3DTIFF_INVALID_46,
D3DTIFF_INVALID_47,
D3DTIFF_INVALID_48,
D3DTIFF_INVALID_49,
D3DTIFF_INVALID_50,
D3DTIFF_INVALID_51,
D3DTIFF_INVALID_52,
D3DTIFF_INVALID_53,
D3DTIFF_INVALID_54,
D3DTIFF_INVALID_55,
D3DTIFF_INVALID_56,
D3DTIFF_INVALID_57,
D3DTIFF_INVALID_58,
D3DTIFF_INVALID_59,
D3DTIFF_INVALID_60,
D3DTIFF_INVALID_61,
D3DTIFF_INVALID_62,
D3DTIFF_INVALID_63,
D3DTIFF_INVALID_64,
D3DTIFF_INVALID_65,
D3DTIFF_INVALID_66,
D3DTIFF_INVALID_67,
D3DTIFF_INVALID_68,
D3DTIFF_INVALID_69,
D3DTIFF_INVALID_70,
D3DTIFF_INVALID_71,
D3DTIFF_INVALID_72,
D3DTIFF_INVALID_73,
D3DTIFF_INVALID_74,
D3DTIFF_INVALID_75,
D3DTIFF_INVALID_76,
D3DTIFF_INVALID_77,
D3DTIFF_INVALID_78,
D3DTIFF_INVALID_79,
D3DTIFF_INVALID_80,
D3DTIFF_INVALID_81,
D3DTIFF_INVALID_82,
D3DTIFF_INVALID_83,
D3DTIFF_INVALID_84,
D3DTIFF_INVALID_85,
D3DTIFF_INVALID_86,
D3DTIFF_INVALID_87,
D3DTIFF_INVALID_88,
D3DTIFF_INVALID_89,
D3DTIFF_INVALID_90,
D3DTIFF_INVALID_91,
D3DTIFF_INVALID_92,
D3DTIFF_INVALID_93,
D3DTIFF_INVALID_94,
D3DTIFF_INVALID_95,
D3DTIFF_INVALID_96,
D3DTIFF_INVALID_97,
D3DTIFF_INVALID_98,
D3DTIFF_INVALID_99,
D3DTIFF_INVALID_100,
D3DTIFF_INVALID_101,
D3DTIFF_INVALID_102,
D3DTIFF_INVALID_103,
D3DTIFF_INVALID_104,
D3DTIFF_INVALID_105,
D3DTIFF_INVALID_106,
D3DTIFF_INVALID_107,
D3DTIFF_INVALID_108,
D3DTIFF_INVALID_109,
D3DTIFF_INVALID_110,
D3DTIFF_INVALID_111,
D3DTIFF_INVALID_112,
D3DTIFF_INVALID_113,
D3DTIFF_INVALID_114,
D3DTIFF_INVALID_115,
D3DTIFF_INVALID_116,
D3DTIFF_INVALID_117,
D3DTIFF_INVALID_118,
D3DTIFF_INVALID_119,
D3DTIFF_INVALID_120,
D3DTIFF_INVALID_121,
D3DTIFF_INVALID_122,
D3DTIFF_INVALID_123,
D3DTIFF_INVALID_124,
D3DTIFF_INVALID_125,
D3DTIFF_INVALID_126,
D3DTIFF_INVALID_127,
D3DTIFF_INVALID_128,
D3DTIFF_INVALID_129,
D3DTIFF_INVALID_130,
D3DTIFF_INVALID_131,
D3DTIFF_INVALID_132,
D3DTIFF_INVALID_133,
D3DTIFF_INVALID_134,
D3DTIFF_INVALID_135,
D3DTIFF_INVALID_136,
D3DTIFF_INVALID_137,
D3DTIFF_INVALID_138,
D3DTIFF_INVALID_139,
D3DTIFF_INVALID_140,
D3DTIFF_INVALID_141,
D3DTIFF_INVALID_142,
D3DTIFF_INVALID_143,
D3DTIFF_INVALID_144,
D3DTIFF_INVALID_145,
D3DTIFF_INVALID_146,
D3DTIFF_INVALID_147,
D3DTIFF_INVALID_148,
D3DTIFF_INVALID_149,
D3DTIFF_INVALID_150,
D3DTIFF_INVALID_151,
D3DTIFF_INVALID_152,
D3DTIFF_INVALID_153,
D3DTIFF_INVALID_154,
D3DTIFF_INVALID_155,
D3DTIFF_INVALID_156,
D3DTIFF_INVALID_157,
D3DTIFF_INVALID_158,
D3DTIFF_INVALID_159,
D3DTIFF_INVALID_160,
D3DTIFF_INVALID_161,
D3DTIFF_INVALID_162,
D3DTIFF_INVALID_163,
D3DTIFF_INVALID_164,
D3DTIFF_INVALID_165,
D3DTIFF_INVALID_166,
D3DTIFF_INVALID_167,
D3DTIFF_INVALID_168,
D3DTIFF_INVALID_169,
D3DTIFF_INVALID_170,
D3DTIFF_INVALID_171,
D3DTIFF_INVALID_172,
D3DTIFF_INVALID_173,
D3DTIFF_INVALID_174,
D3DTIFF_INVALID_175,
D3DTIFF_INVALID_176,
D3DTIFF_INVALID_177,
D3DTIFF_INVALID_178,
D3DTIFF_INVALID_179,
D3DTIFF_INVALID_180,
D3DTIFF_INVALID_181,
D3DTIFF_INVALID_182,
D3DTIFF_INVALID_183,
D3DTIFF_INVALID_184,
D3DTIFF_INVALID_185,
D3DTIFF_INVALID_186,
D3DTIFF_INVALID_187,
D3DTIFF_INVALID_188,
D3DTIFF_INVALID_189,
D3DTIFF_INVALID_190,
D3DTIFF_INVALID_191,
D3DTIFF_INVALID_192,
D3DTIFF_INVALID_193,
D3DTIFF_INVALID_194,
D3DTIFF_INVALID_195,
D3DTIFF_INVALID_196,
D3DTIFF_INVALID_197,
D3DTIFF_INVALID_198,
D3DTIFF_INVALID_199,
D3DTIFF_INVALID_200,
D3DTIFF_INVALID_201,
D3DTIFF_INVALID_202,
D3DTIFF_INVALID_203,
D3DTIFF_INVALID_204,
D3DTIFF_INVALID_205,
D3DTIFF_INVALID_206,
D3DTIFF_INVALID_207,
D3DTIFF_INVALID_208,
D3DTIFF_INVALID_209,
D3DTIFF_INVALID_210,
D3DTIFF_INVALID_211,
D3DTIFF_INVALID_212,
D3DTIFF_INVALID_213,
D3DTIFF_INVALID_214,
D3DTIFF_INVALID_215,
D3DTIFF_INVALID_216,
D3DTIFF_INVALID_217,
D3DTIFF_INVALID_218,
D3DTIFF_INVALID_219,
D3DTIFF_INVALID_220,
D3DTIFF_INVALID_221,
D3DTIFF_INVALID_222,
D3DTIFF_INVALID_223,
D3DTIFF_INVALID_224,
D3DTIFF_INVALID_225,
D3DTIFF_INVALID_226,
D3DTIFF_INVALID_227,
D3DTIFF_INVALID_228,
D3DTIFF_INVALID_229,
D3DTIFF_INVALID_230,
D3DTIFF_INVALID_231,
D3DTIFF_INVALID_232,
D3DTIFF_INVALID_233,
D3DTIFF_INVALID_234,
D3DTIFF_INVALID_235,
D3DTIFF_INVALID_236,
D3DTIFF_INVALID_237,
D3DTIFF_INVALID_238,
D3DTIFF_INVALID_239,
D3DTIFF_INVALID_240,
D3DTIFF_INVALID_241,
D3DTIFF_INVALID_242,
D3DTIFF_INVALID_243,
D3DTIFF_INVALID_244,
D3DTIFF_INVALID_245,
D3DTIFF_INVALID_246,
D3DTIFF_INVALID_247,
D3DTIFF_INVALID_248,
D3DTIFF_INVALID_249,
D3DTIFF_INVALID_250,
D3DTIFF_INVALID_251,
D3DTIFF_INVALID_252,
D3DTIFF_INVALID_253,
D3DTIFF_INVALID_254,
D3DTIFF_INVALID_255,
D3DTTFF_PROJECTED // texcoords to be divided by COUNTth element
);
 
{ Macros to set texture coordinate format bits in the FVF id }
 
const
D3DTTFF_PROJECTED = TD3DTextureTransformFlags(256); // texcoords to be divided by COUNTth element
 
// Macros to set texture coordinate format bits in the FVF id
 
D3DFVF_TEXTUREFORMAT2 = 0; // Two floating point values
D3DFVF_TEXTUREFORMAT1 = 3; // One floating point value
D3DFVF_TEXTUREFORMAT3 = 1; // Three floating point values
7362,6 → 4469,7
 
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: d3dcaps.h
* Content: Direct3D capabilities include file
7368,46 → 4476,52
*
***************************************************************************)
 
(* Description of capabilities of transform *)
{ Description of capabilities of transform }
 
type
PD3DTransformCaps = ^TD3DTransformCaps;
TD3DTransformCaps = packed record
TD3DTransformCaps = record
dwSize: DWORD;
dwCaps: DWORD;
end;
 
D3DTRANSFORMCAPS = TD3DTransformCaps;
LPD3DTRANSFORMCAPS = PD3DTransformCaps;
 
const
D3DTRANSFORMCAPS_CLIP = $00000001; (* Will clip whilst transforming *)
D3DTRANSFORMCAPS_CLIP = $00000001; // Will clip whilst transforming
 
(* Description of capabilities of lighting *)
{ Description of capabilities of lighting }
 
type
PD3DLightingCaps = ^TD3DLightingCaps;
TD3DLightingCaps = packed record
TD3DLightingCaps = record
dwSize: DWORD;
dwCaps: DWORD; (* Lighting caps *)
dwLightingModel: DWORD; (* Lighting model - RGB or mono *)
dwNumLights: DWORD; (* Number of lights that can be handled *)
dwCaps: DWORD; // Lighting caps
dwLightingModel: DWORD; // Lighting model - RGB or mono
dwNumLights: DWORD; // Number of lights that can be handled
end;
 
D3DLIGHTINGCAPS = TD3DLightingCaps;
LPD3DLIGHTINGCAPS = PD3DLightingCaps;
 
const
D3DLIGHTINGMODEL_RGB = $00000001;
D3DLIGHTINGMODEL_MONO = $00000002;
 
D3DLIGHTCAPS_POINT = $00000001; (* Point lights supported *)
D3DLIGHTCAPS_SPOT = $00000002; (* Spot lights supported *)
D3DLIGHTCAPS_DIRECTIONAL = $00000004; (* Directional lights supported *)
D3DLIGHTCAPS_PARALLELPOINT = $00000008; (* Parallel point lights supported *)
D3DLIGHTCAPS_GLSPOT = $00000010; (* GL syle spot lights supported *)
D3DLIGHTCAPS_POINT = $00000001; // Point lights supported
D3DLIGHTCAPS_SPOT = $00000002; // Spot lights supported
D3DLIGHTCAPS_DIRECTIONAL = $00000004; // Directional lights supported
D3DLIGHTCAPS_PARALLELPOINT = $00000008; // Parallel point lights supported
D3DLIGHTCAPS_GLSPOT = $00000010; // GL syle spot lights supported
 
(* Description of capabilities for each primitive type *)
{ Description of capabilities for each primitive type }
 
type
PD3DPrimCaps = ^TD3DPrimCaps;
TD3DPrimCaps = packed record
TD3DPrimCaps = record
dwSize: DWORD;
dwMiscCaps: DWORD; (* Capability flags *)
dwMiscCaps: DWORD; // Capability flags
dwRasterCaps: DWORD;
dwZCmpCaps: DWORD;
dwSrcBlendCaps: DWORD;
7418,13 → 4532,16
dwTextureFilterCaps: DWORD;
dwTextureBlendCaps: DWORD;
dwTextureAddressCaps: DWORD;
dwStippleWidth: DWORD; (* maximum width and height of *)
dwStippleHeight: DWORD; (* of supported stipple (up to 32x32) *)
dwStippleWidth: DWORD; // maximum width and height of
dwStippleHeight: DWORD; // of supported stipple (up to 32x32)
end;
 
D3DPRIMCAPS = TD3DPrimCaps;
LPD3DPRIMCAPS = PD3DPrimCaps;
 
{ TD3DPrimCaps dwMiscCaps }
 
const
(* TD3DPrimCaps dwMiscCaps *)
 
D3DPMISCCAPS_MASKPLANES = $00000001;
D3DPMISCCAPS_MASKZ = $00000002;
D3DPMISCCAPS_LINEPATTERNREP = $00000004;
7433,7 → 4550,7
D3DPMISCCAPS_CULLCW = $00000020;
D3DPMISCCAPS_CULLCCW = $00000040;
 
(* TD3DPrimCaps dwRasterCaps *)
{ TD3DPrimCaps dwRasterCaps }
 
D3DPRASTERCAPS_DITHER = $00000001;
D3DPRASTERCAPS_ROP2 = $00000002;
7458,9 → 4575,8
D3DPRASTERCAPS_WFOG = $00100000;
D3DPRASTERCAPS_ZFOG = $00200000;
 
(* TD3DPrimCaps dwZCmpCaps, dwAlphaCmpCaps *)
{ TD3DPrimCaps dwZCmpCaps, dwAlphaCmpCaps }
 
const
D3DPCMPCAPS_NEVER = $00000001;
D3DPCMPCAPS_LESS = $00000002;
D3DPCMPCAPS_EQUAL = $00000004;
7470,7 → 4586,7
D3DPCMPCAPS_GREATEREQUAL = $00000040;
D3DPCMPCAPS_ALWAYS = $00000080;
 
(* TD3DPrimCaps dwSourceBlendCaps, dwDestBlendCaps *)
{ TD3DPrimCaps dwSourceBlendCaps, dwDestBlendCaps }
 
D3DPBLENDCAPS_ZERO = $00000001;
D3DPBLENDCAPS_ONE = $00000002;
7486,7 → 4602,7
D3DPBLENDCAPS_BOTHSRCALPHA = $00000800;
D3DPBLENDCAPS_BOTHINVSRCALPHA = $00001000;
 
(* TD3DPrimCaps dwShadeCaps *)
{ TD3DPrimCaps dwShadeCaps }
 
D3DPSHADECAPS_COLORFLATMONO = $00000001;
D3DPSHADECAPS_COLORFLATRGB = $00000002;
7513,75 → 4629,23
D3DPSHADECAPS_FOGGOURAUD = $00080000;
D3DPSHADECAPS_FOGPHONG = $00100000;
 
(* TD3DPrimCaps dwTextureCaps *)
{ TD3DPrimCaps dwTextureCaps }
 
(*
* Perspective-correct texturing is supported
*)
D3DPTEXTURECAPS_PERSPECTIVE = $00000001;
 
(*
* Power-of-2 texture dimensions are required
*)
D3DPTEXTURECAPS_POW2 = $00000002;
 
(*
* Alpha in texture pixels is supported
*)
D3DPTEXTURECAPS_ALPHA = $00000004;
 
(*
* Color-keyed textures are supported
*)
D3DPTEXTURECAPS_TRANSPARENCY = $00000008;
 
(*
* obsolete, see D3DPTADDRESSCAPS_BORDER
*)
D3DPTEXTURECAPS_BORDER = $00000010;
 
(*
* Only square textures are supported
*)
D3DPTEXTURECAPS_SQUAREONLY = $00000020;
 
(*
* Texture indices are not scaled by the texture size prior
* to interpolation.
*)
D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE = $00000040;
 
(*
* Device can draw alpha from texture palettes
*)
D3DPTEXTURECAPS_ALPHAPALETTE = $00000080;
 
(*
* Device can use non-POW2 textures if:
* 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage
* 2) D3DRS_WRAP(N) is zero for this texture's coordinates
* 3) mip mapping is not enabled (use magnification filter only)
*)
D3DPTEXTURECAPS_NONPOW2CONDITIONAL = $00000100;
 
// 0x00000200L unused
 
(*
* Device can divide transformed texture coordinates by the
* COUNTth texture coordinate (can do D3DTTFF_PROJECTED)
*)
D3DPTEXTURECAPS_PROJECTED = $00000400;
 
(*
* Device can do cubemap textures
*)
D3DPTEXTURECAPS_CUBEMAP = $00000800;
 
D3DPTEXTURECAPS_COLORKEYBLEND = $00001000;
 
{ TD3DPrimCaps dwTextureFilterCaps }
 
(* TD3DPrimCaps dwTextureFilterCaps *)
 
D3DPTFILTERCAPS_NEAREST = $00000001;
D3DPTFILTERCAPS_LINEAR = $00000002;
D3DPTFILTERCAPS_MIPNEAREST = $00000004;
7589,16 → 4653,19
D3DPTFILTERCAPS_LINEARMIPNEAREST = $00000010;
D3DPTFILTERCAPS_LINEARMIPLINEAR = $00000020;
 
(* Device3 Min Filter *)
{ Device3 Min Filter }
 
D3DPTFILTERCAPS_MINFPOINT = $00000100;
D3DPTFILTERCAPS_MINFLINEAR = $00000200;
D3DPTFILTERCAPS_MINFANISOTROPIC = $00000400;
 
(* Device3 Mip Filter *)
{ Device3 Mip Filter }
 
D3DPTFILTERCAPS_MIPFPOINT = $00010000;
D3DPTFILTERCAPS_MIPFLINEAR = $00020000;
 
(* Device3 Mag Filter *)
{ Device3 Mag Filter }
 
D3DPTFILTERCAPS_MAGFPOINT = $01000000;
D3DPTFILTERCAPS_MAGFLINEAR = $02000000;
D3DPTFILTERCAPS_MAGFANISOTROPIC = $04000000;
7605,7 → 4672,7
D3DPTFILTERCAPS_MAGFAFLATCUBIC = $08000000;
D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC = $10000000;
 
(* TD3DPrimCaps dwTextureBlendCaps *)
{ TD3DPrimCaps dwTextureBlendCaps }
 
D3DPTBLENDCAPS_DECAL = $00000001;
D3DPTBLENDCAPS_MODULATE = $00000002;
7616,7 → 4683,8
D3DPTBLENDCAPS_COPY = $00000040;
D3DPTBLENDCAPS_ADD = $00000080;
 
(* TD3DPrimCaps dwTextureAddressCaps *)
{ TD3DPrimCaps dwTextureAddressCaps }
 
D3DPTADDRESSCAPS_WRAP = $00000001;
D3DPTADDRESSCAPS_MIRROR = $00000002;
D3DPTADDRESSCAPS_CLAMP = $00000004;
7623,7 → 4691,7
D3DPTADDRESSCAPS_BORDER = $00000008;
D3DPTADDRESSCAPS_INDEPENDENTUV = $00000010;
 
(* D3DDEVICEDESC dwStencilCaps *)
{ D3DDEVICEDESC dwStencilCaps }
 
D3DSTENCILCAPS_KEEP = $00000001;
D3DSTENCILCAPS_ZERO = $00000002;
7634,7 → 4702,7
D3DSTENCILCAPS_INCR = $00000040;
D3DSTENCILCAPS_DECR = $00000080;
 
(* D3DDEVICEDESC dwTextureOpCaps *)
{ D3DDEVICEDESC dwTextureOpCaps }
 
D3DTEXOPCAPS_DISABLE = $00000001;
D3DTEXOPCAPS_SELECTARG1 = $00000002;
7661,41 → 4729,77
D3DTEXOPCAPS_BUMPENVMAPLUMINANCE = $00400000;
D3DTEXOPCAPS_DOTPRODUCT3 = $00800000;
 
(* D3DDEVICEDESC dwFVFCaps flags *)
{ D3DDEVICEDESC dwFVFCaps flags }
 
D3DFVFCAPS_TEXCOORDCOUNTMASK = $0000ffff; (* mask for texture coordinate count field *)
D3DFVFCAPS_DONOTSTRIPELEMENTS = $00080000; (* Device prefers that vertex elements not be stripped *)
D3DFVFCAPS_TEXCOORDCOUNTMASK = $0000ffff; // mask for texture coordinate count field
D3DFVFCAPS_DONOTSTRIPELEMENTS = $00080000; // Device prefers that vertex elements not be stripped
 
(*
* Description for a device.
* This is used to describe a device that is to be created or to query
* the current device.
*)
{ Description for a device. }
 
type
PD3DDeviceDesc = ^TD3DDeviceDesc;
TD3DDeviceDesc = packed record
dwSize: DWORD; (* Size of TD3DDeviceDesc structure *)
dwFlags: DWORD; (* Indicates which fields have valid data *)
dcmColorModel: TD3DColorModel; (* Color model of device *)
dwDevCaps: DWORD; (* Capabilities of device *)
dtcTransformCaps: TD3DTransformCaps; (* Capabilities of transform *)
bClipping: BOOL; (* Device can do 3D clipping *)
dlcLightingCaps: TD3DLightingCaps; (* Capabilities of lighting *)
PD3DDeviceDesc_DX3 = ^TD3DDeviceDesc_DX3;
TD3DDeviceDesc_DX3 = record
dwSize: DWORD; // Size of D3DDEVICEDESC structure
dwFlags: DWORD; // Indicates which fields have valid data
dcmColorModel: TD3DColorModel; // Color model of device
dwDevCaps: DWORD; // Capabilities of device
dtcTransformCaps: TD3DTransformCaps; // Capabilities of transform
bClipping: BOOL; // Device can do 3D clipping
dlcLightingCaps: TD3DLightingCaps; // Capabilities of lighting
dpcLineCaps: TD3DPrimCaps;
dpcTriCaps: TD3DPrimCaps;
dwDeviceRenderBitDepth: DWORD; (* One of DDBB_8, 16, etc.. *)
dwDeviceZBufferBitDepth: DWORD; (* One of DDBD_16, 32, etc.. *)
dwMaxBufferSize: DWORD; (* Maximum execute buffer size *)
dwMaxVertexCount: DWORD; (* Maximum vertex count *)
// *** New fields for DX5 *** //
dwDeviceRenderBitDepth: DWORD; // One of DDBB_8, 16, etc..
dwDeviceZBufferBitDepth: DWORD; // One of DDBD_16, 32, etc..
dwMaxBufferSize: DWORD; // Maximum execute buffer size
dwMaxVertexCount: DWORD; // Maximum vertex count
end;
 
PD3DDeviceDesc_DX5 = ^TD3DDeviceDesc_DX5;
TD3DDeviceDesc_DX5 = record
dwSize: DWORD; // Size of D3DDEVICEDESC structure
dwFlags: DWORD; // Indicates which fields have valid data
dcmColorModel: TD3DColorModel; // Color model of device
dwDevCaps: DWORD; // Capabilities of device
dtcTransformCaps: TD3DTransformCaps; // Capabilities of transform
bClipping: BOOL; // Device can do 3D clipping
dlcLightingCaps: TD3DLightingCaps; // Capabilities of lighting
dpcLineCaps: TD3DPrimCaps;
dpcTriCaps: TD3DPrimCaps;
dwDeviceRenderBitDepth: DWORD; // One of DDBB_8, 16, etc..
dwDeviceZBufferBitDepth: DWORD; // One of DDBD_16, 32, etc..
dwMaxBufferSize: DWORD; // Maximum execute buffer size
dwMaxVertexCount: DWORD; // Maximum vertex count
// New fields for DX5
// Width and height caps are 0 for legacy HALs.
dwMinTextureWidth, dwMinTextureHeight : DWORD;
dwMaxTextureWidth, dwMaxTextureHeight : DWORD;
dwMinStippleWidth, dwMaxStippleWidth : DWORD;
dwMinStippleHeight, dwMaxStippleHeight : DWORD;
end;
 
PD3DDeviceDesc_DX6 = ^TD3DDeviceDesc_DX6;
TD3DDeviceDesc_DX6 = record
dwSize: DWORD; // Size of D3DDEVICEDESC structure
dwFlags: DWORD; // Indicates which fields have valid data
dcmColorModel: TD3DColorModel; // Color model of device
dwDevCaps: DWORD; // Capabilities of device
dtcTransformCaps: TD3DTransformCaps; // Capabilities of transform
bClipping: BOOL; // Device can do 3D clipping
dlcLightingCaps: TD3DLightingCaps; // Capabilities of lighting
dpcLineCaps: TD3DPrimCaps;
dpcTriCaps: TD3DPrimCaps;
dwDeviceRenderBitDepth: DWORD; // One of DDBB_8, 16, etc..
dwDeviceZBufferBitDepth: DWORD; // One of DDBD_16, 32, etc..
dwMaxBufferSize: DWORD; // Maximum execute buffer size
dwMaxVertexCount: DWORD; // Maximum vertex count
 
// New fields for DX5
// Width and height caps are 0 for legacy HALs.
dwMinTextureWidth, dwMinTextureHeight : DWORD;
dwMaxTextureWidth, dwMaxTextureHeight : DWORD;
dwMinStippleWidth, dwMaxStippleWidth : DWORD;
dwMinStippleHeight, dwMaxStippleHeight : DWORD;
 
// New fields for DX6
dwMaxTextureRepeat : DWORD;
dwMaxTextureAspectRatio : DWORD;
7708,26 → 4812,43
dvGuardBandTop : TD3DValue;
dvGuardBandRight : TD3DValue;
dvGuardBandBottom : TD3DValue;
 
dvExtentsAdjust : TD3DValue;
dwStencilCaps : DWORD;
 
dwFVFCaps : DWORD; (* low 4 bits: 0 implies TLVERTEX only, 1..8 imply FVF aware *)
dwFVFCaps: DWORD; // low 4 bits: 0 implies TLVERTEX only, 1..8 imply FVF aware
dwTextureOpCaps : DWORD;
wMaxTextureBlendStages : WORD;
wMaxSimultaneousTextures : WORD;
wMaxTextureBlendStages: Word;
wMaxSimultaneousTextures: Word;
end;
 
{$IFDEF DirectX3}
TD3DDeviceDesc = TD3DDeviceDesc_DX3;
PD3DDeviceDesc = PD3DDeviceDesc_DX3;
{$ENDIF}{$IFDEF DirectX5}
TD3DDeviceDesc = TD3DDeviceDesc_DX5;
PD3DDeviceDesc = PD3DDeviceDesc_DX5;
{$ENDIF}{$IFDEF DirectX6}
TD3DDeviceDesc = TD3DDeviceDesc_DX6;
PD3DDeviceDesc = PD3DDeviceDesc_DX6;
{$ENDIF}{$IFDEF DirectX7}
TD3DDeviceDesc = TD3DDeviceDesc_DX6;
PD3DDeviceDesc = PD3DDeviceDesc_DX6;
{$ENDIF}
 
D3DDEVICEDESC = TD3DDeviceDesc;
LPD3DDEVICEDESC = PD3DDeviceDesc;
 
PD3DDeviceDesc7 = ^TD3DDeviceDesc7;
TD3DDeviceDesc7 = packed record
dwDevCaps: DWORD; (* Capabilities of device *)
TD3DDeviceDesc7 = record
dwDevCaps: DWORD;
dpcLineCaps: TD3DPrimCaps;
dpcTriCaps: TD3DPrimCaps;
dwDeviceRenderBitDepth: DWORD; (* One of DDBB_8, 16, etc.. *)
dwDeviceZBufferBitDepth: DWORD; (* One of DDBD_16, 32, etc.. *)
dwDeviceRenderBitDepth: DWORD;
dwDeviceZBufferBitDepth: DWORD;
 
dwMinTextureWidth, dwMinTextureHeight: DWORD;
dwMaxTextureWidth, dwMaxTextureHeight: DWORD;
dwMinTextureWidth: DWORD;
dwMinTextureHeight: DWORD;
dwMaxTextureWidth: DWORD;
dwMaxTextureHeight: DWORD;
 
dwMaxTextureRepeat: DWORD;
dwMaxTextureAspectRatio: DWORD;
7743,15 → 4864,15
 
dwFVFCaps: DWORD;
dwTextureOpCaps: DWORD;
wMaxTextureBlendStages: WORD;
wMaxSimultaneousTextures: WORD;
wMaxTextureBlendStages: Word;
wMaxSimultaneousTextures: Word;
 
dwMaxActiveLights: DWORD;
dvMaxVertexW: TD3DValue;
deviceGUID: TGUID;
 
wMaxUserClipPlanes: WORD;
wMaxVertexBlendMatrices: WORD;
wMaxUserClipPlanes: Word;
wMaxVertexBlendMatrices: Word;
 
dwVertexProcessingCaps: DWORD;
 
7761,102 → 4882,91
dwReserved4: DWORD;
end;
 
const
D3DDEVICEDESCSIZE = sizeof(TD3DDeviceDesc);
D3DDEVICEDESC7SIZE = sizeof(TD3DDeviceDesc7);
 
type
TD3DEnumDevicesCallbackA = function (lpGuid: PGUID; // nil for the default device
lpDeviceDescription: PAnsiChar; lpDeviceName: PAnsiChar;
var lpD3DHWDeviceDesc: TD3DDeviceDesc;
var lpD3DHELDeviceDesc: TD3DDeviceDesc;
lpContext : pointer) : HResult; stdcall;
TD3DEnumDevicesCallback = TD3DEnumDevicesCallbackA;
TD3DEnumDevicesCallback = function(const lpGuid: TGUID;
lpDeviceDescription: LPSTR; lpDeviceName: LPSTR;
const lpD3DHWDeviceDesc: TD3DDeviceDesc;
const lpD3DHELDeviceDesc: TD3DDeviceDesc;
lpUserArg: Pointer): HResult; stdcall;
 
TD3DEnumDevicesCallback7A = function (
lpDeviceDescription: PAnsiChar; lpDeviceName: PAnsiChar;
const lpD3DDeviceDesc: TD3DDeviceDesc7; lpContext: Pointer) : HResult; stdcall;
TD3DEnumDevicesCallback7 = TD3DEnumDevicesCallback7A;
LPD3DENUMDEVICESCALLBACK = TD3DEnumDevicesCallback;
 
(* TD3DDeviceDesc dwFlags indicating valid fields *)
TD3DEnumDevicesCallback7 = function(lpDeviceDescription: LPSTR; lpDeviceName: LPSTR;
const lpD3DDeviceDesc: TD3DDeviceDesc7; lpUserArg: Pointer): HResult; stdcall;
 
LPD3DENUMDEVICESCALLBACK7 = TD3DEnumDevicesCallback7;
 
{ TD3DDeviceDesc dwFlags indicating valid fields }
 
const
D3DDD_COLORMODEL = $00000001; (* dcmColorModel is valid *)
D3DDD_DEVCAPS = $00000002; (* dwDevCaps is valid *)
D3DDD_TRANSFORMCAPS = $00000004; (* dtcTransformCaps is valid *)
D3DDD_LIGHTINGCAPS = $00000008; (* dlcLightingCaps is valid *)
D3DDD_BCLIPPING = $00000010; (* bClipping is valid *)
D3DDD_LINECAPS = $00000020; (* dpcLineCaps is valid *)
D3DDD_TRICAPS = $00000040; (* dpcTriCaps is valid *)
D3DDD_DEVICERENDERBITDEPTH = $00000080; (* dwDeviceRenderBitDepth is valid *)
D3DDD_DEVICEZBUFFERBITDEPTH = $00000100; (* dwDeviceZBufferBitDepth is valid *)
D3DDD_MAXBUFFERSIZE = $00000200; (* dwMaxBufferSize is valid *)
D3DDD_MAXVERTEXCOUNT = $00000400; (* dwMaxVertexCount is valid *)
D3DDD_COLORMODEL = $00000001; // dcmColorModel is valid
D3DDD_DEVCAPS = $00000002; // dwDevCaps is valid
D3DDD_TRANSFORMCAPS = $00000004; // dtcTransformCaps is valid
D3DDD_LIGHTINGCAPS = $00000008; // dlcLightingCaps is valid
D3DDD_BCLIPPING = $00000010; // bClipping is valid
D3DDD_LINECAPS = $00000020; // dpcLineCaps is valid
D3DDD_TRICAPS = $00000040; // dpcTriCaps is valid
D3DDD_DEVICERENDERBITDEPTH = $00000080; // dwDeviceRenderBitDepth is valid
D3DDD_DEVICEZBUFFERBITDEPTH = $00000100; // dwDeviceZBufferBitDepth is valid
D3DDD_MAXBUFFERSIZE = $00000200; // dwMaxBufferSize is valid
D3DDD_MAXVERTEXCOUNT = $00000400; // dwMaxVertexCount is valid
 
(* TD3DDeviceDesc dwDevCaps flags *)
{ TD3DDeviceDesc dwDevCaps flags }
 
D3DDEVCAPS_FLOATTLVERTEX = $00000001; (* Device accepts floating point *)
(* for post-transform vertex data *)
D3DDEVCAPS_SORTINCREASINGZ = $00000002; (* Device needs data sorted for increasing Z*)
D3DDEVCAPS_SORTDECREASINGZ = $00000004; (* Device needs data sorted for decreasing Z*)
D3DDEVCAPS_SORTEXACT = $00000008; (* Device needs data sorted exactly *)
D3DDEVCAPS_FLOATTLVERTEX = $00000001; // Device accepts floating point
// for post-transform vertex data
D3DDEVCAPS_SORTINCREASINGZ = $00000002; // Device needs data sorted for increasing Z
D3DDEVCAPS_SORTDECREASINGZ = $00000004; // Device needs data sorted for decreasing Z
D3DDEVCAPS_SORTEXACT = $00000008; // Device needs data sorted exactly
 
D3DDEVCAPS_EXECUTESYSTEMMEMORY = $00000010; (* Device can use execute buffers from system memory *)
D3DDEVCAPS_EXECUTEVIDEOMEMORY = $00000020; (* Device can use execute buffers from video memory *)
D3DDEVCAPS_TLVERTEXSYSTEMMEMORY = $00000040; (* Device can use TL buffers from system memory *)
D3DDEVCAPS_TLVERTEXVIDEOMEMORY = $00000080; (* Device can use TL buffers from video memory *)
D3DDEVCAPS_TEXTURESYSTEMMEMORY = $00000100; (* Device can texture from system memory *)
D3DDEVCAPS_TEXTUREVIDEOMEMORY = $00000200; (* Device can texture from device memory *)
D3DDEVCAPS_DRAWPRIMTLVERTEX = $00000400; (* Device can draw TLVERTEX primitives *)
D3DDEVCAPS_CANRENDERAFTERFLIP = $00000800; (* Device can render without waiting for flip to complete *)
D3DDEVCAPS_TEXTURENONLOCALVIDMEM = $00001000; (* Device can texture from nonlocal video memory *)
D3DDEVCAPS_DRAWPRIMITIVES2 = $00002000; (* Device can support DrawPrimitives2 *)
D3DDEVCAPS_SEPARATETEXTUREMEMORIES = $00004000; (* Device is texturing from separate memory pools *)
D3DDEVCAPS_DRAWPRIMITIVES2EX = $00008000; (* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*)
D3DDEVCAPS_HWTRANSFORMANDLIGHT = $00010000; (* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also *)
D3DDEVCAPS_CANBLTSYSTONONLOCAL = $00020000; (* Device supports a Tex Blt from system memory to non-local vidmem *)
D3DDEVCAPS_HWRASTERIZATION = $00080000; (* Device has HW acceleration for rasterization *)
D3DDEVCAPS_EXECUTESYSTEMMEMORY = $00000010; // Device can use execute buffers from system memory
D3DDEVCAPS_EXECUTEVIDEOMEMORY = $00000020; // Device can use execute buffers from video memory
D3DDEVCAPS_TLVERTEXSYSTEMMEMORY = $00000040; // Device can use TL buffers from system memory
D3DDEVCAPS_TLVERTEXVIDEOMEMORY = $00000080; // Device can use TL buffers from video memory
D3DDEVCAPS_TEXTURESYSTEMMEMORY = $00000100; // Device can texture from system memory
D3DDEVCAPS_TEXTUREVIDEOMEMORY = $00000200; // Device can texture from device memory
D3DDEVCAPS_DRAWPRIMTLVERTEX = $00000400; // Device can draw TLVERTEX primitives
D3DDEVCAPS_CANRENDERAFTERFLIP = $00000800; // Device can render without waiting for flip to complete
D3DDEVCAPS_TEXTURENONLOCALVIDMEM = $00001000; // Device can texture from nonlocal video memory
D3DDEVCAPS_DRAWPRIMITIVES2 = $00002000; // Device can support DrawPrimitives2
D3DDEVCAPS_SEPARATETEXTUREMEMORIES = $00004000; // Device is texturing from separate memory pools
D3DDEVCAPS_DRAWPRIMITIVES2EX = $00008000; // Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver
D3DDEVCAPS_HWTRANSFORMANDLIGHT = $00010000; // Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also
D3DDEVCAPS_CANBLTSYSTONONLOCAL = $00020000; // Device supports a Tex Blt from system memory to non-local vidmem
D3DDEVCAPS_HWRASTERIZATION = $00080000; // Device has HW acceleration for rasterization
 
(*
* These are the flags in the D3DDEVICEDESC7.dwVertexProcessingCaps field
*)
{ TD3DDeviceDesc7.dwVertexProcessingCaps field }
 
(* device can do texgen *)
D3DVTXPCAPS_TEXGEN = $00000001;
(* device can do IDirect3DDevice7 colormaterialsource ops *)
D3DVTXPCAPS_MATERIALSOURCE7 = $00000002;
(* device can do vertex fog *)
D3DVTXPCAPS_VERTEXFOG = $00000004;
(* device can do directional lights *)
D3DVTXPCAPS_DIRECTIONALLIGHTS = $00000008;
(* device can do positional lights (includes point and spot) *)
D3DVTXPCAPS_POSITIONALLIGHTS = $00000010;
(* device can do local viewer *)
D3DVTXPCAPS_LOCALVIEWER = $00000020;
 
D3DFDS_COLORMODEL = $00000001; (* Match color model *)
D3DFDS_GUID = $00000002; (* Match guid *)
D3DFDS_HARDWARE = $00000004; (* Match hardware/software *)
D3DFDS_TRIANGLES = $00000008; (* Match in triCaps *)
D3DFDS_LINES = $00000010; (* Match in lineCaps *)
D3DFDS_MISCCAPS = $00000020; (* Match primCaps.dwMiscCaps *)
D3DFDS_RASTERCAPS = $00000040; (* Match primCaps.dwRasterCaps *)
D3DFDS_ZCMPCAPS = $00000080; (* Match primCaps.dwZCmpCaps *)
D3DFDS_ALPHACMPCAPS = $00000100; (* Match primCaps.dwAlphaCmpCaps *)
D3DFDS_SRCBLENDCAPS = $00000200; (* Match primCaps.dwSourceBlendCaps *)
D3DFDS_DSTBLENDCAPS = $00000400; (* Match primCaps.dwDestBlendCaps *)
D3DFDS_SHADECAPS = $00000800; (* Match primCaps.dwShadeCaps *)
D3DFDS_TEXTURECAPS = $00001000; (* Match primCaps.dwTextureCaps *)
D3DFDS_TEXTUREFILTERCAPS = $00002000; (* Match primCaps.dwTextureFilterCaps *)
D3DFDS_TEXTUREBLENDCAPS = $00004000; (* Match primCaps.dwTextureBlendCaps *)
D3DFDS_TEXTUREADDRESSCAPS = $00008000; (* Match primCaps.dwTextureBlendCaps *)
D3DFDS_COLORMODEL = $00000001; // Match color model
D3DFDS_GUID = $00000002; // Match guid
D3DFDS_HARDWARE = $00000004; // Match hardware/software
D3DFDS_TRIANGLES = $00000008; // Match in triCaps
D3DFDS_LINES = $00000010; // Match in lineCaps
D3DFDS_MISCCAPS = $00000020; // Match primCaps.dwMiscCaps
D3DFDS_RASTERCAPS = $00000040; // Match primCaps.dwRasterCaps
D3DFDS_ZCMPCAPS = $00000080; // Match primCaps.dwZCmpCaps
D3DFDS_ALPHACMPCAPS = $00000100; // Match primCaps.dwAlphaCmpCaps
D3DFDS_SRCBLENDCAPS = $00000200; // Match primCaps.dwSourceBlendCaps
D3DFDS_DSTBLENDCAPS = $00000400; // Match primCaps.dwDestBlendCaps
D3DFDS_SHADECAPS = $00000800; // Match primCaps.dwShadeCaps
D3DFDS_TEXTURECAPS = $00001000; // Match primCaps.dwTextureCaps
D3DFDS_TEXTUREFILTERCAPS = $00002000; // Match primCaps.dwTextureFilterCaps
D3DFDS_TEXTUREBLENDCAPS = $00004000; // Match primCaps.dwTextureBlendCaps
D3DFDS_TEXTUREADDRESSCAPS = $00008000; // Match primCaps.dwTextureBlendCaps
 
(*
* FindDevice arguments
*)
{ FindDevice arguments }
 
type
PD3DFindDeviceSearch = ^TD3DFindDeviceSearch;
TD3DFindDeviceSearch = packed record
TD3DFindDeviceSearch = record
dwSize: DWORD;
dwFlags: DWORD;
bHardware: BOOL;
7866,103 → 4976,133
dpcPrimCaps: TD3DPrimCaps;
end;
 
D3DFINDDEVICESEARCH = TD3DFindDeviceSearch;
LPD3DFINDDEVICESEARCH = PD3DFindDeviceSearch;
 
PD3DFindDeviceResult = ^TD3DFindDeviceResult;
TD3DFindDeviceResult = packed record
TD3DFindDeviceResult = record
dwSize: DWORD;
guid: TGUID; (* guid which matched *)
ddHwDesc: TD3DDeviceDesc; (* hardware TD3DDeviceDesc *)
ddSwDesc: TD3DDeviceDesc; (* software TD3DDeviceDesc *)
guid: TGUID; // guid which matched
ddHwDesc: TD3DDeviceDesc; // hardware TD3DDeviceDesc
ddSwDesc: TD3DDeviceDesc; // software TD3DDeviceDesc
end;
 
(*
* Description of execute buffer.
*)
D3DFINDDEVICERESULT = TD3DFindDeviceResult;
LPD3DFINDDEVICERESULT = PD3DFindDeviceResult;
 
{ Description of execute buffer. }
 
PD3DExecuteBufferDesc = ^TD3DExecuteBufferDesc;
TD3DExecuteBufferDesc = packed record
dwSize: DWORD; (* size of this structure *)
dwFlags: DWORD; (* flags indicating which fields are valid *)
dwCaps: DWORD; (* capabilities of execute buffer *)
dwBufferSize: DWORD; (* size of execute buffer data *)
lpData: Pointer; (* pointer to actual data *)
TD3DExecuteBufferDesc = record
dwSize: DWORD; // size of this structure
dwFlags: DWORD; // flags indicating which fields are valid
dwCaps: DWORD; // capabilities of execute buffer
dwBufferSize: DWORD; // size of execute buffer data
lpData: Pointer; // pointer to actual data
end;
 
(* D3DEXECUTEBUFFER dwFlags indicating valid fields *)
D3DEXECUTEBUFFERDESC = TD3DExecuteBufferDesc;
LPD3DEXECUTEBUFFERDESC = PD3DExecuteBufferDesc;
 
{ D3DEXECUTEBUFFER dwFlags indicating valid fields }
 
const
D3DDEB_BUFSIZE = $00000001; (* buffer size valid *)
D3DDEB_CAPS = $00000002; (* caps valid *)
D3DDEB_LPDATA = $00000004; (* lpData valid *)
D3DDEB_BUFSIZE = $00000001; // buffer size valid
D3DDEB_CAPS = $00000002; // caps valid
D3DDEB_LPDATA = $00000004; // lpData valid
 
(* D3DEXECUTEBUFFER dwCaps *)
{ D3DEXECUTEBUFFER dwCaps }
 
D3DDEBCAPS_SYSTEMMEMORY = $00000001; (* buffer in system memory *)
D3DDEBCAPS_VIDEOMEMORY = $00000002; (* buffer in device memory *)
D3DDEBCAPS_MEM = (D3DDEBCAPS_SYSTEMMEMORY or D3DDEBCAPS_VIDEOMEMORY);
D3DDEBCAPS_SYSTEMMEMORY = $00000001; // buffer in system memory
D3DDEBCAPS_VIDEOMEMORY = $00000002; // buffer in device memory
D3DDEBCAPS_MEM = D3DDEBCAPS_SYSTEMMEMORY or D3DDEBCAPS_VIDEOMEMORY;
 
type
 
{ TD3DDevInfo_TextureManager }
 
PD3DDevInfo_TextureManager = ^TD3DDevInfo_TextureManager;
TD3DDevInfo_TextureManager = packed record
bThrashing: BOOL; (* indicates if thrashing *)
dwApproxBytesDownloaded: DWORD; (* Approximate number of bytes downloaded by texture manager *)
dwNumEvicts: DWORD; (* number of textures evicted *)
dwNumVidCreates: DWORD; (* number of textures created in video memory *)
dwNumTexturesUsed: DWORD; (* number of textures used *)
dwNumUsedTexInVid: DWORD; (* number of used textures present in video memory *)
dwWorkingSet: DWORD; (* number of textures in video memory *)
dwWorkingSetBytes: DWORD; (* number of bytes in video memory *)
dwTotalManaged: DWORD; (* total number of managed textures *)
dwTotalBytes: DWORD; (* total number of bytes of managed textures *)
dwLastPri: DWORD; (* priority of last texture evicted *)
TD3DDevInfo_TextureManager = record
bThrashing: BOOL; // indicates if thrashing
dwApproxBytesDownloaded: DWORD; // Approximate number of bytes downloaded by texture manager
dwNumEvicts: DWORD; // number of textures evicted
dwNumVidCreates: DWORD; // number of textures created in video memory
dwNumTexturesUsed: DWORD; // number of textures used
dwNumUsedTexInVid: DWORD; // number of used textures present in video memory
dwWorkingSet: DWORD; // number of textures in video memory
dwWorkingSetBytes: DWORD; // number of bytes in video memory
dwTotalManaged: DWORD; // total number of managed textures
dwTotalBytes: DWORD; // total number of bytes of managed textures
dwLastPri: DWORD; // priority of last texture evicted
end;
 
D3DDEVINFO_TEXTUREMANAGER = TD3DDevInfo_TextureManager;
LPD3DDEVINFO_TEXTUREMANAGER = PD3DDevInfo_TextureManager;
 
{ TD3DDevInfo_Texturing }
 
PD3DDevInfo_Texturing = ^TD3DDevInfo_Texturing;
TD3DDevInfo_Texturing = packed record
dwNumLoads: DWORD; (* counts Load() API calls *)
dwApproxBytesLoaded: DWORD; (* Approximate number bytes loaded via Load() *)
dwNumPreLoads: DWORD; (* counts PreLoad() API calls *)
dwNumSet: DWORD; (* counts SetTexture() API calls *)
dwNumCreates: DWORD; (* counts texture creates *)
dwNumDestroys: DWORD; (* counts texture destroys *)
dwNumSetPriorities: DWORD; (* counts SetPriority() API calls *)
dwNumSetLODs: DWORD; (* counts SetLOD() API calls *)
dwNumLocks: DWORD; (* counts number of texture locks *)
dwNumGetDCs: DWORD; (* counts number of GetDCs to textures *)
TD3DDevInfo_Texturing = record
dwNumLoads: DWORD; // counts Load() API calls
dwApproxBytesLoaded: DWORD; // Approximate number bytes loaded via Load()
dwNumPreLoads: DWORD; // counts PreLoad() API calls
dwNumSet: DWORD; // counts SetTexture() API calls
dwNumCreates: DWORD; // counts texture creates
dwNumDestroys: DWORD; // counts texture destroys
dwNumSetPriorities: DWORD; // counts SetPriority() API calls
dwNumSetLODs: DWORD; // counts SetLOD() API calls
dwNumLocks: DWORD; // counts number of texture locks
dwNumGetDCs: DWORD; // counts number of GetDCs to textures
end;
 
D3DDEVINFO_TEXTURING = TD3DDevInfo_Texturing;
LPD3DDEVINFO_TEXTURING = PD3DDevInfo_Texturing;
 
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: d3d.h
* Content: Direct3D include file
*
****************************************************************************)
***************************************************************************)
 
function D3DErrorString(Value: HResult) : string;
{ Interface IID's }
 
(*
* Interface IID's
*)
 
const
(*
* Internal Guid to distinguish requested MMX from MMX being used as an RGB rasterizer
*)
IID_IDirect3DRampDevice: TGUID =
(D1:$F2086B20;D2:$259F;D3:$11CF;D4:($A3,$1A,$00,$AA,$00,$B9,$33,$56));
IID_IDirect3DRGBDevice: TGUID =
(D1:$A4665C60;D2:$2673;D3:$11CF;D4:($A3,$1A,$00,$AA,$00,$B9,$33,$56));
IID_IDirect3DHALDevice: TGUID =
(D1:$84E63dE0;D2:$46AA;D3:$11CF;D4:($81,$6F,$00,$00,$C0,$20,$15,$6E));
IID_IDirect3DMMXDevice: TGUID =
(D1:$881949a1;D2:$d6f3;D3:$11d0;D4:($89,$ab,$00,$a0,$c9,$05,$41,$29));
IID_IDirect3D: TGUID = '{3BBA0080-2421-11CF-A31A-00AA00B93356}';
IID_IDirect3D2: TGUID = '{6AAE1EC1-662A-11D0-889D-00AA00BBB76A}';
IID_IDirect3D3: TGUID = '{BB223240-E72B-11D0-A9B4-00AA00C0993E}';
IID_IDirect3D7: TGUID = '{F5049E77-4861-11D2-A407-00A0C90629A8}';
 
IID_IDirect3DRefDevice: TGUID =
(D1:$50936643;D2:$13e9;D3:$11d1;D4:($89,$aa,$00,$a0,$c9,$05,$41,$29));
IID_IDirect3DNullDevice: TGUID =
(D1:$8767df22;D2:$bacc;D3:$11d1;D4:($89,$69,$00,$a0,$c9,$06,$29,$a8));
IID_IDirect3DRampDevice: TGUID = '{F2086B20-259F-11CF-A31A-00AA00B93356}';
IID_IDirect3DRGBDevice: TGUID = '{A4665C60-2673-11CF-A31A-00AA00B93356}';
IID_IDirect3DHALDevice: TGUID = '{84E63DE0-46AA-11CF-816F-0000C020156E}';
IID_IDirect3DMMXDevice: TGUID = '{881949A1-D6F3-11D0-89AB-00A0C9054129}';
IID_IDirect3DRefDevice: TGUID = '{50936643-13E9-11D1-89AA-00A0C9054129}';
IID_IDirect3DNullDevice: TGUID = '{8767DF22-BACC-11D1-8969-00A0C90629A8}';
IID_IDirect3DTnLHalDevice: TGUID = '{F5049E78-4861-11D2-A407-00A0C90629A8}';
 
IID_IDirect3DTnLHalDevice: TGUID = '{f5049e78-4861-11d2-a407-00a0c90629a8}';
IID_IDirect3DDevice: TGUID = '{64108800-957D-11D0-89AB-00A0C9054129}';
IID_IDirect3DDevice2: TGUID = '{93281501-8CF8-11D0-89AB-00A0C9054129}';
IID_IDirect3DDevice3: TGUID = '{B0AB3B60-33D7-11D1-A981-00C04FD7B174}';
IID_IDirect3DDevice7: TGUID = '{F5049E79-4861-11D2-A407-00A0C90629A8}';
 
IID_IDirect3DTexture: TGUID ='{2CDCD9E0-25A0-11CF-A31A-00AA00B93356}';
IID_IDirect3DTexture2: TGUID = '{93281502-8CF8-11D0-89AB-00A0C9054129}';
IID_IDirect3DLight: TGUID = '{4417C142-33AD-11CF-816F-0000C020156E}';
IID_IDirect3DMaterial: TGUID = '{4417C144-33AD-11CF-816F-0000C020156E}';
IID_IDirect3DMaterial2: TGUID = '{93281503-8CF8-11D0-89AB-00A0C9054129}';
IID_IDirect3DMaterial3: TGUID = '{CA9C46F4-D3C5-11D1-B75A-00600852B312}';
IID_IDirect3DExecuteBuffer: TGUID = '{4417C145-33AD-11CF-816F-0000C020156E}';
IID_IDirect3DViewport: TGUID = '{4417C146-33AD-11CF-816F-0000C020156E}';
IID_IDirect3DViewport2: TGUID = '{93281500-8CF8-11D0-89AB-00A0C9054129}';
IID_IDirect3DViewport3: TGUID = '{B0AB3B61-33D7-11D1-A981-00C04FD7B174}';
IID_IDirect3DVertexBuffer: TGUID = '{7A503555-4A83-11D1-A5DB-00A0C90367F8}';
IID_IDirect3DVertexBuffer7: TGUID = '{F5049E7D-4861-11D2-A407-00A0C90629A8}';
 
{ Data structures }
 
type
IDirect3D = interface;
IDirect3D2 = interface;
7985,96 → 5125,89
IDirect3DVertexBuffer = interface;
IDirect3DVertexBuffer7 = interface;
 
(*
* Direct3D interfaces
*)
 
IDirect3D = interface (IUnknown)
['{3BBA0080-2421-11CF-A31A-00AA00B93356}']
(*** IDirect3D methods ***)
function Initialize (lpREFIID: {REFIID} PGUID) : HResult; stdcall;
// IDirect3D methods
function Initialize(const lpREFIID: TGUID): HResult; stdcall;
function EnumDevices (lpEnumDevicesCallback: TD3DEnumDevicesCallback;
lpUserArg: Pointer) : HResult; stdcall;
function CreateLight (var lplpDirect3Dlight: IDirect3DLight;
function CreateLight(out lplpDirect3Dlight: IDirect3DLight;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreateMaterial (var lplpDirect3DMaterial: IDirect3DMaterial;
function CreateMaterial(out lplpDirect3DMaterial: IDirect3DMaterial;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreateViewport (var lplpD3DViewport: IDirect3DViewport;
function CreateViewport(out lplpD3DViewport: IDirect3DViewport;
pUnkOuter: IUnknown) : HResult; stdcall;
function FindDevice (var lpD3DFDS: TD3DFindDeviceSearch;
function FindDevice(const lpD3DFDS: TD3DFindDeviceSearch;
var lpD3DFDR: TD3DFindDeviceResult) : HResult; stdcall;
end;
 
IDirect3D2 = interface (IUnknown)
['{6aae1ec1-662a-11d0-889d-00aa00bbb76a}']
(*** IDirect3D2 methods ***)
['{6AAE1EC1-662A-11D0-889D-00AA00BBB76A}']
// IDirect3D methods
function EnumDevices(lpEnumDevicesCallback: TD3DEnumDevicesCallback;
lpUserArg: pointer) : HResult; stdcall;
function CreateLight (var lplpDirect3Dlight: IDirect3DLight;
lpUserArg: Pointer): HResult; stdcall;
function CreateLight(out lplpDirect3Dlight: IDirect3DLight;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreateMaterial (var lplpDirect3DMaterial2: IDirect3DMaterial2;
function CreateMaterial(out lplpDirect3DMaterial: IDirect3DMaterial2;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreateViewport (var lplpD3DViewport2: IDirect3DViewport2;
function CreateViewport(out lplpD3DViewport: IDirect3DViewport2;
pUnkOuter: IUnknown) : HResult; stdcall;
function FindDevice (var lpD3DFDS: TD3DFindDeviceSearch;
function FindDevice(const lpD3DFDS: TD3DFindDeviceSearch;
var lpD3DFDR: TD3DFindDeviceResult) : HResult; stdcall;
function CreateDevice (const rclsid: TRefClsID; lpDDS: IDirectDrawSurface;
// IDirect3D2 methods
function CreateDevice(const rclsid: TGUID; lpDDS: IDirectDrawSurface;
out lplpD3DDevice2: IDirect3DDevice2) : HResult; stdcall;
end;
 
IDirect3D3 = interface (IUnknown)
['{bb223240-e72b-11d0-a9b4-00aa00c0993e}']
(*** IDirect3D3 methods ***)
['{BB223240-E72B-11D0-A9B4-00AA00C0993E}']
// IDirect3D methods
function EnumDevices(lpEnumDevicesCallback: TD3DEnumDevicesCallback;
lpUserArg: pointer) : HResult; stdcall;
function CreateLight (var lplpDirect3Dlight: IDirect3DLight;
lpUserArg: Pointer): HResult; stdcall;
function CreateLight(out lplpDirect3Dlight: IDirect3DLight;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreateMaterial (var lplpDirect3DMaterial3: IDirect3DMaterial3;
function CreateMaterial(out lplpDirect3DMaterial: IDirect3DMaterial3;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreateViewport (var lplpD3DViewport3: IDirect3DViewport3;
function CreateViewport(out lplpD3DViewport: IDirect3DViewport3;
pUnkOuter: IUnknown) : HResult; stdcall;
function FindDevice (var lpD3DFDS: TD3DFindDeviceSearch;
function FindDevice(const lpD3DFDS: TD3DFindDeviceSearch;
var lpD3DFDR: TD3DFindDeviceResult) : HResult; stdcall;
function CreateDevice (const rclsid: TRefClsID; lpDDS: IDirectDrawSurface4;
out lplpD3DDevice: IDirect3DDevice3; pUnkOuter: IUnknown) : HResult; stdcall;
function CreateVertexBuffer (var lpVBDesc: TD3DVertexBufferDesc;
var lpD3DVertexBuffer: IDirect3DVertexBuffer;
dwFlags: DWORD; pUnkOuter: IUnknown) : HResult; stdcall;
function EnumZBufferFormats (const riidDevice: TRefClsID; lpEnumCallback:
TD3DEnumPixelFormatsCallback; lpContext: pointer) : HResult; stdcall;
// IDirect3D2 methods
function CreateDevice(const rclsid: TGUID; lpDDS: IDirectDrawSurface4;
out lplpD3DDevice2: IDirect3DDevice3; pUnkOuter: IUnknown): HResult; stdcall;
// IDirect3D3 methods
function CreateVertexBuffer(const lpVBDesc: TD3DVertexBufferDesc;
out lpD3DVertexBuffer: IDirect3DVertexBuffer; dwFlags: DWORD; pUnkOuter: IUnknown): HResult; stdcall;
function EnumZBufferFormats(const riidDevice: TGUID; lpEnumCallback: TD3DEnumPixelFormatsCallback;
lpContext: Pointer): HResult; stdcall;
function EvictManagedTextures : HResult; stdcall;
end;
 
IDirect3D7 = interface (IUnknown)
['{f5049e77-4861-11d2-a407-00a0c90629a8}']
(*** IDirect3D7 methods ***)
['{F5049E77-4861-11D2-A407-00A0C90629A8}']
// IDirect3D7 methods
function EnumDevices(lpEnumDevicesCallback: TD3DEnumDevicesCallback7;
lpUserArg: pointer) : HResult; stdcall;
lpUserArg: Pointer): HResult; stdcall;
function CreateDevice (const rclsid: TGUID; lpDDS: IDirectDrawSurface7;
out lplpD3DDevice: IDirect3DDevice7) : HResult; stdcall;
out lplpD3DDevice7: IDirect3DDevice7): HResult; stdcall;
function CreateVertexBuffer (const lpVBDesc: TD3DVertexBufferDesc;
out lplpD3DVertexBuffer: IDirect3DVertexBuffer7;
dwFlags: DWORD) : HResult; stdcall;
function EnumZBufferFormats (const riidDevice: TGUID; lpEnumCallback:
TD3DEnumPixelFormatsCallback; lpContext: pointer) : HResult; stdcall;
out lpD3DVertexBuffer: IDirect3DVertexBuffer7; dwFlags: DWORD): HResult; stdcall;
function EnumZBufferFormats(const riidDevice: TGUID; lpEnumCallback: TD3DEnumPixelFormatsCallback;
lpContext: Pointer): HResult; stdcall;
function EvictManagedTextures : HResult; stdcall;
end;
(*
* Direct3D Device interfaces
*)
 
IDirect3DDevice = interface (IUnknown)
['{64108800-957d-11d0-89ab-00a0c9054129}']
(*** IDirect3DDevice methods ***)
function Initialize (lpd3d: IDirect3D; lpGUID: PGUID;
var lpd3ddvdesc: TD3DDeviceDesc) : HResult; stdcall;
['{64108800-957D-11D0-89AB-00A0C9054129}']
// IDirect3DDevice methods
function Initialize(lpd3d: IDirect3D; const lpGUID: TGUID;
const lpd3ddvdesc: TD3DDeviceDesc): HResult; stdcall;
function GetCaps (var lpD3DHWDevDesc: TD3DDeviceDesc;
var lpD3DHELDevDesc: TD3DDeviceDesc) : HResult; stdcall;
function SwapTextureHandles (lpD3DTex1: IDirect3DTexture;
lpD3DTex2: IDirect3DTexture) : HResult; stdcall;
function CreateExecuteBuffer (var lpDesc: TD3DExecuteBufferDesc ;
var lplpDirect3DExecuteBuffer: IDirect3DExecuteBuffer;
function CreateExecuteBuffer(const lpDesc: TD3DExecuteBufferDesc;
out lplpDirect3DExecuteBuffer: IDirect3DExecuteBuffer;
pUnkOuter: IUnknown) : HResult; stdcall;
function GetStats (var lpD3DStats: TD3DStats) : HResult; stdcall;
function Execute (lpDirect3DExecuteBuffer: IDirect3DExecuteBuffer;
8082,94 → 5215,82
function AddViewport (lpDirect3DViewport: IDirect3DViewport) : HResult; stdcall;
function DeleteViewport (lpDirect3DViewport: IDirect3DViewport) : HResult; stdcall;
function NextViewport (lpDirect3DViewport: IDirect3DViewport;
var lplpDirect3DViewport: IDirect3DViewport; dwFlags: DWORD) : HResult; stdcall;
out lplpDirect3DViewport: IDirect3DViewport; dwFlags: DWORD): HResult; stdcall;
function Pick (lpDirect3DExecuteBuffer: IDirect3DExecuteBuffer;
lpDirect3DViewport: IDirect3DViewport; dwFlags: DWORD;
var lpRect: TD3DRect) : HResult; stdcall;
const lpRect: TD3DRect): HResult; stdcall;
function GetPickRecords (var lpCount: DWORD;
var lpD3DPickRec: TD3DPickRecord) : HResult; stdcall;
function EnumTextureFormats (lpd3dEnumTextureProc:
TD3DEnumTextureFormatsCallback; lpArg: Pointer) :
HResult; stdcall;
function EnumTextureFormats(lpd3dEnumTextureProc: TD3DEnumTextureFormatsCalback;
lpArg: Pointer): HResult; stdcall;
function CreateMatrix (var lpD3DMatHandle: TD3DMatrixHandle) : HResult; stdcall;
function SetMatrix (d3dMatHandle: TD3DMatrixHandle;
const lpD3DMatrix: TD3DMatrix): HResult; stdcall;
function GetMatrix(lpD3DMatHandle: TD3DMatrixHandle;
var lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
function GetMatrix (var lpD3DMatHandle: TD3DMatrixHandle;
var lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
function DeleteMatrix (d3dMatHandle: TD3DMatrixHandle) : HResult; stdcall;
function BeginScene: HResult; stdcall;
function EndScene: HResult; stdcall;
function GetDirect3D (var lpD3D: IDirect3D) : HResult; stdcall;
function GetDirect3D(out lpD3D: IDirect3D): HResult; stdcall;
end;
 
IDirect3DDevice2 = interface (IUnknown)
['{93281501-8cf8-11d0-89ab-00a0c9054129}']
(*** IDirect3DDevice2 methods ***)
['{93281501-8CF8-11D0-89AB-00A0C9054129}']
// IDirect3DDevice2 methods
function GetCaps (var lpD3DHWDevDesc: TD3DDeviceDesc;
var lpD3DHELDevDesc: TD3DDeviceDesc) : HResult; stdcall;
function SwapTextureHandles (lpD3DTex1: IDirect3DTexture2;
lpD3DTex2: IDirect3DTexture2) : HResult; stdcall;
function GetStats (var lpD3DStats: TD3DStats) : HResult; stdcall;
function AddViewport (lpDirect3DViewport2: IDirect3DViewport2) : HResult; stdcall;
function AddViewport(lpDirect3DViewport: IDirect3DViewport2): HResult; stdcall;
function DeleteViewport (lpDirect3DViewport: IDirect3DViewport2) : HResult; stdcall;
function NextViewport (lpDirect3DViewport: IDirect3DViewport2;
var lplpDirect3DViewport: IDirect3DViewport2; dwFlags: DWORD) :
HResult; stdcall;
function EnumTextureFormats (
lpd3dEnumTextureProc: TD3DEnumTextureFormatsCallback; lpArg: Pointer) :
HResult; stdcall;
out lplpDirect3DViewport: IDirect3DViewport2; dwFlags: DWORD): HResult; stdcall;
function EnumTextureFormats(lpd3dEnumTextureProc: TD3DEnumTextureFormatsCalback;
lpArg: Pointer): HResult; stdcall;
function BeginScene: HResult; stdcall;
function EndScene: HResult; stdcall;
function GetDirect3D (var lpD3D: IDirect3D2) : HResult; stdcall;
 
(*** DrawPrimitive API ***)
function SetCurrentViewport (lpd3dViewport2: IDirect3DViewport2)
: HResult; stdcall;
function GetCurrentViewport (var lplpd3dViewport2: IDirect3DViewport2)
: HResult; stdcall;
 
function SetRenderTarget (lpNewRenderTarget: IDirectDrawSurface)
: HResult; stdcall;
function GetRenderTarget (var lplpNewRenderTarget: IDirectDrawSurface)
: HResult; stdcall;
 
function GetDirect3D(out lpD3D: IDirect3D2): HResult; stdcall;
function SetCurrentViewport(lpd3dViewport2: IDirect3DViewport2): HResult; stdcall;
function GetCurrentViewport(out lplpd3dViewport2: IDirect3DViewport2): HResult; stdcall;
function SetRenderTarget(lpNewRenderTarget: IDirectDrawSurface): HResult; stdcall;
function GetRenderTarget(out lplpNewRenderTarget: IDirectDrawSurface): HResult; stdcall;
function Begin_ (d3dpt: TD3DPrimitiveType; d3dvt: TD3DVertexType;
dwFlags: DWORD) : HResult; stdcall;
function BeginIndexed (dptPrimitiveType: TD3DPrimitiveType; dvtVertexType:
TD3DVertexType; lpvVertices: pointer; dwNumVertices: DWORD;
TD3DVertexType; const lpvVertices; dwNumVertices: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function Vertex (lpVertexType: pointer) : HResult; stdcall;
function Vertex(const lpVertexType): HResult; stdcall;
function Index (wVertexIndex: WORD) : HResult; stdcall;
function End_ (dwFlags: DWORD) : HResult; stdcall;
 
function GetRenderState (dwRenderStateType: TD3DRenderStateType;
var lpdwRenderState) : HResult; stdcall;
var lpdwRenderState: DWORD): HResult; stdcall;
function SetRenderState (dwRenderStateType: TD3DRenderStateType;
dwRenderState: DWORD) : HResult; stdcall;
function GetLightState (dwLightStateType: TD3DLightStateType;
var lpdwLightState) : HResult; stdcall;
var lpdwLightState: DWORD): HResult; stdcall;
function SetLightState (dwLightStateType: TD3DLightStateType;
dwLightState: DWORD) : HResult; stdcall;
function SetTransform (dtstTransformStateType: TD3DTransformStateType;
var lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
const lpD3DMatrix: TD3DMatrix): HResult; stdcall;
function GetTransform (dtstTransformStateType: TD3DTransformStateType;
var lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
function MultiplyTransform (dtstTransformStateType: TD3DTransformStateType;
var lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
 
function DrawPrimitive (dptPrimitiveType: TD3DPrimitiveType;
dvtVertexType: TD3DVertexType; var lpvVertices; dwVertexCount,
dvtVertexType: TD3DVertexType; const lpvVertices; dwVertexCount,
dwFlags: DWORD) : HResult; stdcall;
function DrawIndexedPrimitive (dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc: DWORD; lpvVertices: pointer; dwVertexCount: DWORD;
var lpwIndices: WORD; dwIndexCount, dwFlags: DWORD) : HResult; stdcall;
function SetClipStatus (var lpD3DClipStatus: TD3DClipStatus) : HResult; stdcall;
dvtVertexType: TD3DVertexType; const lpvVertices;
dwVertexCount: DWORD; const dwIndices; dwIndexCount: DWORD;
dwFlags: DWORD): HResult; stdcall;
function SetClipStatus(const lpD3DClipStatus: TD3DClipStatus): HResult; stdcall;
function GetClipStatus (var lpD3DClipStatus: TD3DClipStatus) : HResult; stdcall;
end;
 
IDirect3DDevice3 = interface (IUnknown)
['{b0ab3b60-33d7-11d1-a981-00c04fd7b174}']
(*** IDirect3DDevice2 methods ***)
['{B0AB3B60-33D7-11D1-A981-00C04FD7B174}']
// IDirect3DDevice3 methods
function GetCaps (var lpD3DHWDevDesc: TD3DDeviceDesc;
var lpD3DHELDevDesc: TD3DDeviceDesc) : HResult; stdcall;
function GetStats (var lpD3DStats: TD3DStats) : HResult; stdcall;
8176,193 → 5297,155
function AddViewport (lpDirect3DViewport: IDirect3DViewport3) : HResult; stdcall;
function DeleteViewport (lpDirect3DViewport: IDirect3DViewport3) : HResult; stdcall;
function NextViewport (lpDirect3DViewport: IDirect3DViewport3;
var lplpAnotherViewport: IDirect3DViewport3; dwFlags: DWORD) : HResult; stdcall;
function EnumTextureFormats (
lpd3dEnumPixelProc: TD3DEnumPixelFormatsCallback; lpArg: Pointer) :
HResult; stdcall;
out lplpDirect3DViewport: IDirect3DViewport3; dwFlags: DWORD): HResult; stdcall;
function EnumTextureFormats(lpd3dEnumPixelProc: TD3DEnumPixelFormatsCallback;
lpArg: Pointer): HResult; stdcall;
function BeginScene: HResult; stdcall;
function EndScene: HResult; stdcall;
function GetDirect3D (var lpD3D: IDirect3D3) : HResult; stdcall;
function SetCurrentViewport (lpd3dViewport: IDirect3DViewport3)
: HResult; stdcall;
function GetCurrentViewport (var lplpd3dViewport: IDirect3DViewport3)
: HResult; stdcall;
function SetRenderTarget (lpNewRenderTarget: IDirectDrawSurface4)
: HResult; stdcall;
function GetRenderTarget (var lplpNewRenderTarget: IDirectDrawSurface4)
: HResult; stdcall;
function GetDirect3D(out lpD3D: IDirect3D3): HResult; stdcall;
function SetCurrentViewport(lpd3dViewport: IDirect3DViewport3): HResult; stdcall;
function GetCurrentViewport(out lplpd3dViewport: IDirect3DViewport3): HResult; stdcall;
function SetRenderTarget(lpNewRenderTarget: IDirectDrawSurface4): HResult; stdcall;
function GetRenderTarget(out lplpNewRenderTarget: IDirectDrawSurface4): HResult; stdcall;
function Begin_ (d3dpt: TD3DPrimitiveType; dwVertexTypeDesc: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function BeginIndexed (dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc: DWORD; lpvVertices: pointer; dwNumVertices: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function Vertex (lpVertex: pointer) : HResult; stdcall;
function BeginIndexed(dptPrimitiveType: TD3DPrimitiveType; dwVertexTypeDesc: DWORD;
const lpvVertices; dwNumVertices: DWORD; dwFlags: DWORD): HResult; stdcall;
function Vertex(const lpVertexType): HResult; stdcall;
function Index (wVertexIndex: WORD) : HResult; stdcall;
function End_ (dwFlags: DWORD) : HResult; stdcall;
function GetRenderState (dwRenderStateType: TD3DRenderStateType;
var lpdwRenderState) : HResult; stdcall;
var lpdwRenderState: DWORD): HResult; stdcall;
function SetRenderState (dwRenderStateType: TD3DRenderStateType;
dwRenderState: DWORD) : HResult; stdcall;
function GetLightState (dwLightStateType: TD3DLightStateType;
var lpdwLightState) : HResult; stdcall;
var lpdwLightState: DWORD): HResult; stdcall;
function SetLightState (dwLightStateType: TD3DLightStateType;
dwLightState: DWORD) : HResult; stdcall;
function SetTransform (dtstTransformStateType: TD3DTransformStateType;
var lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
const lpD3DMatrix: TD3DMatrix): HResult; stdcall;
function GetTransform (dtstTransformStateType: TD3DTransformStateType;
var lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
function MultiplyTransform (dtstTransformStateType: TD3DTransformStateType;
var lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
function DrawPrimitive (dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc: DWORD; const lpvVertices; dwVertexCount,
dwFlags: DWORD): HResult; stdcall;
function DrawIndexedPrimitive(dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc: DWORD; const lpvVertices;
dwVertexCount, dwFlags: DWORD) : HResult; stdcall;
function DrawIndexedPrimitive (dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc: DWORD; const lpvVertices; dwVertexCount: DWORD;
var lpwIndices: WORD; dwIndexCount, dwFlags: DWORD) : HResult; stdcall;
function SetClipStatus (var lpD3DClipStatus: TD3DClipStatus) : HResult; stdcall;
dwVertexCount: DWORD; const dwIndices; dwIndexCount: DWORD;
dwFlags: DWORD): HResult; stdcall;
function SetClipStatus(const lpD3DClipStatus: TD3DClipStatus): HResult; stdcall;
function GetClipStatus (var lpD3DClipStatus: TD3DClipStatus) : HResult; stdcall;
function DrawPrimitiveStrided (dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc : DWORD;
var lpVertexArray: TD3DDrawPrimitiveStridedData;
dwVertexCount, dwFlags: DWORD) : HResult; stdcall;
dwVertexTypeDesc: DWORD; const lpVertexArray;
dwVertexCount: DWORD; dwFlags: DWORD): HResult; stdcall;
function DrawIndexedPrimitiveStrided (dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc : DWORD;
var lpVertexArray: TD3DDrawPrimitiveStridedData; dwVertexCount: DWORD;
var lpwIndices: WORD; dwIndexCount, dwFlags: DWORD) : HResult; stdcall;
dwVertexTypeDesc: DWORD; const lpVertexArray;
dwVertexCount: DWORD; const lpwIndices; dwIndexCount: DWORD; dwFlags: DWORD): HResult; stdcall;
function DrawPrimitiveVB (dptPrimitiveType: TD3DPrimitiveType;
lpd3dVertexBuffer: IDirect3DVertexBuffer;
dwStartVertex, dwNumVertices, dwFlags: DWORD) : HResult; stdcall;
lpd3dVertexBuffer: IDirect3DVertexBuffer; dwStartVertex, dwNumVertices: DWORD;
dwFlags: DWORD): HResult; stdcall;
function DrawIndexedPrimitiveVB (dptPrimitiveType: TD3DPrimitiveType;
lpd3dVertexBuffer: IDirect3DVertexBuffer; var lpwIndices: WORD;
dwIndexCount, dwFlags: DWORD) : HResult; stdcall;
function ComputeSphereVisibility (var lpCenters: TD3DVector;
var lpRadii: TD3DValue; dwNumSpheres, dwFlags: DWORD;
var lpdwReturnValues: DWORD) : HResult; stdcall;
function GetTexture (dwStage: DWORD; var lplpTexture: IDirect3DTexture2)
: HResult; stdcall;
function SetTexture (dwStage: DWORD; lplpTexture: IDirect3DTexture2)
: HResult; stdcall;
function GetTextureStageState (dwStage: DWORD;
dwState: TD3DTextureStageStateType; var lpdwValue: DWORD) : HResult; stdcall;
function SetTextureStageState (dwStage: DWORD;
dwState: TD3DTextureStageStateType; lpdwValue: DWORD) : HResult; stdcall;
function ValidateDevice (var lpdwExtraPasses: DWORD) : HResult; stdcall;
lpd3dVertexBuffer: IDirect3DVertexBuffer; const lpwIndices; dwIndexCount: DWORD;
dwFlags: DWORD): HResult; stdcall;
function ComputeSphereVisibility(const lpCenters; const lpRadii;
dwNumSpheres: DWORD; dwFlags: DWORD; var lpdwReturnValues): HResult; stdcall;
function GetTexture(dwStage: DWORD; out lplpTexture: IDirect3DTexture2): HResult; stdcall;
function SetTexture(dwStage: DWORD; lpTexture: IDirect3DTexture2): HResult; stdcall;
function GetTextureStageState(dwStage: DWORD; dwState: TD3DTextureStagesStateType;
var lpdwValue: DWORD): HResult; stdcall;
function SetTextureStageState(dwStage: DWORD; dwState: TD3DTextureStagesStateType;
lpdwValue: DWORD): HResult; stdcall;
function ValidateDevice(var lpdwPasses: DWORD): HResult; stdcall;
end;
 
IDirect3DDevice7 = interface (IUnknown)
['{f5049e79-4861-11d2-a407-00a0c90629a8}']
(*** IDirect3DDevice7 methods ***)
function GetCaps(out lpD3DDevDesc: TD3DDeviceDesc7) : HResult; stdcall;
function EnumTextureFormats(lpd3dEnumPixelProc: TD3DEnumPixelFormatsCallback; lpArg: Pointer) : HResult; stdcall;
['{F5049E79-4861-11D2-A407-00A0C90629A8}']
// IDirect3DDevice7 methods
function GetCaps(var lpD3DDeviceDesc: TD3DDeviceDesc7): HResult; stdcall;
function EnumTextureFormats(lpd3dEnumPixelProc: TD3DEnumPixelFormatsCallback;
lpArg: Pointer): HResult; stdcall;
function BeginScene: HResult; stdcall;
function EndScene: HResult; stdcall;
function GetDirect3D(out lpD3D: IDirect3D7) : HResult; stdcall;
function GetDirect3D(out lplpD3D: IDirect3D7): HResult; stdcall;
function SetRenderTarget(lpNewRenderTarget: IDirectDrawSurface7; dwFlags: DWORD) : HResult; stdcall;
function GetRenderTarget(out lplpRenderTarget: IDirectDrawSurface7) : HResult; stdcall;
function Clear(dwCount: DWORD; lpRects: PD3DRect; dwFlags, dwColor: DWORD; dvZ: TD3DValue; dwStencil: DWORD) : HResult; stdcall;
function SetTransform(dtstTransformStateType: TD3DTransformStateType;
const lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
function GetTransform(dtstTransformStateType: TD3DTransformStateType;
out lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
function Clear(dwCount: DWORD; const lpRects: TD3DRect; dwFlags: DWORD; dwColor: TD3DColor;
dvZ: TD3DValue; dwStencil: DWORD): HResult; stdcall;
function SetTransform(dtstTransformStateType: TD3DTransformStateType; const lpD3DMatrix: TD3DMatrix): HResult; stdcall;
function GetTransform(dtstTransformStateType: TD3DTransformStateType; var lpD3DMatrix: TD3DMatrix): HResult; stdcall;
function SetViewport(const lpViewport: TD3DViewport7) : HResult; stdcall;
function MultiplyTransform(dtstTransformStateType: TD3DTransformStateType;
const lpD3DMatrix: TD3DMatrix) : HResult; stdcall;
function GetViewport(out lpViewport: TD3DViewport7) : HResult; stdcall;
function MultiplyTransform(dtstTransformStateType: TD3DTransformStateType; const lpD3DMatrix: TD3DMatrix): HResult; stdcall;
function GetViewport(var lpViewport: TD3DViewport7): HResult; stdcall;
function SetMaterial(const lpMaterial: TD3DMaterial7) : HResult; stdcall;
function GetMaterial(out lpMaterial: TD3DMaterial7) : HResult; stdcall;
function GetMaterial(var lpMaterial: TD3DMaterial7): HResult; stdcall;
function SetLight(dwLightIndex: DWORD; const lpLight: TD3DLight7) : HResult; stdcall;
function GetLight(dwLightIndex: DWORD; out lpLight: TD3DLight7) : HResult; stdcall;
function GetLight(dwLightIndex: DWORD; var lpLight: TD3DLight7): HResult; stdcall;
function SetRenderState(dwRenderStateType: TD3DRenderStateType; dwRenderState: DWORD) : HResult; stdcall;
function GetRenderState(dwRenderStateType: TD3DRenderStateType; out dwRenderState: DWORD) : HResult; stdcall;
function GetRenderState(dwRenderStateType: TD3DRenderStateType; var lpdwRenderState: DWORD): HResult; stdcall;
function BeginStateBlock : HResult; stdcall;
function EndStateBlock(out lpdwBlockHandle: DWORD) : HResult; stdcall;
function EndStateBlock(var lpdwBlockHandle: DWORD): HResult; stdcall;
function PreLoad(lpddsTexture: IDirectDrawSurface7) : HResult; stdcall;
function DrawPrimitive(dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc: DWORD; const lpvVertices;
dwVertexCount, dwFlags: DWORD) : HResult; stdcall;
function DrawIndexedPrimitive(dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc: DWORD; const lpvVertices; dwVertexCount: DWORD;
const lpwIndices; dwIndexCount, dwFlags: DWORD) : HResult; stdcall;
function DrawPrimitive(dptPrimitiveType: TD3DPrimitiveType; dwVertexTypeDesc: DWORD;
const lpvVertices; dwVertexCount: DWORD; dwFlags: DWORD): HResult; stdcall;
function DrawIndexedPrimitive(d3dptPrimitiveType: TD3DPrimitiveType; dwVertexTypeDesc: DWORD;
const lpvVertices; dwVertexCount: DWORD; const lpwIndices; dwIndexCount: DWORD; dwFlags: DWORD): HResult; stdcall;
function SetClipStatus(const lpD3DClipStatus: TD3DClipStatus) : HResult; stdcall;
function GetClipStatus(out lpD3DClipStatus: TD3DClipStatus) : HResult; stdcall;
function DrawPrimitiveStrided(dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc : DWORD;
const lpVertexArray: TD3DDrawPrimitiveStridedData;
dwVertexCount, dwFlags: DWORD) : HResult; stdcall;
function DrawIndexedPrimitiveStrided(dptPrimitiveType: TD3DPrimitiveType;
dwVertexTypeDesc : DWORD;
const lpVertexArray: TD3DDrawPrimitiveStridedData; dwVertexCount: DWORD;
var lpwIndices: WORD; dwIndexCount, dwFlags: DWORD) : HResult; stdcall;
function DrawPrimitiveVB(dptPrimitiveType: TD3DPrimitiveType;
lpd3dVertexBuffer: IDirect3DVertexBuffer7;
dwStartVertex, dwNumVertices, dwFlags: DWORD) : HResult; stdcall;
function DrawIndexedPrimitiveVB(dptPrimitiveType: TD3DPrimitiveType;
lpd3dVertexBuffer: IDirect3DVertexBuffer7; dwStartVertex, dwNumVertices: DWORD;
var lpwIndices: WORD; dwIndexCount, dwFlags: DWORD) : HResult; stdcall;
function ComputeSphereVisibility(const lpCenters: TD3DVector;
var lpRadii: TD3DValue; dwNumSpheres, dwFlags: DWORD;
var lpdwReturnValues: DWORD) : HResult; stdcall;
function GetClipStatus(var lpD3DClipStatus: TD3DClipStatus): HResult; stdcall;
function DrawPrimitiveStrided(dptPrimitiveType: TD3DPrimitiveType; dwVertexTypeDesc: DWORD;
const lpVertexArray; dwVertexCount: DWORD; dwFlags: DWORD): HResult; stdcall;
function DrawIndexedPrimitiveStrided(d3dptPrimitiveType: TD3DPrimitiveType; dwVertexTypeDesc: DWORD;
const lpVertexArray; dwVertexCount: DWORD; const lpwIndices; dwIndexCount: DWORD; dwFlags: DWORD): HResult; stdcall;
function DrawPrimitiveVB(d3dptPrimitiveType: TD3DPrimitiveType; lpd3dVertexBuffer: IDirect3DVertexBuffer7;
dwStartVertex: DWORD; dwNumVertices: DWORD; dwFlags: DWORD): HResult; stdcall;
function DrawIndexedPrimitiveVB(d3dptPrimitiveType: TD3DPrimitiveType; lpd3dVertexBuffer: IDirect3DVertexBuffer7;
dwStartVertex: DWORD; dwNumVertices: DWORD; const lpwIndices; dwIndexCount: DWORD; dwFlags: DWORD): HResult; stdcall;
function ComputeSphereVisibility(const lpCenters; const lpRadii; dwNumSpheres: DWORD; dwFlags: DWORD; var lpdwReturnValue): HResult; stdcall;
function GetTexture(dwStage: DWORD; out lplpTexture: IDirectDrawSurface7) : HResult; stdcall;
function SetTexture(dwStage: DWORD; lpTexture: IDirectDrawSurface7) : HResult; stdcall;
function GetTextureStageState(dwStage: DWORD;
dwState: TD3DTextureStageStateType; out lpdwValue: DWORD) : HResult; stdcall;
function SetTextureStageState(dwStage: DWORD;
dwState: TD3DTextureStageStateType; lpdwValue: DWORD) : HResult; stdcall;
function ValidateDevice(out lpdwExtraPasses: DWORD) : HResult; stdcall;
function GetTextureStageState(dwStage: DWORD; dwState: TD3DTextureStagesStateType; var lpdwValue: DWORD): HResult; stdcall;
function SetTextureStageState(dwStage: DWORD; dwState: TD3DTextureStagesStateType; dwValue: DWORD): HResult; stdcall;
function ValidateDevice(var lpdwPasses: DWORD): HResult; stdcall;
function ApplyStateBlock(dwBlockHandle: DWORD) : HResult; stdcall;
function CaptureStateBlock(dwBlockHandle: DWORD) : HResult; stdcall;
function DeleteStateBlock(dwBlockHandle: DWORD) : HResult; stdcall;
function CreateStateBlock(d3dsbType: TD3DStateBlockType; out lpdwBlockHandle: DWORD) : HResult; stdcall;
function Load(lpDestTex: IDirectDrawSurface7; lpDestPoint: PPoint;
lpSrcTex: IDirectDrawSurface7; lprcSrcRect: PRect; dwFlags: DWORD) : HResult; stdcall;
function CreateStateBlock(d3dsbType: TD3DSTATEBLOCKTYPE; var lpdwBlockHandle: DWORD): HResult; stdcall;
function Load(lpDestTex: IDirectDrawSurface7; const lpDestPoint: TPoint; lpSrcTex: IDirectDrawSurface7; const lprcSrcRect: TRect; dwFlags: DWORD): HResult; stdcall;
function LightEnable(dwLightIndex: DWORD; bEnable: BOOL) : HResult; stdcall;
function GetLightEnable(dwLightIndex: DWORD; out bEnable: BOOL) : HResult; stdcall;
function SetClipPlane(dwIndex: DWORD; var pPlaneEquation: TD3DValue) : HResult; stdcall;
function GetClipPlane(dwIndex: DWORD; out pPlaneEquation: TD3DValue) : HResult; stdcall;
function GetLightEnable(dwLightIndex: DWORD; var pbEnable: BOOL): HResult; stdcall;
function SetClipPlane(dwIndex: DWORD; const pPlaneEquation): HResult; stdcall;
function GetClipPlane(dwIndex: DWORD; var pPlaneEquation): HResult; stdcall;
function GetInfo(dwDevInfoID: DWORD; pDevInfoStruct: Pointer; dwSize: DWORD) : HResult; stdcall;
end;
(*
* Execute Buffer interface
*)
 
IDirect3DExecuteBuffer = interface (IUnknown)
['{4417C145-33AD-11CF-816F-0000C020156E}']
(*** IDirect3DExecuteBuffer methods ***)
// IDirect3DExecuteBuffer methods
function Initialize (lpDirect3DDevice: IDirect3DDevice;
var lpDesc: TD3DExecuteBufferDesc) : HResult; stdcall;
const lpDesc: TD3DExecuteBufferDesc): HResult; stdcall;
function Lock (var lpDesc: TD3DExecuteBufferDesc) : HResult; stdcall;
function Unlock: HResult; stdcall;
function SetExecuteData (var lpData: TD3DExecuteData) : HResult; stdcall;
function SetExecuteData(const lpData: TD3DExecuteData): HResult; stdcall;
function GetExecuteData (var lpData: TD3DExecuteData) : HResult; stdcall;
function Validate (var lpdwOffset: DWORD; lpFunc: TD3DValidateCallback;
lpUserArg: Pointer; dwReserved: DWORD) : HResult; stdcall;
(*** Warning! Optimize is defined differently in the header files
and the online documentation ***)
function Optimize (dwFlags: DWORD) : HResult; stdcall;
end;
 
(*
* Light interfaces
*)
 
IDirect3DLight = interface (IUnknown)
['{4417C142-33AD-11CF-816F-0000C020156E}']
(*** IDirect3DLight methods ***)
// IDirect3DLight methods
function Initialize (lpDirect3D: IDirect3D) : HResult; stdcall;
function SetLight (var lpLight: TD3DLight2) : HResult; stdcall;
function GetLight (var lpLight: TD3DLight2) : HResult; stdcall;
function SetLight(const lpLight: TD3DLight): HResult; stdcall;
function GetLight(var lpLight: TD3DLight): HResult; stdcall;
end;
 
(*
* Material interfaces
*)
 
IDirect3DMaterial = interface (IUnknown)
['{4417C144-33AD-11CF-816F-0000C020156E}']
(*** IDirect3DMaterial methods ***)
// IDirect3DMaterial methods
function Initialize (lpDirect3D: IDirect3D) : HResult; stdcall;
function SetMaterial (var lpMat: TD3DMaterial) : HResult; stdcall;
function SetMaterial(const lpMat: TD3DMaterial): HResult; stdcall;
function GetMaterial (var lpMat: TD3DMaterial) : HResult; stdcall;
function GetHandle (lpDirect3DDevice: IDirect3DDevice;
var lpHandle: TD3DMaterialHandle) : HResult; stdcall;
8371,9 → 5454,9
end;
 
IDirect3DMaterial2 = interface (IUnknown)
['{93281503-8cf8-11d0-89ab-00a0c9054129}']
(*** IDirect3DMaterial2 methods ***)
function SetMaterial (var lpMat: TD3DMaterial) : HResult; stdcall;
['{93281503-8CF8-11D0-89AB-00A0C9054129}']
// IDirect3DMaterial2 methods
function SetMaterial(const lpMat: TD3DMaterial): HResult; stdcall;
function GetMaterial (var lpMat: TD3DMaterial) : HResult; stdcall;
function GetHandle (lpDirect3DDevice: IDirect3DDevice2;
var lpHandle: TD3DMaterialHandle) : HResult; stdcall;
8380,21 → 5463,17
end;
 
IDirect3DMaterial3 = interface (IUnknown)
['{ca9c46f4-d3c5-11d1-b75a-00600852b312}']
(*** IDirect3DMaterial2 methods ***)
function SetMaterial (var lpMat: TD3DMaterial) : HResult; stdcall;
['{CA9C46F4-D3C5-11D1-B75A-00600852B312}']
// IDirect3DMaterial3 methods
function SetMaterial(const lpMat: TD3DMaterial): HResult; stdcall;
function GetMaterial (var lpMat: TD3DMaterial) : HResult; stdcall;
function GetHandle (lpDirect3DDevice: IDirect3DDevice3;
var lpHandle: TD3DMaterialHandle) : HResult; stdcall;
end;
 
(*
* Texture interfaces
*)
 
IDirect3DTexture = interface (IUnknown)
['{2CDCD9E0-25A0-11CF-A31A-00AA00B93356}']
(*** IDirect3DTexture methods ***)
// IDirect3DTexture methods
function Initialize (lpD3DDevice: IDirect3DDevice;
lpDDSurface: IDirectDrawSurface) : HResult; stdcall;
function GetHandle (lpDirect3DDevice: IDirect3DDevice;
8405,37 → 5484,31
end;
 
IDirect3DTexture2 = interface (IUnknown)
['{93281502-8cf8-11d0-89ab-00a0c9054129}']
(*** IDirect3DTexture2 methods ***)
function GetHandle (lpDirect3DDevice: IDirect3DDevice2;
['{93281502-8CF8-11D0-89AB-00A0C9054129}']
// IDirect3DTexture2 methods
function GetHandle(lpDirect3DDevice2: IDirect3DDevice2;
var lpHandle: TD3DTextureHandle) : HResult; stdcall;
function PaletteChanged (dwStart: DWORD; dwCount: DWORD) : HResult; stdcall;
function Load (lpD3DTexture: IDirect3DTexture2) : HResult; stdcall;
function Load(lpD3DTexture2: IDirect3DTexture2): HResult; stdcall;
end;
 
(*
* Viewport interfaces
*)
 
IDirect3DViewport = interface (IUnknown)
['{4417C146-33AD-11CF-816F-0000C020156E}']
(*** IDirect3DViewport methods ***)
// IDirect3DViewport methods
function Initialize (lpDirect3D: IDirect3D) : HResult; stdcall;
function GetViewport (out lpData: TD3DViewport) : HResult; stdcall;
function GetViewport(var lpData: TD3DViewport): HResult; stdcall;
function SetViewport (const lpData: TD3DViewport) : HResult; stdcall;
function TransformVertices (dwVertexCount: DWORD;
const lpData: TD3DTransformData; dwFlags: DWORD;
out lpOffscreen: DWORD) : HResult; stdcall;
var lpData: TD3DTransformData; dwFlags: DWORD;
var lpOffscreen: DWORD): HResult; stdcall;
function LightElements (dwElementCount: DWORD;
var lpData: TD3DLightData) : HResult; stdcall;
function SetBackground (hMat: TD3DMaterialHandle) : HResult; stdcall;
function GetBackground (out hMat: TD3DMaterialHandle) : HResult; stdcall;
function SetBackgroundDepth (lpDDSurface: IDirectDrawSurface) :
HResult; stdcall;
function GetBackground(hMat: TD3DMaterialHandle): HResult; stdcall;
function SetBackgroundDepth(lpDDSurface: IDirectDrawSurface): HResult; stdcall;
function GetBackgroundDepth (out lplpDDSurface: IDirectDrawSurface;
out lpValid: BOOL) : HResult; stdcall;
function Clear (dwCount: DWORD; const lpRects: TD3DRect; dwFlags: DWORD) :
HResult; stdcall;
var lpValid: BOOL): HResult; stdcall;
function Clear(dwCount: DWORD; const lpRects: TD3DRect; dwFlags: DWORD): HResult; stdcall;
function AddLight (lpDirect3DLight: IDirect3DLight) : HResult; stdcall;
function DeleteLight (lpDirect3DLight: IDirect3DLight) : HResult; stdcall;
function NextLight (lpDirect3DLight: IDirect3DLight;
8442,74 → 5515,28
out lplpDirect3DLight: IDirect3DLight; dwFlags: DWORD) : HResult; stdcall;
end;
 
IDirect3DViewport2 = interface (IUnknown)
['{93281500-8cf8-11d0-89ab-00a0c9054129}']
(*** IDirect3DViewport2 methods ***)
function Initialize (lpDirect3D: IDirect3D) : HResult; stdcall;
function GetViewport (out lpData: TD3DViewport) : HResult; stdcall;
function SetViewport (const lpData: TD3DViewport) : HResult; stdcall;
function TransformVertices (dwVertexCount: DWORD;
const lpData: TD3DTransformData; dwFlags: DWORD;
out lpOffscreen: DWORD) : HResult; stdcall;
function LightElements (dwElementCount: DWORD;
var lpData: TD3DLightData) : HResult; stdcall;
function SetBackground (hMat: TD3DMaterialHandle) : HResult; stdcall;
function GetBackground (out hMat: TD3DMaterialHandle) : HResult; stdcall;
function SetBackgroundDepth (lpDDSurface: IDirectDrawSurface) :
HResult; stdcall;
function GetBackgroundDepth (out lplpDDSurface: IDirectDrawSurface;
out lpValid: BOOL) : HResult; stdcall;
function Clear (dwCount: DWORD; const lpRects: TD3DRect; dwFlags: DWORD) :
HResult; stdcall;
function AddLight (lpDirect3DLight: IDirect3DLight) : HResult; stdcall;
function DeleteLight (lpDirect3DLight: IDirect3DLight) : HResult; stdcall;
function NextLight (lpDirect3DLight: IDirect3DLight;
out lplpDirect3DLight: IDirect3DLight; dwFlags: DWORD) : HResult; stdcall;
(*** IDirect3DViewport2 methods ***)
function GetViewport2 (out lpData: TD3DViewport2) : HResult; stdcall;
IDirect3DViewport2 = interface(IDirect3DViewport)
['{93281500-8CF8-11D0-89AB-00A0C9054129}']
// IDirect3DViewport2 methods
function GetViewport2(var lpData: TD3DViewport2): HResult; stdcall;
function SetViewport2 (const lpData: TD3DViewport2) : HResult; stdcall;
end;
 
IDirect3DViewport3 = interface (IUnknown)
['{b0ab3b61-33d7-11d1-a981-00c04fd7b174}']
(*** IDirect3DViewport3 methods ***)
function Initialize (lpDirect3D: IDirect3D) : HResult; stdcall;
function GetViewport (out lpData: TD3DViewport) : HResult; stdcall;
function SetViewport (const lpData: TD3DViewport) : HResult; stdcall;
function TransformVertices (dwVertexCount: DWORD;
const lpData: TD3DTransformData; dwFlags: DWORD;
out lpOffscreen: DWORD) : HResult; stdcall;
function LightElements (dwElementCount: DWORD;
var lpData: TD3DLightData) : HResult; stdcall;
function SetBackground (hMat: TD3DMaterialHandle) : HResult; stdcall;
function GetBackground (var hMat: TD3DMaterialHandle) : HResult; stdcall;
function SetBackgroundDepth (
lpDDSurface: IDirectDrawSurface) : HResult; stdcall;
function GetBackgroundDepth (out lplpDDSurface: IDirectDrawSurface;
out lpValid: BOOL) : HResult; stdcall;
function Clear (dwCount: DWORD; const lpRects: TD3DRect; dwFlags: DWORD) :
HResult; stdcall;
function AddLight (lpDirect3DLight: IDirect3DLight) : HResult; stdcall;
function DeleteLight (lpDirect3DLight: IDirect3DLight) : HResult; stdcall;
function NextLight (lpDirect3DLight: IDirect3DLight;
out lplpDirect3DLight: IDirect3DLight; dwFlags: DWORD) : HResult; stdcall;
function GetViewport2 (out lpData: TD3DViewport2) : HResult; stdcall;
function SetViewport2 (const lpData: TD3DViewport2) : HResult; stdcall;
function SetBackgroundDepth2 (
lpDDSurface: IDirectDrawSurface4) : HResult; stdcall;
function GetBackgroundDepth2 (out lplpDDSurface: IDirectDrawSurface4;
out lpValid: BOOL) : HResult; stdcall;
IDirect3DViewport3 = interface(IDirect3DViewport2)
['{B0AB3B61-33D7-11D1-A981-00C04FD7B174}']
// IDirect3DViewport3 methods
function SetBackgroundDepth2(lpDDS: IDirectDrawSurface4): HResult; stdcall;
function GetBackgroundDepth2(out lplpDDS: IDirectDrawSurface4; var lpValid: BOOL): HResult; stdcall;
function Clear2 (dwCount: DWORD; const lpRects: TD3DRect; dwFlags: DWORD;
dwColor: DWORD; dvZ: TD3DValue; dwStencil: DWORD) : HResult; stdcall;
end;
 
IDirect3DVertexBuffer = interface (IUnknown)
['{7a503555-4a83-11d1-a5db-00a0c90367f8}']
(*** IDirect3DVertexBuffer methods ***)
function Lock (dwFlags: DWORD; var lplpData: pointer; var lpdwSize: DWORD)
: HResult; stdcall;
['{7A503555-4A83-11D1-A5DB-00A0C90367F8}']
// IDirect3DVertexBuffer methods
function Lock(dwFlags: DWORD; var lplpData: Pointer; var lpdwSize: DWORD): HResult; stdcall;
function Unlock : HResult; stdcall;
function ProcessVertices (dwVertexOp, dwDestIndex, dwCount: DWORD;
function ProcessVertices(dwVertexOp: DWORD; dwDestIndex: DWORD; dwCount: DWORD;
lpSrcBuffer: IDirect3DVertexBuffer; dwSrcIndex: DWORD;
lpD3DDevice: IDirect3DDevice3; dwFlags: DWORD) : HResult; stdcall;
function GetVertexBufferDesc (var lpVBDesc: TD3DVertexBufferDesc) : HResult; stdcall;
8517,770 → 5544,145
end;
 
IDirect3DVertexBuffer7 = interface (IUnknown)
['{f5049e7d-4861-11d2-a407-00a0c90629a8}']
(*** IDirect3DVertexBuffer methods ***)
function Lock (dwFlags: DWORD; out lplpData: Pointer; out lpdwSize: DWORD) : HResult; stdcall;
['{F5049E7D-4861-11D2-A407-00A0C90629A8}']
// IDirect3DVertexBuffer7 methods
function Lock(dwFlags: DWORD; var lplpData: Pointer; var lpdwSize: DWORD): HResult; stdcall;
function Unlock : HResult; stdcall;
function ProcessVertices (dwVertexOp, dwDestIndex, dwCount: DWORD;
lpSrcBuffer: IDirect3DVertexBuffer7; dwSrcIndex: DWORD;
lpD3DDevice: IDirect3DDevice7; dwFlags: DWORD) : HResult; stdcall;
function GetVertexBufferDesc (out lpVBDesc: TD3DVertexBufferDesc) : HResult; stdcall;
function ProcessVertices(dwVertexOp: DWORD; dwDestIndex: DWORD; dwCount: DWORD;
lpSrcBuffer: IDirect3DVertexBuffer7; dwSrcIndex: DWORD; lpD3DDevice: IDirect3DDevice7; dwFlags: DWORD): HResult; stdcall;
function GetVertexBufferDesc(var lpVBDesc: TD3DVertexBufferDesc): HResult; stdcall;
function Optimize(lpD3DDevice: IDirect3DDevice7; dwFlags: DWORD) : HResult; stdcall;
function ProcessVerticesStrided(dwVertexOp, dwDestIndex, dwCount: DWORD;
lpVertexArray: TD3DDrawPrimitiveStridedData; dwVertexTypeDesc: DWORD;
lpD3DDevice: IDirect3DDevice7; dwFlags: DWORD) : HResult; stdcall;
function ProcessVerticesStrided(dwVertexOp: DWORD; dwDestIndex: DWORD; dwCount: DWORD;
const lpVertexArray; dwSrcIndex: DWORD; lpD3DDevice: IDirect3DDevice7; dwFlags: DWORD): HResult; stdcall;
end;
 
type
IID_IDirect3D = IDirect3D;
IID_IDirect3D2 = IDirect3D2;
IID_IDirect3D3 = IDirect3D3;
IID_IDirect3D7 = IDirect3D7;
const
 
IID_IDirect3DDevice = IDirect3DDevice;
IID_IDirect3DDevice2 = IDirect3DDevice2;
IID_IDirect3DDevice3 = IDirect3DDevice3;
IID_IDirect3DDevice7 = IDirect3DDevice7;
{ Flags for IDirect3DDevice::NextViewport }
 
IID_IDirect3DTexture = IDirect3DTexture;
IID_IDirect3DTexture2 = IDirect3DTexture2;
IID_IDirect3DLight = IDirect3DLight;
IID_IDirect3DMaterial = IDirect3DMaterial;
IID_IDirect3DMaterial2 = IDirect3DMaterial2;
IID_IDirect3DMaterial3 = IDirect3DMaterial3;
IID_IDirect3DExecuteBuffer = IDirect3DExecuteBuffer;
IID_IDirect3DViewport = IDirect3DViewport;
IID_IDirect3DViewport2 = IDirect3DViewport2;
IID_IDirect3DViewport3 = IDirect3DViewport3;
IID_IDirect3DVertexBuffer = IDirect3DVertexBuffer;
IID_IDirect3DVertexBuffer7 = IDirect3DVertexBuffer7;
 
 
const
(****************************************************************************
*
* Flags for IDirect3DDevice::NextViewport
*
****************************************************************************)
 
(*
* Return the next viewport
*)
D3DNEXT_NEXT = $00000001;
 
(*
* Return the first viewport
*)
D3DNEXT_HEAD = $00000002;
 
(*
* Return the last viewport
*)
D3DNEXT_TAIL = $00000004;
 
{ Flags for DrawPrimitive/DrawIndexedPrimitive
Also valid for Begin/BeginIndexed }
 
(****************************************************************************
*
* Flags for DrawPrimitive/DrawIndexedPrimitive
* Also valid for Begin/BeginIndexed
* Also valid for VertexBuffer::CreateVertexBuffer
****************************************************************************)
 
(*
* Wait until the device is ready to draw the primitive
* This will cause DP to not return DDERR_WASSTILLDRAWING
*)
D3DDP_WAIT = $00000001;
 
(*
* Hint that it is acceptable to render the primitive out of order.
*)
D3DDP_OUTOFORDER = $00000002;
 
(*
* Hint that the primitives have been clipped by the application.
*)
D3DDP_DONOTCLIP = $00000004;
 
(*
* Hint that the extents need not be updated.
*)
D3DDP_DONOTUPDATEEXTENTS = $00000008;
 
(*
* Hint that the lighting should not be applied on vertices.
*)
 
D3DDP_DONOTLIGHT = $00000010;
 
{ Direct3D Errors }
 
(*
* Direct3D Errors
* DirectDraw error codes are used when errors not specified here.
*)
 
const
MAKE_D3DHRESULT = HResult($88760000);
D3D_OK = HResult(DD_OK);
D3DERR_BADMAJORVERSION = HResult($88760000 + 700);
D3DERR_BADMINORVERSION = HResult($88760000 + 701);
 
D3D_OK = DD_OK;
D3DERR_BADMAJORVERSION = MAKE_D3DHRESULT + 700;
D3DERR_BADMINORVERSION = MAKE_D3DHRESULT + 701;
{ An invalid device was requested by the application. }
 
(*
* An invalid device was requested by the application.
*)
D3DERR_INVALID_DEVICE = MAKE_D3DHRESULT + 705;
D3DERR_INITFAILED = MAKE_D3DHRESULT + 706;
D3DERR_INVALID_DEVICE = HResult($88760000 + 705);
D3DERR_INITFAILED = HResult($88760000 + 706);
 
(*
* SetRenderTarget attempted on a device that was
* QI'd off the render target.
*)
D3DERR_DEVICEAGGREGATED = MAKE_D3DHRESULT + 707;
{ SetRenderTarget attempted on a device that was
QI'd off the render target. }
 
D3DERR_EXECUTE_CREATE_FAILED = MAKE_D3DHRESULT + 710;
D3DERR_EXECUTE_DESTROY_FAILED = MAKE_D3DHRESULT + 711;
D3DERR_EXECUTE_LOCK_FAILED = MAKE_D3DHRESULT + 712;
D3DERR_EXECUTE_UNLOCK_FAILED = MAKE_D3DHRESULT + 713;
D3DERR_EXECUTE_LOCKED = MAKE_D3DHRESULT + 714;
D3DERR_EXECUTE_NOT_LOCKED = MAKE_D3DHRESULT + 715;
D3DERR_DEVICEAGGREGATED = HResult($88760000 + 707);
 
D3DERR_EXECUTE_FAILED = MAKE_D3DHRESULT + 716;
D3DERR_EXECUTE_CLIPPED_FAILED = MAKE_D3DHRESULT + 717;
D3DERR_EXECUTE_CREATE_FAILED = HResult($88760000 + 710);
D3DERR_EXECUTE_DESTROY_FAILED = HResult($88760000 + 711);
D3DERR_EXECUTE_LOCK_FAILED = HResult($88760000 + 712);
D3DERR_EXECUTE_UNLOCK_FAILED = HResult($88760000 + 713);
D3DERR_EXECUTE_LOCKED = HResult($88760000 + 714);
D3DERR_EXECUTE_NOT_LOCKED = HResult($88760000 + 715);
 
D3DERR_TEXTURE_NO_SUPPORT = MAKE_D3DHRESULT + 720;
D3DERR_TEXTURE_CREATE_FAILED = MAKE_D3DHRESULT + 721;
D3DERR_TEXTURE_DESTROY_FAILED = MAKE_D3DHRESULT + 722;
D3DERR_TEXTURE_LOCK_FAILED = MAKE_D3DHRESULT + 723;
D3DERR_TEXTURE_UNLOCK_FAILED = MAKE_D3DHRESULT + 724;
D3DERR_TEXTURE_LOAD_FAILED = MAKE_D3DHRESULT + 725;
D3DERR_TEXTURE_SWAP_FAILED = MAKE_D3DHRESULT + 726;
D3DERR_TEXTURE_LOCKED = MAKE_D3DHRESULT + 727;
D3DERR_TEXTURE_NOT_LOCKED = MAKE_D3DHRESULT + 728;
D3DERR_TEXTURE_GETSURF_FAILED = MAKE_D3DHRESULT + 729;
D3DERR_EXECUTE_FAILED = HResult($88760000 + 716);
D3DERR_EXECUTE_CLIPPED_FAILED = HResult($88760000 + 717);
 
D3DERR_MATRIX_CREATE_FAILED = MAKE_D3DHRESULT + 730;
D3DERR_MATRIX_DESTROY_FAILED = MAKE_D3DHRESULT + 731;
D3DERR_MATRIX_SETDATA_FAILED = MAKE_D3DHRESULT + 732;
D3DERR_MATRIX_GETDATA_FAILED = MAKE_D3DHRESULT + 733;
D3DERR_SETVIEWPORTDATA_FAILED = MAKE_D3DHRESULT + 734;
D3DERR_TEXTURE_NO_SUPPORT = HResult($88760000 + 720);
D3DERR_TEXTURE_CREATE_FAILED = HResult($88760000 + 721);
D3DERR_TEXTURE_DESTROY_FAILED = HResult($88760000 + 722);
D3DERR_TEXTURE_LOCK_FAILED = HResult($88760000 + 723);
D3DERR_TEXTURE_UNLOCK_FAILED = HResult($88760000 + 724);
D3DERR_TEXTURE_LOAD_FAILED = HResult($88760000 + 725);
D3DERR_TEXTURE_SWAP_FAILED = HResult($88760000 + 726);
D3DERR_TEXTURE_LOCKED = HResult($88760000 + 727);
D3DERR_TEXTURE_NOT_LOCKED = HResult($88760000 + 728);
D3DERR_TEXTURE_GETSURF_FAILED = HResult($88760000 + 729);
 
D3DERR_INVALIDCURRENTVIEWPORT = MAKE_D3DHRESULT + 735;
D3DERR_INVALIDPRIMITIVETYPE = MAKE_D3DHRESULT + 736;
D3DERR_INVALIDVERTEXTYPE = MAKE_D3DHRESULT + 737;
D3DERR_TEXTURE_BADSIZE = MAKE_D3DHRESULT + 738;
D3DERR_INVALIDRAMPTEXTURE = MAKE_D3DHRESULT + 739;
D3DERR_MATRIX_CREATE_FAILED = HResult($88760000 + 730);
D3DERR_MATRIX_DESTROY_FAILED = HResult($88760000 + 731);
D3DERR_MATRIX_SETDATA_FAILED = HResult($88760000 + 732);
D3DERR_MATRIX_GETDATA_FAILED = HResult($88760000 + 733);
D3DERR_SETVIEWPORTDATA_FAILED = HResult($88760000 + 734);
 
D3DERR_MATERIAL_CREATE_FAILED = MAKE_D3DHRESULT + 740;
D3DERR_MATERIAL_DESTROY_FAILED = MAKE_D3DHRESULT + 741;
D3DERR_MATERIAL_SETDATA_FAILED = MAKE_D3DHRESULT + 742;
D3DERR_MATERIAL_GETDATA_FAILED = MAKE_D3DHRESULT + 743;
D3DERR_INVALIDCURRENTVIEWPORT = HResult($88760000 + 735);
D3DERR_INVALIDPRIMITIVETYPE = HResult($88760000 + 736);
D3DERR_INVALIDVERTEXTYPE = HResult($88760000 + 737);
D3DERR_TEXTURE_BADSIZE = HResult($88760000 + 738);
D3DERR_INVALIDRAMPTEXTURE = HResult($88760000 + 739);
 
D3DERR_INVALIDPALETTE = MAKE_D3DHRESULT + 744;
D3DERR_MATERIAL_CREATE_FAILED = HResult($88760000 + 740);
D3DERR_MATERIAL_DESTROY_FAILED = HResult($88760000 + 741);
D3DERR_MATERIAL_SETDATA_FAILED = HResult($88760000 + 742);
D3DERR_MATERIAL_GETDATA_FAILED = HResult($88760000 + 743);
 
D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY = MAKE_D3DHRESULT + 745;
D3DERR_ZBUFF_NEEDS_VIDEOMEMORY = MAKE_D3DHRESULT + 746;
D3DERR_SURFACENOTINVIDMEM = MAKE_D3DHRESULT + 747;
D3DERR_INVALIDPALETTE = HResult($88760000 + 744);
 
D3DERR_LIGHT_SET_FAILED = MAKE_D3DHRESULT + 750;
D3DERR_LIGHTHASVIEWPORT = MAKE_D3DHRESULT + 751;
D3DERR_LIGHTNOTINTHISVIEWPORT = MAKE_D3DHRESULT + 752;
D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY = HResult($88760000 + 745);
D3DERR_ZBUFF_NEEDS_VIDEOMEMORY = HResult($88760000 + 746);
D3DERR_SURFACENOTINVIDMEM = HResult($88760000 + 747);
 
D3DERR_SCENE_IN_SCENE = MAKE_D3DHRESULT + 760;
D3DERR_SCENE_NOT_IN_SCENE = MAKE_D3DHRESULT + 761;
D3DERR_SCENE_BEGIN_FAILED = MAKE_D3DHRESULT + 762;
D3DERR_SCENE_END_FAILED = MAKE_D3DHRESULT + 763;
D3DERR_LIGHT_SET_FAILED = HResult($88760000 + 750);
D3DERR_LIGHTHASVIEWPORT = HResult($88760000 + 751);
D3DERR_LIGHTNOTINTHISVIEWPORT = HResult($88760000 + 752);
 
D3DERR_INBEGIN = MAKE_D3DHRESULT + 770;
D3DERR_NOTINBEGIN = MAKE_D3DHRESULT + 771;
D3DERR_NOVIEWPORTS = MAKE_D3DHRESULT + 772;
D3DERR_VIEWPORTDATANOTSET = MAKE_D3DHRESULT + 773;
D3DERR_VIEWPORTHASNODEVICE = MAKE_D3DHRESULT + 774;
D3DERR_NOCURRENTVIEWPORT = MAKE_D3DHRESULT + 775;
D3DERR_SCENE_IN_SCENE = HResult($88760000 + 760);
D3DERR_SCENE_NOT_IN_SCENE = HResult($88760000 + 761);
D3DERR_SCENE_BEGIN_FAILED = HResult($88760000 + 762);
D3DERR_SCENE_END_FAILED = HResult($88760000 + 763);
 
D3DERR_INVALIDVERTEXFORMAT = MAKE_D3DHRESULT + 2048;
D3DERR_INBEGIN = HResult($88760000 + 770);
D3DERR_NOTINBEGIN = HResult($88760000 + 771);
D3DERR_NOVIEWPORTS = HResult($88760000 + 772);
D3DERR_VIEWPORTDATANOTSET = HResult($88760000 + 773);
D3DERR_VIEWPORTHASNODEVICE = HResult($88760000 + 774);
D3DERR_NOCURRENTVIEWPORT = HResult($88760000 + 775);
 
(*
* Attempted to CreateTexture on a surface that had a color key
*)
D3DERR_COLORKEYATTACHED = MAKE_D3DHRESULT + 2050;
D3DERR_INVALIDVERTEXFORMAT = HResult($88760000 + 2048);
 
D3DERR_VERTEXBUFFEROPTIMIZED = MAKE_D3DHRESULT + 2060;
D3DERR_VBUF_CREATE_FAILED = MAKE_D3DHRESULT + 2061;
D3DERR_VERTEXBUFFERLOCKED = MAKE_D3DHRESULT + 2062;
D3DERR_COLORKEYATTACHED = HResult($88760000 + 2050);
 
D3DERR_ZBUFFER_NOTPRESENT = MAKE_D3DHRESULT + 2070;
D3DERR_STENCILBUFFER_NOTPRESENT = MAKE_D3DHRESULT + 2071;
D3DERR_VERTEXBUFFEROPTIMIZED = HResult($88760000 + 2060);
D3DERR_VBUF_CREATE_FAILED = HResult($88760000 + 2061);
D3DERR_VERTEXBUFFERLOCKED = HResult($88760000 + 2062);
D3DERR_VERTEXBUFFERUNLOCKFAILED = HResult($88760000 + 2063);
 
D3DERR_WRONGTEXTUREFORMAT = MAKE_D3DHRESULT + 2072;
D3DERR_UNSUPPORTEDCOLOROPERATION = MAKE_D3DHRESULT + 2073;
D3DERR_UNSUPPORTEDCOLORARG = MAKE_D3DHRESULT + 2074;
D3DERR_UNSUPPORTEDALPHAOPERATION = MAKE_D3DHRESULT + 2075;
D3DERR_UNSUPPORTEDALPHAARG = MAKE_D3DHRESULT + 2076;
D3DERR_TOOMANYOPERATIONS = MAKE_D3DHRESULT + 2077;
D3DERR_CONFLICTINGTEXTUREFILTER = MAKE_D3DHRESULT + 2078;
D3DERR_UNSUPPORTEDFACTORVALUE = MAKE_D3DHRESULT + 2079;
D3DERR_CONFLICTINGRENDERSTATE = MAKE_D3DHRESULT + 2081;
D3DERR_UNSUPPORTEDTEXTUREFILTER = MAKE_D3DHRESULT + 2082;
D3DERR_TOOMANYPRIMITIVES = MAKE_D3DHRESULT + 2083;
D3DERR_INVALIDMATRIX = MAKE_D3DHRESULT + 2084;
D3DERR_TOOMANYVERTICES = MAKE_D3DHRESULT + 2085;
D3DERR_CONFLICTINGTEXTUREPALETTE = MAKE_D3DHRESULT + 2086;
D3DERR_ZBUFFER_NOTPRESENT = HResult($88760000 + 2070);
D3DERR_STENCILBUFFER_NOTPRESENT = HResult($88760000 + 2071);
 
D3DERR_INVALIDSTATEBLOCK = MAKE_D3DHRESULT + 2100;
D3DERR_INBEGINSTATEBLOCK = MAKE_D3DHRESULT + 2101;
D3DERR_NOTINBEGINSTATEBLOCK = MAKE_D3DHRESULT + 2102;
D3DERR_WRONGTEXTUREFORMAT = HResult($88760000 + 2072);
D3DERR_UNSUPPORTEDCOLOROPERATION = HResult($88760000 + 2073);
D3DERR_UNSUPPORTEDCOLORARG = HResult($88760000 + 2074);
D3DERR_UNSUPPORTEDALPHAOPERATION = HResult($88760000 + 2075);
D3DERR_UNSUPPORTEDALPHAARG = HResult($88760000 + 2076);
D3DERR_TOOMANYOPERATIONS = HResult($88760000 + 2077);
D3DERR_CONFLICTINGTEXTUREFILTER = HResult($88760000 + 2078);
D3DERR_UNSUPPORTEDFACTORVALUE = HResult($88760000 + 2079);
D3DERR_CONFLICTINGRENDERSTATE = HResult($88760000 + 2081);
D3DERR_UNSUPPORTEDTEXTUREFILTER = HResult($88760000 + 2082);
D3DERR_TOOMANYPRIMITIVES = HResult($88760000 + 2083);
D3DERR_INVALIDMATRIX = HResult($88760000 + 2084);
D3DERR_TOOMANYVERTICES = HResult($88760000 + 2085);
D3DERR_CONFLICTINGTEXTUREPALETTE = HResult($88760000 + 2086);
 
procedure DisableFPUExceptions;
procedure EnableFPUExceptions;
D3DERR_INVALIDSTATEBLOCK = HResult($88760000 + 2100);
D3DERR_INBEGINSTATEBLOCK = HResult($88760000 + 2101);
D3DERR_NOTINBEGINSTATEBLOCK = HResult($88760000 + 2102);
 
(***************************************************************************
*
* Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved.
*
* File: dxfile.h
*
* Content: DirectX File public header file
*
***************************************************************************)
 
var
DXFileDLL : HMODULE;
 
function DXFileErrorString(Value: HResult) : string;
 
type
TDXFileFormat = (
DXFILEFORMAT_BINARY,
DXFILEFORMAT_TEXT,
DXFILEFORMAT_COMPRESSED
);
 
TDXFileLoadOptions = (
DXFILELOAD_FROMFILE,
DXFILELOAD_FROMRESOURCE,
DXFILELOAD_FROMMEMORY,
DXFILELOAD_INVALID_3,
DXFILELOAD_FROMSTREAM,
DXFILELOAD_INVALID_5,
DXFILELOAD_INVALID_6,
DXFILELOAD_INVALID_7,
DXFILELOAD_FROMURL
);
 
PDXFileLoadResource = ^TDXFileLoadResource;
TDXFileLoadResource = packed record
hModule: HModule;
lpName: PAnsiChar;
lpType: PAnsiChar;
end;
 
PDXFileLoadMemory = ^TDXFileLoadMemory;
TDXFileLoadMemory = packed record
lpMemory: Pointer;
dSize: DWORD;
end;
 
(*
* DirectX File object types.
*)
 
IDirectXFile = interface;
IDirectXFileEnumObject = interface;
IDirectXFileSaveObject = interface;
IDirectXFileObject = interface;
IDirectXFileData = interface;
IDirectXFileDataReference = interface;
IDirectXFileBinary = interface;
 
(*
* DirectX File interfaces.
*)
 
IDirectXFile = interface (IUnknown)
['{3d82ab40-62da-11cf-ab39-0020af71e433}']
function CreateEnumObject (pvSource: Pointer;
dwLoadOptions: TDXFileLoadOptions;
var ppEnumObj: IDirectXFileEnumObject) : HResult; stdcall;
function CreateSaveObject (szFileName: PChar; dwFileFormat: TDXFileFormat;
var ppSaveObj: IDirectXFileSaveObject) : HResult; stdcall;
function RegisterTemplates (pvData: Pointer; cbSize: DWORD) : HResult; stdcall;
end;
 
IDirectXFileEnumObject = interface (IUnknown)
['{3d82ab41-62da-11cf-ab39-0020af71e433}']
function GetNextDataObject (var ppDataObj: IDirectXFileData) : HResult; stdcall;
function GetDataObjectById
(const rguid: TGUID; var ppDataObj: IDirectXFileData) : HResult; stdcall;
function GetDataObjectByName
(szName: PChar; var ppDataObj: IDirectXFileData) : HResult; stdcall;
end;
 
IDirectXFileSaveObject = interface (IUnknown)
['{3d82ab42-62da-11cf-ab39-0020af71e433}']
function SaveTemplates
(cTemplates: DWORD; var ppguidTemplates: PGUID) : HResult; stdcall;
function CreateDataObject (const rguidTemplate: TGUID; szName: PChar;
pguid: PGUID; cbSize: DWORD; pvData: Pointer;
var ppDataObj: IDirectXFileData) : HResult; stdcall;
function SaveData (pDataObj: IDirectXFileData) : HResult; stdcall;
end;
 
IDirectXFileObject = interface (IUnknown)
['{3d82ab43-62da-11cf-ab39-0020af71e433}']
function GetName (pstrNameBuf: PChar; var dwBufLen: DWORD) : HResult; stdcall;
function GetId (var pGuidBuf: TGUID) : HResult; stdcall;
end;
 
IDirectXFileData = interface (IDirectXFileObject)
['{3d82ab44-62da-11cf-ab39-0020af71e433}']
function GetData
(szMember: PChar; var pcbSize: DWORD; var ppvData: Pointer) : HResult; stdcall;
function GetType (var ppguid: PGUID) : HResult; stdcall;
function GetNextObject (var ppChildObj: IDirectXFileObject) : HResult; stdcall;
function AddDataObject (pDataObj: IDirectXFileData) : HResult; stdcall;
function AddDataReference (szRef: PChar; pguidRef: PGUID) : HResult; stdcall;
function AddBinaryObject (szName: PChar; pguid: PGUID; szMimeType: PChar;
pvData: Pointer; cbSize: DWORD) : HResult; stdcall;
end;
 
IDirectXFileDataReference = interface (IDirectXFileObject)
['{3d82ab45-62da-11cf-ab39-0020af71e433}']
function Resolve (var ppDataObj: IDirectXFileData) : HResult; stdcall;
end;
 
IDirectXFileBinary = interface (IDirectXFileObject)
['{3d82ab46-62da-11cf-ab39-0020af71e433}']
function GetSize (var pcbSize: DWORD) : HResult; stdcall;
function GetMimeType (var pszMimeType: PChar) : HResult; stdcall;
function Read(pvData: Pointer; cbSize: DWORD; pcbRead: PDWORD{?}) : HResult; stdcall;
end;
 
const
 
(*
* DirectXFile Object Class Id (for CoCreateInstance())
*)
 
CLSID_CDirectXFile: TGUID =
(D1:$4516ec43;D2:$8f20;D3:$11d0;D4:($9b,$6d,$00,$00,$c0,$78,$1b,$c3));
 
(*
* DirectX File Interface GUIDs.
*)
 
type
IID_IDirectXFile = IDirectXFile;
IID_IDirectXFileEnumObject = IDirectXFileEnumObject;
IID_IDirectXFileSaveObject = IDirectXFileSaveObject;
IID_IDirectXFileObject = IDirectXFileObject;
IID_IDirectXFileData = IDirectXFileData;
IID_IDirectXFileDataReference = IDirectXFileDataReference;
IID_IDirectXFileBinary = IDirectXFileBinary;
 
(*
* DirectX File Header template's GUID.
*)
const
TID_DXFILEHeader: TGUID =
(D1:$3d82ab43;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
 
(*
* DirectX File errors.
*)
 
const
DXFILE_OK = 0;
 
DXFILEERR_BADOBJECT = MAKE_D3DHRESULT or 850;
DXFILEERR_BADVALUE = MAKE_D3DHRESULT or 851;
DXFILEERR_BADTYPE = MAKE_D3DHRESULT or 852;
DXFILEERR_BADSTREAMHANDLE = MAKE_D3DHRESULT or 853;
DXFILEERR_BADALLOC = MAKE_D3DHRESULT or 854;
DXFILEERR_NOTFOUND = MAKE_D3DHRESULT or 855;
DXFILEERR_NOTDONEYET = MAKE_D3DHRESULT or 856;
DXFILEERR_FILENOTFOUND = MAKE_D3DHRESULT or 857;
DXFILEERR_RESOURCENOTFOUND = MAKE_D3DHRESULT or 858;
DXFILEERR_URLNOTFOUND = MAKE_D3DHRESULT or 859;
DXFILEERR_BADRESOURCE = MAKE_D3DHRESULT or 860;
DXFILEERR_BADFILETYPE = MAKE_D3DHRESULT or 861;
DXFILEERR_BADFILEVERSION = MAKE_D3DHRESULT or 862;
DXFILEERR_BADFILEFLOATSIZE = MAKE_D3DHRESULT or 863;
DXFILEERR_BADFILECOMPRESSIONTYPE = MAKE_D3DHRESULT or 864;
DXFILEERR_BADFILE = MAKE_D3DHRESULT or 865;
DXFILEERR_PARSEERROR = MAKE_D3DHRESULT or 866;
DXFILEERR_NOTEMPLATE = MAKE_D3DHRESULT or 867;
DXFILEERR_BADARRAYSIZE = MAKE_D3DHRESULT or 868;
DXFILEERR_BADDATAREFERENCE = MAKE_D3DHRESULT or 869;
DXFILEERR_INTERNALERROR = MAKE_D3DHRESULT or 870;
DXFILEERR_NOMOREOBJECTS = MAKE_D3DHRESULT or 871;
DXFILEERR_BADINTRINSICS = MAKE_D3DHRESULT or 872;
DXFILEERR_NOMORESTREAMHANDLES = MAKE_D3DHRESULT or 873;
DXFILEERR_NOMOREDATA = MAKE_D3DHRESULT or 874;
DXFILEERR_BADCACHEFILE = MAKE_D3DHRESULT or 875;
DXFILEERR_NOINTERNET = MAKE_D3DHRESULT or 876;
 
{$IFDEF D3DRM}
(*
* API for creating IDirectXFile interface.
*)
 
var
DirectXFileCreate : function
(out lplpDirectXFile: IDirectXFile) : HResult; stdcall;
 
(* D3DRM XFile templates in binary form *)
const
D3DRM_XTEMPLATE_BYTES = 3215;
D3DRM_XTEMPLATES: array [0..D3DRM_XTEMPLATE_BYTES-1] of byte = (
$78, $6f, $66, $20, $30, $33, $30, $32, $62,
$69, $6e, $20, $30, $30, $36, $34, $1f, 0, $1,
0, $6, 0, 0, 0, $48, $65, $61, $64, $65,
$72, $a, 0, $5, 0, $43, $ab, $82, $3d, $da,
$62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4,
$33, $28, 0, $1, 0, $5, 0, 0, 0, $6d,
$61, $6a, $6f, $72, $14, 0, $28, 0, $1, 0,
$5, 0, 0, 0, $6d, $69, $6e, $6f, $72, $14,
0, $29, 0, $1, 0, $5, 0, 0, 0, $66,
$6c, $61, $67, $73, $14, 0, $b, 0, $1f, 0,
$1, 0, $6, 0, 0, 0, $56, $65, $63, $74,
$6f, $72, $a, 0, $5, 0, $5e, $ab, $82, $3d,
$da, $62, $cf, $11, $ab, $39, 0, $20, $af, $71,
$e4, $33, $2a, 0, $1, 0, $1, 0, 0, 0,
$78, $14, 0, $2a, 0, $1, 0, $1, 0, 0,
0, $79, $14, 0, $2a, 0, $1, 0, $1, 0,
0, 0, $7a, $14, 0, $b, 0, $1f, 0, $1,
0, $8, 0, 0, 0, $43, $6f, $6f, $72, $64,
$73, $32, $64, $a, 0, $5, 0, $44, $3f, $f2,
$f6, $86, $76, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $2a, 0, $1, 0, $1, 0, 0,
0, $75, $14, 0, $2a, 0, $1, 0, $1, 0,
0, 0, $76, $14, 0, $b, 0, $1f, 0, $1,
0, $9, 0, 0, 0, $4d, $61, $74, $72, $69,
$78, $34, $78, $34, $a, 0, $5, 0, $45, $3f,
$f2, $f6, $86, $76, $cf, $11, $8f, $52, 0, $40,
$33, $35, $94, $a3, $34, 0, $2a, 0, $1, 0,
$6, 0, 0, 0, $6d, $61, $74, $72, $69, $78,
$e, 0, $3, 0, $10, 0, 0, 0, $f, 0,
$14, 0, $b, 0, $1f, 0, $1, 0, $9, 0,
0, 0, $43, $6f, $6c, $6f, $72, $52, $47, $42,
$41, $a, 0, $5, 0, $e0, $44, $ff, $35, $7c,
$6c, $cf, $11, $8f, $52, 0, $40, $33, $35, $94,
$a3, $2a, 0, $1, 0, $3, 0, 0, 0, $72,
$65, $64, $14, 0, $2a, 0, $1, 0, $5, 0,
0, 0, $67, $72, $65, $65, $6e, $14, 0, $2a,
0, $1, 0, $4, 0, 0, 0, $62, $6c, $75,
$65, $14, 0, $2a, 0, $1, 0, $5, 0, 0,
0, $61, $6c, $70, $68, $61, $14, 0, $b, 0,
$1f, 0, $1, 0, $8, 0, 0, 0, $43, $6f,
$6c, $6f, $72, $52, $47, $42, $a, 0, $5, 0,
$81, $6e, $e1, $d3, $35, $78, $cf, $11, $8f, $52,
0, $40, $33, $35, $94, $a3, $2a, 0, $1, 0,
$3, 0, 0, 0, $72, $65, $64, $14, 0, $2a,
0, $1, 0, $5, 0, 0, 0, $67, $72, $65,
$65, $6e, $14, 0, $2a, 0, $1, 0, $4, 0,
0, 0, $62, $6c, $75, $65, $14, 0, $b, 0,
$1f, 0, $1, 0, $c, 0, 0, 0, $49, $6e,
$64, $65, $78, $65, $64, $43, $6f, $6c, $6f, $72,
$a, 0, $5, 0, $20, $b8, $30, $16, $42, $78,
$cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3,
$29, 0, $1, 0, $5, 0, 0, 0, $69, $6e,
$64, $65, $78, $14, 0, $1, 0, $9, 0, 0,
0, $43, $6f, $6c, $6f, $72, $52, $47, $42, $41,
$1, 0, $a, 0, 0, 0, $69, $6e, $64, $65,
$78, $43, $6f, $6c, $6f, $72, $14, 0, $b, 0,
$1f, 0, $1, 0, $7, 0, 0, 0, $42, $6f,
$6f, $6c, $65, $61, $6e, $a, 0, $5, 0, $a0,
$a6, $7d, $53, $37, $ca, $d0, $11, $94, $1c, 0,
$80, $c8, $c, $fa, $7b, $29, 0, $1, 0, $9,
0, 0, 0, $74, $72, $75, $65, $66, $61, $6c,
$73, $65, $14, 0, $b, 0, $1f, 0, $1, 0,
$9, 0, 0, 0, $42, $6f, $6f, $6c, $65, $61,
$6e, $32, $64, $a, 0, $5, 0, $63, $ae, $85,
$48, $e8, $78, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $1, 0, $7, 0, 0, 0, $42,
$6f, $6f, $6c, $65, $61, $6e, $1, 0, $1, 0,
0, 0, $75, $14, 0, $1, 0, $7, 0, 0,
0, $42, $6f, $6f, $6c, $65, $61, $6e, $1, 0,
$1, 0, 0, 0, $76, $14, 0, $b, 0, $1f,
0, $1, 0, $c, 0, 0, 0, $4d, $61, $74,
$65, $72, $69, $61, $6c, $57, $72, $61, $70, $a,
0, $5, 0, $60, $ae, $85, $48, $e8, $78, $cf,
$11, $8f, $52, 0, $40, $33, $35, $94, $a3, $1,
0, $7, 0, 0, 0, $42, $6f, $6f, $6c, $65,
$61, $6e, $1, 0, $1, 0, 0, 0, $75, $14,
0, $1, 0, $7, 0, 0, 0, $42, $6f, $6f,
$6c, $65, $61, $6e, $1, 0, $1, 0, 0, 0,
$76, $14, 0, $b, 0, $1f, 0, $1, 0, $f,
0, 0, 0, $54, $65, $78, $74, $75, $72, $65,
$46, $69, $6c, $65, $6e, $61, $6d, $65, $a, 0,
$5, 0, $e1, $90, $27, $a4, $10, $78, $cf, $11,
$8f, $52, 0, $40, $33, $35, $94, $a3, $31, 0,
$1, 0, $8, 0, 0, 0, $66, $69, $6c, $65,
$6e, $61, $6d, $65, $14, 0, $b, 0, $1f, 0,
$1, 0, $8, 0, 0, 0, $4d, $61, $74, $65,
$72, $69, $61, $6c, $a, 0, $5, 0, $4d, $ab,
$82, $3d, $da, $62, $cf, $11, $ab, $39, 0, $20,
$af, $71, $e4, $33, $1, 0, $9, 0, 0, 0,
$43, $6f, $6c, $6f, $72, $52, $47, $42, $41, $1,
0, $9, 0, 0, 0, $66, $61, $63, $65, $43,
$6f, $6c, $6f, $72, $14, 0, $2a, 0, $1, 0,
$5, 0, 0, 0, $70, $6f, $77, $65, $72, $14,
0, $1, 0, $8, 0, 0, 0, $43, $6f, $6c,
$6f, $72, $52, $47, $42, $1, 0, $d, 0, 0,
0, $73, $70, $65, $63, $75, $6c, $61, $72, $43,
$6f, $6c, $6f, $72, $14, 0, $1, 0, $8, 0,
0, 0, $43, $6f, $6c, $6f, $72, $52, $47, $42,
$1, 0, $d, 0, 0, 0, $65, $6d, $69, $73,
$73, $69, $76, $65, $43, $6f, $6c, $6f, $72, $14,
0, $e, 0, $12, 0, $12, 0, $12, 0, $f,
0, $b, 0, $1f, 0, $1, 0, $8, 0, 0,
0, $4d, $65, $73, $68, $46, $61, $63, $65, $a,
0, $5, 0, $5f, $ab, $82, $3d, $da, $62, $cf,
$11, $ab, $39, 0, $20, $af, $71, $e4, $33, $29,
0, $1, 0, $12, 0, 0, 0, $6e, $46, $61,
$63, $65, $56, $65, $72, $74, $65, $78, $49, $6e,
$64, $69, $63, $65, $73, $14, 0, $34, 0, $29,
0, $1, 0, $11, 0, 0, 0, $66, $61, $63,
$65, $56, $65, $72, $74, $65, $78, $49, $6e, $64,
$69, $63, $65, $73, $e, 0, $1, 0, $12, 0,
0, 0, $6e, $46, $61, $63, $65, $56, $65, $72,
$74, $65, $78, $49, $6e, $64, $69, $63, $65, $73,
$f, 0, $14, 0, $b, 0, $1f, 0, $1, 0,
$d, 0, 0, 0, $4d, $65, $73, $68, $46, $61,
$63, $65, $57, $72, $61, $70, $73, $a, 0, $5,
0, $c0, $c5, $1e, $ed, $a8, $c0, $d0, $11, $94,
$1c, 0, $80, $c8, $c, $fa, $7b, $29, 0, $1,
0, $f, 0, 0, 0, $6e, $46, $61, $63, $65,
$57, $72, $61, $70, $56, $61, $6c, $75, $65, $73,
$14, 0, $34, 0, $1, 0, $9, 0, 0, 0,
$42, $6f, $6f, $6c, $65, $61, $6e, $32, $64, $1,
0, $e, 0, 0, 0, $66, $61, $63, $65, $57,
$72, $61, $70, $56, $61, $6c, $75, $65, $73, $e,
0, $1, 0, $f, 0, 0, 0, $6e, $46, $61,
$63, $65, $57, $72, $61, $70, $56, $61, $6c, $75,
$65, $73, $f, 0, $14, 0, $b, 0, $1f, 0,
$1, 0, $11, 0, 0, 0, $4d, $65, $73, $68,
$54, $65, $78, $74, $75, $72, $65, $43, $6f, $6f,
$72, $64, $73, $a, 0, $5, 0, $40, $3f, $f2,
$f6, $86, $76, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $29, 0, $1, 0, $e, 0, 0,
0, $6e, $54, $65, $78, $74, $75, $72, $65, $43,
$6f, $6f, $72, $64, $73, $14, 0, $34, 0, $1,
0, $8, 0, 0, 0, $43, $6f, $6f, $72, $64,
$73, $32, $64, $1, 0, $d, 0, 0, 0, $74,
$65, $78, $74, $75, $72, $65, $43, $6f, $6f, $72,
$64, $73, $e, 0, $1, 0, $e, 0, 0, 0,
$6e, $54, $65, $78, $74, $75, $72, $65, $43, $6f,
$6f, $72, $64, $73, $f, 0, $14, 0, $b, 0,
$1f, 0, $1, 0, $10, 0, 0, 0, $4d, $65,
$73, $68, $4d, $61, $74, $65, $72, $69, $61, $6c,
$4c, $69, $73, $74, $a, 0, $5, 0, $42, $3f,
$f2, $f6, $86, $76, $cf, $11, $8f, $52, 0, $40,
$33, $35, $94, $a3, $29, 0, $1, 0, $a, 0,
0, 0, $6e, $4d, $61, $74, $65, $72, $69, $61,
$6c, $73, $14, 0, $29, 0, $1, 0, $c, 0,
0, 0, $6e, $46, $61, $63, $65, $49, $6e, $64,
$65, $78, $65, $73, $14, 0, $34, 0, $29, 0,
$1, 0, $b, 0, 0, 0, $66, $61, $63, $65,
$49, $6e, $64, $65, $78, $65, $73, $e, 0, $1,
0, $c, 0, 0, 0, $6e, $46, $61, $63, $65,
$49, $6e, $64, $65, $78, $65, $73, $f, 0, $14,
0, $e, 0, $1, 0, $8, 0, 0, 0, $4d,
$61, $74, $65, $72, $69, $61, $6c, $f, 0, $b,
0, $1f, 0, $1, 0, $b, 0, 0, 0, $4d,
$65, $73, $68, $4e, $6f, $72, $6d, $61, $6c, $73,
$a, 0, $5, 0, $43, $3f, $f2, $f6, $86, $76,
$cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3,
$29, 0, $1, 0, $8, 0, 0, 0, $6e, $4e,
$6f, $72, $6d, $61, $6c, $73, $14, 0, $34, 0,
$1, 0, $6, 0, 0, 0, $56, $65, $63, $74,
$6f, $72, $1, 0, $7, 0, 0, 0, $6e, $6f,
$72, $6d, $61, $6c, $73, $e, 0, $1, 0, $8,
0, 0, 0, $6e, $4e, $6f, $72, $6d, $61, $6c,
$73, $f, 0, $14, 0, $29, 0, $1, 0, $c,
0, 0, 0, $6e, $46, $61, $63, $65, $4e, $6f,
$72, $6d, $61, $6c, $73, $14, 0, $34, 0, $1,
0, $8, 0, 0, 0, $4d, $65, $73, $68, $46,
$61, $63, $65, $1, 0, $b, 0, 0, 0, $66,
$61, $63, $65, $4e, $6f, $72, $6d, $61, $6c, $73,
$e, 0, $1, 0, $c, 0, 0, 0, $6e, $46,
$61, $63, $65, $4e, $6f, $72, $6d, $61, $6c, $73,
$f, 0, $14, 0, $b, 0, $1f, 0, $1, 0,
$10, 0, 0, 0, $4d, $65, $73, $68, $56, $65,
$72, $74, $65, $78, $43, $6f, $6c, $6f, $72, $73,
$a, 0, $5, 0, $21, $b8, $30, $16, $42, $78,
$cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3,
$29, 0, $1, 0, $d, 0, 0, 0, $6e, $56,
$65, $72, $74, $65, $78, $43, $6f, $6c, $6f, $72,
$73, $14, 0, $34, 0, $1, 0, $c, 0, 0,
0, $49, $6e, $64, $65, $78, $65, $64, $43, $6f,
$6c, $6f, $72, $1, 0, $c, 0, 0, 0, $76,
$65, $72, $74, $65, $78, $43, $6f, $6c, $6f, $72,
$73, $e, 0, $1, 0, $d, 0, 0, 0, $6e,
$56, $65, $72, $74, $65, $78, $43, $6f, $6c, $6f,
$72, $73, $f, 0, $14, 0, $b, 0, $1f, 0,
$1, 0, $4, 0, 0, 0, $4d, $65, $73, $68,
$a, 0, $5, 0, $44, $ab, $82, $3d, $da, $62,
$cf, $11, $ab, $39, 0, $20, $af, $71, $e4, $33,
$29, 0, $1, 0, $9, 0, 0, 0, $6e, $56,
$65, $72, $74, $69, $63, $65, $73, $14, 0, $34,
0, $1, 0, $6, 0, 0, 0, $56, $65, $63,
$74, $6f, $72, $1, 0, $8, 0, 0, 0, $76,
$65, $72, $74, $69, $63, $65, $73, $e, 0, $1,
0, $9, 0, 0, 0, $6e, $56, $65, $72, $74,
$69, $63, $65, $73, $f, 0, $14, 0, $29, 0,
$1, 0, $6, 0, 0, 0, $6e, $46, $61, $63,
$65, $73, $14, 0, $34, 0, $1, 0, $8, 0,
0, 0, $4d, $65, $73, $68, $46, $61, $63, $65,
$1, 0, $5, 0, 0, 0, $66, $61, $63, $65,
$73, $e, 0, $1, 0, $6, 0, 0, 0, $6e,
$46, $61, $63, $65, $73, $f, 0, $14, 0, $e,
0, $12, 0, $12, 0, $12, 0, $f, 0, $b,
0, $1f, 0, $1, 0, $14, 0, 0, 0, $46,
$72, $61, $6d, $65, $54, $72, $61, $6e, $73, $66,
$6f, $72, $6d, $4d, $61, $74, $72, $69, $78, $a,
0, $5, 0, $41, $3f, $f2, $f6, $86, $76, $cf,
$11, $8f, $52, 0, $40, $33, $35, $94, $a3, $1,
0, $9, 0, 0, 0, $4d, $61, $74, $72, $69,
$78, $34, $78, $34, $1, 0, $b, 0, 0, 0,
$66, $72, $61, $6d, $65, $4d, $61, $74, $72, $69,
$78, $14, 0, $b, 0, $1f, 0, $1, 0, $5,
0, 0, 0, $46, $72, $61, $6d, $65, $a, 0,
$5, 0, $46, $ab, $82, $3d, $da, $62, $cf, $11,
$ab, $39, 0, $20, $af, $71, $e4, $33, $e, 0,
$12, 0, $12, 0, $12, 0, $f, 0, $b, 0,
$1f, 0, $1, 0, $9, 0, 0, 0, $46, $6c,
$6f, $61, $74, $4b, $65, $79, $73, $a, 0, $5,
0, $a9, $46, $dd, $10, $5b, $77, $cf, $11, $8f,
$52, 0, $40, $33, $35, $94, $a3, $29, 0, $1,
0, $7, 0, 0, 0, $6e, $56, $61, $6c, $75,
$65, $73, $14, 0, $34, 0, $2a, 0, $1, 0,
$6, 0, 0, 0, $76, $61, $6c, $75, $65, $73,
$e, 0, $1, 0, $7, 0, 0, 0, $6e, $56,
$61, $6c, $75, $65, $73, $f, 0, $14, 0, $b,
0, $1f, 0, $1, 0, $e, 0, 0, 0, $54,
$69, $6d, $65, $64, $46, $6c, $6f, $61, $74, $4b,
$65, $79, $73, $a, 0, $5, 0, $80, $b1, $6,
$f4, $3b, $7b, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $29, 0, $1, 0, $4, 0, 0,
0, $74, $69, $6d, $65, $14, 0, $1, 0, $9,
0, 0, 0, $46, $6c, $6f, $61, $74, $4b, $65,
$79, $73, $1, 0, $6, 0, 0, 0, $74, $66,
$6b, $65, $79, $73, $14, 0, $b, 0, $1f, 0,
$1, 0, $c, 0, 0, 0, $41, $6e, $69, $6d,
$61, $74, $69, $6f, $6e, $4b, $65, $79, $a, 0,
$5, 0, $a8, $46, $dd, $10, $5b, $77, $cf, $11,
$8f, $52, 0, $40, $33, $35, $94, $a3, $29, 0,
$1, 0, $7, 0, 0, 0, $6b, $65, $79, $54,
$79, $70, $65, $14, 0, $29, 0, $1, 0, $5,
0, 0, 0, $6e, $4b, $65, $79, $73, $14, 0,
$34, 0, $1, 0, $e, 0, 0, 0, $54, $69,
$6d, $65, $64, $46, $6c, $6f, $61, $74, $4b, $65,
$79, $73, $1, 0, $4, 0, 0, 0, $6b, $65,
$79, $73, $e, 0, $1, 0, $5, 0, 0, 0,
$6e, $4b, $65, $79, $73, $f, 0, $14, 0, $b,
0, $1f, 0, $1, 0, $10, 0, 0, 0, $41,
$6e, $69, $6d, $61, $74, $69, $6f, $6e, $4f, $70,
$74, $69, $6f, $6e, $73, $a, 0, $5, 0, $c0,
$56, $bf, $e2, $f, $84, $cf, $11, $8f, $52, 0,
$40, $33, $35, $94, $a3, $29, 0, $1, 0, $a,
0, 0, 0, $6f, $70, $65, $6e, $63, $6c, $6f,
$73, $65, $64, $14, 0, $29, 0, $1, 0, $f,
0, 0, 0, $70, $6f, $73, $69, $74, $69, $6f,
$6e, $71, $75, $61, $6c, $69, $74, $79, $14, 0,
$b, 0, $1f, 0, $1, 0, $9, 0, 0, 0,
$41, $6e, $69, $6d, $61, $74, $69, $6f, $6e, $a,
0, $5, 0, $4f, $ab, $82, $3d, $da, $62, $cf,
$11, $ab, $39, 0, $20, $af, $71, $e4, $33, $e,
0, $12, 0, $12, 0, $12, 0, $f, 0, $b,
0, $1f, 0, $1, 0, $c, 0, 0, 0, $41,
$6e, $69, $6d, $61, $74, $69, $6f, $6e, $53, $65,
$74, $a, 0, $5, 0, $50, $ab, $82, $3d, $da,
$62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4,
$33, $e, 0, $1, 0, $9, 0, 0, 0, $41,
$6e, $69, $6d, $61, $74, $69, $6f, $6e, $f, 0,
$b, 0, $1f, 0, $1, 0, $a, 0, 0, 0,
$49, $6e, $6c, $69, $6e, $65, $44, $61, $74, $61,
$a, 0, $5, 0, $a0, $ee, $23, $3a, $b1, $94,
$d0, $11, $ab, $39, 0, $20, $af, $71, $e4, $33,
$e, 0, $1, 0, $6, 0, 0, 0, $42, $49,
$4e, $41, $52, $59, $f, 0, $b, 0, $1f, 0,
$1, 0, $3, 0, 0, 0, $55, $72, $6c, $a,
0, $5, 0, $a1, $ee, $23, $3a, $b1, $94, $d0,
$11, $ab, $39, 0, $20, $af, $71, $e4, $33, $29,
0, $1, 0, $5, 0, 0, 0, $6e, $55, $72,
$6c, $73, $14, 0, $34, 0, $31, 0, $1, 0,
$4, 0, 0, 0, $75, $72, $6c, $73, $e, 0,
$1, 0, $5, 0, 0, 0, $6e, $55, $72, $6c,
$73, $f, 0, $14, 0, $b, 0, $1f, 0, $1,
0, $f, 0, 0, 0, $50, $72, $6f, $67, $72,
$65, $73, $73, $69, $76, $65, $4d, $65, $73, $68,
$a, 0, $5, 0, $60, $c3, $63, $8a, $7d, $99,
$d0, $11, $94, $1c, 0, $80, $c8, $c, $fa, $7b,
$e, 0, $1, 0, $3, 0, 0, 0, $55, $72,
$6c, $13, 0, $1, 0, $a, 0, 0, 0, $49,
$6e, $6c, $69, $6e, $65, $44, $61, $74, $61, $f,
0, $b, 0, $1f, 0, $1, 0, $4, 0, 0,
0, $47, $75, $69, $64, $a, 0, $5, 0, $e0,
$90, $27, $a4, $10, $78, $cf, $11, $8f, $52, 0,
$40, $33, $35, $94, $a3, $29, 0, $1, 0, $5,
0, 0, 0, $64, $61, $74, $61, $31, $14, 0,
$28, 0, $1, 0, $5, 0, 0, 0, $64, $61,
$74, $61, $32, $14, 0, $28, 0, $1, 0, $5,
0, 0, 0, $64, $61, $74, $61, $33, $14, 0,
$34, 0, $2d, 0, $1, 0, $5, 0, 0, 0,
$64, $61, $74, $61, $34, $e, 0, $3, 0, $8,
0, 0, 0, $f, 0, $14, 0, $b, 0, $1f,
0, $1, 0, $e, 0, 0, 0, $53, $74, $72,
$69, $6e, $67, $50, $72, $6f, $70, $65, $72, $74,
$79, $a, 0, $5, 0, $e0, $21, $f, $7f, $e1,
$bf, $d1, $11, $82, $c0, 0, $a0, $c9, $69, $72,
$71, $31, 0, $1, 0, $3, 0, 0, 0, $6b,
$65, $79, $14, 0, $31, 0, $1, 0, $5, 0,
0, 0, $76, $61, $6c, $75, $65, $14, 0, $b,
0, $1f, 0, $1, 0, $b, 0, 0, 0, $50,
$72, $6f, $70, $65, $72, $74, $79, $42, $61, $67,
$a, 0, $5, 0, $e1, $21, $f, $7f, $e1, $bf,
$d1, $11, $82, $c0, 0, $a0, $c9, $69, $72, $71,
$e, 0, $1, 0, $e, 0, 0, 0, $53, $74,
$72, $69, $6e, $67, $50, $72, $6f, $70, $65, $72,
$74, $79, $f, 0, $b, 0, $1f, 0, $1, 0,
$e, 0, 0, 0, $45, $78, $74, $65, $72, $6e,
$61, $6c, $56, $69, $73, $75, $61, $6c, $a, 0,
$5, 0, $a0, $6a, $11, $98, $ba, $bd, $d1, $11,
$82, $c0, 0, $a0, $c9, $69, $72, $71, $1, 0,
$4, 0, 0, 0, $47, $75, $69, $64, $1, 0,
$12, 0, 0, 0, $67, $75, $69, $64, $45, $78,
$74, $65, $72, $6e, $61, $6c, $56, $69, $73, $75,
$61, $6c, $14, 0, $e, 0, $12, 0, $12, 0,
$12, 0, $f, 0, $b, 0);
 
//---------------
 
//Direct3DRM file
(*==========================================================================;
*
* Copyright (C) 1994-1997 Microsoft Corporation. All Rights Reserved.
*
* Files: D3DRMDef.h D3DRMObj.h D3DRM.h D3DRMWin.h RMXFGUID.h RMXFTmpl.h
* Content: Direct3D Retained Mode include files
*
* DirectX 7.0 Delphi adaptation by Erik Unger
*
* Modified: 10-Sep-2000
*
* Download: http://www.delphi-jedi.org/DelphiGraphics/
* E-Mail: DelphiDirectX@next-reality.com
*
*
***************************************************************************)
 
var
D3DRMDLL : HMODULE = 0;
 
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: d3drmdef.h
9288,37 → 5690,64
*
***************************************************************************)
 
{ TD3DRMVector4D structure }
 
type
PD3DRMVector4D = ^TD3DRMVector4D;
TD3DRMVector4D = packed record
TD3DRMVector4D = record
x, y, z, w: TD3DValue;
end;
 
PD3DRMMatrix4D = ^TD3DRMMatrix4D;
D3DRMVECTOR4D = TD3DRMVector4D;
LPD3DRMVECTOR4D = PD3DRMVector4D;
 
{ TD3DRMMatrix4D structure }
 
TD3DRMMatrix4D = array [0..3, 0..3] of TD3DValue;
D3DRMMATRIX4D = TD3DRMMatrix4D;
 
{ TD3DRMQuaternion structure }
 
PD3DRMQuaternion = ^TD3DRMQuaternion;
TD3DRMQuaternion = packed record
TD3DRMQuaternion = record
s: TD3DValue;
v: TD3DVector;
end;
 
D3DRMQUATERNION = TD3DRMQuaternion;
LPD3DRMQUATERNION = PD3DRMQUATERNION;
 
{ TD3DRMRay structure }
 
PD3DRMRay = ^TD3DRMRay;
TD3DRMRay = packed record
TD3DRMRay = record
dvDir: TD3DVector;
dvPos: TD3DVector;
end;
 
D3DRMRAY = TD3DRMRay;
LPD3DRMRAY = PD3DRMRay;
 
{ TD3DRMBox structure }
 
PD3DRMBox = ^TD3DRMBox;
TD3DRMBox = packed record
TD3DRMBox = record
min, max: TD3DVector;
end;
 
TD3DRMWrapCallback = procedure (var lpD3DVector: TD3DVector;
var lpU, lpV: Integer; var lpD3DRMVA, lpD3DRMVB: TD3DVector; lpArg:
Pointer); stdcall; // unused ?
D3DRMBOX = TD3DRMBox;
LPD3DRMBOX = PD3DRMBox;
 
PD3DRMLightType = ^TD3DRMLightType; // is it 16 or 32 bit ?
{ TD3DRMWrapCallback }
 
TD3DRMWrapCallback = procedure(var lpD3DVector: TD3DVector; var lpU: Integer;
var lpV: Integer; var lpD3DRMVA: TD3DVector; lpD3DRMVB: TD3DVector;
lpArg: Pointer); stdcall;
 
D3DRMWRAPCALLBACK = TD3DRMWrapCallback;
 
{ TD3DRMLightType }
 
TD3DRMLightType = (
D3DRMLIGHT_AMBIENT,
D3DRMLIGHT_POINT,
9327,9 → 5756,13
D3DRMLIGHT_PARALLELPOINT
);
 
PD3DRMShadeMode = ^TD3DRMShadeMode;
TD3DRMShadeMode = WORD;
D3DRMLIGHTTYPE = TD3DRMLightType;
 
{ TD3DRMShadeMode }
 
TD3DRMShadeMode = Word;
D3DRMSHADEMODE = TD3DRMShadeMode;
 
const
D3DRMSHADE_FLAT = 0;
D3DRMSHADE_GOURAUD = 1;
9337,9 → 5770,11
D3DRMSHADE_MASK = 7;
D3DRMSHADE_MAX = 8;
 
{ TD3DRMLightMode }
 
type
PD3DRMLightMode = ^TD3DRMLightMode;
TD3DRMLightMode = WORD;
TD3DRMLightMode = Word;
D3DRMLIGHTMODE = TD3DRMLightMode;
 
const
D3DRMLIGHT_OFF = 0 * D3DRMSHADE_MAX;
9347,9 → 5782,11
D3DRMLIGHT_MASK = 7 * D3DRMSHADE_MAX;
D3DRMLIGHT_MAX = 8 * D3DRMSHADE_MAX;
 
{ TD3DRMFillMode }
 
type
PD3DRMFillMode = ^TD3DRMFillMode;
TD3DRMFillMode = WORD;
TD3DRMFillMode = Word;
D3DRMFILLMODE = TD3DRMFillMode;
 
const
D3DRMFILL_POINTS = 0 * D3DRMLIGHT_MAX;
9358,59 → 5795,60
D3DRMFILL_MASK = 7 * D3DRMLIGHT_MAX;
D3DRMFILL_MAX = 8 * D3DRMLIGHT_MAX;
 
{ TD3DRMRenderQuality }
 
type
PD3DRMRenderQuality = ^TD3DRMRenderQuality;
TD3DRMRenderQuality = DWORD;
D3DRMRENDERQUALITY = TD3DRMRenderQuality;
 
const
D3DRMRENDER_WIREFRAME =
(D3DRMSHADE_FLAT + D3DRMLIGHT_OFF + D3DRMFILL_WIREFRAME);
D3DRMRENDER_UNLITFLAT =
(D3DRMSHADE_FLAT + D3DRMLIGHT_OFF + D3DRMFILL_SOLID);
D3DRMRENDER_FLAT =
(D3DRMSHADE_FLAT + D3DRMLIGHT_ON + D3DRMFILL_SOLID);
D3DRMRENDER_GOURAUD =
(D3DRMSHADE_GOURAUD + D3DRMLIGHT_ON + D3DRMFILL_SOLID);
D3DRMRENDER_PHONG =
(D3DRMSHADE_PHONG + D3DRMLIGHT_ON + D3DRMFILL_SOLID);
D3DRMRENDER_WIREFRAME = D3DRMSHADE_FLAT + D3DRMLIGHT_OFF + D3DRMFILL_WIREFRAME;
D3DRMRENDER_UNLITFLAT = D3DRMSHADE_FLAT + D3DRMLIGHT_OFF + D3DRMFILL_SOLID;
D3DRMRENDER_FLAT = D3DRMSHADE_FLAT + D3DRMLIGHT_ON + D3DRMFILL_SOLID;
D3DRMRENDER_GOURAUD = D3DRMSHADE_GOURAUD + D3DRMLIGHT_ON + D3DRMFILL_SOLID;
D3DRMRENDER_PHONG = D3DRMSHADE_PHONG + D3DRMLIGHT_ON + D3DRMFILL_SOLID;
 
D3DRMRENDERMODE_BLENDEDTRANSPARENCY = 1;
D3DRMRENDERMODE_SORTEDTRANSPARENCY = 2;
D3DRMRENDERMODE_LIGHTINMODELSPACE = 8;
D3DRMRENDERMODE_VIEWDEPENDENTSPECULAR = 16;
D3DRMRENDERMODE_DISABLESORTEDALPHAZWRITE = 32;
 
{ TD3DRMTextureQuality }
 
type
PD3DRMTextureQuality = ^TD3DRMTextureQuality;
TD3DRMTextureQuality = (
D3DRMTEXTURE_NEAREST, (* choose nearest texel *)
D3DRMTEXTURE_LINEAR, (* interpolate 4 texels *)
D3DRMTEXTURE_MIPNEAREST, (* nearest texel in nearest mipmap *)
D3DRMTEXTURE_MIPLINEAR, (* interpolate 2 texels from 2 mipmaps *)
D3DRMTEXTURE_LINEARMIPNEAREST, (* interpolate 4 texels in nearest mipmap *)
D3DRMTEXTURE_LINEARMIPLINEAR (* interpolate 8 texels from 2 mipmaps *)
D3DRMTEXTURE_NEAREST, // choose nearest texel
D3DRMTEXTURE_LINEAR, // interpolate 4 texels
D3DRMTEXTURE_MIPNEAREST, // nearest texel in nearest mipmap
D3DRMTEXTURE_MIPLINEAR, // interpolate 2 texels from 2 mipmaps
D3DRMTEXTURE_LINEARMIPNEAREST, // interpolate 4 texels in nearest mipmap
D3DRMTEXTURE_LINEARMIPLINEAR // interpolate 8 texels from 2 mipmaps
);
 
D3DRMTEXTUREQUALITY = TD3DRMTextureQuality;
 
{ Texture flags }
 
const
(*
* Texture flags
*)
D3DRMTEXTURE_FORCERESIDENT = $00000001; (* texture should be kept in video memory *)
D3DRMTEXTURE_STATIC = $00000002; (* texture will not change *)
D3DRMTEXTURE_DOWNSAMPLEPOINT = $00000004; (* point filtering should be used when downsampling *)
D3DRMTEXTURE_DOWNSAMPLEBILINEAR = $00000008; (* bilinear filtering should be used when downsampling *)
D3DRMTEXTURE_DOWNSAMPLEREDUCEDEPTH = $00000010; (* reduce bit depth when downsampling *)
D3DRMTEXTURE_DOWNSAMPLENONE = $00000020; (* texture should never be downsampled *)
D3DRMTEXTURE_CHANGEDPIXELS = $00000040; (* pixels have changed *)
D3DRMTEXTURE_CHANGEDPALETTE = $00000080; (* palette has changed *)
D3DRMTEXTURE_INVALIDATEONLY = $00000100; (* dirty regions are invalid *)
D3DRMTEXTURE_FORCERESIDENT = $00000001; // texture should be kept in video memory
D3DRMTEXTURE_STATIC = $00000002; // texture will not change
D3DRMTEXTURE_DOWNSAMPLEPOINT = $00000004; // point filtering should be used when downsampling
D3DRMTEXTURE_DOWNSAMPLEBILINEAR = $00000008; // bilinear filtering should be used when downsampling
D3DRMTEXTURE_DOWNSAMPLEREDUCEDEPTH = $00000010; // reduce bit depth when downsampling
D3DRMTEXTURE_DOWNSAMPLENONE = $00000020; // texture should never be downsampled
D3DRMTEXTURE_CHANGEDPIXELS = $00000040; // pixels have changed
D3DRMTEXTURE_CHANGEDPALETTE = $00000080; // palette has changed
D3DRMTEXTURE_INVALIDATEONLY = $00000100; // dirty regions are invalid
 
(*
* Shadow flags
*)
D3DRMSHADOW_TRUEALPHA = $00000001; (* shadow should render without artifacts when true alpha is on *)
{ Shadow flags }
 
const
D3DRMSHADOW_TRUEALPHA = $00000001; // shadow should render without artifacts when true alpha is on
 
{ TD3DRMCombineType }
 
type
PD3DRMCombineType = ^TD3DRMCombineType;
TD3DRMCombineType = (
D3DRMCOMBINE_REPLACE,
D3DRMCOMBINE_BEFORE,
9417,26 → 5855,40
D3DRMCOMBINE_AFTER
);
 
PD3DRMColorModel = ^TD3DRMColorModel;
D3DRMCOMBINETYPE = TD3DRMCombineType;
 
{ TD3DRMColorModel }
 
TD3DRMColorModel = TD3DColorModel;
D3DRMCOLORMODEL = TD3DRMColorModel;
 
PD3DRMPaletteFlags = ^TD3DRMPaletteFlags;
{ TD3DRMPaletteFlags }
 
TD3DRMPaletteFlags = (
D3DRMPALETTE_FREE, (* renderer may use this entry freely *)
D3DRMPALETTE_READONLY, (* fixed but may be used by renderer *)
D3DRMPALETTE_RESERVED (* may not be used by renderer *)
D3DRMPALETTE_FREE, // renderer may use this entry freely
D3DRMPALETTE_READONLY, // fixed but may be used by renderer
D3DRMPALETTE_RESERVED // may not be used by renderer
);
 
D3DRMPALETTEFLAGS = TD3DRMPaletteFlags;
 
{ TD3DRMPaletteEntry structure }
 
PD3DRMPaletteEntry = ^TD3DRMPaletteEntry;
TD3DRMPaletteEntry = packed record
red: Byte; (* 0 .. 255 *)
green: Byte; (* 0 .. 255 *)
blue: Byte; (* 0 .. 255 *)
flags: Byte; (* one of D3DRMPALETTEFLAGS *)
TD3DRMPaletteEntry = record
red: Byte; // 0 .. 255
green: Byte; // 0 .. 255
blue: Byte; // 0 .. 255
flags: Byte; // one of TD3DRMPaletteFlags
end;
 
D3DRMPALETTEENTRY = TD3DRMPaletteEntry;
LPD3DRMPALETTEENTRY = PD3DRMPaletteEntry;
 
{ TD3DRMImage structure }
 
PD3DRMImage = ^TD3DRMImage;
TD3DRMImage = packed record
TD3DRMImage = record
width, height: Integer; (* width and height in pixels *)
aspectx, aspecty: Integer; (* aspect ratio for non-square pixels *)
depth: Integer; (* bits per pixel *)
9450,10 → 5902,10
buffer2: Pointer; (* second rendering buffer for double
buffering, set to NULL for single
buffering. *)
red_mask: DWORD;
green_mask: DWORD;
blue_mask: DWORD;
alpha_mask: DWORD; (* if rgb is true, these are masks for
red_mask: Longint;
green_mask: Longint;
blue_mask: Longint;
alpha_mask: Longint; (* if rgb is true, these are masks for
the red, green and blue parts of a
pixel. Otherwise, these are masks
for the significant bits of the
9468,7 → 5920,11
elements. *)
end;
 
PD3DRMWrapType = ^TD3DRMWrapType;
D3DRMIMAGE = TD3DRMImage;
LPD3DRMIMAGE = PD3DRMImage;
 
{ TD3DRMWrapType }
 
TD3DRMWrapType = (
D3DRMWRAP_FLAT,
D3DRMWRAP_CYLINDER,
9478,29 → 5934,31
D3DRMWRAP_BOX
);
 
D3DRMWRAPTYPE = TD3DRMWrapType;
 
const
D3DRMWIREFRAME_CULL = 1; (* cull backfaces *)
D3DRMWIREFRAME_HIDDENLINE = 2; (* lines are obscured by closer objects *)
D3DRMWIREFRAME_CULL = 1; // cull backfaces
D3DRMWIREFRAME_HIDDENLINE = 2; // lines are obscured by closer objects
 
{ TD3DRMProjectionType }
 
type
(*
* Do not use righthanded perspective in Viewport2::SetProjection().
* Set up righthanded mode by using IDirect3DRM3::SetOptions().
*)
PD3DRMProjectionType = ^TD3DRMProjectionType;
TD3DRMProjectionType = (
D3DRMPROJECT_PERSPECTIVE,
D3DRMPROJECT_ORTHOGRAPHIC,
D3DRMPROJECT_RIGHTHANDPERSPECTIVE, (* Only valid pre-DX6 *)
D3DRMPROJECT_RIGHTHANDORTHOGRAPHIC (* Only valid pre-DX6 *)
D3DRMPROJECT_RIGHTHANDPERSPECTIVE, // Only valid pre-DX6
D3DRMPROJECT_RIGHTHANDORTHOGRAPHIC // Only valid pre-DX6
);
 
D3DRMPROJECTIONTYPE = TD3DRMProjectionType;
 
const
D3DRMOPTIONS_LEFTHANDED = 00000001; (* Default *)
D3DRMOPTIONS_RIGHTHANDED = 00000002;
D3DRMOPTIONS_LEFTHANDED = $00000001; // Default
D3DRMOPTIONS_RIGHTHANDED = $00000002;
 
{ TD3DRMXOFFormat }
 
type
PD3DRMXOFFormat = ^TD3DRMXOFFormat;
TD3DRMXOFFormat = (
D3DRMXOF_BINARY,
D3DRMXOF_COMPRESSED,
9507,7 → 5965,13
D3DRMXOF_TEXT
);
 
D3DRMXOFFORMAT = TD3DRMXOFFormat;
 
{ TD3DRMSaveOptions }
 
TD3DRMSaveOptions = DWORD;
D3DRMSAVEOPTIONS = TD3DRMSaveOptions;
 
const
D3DRMXOFSAVE_NORMALS = 1;
D3DRMXOFSAVE_TEXTURECOORDINATES = 2;
9517,21 → 5981,28
D3DRMXOFSAVE_TEMPLATES = 16;
D3DRMXOFSAVE_TEXTURETOPOLOGY = 32;
 
{ TD3DRMColorSource }
 
type
PD3DRMColorSource = ^TD3DRMColorSource;
TD3DRMColorSource = (
D3DRMCOLOR_FROMFACE,
D3DRMCOLOR_FROMVERTEX
);
 
PD3DRMFrameConstraint = ^TD3DRMFrameConstraint;
D3DRMCOLORSOURCE = TD3DRMColorSource;
 
{ TD3DRMFrameConstraint }
 
TD3DRMFrameConstraint = (
D3DRMCONSTRAIN_Z, (* use only X and Y rotations *)
D3DRMCONSTRAIN_Y, (* use only X and Z rotations *)
D3DRMCONSTRAIN_X (* use only Y and Z rotations *)
D3DRMCONSTRAIN_Z, // use only X and Y rotations
D3DRMCONSTRAIN_Y, // use only X and Z rotations
D3DRMCONSTRAIN_X // use only Y and Z rotations
);
 
PD3DRMMaterialMode = ^TD3DRMMaterialMode;
D3DRMFRAMECONSTRAINT = TD3DRMFrameConstraint;
 
{ TD3DRMMaterialMode }
 
TD3DRMMaterialMode = (
D3DRMMATERIAL_FROMMESH,
D3DRMMATERIAL_FROMPARENT,
9538,39 → 6009,56
D3DRMMATERIAL_FROMFRAME
);
 
PD3DRMFogMode = ^TD3DRMFogMode;
D3DRMMATERIALMODE = TD3DRMMaterialMode;
 
{ TD3DRMFogMode }
 
TD3DRMFogMode = (
D3DRMFOG_LINEAR, (* linear between start and end *)
D3DRMFOG_EXPONENTIAL, (* density * exp(-distance) *)
D3DRMFOG_EXPONENTIALSQUARED (* density * exp(-distance*distance) *)
D3DRMFOG_LINEAR, // linear between start and end
D3DRMFOG_EXPONENTIAL, // density * exp(-distance)
D3DRMFOG_EXPONENTIALSQUARED // density * exp(-distance*distance)
);
 
PD3DRMZBufferMode = ^TD3DRMZBufferMode;
D3DRMFOGMODE = TD3DRMFogMode;
 
{ TD3DRMZBufferMode }
 
TD3DRMZBufferMode = (
D3DRMZBUFFER_FROMPARENT, (* default *)
D3DRMZBUFFER_ENABLE, (* enable zbuffering *)
D3DRMZBUFFER_DISABLE (* disable zbuffering *)
D3DRMZBUFFER_FROMPARENT, // default
D3DRMZBUFFER_ENABLE, // enable zbuffering
D3DRMZBUFFER_DISABLE // disable zbuffering
);
 
PD3DRMSortMode = ^TD3DRMSortMode;
D3DRMZBUFFERMODE = TD3DRMZBufferMode;
 
{ TD3DRMSortMode }
 
TD3DRMSortMode = (
D3DRMSORT_FROMPARENT, (* default *)
D3DRMSORT_NONE, (* don't sort child frames *)
D3DRMSORT_FRONTTOBACK, (* sort child frames front-to-back *)
D3DRMSORT_BACKTOFRONT (* sort child frames back-to-front *)
D3DRMSORT_FROMPARENT, // default
D3DRMSORT_NONE, // don't sort child frames
D3DRMSORT_FRONTTOBACK, // sort child frames front-to-back
D3DRMSORT_BACKTOFRONT // sort child frames back-to-front
);
 
TD3DRMMaterialOverride = packed record
dwSize : DWORD; (* Size of this structure *)
dwFlags : DWORD; (* Indicate which fields are valid *)
dcDiffuse : TD3DColorValue; (* RGBA *)
dcAmbient : TD3DColorValue; (* RGB *)
dcEmissive : TD3DColorValue; (* RGB *)
dcSpecular : TD3DColorValue; (* RGB *)
D3DRMSORTMODE = TD3DRMSortMode;
 
{ TD3DRMMaterialOverride structure }
 
PD3DRMMaterialOverride = ^TD3DRMMaterialOverride;
TD3DRMMaterialOverride = record
dwSize: DWORD; // Size of this structure
dwFlags: DWORD; // Indicate which fields are valid
dcDiffuse: TD3DColorValue; // RGBA
dcAmbient: TD3DColorValue; // RGB
dcEmissive: TD3DColorValue; // RGB
dcSpecular: TD3DColorValue; // RGB
dvPower : TD3DValue;
lpD3DRMTex : IUnknown;
end;
 
D3DRMMATERIALOVERRIDE = TD3DRMMaterialOverride;
LPD3DRMMATERIALOVERRIDE = PD3DRMMaterialOverride;
 
const
D3DRMMATERIALOVERRIDE_DIFFUSE_ALPHAONLY = $00000001;
D3DRMMATERIALOVERRIDE_DIFFUSE_RGBONLY = $00000002;
9594,27 → 6082,23
D3DRMSTATECHANGE_RENDER = $000000020;
D3DRMSTATECHANGE_LIGHT = $000000040;
 
(*
* Values for flags in RM3::CreateDeviceFromSurface
*)
{ Values for flags in RM3::CreateDeviceFromSurface }
 
D3DRMDEVICE_NOZBUFFER = $00000001;
 
(*
* Values for flags in Object2::SetClientData
*)
{ Values for flags in Object2::SetClientData }
 
D3DRMCLIENTDATA_NONE = $00000001;
D3DRMCLIENTDATA_LOCALFREE = $00000002;
D3DRMCLIENTDATA_IUNKNOWN = $00000004;
 
(*
* Values for flags in Frame2::AddMoveCallback.
*)
{ Values for flags in Frame2::AddMoveCallback. }
 
D3DRMCALLBACK_PREORDER = 0;
D3DRMCALLBACK_POSTORDER = 1;
 
(*
* Values for flags in MeshBuilder2::RayPick.
*)
{ Values for flags in MeshBuilder2::RayPick. }
 
D3DRMRAYPICK_ONLYBOUNDINGBOXES = 1;
D3DRMRAYPICK_IGNOREFURTHERPRIMITIVES = 2;
D3DRMRAYPICK_INTERPOLATEUV = 4;
9621,39 → 6105,37
D3DRMRAYPICK_INTERPOLATECOLOR = 8;
D3DRMRAYPICK_INTERPOLATENORMAL = $10;
 
(*
* Values for flags in MeshBuilder3::AddFacesIndexed.
*)
{ Values for flags in MeshBuilder3::AddFacesIndexed. }
 
D3DRMADDFACES_VERTICESONLY = 1;
 
(*
* Values for flags in MeshBuilder2::GenerateNormals.
*)
 
{ Values for flags in MeshBuilder2::GenerateNormals. }
 
D3DRMGENERATENORMALS_PRECOMPACT = 1;
D3DRMGENERATENORMALS_USECREASEANGLE = 2;
 
(*
* Values for MeshBuilder3::GetParentMesh
*)
{ Values for MeshBuilder3::GetParentMesh }
 
D3DRMMESHBUILDER_DIRECTPARENT = 1;
D3DRMMESHBUILDER_ROOTMESH = 2;
 
(*
* Flags for MeshBuilder3::Enable
*)
{ Flags for MeshBuilder3::Enable }
D3DRMMESHBUILDER_RENDERENABLE = $00000001;
D3DRMMESHBUILDER_PICKENABLE = $00000002;
 
(*
* Flags for Object2::GetAge when used with MeshBuilders
*)
{ Flags for MeshBuilder3::AddMeshBuilder }
D3DRMADDMESHBUILDER_DONTCOPYAPPDATA = 1;
D3DRMADDMESHBUILDER_FLATTENSUBMESHES = 2;
D3DRMADDMESHBUILDER_NOSUBMESHES = 4;
 
{ Flags for Object2::GetAge when used with MeshBuilders }
D3DRMMESHBUILDERAGE_GEOMETRY = $00000001;
D3DRMMESHBUILDERAGE_MATERIALS = $00000002;
D3DRMMESHBUILDERAGE_TEXTURES = $00000004;
 
(*
* Format flags for MeshBuilder3::AddTriangles.
*)
{ Format flags for MeshBuilder3::AddTriangles. }
 
D3DRMFVF_TYPE = $00000001;
D3DRMFVF_NORMAL = $00000002;
D3DRMFVF_COLOR = $00000004;
9663,31 → 6145,29
D3DRMVERTEX_FAN = $00000002;
D3DRMVERTEX_LIST = $00000004;
 
(*
* Values for flags in Viewport2::Clear2
*)
{ Values for flags in Viewport2::Clear2 }
 
D3DRMCLEAR_TARGET = $00000001;
D3DRMCLEAR_ZBUFFER = $00000002;
D3DRMCLEAR_DIRTYRECTS = $00000004;
D3DRMCLEAR_ALL = (D3DRMCLEAR_TARGET or
D3DRMCLEAR_ZBUFFER or
D3DRMCLEAR_DIRTYRECTS);
D3DRMCLEAR_ALL = D3DRMCLEAR_TARGET or D3DRMCLEAR_ZBUFFER or D3DRMCLEAR_DIRTYRECTS;
 
(*
* Values for flags in Frame3::SetSceneFogMethod
*)
{ Values for flags in Frame3::SetSceneFogMethod }
 
D3DRMFOGMETHOD_VERTEX = $00000001;
D3DRMFOGMETHOD_TABLE = $00000002;
D3DRMFOGMETHOD_ANY = $00000004;
 
(*
* Values for flags in Frame3::SetTraversalOptions
*)
{ Values for flags in Frame3::SetTraversalOptions }
 
D3DRMFRAME_RENDERENABLE = $00000001;
D3DRMFRAME_PICKENABLE = $00000002;
 
{ TD3DRMAnimationOptions }
 
type
TD3DRMAnimationOptions = DWORD;
D3DRMANIMATIONOPTIONS = TD3DRMAnimationOptions;
 
const
D3DRMANIMATION_OPEN = $01;
9697,8 → 6177,12
D3DRMANIMATION_SCALEANDROTATION = $00000010;
D3DRMANIMATION_POSITION = $00000020;
 
{ TD3DRMInterpolationOptions }
 
type
TD3DRMInterpolationOptions = DWORD;
D3DRMINTERPOLATIONOPTIONS = TD3DRMInterpolationOptions;
 
const
D3DRMINTERPOLATION_OPEN = $01;
D3DRMINTERPOLATION_CLOSED = $02;
9708,8 → 6192,11
D3DRMINTERPOLATION_VERTEXCOLOR = $40;
D3DRMINTERPOLATION_SLERPNORMALS = $80;
 
{ TD3DRMLoadOptions }
 
type
TD3DRMLoadOptions = DWORD;
D3DRMLOADOPTIONS = TD3DRMLoadOptions;
 
const
D3DRMLOAD_FROMFILE = $00;
9728,20 → 6215,30
 
D3DRMLOAD_ASYNCHRONOUS = $400;
 
{ TD3DRMLoadReource }
 
type
PD3DRMLoadResource = ^TD3DRMLoadResource;
TD3DRMLoadResource = packed record
PD3DRMLoadReource = ^TD3DRMLoadReource;
TD3DRMLoadReource = record
hModule: HMODULE;
lpName: PAnsiChar;
lpType: PAnsiChar;
lpName: PChar;
lpType: PChar;
end;
 
D3DRMLOADRESOURCE = TD3DRMLoadReource;
LPD3DRMLOADRESOURCE = PD3DRMLoadReource;
 
{ TD3DRMLoadMemory }
 
PD3DRMLoadMemory = ^TD3DRMLoadMemory;
TD3DRMLoadMemory = packed record
TD3DRMLoadMemory = record
lpMemory: Pointer;
dwSize: DWORD;
dSize: DWORD;
end;
 
D3DRMLOADMEMORY = TD3DRMLoadMemory;
LPD3DRMLOADMEMORY = PD3DRMLoadMemory;
 
const
D3DRMPMESHSTATUS_VALID = $01;
D3DRMPMESHSTATUS_INTERRUPTED = $02;
9752,32 → 6249,43
D3DRMPMESHEVENT_BASEMESH = $01;
D3DRMPMESHEVENT_COMPLETE = $02;
 
{ TD3DRMPMeshLoadStatus }
 
type
PD3DRMPMeshLoadStatus = ^TD3DRMPMeshLoadStatus;
TD3DRMPMeshLoadStatus = packed record
dwSize, // Size of this structure
dwPMeshSize, // Total Size (bytes)
dwBaseMeshSize, // Total Size of the Base Mesh
dwBytesLoaded, // Total bytes loaded
dwVerticesLoaded, // Number of vertices loaded
TD3DRMPMeshLoadStatus = record
dwSize: DWORD; // Size of this structure
dwPMeshSize: DWORD; // Total Size (bytes)
dwBaseMeshSize: DWORD; // Total Size of the Base Mesh
dwBytesLoaded: DWORD; // Total bytes loaded
dwVerticesLoaded: DWORD; // Number of vertices loaded
dwFacesLoaded : DWORD; // Number of faces loaded
dwLoadResult : HResult; // Result of the load operation
dwFlags : DWORD;
end;
 
PD3DRMUserVisualReason = ^TD3DRMUserVisualReason;
D3DRMPMESHLOADSTATUS = TD3DRMPMeshLoadStatus;
LPD3DRMPMESHLOADSTATUS = PD3DRMPMeshLoadStatus;
 
{ TD3DRMUserVisualReason }
 
TD3DRMUserVisualReason = (
D3DRMUSERVISUAL_CANSEE,
D3DRMUSERVISUAL_RENDER
);
 
D3DRMUSERVISUALREASON = TD3DRMUserVisualReason;
 
{ TD3DRMAnimationKey }
 
PD3DRMAnimationKey = ^TD3DRMAnimationKey;
TD3DRMAnimationKey = packed record
TD3DRMAnimationKey = record
dwSize : DWORD;
dwKeyType : DWORD;
dvTime : TD3DValue;
dwID : DWORD;
case integer of
 
case Integer of
0 : (dqRotateKey : TD3DRMQuaternion);
1 : (dvScaleKey : TD3DVector);
2 : (dvPositionKey : TD3DVector);
9784,33 → 6292,31
3 : (dvK : array [0..3] of TD3DValue);
end;
 
procedure D3DRMAnimationGetRotateKey
(var rmKey: TD3DRMAnimationKey; var rmQuat: TD3DRMQuaternion);
D3DRMANIMATIONKEY = TD3DRMAnimationKey;
LPD3DRMANIMATIONKEY = PD3DRMAnimationKey;
 
procedure D3DRMAnimationGetScaleKey
(var rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
procedure D3DRMAnimationGetRotateKey(const rmKey: TD3DRMAnimationKey; var rmQuat: TD3DRMQuaternion);
procedure D3DRMAnimationGetScaleKey(const rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
procedure D3DRMAnimationGetPositionKey(const rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
procedure D3DRMAnimationSetRotateKey(var rmKey: TD3DRMAnimationKey; const rmQuat: TD3DRMQuaternion);
procedure D3DRMAnimationSetScaleKey(var rmKey: TD3DRMAnimationKey; const dvVec: TD3DVector);
procedure D3DRMAnimationSetPositionKey(var rmKey: TD3DRMAnimationKey; const dvVec: TD3DVector);
 
procedure D3DRMAnimationGetPositionKey
(var rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
const
D3DRMANIMATION_ROTATEKEY = $01;
D3DRMANIMATION_SCALEKEY = $02;
D3DRMANIMATION_POSITIONKEY = $03;
 
procedure D3DRMAnimatioSetRotateKey
(var rmKey: TD3DRMAnimationKey; var rmQuat: TD3DRMQuaternion);
{ TD3DRMMapping }
 
procedure D3DRMAnimationSetScaleKey
(var rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
type
TD3DRMMapping = DWORD;
D3DRMMAPPING = TD3DRMMapping;
 
procedure D3DRMAnimationSetPositionKey
(var rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
{ TD3DRMMappingFlag }
 
const
D3DRMANIMATION_ROTATEKEY = 01;
D3DRMANIMATION_SCALEKEY = 02;
D3DRMANIMATION_POSITIONKEY = 03;
 
type
TD3DRMMapping = DWORD;
PD3DRMMappingFlag = ^TD3DRMMappingFlag;
TD3DRMMappingFlag = DWORD;
D3DRMMAPPINGFLAG = TD3DRMMappingFlag;
 
const
D3DRMMAP_WRAPU = 1;
9817,9 → 6323,11
D3DRMMAP_WRAPV = 2;
D3DRMMAP_PERSPCORRECT = 4;
 
{ TD3DRMVertex }
 
type
PD3DRMVertex = ^TD3DRMVertex;
TD3DRMVertex = packed record
TD3DRMVertex = record
position: TD3DVector;
normal: TD3DVector;
tu, tv: TD3DValue;
9826,197 → 6334,173
color: TD3DColor;
end;
 
TD3DRMGroupIndex = LongInt; (* group indexes begin a 0 *)
D3DRMVERTEX = TD3DRMVertex;
LPD3DRMVERTEX = PD3DRMVertex;
 
{ TD3DRMGroupIndex }
 
TD3DRMGroupIndex = Longint;
D3DRMGROUPINDEX = TD3DRMGroupIndex; // group indexes begin a 0
 
const
D3DRMGROUP_ALLGROUPS = -1;
 
var
(*
* Create a color from three components in the range 0-1 inclusive.
*)
D3DRMCreateColorRGB : function (red, green, blue: TD3DValue) : TD3DColor;
stdcall;
{ Create a color from three components in the range 0-1 inclusive. }
function D3DRMCreateColorRGB(red, green, blue: TD3DValue): TD3DColor; stdcall;
 
(*
* Create a color from four components in the range 0-1 inclusive.
*)
D3DRMCreateColorRGBA : function (red, green, blue, alpha: TD3DValue)
: TD3DColor; stdcall;
{ Create a color from four components in the range 0-1 inclusive. }
function D3DRMCreateColorRGBA(red, green, blue, alpha: TD3DValue): TD3DColor; stdcall;
 
(*
* Get the red component of a color.
*)
D3DRMColorGetRed : function (d3drmc: TD3DColor) : TD3DValue; stdcall;
{ Get the red component of a color. }
function D3DRMColorGetRed(d3drmc: TD3DColor): TD3DValue; stdcall;
 
(*
* Get the green component of a color.
*)
D3DRMColorGetGreen : function (d3drmc: TD3DColor) : TD3DValue; stdcall;
{ Get the green component of a color. }
function D3DRMColorGetGreen(d3drmc: TD3DColor): TD3DValue; stdcall;
 
(*
* Get the blue component of a color.
*)
D3DRMColorGetBlue : function (d3drmc: TD3DColor) : TD3DValue; stdcall;
{ Get the blue component of a color. }
function D3DRMColorGetBlue(d3drmc: TD3DColor): TD3DValue; stdcall;
 
(*
* Get the alpha component of a color.
*)
D3DRMColorGetAlpha : function (d3drmc: TD3DColor) : TD3DValue; stdcall;
{ Get the alpha component of a color. }
function D3DRMColorGetAlpha(d3drmc: TD3DColor): TD3DValue; stdcall;
 
(*
* Add two vectors. Returns its first argument.
*)
D3DRMVectorAdd : function (var d, s1, s2: TD3DVector) : PD3DVector; stdcall;
{ Add two vectors. Returns its first argument. }
function D3DRMVectorAdd(var d, s1, s2: TD3DVector): PD3DVector; stdcall;
 
(*
* Subtract two vectors. Returns its first argument.
*)
D3DRMVectorSubtract : function (var d, s1, s2: TD3DVector) : PD3DVector;
stdcall;
{ Subtract two vectors. Returns its first argument. }
function D3DRMVectorSubtract(var d, s1, s2: TD3DVector): PD3DVector; stdcall;
 
(*
* Reflect a ray about a given normal. Returns its first argument.
*)
D3DRMVectorReflect : function (var d, ray, norm: TD3DVector) : PD3DVector;
stdcall;
{ Reflect a ray about a given normal. Returns its first argument. }
function D3DRMVectorReflect(var d, ray, norm: TD3DVector): PD3DVector; stdcall;
 
(*
* Calculate the vector cross product. Returns its first argument.
*)
D3DRMVectorCrossProduct : function (var d, s1, s2: TD3DVector) : PD3DVector;
stdcall;
{ Calculate the vector cross product. Returns its first argument. }
function D3DRMVectorCrossProduct(var d, s1, s2: TD3DVector): PD3DVector; stdcall;
 
(*
* Return the vector dot product.
*)
D3DRMVectorDotProduct : function (var s1, s2: TD3DVector) : TD3DValue;
stdcall;
{ Return the vector dot product. }
function D3DRMVectorDotProduct(var s1, s2: TD3DVector): TD3DValue; stdcall;
 
(*
* Scale a vector so that its modulus is 1. Returns its argument or
* NULL if there was an error (e.g. a zero vector was passed).
*)
D3DRMVectorNormalize : function (var lpv: TD3DVector) : PD3DVector; stdcall;
{ Scale a vector so that its modulus is 1. Returns its argument or
NULL if there was an error (e.g. a zero vector was passed). }
function D3DRMVectorNormalize(var lpv: TD3DVector): PD3DVector; stdcall;
 
(*
* Return the length of a vector (e.g. sqrt(x*x + y*y + z*z)).
*)
D3DRMVectorModulus : function (var v: TD3DVector) : TD3DValue; stdcall;
{ Return the length of a vector (e.g. sqrt(x*x + y*y + z*z)). }
function D3DRMVectorModulus(var v: TD3DVector): TD3DValue; stdcall;
 
(*
* Set the rotation part of a matrix to be a rotation of theta radians
* around the given axis.
*)
D3DRMVectorRotate : function (var r, v, axis: TD3DVector; theta: TD3DValue) :
PD3DVector; stdcall;
{ Set the rotation part of a matrix to be a rotation of theta radians
around the given axis. }
function D3DRMVectorRotate(var r, v, axis: TD3DVector; theta: TD3DValue): PD3DVector; stdcall;
 
(*
* Scale a vector uniformly in all three axes
*)
D3DRMVectorScale : function (var d, s: TD3DVector; factor: TD3DValue) :
PD3DVector; stdcall;
{ Scale a vector uniformly in all three axes }
function D3DRMVectorScale( var d, s: TD3DVector; factor: TD3DValue): PD3DVector; stdcall;
 
(*
* Return a random unit vector
*)
D3DRMVectorRandom : function (var d: TD3DVector) : PD3DVector; stdcall;
{ Return a random unit vector }
function D3DRMVectorRandom(var d: TD3DVector): PD3DVector; stdcall;
 
(*
* Returns a unit quaternion that represents a rotation of theta radians
* around the given axis.
*)
 
D3DRMQuaternionFromRotation : function (var quat: TD3DRMQuaternion;
{ Returns a unit quaternion that represents a rotation of theta radians
around the given axis. }
function D3DRMQuaternionFromRotation(var quat: PD3DRMQuaternion;
var v: TD3DVector; theta: TD3DValue) : PD3DRMQuaternion; stdcall;
 
(*
* Calculate the product of two quaternions
*)
D3DRMQuaternionMultiply : function (var q, a, b: TD3DRMQuaternion) :
PD3DRMQuaternion; stdcall;
{ Calculate the product of two quaternions }
function D3DRMQuaternionMultiply(var q, a, b: TD3DRMQuaternion): PD3DRMQuaternion; stdcall;
 
(*
* Interpolate between two quaternions
*)
D3DRMQuaternionSlerp : function (var q, a, b: TD3DRMQuaternion;
alpha: TD3DValue) : PD3DRMQuaternion; stdcall;
{ Interpolate between two quaternions }
function D3DRMQuaternionSlerp(var q, a, b: TD3DRMQuaternion; alpha: TD3DValue): PD3DRMQuaternion; stdcall;
 
(*
* Calculate the matrix for the rotation that a unit quaternion represents
*)
D3DRMMatrixFromQuaternion : procedure (dmMat: TD3DRMMatrix4D; var lpDqQuat:
TD3DRMQuaternion); stdcall;
{ Calculate the matrix for the rotation that a unit quaternion represents }
procedure D3DRMMatrixFromQuaternion(dmMat: TD3DRMMatrix4D; var lpDqQuat: TD3DRMQuaternion); stdcall;
 
(*
* Calculate the quaternion that corresponds to a rotation matrix
*)
D3DRMQuaternionFromMatrix : function (var lpQuat: TD3DRMQuaternion;
Mat: TD3DRMMatrix4D) : PD3DRMQuaternion; stdcall;
{ Calculate the quaternion that corresponds to a rotation matrix }
function D3DRMQuaternionFromMatrix(var lpQuat: TD3DRMQuaternion; Mat: TD3DRMMatrix4D): PD3DRMQuaternion;
 
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: d3drmobj.h
* File: d3drm.h, d3drmobj.h, d3drmwin.h
* Content: Direct3DRM include file
*
***************************************************************************)
 
(*
* Direct3DRM Object classes
*)
 
{ Direct3DRM Object classes }
const
CLSID_CDirect3DRMDevice: TGUID =
(D1:$4fa3568e;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMViewport: TGUID =
(D1:$4fa3568f;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMFrame: TGUID =
(D1:$4fa35690;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMMesh: TGUID =
(D1:$4fa35691;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMMeshBuilder: TGUID =
(D1:$4fa35692;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMFace: TGUID =
(D1:$4fa35693;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMLight: TGUID =
(D1:$4fa35694;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMTexture: TGUID =
(D1:$4fa35695;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMWrap: TGUID =
(D1:$4fa35696;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMMaterial: TGUID =
(D1:$4fa35697;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMAnimation: TGUID =
(D1:$4fa35698;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMAnimationSet: TGUID =
(D1:$4fa35699;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMUserVisual: TGUID =
(D1:$4fa3569a;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMShadow: TGUID =
(D1:$4fa3569b;D2:$623f;D3:$11cf;D4:($ac,$4a,$00,$00,$c0,$38,$25,$a1));
CLSID_CDirect3DRMViewportInterpolator: TGUID =
(D1:$0de9eaa1;D2:$3b84;D3:$11d0;D4:($9b,$6d,$00,$00,$c0,$78,$1b,$c3));
CLSID_CDirect3DRMFrameInterpolator: TGUID =
(D1:$0de9eaa2;D2:$3b84;D3:$11d0;D4:($9b,$6d,$00,$00,$c0,$78,$1b,$c3));
CLSID_CDirect3DRMMeshInterpolator: TGUID =
(D1:$0de9eaa3;D2:$3b84;D3:$11d0;D4:($9b,$6d,$00,$00,$c0,$78,$1b,$c3));
CLSID_CDirect3DRMLightInterpolator: TGUID =
(D1:$0de9eaa6;D2:$3b84;D3:$11d0;D4:($9b,$6d,$00,$00,$c0,$78,$1b,$c3));
CLSID_CDirect3DRMMaterialInterpolator: TGUID =
(D1:$0de9eaa7;D2:$3b84;D3:$11d0;D4:($9b,$6d,$00,$00,$c0,$78,$1b,$c3));
CLSID_CDirect3DRMTextureInterpolator: TGUID =
(D1:$0de9eaa8;D2:$3b84;D3:$11d0;D4:($9b,$6d,$00,$00,$c0,$78,$1b,$c3));
CLSID_CDirect3DRMProgressiveMesh: TGUID =
(D1:$4516ec40;D2:$8f20;D3:$11d0;D4:($9b,$6d,$00,$00,$c0,$78,$1b,$c3));
CLSID_CDirect3DRMClippedVisual: TGUID =
(D1:$5434e72d;D2:$6d66;D3:$11d1;D4:($bb,$0b,$00,$00,$f8,$75,$86,$5a));
CLSID_CDirect3DRMDevice: TGUID = '{4FA3568E-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMViewport: TGUID = '{4FA3568F-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMFrame: TGUID = '{4FA35690-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMMesh: TGUID = '{4FA35691-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMMeshBuilder: TGUID = '{4FA35692-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMFace: TGUID = '{4FA35693-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMLight: TGUID = '{4FA35694-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMTexture: TGUID = '{4FA35695-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMWrap: TGUID = '{4FA35696-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMMaterial: TGUID = '{4FA35697-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMAnimation: TGUID = '{4FA35698-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMAnimationSet: TGUID = '{4FA35699-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMUserVisual: TGUID = '{4FA3569A-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMShadow: TGUID = '{4FA3569B-623F-11CF-AC4A-0000C03825A1}';
CLSID_CDirect3DRMViewportInterpolator: TGUID = '{0DE9EAA1-3B84-11D0-9B6D-0000C0781BC3}';
CLSID_CDirect3DRMFrameInterpolator: TGUID = '{0DE9EAA2-3B84-11D0-9B6D-0000C0781BC3}';
CLSID_CDirect3DRMMeshInterpolator: TGUID = '{0DE9EAA3-3B84-11D0-9B6D-0000C0781BC3}';
CLSID_CDirect3DRMLightInterpolator: TGUID = '{0DE9EAA6-3B84-11D0-9B6D-0000C0781BC3}';
CLSID_CDirect3DRMMaterialInterpolator: TGUID = '{0DE9EAA7-3B84-11D0-9B6D-0000C0781BC3}';
CLSID_CDirect3DRMTextureInterpolator: TGUID = '{0DE9EAA8-3B84-11D0-9B6D-0000C0781BC3}';
CLSID_CDirect3DRMProgressiveMesh: TGUID = '{4516EC40-8F20-11D0-9B6D-0000C0781BC3}';
CLSID_CDirect3DRMClippedVisual: TGUID = '{5434E72D-6D66-11D1-BB0B-0000F875865A}';
 
{ Direct3DRM Object interfaces }
 
IID_IDirect3DRMObject: TGUID = '{EB16CB00-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMObject2: TGUID = '{4516EC7C-8F20-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRMDevice: TGUID = '{E9E19280-6E05-11CF-AC4A-0000C03825A1}';
IID_IDirect3DRMDevice2: TGUID = '{4516EC78-8F20-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRMDevice3: TGUID = '{549F498B-BFEB-11D1-8ED8-00A0C967A482}';
IID_IDirect3DRMViewport: TGUID = '{EB16CB02-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMViewport2: TGUID = '{4A1B1BE6-BFED-11D1-8ED8-00A0C967A482}';
IID_IDirect3DRMFrame: TGUID = '{EB16CB03-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMFrame2: TGUID = '{C3DFBD60-3988-11D0-9EC2-0000C0291AC3}';
IID_IDirect3DRMFrame3: TGUID = '{FF6B7F70-A40E-11D1-91F9-0000F8758E66}';
IID_IDirect3DRMVisual: TGUID = '{EB16CB04-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMMesh: TGUID = '{A3A80D01-6E12-11CF-AC4A-0000C03825A1}';
IID_IDirect3DRMMeshBuilder: TGUID = '{A3A80D02-6E12-11CF-AC4A-0000C03825A1}';
IID_IDirect3DRMMeshBuilder2: TGUID = '{4516EC77-8F20-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRMMeshBuilder3: TGUID = '{4516EC82-8F20-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRMFace: TGUID = '{EB16CB07-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMFace2: TGUID = '{4516EC81-8F20-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRMLight: TGUID = '{EB16CB08-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMTexture: TGUID = '{EB16CB09-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMTexture2: TGUID = '{120F30C0-1629-11D0-941C-0080C80CFA7B}';
IID_IDirect3DRMTexture3: TGUID = '{FF6B7F73-A40E-11D1-91F9-0000F8758E66}';
IID_IDirect3DRMWrap: TGUID = '{EB16CB0A-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMMaterial: TGUID = '{EB16CB0B-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMMaterial2: TGUID = '{FF6B7F75-A40E-11D1-91F9-0000F8758E66}';
IID_IDirect3DRMAnimation: TGUID = '{EB16CB0D-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMAnimation2: TGUID = '{FF6B7F77-A40E-11D1-91F9-0000F8758E66}';
IID_IDirect3DRMAnimationSet: TGUID = '{EB16CB0E-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMAnimationSet2: TGUID = '{FF6B7F79-A40E-11D1-91F9-0000F8758E66}';
IID_IDirect3DRMObjectArray: TGUID = '{242F6BC2-3849-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRMDeviceArray: TGUID = '{EB16CB10-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMViewportArray: TGUID = '{EB16CB11-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMFrameArray: TGUID = '{EB16CB12-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMVisualArray: TGUID = '{EB16CB13-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMLightArray: TGUID = '{EB16CB14-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMPickedArray: TGUID = '{EB16CB16-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMFaceArray: TGUID = '{EB16CB17-D271-11CE-AC48-0000C03825A1}';
IID_IDirect3DRMAnimationArray: TGUID = '{D5F1CAE0-4BD7-11D1-B974-0060083E45F3}';
IID_IDirect3DRMUserVisual: TGUID = '{59163DE0-6D43-11CF-AC4A-0000C03825A1}';
IID_IDirect3DRMShadow: TGUID = '{AF359780-6BA3-11CF-AC4A-0000C03825A1}';
IID_IDirect3DRMShadow2: TGUID = '{86B44E25-9C82-11D1-BB0B-00A0C981A0A6}';
IID_IDirect3DRMInterpolator: TGUID = '{242F6BC1-3849-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRMProgressiveMesh: TGUID = '{4516EC79-8F20-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRMPicked2Array: TGUID = '{4516EC7B-8F20-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRMClippedVisual: TGUID = '{5434E733-6D66-11D1-BB0B-0000F875865A}';
 
IID_IDirect3DRMWinDevice: TGUID = '{C5016CC0-D273-11CE-AC48-0000C03825A1}';
IID_IDirect3DRM: TGUID = '{2BC49361-8327-11CF-AC4A-0000C03825A1}';
IID_IDirect3DRM2: TGUID = '{4516ECC8-8F20-11D0-9B6D-0000C0781BC3}';
IID_IDirect3DRM3: TGUID = '{4516EC83-8F20-11D0-9B6D-0000C0781BC3}';
 
type
IDirect3DRMObject = interface;
IDirect3DRMObject2 = interface;
IDirect3DRMDevice = interface;
IDirect3DRMDevice2 = interface;
IDirect3DRMDevice3 = interface;
10039,117 → 6523,94
IDirect3DRMWrap = interface;
IDirect3DRMMaterial = interface;
IDirect3DRMMaterial2 = interface;
IDirect3DRMInterpolator = interface;
IDirect3DRMAnimation = interface;
IDirect3DRMAnimation2 = interface;
IDirect3DRMAnimationSet = interface;
IDirect3DRMAnimationSet2 = interface;
IDirect3DRMUserVisual = interface;
IDirect3DRMShadow = interface;
IDirect3DRMShadow2 = interface;
IDirect3DRMArray = interface;
IDirect3DRMObjectArray = interface;
IDirect3DRMDeviceArray = interface;
IDirect3DRMFaceArray = interface;
IDirect3DRMViewportArray = interface;
IDirect3DRMFrameArray = interface;
IDirect3DRMAnimationArray = interface;
IDirect3DRMVisualArray = interface;
IDirect3DRMPickedArray = interface;
IDirect3DRMPicked2Array = interface;
IDirect3DRMLightArray = interface;
IDirect3DRMPickedArray = interface;
IDirect3DRMFaceArray = interface;
IDirect3DRMAnimationArray = interface;
IDirect3DRMUserVisual = interface;
IDirect3DRMShadow = interface;
IDirect3DRMShadow2 = interface;
IDirect3DRMInterpolator = interface;
IDirect3DRMProgressiveMesh = interface;
IDirect3DRMPicked2Array = interface;
IDirect3DRMClippedVisual = interface;
 
(*
* Direct3DRM Object interfaces
*)
IID_IDirect3DRMObject = IDirect3DRMObject;
IID_IDirect3DRMDevice = IDirect3DRMDevice;
IID_IDirect3DRMDevice2 = IDirect3DRMDevice2;
IID_IDirect3DRMDevice3 = IDirect3DRMDevice3;
IID_IDirect3DRMViewport = IDirect3DRMViewport;
IID_IDirect3DRMViewport2 = IDirect3DRMViewport2;
IID_IDirect3DRMFrame = IDirect3DRMFrame;
IID_IDirect3DRMFrame2 = IDirect3DRMFrame2;
IID_IDirect3DRMFrame3 = IDirect3DRMFrame3;
IID_IDirect3DRMVisual = IDirect3DRMVisual;
IID_IDirect3DRMMesh = IDirect3DRMMesh;
IID_IDirect3DRMMeshBuilder = IDirect3DRMMeshBuilder;
IID_IDirect3DRMMeshBuilder2 = IDirect3DRMMeshBuilder2;
IID_IDirect3DRMMeshBuilder3 = IDirect3DRMMeshBuilder3;
IID_IDirect3DRMFace = IDirect3DRMFace;
IID_IDirect3DRMFace2 = IDirect3DRMFace2;
IID_IDirect3DRMLight = IDirect3DRMLight;
IID_IDirect3DRMTexture = IDirect3DRMTexture;
IID_IDirect3DRMTexture2 = IDirect3DRMTexture2;
IID_IDirect3DRMTexture3 = IDirect3DRMTexture3;
IID_IDirect3DRMWrap = IDirect3DRMWrap;
IID_IDirect3DRMMaterial = IDirect3DRMMaterial;
IID_IDirect3DRMMaterial2 = IDirect3DRMMaterial2;
IID_IDirect3DRMAnimation = IDirect3DRMAnimation;
IID_IDirect3DRMAnimation2 = IDirect3DRMAnimation2;
IID_IDirect3DRMAnimationSet = IDirect3DRMAnimationSet;
IID_IDirect3DRMAnimationSet2 = IDirect3DRMAnimationSet2;
IID_IDirect3DRMObjectArray = IDirect3DRMObjectArray;
IID_IDirect3DRMDeviceArray = IDirect3DRMDeviceArray;
IID_IDirect3DRMViewportArray = IDirect3DRMViewportArray;
IID_IDirect3DRMFrameArray = IDirect3DRMFrameArray;
IID_IDirect3DRMVisualArray = IDirect3DRMVisualArray;
IID_IDirect3DRMLightArray = IDirect3DRMLightArray;
IID_IDirect3DRMPickedArray = IDirect3DRMPickedArray;
IID_IDirect3DRMFaceArray = IDirect3DRMFaceArray;
IID_IDirect3DRMAnimationArray = IDirect3DRMAnimationArray;
IID_IDirect3DRMUserVisual = IDirect3DRMUserVisual;
IID_IDirect3DRMShadow = IDirect3DRMShadow;
IID_IDirect3DRMShadow2 = IDirect3DRMShadow2;
IID_IDirect3DRMInterpolator = IDirect3DRMInterpolator;
IID_IDirect3DRMProgressiveMesh = IDirect3DRMProgressiveMesh;
IID_IDirect3DRMPicked2Array = IDirect3DRMPicked2Array;
IID_IDirect3DRMClippedVisual = IDirect3DRMClippedVisual;
IDirect3DRMWinDevice = interface;
IDirect3DRM = interface;
IDirect3DRM2 = interface;
IDirect3DRM3 = interface;
 
TD3DRMObjectCallback = procedure(obj: IDirect3DRMObject; arg: Pointer); cdecl;
D3DRMOBJECTCALLBACK = TD3DRMObjectCallback;
 
TD3DRMFrameMoveCallback = procedure(obj: IDirect3DRMFrame; arg: Pointer; delta: TD3DValue); cdecl;
D3DRMFRAMEMOVECALLBACK = TD3DRMFrameMoveCallback;
 
TD3DRMFrame3MoveCallback = procedure(obj: IDirect3DRMFrame3; arg: Pointer; delta: TD3DValue); cdecl;
D3DRMFRAME3MOVECALLBACK = TD3DRMFrame3MoveCallback;
 
TD3DRMUpdateCallback = procedure(obj: IDirect3DRMDevice; arg: Pointer;
iRectCount: DWORD; d3dRectUpdate: PD3DRect); cdecl;
D3DRMUPDATECALLBACK = TD3DRMUpdateCallback;
 
PIDirect3DRMFaceArray = ^IDirect3DRMFaceArray;
TD3DRMDevice3UpdateCallback = procedure(obj: IDirect3DRMDevice3; arg: Pointer;
iRectCount: DWORD; d3dRectUpdate: PD3DRect); cdecl;
D3DRMDEVICE3UPDATECALLBACK = TD3DRMDevice3UpdateCallback;
 
TD3DRMObjectCallback = procedure (lpD3DRMobj: IDirect3DRMObject;
lpArg: Pointer); cdecl;
TD3DRMFrameMoveCallback = procedure (lpD3DRMFrame: IDirect3DRMFrame;
lpArg: Pointer; delta: TD3DValue); cdecl;
TD3DRMFrame3MoveCallback = procedure (lpD3DRMFrame: IDirect3DRMFrame3;
lpArg: Pointer; delta: TD3DValue); cdecl;
TD3DRMUpdateCallback = procedure (lpobj: IDirect3DRMDevice; lpArg: Pointer;
iRectCount: Integer; const d3dRectUpdate: TD3DRect); cdecl;
TD3DRMDevice3UpdateCallback = procedure (lpobj: IDirect3DRMDevice3;
lpArg: Pointer; iRectCount: Integer; const d3dRectUpdate: TD3DRect);cdecl;
TD3DRMUserVisualCallback = function (lpD3DRMUV: IDirect3DRMUserVisual;
lpArg: Pointer; lpD3DRMUVreason: TD3DRMUserVisualReason;
lpD3DRMDev: IDirect3DRMDevice;
lpD3DRMview: IDirect3DRMViewport) : Integer; cdecl;
TD3DRMLoadTextureCallback = function (tex_name: PAnsiChar; lpArg: Pointer;
lpD3DRMview: IDirect3DRMViewport): Longint; cdecl;
D3DRMUSERVISUALCALLBACK = TD3DRMUserVisualCallback;
 
TD3DRMLoadTextureCallback = function(tex_name: PChar; arg: Pointer;
out lpD3DRMTex: IDirect3DRMTexture) : HResult; cdecl;
TD3DRMLoadTexture3Callback = function (tex_name: PAnsiChar; lpArg: Pointer;
D3DRMLOADTEXTURECALLBACK = TD3DRMLoadTextureCallback;
 
TD3DRMLoadTexture3Callback = function(tex_name: PChar; arg: Pointer;
out lpD3DRMTex: IDirect3DRMTexture3) : HResult; cdecl;
TD3DRMLoadCallback = procedure (lpObject: IDirect3DRMObject;
const ObjectGuid: TGUID; lpArg: Pointer); cdecl;
D3DRMLOADTEXTURE3CALLBACK = TD3DRMLoadTexture3Callback;
 
TD3DRMLoadCallback = procedure(lpObject: IDirect3DRMObject; const ObjectGuid: TGUID;
lpArg: Pointer); cdecl;
D3DRMLOADCALLBACK = TD3DRMLoadCallback;
 
TD3DRMDownSampleCallback = function (lpDirect3DRMTexture: IDirect3DRMTexture3;
pArg: pointer; pDDSSrc, pDDSDst: IDirectDrawSurface) : HResult; cdecl;
pArg: Pointer; pDDSSrc, pDDSDst: IDirectDrawSurface): HResult; cdecl;
D3DRMDOWNSAMPLECALLBACK = TD3DRMDownSampleCallback;
 
TD3DRMValidationCallback = function (lpDirect3DRMTexture: IDirect3DRMTexture3;
pArg: pointer; dwFlags, DWcRects: DWORD; const pRects: TRect) : HResult; cdecl;
pArg: Pointer; dwFlags: DWORD; dwcRects: DWORD; pRects: PRect): HResult; cdecl;
D3DRMVALIDATIONCALLBACK = TD3DRMValidationCallback;
 
{ TD3DRMPickDesc }
 
PD3DRMPickDesc = ^TD3DRMPickDesc;
TD3DRMPickDesc = packed record
ulFaceIdx: DWORD;
lGroupIdx: LongInt;
TD3DRMPickDesc = record
ulFaceIdx: Longint;
lGroupIdx: Longint;
vPosition: TD3DVector;
end;
 
D3DRMPICKDESC = TD3DRMPickDesc;
LPD3DRMPICKDESC = PD3DRMPickDesc;
 
{ TD3DRMPickDesc2 }
 
PD3DRMPickDesc2 = ^TD3DRMPickDesc2;
TD3DRMPickDesc2 = packed record
ulFaceIdx: DWORD;
lGroupIdx: LongInt;
TD3DRMPickDesc2 = record
ulFaceIdx: Longint;
lGroupIdx: Longint;
dvPosition: TD3DVector;
tu, tv: TD3DValue;
dvNormal: TD3DVector;
10156,20 → 6617,13
dcColor: TD3DColor;
end;
 
(*
* Base class
*)
{$IFDEF D2COM}
IDirect3DRMObject = class (IUnknown)
{$ELSE}
D3DRMPICKDESC2 = TD3DRMPickDesc2;
LPD3DRMPICKDESC2 = PD3DRMPickDesc2;
 
IDirect3DRMObject = interface (IUnknown)
['{eb16cb00-d271-11ce-ac48-0000c03825a1}']
{$ENDIF}
(*
* The methods for IDirect3DRMObject
*)
function Clone (pUnkOuter: IUnknown; riid: TGUID;
var ppvObj: Pointer) : HResult; stdcall;
['{EB16CB00-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMObject methods
function Clone(pUnkOuter: IUnknown; const riid: TGUID; out ppvObj): HResult; stdcall;
function AddDestroyCallback (lpCallback: TD3DRMObjectCallback;
lpArg: Pointer) : HResult; stdcall;
function DeleteDestroyCallback (d3drmObjProc: TD3DRMObjectCallback;
10176,23 → 6630,38
lpArg: Pointer) : HResult; stdcall;
function SetAppData (ulData: DWORD) : HResult; stdcall;
function GetAppData: DWORD; stdcall;
function SetName (lpName: PAnsiChar) : HResult; stdcall;
function GetName (var lpdwSize: DWORD; lpName: PAnsiChar) : HResult; stdcall;
function GetClassName (var lpdwSize: DWORD; lpName: PAnsiChar) : HResult; stdcall;
function SetName(lpName: PChar): HResult; stdcall;
function GetName(var lpdwSize: DWORD; lpName: PChar): HResult; stdcall;
function GetClassName(var lpdwSize: DWORD; lpName: PChar): HResult; stdcall;
end;
 
IDirect3DRMObject2 = interface(IUnknown)
['{EB16CB00-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMObject2 methods
function AddDestroyCallback(lpCallback: TD3DRMObjectCallback; lpArg: Pointer): HResult; stdcall;
function Clone(pUnkOuter: IUnknown; const riid: TGUID;
out ppvObj): HResult; stdcall;
function DeleteDestroyCallback(d3drmObjProc: TD3DRMObjectCallback;
lpArg: Pointer): HResult; stdcall;
function GetClientData(dwID: DWORD; var lplpvData: Pointer): HResult; stdcall;
function GetDirect3DRM(out lplpDirect3DRM: IDirect3DRM): HResult; stdcall;
function GetName(var lpdwSize: DWORD; lpName: LPSTR): HResult; stdcall;
function SetClientData(dwID: DWORD; lplpvData: Pointer; dwFlags: DWORD): HResult; stdcall;
function SetName(lpName: PChar): HResult; stdcall;
function GetAge(dwFlags: DWORD; var pdwAge: DWORD): HResult; stdcall;
end;
 
IDirect3DRMVisual = interface (IDirect3DRMObject)
['{EB16CB04-D271-11CE-AC48-0000C03825A1}']
end;
 
IDirect3DRMDevice = interface (IDirect3DRMObject)
['{e9e19280-6e05-11cf-ac4a-0000c03825a1}']
(*
* IDirect3DRMDevice methods
*)
function Init (width: LongInt; height: LongInt) : HResult; stdcall;
['{E9E19280-6E05-11CF-AC4A-0000C03825A1}']
// IDirect3DRMDevice methods
function Init(width, height: DWORD): HResult; stdcall;
function InitFromD3D (lpD3D: IDirect3D; lpD3DIMDev: IDirect3DDevice) : HResult; stdcall;
function InitFromClipper (lpDDClipper: IDirectDrawClipper; lpGUID: PGUID;
width: Integer; height: Integer) : HResult; stdcall;
function InitFromClipper(lpDDClipper: IDirectDrawClipper;
const lpGUID: TGUID; width, height: DWORD): HResult; stdcall;
function Update: HResult; stdcall;
function AddUpdateCallback (d3drmUpdateProc: TD3DRMUpdateCallback;
arg: Pointer) : HResult; stdcall;
10218,79 → 6687,36
end;
 
IDirect3DRMDevice2 = interface (IDirect3DRMDevice)
['{4516ec78-8f20-11d0-9b6d-0000c0781bc3}']
(*
* IDirect3DRMDevice2 methods
*)
['{4516EC78-8F20-11D0-9B6D-0000C0781BC3}']
// IDirect3DRMDevice2 methods
function InitFromD3D2(lpD3D: IDirect3D2; lpD3DIMDev: IDirect3DDevice2) : HResult; stdcall;
function InitFromSurface(const lpGUID: TGUID; lpDD: IDirectDraw; lpDDSBack: IDirectDrawSurface) : HResult; stdcall;
function SetRenderMode(dwFlags: DWORD ) : HResult; stdcall;
function GetRenderMode : DWORD; stdcall;
function GetDirect3DDevice2(out lplpD3DDevice: IDirect3DDevice2) : HResult; stdcall;
end;
 
IDirect3DRMDevice3 = interface (IDirect3DRMObject)
['{549f498b-bfeb-11d1-8ed8-00a0c967a482}']
(*
* IDirect3DRMDevice methods
*)
function Init (width: LongInt; height: LongInt) : HResult; stdcall;
function InitFromD3D (lpD3D: IDirect3D2; lpD3DIMDev: IDirect3DDevice2) : HResult; stdcall;
function InitFromClipper (lpDDClipper: IDirectDrawClipper; lpGUID: PGUID;
width: Integer; height: Integer) : HResult; stdcall;
function Update: HResult; stdcall;
function AddUpdateCallback (d3drmUpdateProc: TD3DRMDevice3UpdateCallback;
arg: Pointer) : HResult; stdcall;
function DeleteUpdateCallback (d3drmUpdateProc: TD3DRMDevice3UpdateCallback;
arg: Pointer) : HResult; stdcall;
function SetBufferCount (dwCount: DWORD) : HResult; stdcall;
function GetBufferCount: DWORD; stdcall;
function SetDither (bDither: BOOL) : HResult; stdcall;
function SetShades (ulShades: DWORD) : HResult; stdcall;
function SetQuality (rqQuality: TD3DRMRenderQuality) : HResult; stdcall;
function SetTextureQuality (tqTextureQuality: TD3DRMTextureQuality) : HResult; stdcall;
function GetViewports (out lplpViewports: IDirect3DRMViewportArray) : HResult; stdcall;
function GetDither: BOOL; stdcall;
function GetShades: DWORD; stdcall;
function GetHeight: DWORD; stdcall;
function GetWidth: DWORD; stdcall;
function GetTrianglesDrawn: DWORD; stdcall;
function GetWireframeOptions: DWORD; stdcall;
function GetQuality: TD3DRMRenderQuality; stdcall;
function GetColorModel: TD3DColorModel; stdcall;
function GetTextureQuality: TD3DRMTextureQuality; stdcall;
function GetDirect3DDevice (out lplpD3DDevice: IDirect3DDevice) : HResult; stdcall;
(*
* IDirect3DRMDevice2 methods
*)
function InitFromD3D2(lpD3D: IDirect3D2; lpD3DIMDev: IDirect3DDevice2) : HResult; stdcall;
function InitFromSurface(const lpGUID: TGUID; lpDD: IDirectDraw;
lpDDSBack: IDirectDrawSurface) : HResult; stdcall;
function SetRenderMode(dwFlags: DWORD ) : HResult; stdcall;
function GetRenderMode : DWORD; stdcall;
function GetDirect3DDevice2(out lplpD3DDevice: IDirect3DDevice2) : HResult; stdcall;
(*
* IDirect3DRMDevice3 methods
*)
function FindPreferredTextureFormat (dwBitDepths, dwFlags: DWORD;
out lpDDPF: TDDPixelFormat) : HResult; stdcall;
function RenderStateChange (dwStateNum, dwVal, dwFlags: DWORD) : HResult; stdcall;
end;
 
function LightStateChange (drsType: TD3DLightStateType; // defined different in header and help
dwVal, dwFlags: DWORD) : HResult; stdcall;
function GetStateChangeOptions (dwStateClass, dwStateNum: DWORD;
IDirect3DRMDevice3 = interface(IDirect3DRMDevice2)
['{549F498B-BFEB-11D1-8ED8-00A0C967A482}']
// IDirect3DRMDevice3 methods
function FindPreferredTextureFormat(dwBitDepths: DWORD; dwFlags: DWORD;
var lpDDPF: TDDPixelFormat): HResult; stdcall;
function RenderStateChange(drsType: TD3DRenderStateType; dwVal: DWORD;
dwFlags: DWORD): HResult; stdcall;
function LightStateChange(drsType: TD3DLightStateType; dwVal: DWORD;
dwFlags: DWORD): HResult; stdcall;
function GetStateChangeOptions(dwStateClass: DWORD; dwStateNum: DWORD;
var pdwFlags: DWORD) : HResult; stdcall;
function SetStateChangeOptions ( dwStateClass, dwStateNum, dwFlags: DWORD) : HResult; stdcall;
function SetStateChangeOptions(dwStateClass: DWORD; dwStateNum: DWORD;
dwFlags: DWORD): HResult; stdcall;
end;
 
IDirect3DRMViewport = interface (IDirect3DRMObject)
['{eb16cb02-d271-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMViewport methods
*)
['{EB16CB02-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMViewport methods
function Init (lpD3DRMDevice: IDirect3DRMDevice;
lpD3DRMFrameCamera: IDirect3DRMFrame; xpos, ypos,
width, height: DWORD) : HResult; stdcall;
lpD3DRMFrameCamera: IDirect3DRMFrame; xpos, ypos, width, height: DWORD): HResult; stdcall;
function Clear: HResult; stdcall;
function Render (lpD3DRMFrame: IDirect3DRMFrame) : HResult; stdcall;
function SetFront (rvFront: TD3DValue) : HResult; stdcall;
10299,20 → 6725,20
function SetUniformScaling (bScale: BOOL) : HResult; stdcall;
function SetCamera (lpCamera: IDirect3DRMFrame) : HResult; stdcall;
function SetProjection (rptType: TD3DRMProjectionType) : HResult; stdcall;
function Transform (out lprvDst: TD3DRMVector4D; const lprvSrc: TD3DVector) : HResult; stdcall;
function InverseTransform (out lprvDst: TD3DVector;
const lprvSrc: TD3DRMVector4D) : HResult; stdcall;
function Configure (lX, lY: LongInt; dwWidth, dwHeight: DWORD) : HResult; stdcall;
function Transform(var lprvDst: TD3DRMVector4D; const lprvSrc: TD3DVector): HResult; stdcall;
function InverseTransform(var lprvDst: TD3DVector;
var lprvSrc: TD3DRMVector4D): HResult; stdcall;
function Configure(lX, lY: Longint; dwWidth, dwHeight: DWORD): HResult; stdcall;
function ForceUpdate (dwX1, dwY1, dwX2, dwY2: DWORD) : HResult; stdcall;
function SetPlane (rvLeft, rvRight, rvBottom, rvTop: TD3DValue) : HResult; stdcall;
function GetCamera (out lpCamera: IDirect3DRMFrame) : HResult; stdcall;
function GetDevice (out lpD3DRMDevice: IDirect3DRMDevice) : HResult; stdcall;
function GetPlane (out lpd3dvLeft, lpd3dvRight, lpd3dvBottom, lpd3dvTop:
TD3DValue) : HResult; stdcall;
function Pick (lX, lY: LongInt; var lplpVisuals: IDirect3DRMPickedArray) : HResult; stdcall;
function GetPlane(var lpd3dvLeft, lpd3dvRight, lpd3dvBottom,
lpd3dvTop: TD3DValue): HResult; stdcall;
function Pick(lX, lY: Longint; out lplpVisuals: IDirect3DRMPickedArray): HResult; stdcall;
function GetUniformScaling: BOOL; stdcall;
function GetX: LongInt; stdcall;
function GetY: LongInt; stdcall;
function GetX: Longint; stdcall;
function GetY: Longint; stdcall;
function GetWidth: DWORD; stdcall;
function GetHeight: DWORD; stdcall;
function GetField: TD3DValue; stdcall;
10323,13 → 6749,10
end;
 
IDirect3DRMViewport2 = interface (IDirect3DRMObject)
['{4a1b1be6-bfed-11d1-8ed8-00a0c967a482}']
(*
* IDirect3DRMViewport2 methods
*)
function Init (lpD3DRMDevice: IDirect3DRMDevice3;
lpD3DRMFrameCamera: IDirect3DRMFrame3; xpos, ypos,
width, height: DWORD) : HResult; stdcall;
['{4A1B1BE6-BFED-11D1-8ED8-00A0C967A482}']
// IDirect3DRMViewport2 methods
function Init(dec: IDirect3DRMDevice3; camera: IDirect3DRMFrame3;
xpos, ypos: DWORD; width, height: DWORD): HResult; stdcall;
function Clear (dwFlags: DWORD): HResult; stdcall;
function Render (lpD3DRMFrame: IDirect3DRMFrame3) : HResult; stdcall;
function SetFront (rvFront: TD3DValue) : HResult; stdcall;
10338,20 → 6761,20
function SetUniformScaling (bScale: BOOL) : HResult; stdcall;
function SetCamera (lpCamera: IDirect3DRMFrame3) : HResult; stdcall;
function SetProjection (rptType: TD3DRMProjectionType) : HResult; stdcall;
function Transform (out lprvDst: TD3DRMVector4D; const lprvSrc: TD3DVector) : HResult; stdcall;
function InverseTransform (out lprvDst: TD3DVector;
function Transform(var lprvDst: TD3DRMVector4D; const lprvSrc: TD3DVector): HResult; stdcall;
function InverseTransform(var lprvDst: TD3DVector;
const lprvSrc: TD3DRMVector4D) : HResult; stdcall;
function Configure (lX, lY: LongInt; dwWidth, dwHeight: DWORD) : HResult; stdcall;
function Configure(lX, lY: Longint; dwWidth, dwHeight: DWORD): HResult; stdcall;
function ForceUpdate (dwX1, dwY1, dwX2, dwY2: DWORD) : HResult; stdcall;
function SetPlane (rvLeft, rvRight, rvBottom, rvTop: TD3DValue) : HResult; stdcall;
function GetCamera (out lpCamera: IDirect3DRMFrame3) : HResult; stdcall;
function GetDevice (out lpD3DRMDevice: IDirect3DRMDevice3) : HResult; stdcall;
function GetPlane (out lpd3dvLeft, lpd3dvRight, lpd3dvBottom, lpd3dvTop:
TD3DValue) : HResult; stdcall;
function Pick (lX, lY: LongInt; var lplpVisuals: IDirect3DRMPickedArray) : HResult; stdcall;
function GetPlane(var lpd3dvLeft, lpd3dvRight, lpd3dvBottom,
lpd3dvTop: TD3DValue): HResult; stdcall;
function Pick(lX, lY: Longint; out lplpVisuals: IDirect3DRMPickedArray): HResult; stdcall;
function GetUniformScaling: BOOL; stdcall;
function GetX: LongInt; stdcall;
function GetY: LongInt; stdcall;
function GetX: Longint; stdcall;
function GetY: Longint; stdcall;
function GetWidth: DWORD; stdcall;
function GetHeight: DWORD; stdcall;
function GetField: TD3DValue; stdcall;
10358,18 → 6781,16
function GetBack: TD3DValue; stdcall;
function GetFront: TD3DValue; stdcall;
function GetProjection: TD3DRMProjectionType; stdcall;
function GetDirect3DViewport (var lplpD3DViewport: IDirect3DViewport) : HResult; stdcall;
function TransformVectors (dwNumVectors: DWORD; out lpDstVectors:
TD3DRMVector4D; const lpSrcVectors: TD3DVector) : HResult; stdcall;
function InverseTransformVectors (dwNumVectors: DWORD; out lpDstVectors:
TD3DRMVector4D; const lpSrcVectors: TD3DVector) : HResult; stdcall;
function GetDirect3DViewport(out lplpD3DViewport: IDirect3DViewport): HResult; stdcall;
function TransformVectors(dwNumVectors: DWORD; var lpDstVectors: TD3DRMVector4D;
const lpSrcVectors: TD3DVector): HResult; stdcall;
function InverseTransformVectors(dwNumVectors: DWORD; var lpDstVectors: TD3DVector;
const lpSrcVectors: TD3DRMVector4D): HResult; stdcall;
end;
 
IDirect3DRMFrame = interface (IDirect3DRMVisual)
['{eb16cb03-d271-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMFrame methods
*)
['{EB16CB03-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMFrame methods
function AddChild (lpD3DRMFrameChild: IDirect3DRMFrame) : HResult; stdcall;
function AddLight (lpD3DRMLight: IDirect3DRMLight) : HResult; stdcall;
function AddMoveCallback (d3drmFMC: TD3DRMFrameMoveCallback;
10376,9 → 6797,10
lpArg: Pointer) : HResult; stdcall;
function AddTransform (rctCombine: TD3DRMCombineType;
rmMatrix: TD3DRMMatrix4D) : HResult; stdcall;
function AddTranslation (rctCombine: TD3DRMCombineType; rvX, rvY, rvZ:
TD3DValue) : HResult; stdcall;
function AddScale (rctCombine: TD3DRMCombineType; rvX, rvY, rvZ: TD3DValue) : HResult; stdcall;
function AddTranslation(rctCombine: TD3DRMCombineType; rvX, rvY,
rvZ: TD3DValue): HResult; stdcall;
function AddScale(rctCombine: TD3DRMCombineType; rvX, rvY,
rvZ: TD3DValue): HResult; stdcall;
function AddRotation (rctCombine: TD3DRMCombineType; rvX, rvY, rvZ,
rvTheta: TD3DValue) : HResult; stdcall;
function AddVisual (lpD3DRMVisual: IDirect3DRMVisual) : HResult; stdcall;
10387,20 → 6809,20
function GetLights (out lplpLights: IDirect3DRMLightArray) : HResult; stdcall;
function GetMaterialMode: TD3DRMMaterialMode; stdcall;
function GetParent (out lplpParent: IDirect3DRMFrame) : HResult; stdcall;
function GetPosition (lpRef: IDirect3DRMFrame; out lprvPos: TD3DVector) : HResult; stdcall;
function GetRotation (lpRef: IDirect3DRMFrame; out lprvAxis: TD3DVector;
out lprvTheta: TD3DValue) : HResult; stdcall;
function GetPosition(lpRef: IDirect3DRMFrame; var lprvPos: TD3DVector): HResult; stdcall;
function GetRotation(lpRef: IDirect3DRMFrame; var lprvAxis: TD3DVector;
var lprvTheta: TD3DValue): HResult; stdcall;
function GetScene (out lplpRoot: IDirect3DRMFrame) : HResult; stdcall;
function GetSortMode: TD3DRMSortMode; stdcall;
function GetTexture (out lplpTexture: IDirect3DRMTexture) : HResult; stdcall;
function GetTransform (out rmMatrix: TD3DRMMatrix4D) : HResult; stdcall;
function GetTransform(var rmMatrix: TD3DRMMatrix4D): HResult; stdcall;
function GetVelocity (lpRef: IDirect3DRMFrame; var lprvVel: TD3DVector;
fRotVel: BOOL) : HResult; stdcall;
function GetOrientation (lpRef: IDirect3DRMFrame; var lprvDir: TD3DVector;
var lprvUp: TD3DVector) : HResult; stdcall;
function GetVisuals (out lplpVisuals: IDirect3DRMVisualArray) : HResult; stdcall;
function GetTextureTopology (out lpU, lpV: BOOL) : HResult; stdcall;
function InverseTransform (out lprvDst: TD3DVector; const lprvSrc: TD3DVector) : HResult; stdcall;
function GetTextureTopology(var lpU, lpV: BOOL): HResult; stdcall;
function InverseTransform(var lprvDst, lprvSrc: TD3DVector): HResult; stdcall;
function Load (lpvObjSource: Pointer; lpvObjID: Pointer;
d3drmLOFlags: TD3DRMLoadOptions; d3drmLoadTextureProc:
TD3DRMLoadTextureCallback; lpArgLTP: Pointer) : HResult; stdcall;
10417,7 → 6839,7
function GetSceneFogColor: TD3DColor; stdcall;
function GetSceneFogEnable: BOOL; stdcall;
function GetSceneFogMode: TD3DRMFogMode; stdcall;
function GetSceneFogParams (out lprvStart, lprvEnd, lprvDensity: TD3DValue) : HResult; stdcall;
function GetSceneFogParams(var lprvStart, lprvEnd, lprvDensity: TD3DValue): HResult; stdcall;
function SetSceneBackground (rcColor: TD3DColor) : HResult; stdcall;
function SetSceneBackgroundRGB (rvRed, rvGreen, rvBlue: TD3DValue) : HResult; stdcall;
function SetSceneBackgroundDepth (lpImage: IDirectDrawSurface) : HResult; stdcall;
10441,41 → 6863,34
function SetVelocity (lpRef: IDirect3DRMFrame; rvX, rvY, rvZ: TD3DValue;
fRotVel: BOOL) : HResult; stdcall;
function SetZbufferMode (d3drmZBM: TD3DRMZBufferMode) : HResult; stdcall;
function Transform (out lpd3dVDst: TD3DVector; const lpd3dVSrc: TD3DVector) : HResult; stdcall;
function Transform(var lpd3dVDst, lpd3dVSrc: TD3DVector): HResult; stdcall;
end;
 
IDirect3DRMFrame2 = interface (IDirect3DRMFrame)
['{c3dfbd60-3988-11d0-9ec2-0000c0291ac3}']
(*
* IDirect3DRMFrame2 methods
*)
['{C3DFBD60-3988-11D0-9EC2-0000C0291AC3}']
// IDirect3DRMFrame2 methods
function AddMoveCallback2 (d3drmFMC: TD3DRMFrameMoveCallback; lpArg:
Pointer; dwFlags: DWORD) : HResult; stdcall;
function GetBox (out lpTD3DRMBox: TD3DRMBox) : HResult; stdcall;
function GetBoxEnable : boolean; stdcall;
function GetAxes (out dir, up: TD3DVector) : HResult; stdcall;
function GetBox(var lpD3DRMBox: TD3DRMBox): HResult; stdcall;
function GetBoxEnable: BOOL; stdcall;
function GetAxes(var dir, up: TD3DVector): HResult; stdcall;
function GetMaterial (out lplpMaterial: IDirect3DRMMaterial) : HResult; stdcall;
function GetInheritAxes : boolean; stdcall;
function GetHierarchyBox (out lpTD3DRMBox: TD3DRMBox) : HResult; stdcall;
function SetBox (const lpTD3DRMBox: TD3DRMBox) : HResult; stdcall;
function GetInheritAxes: BOOL; stdcall;
function GetHierarchyBox(var lpD3DRMBox: TD3DRMBox): HResult; stdcall;
function SetBox(const lpD3DRMBox: TD3DRMBox): HResult; stdcall;
function SetBoxEnable (bEnableFlag: BOOL) : HResult; stdcall;
function SetAxes (dx, dy, dz, ux, uy, uz: TD3DValue) : HResult; stdcall;
function SetInheritAxes (inherit_from_parent: BOOL) : HResult; stdcall;
function SetMaterial (var lplpMaterial: IDirect3DRMMaterial) : HResult; stdcall;
function SetQuaternion (lpRef: IDirect3DRMFrame;
const quat: TD3DRMQuaternion) : HResult; stdcall;
function RayPick (lpRefFrame: IDirect3DRMFrame; var ray: TD3DRMRay;
dwFlags: DWORD; out lplpPicked2Array: IDirect3DRMPicked2Array) :
HResult; stdcall;
function Save (lpFilename: PAnsiChar; d3dFormat: TD3DRMXOFFormat;
function SetMaterial(lplpMaterial: IDirect3DRMMaterial): HResult; stdcall;
function SetQuaternion(lpRef: IDirect3DRMFrame2; var quat: TD3DRMQuaternion): HResult; stdcall;
function RayPick(lpRefFrame: IDirect3DRMFrame; const ray: TD3DRMRay;
dwFlags: DWORD; out lplpPicked2Array: IDirect3DRMPicked2Array): HResult; stdcall;
function Save(lpFilename: PChar; d3dFormat: TD3DRMXOFFormat;
d3dSaveFlags: TD3DRMSaveOptions) : HResult; stdcall;
end;
 
IDirect3DRMFrame3 = interface (IDirect3DRMVisual)
['{ff6b7f70-a40e-11d1-91f9-0000f8758e66}']
(*
* IDirect3DRMFrame3 methods
*)
['{FF6B7F70-A40E-11D1-91F9-0000F8758E66}']
function AddChild (lpD3DRMFrameChild: IDirect3DRMFrame3) : HResult; stdcall;
function AddLight (lpD3DRMLight: IDirect3DRMLight) : HResult; stdcall;
function AddMoveCallback (d3drmFMC: TD3DRMFrame3MoveCallback;
10482,9 → 6897,10
lpArg: Pointer; dwFlags: DWORD) : HResult; stdcall;
function AddTransform (rctCombine: TD3DRMCombineType;
rmMatrix: TD3DRMMatrix4D) : HResult; stdcall;
function AddTranslation (rctCombine: TD3DRMCombineType; rvX, rvY, rvZ:
TD3DValue) : HResult; stdcall;
function AddScale (rctCombine: TD3DRMCombineType; rvX, rvY, rvZ: TD3DValue) : HResult; stdcall;
function AddTranslation(rctCombine: TD3DRMCombineType; rvX, rvY,
rvZ: TD3DValue): HResult; stdcall;
function AddScale(rctCombine: TD3DRMCombineType; rvX, rvY,
rvZ: TD3DValue): HResult; stdcall;
function AddRotation (rctCombine: TD3DRMCombineType; rvX, rvY, rvZ,
rvTheta: TD3DValue) : HResult; stdcall;
function AddVisual (lpD3DRMVisual: IDirect3DRMVisual) : HResult; stdcall;
10493,20 → 6909,19
function GetLights (out lplpLights: IDirect3DRMLightArray) : HResult; stdcall;
function GetMaterialMode: TD3DRMMaterialMode; stdcall;
function GetParent (out lplpParent: IDirect3DRMFrame3) : HResult; stdcall;
function GetPosition (lpRef: IDirect3DRMFrame3; out lprvPos: TD3DVector) : HResult; stdcall;
function GetRotation (lpRef: IDirect3DRMFrame3; out lprvAxis: TD3DVector;
out lprvTheta: TD3DValue) : HResult; stdcall;
function GetPosition(lpRef: IDirect3DRMFrame3; var lprvPos: TD3DVector): HResult; stdcall;
function GetRotation(lpRef: IDirect3DRMFrame3; var lprvAxis: TD3DVector;
var lprvTheta: TD3DValue): HResult; stdcall;
function GetScene (out lplpRoot: IDirect3DRMFrame3) : HResult; stdcall;
function GetSortMode: TD3DRMSortMode; stdcall;
function GetTexture (out lplpTexture: IDirect3DRMTexture3) : HResult; stdcall;
function GetTransform (lpRefFrame: IDirect3DRMFrame3;
var rmMatrix: TD3DRMMatrix4D) : HResult; stdcall;
function GetVelocity (lpRef: IDirect3DRMFrame3; out lprvVel: TD3DVector;
function GetTransform(RefFrame: IDirect3DRMFrame3; var rmMatrix: TD3DRMMatrix4D): HResult; stdcall;
function GetVelocity(lpRef: IDirect3DRMFrame3; var lprvVel: TD3DVector;
fRotVel: BOOL) : HResult; stdcall;
function GetOrientation (lpRef: IDirect3DRMFrame3; out lprvDir: TD3DVector;
out lprvUp: TD3DVector) : HResult; stdcall;
function GetVisuals (out lplpVisuals: IDirect3DRMVisualArray) : HResult; stdcall;
function InverseTransform (out lprvDst: TD3DVector; const lprvSrc: TD3DVector) : HResult; stdcall;
function GetOrientation(lpRef: IDirect3DRMFrame3; var lprvDir: TD3DVector;
var lprvUp: TD3DVector): HResult; stdcall;
function GetVisuals(var pdwNumVisuals: DWORD; var lplpVisuals: Pointer): HResult; stdcall;
function InverseTransform(var lprvDst, lprvSrc: TD3DVector): HResult; stdcall;
function Load (lpvObjSource: Pointer; lpvObjID: Pointer;
d3drmLOFlags: TD3DRMLoadOptions; d3drmLoadTextureProc:
TD3DRMLoadTexture3Callback; lpArgLTP: Pointer) : HResult; stdcall;
10522,7 → 6937,7
function GetSceneFogColor: TD3DColor; stdcall;
function GetSceneFogEnable: BOOL; stdcall;
function GetSceneFogMode: TD3DRMFogMode; stdcall;
function GetSceneFogParams (out lprvStart, lprvEnd, lprvDensity: TD3DValue) : HResult; stdcall;
function GetSceneFogParams(var lprvStart, lprvEnd, lprvDensity: TD3DValue): HResult; stdcall;
function SetSceneBackground (rcColor: TD3DColor) : HResult; stdcall;
function SetSceneBackgroundRGB (rvRed, rvGreen, rvBlue: TD3DValue) : HResult; stdcall;
function SetSceneBackgroundDepth (lpImage: IDirectDrawSurface) : HResult; stdcall;
10537,59 → 6952,48
function SetMaterialMode (rmmMode: TD3DRMMaterialMode) : HResult; stdcall;
function SetOrientation (lpRef: IDirect3DRMFrame3; rvDx, rvDy, rvDz, rvUx,
rvUy, rvUz: TD3DValue) : HResult; stdcall;
function SetPosition (lpRef: IDirect3DRMFrame3; rvX, rvY, rvZ: TD3DValue) :
HResult; stdcall;
function SetRotation (lpRef: IDirect3DRMFrame3; rvX, rvY, rvZ,
rvTheta: TD3DValue) : HResult; stdcall;
function SetPosition(lpRef: IDirect3DRMFrame3; rvX, rvY, rvZ: TD3DValue): HResult; stdcall;
function SetRotation(lpRef: IDirect3DRMFrame3; rvX, rvY, rvZ, rvTheta: TD3DValue): HResult; stdcall;
function SetSortMode (d3drmSM: TD3DRMSortMode) : HResult; stdcall;
function SetTexture (lpD3DRMTexture: IDirect3DRMTexture3) : HResult; stdcall;
function SetVelocity (lpRef: IDirect3DRMFrame3; rvX, rvY, rvZ: TD3DValue;
fRotVel: BOOL) : HResult; stdcall;
function SetZbufferMode (d3drmZBM: TD3DRMZBufferMode) : HResult; stdcall;
function Transform (out lpd3dVDst: TD3DVector; const lpd3dVSrc: TD3DVector) : HResult; stdcall;
 
function GetBox (out lpTD3DRMBox: TD3DRMBox) : HResult; stdcall;
function GetBoxEnable : boolean; stdcall;
function GetAxes (out dir, up: TD3DVector) : HResult; stdcall;
function Transform(var lpd3dVDst, lpd3dVSrc: TD3DVector): HResult; stdcall;
function GetBox(var lpD3DRMBox: TD3DRMBox): HResult; stdcall;
function GetBoxEnable: BOOL; stdcall;
function GetAxes(var dir, up: TD3DVector): HResult; stdcall;
function GetMaterial (out lplpMaterial: IDirect3DRMMaterial2) : HResult; stdcall;
function GetInheritAxes : boolean; stdcall;
function GetHierarchyBox (out lpTD3DRMBox: TD3DRMBox) : HResult; stdcall;
function SetBox (const lpTD3DRMBox: TD3DRMBox) : HResult; stdcall;
function GetInheritAxes: BOOL; stdcall;
function GetHierarchyBox(var lpD3DRMBox: TD3DRMBox): HResult; stdcall;
function SetBox(const lpD3DRMBox: TD3DRMBox): HResult; stdcall;
function SetBoxEnable (bEnableFlag: BOOL) : HResult; stdcall;
function SetAxes (dx, dy, dz, ux, uy, uz: TD3DValue) : HResult; stdcall;
function SetInheritAxes (inherit_from_parent: BOOL) : HResult; stdcall;
function SetMaterial (var lplpMaterial: IDirect3DRMMaterial2) : HResult; stdcall;
function SetQuaternion (lpRef: IDirect3DRMFrame3;
const quat: TD3DRMQuaternion) : HResult; stdcall;
function RayPick (lpRefFrame: IDirect3DRMFrame3; var ray: TD3DRMRay;
function SetMaterial(lplpMaterial: IDirect3DRMMaterial2): HResult; stdcall;
function SetQuaternion(lpRef: IDirect3DRMFrame3; var quat: TD3DRMQuaternion): HResult; stdcall;
function RayPick(lpRefFrame: IDirect3DRMFrame3; const ray: TD3DRMRay;
dwFlags: DWORD; out lplpPicked2Array: IDirect3DRMPicked2Array) : HResult; stdcall;
function Save (lpFilename: PAnsiChar; d3dFormat: TD3DRMXOFFormat;
function Save(lpFilename: PChar; d3dFormat: TD3DRMXOFFormat;
d3dSaveFlags: TD3DRMSaveOptions) : HResult; stdcall;
function TransformVectors (lpRefFrame: IDirect3DRMFrame3;
dwNumVectors: DWORD; out lpDstVectors: TD3DVector;
const lpSrcVectors: TD3DVector) : HResult; stdcall;
function InverseTransformVectors (lpRefFrame: IDirect3DRMFrame3;
dwNumVectors: DWORD; out lpDstVectors: TD3DVector;
const lpSrcVectors: TD3DVector) : HResult; stdcall;
function TransformVectors(reference: IDirect3DRMFrame3; dwNumVectors: DWORD;
var lpDstVectors: TD3DVector; const lpSrcVectors: TD3DVector): HResult; stdcall;
function InverseTransformVectors(reference: IDirect3DRMFrame3; dwNumVectors: DWORD;
var lpDstVectors: TD3DVector; const lpSrcVectors: TD3DVector): HResult; stdcall;
function SetTraversalOptions (dwFlags: DWORD) : HResult; stdcall;
function GetTraversalOptions (out lpdwFlags: DWORD) : HResult; stdcall;
function GetTraversalOptions(var lpdwFlags: DWORD): HResult; stdcall;
function SetSceneFogMethod (dwFlags: DWORD) : HResult; stdcall;
function GetSceneFogMethod (out lpdwFlags: DWORD) : HResult; stdcall;
function SetMaterialOverride (
const lpdmOverride: TD3DRMMaterialOverride) : HResult; stdcall;
function GetMaterialOverride (
const lpdmOverride: TD3DRMMaterialOverride) : HResult; stdcall;
function GetSceneFogMethod(var lpdwFlags: DWORD): HResult; stdcall;
function SetMaterialOverride(lpdmOverride: TD3DRMMaterialOverride): HResult; stdcall;
function GetMaterialOverride(var lplpdmOverride: TD3DRMMaterialOverride): HResult; stdcall;
end;
 
 
IDirect3DRMMesh = interface (IDirect3DRMVisual)
['{a3a80d01-6e12-11cf-ac4a-0000c03825a1}']
(*
* IDirect3DRMMesh methods
*)
['{A3A80D01-6E12-11CF-AC4A-0000C03825A1}']
// IDirect3DRMMesh methods
function Scale (sx, sy, sz: TD3DValue) : HResult; stdcall;
function Translate (tx, ty, tz: TD3DValue) : HResult; stdcall;
function GetBox (out lpTD3DRMBox: TD3DRMBox) : HResult; stdcall;
function GetBox(var lpD3DRMBox: TD3DRMBox): HResult; stdcall;
function AddGroup (vCount, fCount, vPerFace: DWORD; var fData: DWORD;
var returnId: TD3DRMGroupIndex) : HResult; stdcall;
function SetVertices (id: TD3DRMGroupIndex; index, count: DWORD;
10605,10 → 7009,10
IDirect3DRMMaterial) : HResult; stdcall;
function SetGroupTexture (id: TD3DRMGroupIndex; value: IDirect3DRMTexture) : HResult; stdcall;
function GetGroupCount: DWORD; stdcall;
function GetGroup (id: TD3DRMGroupIndex; vCount, fCount, vPerFace : PDWORD;
var fDataSize: DWORD; fData: PDWORD) : HResult; stdcall;
function GetVertices (id: TD3DRMGroupIndex; index, count : DWORD;
out returnPtr : TD3DRMVertex) : HResult; stdcall;
function GetGroup(id: TD3DRMGroupIndex; var vCount, fCount, vPerFace,
fDataSize, fData: DWORD): HResult; stdcall;
function GetVertices(id: TD3DRMGroupIndex; index: DWORD; count: DWORD;
var returnPtr: TD3DRMVertex): HResult; stdcall;
function GetGroupColor (id: TD3DRMGroupIndex) : TD3DColor; stdcall;
function GetGroupMapping (id: TD3DRMGroupIndex) : TD3DRMMapping; stdcall;
function GetGroupQuality (id: TD3DRMGroupIndex) : TD3DRMRenderQuality; stdcall;
10619,66 → 7023,52
end;
 
IDirect3DRMProgressiveMesh = interface (IDirect3DRMVisual)
['{4516ec79-8f20-11d0-9b6d-0000c0781bc3}']
(*
* IDirect3DRMProgressiveMesh methods
*)
['{4516EC79-8F20-11D0-9B6D-0000C0781BC3}']
// IDirect3DRMProgressiveMesh methods
function Load (lpSource, lpObjID: pointer; dloLoadflags : TD3DRMLoadOptions;
lpCallback: TD3DRMLoadTextureCallback; lpArg: pointer) : HResult; stdcall;
function GetLoadStatus (out lpStatus: TD3DRMPMeshLoadStatus) : HResult; stdcall;
function GetLoadStatus(var lpStatus: TD3DRMPMeshLoadStatus): HResult; stdcall;
function SetMinRenderDetail (d3dVal: TD3DValue) : HResult; stdcall;
function Abort (dwFlags: DWORD) : HResult; stdcall;
function GetFaceDetail (out lpdwCount: DWORD) : HResult; stdcall;
function GetVertexDetail (out lpdwCount: DWORD) : HResult; stdcall;
function GetFaceDetail(var lpdwCount: DWORD): HResult; stdcall;
function GetVertexDetail(var lpdwCount: DWORD): HResult; stdcall;
function SetFaceDetail (dwCount: DWORD) : HResult; stdcall;
function SetVertexDetail (dwCount: DWORD) : HResult; stdcall;
function GetFaceDetailRange (out lpdwMin, lpdwMax: DWORD) : HResult; stdcall;
function GetVertexDetailRange (out lpdwMin, lpdwMax: DWORD) : HResult; stdcall;
function GetDetail (out lpdvVal: TD3DValue) : HResult; stdcall;
function GetFaceDetailRange(var lpdwMin, lpdwMax: DWORD): HResult; stdcall;
function GetVertexDetailRange(var lpdwMin, lpdwMax: DWORD): HResult; stdcall;
function GetDetail(var lpdvVal: TD3DValue): HResult; stdcall;
function SetDetail (lpdvVal: TD3DValue) : HResult; stdcall;
function RegisterEvents (hEvent: THANDLE; dwFlags, dwReserved: DWORD) : HResult; stdcall;
function CreateMesh (out lplpD3DRMMesh: IDirect3DRMMesh) : HResult; stdcall;
function Duplicate (out lplpD3DRMPMesh: IDirect3DRMProgressiveMesh) : HResult; stdcall;
function GetBox (out lpBBox: TD3DRMBox) : HResult; stdcall;
function GetBox(var lpBBox: TD3DRMBox): HResult; stdcall;
function SetQuality (quality: TD3DRMRenderQuality) : HResult; stdcall;
function GetQuality (out lpdwquality: TD3DRMRenderQuality) : HResult; stdcall;
function GetQuality(var lpdwquality: TD3DRMRenderQuality): HResult; stdcall;
end;
 
IDirect3DRMShadow = interface (IDirect3DRMVisual)
['{af359780-6ba3-11cf-ac4a-0000c03825a1}']
(*
* IDirect3DRMShadow methods
*)
['{AF359780-6BA3-11CF-AC4A-0000C03825A1}']
// IDirect3DRMShadow methods
function Init (lpD3DRMVisual: IDirect3DRMVisual;
lpD3DRMLight: IDirect3DRMLight;
px, py, pz, nx, ny, nz: TD3DValue) : HResult; stdcall;
lpD3DRMLight: IDirect3DRMLight; px, py, pz, nx, ny, nz: TD3DValue): HResult; stdcall;
end;
 
IDirect3DRMShadow2 = interface (IDirect3DRMShadow)
['{86b44e25-9c82-11d1-bb0b-00a0c981a0a6}']
(*
* IDirect3DRMShadow2 methods
*)
['{86B44E25-9C82-11D1-BB0B-00A0C981A0A6}']
// IDirect3DRMShadow2 methods
function GetVisual (out lplpDirect3DRMVisual: IDirect3DRMVisual) : HResult; stdcall;
function SetVisual (lpDirect3DRMVisual: IDirect3DRMVisual;
dwFlags: DWORD) : HResult; stdcall;
function SetVisual(pUNK: IUnknown; dwFlags: DWORD): HResult; stdcall;
function GetLight (out lplpDirect3DRMLight: IDirect3DRMLight) : HResult; stdcall;
function SetLight (lplpDirect3DRMLight: IDirect3DRMLight;
dwFlags: DWORD) : HResult; stdcall;
function GetPlane (
var pdvPX, pdvPY, pdvPZ, pdvNX, pdvNY, pdvNZ: TD3DValue) : HResult; stdcall;
function SetPlane (px, py, pz, nx, ny, nz: TD3DValue;
dwFlags: DWORD) : HResult; stdcall;
function GetOptions (out pdwOptions: DWORD) : HResult; stdcall;
function SetLight(lpDirect3DRMLight: IDirect3DRMLight; dwFlags: DWORD): HResult; stdcall;
function GetPlane(var px, py, pz: TD3DValue; var nx, ny, nz: TD3DValue): HResult; stdcall;
function SetPlane(px, py, pz: TD3DValue; nx, ny, nz: TD3DValue): HResult; stdcall;
function GetOptions(var pdwOptions: DWORD): HResult; stdcall;
function SetOptions (dwOptions: DWORD) : HResult; stdcall;
 
end;
 
IDirect3DRMFace = interface (IDirect3DRMObject)
['{eb16cb07-d271-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMFace methods
*)
['{EB16CB07-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMFace methods
function AddVertex (x, y, z: TD3DValue) : HResult; stdcall;
function AddVertexAndNormalIndexed (vertex: DWORD; normal: DWORD) : HResult; stdcall;
function SetColorRGB (red, green, blue: TD3DValue) : HResult; stdcall;
10687,26 → 7077,22
function SetTextureCoordinates (vertex: DWORD; u, v: TD3DValue) : HResult; stdcall;
function SetMaterial (lpMat: IDirect3DRMMaterial) : HResult; stdcall;
function SetTextureTopology (cylU, cylV: BOOL) : HResult; stdcall;
function GetVertex (index: DWORD; out lpPosition: TD3DVector;
out lpNormal: TD3DVector) : HResult; stdcall;
function GetVertices (var lpdwVertexCount: DWORD;
out lpPosition, lpNormal: TD3DVector) : HResult; stdcall;
function GetTextureCoordinates (index: DWORD; out lpU, lpV: TD3DValue) : HResult; stdcall;
function GetTextureTopology (out lpU, lpV: BOOL) : HResult; stdcall;
function GetNormal (out lpNormal: TD3DVector) : HResult; stdcall;
function GetVertex(index: DWORD; var lpPosition: TD3DVector; var lpNormal: TD3DVector): HResult; stdcall;
function GetVertices(var lpdwVertexCount: DWORD; var lpPosition, lpNormal: TD3DVector): HResult; stdcall;
function GetTextureCoordinates(index: DWORD; var lpU, lpV: TD3DValue): HResult; stdcall;
function GetTextureTopology(var lpU, lpV: BOOL): HResult; stdcall;
function GetNormal(var lpNormal: TD3DVector): HResult; stdcall;
function GetTexture (out lplpTexture: IDirect3DRMTexture) : HResult; stdcall;
function GetMaterial (out lpMat: IDirect3DRMMaterial) : HResult; stdcall;
function GetVertexCount: Integer; stdcall;
function GetVertexIndex (dwIndex: DWORD) : Integer; stdcall;
function GetTextureCoordinateIndex (dwIndex: DWORD) : Integer; stdcall;
function GetVertexCount: Longint; stdcall;
function GetVertexIndex(dwIndex: DWORD): Longint; stdcall;
function GetTextureCoordinateIndex(dwIndex: DWORD): Longint; stdcall;
function GetColor: TD3DColor; stdcall;
end;
 
IDirect3DRMFace2 = interface (IDirect3DRMObject)
['{4516ec81-8f20-11d0-9b6d-0000c0781bc3}']
(*
* IDirect3DRMFace2 methods
*)
['{4516EC81-8F20-11D0-9B6D-0000C0781BC3}']
// IDirect3DRMFace methods
function AddVertex (x, y, z: TD3DValue) : HResult; stdcall;
function AddVertexAndNormalIndexed (vertex: DWORD; normal: DWORD) : HResult; stdcall;
function SetColorRGB (red, green, blue: TD3DValue) : HResult; stdcall;
10715,35 → 7101,30
function SetTextureCoordinates (vertex: DWORD; u, v: TD3DValue) : HResult; stdcall;
function SetMaterial (lpMat: IDirect3DRMMaterial2) : HResult; stdcall;
function SetTextureTopology (cylU, cylV: BOOL) : HResult; stdcall;
function GetVertex (index: DWORD; out lpPosition: TD3DVector;
out lpNormal: TD3DVector) : HResult; stdcall;
function GetVertices (var lpdwVertexCount: DWORD;
out lpPosition, lpNormal: TD3DVector) : HResult; stdcall;
function GetTextureCoordinates (index: DWORD; out lpU, lpV: TD3DValue) : HResult; stdcall;
function GetTextureTopology (out lpU, lpV: BOOL) : HResult; stdcall;
function GetNormal (out lpNormal: TD3DVector) : HResult; stdcall;
function GetVertex(index: DWORD; var lpPosition: TD3DVector; var lpNormal: TD3DVector): HResult; stdcall;
function GetVertices(var lpdwVertexCount: DWORD; var lpPosition, lpNormal: TD3DVector): HResult; stdcall;
function GetTextureCoordinates(index: DWORD; var lpU, lpV: TD3DValue): HResult; stdcall;
function GetTextureTopology(var lpU, lpV: BOOL): HResult; stdcall;
function GetNormal(var lpNormal: TD3DVector): HResult; stdcall;
function GetTexture (out lplpTexture: IDirect3DRMTexture3) : HResult; stdcall;
function GetMaterial (out lpMat: IDirect3DRMMaterial2) : HResult; stdcall;
function GetVertexCount: Integer; stdcall;
function GetVertexIndex (dwIndex: DWORD) : Integer; stdcall;
function GetTextureCoordinateIndex (dwIndex: DWORD) : Integer; stdcall;
function GetVertexCount: Longint; stdcall;
function GetVertexIndex(dwIndex: DWORD): Longint; stdcall;
function GetTextureCoordinateIndex(dwIndex: DWORD): Longint; stdcall;
function GetColor: TD3DColor; stdcall;
end;
 
IDirect3DRMMeshBuilder = interface (IDirect3DRMVisual)
['{a3a80d02-6e12-11cf-ac4a-0000c03825a1}']
(*
* IDirect3DRMMeshBuilder methods
*)
function Load (lpvObjSource, lpvObjID: Pointer; d3drmLOFlags:
TD3DRMLoadOptions; d3drmLoadTextureProc: TD3DRMLoadTextureCallback;
lpvArg: Pointer) : HResult; stdcall;
['{A3A80D02-6E12-11CF-AC4A-0000C03825A1}']
// IDirect3DRMMeshBuilder methods
function Load(lpvObjSource, lpvObjID: Pointer; d3drmLOFlags: TD3DRMLoadOptions;
d3drmLoadTextureProc: TD3DRMLoadTextureCallback; lpvArg: Pointer): HResult; stdcall;
function Save (lpFilename: PChar; TD3DRMXOFFormat: TD3DRMXOFFormat;
d3drmSOContents: TD3DRMSaveOptions) : HResult; stdcall;
function Scale (sx, sy, sz: TD3DValue) : HResult; stdcall;
function Translate (tx, ty, tz: TD3DValue) : HResult; stdcall;
function SetColorSource (source: TD3DRMColorSource) : HResult; stdcall;
function GetBox (out lpTD3DRMBox: TD3DRMBox) : HResult; stdcall;
function GetBox(var lpD3DRMBox: TD3DRMBox): HResult; stdcall;
function GenerateNormals : HResult; stdcall;
function GetColorSource: TD3DRMColorSource; stdcall;
function AddMesh (lpD3DRMMesh: IDirect3DRMMesh) : HResult; stdcall;
10750,9 → 7131,9
function AddMeshBuilder (lpD3DRMMeshBuild: IDirect3DRMMeshBuilder) : HResult; stdcall;
function AddFrame (lpD3DRMFrame: IDirect3DRMFrame) : HResult; stdcall;
function AddFace (lpD3DRMFace: IDirect3DRMFace) : HResult; stdcall;
function AddFaces (dwVertexCount: DWORD; const lpD3DVertices: TD3DVector;
normalCount: DWORD; lpNormals: PD3DVector; var lpFaceData: DWORD;
lplpD3DRMFaceArray: PIDirect3DRMFaceArray) : HResult; stdcall;
function AddFaces(dwVertexCount: DWORD; var lpD3DVertices: TD3DVector;
normalCount: DWORD; var lpNormals: TD3DVector; var lpFaceData: DWORD;
out lplpD3DRMFaceArray: IDirect3DRMFaceArray): HResult; stdcall;
function ReserveSpace (vertexCount, normalCount, faceCount: DWORD) : HResult; stdcall;
function SetColorRGB (red, green, blue: TD3DValue) : HResult; stdcall;
function SetColor (color: TD3DColor) : HResult; stdcall;
10768,62 → 7149,52
function SetVertexColorRGB (index: DWORD; red, green, blue: TD3DValue) : HResult; stdcall;
function GetFaces (out lplpD3DRMFaceArray: IDirect3DRMFaceArray) : HResult; stdcall;
function GetVertices (var vcount: DWORD; var vertices : TD3DVector;
var ncount : DWORD;
var normals : TD3DVector;
var face_data_size, face_data : DWORD) : HResult; stdcall;
function GetTextureCoordinates(index : DWORD; out u, v : TD3DValue) : HResult; stdcall;
function AddVertex (x, y, z: TD3DValue) : Integer; stdcall;
function AddNormal (x, y, z: TD3DValue) : Integer; stdcall;
var ncount: DWORD; var normals: TD3DVector; var face_data_size: DWORD;
var face_data: DWORD): HResult; stdcall;
function GetTextureCoordinates(index: DWORD; var u, v: TD3DValue): HResult; stdcall;
function AddVertex(x, y, z: TD3DValue): Longint; stdcall;
function AddNormal(x, y, z: TD3DValue): Longint; stdcall;
function CreateFace (out lplpd3drmFace: IDirect3DRMFace) : HResult; stdcall;
function GetQuality: TD3DRMRenderQuality; stdcall;
function GetPerspective: BOOL; stdcall;
function GetFaceCount: Integer; stdcall;
function GetVertexCount: Integer; stdcall;
function GetFaceCount: Longint; stdcall;
function GetVertexCount: Longint; stdcall;
function GetVertexColor (index: DWORD) : TD3DColor; stdcall;
function CreateMesh (out lplpD3DRMMesh: IDirect3DRMMesh) : HResult; stdcall;
end;
 
IDirect3DRMMeshBuilder2 = interface (IDirect3DRMMeshBuilder)
['{4516ec77-8f20-11d0-9b6d-0000c0781bc3}']
(*
* IDirect3DRMMeshBuilder2 methods
*)
function GenerateNormals2 (
dvCreaseAngle: TD3DValue; dwFlags: DWORD) : HResult; stdcall;
function GetFace (dwIndex: DWORD; lplpD3DRMFace: IDirect3DRMFace) : HResult; stdcall;
['{4516EC77-8F20-11D0-9B6D-0000C0781BC3}']
// IDirect3DRMMeshBuilder2 methods
function GenerateNormals2(dvCreaseAngle: TD3DValue; dwFlags: DWORD): HResult; stdcall;
function GetFace(dwIndex: DWORD; out lplpD3DRMFace: IDirect3DRMFace): HResult; stdcall;
end;
 
IDirect3DRMMeshBuilder3 = interface (IDirect3DRMVisual)
['{ff6b7f71-a40e-11d1-91f9-0000f8758e66}']
(*
* IDirect3DRMMeshBuilder3 methods
*)
function Load (lpvObjSource, lpvObjID: Pointer;
d3drmLOFlags: TD3DRMLoadOptions;
d3drmLoadTextureProc: TD3DRMLoadTexture3Callback;
lpvArg: Pointer) : HResult; stdcall;
function Save (lpFilename: PAnsiChar; TD3DRMXOFFormat: TD3DRMXOFFormat;
['{4516EC82-8F20-11D0-9B6D-0000C0781BC3}']
// IDirect3DRMMeshBuilder methods
function Load(lpvObjSource, lpvObjID: Pointer; d3drmLOFlags: TD3DRMLoadOptions;
d3drmLoadTextureProc: TD3DRMLoadTexture3Callback; lpvArg: Pointer): HResult; stdcall;
function Save(lpFilename: PChar; TD3DRMXOFFormat: TD3DRMXOFFormat;
d3drmSOContents: TD3DRMSaveOptions) : HResult; stdcall;
function Scale (sx, sy, sz: TD3DValue) : HResult; stdcall;
function Translate (tx, ty, tz: TD3DValue) : HResult; stdcall;
function SetColorSource (source: TD3DRMColorSource) : HResult; stdcall;
function GetBox (out lpTD3DRMBox: TD3DRMBox) : HResult; stdcall;
function GenerateNormals (
dvCreaseAngle: TD3DValue; dwFlags: DWORD): HResult; stdcall;
function GetBox(var lpD3DRMBox: TD3DRMBox): HResult; stdcall;
function GenerateNormals(dvCreaseAngle: TD3DValue; dwFlags: DWORD): HResult; stdcall;
function GetColorSource: TD3DRMColorSource; stdcall;
function AddMesh (lpD3DRMMesh: IDirect3DRMMesh) : HResult; stdcall;
function AddMeshBuilder (
lpD3DRMMeshBuild: IDirect3DRMMeshBuilder3) : HResult; stdcall;
function AddMeshBuilder(lpD3DRMMeshBuild: IDirect3DRMMeshBuilder3): HResult; stdcall;
function AddFrame (lpD3DRMFrame: IDirect3DRMFrame3) : HResult; stdcall;
function AddFace (lpD3DRMFace: IDirect3DRMFace2) : HResult; stdcall;
function AddFaces (dwVertexCount: DWORD; const lpD3DVertices: TD3DVector;
normalCount: DWORD; lpNormals: PD3DVector; var lpFaceData: DWORD;
lplpD3DRMFaceArray: PIDirect3DRMFaceArray) : HResult; stdcall;
function AddFaces(dwVertexCount: DWORD; var lpD3DVertices: TD3DVector;
normalCount: DWORD; var lpNormals: TD3DVector; var lpFaceData: DWORD;
out lplpD3DRMFaceArray: IDirect3DRMFaceArray): HResult; stdcall;
function ReserveSpace (vertexCount, normalCount, faceCount: DWORD) : HResult; stdcall;
function SetColorRGB (red, green, blue: TD3DValue) : HResult; stdcall;
function SetColor (color: TD3DColor) : HResult; stdcall;
function SetTexture (lpD3DRMTexture: IDirect3DRMTexture3) : HResult; stdcall;
function SetMaterial (lpIDirect3DRMmaterial: IDirect3DRMMaterial2) : HResult; stdcall;
function SetMaterial(lpDirect3DRMMaterial: IDirect3DRMMaterial2): HResult; stdcall;
function SetTextureTopology (cylU, cylV: BOOL) : HResult; stdcall;
function SetQuality (quality: TD3DRMRenderQuality) : HResult; stdcall;
function SetPerspective (perspective: BOOL) : HResult; stdcall;
10833,53 → 7204,50
function SetVertexColor (index: DWORD; color: TD3DColor) : HResult; stdcall;
function SetVertexColorRGB (index: DWORD; red, green, blue: TD3DValue) : HResult; stdcall;
function GetFaces (out lplpD3DRMFaceArray: IDirect3DRMFaceArray) : HResult; stdcall;
function GetGeometry (var vcount: DWORD; var vertices : TD3DVector;
var ncount : DWORD; var normals : TD3DVector;
var face_data_size, face_data : DWORD) : HResult; stdcall;
function GetTextureCoordinates(index : DWORD; out u, v : TD3DValue) : HResult; stdcall;
function AddVertex (x, y, z: TD3DValue) : Integer; stdcall;
function AddNormal (x, y, z: TD3DValue) : Integer; stdcall;
function GetGeometry(var vcount: DWORD; var vertices; var ncount: DWORD; var normals;
var face_data_size: DWORD; var face_data): HResult; stdcall;
function GetTextureCoordinates(index: DWORD; var u, v: TD3DValue): HResult; stdcall;
function AddVertex(x, y, z: TD3DValue): Longint; stdcall;
function AddNormal(x, y, z: TD3DValue): Longint; stdcall;
function CreateFace (out lplpd3drmFace: IDirect3DRMFace2) : HResult; stdcall;
function GetQuality: TD3DRMRenderQuality; stdcall;
function GetPerspective: BOOL; stdcall;
function GetFaceCount: Integer; stdcall;
function GetVertexCount: Integer; stdcall;
function GetFaceCount: Longint; stdcall;
function GetVertexCount: Longint; stdcall;
function GetVertexColor (index: DWORD) : TD3DColor; stdcall;
function CreateMesh (out lplpD3DRMMesh: IDirect3DRMMesh) : HResult; stdcall;
function GetFace
(dwIndex: DWORD; lplpD3DRMFace: IDirect3DRMFace) : HResult; stdcall;
function GetVertex (dwIndex: DWORD; out lpVector: TD3DVector) : HResult; stdcall;
function GetNormal (dwIndex: DWORD; out lpVector: TD3DVector) : HResult; stdcall;
function DeleteVertices (dwFirstIndex, dwCount: DWORD) : HResult; stdcall;
function DeleteNormals (dwFirstIndex, dwCount: DWORD) : HResult; stdcall;
function DeleteFace (lpFace: IDirect3DRMFace2) : HResult; stdcall;
function GetFace(dwIndex: DWORD; out lplpD3DRMFace: IDirect3DRMFace2): HResult; stdcall;
function GetVertex(dwIndex: DWORD; var lpVector: TD3DVector): HResult; stdcall;
function GetNormal(dwIndex: DWORD; var lpVector: TD3DVector): HResult; stdcall;
function DeleteVertices(dwIndexFirst: DWORD; dwCount: DWORD): HResult; stdcall;
function DeleteNormals(dwIndexFirst: DWORD; dwCount: DWORD): HResult; stdcall;
function DeleteFace(lpD3DRMFace: IDirect3DRMFace2): HResult; stdcall;
function Empty (dwFlags: DWORD) : HResult; stdcall;
function Optimize (dwFlags: DWORD) : HResult; stdcall;
function AddFacesIndexed (dwFlags: DWORD; var lpdwvIndices: DWORD;
lpdwIndexFirst, lpdwCount: PDWORD) : HResult; stdcall;
var dwIndexFirst: DWORD; var dwCount: DWORD): HResult; stdcall;
function CreateSubMesh (out lplpUnk: IUnknown) : HResult; stdcall;
function GetParentMesh (dwFlags: DWORD; out lplpUnk: IUnknown) : HResult; stdcall;
function GetSubMeshes (lpdwCount: PDWORD; lpUnk: IUnknown) : HResult; stdcall;
function DeleteSubMesh (lplpUnk: IUnknown) : HResult; stdcall;
function GetSubMeshes(var lpdwCount: DWORD; out lplpUnk: IUnknown): HResult; stdcall;
function DeleteSubMesh(lpUnk: IUnknown): HResult; stdcall;
function Enable (dwFlags: DWORD) : HResult; stdcall;
function GetEnable (out lpdwFlags: DWORD) : HResult; stdcall;
function AddTriangles (dwFlags, dwFormat, dwVertexCount: DWORD;
lpData: pointer) : HResult; stdcall;
function SetVertices
(dwFirst, dwCount: DWORD; const lpdvVector: TD3DVector) : HResult; stdcall;
function GetVertices(dwFirst: DWORD; var lpdwCount: DWORD;
lpdvVector: PD3DVector) : HResult; stdcall;
function SetNormals(dwFirst, dwCount: DWORD; const lpdvVector: TD3DVector) : HResult; stdcall;
function GetNormals (dwFirst: DWORD; lpdwCount: PDWORD;
function GetEnable(var lpdwFlags: DWORD): HResult; stdcall;
function AddTriangles(dwFlags: DWORD; dwFormat: DWORD; dwVertexCount: DWORD;
lpvData: Pointer): HResult; stdcall;
function SetVertices(dwIndexFirst: DWORD; dwCount: DWORD;
const lpdvVector: TD3DVector): HResult; stdcall;
function GetVertices(dwIndexFirst: DWORD; var lpdwCount: DWORD;
var lpdvVector: TD3DVector) : HResult; stdcall;
function GetNormalCount : integer; stdcall;
function SetNormals(dwIndexFirst: DWORD; dwCount: DWORD;
const lpdvVector: TD3DVector): HResult; stdcall;
function GetNormals(dwIndexFirst: DWORD; var lpdwCount: DWORD;
var lpdvVector: TD3DVector): HResult; stdcall;
function GetNormalCount: Longint; stdcall;
end;
 
IDirect3DRMLight = interface (IDirect3DRMObject)
['{eb16cb08-d271-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMLight methods
*)
['{EB16CB08-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMLight methods
function SetType (d3drmtType: TD3DRMLightType) : HResult; stdcall;
function SetColor (rcColor: TD3DColor) : HResult; stdcall;
function SetColorRGB (rvRed, rvGreen, rvBlue: TD3DValue) : HResult; stdcall;
10902,11 → 7270,9
end;
 
IDirect3DRMTexture = interface (IDirect3DRMVisual)
['{eb16cb09-d271-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMTexture methods
*)
function InitFromFile (filename: PAnsiChar) : HResult; stdcall;
['{EB16CB09-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMTexture methods
function InitFromFile(filename: PChar): HResult; stdcall;
function InitFromSurface (lpDDS: IDirectDrawSurface) : HResult; stdcall;
function InitFromResource (rs: HRSRC) : HResult; stdcall;
function Changed (bPixels, bPalette: BOOL) : HResult; stdcall;
10913,12 → 7279,12
function SetColors (ulColors: DWORD) : HResult; stdcall;
function SetShades (ulShades: DWORD) : HResult; stdcall;
function SetDecalSize (rvWidth, rvHeight: TD3DValue) : HResult; stdcall;
function SetDecalOrigin (lX, lY: LongInt) : HResult; stdcall;
function SetDecalOrigin(lX, lY: Longint): HResult; stdcall;
function SetDecalScale (dwScale: DWORD) : HResult; stdcall;
function SetDecalTransparency (bTransp: BOOL) : HResult; stdcall;
function SetDecalTransparentColor (rcTransp: TD3DColor) : HResult; stdcall;
function GetDecalSize (out lprvWidth, lprvHeight: TD3DValue) : HResult; stdcall;
function GetDecalOrigin (out lplX, lplY: LongInt) : HResult; stdcall;
function GetDecalSize(var lprvWidth, lprvHeight: TD3DValue): HResult; stdcall;
function GetDecalOrigin(var lplX, lplY: Longint): HResult; stdcall;
function GetImage: PD3DRMImage; stdcall;
function GetShades: DWORD; stdcall;
function GetColors: DWORD; stdcall;
10928,70 → 7294,53
end;
 
IDirect3DRMTexture2 = interface (IDirect3DRMTexture)
['{120f30c0-1629-11d0-941c-0080c80cfa7b}']
(*
* IDirect3DRMTexture2 methods
*)
['{120F30C0-1629-11D0-941C-0080C80CFA7B}']
// IDirect3DRMTexture2 methods
function InitFromImage (const lpImage: TD3DRMImage) : HResult; stdcall;
function InitFromResource2 (hModule: HModule;
strName, strType: PAnsiChar) : HResult; stdcall;
function InitFromResource2(hModule: HModule; strName, strType: PChar): HResult; stdcall;
function GenerateMIPMap (dwFlags: DWORD) : HResult; stdcall;
end;
 
IDirect3DRMTexture3 = interface (IDirect3DRMTexture2)
['{ff6b7f73-a40e-11d1-91f9-0000f8758e66}']
(*
* IDirect3DRMTexture3 methods
*)
function GetSurface
(dwFlags: DWORD; out lplpDDS: IDirectDrawSurface) : HResult; stdcall;
function SetCacheOptions (lImportance: integer; dwFlags: DWORD) : HResult; stdcall;
function GetCacheOptions (var lplImportance: integer; var lpdwFlags: DWORD) : HResult; stdcall;
function SetDownsampleCallback (
pCallback: TD3DRMDownSampleCallback; pArg: pointer) : HResult; stdcall;
function SetValidationCallback (
pCallback: TD3DRMValidationCallback; pArg: pointer) : HResult; stdcall;
['{FF6B7F73-A40E-11D1-91F9-0000F8758E66}']
// IDirect3DRMTexture3 methods
function GetSurface(dwFlags: DWORD; out lplpDDS: IDirectDrawSurface): HResult; stdcall;
function SetCacheOptions(lImportance: Longint; dwFlags: DWORD): HResult; stdcall;
function GetCacheOptions(var lplImportance: Longint; var lpdwFlags: DWORD): HResult; stdcall;
function SetDownsampleCallback(pCallback: TD3DRMDownSampleCallback; pArg: Pointer): HResult; stdcall;
function SetValidationCallback(pCallback: TD3DRMValidationCallback; pArg: Pointer): HResult; stdcall;
end;
 
IDirect3DRMWrap = interface (IDirect3DRMObject)
['{eb16cb0a-d271-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMWrap methods
*)
['{EB16CB0A-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMWrap methods
function Init (d3drmwt: TD3DRMWrapType; lpd3drmfRef: IDirect3DRMFrame;
ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv: TD3DValue)
: HResult; stdcall;
ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv: TD3DValue): HResult; stdcall;
function Apply (lpObject: IDirect3DRMObject) : HResult; stdcall;
function ApplyRelative(frame: IDirect3DRMFrame; mesh: IDirect3DRMObject) : HResult; stdcall;
end;
 
IDirect3DRMMaterial = interface (IDirect3DRMObject)
['{eb16cb0b-d271-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMMaterial methods
*)
['{EB16CB0B-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMMaterial methods
function SetPower (rvPower: TD3DValue) : HResult; stdcall;
function SetSpecular (r, g, b: TD3DValue) : HResult; stdcall;
function SetEmissive (r, g, b: TD3DValue) : HResult; stdcall;
function GetPower: TD3DValue; stdcall;
function GetSpecular (out lpr, lpg, lpb: TD3DValue) : HResult; stdcall;
function GetEmissive (out lpr, lpg, lpb: TD3DValue) : HResult; stdcall;
function GetSpecular(var r, g, b: TD3DValue): HResult; stdcall;
function GetEmissive(var r, g, b: TD3DValue): HResult; stdcall;
end;
 
IDirect3DRMMaterial2 = interface (IDirect3DRMMaterial)
['{ff6b7f75-a40e-11d1-91f9-0000f8758e66}']
(*
* IDirect3DRMMaterial2 methods
*)
function GetAmbient(out r,g,b: TD3DValue) : HResult; stdcall;
['{FF6B7F75-A40E-11D1-91F9-0000F8758E66}']
// IDirect3DRMMaterial2 methods
function GetAmbient(var r, g, b: TD3DValue): HResult; stdcall;
function SetAmbient(r,g,b: TD3DValue) : HResult; stdcall;
end;
 
IDirect3DRMAnimation = interface (IDirect3DRMObject)
['{eb16cb0d-d271-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMAnimation methods
*)
['{EB16CB0D-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMAnimation methods
function SetOptions (d3drmanimFlags: TD3DRMAnimationOptions) : HResult; stdcall;
function AddRotateKey (rvTime: TD3DValue; const rqQuat: TD3DRMQuaternion) : HResult; stdcall;
function AddPositionKey (rvTime, rvX, rvY, rvZ: TD3DValue) : HResult; stdcall;
11002,27 → 7351,30
function GetOptions: TD3DRMAnimationOptions; stdcall;
end;
 
IDirect3DRMAnimation2 = interface (IDirect3DRMAnimation)
['{ff6b7f77-a40e-11d1-91f9-0000f8758e66}']
(*
* IDirect3DRMAnimation methods
*)
IDirect3DRMAnimation2 = interface(IDirect3DRMObject)
['{FF6B7F77-A40E-11D1-91F9-0000F8758E66}']
// IDirect3DRMAnimation2 methods
function SetOptions(d3drmanimFlags: TD3DRMAnimationOptions): HResult; stdcall;
function AddRotateKey(rvTime: TD3DValue; const rqQuat: TD3DRMQuaternion): HResult; stdcall;
function AddPositionKey(rvTime, rvX, rvY, rvZ: TD3DValue): HResult; stdcall;
function AddScaleKey(time, x, y, z: TD3DValue): HResult; stdcall;
function DeleteKey(time: TD3DValue): HResult; stdcall;
function SetFrame(lpD3DRMFrame: IDirect3DRMFrame3): HResult; stdcall;
function SetTime(rvTime: TD3DValue): HResult; stdcall;
function GetOptions: TD3DRMAnimationOptions; stdcall;
function GetFrame (out lpD3DFrame: IDirect3DRMFrame3) : HResult; stdcall;
function DeleteKeyByID (dwID: DWORD) : HResult; stdcall;
function AddKey (const lpKey: TD3DRMAnimationKey) : HResult; stdcall;
function ModifyKey (const lpKey: TD3DRMAnimationKey) : HResult; stdcall;
function GetKeys (dvTimeMin, dvTimeMax: TD3DValue; var lpdwNumKeys: DWORD;
lpKey: PD3DRMAnimationKey) : HResult; stdcall;
var lpKey: TD3DRMAnimationKey): HResult; stdcall;
end;
 
IDirect3DRMAnimationSet = interface (IDirect3DRMObject)
['{eb16cb0e-d271-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMAnimationSet methods
*)
['{EB16CB0E-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMAnimationSet methods
function AddAnimation (lpD3DRMAnimation: IDirect3DRMAnimation) : HResult; stdcall;
function Load (lpvObjSource, lpvObjID: Pointer;
d3drmLOFlags: TD3DRMLoadOptions;
function Load(lpvObjSource, lpvObjID: Pointer; d3drmLOFlags: TD3DRMLoadOptions;
d3drmLoadTextureProc: TD3DRMLoadTextureCallback; lpArgLTP: Pointer;
lpParentFrame: IDirect3DRMFrame) : HResult; stdcall;
function DeleteAnimation (lpD3DRMAnimation: IDirect3DRMAnimation) : HResult; stdcall;
11030,27 → 7382,21
end;
 
IDirect3DRMAnimationSet2 = interface (IDirect3DRMObject)
['{ff6b7f79-a40e-11d1-91f9-0000f8758e66}']
(*
* IDirect3DRMAnimationSet methods
*)
function AddAnimation (lpD3DRMAnimation: IDirect3DRMAnimation2) : HResult; stdcall;
function Load (lpvObjSource, lpvObjID: Pointer;
d3drmLOFlags: TD3DRMLoadOptions;
d3drmLoadTextureProc: TD3DRMLoadTexture3Callback; lpArgLTP: Pointer;
['{FF6B7F79-A40E-11D1-91F9-0000F8758E66}']
// IDirect3DRMAnimationSet2 methods
function AddAnimation(aid: IDirect3DRMAnimation2): HResult; stdcall;
function Load(filename, name: Pointer; loadflags: TD3DRMLoadOptions;
d3drmLoadTextureProc: TD3DRMLoadTexture3Callback; lpArg: Pointer;
lpParentFrame: IDirect3DRMFrame3) : HResult; stdcall;
function DeleteAnimation (lpD3DRMAnimation: IDirect3DRMAnimation2) : HResult; stdcall;
function SetTime (rvTime: TD3DValue) : HResult; stdcall;
function GetAnimations(out lplpArray: IDirect3DRMAnimationArray) : HResult; stdcall;
function DeleteAnimation(aid: IDirect3DRMAnimation2): HResult; stdcall;
function SetTime(time: TD3DValue): HResult; stdcall;
function GetAnimations(out lpAnimationArray: IDirect3DRMAnimationArray): HResult; stdcall;
end;
 
IDirect3DRMUserVisual = interface (IDirect3DRMVisual)
['{59163de0-6d43-11cf-ac4a-0000c03825a1}']
(*
* IDirect3DRMUserVisual methods
*)
function Init (d3drmUVProc: TD3DRMUserVisualCallback;
lpArg: Pointer) : HResult; stdcall;
['{59163DE0-6D43-11CF-AC4A-0000C03825A1}']
// IDirect3DRMUserVisual methods
function Init(d3drmUVProc: TD3DRMUserVisualCallback; lpArg: Pointer): HResult; stdcall;
end;
 
IDirect3DRMArray = interface (IUnknown)
11061,75 → 7407,72
*)
end;
 
IDirect3DRMObjectArray = interface (IDirect3DRMArray)
['{242f6bc2-3849-11d0-9b6d-0000c0781bc3}']
function GetElement (index: DWORD; out lplpD3DRMObject:
IDirect3DRMObject) : HResult; stdcall;
IDirect3DRMObjectarray = interface(IDirect3DRMArray)
function GetElement(index: DWORD; out lplpD3DRMObject: IDirect3DRMObject): HResult; stdcall;
end;
 
IDirect3DRMDeviceArray = interface (IDirect3DRMArray)
['{eb16cb0e-d271-11ce-ac48-0000c03825a1}']
function GetElement (index: DWORD; out lplpD3DRMDevice:
IDirect3DRMDevice) : HResult; stdcall;
['{EB16CB10-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMDevicearraymethods
function GetElement(index: DWORD; out lplpD3DRMDevice: IDirect3DRMDevice): HResult; stdcall;
end;
 
IDirect3DRMFrameArray = interface (IDirect3DRMArray)
['{eb16cb12-d271-11ce-ac48-0000c03825a1}']
['{EB16CB12-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMFramearraymethods
function GetElement (index: DWORD; out lplpD3DRMFrame: IDirect3DRMFrame) : HResult; stdcall;
end;
 
IDirect3DRMViewportArray = interface (IDirect3DRMArray)
['{eb16cb11-d271-11ce-ac48-0000c03825a1}']
function GetElement (index: DWORD; out lplpD3DRMViewport:
IDirect3DRMViewport) : HResult; stdcall;
['{EB16CB11-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMViewportarraymethods
function GetElement(index: DWORD; out lplpD3DRMViewport: IDirect3DRMViewport): HResult; stdcall;
end;
 
IDirect3DRMVisualArray = interface (IDirect3DRMArray)
['{eb16cb13-d271-11ce-ac48-0000c03825a1}']
function GetElement (index: DWORD; out lplpD3DRMVisual:
IDirect3DRMVisual) : HResult; stdcall;
['{EB16CB13-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMVisualarraymethods
function GetElement(index: DWORD; out lplpD3DRMVisual: IDirect3DRMVisual): HResult; stdcall;
end;
 
IDirect3DRMAnimationArray = interface (IDirect3DRMArray)
['{d5f1cae0-4bd7-11d1-b974-0060083e45f3}']
function GetElement (index: DWORD; out lplpD3DRMAnimation2:
IDirect3DRMAnimation2) : HResult; stdcall;
['{D5F1CAE0-4BD7-11D1-B974-0060083E45F3}']
function GetElement(index: DWORD; out lplpD3DRMAnimation: IDirect3DRMAnimation2): HResult; stdcall;
end;
 
IDirect3DRMPickedArray = interface (IDirect3DRMArray)
['{eb16cb16-d271-11ce-ac48-0000c03825a1}']
['{EB16CB16-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMPickedarraymethods
function GetPick (index: DWORD; out lplpVisual: IDirect3DRMVisual;
out lplpFrameArray: IDirect3DRMFrameArray;
const lpD3DRMPickDesc: TD3DRMPickDesc) : HResult; stdcall;
 
var lpD3DRMPickDesc: TD3DRMPickDesc): HResult; stdcall;
end;
 
IDirect3DRMLightArray = interface (IDirect3DRMArray)
['{eb16cb14-d271-11ce-ac48-0000c03825a1}']
['{EB16CB14-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMLightarraymethods
function GetElement (index: DWORD; out lplpD3DRMLight: IDirect3DRMLight) : HResult; stdcall;
end;
 
 
IDirect3DRMFaceArray = interface (IDirect3DRMArray)
['{eb16cb17-d271-11ce-ac48-0000c03825a1}']
['{EB16CB17-D271-11CE-AC48-0000C03825A1}']
// IDirect3DRMFacearraymethods
function GetElement (index: DWORD; out lplpD3DRMFace: IDirect3DRMFace) : HResult; stdcall;
end;
 
IDirect3DRMPicked2Array = interface (IDirect3DRMArray)
['{4516ec7b-8f20-11d0-9b6d-0000c0781bc3}']
['{4516EC7B-8F20-11D0-9B6D-0000C0781BC3}']
// IDirect3DRMPicked2arraymethods
function GetPick (index: DWORD; out lplpVisual: IDirect3DRMVisual;
out lplpFrameArray: IDirect3DRMFrameArray; const lpD3DRMPickDesc2:
TD3DRMPickDesc2) : HResult; stdcall;
out lplpFrameArray: IDirect3DRMFrameArray;
const lpD3DRMPickDesc2: D3DRMPICKDESC2): HResult; stdcall;
end;
 
IDirect3DRMInterpolator = interface (IDirect3DRMObject)
['{242f6bc1-3849-11d0-9b6d-0000c0781bc3}']
(*
* IDirect3DRMInterpolator methods
*)
['{242F6BC1-3849-11D0-9B6D-0000C0781BC3}']
// IDirect3DRMInterpolator methods
function AttachObject (lpD3DRMObject: IDirect3DRMObject) : HResult; stdcall;
function GetAttachedObjects
(lpD3DRMObjectArray: IDirect3DRMObjectArray) : HResult; stdcall;
function GetAttachedObjects(lpD3DRMObjectArray: IDirect3DRMObjectArray): HResult; stdcall;
function DetachObject (lpD3DRMObject: IDirect3DRMObject) : HResult; stdcall;
function SetIndex (d3dVal: TD3DValue) : HResult; stdcall;
function GetIndex : TD3DValue; stdcall;
11137,228 → 7480,163
d3drmInterpFlags: TD3DRMInterpolationOptions) : HResult; stdcall;
end;
 
IDirect3DRMClippedVisual = interface (IDirect3DRMObject)
['{5434e733-6d66-11d1-bb0b-0000f875865a}']
(*
* IDirect3DRMClippedVisual methods
*)
IDirect3DRMClippedVisual = interface(IDirect3DRMVisual)
['{5434E733-6D66-11D1-BB0B-0000F875865A}']
// IDirect3DRMClippedVisual methods
function Init (lpD3DRMVisual: IDirect3DRMVisual) : HResult; stdcall;
function AddPlane (lpRef: IDirect3DRMFrame3;
const lpdvPoint, lpdvNormal: TD3DVector;
dwFlags: DWORD; out lpdwReturnID: DWORD) : HResult; stdcall;
function AddPlane(lpRef: IDirect3DRMFrame3; const lpdvPoint, lpdvNormal: TD3DVector;
dwFlags: DWORD; var lpdwReturnID: DWORD): HResult; stdcall;
function DeletePlane (dwID, dwFlags: DWORD) : HResult; stdcall;
function GetPlaneIDs (var lpdwCount: DWORD; out lpdwID: DWORD; dwFlags: DWORD) : HResult; stdcall;
function GetPlaneIDs(var lpdwCount, lpdwID: DWORD; dwFlags: DWORD): HResult; stdcall;
function GetPlane (dwID: DWORD; lpRef: IDirect3DRMFrame3;
out lpdvPoint, lpdvNormal: TD3DVector; dwFlags: DWORD) : HResult; stdcall;
var lpdvPoint, lpdvNormal: TD3DVector; dwFlags: DWORD): HResult; stdcall;
function SetPlane (dwID: DWORD; lpRef: IDirect3DRMFrame3;
const lpdvPoint, lpdvNormal: TD3DVector; dwFlags: DWORD) : HResult; stdcall;
end;
 
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: d3drm.h
* Content: Direct3DRM include file
*
***************************************************************************)
IDirect3DRMWinDevice = interface(IDirect3DRMObject)
['{C5016CC0-D273-11CE-AC48-0000C03825A1}']
// IDirect3DRMWinDevice methods
function HandlePaint(hDC: HDC): HResult; stdcall;
function HandleActivate(wparam: WORD): HResult; stdcall;
end;
 
function D3DRMErrorString(Value: HResult) : string;
 
//type
//TRefClsID = TGUID;
 
type
TD3DRMDevicePaletteCallback = procedure (lpDirect3DRMDev: IDirect3DRMDevice;
lpArg: Pointer; dwIndex: DWORD; red, green, blue: LongInt); cdecl;
 
(*
* Direct3DRM Object Class (for CoCreateInstance())
*)
const
CLSID_CDirect3DRM: TGUID =
(D1:$4516ec41;D2:$8f20;D3:$11d0;D4:($9b,$6d,$00,$00,$c0,$78,$1b,$c3));
 
type
IDirect3DRM = interface (IUnknown)
['{2bc49361-8327-11cf-ac4a-0000c03825a1}']
function CreateObject (const rclsid: TRefClsID; pUnkOuter: IUnknown;
['{2BC49361-8327-11CF-AC4A-0000C03825A1}']
// IDirect3DRM methods
function CreateObject(const rclsid: TGUID; pUnkOuter: IUnknown;
const riid: TGUID; out ppv) : HResult; stdcall;
function CreateFrame (lpD3DRMFrame: IDirect3DRMFrame;
var lplpD3DRMFrame: IDirect3DRMFrame) : HResult; stdcall;
function CreateMesh (var lplpD3DRMMesh: IDirect3DRMMesh) : HResult; stdcall;
function CreateMeshBuilder (var lplpD3DRMMeshBuilder:
out lplpD3DRMFrame: IDirect3DRMFrame): HResult; stdcall;
function CreateMesh(out lplpD3DRMMesh: IDirect3DRMMesh): HResult; stdcall;
function CreateMeshBuilder(out lplpD3DRMMeshBuilder:
IDirect3DRMMeshBuilder) : HResult; stdcall;
function CreateFace (var lplpd3drmFace: IDirect3DRMFace) : HResult; stdcall;
function CreateAnimation (var lplpD3DRMAnimation: IDirect3DRMAnimation) : HResult; stdcall;
function CreateAnimationSet (var lplpD3DRMAnimationSet:
function CreateFace(out lplpd3drmFace: IDirect3DRMFace): HResult; stdcall;
function CreateAnimation(out lplpD3DRMAnimation: IDirect3DRMAnimation): HResult; stdcall;
function CreateAnimationSet(out lplpD3DRMAnimationSet:
IDirect3DRMAnimationSet) : HResult; stdcall;
function CreateTexture (var lpImage: TD3DRMImage;
var lplpD3DRMTexture: IDirect3DRMTexture) : HResult; stdcall;
function CreateTexture(const lpImage: TD3DRMImage;
out lplpD3DRMTexture: IDirect3DRMTexture): HResult; stdcall;
function CreateLight (d3drmltLightType: TD3DRMLightType;
cColor: TD3DColor; var lplpD3DRMLight: IDirect3DRMLight) : HResult; stdcall;
function CreateLightRGB (ltLightType: TD3DRMLightType; vRed,
vGreen, vBlue: TD3DValue; var lplpD3DRMLight: IDirect3DRMLight) : HResult; stdcall;
function CreateMaterial (vPower: TD3DValue; var lplpD3DRMMaterial:
cColor: TD3DColor; out lplpD3DRMLight: IDirect3DRMLight): HResult; stdcall;
function CreateLightRGB(ltLightType: TD3DRMLightType; vRed, vGreen, vBlue:
TD3DValue; out lplpD3DRMLight: IDirect3DRMLight): HResult; stdcall;
function CreateMaterial(vPower: TD3DValue; out lplpD3DRMMaterial:
IDirect3DRMMaterial) : HResult; stdcall;
function CreateDevice (dwWidth, dwHeight: DWORD; var lplpD3DRMDevice:
function CreateDevice(dwWidth, dwHeight: DWORD; out lplpD3DRMDevice:
IDirect3DRMDevice) : HResult; stdcall;
 
(* Create a Windows Device using DirectDraw surfaces *)
function CreateDeviceFromSurface (lpGUID: PGUID; lpDD: IDirectDraw;
lpDDSBack: IDirectDrawSurface; var lplpD3DRMDevice: IDirect3DRMDevice) :
HResult; stdcall;
 
(* Create a Windows Device using D3D objects *)
function CreateDeviceFromSurface(const lpGUID: TGUID; lpDD: IDirectDraw;
lpDDSBack: IDirectDrawSurface; out lplpD3DRMDevice: IDirect3DRMDevice): HResult; stdcall;
function CreateDeviceFromD3D (lpD3D: IDirect3D; lpD3DDev: IDirect3DDevice;
var lplpD3DRMDevice: IDirect3DRMDevice) : HResult; stdcall;
 
out lplpD3DRMDevice: IDirect3DRMDevice): HResult; stdcall;
function CreateDeviceFromClipper (lpDDClipper: IDirectDrawClipper;
lpGUID: PGUID; width, height: Integer; var lplpD3DRMDevice:
const lpGUID: TGUID; width, height: DWORD; out lplpD3DRMDevice:
IDirect3DRMDevice) : HResult; stdcall;
 
function CreateTextureFromSurface ( lpDDS: IDirectDrawSurface;
var lplpD3DRMTexture: IDirect3DRMTexture) : HResult; stdcall;
 
out lplpD3DRMTexture: IDirect3DRMTexture): HResult; stdcall;
function CreateShadow (lpVisual: IDirect3DRMVisual;
lpLight: IDirect3DRMLight; px, py, pz, nx, ny, nz: TD3DValue;
var lplpShadow: IDirect3DRMVisual) : HResult; stdcall;
out lplpShadow: IDirect3DRMVisual): HResult; stdcall;
function CreateViewport (lpDev: IDirect3DRMDevice;
lpCamera: IDirect3DRMFrame; dwXPos, dwYPos, dwWidth, dwHeight: DWORD;
var lplpD3DRMViewport: IDirect3DRMViewport) : HResult; stdcall;
out lplpD3DRMViewport: IDirect3DRMViewport): HResult; stdcall;
function CreateWrap (wraptype: TD3DRMWrapType; lpRef: IDirect3DRMFrame;
ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv: TD3DValue;
var lplpD3DRMWrap: IDirect3DRMWrap) : HResult; stdcall;
out lplpD3DRMWrap: IDirect3DRMWrap): HResult; stdcall;
function CreateUserVisual (fn: TD3DRMUserVisualCallback; lpArg: Pointer;
var lplpD3DRMUV: IDirect3DRMUserVisual) : HResult; stdcall;
function LoadTexture (lpFileName: PAnsiChar; var lplpD3DRMTexture:
out lplpD3DRMUV: IDirect3DRMUserVisual): HResult; stdcall;
function LoadTexture(lpFileName: LPSTR; out lplpD3DRMTexture:
IDirect3DRMTexture) : HResult; stdcall;
function LoadTextureFromResource (rs: HRSRC; var lplpD3DRMTexture:
function LoadTextureFromResource(rs: HRSRC; out lplpD3DRMTexture:
IDirect3DRMTexture) : HResult; stdcall;
 
function SetSearchPath (lpPath: PAnsiChar) : HResult; stdcall;
function AddSearchPath (lpPath: PAnsiChar) : HResult; stdcall;
function GetSearchPath (var lpdwSize: DWORD; lpszPath: PAnsiChar) : HResult; stdcall;
function SetSearchPath(lpPath: LPSTR): HResult; stdcall;
function AddSearchPath(lpPath: LPSTR): HResult; stdcall;
function GetSearchPath(var lpdwSize: DWORD; lpszPath: LPSTR): HResult; stdcall;
function SetDefaultTextureColors (dwColors: DWORD) : HResult; stdcall;
function SetDefaultTextureShades (dwShades: DWORD) : HResult; stdcall;
 
function GetDevices (var lplpDevArray: IDirect3DRMDeviceArray) : HResult; stdcall;
function GetNamedObject (lpName: PAnsiChar; var lplpD3DRMObject: IDirect3DRMObject) : HResult; stdcall;
 
function GetDevices(out lplpDevArray: IDirect3DRMDeviceArray): HResult; stdcall;
function GetNamedObject(lpName: LPSTR; out lplpD3DRMObject:
IDirect3DRMObject): HResult; stdcall;
function EnumerateObjects (func: TD3DRMObjectCallback; lpArg: Pointer) : HResult; stdcall;
 
function Load (lpvObjSource, lpvObjID: Pointer; var lplpGUIDs: PGUID;
dwcGUIDs: DWORD; d3drmLOFlags: TD3DRMLoadOptions; d3drmLoadProc:
TD3DRMLoadCallback; lpArgLP: Pointer; d3drmLoadTextureProc:
TD3DRMLoadTextureCallback; lpArgLTP: Pointer; lpParentFrame:
IDirect3DRMFrame) : HResult; stdcall;
D3DRMLOADCALLBACK; lpArgLP: Pointer; d3drmLoadTextureProc:
TD3DRMLoadTextureCallback; lpArgLTP: Pointer;
lpParentFrame: IDirect3DRMFrame): HResult; stdcall;
function Tick (d3dvalTick: TD3DValue) : HResult; stdcall;
end;
 
// Moved from D3DRMObj, to avoid circular unit reference:
 
IDirect3DRMObject2 = interface (IUnknown)
['{4516ec7c-8f20-11d0-9b6d-0000c0781bc3}']
(*
* IDirect3DRMObject2 methods
*)
function AddDestroyCallback (lpCallback: TD3DRMObjectCallback;
lpArg: Pointer) : HResult; stdcall;
function Clone (pUnkOuter: IUnknown; const riid: TGUID;
out ppvObj) : HResult; stdcall;
function DeleteDestroyCallback (d3drmObjProc: TD3DRMObjectCallback;
lpArg: Pointer) : HResult; stdcall;
function GetClientData (dwID: DWORD; out lplpvData: Pointer) : HResult; stdcall;
function GetDirect3DRM (out lplpDirect3DRM: IDirect3DRM) : HResult; stdcall;
function GetName (var lpdwSize: DWORD; lpName: PAnsiChar) : HResult; stdcall;
function SetClientData (dwID: DWORD; lpvData: pointer; dwFlags: DWORD) : HResult; stdcall;
function SetName (lpName: PAnsiChar) : HResult; stdcall;
function GetAge (dwFlags: DWORD; out pdwAge: DWORD) : HResult; stdcall;
end;
 
IID_IDirect3DRMObject2 = IDirect3DRMObject2;
 
IDirect3DRM2 = interface (IUnknown)
['{4516ecc8-8f20-11d0-9b6d-0000c0781bc3}']
function CreateObject (const rclsid: TRefClsID; pUnkOuter: IUnknown;
['{4516ECC8-8F20-11D0-9B6D-0000C0781BC3}']
// IDirect3DRM2 methods
function CreateObject(const rclsid: TGUID; pUnkOuter: IUnknown;
const riid: TGUID; out ppv) : HResult; stdcall;
function CreateFrame (lpD3DRMFrame: IDirect3DRMFrame2;
var lplpD3DRMFrame: IDirect3DRMFrame2) : HResult; stdcall;
function CreateMesh (var lplpD3DRMMesh: IDirect3DRMMesh) : HResult; stdcall;
function CreateMeshBuilder (var lplpD3DRMMeshBuilder:
out lplpD3DRMFrame: IDirect3DRMFrame2): HResult; stdcall;
function CreateMesh(out lplpD3DRMMesh: IDirect3DRMMesh): HResult; stdcall;
function CreateMeshBuilder(out lplpD3DRMMeshBuilder:
IDirect3DRMMeshBuilder2) : HResult; stdcall;
function CreateFace (var lplpd3drmFace: IDirect3DRMFace) : HResult; stdcall;
function CreateAnimation (var lplpD3DRMAnimation: IDirect3DRMAnimation) : HResult; stdcall;
function CreateAnimationSet (var lplpD3DRMAnimationSet:
function CreateFace(out lplpd3drmFace: IDirect3DRMFace): HResult; stdcall;
function CreateAnimation(out lplpD3DRMAnimation: IDirect3DRMAnimation): HResult; stdcall;
function CreateAnimationSet(out lplpD3DRMAnimationSet:
IDirect3DRMAnimationSet) : HResult; stdcall;
function CreateTexture (var lpImage: TD3DRMImage;
var lplpD3DRMTexture: IDirect3DRMTexture2) : HResult; stdcall;
function CreateTexture(const lpImage: TD3DRMImage;
out lplpD3DRMTexture: IDirect3DRMTexture2): HResult; stdcall;
function CreateLight (d3drmltLightType: TD3DRMLightType;
cColor: TD3DColor; var lplpD3DRMLight: IDirect3DRMLight) : HResult; stdcall;
cColor: TD3DColor; out lplpD3DRMLight: IDirect3DRMLight): HResult; stdcall;
function CreateLightRGB (ltLightType: TD3DRMLightType; vRed,
vGreen, vBlue: TD3DValue; var lplpD3DRMLight: IDirect3DRMLight) : HResult; stdcall;
function CreateMaterial (vPower: TD3DValue; var lplpD3DRMMaterial:
vGreen, vBlue: TD3DValue; out lplpD3DRMLight: IDirect3DRMLight): HResult; stdcall;
function CreateMaterial(vPower: TD3DValue; out lplpD3DRMMaterial:
IDirect3DRMMaterial) : HResult; stdcall;
function CreateDevice (dwWidth, dwHeight: DWORD; var lplpD3DRMDevice:
function CreateDevice(dwWidth, dwHeight: DWORD; out lplpD3DRMDevice:
IDirect3DRMDevice2) : HResult; stdcall;
 
(* Create a Windows Device using DirectDraw surfaces *)
function CreateDeviceFromSurface (lpGUID: PGUID; lpDD: IDirectDraw;
lpDDSBack: IDirectDrawSurface; var lplpD3DRMDevice: IDirect3DRMDevice2) :
HResult; stdcall;
 
(* Create a Windows Device using D3D objects *)
function CreateDeviceFromSurface(const lpGUID: TGUID; lpDD: IDirectDraw;
lpDDSBack: IDirectDrawSurface; out lplpD3DRMDevice: IDirect3DRMDevice2): HResult; stdcall;
function CreateDeviceFromD3D (lpD3D: IDirect3D2; lpD3DDev: IDirect3DDevice2;
var lplpD3DRMDevice: IDirect3DRMDevice2) : HResult; stdcall;
 
out lplpD3DRMDevice: IDirect3DRMDevice2): HResult; stdcall;
function CreateDeviceFromClipper (lpDDClipper: IDirectDrawClipper;
lpGUID: PGUID; width, height: Integer; var lplpD3DRMDevice:
const lpGUID: TGUID; width, height: DWORD; out lplpD3DRMDevice:
IDirect3DRMDevice2) : HResult; stdcall;
 
function CreateTextureFromSurface ( lpDDS: IDirectDrawSurface;
var lplpD3DRMTexture: IDirect3DRMTexture2) : HResult; stdcall;
 
out lplpD3DRMTexture: IDirect3DRMTexture2): HResult; stdcall;
function CreateShadow (lpVisual: IDirect3DRMVisual;
lpLight: IDirect3DRMLight; px, py, pz, nx, ny, nz: TD3DValue;
var lplpShadow: IDirect3DRMVisual) : HResult; stdcall;
out lplpShadow: IDirect3DRMVisual): HResult; stdcall;
function CreateViewport (lpDev: IDirect3DRMDevice;
lpCamera: IDirect3DRMFrame; dwXPos, dwYPos, dwWidth, dwHeight: DWORD;
var lplpD3DRMViewport: IDirect3DRMViewport) : HResult; stdcall;
out lplpD3DRMViewport: IDirect3DRMViewport): HResult; stdcall;
function CreateWrap (wraptype: TD3DRMWrapType; lpRef: IDirect3DRMFrame;
ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv: TD3DValue;
var lplpD3DRMWrap: IDirect3DRMWrap) : HResult; stdcall;
out lplpD3DRMWrap: IDirect3DRMWrap): HResult; stdcall;
function CreateUserVisual (fn: TD3DRMUserVisualCallback; lpArg: Pointer;
var lplpD3DRMUV: IDirect3DRMUserVisual) : HResult; stdcall;
function LoadTexture (lpFileName: PAnsiChar; var lplpD3DRMTexture:
out lplpD3DRMUV: IDirect3DRMUserVisual): HResult; stdcall;
function LoadTexture(lpFileName: LPSTR; out lplpD3DRMTexture:
IDirect3DRMTexture2) : HResult; stdcall;
function LoadTextureFromResource (rs: HRSRC; var lplpD3DRMTexture:
function LoadTextureFromResource(hModule: HModule; str: LPCSTR; out lplpD3DRMTexture:
IDirect3DRMTexture2) : HResult; stdcall;
 
function SetSearchPath (lpPath: PAnsiChar) : HResult; stdcall;
function AddSearchPath (lpPath: PAnsiChar) : HResult; stdcall;
function GetSearchPath (var lpdwSize: DWORD; lpszPath: PAnsiChar) : HResult; stdcall;
function SetSearchPath(lpPath: LPSTR): HResult; stdcall;
function AddSearchPath(lpPath: LPSTR): HResult; stdcall;
function GetSearchPath(var lpdwSize: DWORD; lpszPath: LPSTR): HResult; stdcall;
function SetDefaultTextureColors (dwColors: DWORD) : HResult; stdcall;
function SetDefaultTextureShades (dwShades: DWORD) : HResult; stdcall;
 
function GetDevices (var lplpDevArray: IDirect3DRMDeviceArray) : HResult; stdcall;
function GetNamedObject (lpName: PAnsiChar; var lplpD3DRMObject:
function GetDevices(out lplpDevArray: IDirect3DRMDeviceArray): HResult; stdcall;
function GetNamedObject(lpName: LPSTR; out lplpD3DRMObject:
IDirect3DRMObject) : HResult; stdcall;
 
function EnumerateObjects (func: TD3DRMObjectCallback; lpArg: Pointer) : HResult; stdcall;
 
function Load (lpvObjSource, lpvObjID: Pointer; var lplpGUIDs: PGUID;
dwcGUIDs: DWORD; d3drmLOFlags: TD3DRMLoadOptions; d3drmLoadProc:
TD3DRMLoadCallback; lpArgLP: Pointer; d3drmLoadTextureProc:
D3DRMLOADCALLBACK; lpArgLP: Pointer; d3drmLoadTextureProc:
TD3DRMLoadTextureCallback; lpArgLTP: Pointer; lpParentFrame:
IDirect3DRMFrame) : HResult; stdcall;
function Tick (d3dvalTick: TD3DValue) : HResult; stdcall;
function CreateProgressiveMesh (var lplpD3DRMProgressiveMesh:
function CreateProgressiveMesh(out lplpD3DRMProgressiveMesh:
IDirect3DRMProgressiveMesh) : HResult; stdcall;
end;
 
IDirect3DRM3 = interface (IUnknown)
['{4516ec83-8f20-11d0-9b6d-0000c0781bc3}']
function CreateObject (const rclsid: TRefClsID; pUnkOuter: IUnknown;
['{4516EC83-8F20-11D0-9B6D-0000C0781BC3}']
// IDirect3DRM2 methods
function CreateObject(const rclsid: TGUID; pUnkOuter: IUnknown;
const riid: TGUID; out ppv) : HResult; stdcall;
function CreateFrame (lpD3DRMFrame: IDirect3DRMFrame3;
out lplpD3DRMFrame: IDirect3DRMFrame3) : HResult; stdcall;
11379,26 → 7657,18
IDirect3DRMMaterial2) : HResult; stdcall;
function CreateDevice (dwWidth, dwHeight: DWORD; out lplpD3DRMDevice:
IDirect3DRMDevice3) : HResult; stdcall;
 
(* Create a Windows Device using DirectDraw surfaces *)
function CreateDeviceFromSurface (lpGUID: PGUID; lpDD: IDirectDraw;
lpDDSBack: IDirectDrawSurface; dwFlags: DWORD;
out lplpD3DRMDevice: IDirect3DRMDevice3) : HResult; stdcall;
 
(* Create a Windows Device using D3D objects *)
function CreateDeviceFromSurface(const lpGUID: TGUID; lpDD: IDirectDraw;
lpDDSBack: IDirectDrawSurface; out lplpD3DRMDevice: IDirect3DRMDevice3): HResult; stdcall;
function CreateDeviceFromD3D (lpD3D: IDirect3D2; lpD3DDev: IDirect3DDevice2;
out lplpD3DRMDevice: IDirect3DRMDevice3) : HResult; stdcall;
 
function CreateDeviceFromClipper (lpDDClipper: IDirectDrawClipper;
lpGUID: PGUID; width, height: Integer;
out lplpD3DRMDevice: IDirect3DRMDevice3) : HResult; stdcall;
 
const lpGUID: TGUID; width, height: DWORD; out lplpD3DRMDevice:
IDirect3DRMDevice3): HResult; stdcall;
function CreateTextureFromSurface ( lpDDS: IDirectDrawSurface;
out lplpD3DRMTexture: IDirect3DRMTexture3) : HResult; stdcall;
 
function CreateShadow (pUnk: IUnknown; lpLight: IDirect3DRMLight;
px, py, pz, nx, ny, nz: TD3DValue;
out lplpShadow: IDirect3DRMShadow2) : HResult; stdcall;
function CreateShadow(lpVisual: IDirect3DRMVisual;
lpLight: IDirect3DRMLight; px, py, pz, nx, ny, nz: TD3DValue;
out lplpShadow: IDirect3DRMShadow): HResult; stdcall;
function CreateViewport (lpDev: IDirect3DRMDevice3;
lpCamera: IDirect3DRMFrame3; dwXPos, dwYPos, dwWidth, dwHeight: DWORD;
out lplpD3DRMViewport: IDirect3DRMViewport2) : HResult; stdcall;
11407,687 → 7677,733
out lplpD3DRMWrap: IDirect3DRMWrap) : HResult; stdcall;
function CreateUserVisual (fn: TD3DRMUserVisualCallback; lpArg: Pointer;
out lplpD3DRMUV: IDirect3DRMUserVisual) : HResult; stdcall;
function LoadTexture (lpFileName: PAnsiChar; out lplpD3DRMTexture:
function LoadTexture(lpFileName: LPSTR; out lplpD3DRMTexture:
IDirect3DRMTexture3) : HResult; stdcall;
function LoadTextureFromResource (hModule: HMODULE;
strName, strType: PAnsiChar;
out lplpD3DRMTexture: IDirect3DRMTexture3) : HResult; stdcall;
function LoadTextureFromResource(hModule: HModule; str: LPCSTR; out lplpD3DRMTexture:
IDirect3DRMTexture3): HResult; stdcall;
 
function SetSearchPath (lpPath: PAnsiChar) : HResult; stdcall;
function AddSearchPath (lpPath: PAnsiChar) : HResult; stdcall;
function GetSearchPath (var lpdwSize: DWORD; lpszPath: PAnsiChar) : HResult; stdcall;
function SetSearchPath(lpPath: LPSTR): HResult; stdcall;
function AddSearchPath(lpPath: LPSTR): HResult; stdcall;
function GetSearchPath(var lpdwSize: DWORD; lpszPath: LPSTR): HResult; stdcall;
function SetDefaultTextureColors (dwColors: DWORD) : HResult; stdcall;
function SetDefaultTextureShades (dwShades: DWORD) : HResult; stdcall;
 
function GetDevices (out lplpDevArray: IDirect3DRMDeviceArray) : HResult; stdcall;
function GetNamedObject (lpName: PAnsiChar; out lplpD3DRMObject: IDirect3DRMObject) : HResult; stdcall;
 
function GetNamedObject(lpName: LPSTR; out lplpD3DRMObject:
IDirect3DRMObject): HResult; stdcall;
function EnumerateObjects (func: TD3DRMObjectCallback; lpArg: Pointer) : HResult; stdcall;
 
function Load (lpvObjSource, lpvObjID: Pointer; var lplpGUIDs: PGUID;
dwcGUIDs: DWORD; d3drmLOFlags: TD3DRMLoadOptions; d3drmLoadProc:
TD3DRMLoadCallback; lpArgLP: Pointer; d3drmLoadTextureProc:
D3DRMLOADCALLBACK; lpArgLP: Pointer; d3drmLoadTextureProc:
TD3DRMLoadTexture3Callback; lpArgLTP: Pointer; lpParentFrame:
IDirect3DRMFrame3) : HResult; stdcall;
function Tick (d3dvalTick: TD3DValue) : HResult; stdcall;
function CreateProgressiveMesh (out lplpD3DRMProgressiveMesh:
IDirect3DRMProgressiveMesh) : HResult; stdcall;
 
(* Used with IDirect3DRMObject2 *)
function RegisterClient (const rguid: TGUID; out lpdwID: DWORD) : HResult; stdcall;
// IDirect3RM3 methods
function RegisterClient(const rguid: TGUID; var lpdwID: DWORD): HResult; stdcall;
function UnregisterClient (const rguid: TGUID) : HResult; stdcall;
 
function CreateClippedVisual (lpVisual: IDirect3DRMVisual;
lpClippedVisual: IDirect3DRMClippedVisual) : HResult; stdcall;
function SetOptions (dwOptions: DWORD) : HResult; stdcall;
function GetOptions (out lpdwOptions: DWORD) : HResult; stdcall;
out lpClippedVisual: IDirect3DRMVisual): HResult; stdcall;
function SetOptions(lpdwOptions: DWORD): HResult; stdcall;
function GetOptions(var lpdwOptions: DWORD): HResult; stdcall;
end;
 
IID_IDirect3DRM = IDirect3DRM;
IID_IDirect3DRM2 = IDirect3DRM2;
IID_IDirect3DRM3 = IDirect3DRM3;
 
const
MAKE_D3RMDHRESULT = HResult($88760000);
D3DRM_OK = HResult(DD_OK);
D3DRMERR_BADOBJECT = HResult($88760000 + 781);
D3DRMERR_BADTYPE = HResult($88760000 + 782);
D3DRMERR_BADALLOC = HResult($88760000 + 783);
D3DRMERR_FACEUSED = HResult($88760000 + 784);
D3DRMERR_NOTFOUND = HResult($88760000 + 785);
D3DRMERR_NOTDONEYET = HResult($88760000 + 786);
D3DRMERR_FILENOTFOUND = HResult($88760000 + 787);
D3DRMERR_BADFILE = HResult($88760000 + 788);
D3DRMERR_BADDEVICE = HResult($88760000 + 789);
D3DRMERR_BADVALUE = HResult($88760000 + 790);
D3DRMERR_BADMAJORVERSION = HResult($88760000 + 791);
D3DRMERR_BADMINORVERSION = HResult($88760000 + 792);
D3DRMERR_UNABLETOEXECUTE = HResult($88760000 + 793);
D3DRMERR_LIBRARYNOTFOUND = HResult($88760000 + 794);
D3DRMERR_INVALIDLIBRARY = HResult($88760000 + 795);
D3DRMERR_PENDING = HResult($88760000 + 796);
D3DRMERR_NOTENOUGHDATA = HResult($88760000 + 797);
D3DRMERR_REQUESTTOOLARGE = HResult($88760000 + 798);
D3DRMERR_REQUESTTOOSMALL = HResult($88760000 + 799);
D3DRMERR_CONNECTIONLOST = HResult($88760000 + 800);
D3DRMERR_LOADABORTED = HResult($88760000 + 801);
D3DRMERR_NOINTERNET = HResult($88760000 + 802);
D3DRMERR_BADCACHEFILE = HResult($88760000 + 803);
D3DRMERR_BOXNOTSET = HResult($88760000 + 804);
D3DRMERR_BADPMDATA = HResult($88760000 + 805);
D3DRMERR_CLIENTNOTREGISTERED = HResult($88760000 + 806);
D3DRMERR_NOTCREATEDFROMDDS = HResult($88760000 + 807);
D3DRMERR_NOSUCHKEY = HResult($88760000 + 808);
D3DRMERR_INCOMPATABLEKEY = HResult($88760000 + 809);
D3DRMERR_ELEMENTINUSE = HResult($88760000 + 810);
D3DRMERR_TEXTUREFORMATNOTFOUND = HResult($88760000 + 811);
D3DRMERR_NOTAGGREGATED = HResult($88760000 + 812);
 
D3DRM_OK = DD_OK;
D3DRMERR_BADOBJECT = MAKE_D3RMDHRESULT + 781;
D3DRMERR_BADTYPE = MAKE_D3RMDHRESULT + 782;
D3DRMERR_BADALLOC = MAKE_D3RMDHRESULT + 783;
D3DRMERR_FACEUSED = MAKE_D3RMDHRESULT + 784;
D3DRMERR_NOTFOUND = MAKE_D3RMDHRESULT + 785;
D3DRMERR_NOTDONEYET = MAKE_D3RMDHRESULT + 786;
D3DRMERR_FILENOTFOUND = MAKE_D3RMDHRESULT + 787;
D3DRMERR_BADFILE = MAKE_D3RMDHRESULT + 788;
D3DRMERR_BADDEVICE = MAKE_D3RMDHRESULT + 789;
D3DRMERR_BADVALUE = MAKE_D3RMDHRESULT + 790;
D3DRMERR_BADMAJORVERSION = MAKE_D3RMDHRESULT + 791;
D3DRMERR_BADMINORVERSION = MAKE_D3RMDHRESULT + 792;
D3DRMERR_UNABLETOEXECUTE = MAKE_D3RMDHRESULT + 793;
D3DRMERR_LIBRARYNOTFOUND = MAKE_D3RMDHRESULT + 794;
D3DRMERR_INVALIDLIBRARY = MAKE_D3RMDHRESULT + 795;
D3DRMERR_PENDING = MAKE_D3RMDHRESULT + 796;
D3DRMERR_NOTENOUGHDATA = MAKE_D3RMDHRESULT + 797;
D3DRMERR_REQUESTTOOLARGE = MAKE_D3RMDHRESULT + 798;
D3DRMERR_REQUESTTOOSMALL = MAKE_D3RMDHRESULT + 799;
D3DRMERR_CONNECTIONLOST = MAKE_D3RMDHRESULT + 800;
D3DRMERR_LOADABORTED = MAKE_D3RMDHRESULT + 801;
D3DRMERR_NOINTERNET = MAKE_D3RMDHRESULT + 802;
D3DRMERR_BADCACHEFILE = MAKE_D3RMDHRESULT + 803;
D3DRMERR_BOXNOTSET = MAKE_D3RMDHRESULT + 804;
D3DRMERR_BADPMDATA = MAKE_D3RMDHRESULT + 805;
D3DRMERR_CLIENTNOTREGISTERED = MAKE_D3RMDHRESULT + 806;
D3DRMERR_NOTCREATEDFROMDDS = MAKE_D3RMDHRESULT + 807;
D3DRMERR_NOSUCHKEY = MAKE_D3RMDHRESULT + 808;
D3DRMERR_INCOMPATABLEKEY = MAKE_D3RMDHRESULT + 809;
D3DRMERR_ELEMENTINUSE = MAKE_D3RMDHRESULT + 810;
D3DRMERR_TEXTUREFORMATNOTFOUND = MAKE_D3RMDHRESULT + 811;
{ Create a Direct3DRM API }
function Direct3DRMCreate(out lplpDirect3DRM: IDirect3DRM): HResult; stdcall;
 
(* Create a Direct3DRM API *)
var
Direct3DRMCreate : function (out lplpDirect3DRM: IDirect3DRM) : HResult; stdcall;
 
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: d3drmwin.h
* Content: Direct3DRM include file
*
***************************************************************************)
 
type
IDirect3DRMWinDevice = interface (IDirect3DRMObject)
['{c5016cc0-d273-11ce-ac48-0000c03825a1}']
(*
* IDirect3DRMWinDevice methods
*)
 
(* Repaint the window with the last frame which was rendered. *)
function HandlePaint (hDC: HDC) : HResult; stdcall;
 
(* Respond to a WM_ACTIVATE message. *)
function HandleActivate (wparam: WORD) : HResult; stdcall;
end;
 
(*
* GUIDS used by Direct3DRM Windows interface
*)
IID_IDirect3DRMWinDevice = IDirect3DRMWinDevice;
 
(***************************************************************************
*
* Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved.
*
* File: rmxfguid.h
* File: dxfile.h
*
* Content: Defines GUIDs of D3DRM's templates.
* Content: DirectX File public header file
*
***************************************************************************)
{ DirectXFile Object Class Id (for CoCreateInstance()) }
 
const
(* {2B957100-9E9A-11cf-AB39-0020AF71E433} *)
TID_D3DRMInfo: TGUID =
(D1:$2b957100;D2:$9e9a;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
CLSID_CDirectXFile: TGUID = '{4516EC43-8F20-11D0-9B6D-0000C0781BC3}';
 
(* {3D82AB44-62DA-11cf-AB39-0020AF71E433} *)
TID_D3DRMMesh: TGUID =
(D1:$3d82ab44;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
{ DirectX File Interface GUIDs. }
 
(* {3D82AB5E-62DA-11cf-AB39-0020AF71E433} *)
TID_D3DRMVector: TGUID =
(D1:$3d82ab5e;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
IID_IDirectXFile: TGUID = '{3D82AB40-62DA-11CF-AB39-0020AF71E433}';
IID_IDirectXFileEnumObject: TGUID = '{3D82AB41-62DA-11CF-AB39-0020AF71E433}';
IID_IDirectXFileSaveObject: TGUID = '{3D82AB42-62DA-11CF-AB39-0020AF71E433}';
IID_IDirectXFileObject: TGUID = '{3D82AB43-62DA-11CF-AB39-0020AF71E433}';
IID_IDirectXFileData: TGUID = '{3D82AB44-62DA-11CF-AB39-0020AF71E433}';
IID_IDirectXFileDataReference: TGUID = '{3D82AB45-62DA-11CF-AB39-0020AF71E433}';
IID_IDirectXFileBinary: TGUID = '{3D82AB46-62DA-11CF-AB39-0020AF71E433}';
 
(* {3D82AB5F-62DA-11cf-AB39-0020AF71E433} *)
TID_D3DRMMeshFace: TGUID =
(D1:$3d82ab5f;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
type
TDXFileFormat = DWORD;
DXFILEFORMAT = TDXFileFormat;
 
(* {3D82AB4D-62DA-11cf-AB39-0020AF71E433} *)
TID_D3DRMMaterial: TGUID =
(D1:$3d82ab4d;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
const
DXFILEFORMAT_BINARY = 0;
DXFILEFORMAT_TEXT = 1;
DXFILEFORMAT_COMPRESSED = 2;
 
(* {35FF44E1-6C7C-11cf-8F52-0040333594A3} *)
TID_D3DRMMaterialArray: TGUID =
(D1:$35ff44e1;D2:$6c7c;D3:$11cf;D4:($8F,$52,$00,$40,$33,$35,$94,$a3));
type
TDXFileLoadOptions = DWORD;
DXFILELOADOPTIONS = TDXFileLoadOptions;
 
(* {3D82AB46-62DA-11cf-AB39-0020AF71E433} *)
TID_D3DRMFrame: TGUID =
(D1:$3d82ab46;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
const
DXFILELOAD_FROMFILE = $00;
DXFILELOAD_FROMRESOURCE = $01;
DXFILELOAD_FROMMEMORY = $02;
DXFILELOAD_FROMSTREAM = $04;
DXFILELOAD_FROMURL = $08;
 
(* {F6F23F41-7686-11cf-8F52-0040333594A3} *)
TID_D3DRMFrameTransformMatrix: TGUID =
(D1:$f6f23f41;D2:$7686;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
type
PDXFileLoadResource = ^TDXFileLoadResource;
TDXFileLoadResource = record
hModule: HModule;
lpName: PChar;
lpType: PChar;
end;
 
(* {F6F23F42-7686-11cf-8F52-0040333594A3} *)
TID_D3DRMMeshMaterialList: TGUID =
(D1:$f6f23f42;D2:$7686;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
DXFILELOADRESOURCE = TDXFileLoadResource;
LPDXFILELOADRESOURCE = PDXFileLoadResource;
 
(* {F6F23F40-7686-11cf-8F52-0040333594A3} *)
TID_D3DRMMeshTextureCoords: TGUID =
(D1:$f6f23f40;D2:$7686;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
PDXFileLoadMemory = ^TDXFileLoadMemory;
TDXFileLoadMemory = record
lpMemory: Pointer;
dSize: DWORD;
end;
 
(* {F6F23F43-7686-11cf-8F52-0040333594A3} *)
TID_D3DRMMeshNormals: TGUID =
(D1:$f6f23f43;D2:$7686;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
DXFILELOADMEMORY = TDXFileLoadMemory;
LPDXFILELOADMEMORY = PDXFileLoadMemory;
 
(* {F6F23F44-7686-11cf-8F52-0040333594A3} *)
TID_D3DRMCoords2d: TGUID =
(D1:$f6f23f44;D2:$7686;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
{ DirectX File object types. }
 
(* {F6F23F45-7686-11cf-8F52-0040333594A3} *)
TID_D3DRMMatrix4x4: TGUID =
(D1:$f6f23f45;D2:$7686;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
type
IDirectXFile = interface;
IDirectXFileEnumObject = interface;
IDirectXFileSaveObject = interface;
IDirectXFileObject = interface;
IDirectXFileData = interface;
IDirectXFileDataReference = interface;
IDirectXFileBinary = interface;
 
(* {3D82AB4F-62DA-11cf-AB39-0020AF71E433} *)
TID_D3DRMAnimation: TGUID =
(D1:$3d82ab4f;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
IDirectXFile = interface(IUnknown)
['{3D82AB40-62DA-11CF-AB39-0020AF71E433}']
function CreateEnumObject(pvSource: Pointer; dwLoadOptions: TDXFileLoadOptions;
out ppEnumObj: IDirectXFileEnumObject): HResult; stdcall;
function CreateSaveObject(szFileName: PChar; dwFileFormat: TDXFileFormat;
out ppSaveObj: IDirectXFileSaveObject): HResult; stdcall;
function RegisterTemplates(pvData: Pointer; cbSize: DWORD): HResult; stdcall;
end;
 
(* {3D82AB50-62DA-11cf-AB39-0020AF71E433} *)
TID_D3DRMAnimationSet: TGUID =
(D1:$3d82ab50;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
IDirectXFileEnumObject = interface(IUnknown)
['{3D82AB41-62DA-11CF-AB39-0020AF71E433}']
function GetNextDataObject(out ppDataObj: IDirectXFileData): HResult; stdcall;
function GetDataObjectById(const rguid: TGUID; out ppDataObj: IDirectXFileData): HResult; stdcall;
function GetDataObjectByName(szName: PChar; out ppDataObj: IDirectXFileData): HResult; stdcall;
end;
 
(* {10DD46A8-775B-11cf-8F52-0040333594A3} *)
TID_D3DRMAnimationKey: TGUID =
(D1:$10dd46a8;D2:$775b;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$A3));
IDirectXFileSaveObject = interface(IUnknown)
['{3D82AB42-62DA-11CF-AB39-0020AF71E433}']
function SaveTemplates(cTemplates: DWORD; var ppguidTemplates: PGUID): HResult; stdcall;
function CreateDataObject(const rguidTemplate: TGUID; szName: PChar;
const pguid: TGUID; cbSize: DWORD; pvData: Pointer;
out ppDataObj: IDirectXFileData): HResult; stdcall;
function SaveData(pDataObj: IDirectXFileData): HResult; stdcall;
end;
 
(* {10DD46A9-775B-11cf-8F52-0040333594A3} *)
TID_D3DRMFloatKeys: TGUID =
(D1:$10dd46a9;D2:$775b;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$A3));
IDirectXFileObject = interface(IUnknown)
['{3D82AB43-62DA-11CF-AB39-0020AF71E433}']
function GetName(pstrNameBuf: PChar; var dwBufLen: DWORD): HResult; stdcall;
function GetId (var pGuidBuf: TGUID): HResult; stdcall;
end;
 
(* {01411840-7786-11cf-8F52-0040333594A3} *)
TID_D3DRMMaterialAmbientColor: TGUID =
(D1:$01411840;D2:$7786;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$A3));
IDirectXFileData = interface(IDirectXFileObject)
['{3D82AB44-62DA-11CF-AB39-0020AF71E433}']
function GetData(szMember: PChar; var pcbSize: DWORD; var ppvData: Pointer): HResult; stdcall;
function GetType(var ppguid: PGUID): HResult; stdcall;
function GetNextObject(out ppChildObj: IDirectXFileObject): HResult; stdcall;
function AddDataObject(pDataObj: IDirectXFileData): HResult; stdcall;
function AddDataReference(szRef: PChar; pguidRef: PGUID): HResult; stdcall;
function AddBinaryObjec (szName: PChar; pguid: PGUID; szMimeType: PChar;
pvData: Pointer; cbSize: DWORD): HResult; stdcall;
end;
 
(* {01411841-7786-11cf-8F52-0040333594A3} *)
TID_D3DRMMaterialDiffuseColor: TGUID =
(D1:$01411841;D2:$7786;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$A3));
IDirectXFileDataReference = interface(IDirectXFileObject)
['{3D82AB45-62DA-11CF-AB39-0020AF71E433}']
function Resolve(out ppDataObj: IDirectXFileData): HResult; stdcall;
end;
 
(* {01411842-7786-11cf-8F52-0040333594A3} *)
TID_D3DRMMaterialSpecularColor: TGUID =
(D1:$01411842;D2:$7786;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$A3));
IDirectXFileBinary = interface(IDirectXFileObject)
['{3D82AB46-62DA-11CF-AB39-0020AF71E433}']
function GetSize(var pcbSize: DWORD): HResult; stdcall;
function GetMimeType(var pszMimeType: PChar): HResult; stdcall;
function Read(pvData: Pointer; cbSize: DWORD; var pcbRead: DWORD): HResult; stdcall;
end;
 
(* {D3E16E80-7835-11cf-8F52-0040333594A3} *)
TID_D3DRMMaterialEmissiveColor: TGUID =
(D1:$d3e16e80;D2:$7835;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
{ DirectX File Header template's GUID. }
 
(* {01411843-7786-11cf-8F52-0040333594A3} *)
TID_D3DRMMaterialPower: TGUID =
(D1:$01411843;D2:$7786;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$A3));
const
TID_DXFILEHeader: TGUID = '{3D82AB43-62DA-11CF-AB39-0020AF71E433}';
 
(* {35FF44E0-6C7C-11cf-8F52-0040333594A3} *)
TID_D3DRMColorRGBA: TGUID =
(D1:$35ff44e0;D2:$6c7c;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$A3));
{ DirectX File errors. }
 
(* {D3E16E81-7835-11cf-8F52-0040333594A3} *)
TID_D3DRMColorRGB: TGUID =
(D1:$d3e16e81;D2:$7835;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
const
DXFILE_OK = HResult(0);
 
(* {A42790E0-7810-11cf-8F52-0040333594A3} *)
TID_D3DRMGuid: TGUID =
(D1:$a42790e0;D2:$7810;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
DXFILEERR_BADOBJECT = HResult($88760000 + 850);
DXFILEERR_BADVALUE = HResult($88760000 + 851);
DXFILEERR_BADTYPE = HResult($88760000 + 852);
DXFILEERR_BADSTREAMHANDLE = HResult($88760000 + 853);
DXFILEERR_BADALLOC = HResult($88760000 + 854);
DXFILEERR_NOTFOUND = HResult($88760000 + 855);
DXFILEERR_NOTDONEYET = HResult($88760000 + 856);
DXFILEERR_FILENOTFOUND = HResult($88760000 + 857);
DXFILEERR_RESOURCENOTFOUND = HResult($88760000 + 858);
DXFILEERR_URLNOTFOUND = HResult($88760000 + 859);
DXFILEERR_BADRESOURCE = HResult($88760000 + 860);
DXFILEERR_BADFILETYPE = HResult($88760000 + 861);
DXFILEERR_BADFILEVERSION = HResult($88760000 + 862);
DXFILEERR_BADFILEFLOATSIZE = HResult($88760000 + 863);
DXFILEERR_BADFILECOMPRESSIONTYPE = HResult($88760000 + 864);
DXFILEERR_BADFILE = HResult($88760000 + 865);
DXFILEERR_PARSEERROR = HResult($88760000 + 866);
DXFILEERR_NOTEMPLATE = HResult($88760000 + 867);
DXFILEERR_BADARRAYSIZE = HResult($88760000 + 868);
DXFILEERR_BADDATAREFERENCE = HResult($88760000 + 869);
DXFILEERR_INTERNALERROR = HResult($88760000 + 870);
DXFILEERR_NOMOREOBJECTS = HResult($88760000 + 871);
DXFILEERR_BADINTRINSICS = HResult($88760000 + 872);
DXFILEERR_NOMORESTREAMHANDLES = HResult($88760000 + 873);
DXFILEERR_NOMOREDATA = HResult($88760000 + 874);
DXFILEERR_BADCACHEFILE = HResult($88760000 + 875);
DXFILEERR_NOINTERNET = HResult($88760000 + 876);
 
(* {A42790E1-7810-11cf-8F52-0040333594A3} *)
TID_D3DRMTextureFilename: TGUID =
(D1:$a42790e1;D2:$7810;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
{ API for creating IDirectXFile interface. }
 
(* {A42790E2-7810-11cf-8F52-0040333594A3} *)
TID_D3DRMTextureReference: TGUID =
(D1:$a42790e2;D2:$7810;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
function DirectXFileCreate(out lplpDirectXFile: IDirectXFile): HResult; stdcall;
 
(* {1630B820-7842-11cf-8F52-0040333594A3} *)
TID_D3DRMIndexedColor: TGUID =
(D1:$1630b820;D2:$7842;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
(***************************************************************************
*
* Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved.
*
* File: rmxfguid.h
*
* Content: Defines GUIDs of D3DRM's templates.
*
***************************************************************************)
 
(* {1630B821-7842-11cf-8F52-0040333594A3} *)
TID_D3DRMMeshVertexColors: TGUID =
(D1:$1630b821;D2:$7842;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
const
TID_D3DRMInfo: TGUID = '{2B957100-9E9A-11cf-AB39-0020AF71E433}';
TID_D3DRMMesh: TGUID = '{3D82AB44-62DA-11cf-AB39-0020AF71E433}';
TID_D3DRMVector: TGUID = '{3D82AB5E-62DA-11cf-AB39-0020AF71E433}';
TID_D3DRMMeshFace: TGUID = '{3D82AB5F-62DA-11cf-AB39-0020AF71E433}';
TID_D3DRMMaterial: TGUID = '{3D82AB4D-62DA-11cf-AB39-0020AF71E433}';
TID_D3DRMMaterialArray: TGUID = '{35FF44E1-6C7C-11cf-8F52-0040333594A3}';
TID_D3DRMFrame: TGUID = '{3D82AB46-62DA-11cf-AB39-0020AF71E433}';
TID_D3DRMFrameTransformMatrix: TGUID = '{F6F23F41-7686-11cf-8F52-0040333594A3}';
TID_D3DRMMeshMaterialList: TGUID = '{F6F23F42-7686-11cf-8F52-0040333594A3}';
TID_D3DRMMeshTextureCoords: TGUID = '{F6F23F40-7686-11cf-8F52-0040333594A3}';
TID_D3DRMMeshNormals: TGUID = '{F6F23F43-7686-11cf-8F52-0040333594A3}';
TID_D3DRMCoords2d: TGUID = '{F6F23F44-7686-11cf-8F52-0040333594A3}';
TID_D3DRMMatrix4x4: TGUID = '{F6F23F45-7686-11cf-8F52-0040333594A3}';
TID_D3DRMAnimation: TGUID = '{3D82AB4F-62DA-11cf-AB39-0020AF71E433}';
TID_D3DRMAnimationSet: TGUID = '{3D82AB50-62DA-11cf-AB39-0020AF71E433}';
TID_D3DRMAnimationKey: TGUID = '{10DD46A8-775B-11cf-8F52-0040333594A3}';
TID_D3DRMFloatKeys: TGUID = '{10DD46A9-775B-11cf-8F52-0040333594A3}';
TID_D3DRMMaterialAmbientColor: TGUID = '{01411840-7786-11cf-8F52-0040333594A3}';
TID_D3DRMMaterialDiffuseColor: TGUID = '{01411841-7786-11cf-8F52-0040333594A3}';
TID_D3DRMMaterialSpecularColor: TGUID = '{01411842-7786-11cf-8F52-0040333594A3}';
TID_D3DRMMaterialEmissiveColor: TGUID = '{D3E16E80-7835-11cf-8F52-0040333594A3}';
TID_D3DRMMaterialPower: TGUID = '{01411843-7786-11cf-8F52-0040333594A3}';
TID_D3DRMColorRGBA: TGUID = '{35FF44E0-6C7C-11cf-8F52-0040333594A3}';
TID_D3DRMColorRGB: TGUID = '{D3E16E81-7835-11cf-8F52-0040333594A3}';
TID_D3DRMGuid: TGUID = '{A42790E0-7810-11cf-8F52-0040333594A3}';
TID_D3DRMTextureFilename: TGUID = '{A42790E1-7810-11cf-8F52-0040333594A3}';
TID_D3DRMTextureReference: TGUID = '{A42790E2-7810-11cf-8F52-0040333594A3}';
TID_D3DRMIndexedColor: TGUID = '{1630B820-7842-11cf-8F52-0040333594A3}';
TID_D3DRMMeshVertexColors: TGUID = '{1630B821-7842-11cf-8F52-0040333594A3}';
TID_D3DRMMaterialWrap: TGUID = '{4885AE60-78E8-11cf-8F52-0040333594A3}';
TID_D3DRMBoolean: TGUID = '{537DA6A0-CA37-11d0-941C-0080C80CFA7B}';
TID_D3DRMMeshFaceWraps: TGUID = '{ED1EC5C0-C0A8-11d0-941C-0080C80CFA7B}';
TID_D3DRMBoolean2d: TGUID = '{4885AE63-78E8-11cf-8F52-0040333594A3}';
TID_D3DRMTimedFloatKeys: TGUID = '{F406B180-7B3B-11cf-8F52-0040333594A3}';
TID_D3DRMAnimationOptions: TGUID = '{E2BF56C0-840F-11cf-8F52-0040333594A3}';
TID_D3DRMFramePosition: TGUID = '{E2BF56C1-840F-11cf-8F52-0040333594A3}';
TID_D3DRMFrameVelocity: TGUID = '{E2BF56C2-840F-11cf-8F52-0040333594A3}';
TID_D3DRMFrameRotation: TGUID = '{E2BF56C3-840F-11cf-8F52-0040333594A3}';
TID_D3DRMLight: TGUID = '{3D82AB4A-62DA-11cf-AB39-0020AF71E433}';
TID_D3DRMCamera: TGUID = '{3D82AB51-62DA-11cf-AB39-0020AF71E433}';
TID_D3DRMAppData: TGUID = '{E5745280-B24F-11cf-9DD5-00AA00A71A2F}';
TID_D3DRMLightUmbra: TGUID = '{AED22740-B31F-11cf-9DD5-00AA00A71A2F}';
TID_D3DRMLightRange: TGUID = '{AED22742-B31F-11cf-9DD5-00AA00A71A2F}';
TID_D3DRMLightPenumbra: TGUID = '{AED22741-B31F-11cf-9DD5-00AA00A71A2F}';
TID_D3DRMLightAttenuation: TGUID = '{A8A98BA0-C5E5-11cf-B941-0080C80CFA7B}';
TID_D3DRMInlineData: TGUID = '{3A23EEA0-94B1-11d0-AB39-0020AF71E433}';
TID_D3DRMUrl: TGUID = '{3A23EEA1-94B1-11d0-AB39-0020AF71E433}';
 
(* {4885AE60-78E8-11cf-8F52-0040333594A3} *)
TID_D3DRMMaterialWrap: TGUID =
(D1:$4885ae60;D2:$78e8;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
TID_D3DRMProgressiveMesh: TGUID = '{8A63C360-997D-11d0-941C-0080C80CFA7B}';
TID_D3DRMExternalVisual: TGUID = '{98116AA0-BDBA-11d1-82C0-00A0C9697271}';
TID_D3DRMStringProperty: TGUID = '{7F0F21E0-BFE1-11d1-82C0-00A0C9697271}';
TID_D3DRMPropertyBag: TGUID = '{7F0F21E1-BFE1-11d1-82C0-00A0C9697271}';
TID_D3DRMRightHanded: TGUID = '{7F5D5EA0-D53A-11d1-82C0-00A0C9697271}';
 
(* {537DA6A0-CA37-11d0-941C-0080C80CFA7B} *)
TID_D3DRMBoolean: TGUID =
(D1:$537da6a0;D2:$ca37;D3:$11d0;D4:($94,$1c,$00,$80,$c8,$0c,$fa,$7b));
 
(* {ED1EC5C0-C0A8-11d0-941C-0080C80CFA7B} *)
TID_D3DRMMeshFaceWraps: TGUID =
(D1:$ed1ec5c0;D2:$c0a8;D3:$11d0;D4:($94,$1c,$00,$80,$c8,$0c,$fa,$7b));
 
(* {4885AE63-78E8-11cf-8F52-0040333594A3} *)
TID_D3DRMBoolean2d: TGUID =
(D1:$4885ae63;D2:$78e8;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
 
(* {F406B180-7B3B-11cf-8F52-0040333594A3} *)
TID_D3DRMTimedFloatKeys: TGUID =
(D1:$f406b180;D2:$7b3b;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
 
(* {E2BF56C0-840F-11cf-8F52-0040333594A3} *)
TID_D3DRMAnimationOptions: TGUID =
(D1:$e2bf56c0;D2:$840f;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
 
(* {E2BF56C1-840F-11cf-8F52-0040333594A3} *)
TID_D3DRMFramePosition: TGUID =
(D1:$e2bf56c1;D2:$840f;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
 
(* {E2BF56C2-840F-11cf-8F52-0040333594A3} *)
TID_D3DRMFrameVelocity: TGUID =
(D1:$e2bf56c2;D2:$840f;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
 
(* {E2BF56C3-840F-11cf-8F52-0040333594A3} *)
TID_D3DRMFrameRotation: TGUID =
(D1:$e2bf56c3;D2:$840f;D3:$11cf;D4:($8f,$52,$00,$40,$33,$35,$94,$a3));
 
(* {3D82AB4A-62DA-11cf-AB39-0020AF71E433} *)
TID_D3DRMLight: TGUID =
(D1:$3d82ab4a;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
 
(* {3D82AB51-62DA-11cf-AB39-0020AF71E433} *)
TID_D3DRMCamera: TGUID =
(D1:$3d82ab51;D2:$62da;D3:$11cf;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
 
(* {E5745280-B24F-11cf-9DD5-00AA00A71A2F} *)
TID_D3DRMAppData: TGUID =
(D1:$e5745280;D2:$b24f;D3:$11cf;D4:($9d,$d5,$00,$aa,$00,$a7,$1a,$2f));
 
(* {AED22740-B31F-11cf-9DD5-00AA00A71A2F} *)
TID_D3DRMLightUmbra: TGUID =
(D1:$aed22740;D2:$b31f;D3:$11cf;D4:($9d,$d5,$00,$aa,$00,$a7,$1a,$2f));
 
(* {AED22742-B31F-11cf-9DD5-00AA00A71A2F} *)
TID_D3DRMLightRange: TGUID =
(D1:$aed22742;D2:$b31f;D3:$11cf;D4:($9d,$d5,$00,$aa,$00,$a7,$1a,$2f));
 
(* {AED22741-B31F-11cf-9DD5-00AA00A71A2F} *)
TID_D3DRMLightPenumbra: TGUID =
(D1:$aed22741;D2:$b31f;D3:$11cf;D4:($9d,$d5,$00,$aa,$00,$a7,$1a,$2f));
 
(* {A8A98BA0-C5E5-11cf-B941-0080C80CFA7B} *)
TID_D3DRMLightAttenuation: TGUID =
(D1:$a8a98ba0;D2:$c5e5;D3:$11cf;D4:($b9,$41,$00,$80,$c8,$0c,$fa,$7b));
 
(* {3A23EEA0-94B1-11d0-AB39-0020AF71E433} *)
TID_D3DRMInlineData: TGUID =
(D1:$3a23eea0;D2:$94b1;D3:$11d0;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
 
(* {3A23EEA1-94B1-11d0-AB39-0020AF71E433} *)
TID_D3DRMUrl: TGUID =
(D1:$3a23eea1;D2:$94b1;D3:$11d0;D4:($ab,$39,$00,$20,$af,$71,$e4,$33));
 
(* {8A63C360-997D-11d0-941C-0080C80CFA7B} *)
TID_D3DRMProgressiveMesh: TGUID =
(D1:$8A63C360;D2:$997D;D3:$11d0;D4:($94,$1C,$00,$80,$C8,$0C,$FA,$7B));
 
(* {98116AA0-BDBA-11d1-82C0-00A0C9697271} *)
TID_D3DRMExternalVisual: TGUID =
(D1:$98116AA0;D2:$BDBA;D3:$11d1;D4:($82,$C0,$00,$A0,$C9,$69,$72,$71));
 
(* {7F0F21E0-BFE1-11d1-82C0-00A0C9697271} *)
TID_D3DRMStringProperty: TGUID =
(D1:$7f0f21e0;D2:$bfe1;D3:$11d1;D4:($82,$c0,$00,$a0,$c9,$69,$72,$71));
 
(* {7F0F21E1-BFE1-11d1-82C0-00A0C9697271} *)
TID_D3DRMPropertyBag: TGUID =
(D1:$7f0f21e1;D2:$bfe1;D3:$11d1;D4:($82,$c0,$00,$a0,$c9,$69,$72,$71));
 
// {7F5D5EA0-D53A-11d1-82C0-00A0C9697271}
TID_D3DRMRightHanded: TGUID =
(D1:$7f5d5ea0;D2:$d53a;D3:$11d1;D4:($82,$c0,$00,$a0,$c9,$69,$72,$71));
 
(*==========================================================================;
(***************************************************************************
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
* Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved.
*
* File: rmxftmpl.h
* Content: D3DRM XFile templates in binary form
*
* Content: D3DRM XFile templates in binary form.
*
***************************************************************************)
 
const
D3DRM_XTEMPLATE_BYTES_2 = 3278;
D3DRM_XTEMPLATES: array [0..3214] of byte = (
$78, $6f, $66, $20, $30, $33, $30, $32, $62,
$69, $6e, $20, $30, $30, $36, $34, $1f, 0, $1,
0, $6, 0, 0, 0, $48, $65, $61, $64, $65,
$72, $a, 0, $5, 0, $43, $ab, $82, $3d, $da,
$62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4,
$33, $28, 0, $1, 0, $5, 0, 0, 0, $6d,
$61, $6a, $6f, $72, $14, 0, $28, 0, $1, 0,
$5, 0, 0, 0, $6d, $69, $6e, $6f, $72, $14,
0, $29, 0, $1, 0, $5, 0, 0, 0, $66,
$6c, $61, $67, $73, $14, 0, $b, 0, $1f, 0,
$1, 0, $6, 0, 0, 0, $56, $65, $63, $74,
$6f, $72, $a, 0, $5, 0, $5e, $ab, $82, $3d,
$da, $62, $cf, $11, $ab, $39, 0, $20, $af, $71,
$e4, $33, $2a, 0, $1, 0, $1, 0, 0, 0,
$78, $14, 0, $2a, 0, $1, 0, $1, 0, 0,
0, $79, $14, 0, $2a, 0, $1, 0, $1, 0,
0, 0, $7a, $14, 0, $b, 0, $1f, 0, $1,
0, $8, 0, 0, 0, $43, $6f, $6f, $72, $64,
$73, $32, $64, $a, 0, $5, 0, $44, $3f, $f2,
$f6, $86, $76, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $2a, 0, $1, 0, $1, 0, 0,
0, $75, $14, 0, $2a, 0, $1, 0, $1, 0,
0, 0, $76, $14, 0, $b, 0, $1f, 0, $1,
0, $9, 0, 0, 0, $4d, $61, $74, $72, $69,
$78, $34, $78, $34, $a, 0, $5, 0, $45, $3f,
$f2, $f6, $86, $76, $cf, $11, $8f, $52, 0, $40,
$33, $35, $94, $a3, $34, 0, $2a, 0, $1, 0,
$6, 0, 0, 0, $6d, $61, $74, $72, $69, $78,
$e, 0, $3, 0, $10, 0, 0, 0, $f, 0,
$14, 0, $b, 0, $1f, 0, $1, 0, $9, 0,
0, 0, $43, $6f, $6c, $6f, $72, $52, $47, $42,
$41, $a, 0, $5, 0, $e0, $44, $ff, $35, $7c,
$6c, $cf, $11, $8f, $52, 0, $40, $33, $35, $94,
$a3, $2a, 0, $1, 0, $3, 0, 0, 0, $72,
$65, $64, $14, 0, $2a, 0, $1, 0, $5, 0,
0, 0, $67, $72, $65, $65, $6e, $14, 0, $2a,
0, $1, 0, $4, 0, 0, 0, $62, $6c, $75,
$65, $14, 0, $2a, 0, $1, 0, $5, 0, 0,
0, $61, $6c, $70, $68, $61, $14, 0, $b, 0,
$1f, 0, $1, 0, $8, 0, 0, 0, $43, $6f,
$6c, $6f, $72, $52, $47, $42, $a, 0, $5, 0,
$81, $6e, $e1, $d3, $35, $78, $cf, $11, $8f, $52,
0, $40, $33, $35, $94, $a3, $2a, 0, $1, 0,
$3, 0, 0, 0, $72, $65, $64, $14, 0, $2a,
0, $1, 0, $5, 0, 0, 0, $67, $72, $65,
$65, $6e, $14, 0, $2a, 0, $1, 0, $4, 0,
0, 0, $62, $6c, $75, $65, $14, 0, $b, 0,
$1f, 0, $1, 0, $c, 0, 0, 0, $49, $6e,
$64, $65, $78, $65, $64, $43, $6f, $6c, $6f, $72,
$a, 0, $5, 0, $20, $b8, $30, $16, $42, $78,
$cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3,
$29, 0, $1, 0, $5, 0, 0, 0, $69, $6e,
$64, $65, $78, $14, 0, $1, 0, $9, 0, 0,
0, $43, $6f, $6c, $6f, $72, $52, $47, $42, $41,
$1, 0, $a, 0, 0, 0, $69, $6e, $64, $65,
$78, $43, $6f, $6c, $6f, $72, $14, 0, $b, 0,
$1f, 0, $1, 0, $7, 0, 0, 0, $42, $6f,
$6f, $6c, $65, $61, $6e, $a, 0, $5, 0, $a0,
$a6, $7d, $53, $37, $ca, $d0, $11, $94, $1c, 0,
$80, $c8, $c, $fa, $7b, $29, 0, $1, 0, $9,
0, 0, 0, $74, $72, $75, $65, $66, $61, $6c,
$73, $65, $14, 0, $b, 0, $1f, 0, $1, 0,
$9, 0, 0, 0, $42, $6f, $6f, $6c, $65, $61,
$6e, $32, $64, $a, 0, $5, 0, $63, $ae, $85,
$48, $e8, $78, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $1, 0, $7, 0, 0, 0, $42,
$6f, $6f, $6c, $65, $61, $6e, $1, 0, $1, 0,
0, 0, $75, $14, 0, $1, 0, $7, 0, 0,
0, $42, $6f, $6f, $6c, $65, $61, $6e, $1, 0,
$1, 0, 0, 0, $76, $14, 0, $b, 0, $1f,
0, $1, 0, $c, 0, 0, 0, $4d, $61, $74,
$65, $72, $69, $61, $6c, $57, $72, $61, $70, $a,
0, $5, 0, $60, $ae, $85, $48, $e8, $78, $cf,
$11, $8f, $52, 0, $40, $33, $35, $94, $a3, $1,
0, $7, 0, 0, 0, $42, $6f, $6f, $6c, $65,
$61, $6e, $1, 0, $1, 0, 0, 0, $75, $14,
0, $1, 0, $7, 0, 0, 0, $42, $6f, $6f,
$6c, $65, $61, $6e, $1, 0, $1, 0, 0, 0,
$76, $14, 0, $b, 0, $1f, 0, $1, 0, $f,
0, 0, 0, $54, $65, $78, $74, $75, $72, $65,
$46, $69, $6c, $65, $6e, $61, $6d, $65, $a, 0,
$5, 0, $e1, $90, $27, $a4, $10, $78, $cf, $11,
$8f, $52, 0, $40, $33, $35, $94, $a3, $31, 0,
$1, 0, $8, 0, 0, 0, $66, $69, $6c, $65,
$6e, $61, $6d, $65, $14, 0, $b, 0, $1f, 0,
$1, 0, $8, 0, 0, 0, $4d, $61, $74, $65,
$72, $69, $61, $6c, $a, 0, $5, 0, $4d, $ab,
$82, $3d, $da, $62, $cf, $11, $ab, $39, 0, $20,
$af, $71, $e4, $33, $1, 0, $9, 0, 0, 0,
$43, $6f, $6c, $6f, $72, $52, $47, $42, $41, $1,
0, $9, 0, 0, 0, $66, $61, $63, $65, $43,
$6f, $6c, $6f, $72, $14, 0, $2a, 0, $1, 0,
$5, 0, 0, 0, $70, $6f, $77, $65, $72, $14,
0, $1, 0, $8, 0, 0, 0, $43, $6f, $6c,
$6f, $72, $52, $47, $42, $1, 0, $d, 0, 0,
0, $73, $70, $65, $63, $75, $6c, $61, $72, $43,
$6f, $6c, $6f, $72, $14, 0, $1, 0, $8, 0,
0, 0, $43, $6f, $6c, $6f, $72, $52, $47, $42,
$1, 0, $d, 0, 0, 0, $65, $6d, $69, $73,
$73, $69, $76, $65, $43, $6f, $6c, $6f, $72, $14,
0, $e, 0, $12, 0, $12, 0, $12, 0, $f,
0, $b, 0, $1f, 0, $1, 0, $8, 0, 0,
0, $4d, $65, $73, $68, $46, $61, $63, $65, $a,
0, $5, 0, $5f, $ab, $82, $3d, $da, $62, $cf,
$11, $ab, $39, 0, $20, $af, $71, $e4, $33, $29,
0, $1, 0, $12, 0, 0, 0, $6e, $46, $61,
$63, $65, $56, $65, $72, $74, $65, $78, $49, $6e,
$64, $69, $63, $65, $73, $14, 0, $34, 0, $29,
0, $1, 0, $11, 0, 0, 0, $66, $61, $63,
$65, $56, $65, $72, $74, $65, $78, $49, $6e, $64,
$69, $63, $65, $73, $e, 0, $1, 0, $12, 0,
0, 0, $6e, $46, $61, $63, $65, $56, $65, $72,
$74, $65, $78, $49, $6e, $64, $69, $63, $65, $73,
$f, 0, $14, 0, $b, 0, $1f, 0, $1, 0,
$d, 0, 0, 0, $4d, $65, $73, $68, $46, $61,
$63, $65, $57, $72, $61, $70, $73, $a, 0, $5,
0, $c0, $c5, $1e, $ed, $a8, $c0, $d0, $11, $94,
$1c, 0, $80, $c8, $c, $fa, $7b, $29, 0, $1,
0, $f, 0, 0, 0, $6e, $46, $61, $63, $65,
$57, $72, $61, $70, $56, $61, $6c, $75, $65, $73,
$14, 0, $34, 0, $1, 0, $9, 0, 0, 0,
$42, $6f, $6f, $6c, $65, $61, $6e, $32, $64, $1,
0, $e, 0, 0, 0, $66, $61, $63, $65, $57,
$72, $61, $70, $56, $61, $6c, $75, $65, $73, $e,
0, $1, 0, $f, 0, 0, 0, $6e, $46, $61,
$63, $65, $57, $72, $61, $70, $56, $61, $6c, $75,
$65, $73, $f, 0, $14, 0, $b, 0, $1f, 0,
$1, 0, $11, 0, 0, 0, $4d, $65, $73, $68,
$54, $65, $78, $74, $75, $72, $65, $43, $6f, $6f,
$72, $64, $73, $a, 0, $5, 0, $40, $3f, $f2,
$f6, $86, $76, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $29, 0, $1, 0, $e, 0, 0,
0, $6e, $54, $65, $78, $74, $75, $72, $65, $43,
$6f, $6f, $72, $64, $73, $14, 0, $34, 0, $1,
0, $8, 0, 0, 0, $43, $6f, $6f, $72, $64,
$73, $32, $64, $1, 0, $d, 0, 0, 0, $74,
$65, $78, $74, $75, $72, $65, $43, $6f, $6f, $72,
$64, $73, $e, 0, $1, 0, $e, 0, 0, 0,
$6e, $54, $65, $78, $74, $75, $72, $65, $43, $6f,
$6f, $72, $64, $73, $f, 0, $14, 0, $b, 0,
$1f, 0, $1, 0, $10, 0, 0, 0, $4d, $65,
$73, $68, $4d, $61, $74, $65, $72, $69, $61, $6c,
$4c, $69, $73, $74, $a, 0, $5, 0, $42, $3f,
$f2, $f6, $86, $76, $cf, $11, $8f, $52, 0, $40,
$33, $35, $94, $a3, $29, 0, $1, 0, $a, 0,
0, 0, $6e, $4d, $61, $74, $65, $72, $69, $61,
$6c, $73, $14, 0, $29, 0, $1, 0, $c, 0,
0, 0, $6e, $46, $61, $63, $65, $49, $6e, $64,
$65, $78, $65, $73, $14, 0, $34, 0, $29, 0,
$1, 0, $b, 0, 0, 0, $66, $61, $63, $65,
$49, $6e, $64, $65, $78, $65, $73, $e, 0, $1,
0, $c, 0, 0, 0, $6e, $46, $61, $63, $65,
$49, $6e, $64, $65, $78, $65, $73, $f, 0, $14,
0, $e, 0, $1, 0, $8, 0, 0, 0, $4d,
$61, $74, $65, $72, $69, $61, $6c, $f, 0, $b,
0, $1f, 0, $1, 0, $b, 0, 0, 0, $4d,
$65, $73, $68, $4e, $6f, $72, $6d, $61, $6c, $73,
$a, 0, $5, 0, $43, $3f, $f2, $f6, $86, $76,
$cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3,
$29, 0, $1, 0, $8, 0, 0, 0, $6e, $4e,
$6f, $72, $6d, $61, $6c, $73, $14, 0, $34, 0,
$1, 0, $6, 0, 0, 0, $56, $65, $63, $74,
$6f, $72, $1, 0, $7, 0, 0, 0, $6e, $6f,
$72, $6d, $61, $6c, $73, $e, 0, $1, 0, $8,
0, 0, 0, $6e, $4e, $6f, $72, $6d, $61, $6c,
$73, $f, 0, $14, 0, $29, 0, $1, 0, $c,
0, 0, 0, $6e, $46, $61, $63, $65, $4e, $6f,
$72, $6d, $61, $6c, $73, $14, 0, $34, 0, $1,
0, $8, 0, 0, 0, $4d, $65, $73, $68, $46,
$61, $63, $65, $1, 0, $b, 0, 0, 0, $66,
$61, $63, $65, $4e, $6f, $72, $6d, $61, $6c, $73,
$e, 0, $1, 0, $c, 0, 0, 0, $6e, $46,
$61, $63, $65, $4e, $6f, $72, $6d, $61, $6c, $73,
$f, 0, $14, 0, $b, 0, $1f, 0, $1, 0,
$10, 0, 0, 0, $4d, $65, $73, $68, $56, $65,
$72, $74, $65, $78, $43, $6f, $6c, $6f, $72, $73,
$a, 0, $5, 0, $21, $b8, $30, $16, $42, $78,
$cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3,
$29, 0, $1, 0, $d, 0, 0, 0, $6e, $56,
$65, $72, $74, $65, $78, $43, $6f, $6c, $6f, $72,
$73, $14, 0, $34, 0, $1, 0, $c, 0, 0,
0, $49, $6e, $64, $65, $78, $65, $64, $43, $6f,
$6c, $6f, $72, $1, 0, $c, 0, 0, 0, $76,
$65, $72, $74, $65, $78, $43, $6f, $6c, $6f, $72,
$73, $e, 0, $1, 0, $d, 0, 0, 0, $6e,
$56, $65, $72, $74, $65, $78, $43, $6f, $6c, $6f,
$72, $73, $f, 0, $14, 0, $b, 0, $1f, 0,
$1, 0, $4, 0, 0, 0, $4d, $65, $73, $68,
$a, 0, $5, 0, $44, $ab, $82, $3d, $da, $62,
$cf, $11, $ab, $39, 0, $20, $af, $71, $e4, $33,
$29, 0, $1, 0, $9, 0, 0, 0, $6e, $56,
$65, $72, $74, $69, $63, $65, $73, $14, 0, $34,
0, $1, 0, $6, 0, 0, 0, $56, $65, $63,
$74, $6f, $72, $1, 0, $8, 0, 0, 0, $76,
$65, $72, $74, $69, $63, $65, $73, $e, 0, $1,
0, $9, 0, 0, 0, $6e, $56, $65, $72, $74,
$69, $63, $65, $73, $f, 0, $14, 0, $29, 0,
$1, 0, $6, 0, 0, 0, $6e, $46, $61, $63,
$65, $73, $14, 0, $34, 0, $1, 0, $8, 0,
0, 0, $4d, $65, $73, $68, $46, $61, $63, $65,
$1, 0, $5, 0, 0, 0, $66, $61, $63, $65,
$73, $e, 0, $1, 0, $6, 0, 0, 0, $6e,
$46, $61, $63, $65, $73, $f, 0, $14, 0, $e,
0, $12, 0, $12, 0, $12, 0, $f, 0, $b,
0, $1f, 0, $1, 0, $14, 0, 0, 0, $46,
$72, $61, $6d, $65, $54, $72, $61, $6e, $73, $66,
$6f, $72, $6d, $4d, $61, $74, $72, $69, $78, $a,
0, $5, 0, $41, $3f, $f2, $f6, $86, $76, $cf,
$11, $8f, $52, 0, $40, $33, $35, $94, $a3, $1,
0, $9, 0, 0, 0, $4d, $61, $74, $72, $69,
$78, $34, $78, $34, $1, 0, $b, 0, 0, 0,
$66, $72, $61, $6d, $65, $4d, $61, $74, $72, $69,
$78, $14, 0, $b, 0, $1f, 0, $1, 0, $5,
0, 0, 0, $46, $72, $61, $6d, $65, $a, 0,
$5, 0, $46, $ab, $82, $3d, $da, $62, $cf, $11,
$ab, $39, 0, $20, $af, $71, $e4, $33, $e, 0,
$12, 0, $12, 0, $12, 0, $f, 0, $b, 0,
$1f, 0, $1, 0, $9, 0, 0, 0, $46, $6c,
$6f, $61, $74, $4b, $65, $79, $73, $a, 0, $5,
0, $a9, $46, $dd, $10, $5b, $77, $cf, $11, $8f,
$52, 0, $40, $33, $35, $94, $a3, $29, 0, $1,
0, $7, 0, 0, 0, $6e, $56, $61, $6c, $75,
$65, $73, $14, 0, $34, 0, $2a, 0, $1, 0,
$6, 0, 0, 0, $76, $61, $6c, $75, $65, $73,
$e, 0, $1, 0, $7, 0, 0, 0, $6e, $56,
$61, $6c, $75, $65, $73, $f, 0, $14, 0, $b,
0, $1f, 0, $1, 0, $e, 0, 0, 0, $54,
$69, $6d, $65, $64, $46, $6c, $6f, $61, $74, $4b,
$65, $79, $73, $a, 0, $5, 0, $80, $b1, $6,
$f4, $3b, $7b, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $29, 0, $1, 0, $4, 0, 0,
0, $74, $69, $6d, $65, $14, 0, $1, 0, $9,
0, 0, 0, $46, $6c, $6f, $61, $74, $4b, $65,
$79, $73, $1, 0, $6, 0, 0, 0, $74, $66,
$6b, $65, $79, $73, $14, 0, $b, 0, $1f, 0,
$1, 0, $c, 0, 0, 0, $41, $6e, $69, $6d,
$61, $74, $69, $6f, $6e, $4b, $65, $79, $a, 0,
$5, 0, $a8, $46, $dd, $10, $5b, $77, $cf, $11,
$8f, $52, 0, $40, $33, $35, $94, $a3, $29, 0,
$1, 0, $7, 0, 0, 0, $6b, $65, $79, $54,
$79, $70, $65, $14, 0, $29, 0, $1, 0, $5,
0, 0, 0, $6e, $4b, $65, $79, $73, $14, 0,
$34, 0, $1, 0, $e, 0, 0, 0, $54, $69,
$6d, $65, $64, $46, $6c, $6f, $61, $74, $4b, $65,
$79, $73, $1, 0, $4, 0, 0, 0, $6b, $65,
$79, $73, $e, 0, $1, 0, $5, 0, 0, 0,
$6e, $4b, $65, $79, $73, $f, 0, $14, 0, $b,
0, $1f, 0, $1, 0, $10, 0, 0, 0, $41,
$6e, $69, $6d, $61, $74, $69, $6f, $6e, $4f, $70,
$74, $69, $6f, $6e, $73, $a, 0, $5, 0, $c0,
$56, $bf, $e2, $f, $84, $cf, $11, $8f, $52, 0,
$40, $33, $35, $94, $a3, $29, 0, $1, 0, $a,
0, 0, 0, $6f, $70, $65, $6e, $63, $6c, $6f,
$73, $65, $64, $14, 0, $29, 0, $1, 0, $f,
0, 0, 0, $70, $6f, $73, $69, $74, $69, $6f,
$6e, $71, $75, $61, $6c, $69, $74, $79, $14, 0,
$b, 0, $1f, 0, $1, 0, $9, 0, 0, 0,
$41, $6e, $69, $6d, $61, $74, $69, $6f, $6e, $a,
0, $5, 0, $4f, $ab, $82, $3d, $da, $62, $cf,
$11, $ab, $39, 0, $20, $af, $71, $e4, $33, $e,
0, $12, 0, $12, 0, $12, 0, $f, 0, $b,
0, $1f, 0, $1, 0, $c, 0, 0, 0, $41,
$6e, $69, $6d, $61, $74, $69, $6f, $6e, $53, $65,
$74, $a, 0, $5, 0, $50, $ab, $82, $3d, $da,
$62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4,
$33, $e, 0, $1, 0, $9, 0, 0, 0, $41,
$6e, $69, $6d, $61, $74, $69, $6f, $6e, $f, 0,
$b, 0, $1f, 0, $1, 0, $a, 0, 0, 0,
$49, $6e, $6c, $69, $6e, $65, $44, $61, $74, $61,
$a, 0, $5, 0, $a0, $ee, $23, $3a, $b1, $94,
$d0, $11, $ab, $39, 0, $20, $af, $71, $e4, $33,
$e, 0, $1, 0, $6, 0, 0, 0, $42, $49,
$4e, $41, $52, $59, $f, 0, $b, 0, $1f, 0,
$1, 0, $3, 0, 0, 0, $55, $72, $6c, $a,
0, $5, 0, $a1, $ee, $23, $3a, $b1, $94, $d0,
$11, $ab, $39, 0, $20, $af, $71, $e4, $33, $29,
0, $1, 0, $5, 0, 0, 0, $6e, $55, $72,
$6c, $73, $14, 0, $34, 0, $31, 0, $1, 0,
$4, 0, 0, 0, $75, $72, $6c, $73, $e, 0,
$1, 0, $5, 0, 0, 0, $6e, $55, $72, $6c,
$73, $f, 0, $14, 0, $b, 0, $1f, 0, $1,
0, $f, 0, 0, 0, $50, $72, $6f, $67, $72,
$65, $73, $73, $69, $76, $65, $4d, $65, $73, $68,
$a, 0, $5, 0, $60, $c3, $63, $8a, $7d, $99,
$d0, $11, $94, $1c, 0, $80, $c8, $c, $fa, $7b,
$e, 0, $1, 0, $3, 0, 0, 0, $55, $72,
$6c, $13, 0, $1, 0, $a, 0, 0, 0, $49,
$6e, $6c, $69, $6e, $65, $44, $61, $74, $61, $f,
0, $b, 0, $1f, 0, $1, 0, $4, 0, 0,
0, $47, $75, $69, $64, $a, 0, $5, 0, $e0,
$90, $27, $a4, $10, $78, $cf, $11, $8f, $52, 0,
$40, $33, $35, $94, $a3, $29, 0, $1, 0, $5,
0, 0, 0, $64, $61, $74, $61, $31, $14, 0,
$28, 0, $1, 0, $5, 0, 0, 0, $64, $61,
$74, $61, $32, $14, 0, $28, 0, $1, 0, $5,
0, 0, 0, $64, $61, $74, $61, $33, $14, 0,
$34, 0, $2d, 0, $1, 0, $5, 0, 0, 0,
$64, $61, $74, $61, $34, $e, 0, $3, 0, $8,
0, 0, 0, $f, 0, $14, 0, $b, 0, $1f,
0, $1, 0, $e, 0, 0, 0, $53, $74, $72,
$69, $6e, $67, $50, $72, $6f, $70, $65, $72, $74,
$79, $a, 0, $5, 0, $e0, $21, $f, $7f, $e1,
$bf, $d1, $11, $82, $c0, 0, $a0, $c9, $69, $72,
$71, $31, 0, $1, 0, $3, 0, 0, 0, $6b,
$65, $79, $14, 0, $31, 0, $1, 0, $5, 0,
0, 0, $76, $61, $6c, $75, $65, $14, 0, $b,
0, $1f, 0, $1, 0, $b, 0, 0, 0, $50,
$72, $6f, $70, $65, $72, $74, $79, $42, $61, $67,
$a, 0, $5, 0, $e1, $21, $f, $7f, $e1, $bf,
$d1, $11, $82, $c0, 0, $a0, $c9, $69, $72, $71,
$e, 0, $1, 0, $e, 0, 0, 0, $53, $74,
$72, $69, $6e, $67, $50, $72, $6f, $70, $65, $72,
$74, $79, $f, 0, $b, 0, $1f, 0, $1, 0,
$e, 0, 0, 0, $45, $78, $74, $65, $72, $6e,
$61, $6c, $56, $69, $73, $75, $61, $6c, $a, 0,
$5, 0, $a0, $6a, $11, $98, $ba, $bd, $d1, $11,
$82, $c0, 0, $a0, $c9, $69, $72, $71, $1, 0,
$4, 0, 0, 0, $47, $75, $69, $64, $1, 0,
$12, 0, 0, 0, $67, $75, $69, $64, $45, $78,
$74, $65, $72, $6e, $61, $6c, $56, $69, $73, $75,
$61, $6c, $14, 0, $e, 0, $12, 0, $12, 0,
$12, 0, $f, 0, $b, 0);
 
D3DRM_XTEMPLATES_2: array [0..D3DRM_XTEMPLATE_BYTES_2-1] of byte = (
$78, $6f, $66, $20, $30, $33, $30, $32, $62, $69, $6e, $20, $30, $30, $36, $34, $1f, 0, $1,
0, $6, 0, 0, 0, $48, $65, $61, $64, $65, $72, $a, 0, $5, 0, $43, $ab, $82, $3d, $da,
$62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4, $33, $28, 0, $1, 0, $5, 0, 0, 0, $6d,
$61, $6a, $6f, $72, $14, 0, $28, 0, $1, 0, $5, 0, 0, 0, $6d, $69, $6e, $6f, $72, $14,
0, $29, 0, $1, 0, $5, 0, 0, 0, $66, $6c, $61, $67, $73, $14, 0, $b, 0, $1f, 0,
$1, 0, $6, 0, 0, 0, $56, $65, $63, $74, $6f, $72, $a, 0, $5, 0, $5e, $ab, $82, $3d,
$da, $62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4, $33, $2a, 0, $1, 0, $1, 0, 0, 0,
$78, $14, 0, $2a, 0, $1, 0, $1, 0, 0, 0, $79, $14, 0, $2a, 0, $1, 0, $1, 0,
0, 0, $7a, $14, 0, $b, 0, $1f, 0, $1, 0, $8, 0, 0, 0, $43, $6f, $6f, $72, $64,
$73, $32, $64, $a, 0, $5, 0, $44, $3f, $f2, $f6, $86, $76, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $2a, 0, $1, 0, $1, 0, 0, 0, $75, $14, 0, $2a, 0, $1, 0, $1, 0,
0, 0, $76, $14, 0, $b, 0, $1f, 0, $1, 0, $9, 0, 0, 0, $4d, $61, $74, $72, $69,
$78, $34, $78, $34, $a, 0, $5, 0, $45, $3f, $f2, $f6, $86, $76, $cf, $11, $8f, $52, 0, $40,
$33, $35, $94, $a3, $34, 0, $2a, 0, $1, 0, $6, 0, 0, 0, $6d, $61, $74, $72, $69, $78,
$e, 0, $3, 0, $10, 0, 0, 0, $f, 0, $14, 0, $b, 0, $1f, 0, $1, 0, $9, 0,
0, 0, $43, $6f, $6c, $6f, $72, $52, $47, $42, $41, $a, 0, $5, 0, $e0, $44, $ff, $35, $7c,
$6c, $cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3, $2a, 0, $1, 0, $3, 0, 0, 0, $72,
$65, $64, $14, 0, $2a, 0, $1, 0, $5, 0, 0, 0, $67, $72, $65, $65, $6e, $14, 0, $2a,
0, $1, 0, $4, 0, 0, 0, $62, $6c, $75, $65, $14, 0, $2a, 0, $1, 0, $5, 0, 0,
0, $61, $6c, $70, $68, $61, $14, 0, $b, 0, $1f, 0, $1, 0, $8, 0, 0, 0, $43, $6f,
$6c, $6f, $72, $52, $47, $42, $a, 0, $5, 0, $81, $6e, $e1, $d3, $35, $78, $cf, $11, $8f, $52,
0, $40, $33, $35, $94, $a3, $2a, 0, $1, 0, $3, 0, 0, 0, $72, $65, $64, $14, 0, $2a,
0, $1, 0, $5, 0, 0, 0, $67, $72, $65, $65, $6e, $14, 0, $2a, 0, $1, 0, $4, 0,
0, 0, $62, $6c, $75, $65, $14, 0, $b, 0, $1f, 0, $1, 0, $c, 0, 0, 0, $49, $6e,
$64, $65, $78, $65, $64, $43, $6f, $6c, $6f, $72, $a, 0, $5, 0, $20, $b8, $30, $16, $42, $78,
$cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3, $29, 0, $1, 0, $5, 0, 0, 0, $69, $6e,
$64, $65, $78, $14, 0, $1, 0, $9, 0, 0, 0, $43, $6f, $6c, $6f, $72, $52, $47, $42, $41,
$1, 0, $a, 0, 0, 0, $69, $6e, $64, $65, $78, $43, $6f, $6c, $6f, $72, $14, 0, $b, 0,
$1f, 0, $1, 0, $7, 0, 0, 0, $42, $6f, $6f, $6c, $65, $61, $6e, $a, 0, $5, 0, $a0,
$a6, $7d, $53, $37, $ca, $d0, $11, $94, $1c, 0, $80, $c8, $c, $fa, $7b, $29, 0, $1, 0, $9,
0, 0, 0, $74, $72, $75, $65, $66, $61, $6c, $73, $65, $14, 0, $b, 0, $1f, 0, $1, 0,
$9, 0, 0, 0, $42, $6f, $6f, $6c, $65, $61, $6e, $32, $64, $a, 0, $5, 0, $63, $ae, $85,
$48, $e8, $78, $cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3, $1, 0, $7, 0, 0, 0, $42,
$6f, $6f, $6c, $65, $61, $6e, $1, 0, $1, 0, 0, 0, $75, $14, 0, $1, 0, $7, 0, 0,
0, $42, $6f, $6f, $6c, $65, $61, $6e, $1, 0, $1, 0, 0, 0, $76, $14, 0, $b, 0, $1f,
0, $1, 0, $c, 0, 0, 0, $4d, $61, $74, $65, $72, $69, $61, $6c, $57, $72, $61, $70, $a,
0, $5, 0, $60, $ae, $85, $48, $e8, $78, $cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3, $1,
0, $7, 0, 0, 0, $42, $6f, $6f, $6c, $65, $61, $6e, $1, 0, $1, 0, 0, 0, $75, $14,
0, $1, 0, $7, 0, 0, 0, $42, $6f, $6f, $6c, $65, $61, $6e, $1, 0, $1, 0, 0, 0,
$76, $14, 0, $b, 0, $1f, 0, $1, 0, $f, 0, 0, 0, $54, $65, $78, $74, $75, $72, $65,
$46, $69, $6c, $65, $6e, $61, $6d, $65, $a, 0, $5, 0, $e1, $90, $27, $a4, $10, $78, $cf, $11,
$8f, $52, 0, $40, $33, $35, $94, $a3, $31, 0, $1, 0, $8, 0, 0, 0, $66, $69, $6c, $65,
$6e, $61, $6d, $65, $14, 0, $b, 0, $1f, 0, $1, 0, $8, 0, 0, 0, $4d, $61, $74, $65,
$72, $69, $61, $6c, $a, 0, $5, 0, $4d, $ab, $82, $3d, $da, $62, $cf, $11, $ab, $39, 0, $20,
$af, $71, $e4, $33, $1, 0, $9, 0, 0, 0, $43, $6f, $6c, $6f, $72, $52, $47, $42, $41, $1,
0, $9, 0, 0, 0, $66, $61, $63, $65, $43, $6f, $6c, $6f, $72, $14, 0, $2a, 0, $1, 0,
$5, 0, 0, 0, $70, $6f, $77, $65, $72, $14, 0, $1, 0, $8, 0, 0, 0, $43, $6f, $6c,
$6f, $72, $52, $47, $42, $1, 0, $d, 0, 0, 0, $73, $70, $65, $63, $75, $6c, $61, $72, $43,
$6f, $6c, $6f, $72, $14, 0, $1, 0, $8, 0, 0, 0, $43, $6f, $6c, $6f, $72, $52, $47, $42,
$1, 0, $d, 0, 0, 0, $65, $6d, $69, $73, $73, $69, $76, $65, $43, $6f, $6c, $6f, $72, $14,
0, $e, 0, $12, 0, $12, 0, $12, 0, $f, 0, $b, 0, $1f, 0, $1, 0, $8, 0, 0,
0, $4d, $65, $73, $68, $46, $61, $63, $65, $a, 0, $5, 0, $5f, $ab, $82, $3d, $da, $62, $cf,
$11, $ab, $39, 0, $20, $af, $71, $e4, $33, $29, 0, $1, 0, $12, 0, 0, 0, $6e, $46, $61,
$63, $65, $56, $65, $72, $74, $65, $78, $49, $6e, $64, $69, $63, $65, $73, $14, 0, $34, 0, $29,
0, $1, 0, $11, 0, 0, 0, $66, $61, $63, $65, $56, $65, $72, $74, $65, $78, $49, $6e, $64,
$69, $63, $65, $73, $e, 0, $1, 0, $12, 0, 0, 0, $6e, $46, $61, $63, $65, $56, $65, $72,
$74, $65, $78, $49, $6e, $64, $69, $63, $65, $73, $f, 0, $14, 0, $b, 0, $1f, 0, $1, 0,
$d, 0, 0, 0, $4d, $65, $73, $68, $46, $61, $63, $65, $57, $72, $61, $70, $73, $a, 0, $5,
0, $c0, $c5, $1e, $ed, $a8, $c0, $d0, $11, $94, $1c, 0, $80, $c8, $c, $fa, $7b, $29, 0, $1,
0, $f, 0, 0, 0, $6e, $46, $61, $63, $65, $57, $72, $61, $70, $56, $61, $6c, $75, $65, $73,
$14, 0, $34, 0, $1, 0, $9, 0, 0, 0, $42, $6f, $6f, $6c, $65, $61, $6e, $32, $64, $1,
0, $e, 0, 0, 0, $66, $61, $63, $65, $57, $72, $61, $70, $56, $61, $6c, $75, $65, $73, $e,
0, $1, 0, $f, 0, 0, 0, $6e, $46, $61, $63, $65, $57, $72, $61, $70, $56, $61, $6c, $75,
$65, $73, $f, 0, $14, 0, $b, 0, $1f, 0, $1, 0, $11, 0, 0, 0, $4d, $65, $73, $68,
$54, $65, $78, $74, $75, $72, $65, $43, $6f, $6f, $72, $64, $73, $a, 0, $5, 0, $40, $3f, $f2,
$f6, $86, $76, $cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3, $29, 0, $1, 0, $e, 0, 0,
0, $6e, $54, $65, $78, $74, $75, $72, $65, $43, $6f, $6f, $72, $64, $73, $14, 0, $34, 0, $1,
0, $8, 0, 0, 0, $43, $6f, $6f, $72, $64, $73, $32, $64, $1, 0, $d, 0, 0, 0, $74,
$65, $78, $74, $75, $72, $65, $43, $6f, $6f, $72, $64, $73, $e, 0, $1, 0, $e, 0, 0, 0,
$6e, $54, $65, $78, $74, $75, $72, $65, $43, $6f, $6f, $72, $64, $73, $f, 0, $14, 0, $b, 0,
$1f, 0, $1, 0, $10, 0, 0, 0, $4d, $65, $73, $68, $4d, $61, $74, $65, $72, $69, $61, $6c,
$4c, $69, $73, $74, $a, 0, $5, 0, $42, $3f, $f2, $f6, $86, $76, $cf, $11, $8f, $52, 0, $40,
$33, $35, $94, $a3, $29, 0, $1, 0, $a, 0, 0, 0, $6e, $4d, $61, $74, $65, $72, $69, $61,
$6c, $73, $14, 0, $29, 0, $1, 0, $c, 0, 0, 0, $6e, $46, $61, $63, $65, $49, $6e, $64,
$65, $78, $65, $73, $14, 0, $34, 0, $29, 0, $1, 0, $b, 0, 0, 0, $66, $61, $63, $65,
$49, $6e, $64, $65, $78, $65, $73, $e, 0, $1, 0, $c, 0, 0, 0, $6e, $46, $61, $63, $65,
$49, $6e, $64, $65, $78, $65, $73, $f, 0, $14, 0, $e, 0, $1, 0, $8, 0, 0, 0, $4d,
$61, $74, $65, $72, $69, $61, $6c, $f, 0, $b, 0, $1f, 0, $1, 0, $b, 0, 0, 0, $4d,
$65, $73, $68, $4e, $6f, $72, $6d, $61, $6c, $73, $a, 0, $5, 0, $43, $3f, $f2, $f6, $86, $76,
$cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3, $29, 0, $1, 0, $8, 0, 0, 0, $6e, $4e,
$6f, $72, $6d, $61, $6c, $73, $14, 0, $34, 0, $1, 0, $6, 0, 0, 0, $56, $65, $63, $74,
$6f, $72, $1, 0, $7, 0, 0, 0, $6e, $6f, $72, $6d, $61, $6c, $73, $e, 0, $1, 0, $8,
0, 0, 0, $6e, $4e, $6f, $72, $6d, $61, $6c, $73, $f, 0, $14, 0, $29, 0, $1, 0, $c,
0, 0, 0, $6e, $46, $61, $63, $65, $4e, $6f, $72, $6d, $61, $6c, $73, $14, 0, $34, 0, $1,
0, $8, 0, 0, 0, $4d, $65, $73, $68, $46, $61, $63, $65, $1, 0, $b, 0, 0, 0, $66,
$61, $63, $65, $4e, $6f, $72, $6d, $61, $6c, $73, $e, 0, $1, 0, $c, 0, 0, 0, $6e, $46,
$61, $63, $65, $4e, $6f, $72, $6d, $61, $6c, $73, $f, 0, $14, 0, $b, 0, $1f, 0, $1, 0,
$10, 0, 0, 0, $4d, $65, $73, $68, $56, $65, $72, $74, $65, $78, $43, $6f, $6c, $6f, $72, $73,
$a, 0, $5, 0, $21, $b8, $30, $16, $42, $78, $cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3,
$29, 0, $1, 0, $d, 0, 0, 0, $6e, $56, $65, $72, $74, $65, $78, $43, $6f, $6c, $6f, $72,
$73, $14, 0, $34, 0, $1, 0, $c, 0, 0, 0, $49, $6e, $64, $65, $78, $65, $64, $43, $6f,
$6c, $6f, $72, $1, 0, $c, 0, 0, 0, $76, $65, $72, $74, $65, $78, $43, $6f, $6c, $6f, $72,
$73, $e, 0, $1, 0, $d, 0, 0, 0, $6e, $56, $65, $72, $74, $65, $78, $43, $6f, $6c, $6f,
$72, $73, $f, 0, $14, 0, $b, 0, $1f, 0, $1, 0, $4, 0, 0, 0, $4d, $65, $73, $68,
$a, 0, $5, 0, $44, $ab, $82, $3d, $da, $62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4, $33,
$29, 0, $1, 0, $9, 0, 0, 0, $6e, $56, $65, $72, $74, $69, $63, $65, $73, $14, 0, $34,
0, $1, 0, $6, 0, 0, 0, $56, $65, $63, $74, $6f, $72, $1, 0, $8, 0, 0, 0, $76,
$65, $72, $74, $69, $63, $65, $73, $e, 0, $1, 0, $9, 0, 0, 0, $6e, $56, $65, $72, $74,
$69, $63, $65, $73, $f, 0, $14, 0, $29, 0, $1, 0, $6, 0, 0, 0, $6e, $46, $61, $63,
$65, $73, $14, 0, $34, 0, $1, 0, $8, 0, 0, 0, $4d, $65, $73, $68, $46, $61, $63, $65,
$1, 0, $5, 0, 0, 0, $66, $61, $63, $65, $73, $e, 0, $1, 0, $6, 0, 0, 0, $6e,
$46, $61, $63, $65, $73, $f, 0, $14, 0, $e, 0, $12, 0, $12, 0, $12, 0, $f, 0, $b,
0, $1f, 0, $1, 0, $14, 0, 0, 0, $46, $72, $61, $6d, $65, $54, $72, $61, $6e, $73, $66,
$6f, $72, $6d, $4d, $61, $74, $72, $69, $78, $a, 0, $5, 0, $41, $3f, $f2, $f6, $86, $76, $cf,
$11, $8f, $52, 0, $40, $33, $35, $94, $a3, $1, 0, $9, 0, 0, 0, $4d, $61, $74, $72, $69,
$78, $34, $78, $34, $1, 0, $b, 0, 0, 0, $66, $72, $61, $6d, $65, $4d, $61, $74, $72, $69,
$78, $14, 0, $b, 0, $1f, 0, $1, 0, $5, 0, 0, 0, $46, $72, $61, $6d, $65, $a, 0,
$5, 0, $46, $ab, $82, $3d, $da, $62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4, $33, $e, 0,
$12, 0, $12, 0, $12, 0, $f, 0, $b, 0, $1f, 0, $1, 0, $9, 0, 0, 0, $46, $6c,
$6f, $61, $74, $4b, $65, $79, $73, $a, 0, $5, 0, $a9, $46, $dd, $10, $5b, $77, $cf, $11, $8f,
$52, 0, $40, $33, $35, $94, $a3, $29, 0, $1, 0, $7, 0, 0, 0, $6e, $56, $61, $6c, $75,
$65, $73, $14, 0, $34, 0, $2a, 0, $1, 0, $6, 0, 0, 0, $76, $61, $6c, $75, $65, $73,
$e, 0, $1, 0, $7, 0, 0, 0, $6e, $56, $61, $6c, $75, $65, $73, $f, 0, $14, 0, $b,
0, $1f, 0, $1, 0, $e, 0, 0, 0, $54, $69, $6d, $65, $64, $46, $6c, $6f, $61, $74, $4b,
$65, $79, $73, $a, 0, $5, 0, $80, $b1, $6, $f4, $3b, $7b, $cf, $11, $8f, $52, 0, $40, $33,
$35, $94, $a3, $29, 0, $1, 0, $4, 0, 0, 0, $74, $69, $6d, $65, $14, 0, $1, 0, $9,
0, 0, 0, $46, $6c, $6f, $61, $74, $4b, $65, $79, $73, $1, 0, $6, 0, 0, 0, $74, $66,
$6b, $65, $79, $73, $14, 0, $b, 0, $1f, 0, $1, 0, $c, 0, 0, 0, $41, $6e, $69, $6d,
$61, $74, $69, $6f, $6e, $4b, $65, $79, $a, 0, $5, 0, $a8, $46, $dd, $10, $5b, $77, $cf, $11,
$8f, $52, 0, $40, $33, $35, $94, $a3, $29, 0, $1, 0, $7, 0, 0, 0, $6b, $65, $79, $54,
$79, $70, $65, $14, 0, $29, 0, $1, 0, $5, 0, 0, 0, $6e, $4b, $65, $79, $73, $14, 0,
$34, 0, $1, 0, $e, 0, 0, 0, $54, $69, $6d, $65, $64, $46, $6c, $6f, $61, $74, $4b, $65,
$79, $73, $1, 0, $4, 0, 0, 0, $6b, $65, $79, $73, $e, 0, $1, 0, $5, 0, 0, 0,
$6e, $4b, $65, $79, $73, $f, 0, $14, 0, $b, 0, $1f, 0, $1, 0, $10, 0, 0, 0, $41,
$6e, $69, $6d, $61, $74, $69, $6f, $6e, $4f, $70, $74, $69, $6f, $6e, $73, $a, 0, $5, 0, $c0,
$56, $bf, $e2, $f, $84, $cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3, $29, 0, $1, 0, $a,
0, 0, 0, $6f, $70, $65, $6e, $63, $6c, $6f, $73, $65, $64, $14, 0, $29, 0, $1, 0, $f,
0, 0, 0, $70, $6f, $73, $69, $74, $69, $6f, $6e, $71, $75, $61, $6c, $69, $74, $79, $14, 0,
$b, 0, $1f, 0, $1, 0, $9, 0, 0, 0, $41, $6e, $69, $6d, $61, $74, $69, $6f, $6e, $a,
0, $5, 0, $4f, $ab, $82, $3d, $da, $62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4, $33, $e,
0, $12, 0, $12, 0, $12, 0, $f, 0, $b, 0, $1f, 0, $1, 0, $c, 0, 0, 0, $41,
$6e, $69, $6d, $61, $74, $69, $6f, $6e, $53, $65, $74, $a, 0, $5, 0, $50, $ab, $82, $3d, $da,
$62, $cf, $11, $ab, $39, 0, $20, $af, $71, $e4, $33, $e, 0, $1, 0, $9, 0, 0, 0, $41,
$6e, $69, $6d, $61, $74, $69, $6f, $6e, $f, 0, $b, 0, $1f, 0, $1, 0, $a, 0, 0, 0,
$49, $6e, $6c, $69, $6e, $65, $44, $61, $74, $61, $a, 0, $5, 0, $a0, $ee, $23, $3a, $b1, $94,
$d0, $11, $ab, $39, 0, $20, $af, $71, $e4, $33, $e, 0, $1, 0, $6, 0, 0, 0, $42, $49,
$4e, $41, $52, $59, $f, 0, $b, 0, $1f, 0, $1, 0, $3, 0, 0, 0, $55, $72, $6c, $a,
0, $5, 0, $a1, $ee, $23, $3a, $b1, $94, $d0, $11, $ab, $39, 0, $20, $af, $71, $e4, $33, $29,
0, $1, 0, $5, 0, 0, 0, $6e, $55, $72, $6c, $73, $14, 0, $34, 0, $31, 0, $1, 0,
$4, 0, 0, 0, $75, $72, $6c, $73, $e, 0, $1, 0, $5, 0, 0, 0, $6e, $55, $72, $6c,
$73, $f, 0, $14, 0, $b, 0, $1f, 0, $1, 0, $f, 0, 0, 0, $50, $72, $6f, $67, $72,
$65, $73, $73, $69, $76, $65, $4d, $65, $73, $68, $a, 0, $5, 0, $60, $c3, $63, $8a, $7d, $99,
$d0, $11, $94, $1c, 0, $80, $c8, $c, $fa, $7b, $e, 0, $1, 0, $3, 0, 0, 0, $55, $72,
$6c, $13, 0, $1, 0, $a, 0, 0, 0, $49, $6e, $6c, $69, $6e, $65, $44, $61, $74, $61, $f,
0, $b, 0, $1f, 0, $1, 0, $4, 0, 0, 0, $47, $75, $69, $64, $a, 0, $5, 0, $e0,
$90, $27, $a4, $10, $78, $cf, $11, $8f, $52, 0, $40, $33, $35, $94, $a3, $29, 0, $1, 0, $5,
0, 0, 0, $64, $61, $74, $61, $31, $14, 0, $28, 0, $1, 0, $5, 0, 0, 0, $64, $61,
$74, $61, $32, $14, 0, $28, 0, $1, 0, $5, 0, 0, 0, $64, $61, $74, $61, $33, $14, 0,
$34, 0, $2d, 0, $1, 0, $5, 0, 0, 0, $64, $61, $74, $61, $34, $e, 0, $3, 0, $8,
0, 0, 0, $f, 0, $14, 0, $b, 0, $1f, 0, $1, 0, $e, 0, 0, 0, $53, $74, $72,
$69, $6e, $67, $50, $72, $6f, $70, $65, $72, $74, $79, $a, 0, $5, 0, $e0, $21, $f, $7f, $e1,
$bf, $d1, $11, $82, $c0, 0, $a0, $c9, $69, $72, $71, $31, 0, $1, 0, $3, 0, 0, 0, $6b,
$65, $79, $14, 0, $31, 0, $1, 0, $5, 0, 0, 0, $76, $61, $6c, $75, $65, $14, 0, $b,
0, $1f, 0, $1, 0, $b, 0, 0, 0, $50, $72, $6f, $70, $65, $72, $74, $79, $42, $61, $67,
$a, 0, $5, 0, $e1, $21, $f, $7f, $e1, $bf, $d1, $11, $82, $c0, 0, $a0, $c9, $69, $72, $71,
$e, 0, $1, 0, $e, 0, 0, 0, $53, $74, $72, $69, $6e, $67, $50, $72, $6f, $70, $65, $72,
$74, $79, $f, 0, $b, 0, $1f, 0, $1, 0, $e, 0, 0, 0, $45, $78, $74, $65, $72, $6e,
$61, $6c, $56, $69, $73, $75, $61, $6c, $a, 0, $5, 0, $a0, $6a, $11, $98, $ba, $bd, $d1, $11,
$82, $c0, 0, $a0, $c9, $69, $72, $71, $1, 0, $4, 0, 0, 0, $47, $75, $69, $64, $1, 0,
$12, 0, 0, 0, $67, $75, $69, $64, $45, $78, $74, $65, $72, $6e, $61, $6c, $56, $69, $73, $75,
$61, $6c, $14, 0, $e, 0, $12, 0, $12, 0, $12, 0, $f, 0, $b, 0, $1f, 0, $1, 0,
$b, 0, 0, 0, $52, $69, $67, $68, $74, $48, $61, $6e, $64, $65, $64, $a, 0, $5, 0, $a0,
$5e, $5d, $7f, $3a, $d5, $d1, $11, $82, $c0, 0, $a0, $c9, $69, $72, $71, $29, 0, $1, 0, $c,
0, 0, 0, $62, $52, $69, $67, $68, $74, $48, $61, $6e, $64, $65, $64, $14, 0, $b, 0);
D3DRM_XTEMPLATE_BYTES = 3278;
 
//---------------
{$ENDIF}
//DirectInput file
(*==========================================================================;
*
* Copyright (C) 1996-1999 Microsoft Corporation. All Rights Reserved.
* Copyright (C) 1996-1997 Microsoft Corporation. All Rights Reserved.
*
* File: dinput.h
* Content: DirectInput include file
*
* DirectX 7.0 Delphi adaptation by Erik Unger, input format
* variable structure & other fixups by Arne Schäpers (as)
*
* Modified: 10-Sep-2000
*
* Download: http://www.delphi-jedi.org/DelphiGraphics/
* E-Mail: DelphiDirectX@next-reality.com
* a.schaepers@digitalpublishing.de
*
***************************************************************************)
****************************************************************************)
 
{ Some notes from as:
1. DirectInput Enum callback functions which are documented with result
type BOOL in the SDK had to be changed to result type integer because the debug
version of DINPUT.DLL (which is the same for SDK versions 5.0, 5.2, 6.0, and 6.1)
explicitely checks for two possible return values:
 
0 - FALSE in C and in Delphi
1 - TRUE in C, defined as DIENUM_CONTINUE
 
In Delphi, TRUE means $FFFFFFFF (= -1) for the LongBool (= BOOL) data
type, and AL = 1 (upper three bytes undefined) for the Boolean data type.
The debug version of DINPUT.DLL will throw an external exception
("invalid return value for callback") when fed with either value.
 
This change affects the following methods:
EnumDevices, EnumObjects, EnumEffects, EnumCreatedEffectObjects
 
2. Windows 98 and DX6 debug versions DInput and DSound
 
Under Windows 98, the "debug" setup of the DirectX SDK 6.x skips DInput.DLL
and DSound.DLL, i.e. makes you end up with the retail version of these two
files without any notice.
The debug versions of DInput.DLL and DSound.DLL can be found in the
\extras\Win98\Win98Dbg folder of the SDK CD; they need to be installed
"manually".
 
This problem has been fixed with DX7 where the SDK installs the debug versions
of DInput and DSound without any "manual" help.
 
}
 
 
var
DInputDLL : HMODULE;
 
{$IFDEF DIRECTX3}
const DIRECTINPUT_VERSION = $0300;
{$ELSE}
const DIRECTINPUT_VERSION = $0700;
const
{$IFDEF DirectX3}
DIRECTINPUT_VERSION = $0300;
{$ENDIF}{$IFDEF DirectX5}
DIRECTINPUT_VERSION = $0500;
{$ENDIF}{$IFDEF DirectX6}
DIRECTINPUT_VERSION = $0500;
{$ENDIF}{$IFDEF DirectX7}
DIRECTINPUT_VERSION = $0700;
{$ENDIF}
 
function DIErrorString(Value: HResult) : string;
{ Class IDs }
 
//type
// TRefGUID = packed record
// case integer of
// 1: (guid : PGUID);
// 2: (dwFlags : DWORD);
// end;
 
(****************************************************************************
*
* Class IDs
*
****************************************************************************)
const
CLSID_DirectInput: TGUID =
(D1:$25E609E0;D2:$B259;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
CLSID_DirectInputDevice: TGUID =
(D1:$25E609E1;D2:$B259;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
CLSID_DirectInput: TGUID = '{25E609E0-B259-11CF-BFC7-444553540000}';
CLSID_DirectInputDevice: TGUID = '{25E609E1-B259-11CF-BFC7-444553540000}';
 
(****************************************************************************
*
* Predefined object types
*
****************************************************************************)
{ Interfaces }
 
GUID_XAxis: TGUID =
(D1:$A36D02E0;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_YAxis: TGUID =
(D1:$A36D02E1;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_ZAxis: TGUID =
(D1:$A36D02E2;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_RxAxis: TGUID =
(D1:$A36D02F4;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_RyAxis: TGUID =
(D1:$A36D02F5;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_RzAxis: TGUID =
(D1:$A36D02E3;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_Slider: TGUID =
(D1:$A36D02E4;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
const
IID_IDirectInputA: TGUID = '{89521360-AA8A-11CF-BFC7-444553540000}';
IID_IDirectInputW: TGUID = '{89521361-AA8A-11CF-BFC7-444553540000}';
IID_IDirectInput2A: TGUID = '{5944E662-AA8A-11CF-BFC7-444553540000}';
IID_IDirectInput2W: TGUID = '{5944E663-AA8A-11CF-BFC7-444553540000}';
IID_IDirectInput7A: TGUID = '{9A4CB684-236D-11D3-8E9D-00C04F6844AE}';
IID_IDirectInput7W: TGUID = '{9A4CB685-236D-11D3-8E9D-00C04F6844AE}';
IID_IDirectInputDeviceA: TGUID = '{5944E680-C92E-11CF-BFC7-444553540000}';
IID_IDirectInputDeviceW: TGUID = '{5944E681-C92E-11CF-BFC7-444553540000}';
IID_IDirectInputDevice2A: TGUID = '{5944E682-C92E-11CF-BFC7-444553540000}';
IID_IDirectInputDevice2W: TGUID = '{5944E683-C92E-11CF-BFC7-444553540000}';
IID_IDirectInputDevice7A: TGUID = '{57D7C6BC-2356-11D3-8E9D-00C04F6844AE}';
IID_IDirectInputDevice7W: TGUID = '{57D7C6BD-2356-11D3-8E9D-00C04F6844AE}';
IID_IDirectInputEffect: TGUID = '{E7E1F7C0-88D2-11D0-9AD0-00A0C9A06E35}';
 
GUID_Button: TGUID =
(D1:$A36D02F0;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_Key: TGUID =
(D1:$55728220;D2:$D33C;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
{ Predefined object types }
 
GUID_POV: TGUID =
(D1:$A36D02F2;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_XAxis: TGUID = '{A36D02E0-C9F3-11CF-BFC7-444553540000}';
GUID_YAxis: TGUID = '{A36D02E1-C9F3-11CF-BFC7-444553540000}';
GUID_ZAxis: TGUID = '{A36D02E2-C9F3-11CF-BFC7-444553540000}';
GUID_RxAxis: TGUID = '{A36D02F4-C9F3-11CF-BFC7-444553540000}';
GUID_RyAxis: TGUID = '{A36D02F5-C9F3-11CF-BFC7-444553540000}';
GUID_RzAxis: TGUID = '{A36D02E3-C9F3-11CF-BFC7-444553540000}';
GUID_Slider: TGUID = '{A36D02E4-C9F3-11CF-BFC7-444553540000}';
GUID_Button: TGUID = '{A36D02F0-C9F3-11CF-BFC7-444553540000}';
GUID_Key: TGUID = '{55728220-D33C-11CF-BFC7-444553540000}';
GUID_POV: TGUID = '{A36D02F2-C9F3-11CF-BFC7-444553540000}';
GUID_Unknown: TGUID = '{A36D02F3-C9F3-11CF-BFC7-444553540000}';
 
GUID_Unknown: TGUID =
(D1:$A36D02F3;D2:$C9F3;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
{ Predefined product GUIDs }
 
(****************************************************************************
*
* Predefined product GUIDs
*
****************************************************************************)
 
GUID_SysMouse: TGUID =
(D1:$6F1D2B60;D2:$D5A0;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_SysKeyboard: TGUID =
(D1:$6F1D2B61;D2:$D5A0;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_Joystick: TGUID =
(D1:$6F1D2B70;D2:$D5A0;D3:$11CF;D4:($BF,$C7,$44,$45,$53,$54,$00,$00));
GUID_SysMouse: TGUID = '{6F1D2B60-D5A0-11CF-BFC7-444553540000}';
GUID_SysKeyboard: TGUID = '{6F1D2B61-D5A0-11CF-BFC7-444553540000}';
GUID_Joystick: TGUID = '{6F1D2B70-D5A0-11CF-BFC7-444553540000}';
GUID_SysMouseEm: TGUID = '{6F1D2B80-D5A0-11CF-BFC7-444553540000}';
GUID_SysMouseEm2: TGUID = '{6F1D2B81-D5A0-11CF-BFC7-444553540000}';
GUID_SysKeyboardEm: TGUID = '{6F1D2B82-D5A0-11CF-BFC7-444553540000}';
GUID_SysKeyboardEm2: TGUID = '{6F1D2B83-D5A0-11CF-BFC7-444553540000}';
 
(****************************************************************************
*
* Predefined force feedback effects
*
****************************************************************************)
{ Predefined force feedback effects }
 
GUID_ConstantForce: TGUID =
(D1:$13541C20;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_RampForce: TGUID =
(D1:$13541C21;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_Square: TGUID =
(D1:$13541C22;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_Sine: TGUID =
(D1:$13541C23;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_Triangle: TGUID =
(D1:$13541C24;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_SawtoothUp: TGUID =
(D1:$13541C25;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_SawtoothDown: TGUID =
(D1:$13541C26;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_Spring: TGUID =
(D1:$13541C27;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_Damper: TGUID =
(D1:$13541C28;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_Inertia: TGUID =
(D1:$13541C29;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_Friction: TGUID =
(D1:$13541C2A;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_CustomForce: TGUID =
(D1:$13541C2B;D2:$8E33;D3:$11D0;D4:($9A,$D0,$00,$A0,$C9,$A0,$6E,$35));
GUID_ConstantForce: TGUID = '{13541C20-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_RampForce: TGUID = '{13541C21-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_Square: TGUID = '{13541C22-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_Sine: TGUID = '{13541C23-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_Triangle: TGUID = '{13541C24-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_SawtoothUp: TGUID = '{13541C25-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_SawtoothDown: TGUID = '{13541C26-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_Spring: TGUID = '{13541C27-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_Damper: TGUID = '{13541C28-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_Inertia: TGUID = '{13541C29-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_Friction: TGUID = '{13541C2A-8E33-11D0-9AD0-00A0C9A06E35}';
GUID_CustomForce: TGUID = '{13541C2B-8E33-11D0-9AD0-00A0C9A06E35}';
 
{ IDirectInputEffect }
 
 
(****************************************************************************
*
* Interfaces and Structures...
*
****************************************************************************)
 
(****************************************************************************
*
* IDirectInputEffect
*
****************************************************************************)
 
const
DIEFT_ALL = $00000000;
 
12106,7 → 8422,7
DIEFT_DEADBAND = $00004000;
DIEFT_STARTDELAY = $00008000;
 
function DIEFT_GETTYPE(n: variant) : byte;
function DIEFT_GETTYPE(n: DWORD): DWORD;
 
const
DI_DEGREES = 100;
12115,101 → 8431,129
 
type
PDIConstantForce = ^TDIConstantForce;
TDIConstantForce = packed record
lMagnitude : LongInt;
TDIConstantForce = record
lMagnitude: Longint;
end;
 
DICONSTANTFORCE = TDIConstantForce;
LPDICONSTANTFORCE = PDIConstantForce;
 
PDIRampForce = ^TDIRampForce;
TDIRampForce = packed record
lStart : LongInt;
lEnd : LongInt;
TDIRampForce = record
lStart: Longint;
lEnd: Longint;
end;
 
DIRAMPFORCE = TDIRampForce;
LPDIRAMPFORCE = PDIRampForce;
 
PDIPeriodic = ^TDIPeriodic;
TDIPeriodic = packed record
TDIPeriodic = record
dwMagnitude : DWORD;
lOffset : LongInt;
lOffset: Longint;
dwPhase : DWORD;
dwPeriod : DWORD;
end;
 
DIPERIODIC = TDIPeriodic;
LPDIPERIODIC = PDIPeriodic;
 
PDICondition = ^TDICondition;
TDICondition = packed record
lOffset : LongInt;
lPositiveCoefficient : LongInt;
lNegativeCoefficient : LongInt;
TDICondition = record
lOffset: Longint;
lPositiveCoefficient: Longint;
lNegativeCoefficient: Longint;
dwPositiveSaturation : DWORD;
dwNegativeSaturation : DWORD;
lDeadBand : LongInt;
lDeadBand: Longint;
end;
 
DICONDITION = TDICondition;
LPDICONDITION = PDICondition;
 
PDICustomForce = ^TDICustomForce;
TDICustomForce = packed record
TDICustomForce = record
cChannels : DWORD;
dwSamplePeriod : DWORD;
cSamples : DWORD;
rglForceData : PLongInt;
rglForceData: PLongint;
end;
 
DICUSTOMFORCE = TDICustomForce;
LPDICUSTOMFORCE = PDICustomForce;
 
PDIEnvelope = ^TDIEnvelope;
TDIEnvelope = packed record
dwSize : DWORD; (* sizeof(DIENVELOPE) *)
TDIEnvelope = record
dwSize: DWORD; // sizeof(DIENVELOPE)
dwAttackLevel : DWORD;
dwAttackTime : DWORD; (* Microseconds *)
dwAttackTime: DWORD; // Microseconds
dwFadeLevel : DWORD;
dwFadeTime : DWORD; (* Microseconds *)
dwFadeTime: DWORD; // Microseconds
end;
 
DIENVELOPE = TDIEnvelope;
LPDIENVELOPE = PDIEnvelope;
 
PDIEffect_DX5 = ^TDIEffect_DX5;
TDIEffect_DX5 = packed record
dwSize : DWORD; (* sizeof(DIEFFECT) *)
dwFlags : DWORD; (* DIEFF_* *)
dwDuration : DWORD; (* Microseconds *)
dwSamplePeriod : DWORD; (* Microseconds *)
TDIEffect_DX5 = record
dwSize: DWORD; // sizeof(DIEFFECT)
dwFlags: DWORD; // DIEFF_*
dwDuration: DWORD; // Microseconds
dwSamplePeriod: DWORD; // Microseconds
dwGain : DWORD;
dwTriggerButton : DWORD; (* or DIEB_NOTRIGGER *)
dwTriggerRepeatInterval : DWORD; (* Microseconds *)
cAxes : DWORD; (* Number of axes *)
rgdwAxes : PDWORD; (* Array of axes *)
rglDirection : PLongInt; (* Array of directions *)
lpEnvelope : PDIEnvelope; (* Optional *)
cbTypeSpecificParams : DWORD; (* Size of params *)
lpvTypeSpecificParams : pointer; (* Pointer to params *)
dwTriggerButton: DWORD; // or DIEB_NOTRIGGER
dwTriggerRepeatInterval: DWORD; // Microseconds
cAxes: DWORD; // Number of axes
rgdwAxes: PDWORD; // arrayof axes
rglDirection: PLongint; // arrayof directions
lpEnvelope: PDIEnvelope; // Optional
cbTypeSpecificParams: DWORD; // Size of params
lpvTypeSpecificParams: Pointer; // Pointer to params
end;
 
PDIEffect_DX6 = ^TDIEffect_DX6;
TDIEffect_DX6 = packed record
dwSize : DWORD; (* sizeof(DIEFFECT) *)
dwFlags : DWORD; (* DIEFF_* *)
dwDuration : DWORD; (* Microseconds *)
dwSamplePeriod : DWORD; (* Microseconds *)
TDIEffect_DX6 = record
dwSize: DWORD; // sizeof(DIEFFECT)
dwFlags: DWORD; // DIEFF_*
dwDuration: DWORD; // Microseconds
dwSamplePeriod: DWORD; // Microseconds
dwGain : DWORD;
dwTriggerButton : DWORD; (* or DIEB_NOTRIGGER *)
dwTriggerRepeatInterval : DWORD; (* Microseconds *)
cAxes : DWORD; (* Number of axes *)
rgdwAxes : PDWORD; (* Array of axes *)
rglDirection : PLongInt; (* Array of directions *)
lpEnvelope : PDIEnvelope; (* Optional *)
cbTypeSpecificParams : DWORD; (* Size of params *)
lpvTypeSpecificParams : pointer; (* Pointer to params *)
dwStartDelay: DWORD; (* Microseconds *)
dwTriggerButton: DWORD; // or DIEB_NOTRIGGER
dwTriggerRepeatInterval: DWORD; // Microseconds
cAxes: DWORD; // Number of axes
rgdwAxes: PDWORD; // arrayof axes
rglDirection: PLongint; // arrayof directions
lpEnvelope: PDIEnvelope; // Optional
cbTypeSpecificParams: DWORD; // Size of params
lpvTypeSpecificParams: Pointer; // Pointer to params
dwStartDelay: DWORD; // Microseconds
end;
 
PDIEffect = ^TDIEffect;
{$IFDEF DIRECTX5}
{$IFDEF SupportDirectX6}
PDIEffect = PDIEffect_DX6;
TDIEffect = TDIEffect_DX6;
{$ELSE}
PDIEffect = PDIEffect_DX5;
TDIEffect = TDIEffect_DX5;
{$ELSE}
TDIEffect = TDIEffect_DX6;
{$ENDIF}
 
DIEFFECT = TDIEFFECT;
LPDIEFFECT = PDIEFFECT;
 
PDIFileEffect = ^TDIFileEffect;
TDIFileEffect = packed record
TDIFileEffect = record
dwSize : DWORD;
GuidEffect: TGUID;
lpDiEffect: PDIEffect;
szFriendlyName : array [0..MAX_PATH-1] of AnsiChar;
szFriendlyName: array[0..MAX_PATH-1] of Char;
end;
 
DIFILEEFFECT = TDIFileEffect;
LPDIFILEEFFECT = PDIFileEffect;
 
TDIEnumEffectsInFileCallback = function(const lpDiFileEf: TDIFileEffect; pvRef: Pointer): BOOL; far pascal;
LPDIENUMEFFECTSINFILECALLBACK = TDIEnumEffectsInFileCallback;
 
const
DIEFF_OBJECTIDS = $00000001;
DIEFF_OBJECTOFFSETS = $00000002;
12226,12 → 8570,12
DIEP_DIRECTION = $00000040;
DIEP_ENVELOPE = $00000080;
DIEP_TYPESPECIFICPARAMS = $00000100;
{$IFDEF DIRECTX5}
DIEP_ALLPARAMS = $000001FF;
{$ELSE}
DIEP_STARTDELAY = $00000200;
DIEP_ALLPARAMS_DX5 = $000001FF;
{$IFDEF SupportDirectX6}
DIEP_ALLPARAMS = $000003FF;
{$ELSE}
DIEP_ALLPARAMS = $000001FF;
{$ENDIF}
DIEP_START = $20000000;
DIEP_NORESTART = $40000000;
12244,43 → 8588,36
DIEGES_PLAYING = $00000001;
DIEGES_EMULATED = $00000002;
 
 
type
PDIEffEscape = ^TDIEffEscape;
TDIEffEscape = packed record
TDIEffEscape = record
dwSize : DWORD;
dwCommand : DWORD;
lpvInBuffer : pointer;
lpvInBuffer: Pointer;
cbInBuffer : DWORD;
lpvOutBuffer : pointer;
lpvOutBuffer: Pointer;
cbOutBuffer : DWORD;
end;
 
DIEFFESCAPE = TDIEffEscape;
LPDIEFFESCAPE = PDIEffEscape;
 
//
// IDirectSoundCapture // as: ???
//
IDirectInputEffect = interface (IUnknown)
['{E7E1F7C0-88D2-11D0-9AD0-00A0C9A06E35}']
(** IDirectInputEffect methods ***)
function Initialize(hinst: THandle; dwVersion: DWORD;
const rguid: TGUID) : HResult; stdcall;
// IDirectInputEffect methods
function Initialize(hinst: THandle; dwVersion: DWORD; const rguid: TGUID): HResult; stdcall;
function GetEffectGuid(var pguid: TGUID) : HResult; stdcall;
function GetParameters(var peff: TDIEffect; dwFlags: DWORD) : HResult; stdcall;
function SetParameters(var peff: TDIEffect; dwFlags: DWORD) : HResult; stdcall;
function SetParameters(const peff: TDIEffect; dwFlags: DWORD): HResult; stdcall;
function Start(dwIterations: DWORD; dwFlags: DWORD) : HResult; stdcall;
function Stop : HResult; stdcall;
function GetEffectStatus(var pdwFlags : DWORD) : HResult; stdcall;
function Download : HResult; stdcall;
function DownLoad: HResult; stdcall;
function Unload : HResult; stdcall;
function Escape(var pesc: TDIEffEscape) : HResult; stdcall;
function Escape(const pesc: TDIEffEscape): HResult; stdcall;
end;
 
(****************************************************************************
*
* IDirectInputDevice
*
****************************************************************************)
{ IDirectInputDevice }
 
const
DIDEVTYPE_DEVICE = 1;
12317,12 → 8654,12
DIDEVTYPEJOYSTICK_WHEEL = 6;
DIDEVTYPEJOYSTICK_HEADTRACKER = 7;
 
function GET_DIDEVICE_TYPE(dwDevType: variant) : byte;
function GET_DIDEVICE_SUBTYPE(dwDevType: variant) : byte;
function GET_DIDEVICE_TYPE(dwDevType: DWORD): DWORD;
function GET_DIDEVICE_SUBTYPE(dwDevType: DWORD): DWORD;
 
type
PDIDevCaps_DX3 = ^TDIDevCaps_DX3;
TDIDevCaps_DX3 = packed record
TDIDevCaps_DX3 = record
dwSize: DWORD;
dwFlags: DWORD;
dwDevType: DWORD;
12332,7 → 8669,7
end;
 
PDIDevCaps_DX5 = ^TDIDevCaps_DX5;
TDIDevCaps_DX5 = packed record
TDIDevCaps_DX5 = record
dwSize: DWORD;
dwFlags: DWORD;
dwDevType: DWORD;
12346,18 → 8683,29
dwFFDriverVersion: DWORD;
end;
 
PDIDevCaps = ^TDIDevCaps;
{$IFDEF DIRECTX3}
{$IFDEF DirectX3}
TDIDevCaps = TDIDevCaps_DX3;
{$ELSE}
PDIDevCaps = PDIDevCaps_DX3;
{$ENDIF}{$IFDEF DirectX5}
TDIDevCaps = TDIDevCaps_DX5;
PDIDevCaps = PDIDevCaps_DX5;
{$ENDIF}{$IFDEF DirectX6}
TDIDevCaps = TDIDevCaps_DX5;
PDIDevCaps = PDIDevCaps_DX5;
{$ENDIF}{$IFDEF DirectX7}
TDIDevCaps = TDIDevCaps_DX5;
PDIDevCaps = PDIDevCaps_DX5;
{$ENDIF}
 
DIDEVCAPS = TDIDevCaps;
LPDIDEVCAPS = PDIDevCaps;
 
const
DIDC_ATTACHED = $00000001;
DIDC_POLLEDDEVICE = $00000002;
DIDC_EMULATED = $00000004;
DIDC_POLLEDDATAFORMAT = $00000008;
 
DIDC_FORCEFEEDBACK = $00000100;
DIDC_FFATTACK = $00000200;
DIDC_FFFADE = $00000400;
12385,25 → 8733,22
 
DIDFT_ANYINSTANCE = $00FFFF00;
DIDFT_INSTANCEMASK = DIDFT_ANYINSTANCE;
function DIDFT_MAKEINSTANCE(n: variant) : DWORD;
function DIDFT_GETTYPE(n: variant) : byte;
function DIDFT_GETINSTANCE(n: variant) : DWORD;
const
 
DIDFT_FFACTUATOR = $01000000;
DIDFT_FFEFFECTTRIGGER = $02000000;
DIDFT_OUTPUT = $10000000;
DIDFT_VENDORDEFINED = $04000000;
DIDFT_ALIAS = $08000000;
 
function DIDFT_ENUMCOLLECTION(n: variant) : DWORD;
const
DIDFT_NOCOLLECTION = $00FFFF00;
 
function DIDFT_MAKEINSTANCE(n: WORD): DWORD;
function DIDFT_GETTYPE(n: DWORD): DWORD;
function DIDFT_GETINSTANCE(n: DWORD): WORD;
function DIDFT_ENUMCOLLECTION(n: WORD): DWORD;
 
 
type
PDIObjectDataFormat = ^TDIObjectDataFormat;
TDIObjectDataFormat = packed record
TDIObjectDataFormat = record
pguid: PGUID;
dwOfs: DWORD;
dwType: DWORD;
12410,8 → 8755,11
dwFlags: DWORD;
end;
 
DIOBJECTDATAFORMAT = TDIObjectDataFormat;
LPDIOBJECTDATAFORMAT = PDIObjectDataFormat;
 
PDIDataFormat = ^TDIDataFormat;
TDIDataFormat = packed record
TDIDataFormat = record
dwSize: DWORD;
dwObjSize: DWORD;
dwFlags: DWORD;
12420,46 → 8768,32
rgodf: PDIObjectDataFormat;
end;
 
DIDATAFORMAT = TDIDataFormat;
LPDIDATAFORMAT = PDIDataFormat;
 
const
DIDF_ABSAXIS = $00000001;
DIDF_RELAXIS = $00000002;
 
type
PDIDeviceObjectInstance_DX3A = ^TDIDeviceObjectInstance_DX3A;
TDIDeviceObjectInstance_DX3A = packed record
PDIDeviceObjectInstanceA_DX3 = ^TDIDeviceObjectInstanceA_DX3;
TDIDeviceObjectInstanceA_DX3 = record
dwSize: DWORD;
guidType: TGUID;
dwOfs: DWORD;
dwType: DWORD;
dwFlags: DWORD;
tszName: Array [0..MAX_PATH-1] of CHAR;
tszName: array[0..MAX_PATH-1] of CHAR;
end;
 
PDIDeviceObjectInstance_DX3W = ^TDIDeviceObjectInstance_DX3W;
TDIDeviceObjectInstance_DX3W = packed record
PDIDeviceObjectInstanceA_DX5 = ^TDIDeviceObjectInstanceA_DX5;
TDIDeviceObjectInstanceA_DX5 = record
dwSize: DWORD;
guidType: TGUID;
dwOfs: DWORD;
dwType: DWORD;
dwFlags: DWORD;
tszName: Array [0..MAX_PATH-1] of WCHAR;
end;
 
PDIDeviceObjectInstance_DX3 = ^TDIDeviceObjectInstance_DX3;
{$IFDEF UNICODE}
TDIDeviceObjectInstance_DX3 = TDIDeviceObjectInstance_DX3W;
{$ELSE}
TDIDeviceObjectInstance_DX3 = TDIDeviceObjectInstance_DX3A;
{$ENDIF}
 
PDIDeviceObjectInstance_DX5A = ^TDIDeviceObjectInstance_DX5A;
TDIDeviceObjectInstance_DX5A = packed record
dwSize: DWORD;
guidType: TGUID;
dwOfs: DWORD;
dwType: DWORD;
dwFlags: DWORD;
tszName: Array [0..MAX_PATH-1] of CHAR;
tszName: array[0..MAX_PATH-1] of CHAR;
dwFFMaxForce: DWORD;
dwFFForceResolution: DWORD;
wCollectionNumber: WORD;
12471,14 → 8805,41
wReserved: WORD;
end;
 
PDIDeviceObjectInstance_DX5W = ^TDIDeviceObjectInstance_DX5W;
TDIDeviceObjectInstance_DX5W = packed record
{$IFDEF DirectX3}
TDIDeviceObjectInstanceA = TDIDeviceObjectInstanceA_DX3;
PDIDeviceObjectInstanceA = PDIDeviceObjectInstanceA_DX3;
{$ENDIF}{$IFDEF DirectX5}
TDIDeviceObjectInstanceA = TDIDeviceObjectInstanceA_DX5;
PDIDeviceObjectInstanceA = PDIDeviceObjectInstanceA_DX5;
{$ENDIF}{$IFDEF DirectX6}
TDIDeviceObjectInstanceA = TDIDeviceObjectInstanceA_DX5;
PDIDeviceObjectInstanceA = PDIDeviceObjectInstanceA_DX5;
{$ENDIF}{$IFDEF DirectX7}
TDIDeviceObjectInstanceA = TDIDeviceObjectInstanceA_DX5;
PDIDeviceObjectInstanceA = PDIDeviceObjectInstanceA_DX5;
{$ENDIF}
 
DIDEVICEOBJECTINSTANCEA = TDIDeviceObjectInstanceA;
LPDIDEVICEOBJECTINSTANCEA = PDIDeviceObjectInstanceA;
 
PDIDeviceObjectInstanceW_DX3 = ^TDIDeviceObjectInstanceW_DX3;
TDIDeviceObjectInstanceW_DX3 = record
dwSize: DWORD;
guidType: TGUID;
dwOfs: DWORD;
dwType: DWORD;
dwFlags: DWORD;
tszName: Array [0..MAX_PATH-1] of WCHAR;
tszName: array[0..MAX_PATH-1] of WCHAR;
end;
 
PDIDeviceObjectInstanceW_DX5 = ^TDIDeviceObjectInstanceW_DX5;
TDIDeviceObjectInstanceW_DX5 = record
dwSize: DWORD;
guidType: TGUID;
dwOfs: DWORD;
dwType: DWORD;
dwFlags: DWORD;
tszName: array[0..MAX_PATH-1] of WCHAR;
dwFFMaxForce: DWORD;
dwFFForceResolution: DWORD;
wCollectionNumber: WORD;
12490,39 → 8851,40
wReserved: WORD;
end;
 
PDIDeviceObjectInstance_DX5 = ^TDIDeviceObjectInstance_DX5;
{$IFDEF UNICODE}
TDIDeviceObjectInstance_DX5 = TDIDeviceObjectInstance_DX5W;
{$ELSE}
TDIDeviceObjectInstance_DX5 = TDIDeviceObjectInstance_DX5A;
{$IFDEF DirectX3}
TDIDeviceObjectInstanceW = TDIDeviceObjectInstanceW_DX3;
PDIDeviceObjectInstanceW = PDIDeviceObjectInstanceW_DX3;
{$ENDIF}{$IFDEF DirectX5}
TDIDeviceObjectInstanceW = TDIDeviceObjectInstanceW_DX5;
PDIDeviceObjectInstanceW = PDIDeviceObjectInstanceW_DX5;
{$ENDIF}{$IFDEF DirectX6}
TDIDeviceObjectInstanceW = TDIDeviceObjectInstanceW_DX5;
PDIDeviceObjectInstanceW = PDIDeviceObjectInstanceW_DX5;
{$ENDIF}{$IFDEF DirectX7}
TDIDeviceObjectInstanceW = TDIDeviceObjectInstanceW_DX5;
PDIDeviceObjectInstanceW = PDIDeviceObjectInstanceW_DX5;
{$ENDIF}
 
PDIDeviceObjectInstanceA = ^TDIDeviceObjectInstanceA;
PDIDeviceObjectInstanceW = ^TDIDeviceObjectInstanceA;
PDIDeviceObjectInstance = ^TDIDeviceObjectInstance;
{$IFDEF DIRECTX3}
TDIDeviceObjectInstanceA = TDIDeviceObjectInstance_DX3A;
TDIDeviceObjectInstanceW = TDIDeviceObjectInstance_DX3W;
TDIDeviceObjectInstance = TDIDeviceObjectInstance_DX3;
{$ELSE}
TDIDeviceObjectInstanceA = TDIDeviceObjectInstance_DX5A;
TDIDeviceObjectInstanceW = TDIDeviceObjectInstance_DX5W;
TDIDeviceObjectInstance = TDIDeviceObjectInstance_DX5;
{$ENDIF}
DIDEVICEOBJECTINSTANCEW = TDIDeviceObjectInstanceW;
LPDIDEVICEOBJECTINSTANCEW = PDIDeviceObjectInstanceW;
 
// Bug fix (and deviation from the SDK). Callback *must* return
// DIENUM_STOP (= 0) or DIENUM_CONTINUE (=1) in order to work
// with the debug version of DINPUT.DLL
TDIEnumDeviceObjectsCallbackA = function (
var lpddoi: TDIDeviceObjectInstanceA; pvRef: Pointer): Integer; stdcall; // BOOL; stdcall;
TDIEnumDeviceObjectsCallbackW = function (
var lpddoi: TDIDeviceObjectInstanceW; pvRef: Pointer): Integer; stdcall; // BOOL; stdcall;
TDIEnumDeviceObjectsCallback = function (
var lpddoi: TDIDeviceObjectInstance; pvRef: Pointer): Integer; stdcall; // BOOL; stdcall;
TDIDeviceObjectInstance = TDIDeviceObjectInstanceA;
PDIDeviceObjectInstance = PDIDeviceObjectInstanceA;
 
TDIEnumDeviceObjectsProc = function (
var lpddoi: TDIDeviceObjectInstance; pvRef: Pointer): Integer; stdcall; // BOOL; stdcall;
DIDEVICEOBJECTINSTANCE = TDIDeviceObjectInstance;
LPDIDEVICEOBJECTINSTANCE = PDIDeviceObjectInstance;
 
TDIEnumDeviceObjectsCallbackA = function(const peff: TDIDeviceObjectInstanceA;
pvRef: Pointer): HResult; stdcall;
LPDIENUMDEVICEOBJECTSCALLBACKA = TDIEnumDeviceObjectsCallbackA;
 
TDIEnumDeviceObjectsCallbackW = function(const peff: TDIDeviceObjectInstanceW;
pvRef: Pointer): HResult; stdcall;
LPDIENUMDEVICEOBJECTSCALLBACKW = TDIEnumDeviceObjectsCallbackW;
 
TDIEnumDeviceObjectsCallback = TDIEnumDeviceObjectsCallbackA;
LPDIENUMDEVICEOBJECTSCALLBACK = TDIEnumDeviceObjectsCallback;
 
const
DIDOI_FFACTUATOR = $00000001;
DIDOI_FFEFFECTTRIGGER = $00000002;
12536,7 → 8898,7
 
type
PDIPropHeader = ^TDIPropHeader;
TDIPropHeader = packed record
TDIPropHeader = record
dwSize: DWORD;
dwHeaderSize: DWORD;
dwObj: DWORD;
12543,6 → 8905,9
dwHow: DWORD;
end;
 
DIPROPHEADER = TDIPropHeader;
LPDIPROPHEADER = PDIPropHeader;
 
const
DIPH_DEVICE = 0;
DIPH_BYOFFSET = 1;
12549,105 → 8914,97
DIPH_BYID = 2;
DIPH_BYUSAGE = 3;
 
function DIMAKEUSAGEDWORD(UsagePage, Usage: WORD) : DWORD;
function DIMAKEUSAGEDWORD(UsagePage, Usage: Word): DWORD;
 
type
PDIPropDWord = ^TDIPropDWord;
TDIPropDWord = packed record
PDIPropDWORD = ^TDIPropDWORD;
TDIPropDWORD = record
diph: TDIPropHeader;
dwData: DWORD;
end;
 
DIPROPDWORD = TDIPropDWORD;
LPDIPROPDWORD = PDIPropDWORD;
 
PDIPropRange = ^TDIPropRange;
TDIPropRange = packed record
TDIPropRange = record
diph: TDIPropHeader;
lMin: Longint;
lMax: Longint;
end;
 
const
DIPROPRANGE_NOMIN = $80000000;
DIPROPRANGE_NOMAX = $7FFFFFFF;
DIPROPRANGE = TDIPropRange;
LPDIPROPRANGE = PDIPropRange;
 
type
PDIPropCal = ^TDIPropCal;
TDIPropCal = packed record
TDIPropCal = record
diph: TDIPropHeader;
lMin: LongInt;
lCenter: LongInt;
lMax: LongInt;
lMin: Longint;
lCenter: Longint;
lMax: Longint;
end;
 
DIPROPCAL = TDIPropCal;
LPDIPROPCAL = PDIPropCal;
 
PDIPropGUIDAndPath = ^TDIPropGUIDAndPath;
TDIPropGUIDAndPath = packed record
TDIPropGUIDAndPath = record
diph: TDIPropHeader;
guidClass: TGUID;
wszPath: array [0..MAX_PATH-1] of WideChar;
wszPath: array[0..MAX_PATH-1] of WCHAR;
end;
 
DIPROPGUIDANDPATH = TDIPropGUIDAndPath;
LPDIPROPGUIDANDPATH = PDIPropGUIDAndPath;
 
PDIPropString = ^TDIPropString;
TDIPropString = packed record
TDIPropString = record
diph: TDIPropHeader;
wsz: array [0..MAX_PATH-1] of WideChar;
wsz: array[0..MAX_PATH-1] of WCHAR;
end;
 
type
MAKEDIPROP = PGUID;
DIPROPSTRING = TDIPropString;
LPDIPROPSTRING = PDIPropString;
 
const
DIPROP_BUFFERSIZE = MAKEDIPROP(1);
DIPROPRANGE_NOMIN = $80000000;
DIPROPRANGE_NOMAX = $7FFFFFFF;
 
DIPROP_AXISMODE = MAKEDIPROP(2);
DIPROP_BUFFERSIZE = PGUID(1);
DIPROP_AXISMODE = PGUID(2);
 
DIPROPAXISMODE_ABS = 0;
DIPROPAXISMODE_REL = 1;
 
DIPROP_GRANULARITY = MAKEDIPROP(3);
DIPROP_GRANULARITY = PGUID(3);
DIPROP_RANGE = PGUID(4);
DIPROP_DEADZONE = PGUID(5);
DIPROP_SATURATION = PGUID(6);
DIPROP_FFGAIN = PGUID(7);
DIPROP_FFLOAD = PGUID(8);
DIPROP_AUTOCENTER = PGUID(9);
 
DIPROP_RANGE = MAKEDIPROP(4);
 
DIPROP_DEADZONE = MAKEDIPROP(5);
 
DIPROP_SATURATION = MAKEDIPROP(6);
 
DIPROP_FFGAIN = MAKEDIPROP(7);
 
DIPROP_FFLOAD = MAKEDIPROP(8);
 
DIPROP_AUTOCENTER = MAKEDIPROP(9);
 
DIPROPAUTOCENTER_OFF = 0;
DIPROPAUTOCENTER_ON = 1;
 
DIPROP_CALIBRATIONMODE = MAKEDIPROP(10);
DIPROP_CALIBRATIONMODE = PGUID(10);
 
DIPROPCALIBRATIONMODE_COOKED = 0;
DIPROPCALIBRATIONMODE_RAW = 1;
 
DIPROP_CALIBRATION = MAKEDIPROP(11);
DIPROP_CALIBRATION = PGUID(11);
DIPROP_GUIDANDPATH = PGUID(12);
DIPROP_INSTANCENAME = PGUID(13);
DIPROP_PRODUCTNAME = PGUID(14);
DIPROP_JOYSTICKID = PGUID(15);
DIPROP_GETPORTDISPLAYNAME = PGUID(16);
DIPROP_ENABLEREPORTID = PGUID(17);
DIPROP_GETPHYSICALRANGE = PGUID(18);
DIPROP_GETLOGICALRANGE = PGUID(19);
 
DIPROP_GUIDANDPATH = MAKEDIPROP(12);
 
DIPROP_INSTANCENAME = MAKEDIPROP(13);
 
DIPROP_PRODUCTNAME = MAKEDIPROP(14);
 
DIPROP_JOYSTICKID = MAKEDIPROP(15);
 
DIPROP_GETPORTDISPLAYNAME = MAKEDIPROP(16);
 
 
DIPROP_ENABLEREPORTID = MAKEDIPROP(17);
 
 
DIPROP_GETPHYSICALRANGE = MAKEDIPROP(18);
 
DIPROP_GETLOGICALRANGE = MAKEDIPROP(19);
 
 
type
PDIDeviceObjectData = ^TDIDeviceObjectData;
TDIDeviceObjectData = packed record
TDIDeviceObjectData = record
dwOfs: DWORD;
dwData: DWORD;
dwTimeStamp: DWORD;
12654,12 → 9011,11
dwSequence: DWORD;
end;
 
DIDEVICEOBJECTDATA = TDIDeviceObjectData;
LPDIDEVICEOBJECTDATA = PDIDeviceObjectData;
 
const
DIGDD_PEEK = $00000001;
{
#define DISEQUENCE_COMPARE(dwSequence1, cmp, dwSequence2) \
(int) ((dwSequence1) - (dwSequence2)) cmp 0
}
 
DISCL_EXCLUSIVE = $00000001;
DISCL_NONEXCLUSIVE = $00000002;
12667,137 → 9023,140
DISCL_BACKGROUND = $00000008;
DISCL_NOWINKEY = $00000010;
 
 
type
 
PDIDeviceInstance_DX3A = ^TDIDeviceInstance_DX3A;
TDIDeviceInstance_DX3A = packed record
PDIDeviceInstanceA_DX3 = ^TDIDeviceInstanceA_DX3;
TDIDeviceInstanceA_DX3 = record
dwSize: DWORD;
guidInstance: TGUID;
guidProduct: TGUID;
dwDevType: DWORD;
tszInstanceName: Array [0..MAX_PATH-1] of AnsiChar;
tszProductName: Array [0..MAX_PATH-1] of AnsiChar;
tszInstanceName: array[0..MAX_PATH-1] of CHAR;
tszProductName: array[0..MAX_PATH-1] of CHAR;
end;
 
PDIDeviceInstance_DX3W = ^TDIDeviceInstance_DX3W;
TDIDeviceInstance_DX3W = packed record
PDIDeviceInstanceA_DX5 = ^TDIDeviceInstanceA_DX5;
TDIDeviceInstanceA_DX5 = record
dwSize: DWORD;
guidInstance: TGUID;
guidProduct: TGUID;
dwDevType: DWORD;
tszInstanceName: Array [0..MAX_PATH-1] of WideChar;
tszProductName: Array [0..MAX_PATH-1] of WideChar;
tszInstanceName: array[0..MAX_PATH-1] of CHAR;
tszProductName: array[0..MAX_PATH-1] of CHAR;
guidFFDriver: TGUID;
wUsagePage: WORD;
wUsage: WORD;
end;
 
PDIDeviceInstance_DX3 = ^TDIDeviceInstance_DX3;
{$IFDEF UNICODE}
TDIDeviceInstance_DX3 = TDIDeviceInstance_DX3W;
{$ELSE}
TDIDeviceInstance_DX3 = TDIDeviceInstance_DX3A;
{$IFDEF DirectX3}
TDIDeviceInstanceA = TDIDeviceInstanceA_DX3;
PDIDeviceInstanceA = PDIDeviceInstanceA_DX3;
{$ENDIF}{$IFDEF DirectX5}
TDIDeviceInstanceA = TDIDeviceInstanceA_DX5;
PDIDeviceInstanceA = PDIDeviceInstanceA_DX5;
{$ENDIF}{$IFDEF DirectX6}
TDIDeviceInstanceA = TDIDeviceInstanceA_DX5;
PDIDeviceInstanceA = PDIDeviceInstanceA_DX5;
{$ENDIF}{$IFDEF DirectX7}
TDIDeviceInstanceA = TDIDeviceInstanceA_DX5;
PDIDeviceInstanceA = PDIDeviceInstanceA_DX5;
{$ENDIF}
 
PDIDeviceInstance_DX5A = ^TDIDeviceInstance_DX5A;
TDIDeviceInstance_DX5A = packed record
DIDEVICEINSTANCEA = TDIDeviceInstanceA;
LPDIDEVICEINSTANCEA = PDIDeviceInstanceA;
 
PDIDeviceInstanceW_DX3 = ^TDIDeviceInstanceW_DX3;
TDIDeviceInstanceW_DX3 = record
dwSize: DWORD;
guidInstance: TGUID;
guidProduct: TGUID;
dwDevType: DWORD;
tszInstanceName: Array [0..MAX_PATH-1] of AnsiChar;
tszProductName: Array [0..MAX_PATH-1] of AnsiChar;
guidFFDriver: TGUID;
wUsagePage: WORD;
wUsage: WORD;
tszInstanceName: array[0..MAX_PATH-1] of WCHAR;
tszProductName: array[0..MAX_PATH-1] of WCHAR;
end;
 
PDIDeviceInstance_DX5W = ^TDIDeviceInstance_DX5W;
TDIDeviceInstance_DX5W = packed record
PDIDeviceInstanceW_DX5 = ^TDIDeviceInstanceW_DX5;
TDIDeviceInstanceW_DX5 = record
dwSize: DWORD;
guidInstance: TGUID;
guidProduct: TGUID;
dwDevType: DWORD;
tszInstanceName: Array [0..MAX_PATH-1] of WideChar;
tszProductName: Array [0..MAX_PATH-1] of WideChar;
tszInstanceName: array[0..MAX_PATH-1] of WCHAR;
tszProductName: array[0..MAX_PATH-1] of WCHAR;
guidFFDriver: TGUID;
wUsagePage: WORD;
wUsage: WORD;
end;
 
PDIDeviceInstance_DX5 = ^TDIDeviceInstance_DX5;
{$IFDEF UNICODE}
TDIDeviceInstance_DX5 = TDIDeviceInstance_DX5W;
{$ELSE}
TDIDeviceInstance_DX5 = TDIDeviceInstance_DX5A;
{$IFDEF DirectX3}
TDIDeviceInstanceW = TDIDeviceInstanceW_DX3;
PDIDeviceInstanceW = PDIDeviceInstanceW_DX3;
{$ENDIF}{$IFDEF DirectX5}
TDIDeviceInstanceW = TDIDeviceInstanceW_DX5;
PDIDeviceInstanceW = PDIDeviceInstanceW_DX5;
{$ENDIF}{$IFDEF DirectX6}
TDIDeviceInstanceW = TDIDeviceInstanceW_DX5;
PDIDeviceInstanceW = PDIDeviceInstanceW_DX5;
{$ENDIF}{$IFDEF DirectX7}
TDIDeviceInstanceW = TDIDeviceInstanceW_DX5;
PDIDeviceInstanceW = PDIDeviceInstanceW_DX5;
{$ENDIF}
 
PDIDeviceInstanceA = ^TDIDeviceInstanceA;
PDIDeviceInstanceW = ^TDIDeviceInstanceW;
PDIDeviceInstance = ^TDIDeviceInstance;
{$IFDEF DIRECTX3}
TDIDeviceInstanceA = TDIDeviceInstance_DX3A;
TDIDeviceInstanceW = TDIDeviceInstance_DX3W;
TDIDeviceInstance = TDIDeviceInstance_DX3;
{$ELSE}
TDIDeviceInstanceA = TDIDeviceInstance_DX5A;
TDIDeviceInstanceW = TDIDeviceInstance_DX5W;
TDIDeviceInstance = TDIDeviceInstance_DX5;
{$ENDIF}
DIDEVICEINSTANCEW = TDIDeviceInstanceW;
LPDIDEVICEINSTANCEW = PDIDeviceInstanceW;
 
IDirectInputDeviceA = interface (IUnknown)
['{5944E680-C92E-11CF-BFC7-444553540000}']
(*** IDirectInputDeviceA methods ***)
TDIDeviceInstance = TDIDeviceInstanceA;
PDIDeviceInstance = PDIDeviceInstanceA;
 
DIDEVICEINSTANCE = TDIDeviceInstance;
LPDIDEVICEINSTANCE = PDIDeviceInstance;
 
IDirectInputDeviceW = interface(IUnknown)
['{5944E681-C92E-11CF-BFC7-444553540000}']
// IDirectInputDeviceW methods
function GetCapabilities(var lpDIDevCaps: TDIDevCaps) : HResult; stdcall;
function EnumObjects(lpCallback: TDIEnumDeviceObjectsCallbackA;
function EnumObjects(lpCallback: TDIEnumDeviceObjectsCallbackW;
pvRef: Pointer; dwFlags: DWORD) : HResult; stdcall;
function GetProperty(rguidProp: PGUID; var pdiph: TDIPropHeader) :
HResult; stdcall;
function SetProperty(rguidProp: PGUID; const pdiph: TDIPropHeader) :
HResult; stdcall;
function GetProperty(rguidProp: PGUID; var pdiph: TDIPropHeader): HResult; stdcall;
function SetProperty(rguidProp: PGUID; const pdiph: TDIPropHeader): HResult; stdcall;
function Acquire : HResult; stdcall;
function Unacquire : HResult; stdcall;
function GetDeviceState(cbData: DWORD; lpvData: Pointer) : HResult; stdcall;
function GetDeviceData(cbObjectData: DWORD; rgdod: PDIDeviceObjectData;
function GetDeviceState(cbData: DWORD; var lpvData): HResult; stdcall;
function GetDeviceData(cbObjectData: DWORD; var rgdod: TDIDeviceObjectData;
var pdwInOut: DWORD; dwFlags: DWORD) : HResult; stdcall;
function SetDataFormat(var lpdf: TDIDataFormat) : HResult; stdcall;
function SetDataFormat(const lpdf: TDIDataFormat): HResult; stdcall;
function SetEventNotification(hEvent: THandle) : HResult; stdcall;
function SetCooperativeLevel(hwnd: HWND; dwFlags: DWORD) : HResult; stdcall;
function GetObjectInfo(var pdidoi: TDIDeviceObjectInstanceA; dwObj: DWORD;
function GetObjectInfo(var pdidoi: TDIDeviceObjectInstanceW; dwObj: DWORD;
dwHow: DWORD) : HResult; stdcall;
function GetDeviceInfo(var pdidi: TDIDeviceInstanceA) : HResult; stdcall;
function GetDeviceInfo(var pdidi: TDIDeviceInstanceW): HResult; stdcall;
function RunControlPanel(hwndOwner: HWND; dwFlags: DWORD) : HResult; stdcall;
function Initialize(hinst: THandle; dwVersion: DWORD; const rguid: TGUID) : HResult; stdcall;
end;
 
IDirectInputDeviceW = interface (IUnknown)
['{5944E681-C92E-11CF-BFC7-444553540000}']
(*** IDirectInputDeviceW methods ***)
IDirectInputDeviceA = interface(IUnknown)
['{5944E680-C92E-11CF-BFC7-444553540000}']
// IDirectInputDeviceA methods
function GetCapabilities(var lpDIDevCaps: TDIDevCaps) : HResult; stdcall;
function EnumObjects(lpCallback: TDIEnumDeviceObjectsCallbackW;
function EnumObjects(lpCallback: TDIEnumDeviceObjectsCallbackA;
pvRef: Pointer; dwFlags: DWORD) : HResult; stdcall;
function GetProperty(rguidProp: PGUID; var pdiph: TDIPropHeader) :
HResult; stdcall;
function SetProperty(rguidProp: PGUID; var pdiph: TDIPropHeader) :
HResult; stdcall;
function GetProperty(rguidProp: PGUID; var pdiph: TDIPropHeader): HResult; stdcall;
function SetProperty(rguidProp: PGUID; const pdiph: TDIPropHeader): HResult; stdcall;
function Acquire : HResult; stdcall;
function Unacquire : HResult; stdcall;
function GetDeviceState(cbData: DWORD; lpvData: Pointer) : HResult; stdcall;
function GetDeviceData(cbObjectData: DWORD; rgdod: PDIDeviceObjectData;
function GetDeviceState(cbData: DWORD; var lpvData): HResult; stdcall;
function GetDeviceData(cbObjectData: DWORD; var rgdod: TDIDeviceObjectData;
var pdwInOut: DWORD; dwFlags: DWORD) : HResult; stdcall;
function SetDataFormat(var lpdf: TDIDataFormat) : HResult; stdcall;
function SetDataFormat(const lpdf: TDIDataFormat): HResult; stdcall;
function SetEventNotification(hEvent: THandle) : HResult; stdcall;
function SetCooperativeLevel(hwnd: HWND; dwFlags: DWORD) : HResult; stdcall;
function GetObjectInfo(var pdidoi: TDIDeviceObjectInstanceW; dwObj: DWORD;
function GetObjectInfo(var pdidoi: TDIDeviceObjectInstanceA; dwObj: DWORD;
dwHow: DWORD) : HResult; stdcall;
function GetDeviceInfo(var pdidi: TDIDeviceInstanceW) : HResult; stdcall;
function GetDeviceInfo(var pdidi: TDIDeviceInstanceA): HResult; stdcall;
function RunControlPanel(hwndOwner: HWND; dwFlags: DWORD) : HResult; stdcall;
function Initialize(hinst: THandle; dwVersion: DWORD; const rguid: TGUID) : HResult; stdcall;
end;
 
{$IFDEF UNICODE}
IDirectInputDevice = IDirectInputDeviceW;
{$ELSE}
IDirectInputDevice = IDirectInputDeviceA;
{$ENDIF}
 
const
DISFFC_RESET = $00000001;
12820,9 → 9179,15
DIGFFS_USERFFSWITCHOFF = $00000800;
DIGFFS_DEVICELOST = $80000000;
 
DISDD_CONTINUE = 1;
 
DIFEF_DEFAULT = $00000000;
DIFEF_INCLUDENONSTANDARD = $00000001;
DIFEF_MODIFYIFNEEDED = $00000010;
 
type
PDIEffectInfoA = ^TDIEffectInfoA;
TDIEffectInfoA = packed record
TDIEffectInfoA = record
dwSize : DWORD;
guid : TGUID;
dwEffType : DWORD;
12831,8 → 9196,11
tszName : array [0..MAX_PATH-1] of CHAR;
end;
 
DIEFFECTINFOA = TDIEffectInfoA;
LPDIEFFECTINFOA = PDIEffectInfoA;
 
PDIEffectInfoW = ^TDIEffectInfoW;
TDIEffectInfoW = packed record
TDIEffectInfoW = record
dwSize : DWORD;
guid : TGUID;
dwEffType : DWORD;
12841,255 → 9209,142
tszName : array [0..MAX_PATH-1] of WCHAR;
end;
 
PDIEffectInfo = ^TDIEffectInfo;
{$IFDEF UNICODE}
TDIEffectInfo = TDIEffectInfoW;
{$ELSE}
TDIEffectInfo = TDIEffectInfoA;
{$ENDIF}
DIEFFECTINFOW = TDIEffectInfoW;
LPDIEFFECTINFOW = PDIEffectInfoW;
 
const
DISDD_CONTINUE = $00000001;
DIEFFECTINFO = TDIEffectInfoA;
LPDIEFFECTINFO = PDIEffectInfoA;
 
// Bug fix & deviation from the SDK: Must return DIENUM_STOP or
// DIENUM_CONTINUE (=1) in order to work with the debug version of DINPUT.DLL
type
TDIEnumEffectsCallbackA =
function(var pdei: TDIEffectInfoA; pvRef: pointer): Integer; stdcall; // BOOL; stdcall;
TDIEnumEffectsCallbackW =
function(var pdei: TDIEffectInfoW; pvRef: pointer): Integer; stdcall; // BOOL; stdcall;
TDIEnumEffectsCallback =
function(var pdei: TDIEffectInfo; pvRef: pointer) : Integer; stdcall; // BOOL; stdcall;
TDIEnumEffectsProc = TDIEnumEffectsCallback;
TDIEnumEffectsCallbackA = function(const pdei: TDIEffectInfoA;
pvRef: Pointer): HResult; stdcall;
LPDIENUMEFFECTSCALLBACKA = TDIEnumEffectsCallbackA;
 
TDIEnumCreatedEffectObjectsCallback =
function(peff: IDirectInputEffect; pvRev: pointer): Integer; stdcall; // BOOL; stdcall;
TDIEnumCreatedEffectObjectsProc = TDIEnumCreatedEffectObjectsCallback;
TDIEnumEffectsCallbackW = function(const pdei: TDIEffectInfoW;
pvRef: Pointer): HResult; stdcall;
LPDIENUMEFFECTSCALLBACKW = TDIEnumEffectsCallbackW;
 
IDirectInputDevice2A = interface (IDirectInputDeviceA)
['{5944E682-C92E-11CF-BFC7-444553540000}']
(*** IDirectInputDevice2A methods ***)
function CreateEffect(const rguid: TGUID; lpeff: PDIEffect;
var ppdeff: IDirectInputEffect; punkOuter: IUnknown) : HResult; stdcall;
function EnumEffects(lpCallback: TDIEnumEffectsCallbackA;
pvRef: pointer; dwEffType: DWORD) : HResult; stdcall;
function GetEffectInfo(pdei: TDIEffectInfoA; const rguid: TGUID) : HResult; stdcall;
TDIEnumEffectsCallback = TDIEnumEffectsCallbackA;
LPDIENUMEFFECTSCALLBACK = TDIEnumEffectsCallback;
 
LPDIENUMCREATEDEFFECTOBJECTSCALLBACK = function(const peff:
IDirectInputEffect; pvRef: Pointer): HResult; stdcall;
 
IDirectInputDevice2W = interface(IDirectInputDeviceW)
['{5944E683-C92E-11CF-BFC7-444553540000}']
// IDirectInputDevice2W methods
function CreateEffect(const rguid: TGUID; const lpeff: TDIEffect;
out ppdeff: IDirectInputEffect; punkOuter: IUnknown): HResult; stdcall;
function EnumEffects(lpCallback: TDIEnumEffectsCallbackW; pvRef: Pointer;
dwEffType: DWORD): HResult; stdcall;
function GetEffectInfo(var pdei: TDIEffectInfoW; const rguid: TGUID): HResult; stdcall;
function GetForceFeedbackState(var pdwOut: DWORD) : HResult; stdcall;
function SendForceFeedbackCommand(dwFlags: DWORD) : HResult; stdcall;
function EnumCreatedEffectObjects(lpCallback:
TDIEnumCreatedEffectObjectsCallback;
pvRef: pointer; fl: DWORD) : HResult; stdcall;
function Escape(var pesc: TDIEffEscape) : HResult; stdcall;
LPDIENUMCREATEDEFFECTOBJECTSCALLBACK; pvRef: Pointer; fl: DWORD): HResult; stdcall;
function Escape(const pesc: TDIEffEscape): HResult; stdcall;
function Poll : HResult; stdcall;
function SendDeviceData
(cbObjectData: DWORD; var rgdod: TDIDeviceObjectData;
function SendDeviceData(cbObjectData: DWORD; const rgdod: TDIDeviceObjectData;
var pdwInOut: DWORD; fl: DWORD) : HResult; stdcall;
end;
 
IDirectInputDevice2W = interface (IDirectInputDeviceW)
['{5944E683-C92E-11CF-BFC7-444553540000}']
(*** IDirectInputDevice2W methods ***)
function CreateEffect(const rguid: TGUID; lpeff: PDIEffect;
var ppdeff: IDirectInputEffect; punkOuter: IUnknown) : HResult; stdcall;
function EnumEffects(lpCallback: TDIEnumEffectsCallbackW;
pvRef: pointer; dwEffType: DWORD) : HResult; stdcall;
function GetEffectInfo(pdei: TDIEffectInfoW; const rguid: TGUID) : HResult; stdcall;
IDirectInputDevice2A = interface(IDirectInputDeviceA)
['{5944E682-C92E-11CF-BFC7-444553540000}']
// IDirectInputDevice2A methods
function CreateEffect(const rguid: TGUID; const lpeff: TDIEffect;
out ppdeff: IDirectInputEffect; punkOuter: IUnknown): HResult; stdcall;
function EnumEffects(lpCallback: TDIEnumEffectsCallbackA; pvRef: Pointer;
dwEffType: DWORD): HResult; stdcall;
function GetEffectInfo(var pdei: TDIEffectInfoA; const rguid: TGUID): HResult; stdcall;
function GetForceFeedbackState(var pdwOut: DWORD) : HResult; stdcall;
function SendForceFeedbackCommand(dwFlags: DWORD) : HResult; stdcall;
function EnumCreatedEffectObjects(lpCallback:
TDIEnumCreatedEffectObjectsCallback;
pvRef: pointer; fl: DWORD) : HResult; stdcall;
function Escape(var pesc: TDIEffEscape) : HResult; stdcall;
LPDIENUMCREATEDEFFECTOBJECTSCALLBACK; pvRef: Pointer; fl: DWORD): HResult; stdcall;
function Escape(const pesc: TDIEffEscape): HResult; stdcall;
function Poll : HResult; stdcall;
function SendDeviceData
(cbObjectData: DWORD; var rgdod: TDIDeviceObjectData;
function SendDeviceData(cbObjectData: DWORD; const rgdod: TDIDeviceObjectData;
var pdwInOut: DWORD; fl: DWORD) : HResult; stdcall;
end;
 
{$IFDEF UNICODE}
IDirectInputDevice2 = IDirectInputDevice2W;
{$ELSE}
IDirectInputDevice2 = IDirectInputDevice2A;
{$ENDIF}
 
const
DIFEF_DEFAULT = $00000000;
DIFEF_INCLUDENONSTANDARD = $00000001;
DIFEF_MODIFYIFNEEDED = $00000010;
 
///Weitermachen: (as: nur die Deklarationen eingefüllt, die ich zum Testen gebraucht habe)
 
type
TEnumEffectsInFileCallback = function(gaga, huhu: Integer): HResult;
 
type
IDirectInputDevice7W = interface (IDirectInputDevice2W)
['{57D7C6BD-2356-11D3-8E9D-00C04F6844AE}']
(*** IDirectInputDevice7A methods ***)
function EnumEffectsInFile(const lpszFileName: PChar;
pec: TEnumEffectsInFileCallback; pvRef: Pointer; dwFlags: DWord): HResult; stdcall;
function WriteEffectToFile(const lpszFileName: PChar;
dwEntries: DWord; const rgDIFileEft: PDIFileEffect; dwFlags: DWord): HResult; stdcall;
['{57D7C6BC-2356-11D3-8E9D-00C04F6844AE}']
// IDirectInputDevice7W methods
function EnumEffectsInFile(lpszFileName: LPCWSTR; pec: TDIEnumEffectsInFileCallback;
pvRef: Pointer; dwFlags: DWORD): HResult; stdcall;
function WriteEffectToFile(lpszFileName: LPCWSTR; dwEntries: DWORD;
const rgDiFileEft: TDIFileEffect; dwFlags: DWORD): HResult; stdcall;
end;
 
IDirectInputDevice7A = interface (IDirectInputDevice2A)
['{57D7C6BC-2356-11D3-8E9D-00C04F6844AE}']
function EnumEffectsInFile(const lpszFileName: PChar;
pec: TEnumEffectsInFileCallback; pvRef: Pointer; dwFlags: DWord): HResult; stdcall;
function WriteEffectToFile(const lpszFileName: PChar;
dwEntries: DWord; const rgDIFileEft: PDIFileEffect; dwFlags: DWord): HResult; stdcall;
['{57D7C6BD-2356-11D3-8E9D-00C04F6844AE}']
// IDirectInputDevice7A methods
function EnumEffectsInFile(lpszFileName: LPCSTR; pec: TDIEnumEffectsInFileCallback;
pvRef: Pointer; dwFlags: DWORD): HResult; stdcall;
function WriteEffectToFile(lpszFileName: LPCSTR; dwEntries: DWORD;
const rgDiFileEft: TDIFileEffect; dwFlags: DWORD): HResult; stdcall;
end;
 
{$IFDEF UNICODE}
IDirectInputDevice7 = IDirectInputDevice7W;
{$ELSE}
IDirectInputDevice7 = IDirectInputDevice7A;
{$ENDIF}
 
(****************************************************************************
*
* Mouse
*
****************************************************************************)
{ Mouse }
 
type
PDIMouseState = ^TDIMouseState;
TDIMouseState = packed record
TDIMouseState = record
lX: Longint;
lY: Longint;
lZ: Longint;
rgbButtons: Array [0..3] of BYTE; // up to 4 buttons
rgbButtons: array[0..3] of BYTE;
end;
 
PDIMouseState2 = ^TDIMouseState2;
TDIMouseState2 = packed record
DIMOUSESTATE = TDIMouseState;
 
TDIMouseState2 = record
lX: Longint;
lY: Longint;
lZ: Longint;
rgbButtons: Array [0..7] of BYTE; // up to 8 buttons
rgbButtons: array[0..7] of BYTE;
end;
 
const
DIMOFS_X = 0;
DIMOFS_Y = 4;
DIMOFS_Z = 8;
DIMOFS_BUTTON0 = 12;
DIMOFS_BUTTON1 = 13;
DIMOFS_BUTTON2 = 14;
DIMOFS_BUTTON3 = 15;
// DX7 supports up to 8 mouse buttons
DIMOFS_BUTTON4 = DIMOFS_BUTTON0+4;
DIMOFS_BUTTON5 = DIMOFS_BUTTON0+5;
DIMOFS_BUTTON6 = DIMOFS_BUTTON0+6;
DIMOFS_BUTTON7 = DIMOFS_BUTTON0+7;
DIMOUSESTATE2 = TDIMouseState2;
 
 
const
_c_dfDIMouse_Objects: array[0..6] of TDIObjectDataFormat = (
( pguid: @GUID_XAxis;
dwOfs: DIMOFS_X;
dwType: DIDFT_AXIS or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_YAxis;
dwOfs: DIMOFS_Y;
dwType: DIDFT_AXIS or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_ZAxis;
dwOfs: DIMOFS_Z;
dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON0;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON1;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON2;
dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON3;
dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0)
_c_dfDIMouse_Objects: array[0..1] of TDIObjectDataFormat = (
(pguid: nil; dwOfs: 0; dwType: DIDFT_RELAXIS or DIDFT_ANYINSTANCE; dwFlags: 0),
(pguid: @GUID_Button; dwOfs: 12; dwType: DIDFT_BUTTON or DIDFT_ANYINSTANCE; dwFlags: 0)
);
 
c_dfDIMouse: TDIDataFormat = (
dwSize: Sizeof(c_dfDIMouse); // $18
dwObjSize: Sizeof(TDIObjectDataFormat); // $10
dwFlags: DIDF_RELAXIS; //
dwDataSize: Sizeof(TDIMouseState); // $10
dwNumObjs: High(_c_dfDIMouse_Objects)+1; // 7
rgodf: @_c_dfDIMouse_Objects[Low(_c_dfDIMouse_Objects)]
dwSize: Sizeof(c_dfDIMouse);
dwObjSize: Sizeof(TDIObjectDataFormat);
dwFlags: DIDF_RELAXIS;
dwDataSize: Sizeof(TDIMouseState);
dwNumObjs: High(_c_dfDIMouse_Objects)+1;
rgodf: @_c_dfDIMouse_Objects
);
 
{ Keyboard }
 
_c_dfDIMouse2_Objects: array[0..10] of TDIObjectDataFormat = (
( pguid: @GUID_XAxis;
dwOfs: DIMOFS_X;
dwType: DIDFT_AXIS or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_YAxis;
dwOfs: DIMOFS_Y;
dwType: DIDFT_AXIS or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_ZAxis;
dwOfs: DIMOFS_Z;
dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON0;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON1;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON2;
dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON3;
dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// fields introduced with IDirectInputDevice7.GetDeviceState
( pguid: nil;
dwOfs: DIMOFS_BUTTON4;
dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON5;
dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON6;
dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: nil;
dwOfs: DIMOFS_BUTTON7;
dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0)
type
TDIKeyboardState = array[0..255] of Byte;
DIKEYBOARDSTATE = TDIKeyboardState;
 
const
_c_dfDIKeyboard_Objects: array[0..0] of TDIObjectDataFormat = (
(pguid: @GUID_Key; dwOfs: 1; dwType: DIDFT_BUTTON or DIDFT_ANYINSTANCE; dwFlags: 0)
);
 
c_dfDIMouse2: TDIDataFormat = (
dwSize: Sizeof(c_dfDIMouse); // $18
dwObjSize: Sizeof(TDIObjectDataFormat); // $10
dwFlags: DIDF_RELAXIS; //
dwDataSize: Sizeof(TDIMouseState2); // $14
dwNumObjs: High(_c_dfDIMouse_Objects)+1; // 11
rgodf: @_c_dfDIMouse2_Objects[Low(_c_dfDIMouse2_Objects)]
c_dfDIKeyboard: TDIDataFormat = (
dwSize: Sizeof(c_dfDIKeyboard);
dwObjSize: Sizeof(TDIObjectDataFormat);
dwFlags: 0;
dwDataSize: SizeOf(TDIKeyboardState);
dwNumObjs: High(_c_dfDIKeyboard_Objects)+1;
rgodf: @_c_dfDIKeyboard_Objects
);
 
{ DirectInput keyboard scan codes }
 
(****************************************************************************
*
* DirectInput keyboard scan codes
*
****************************************************************************)
 
const
DIK_ESCAPE = $01;
DIK_1 = $02;
13102,9 → 9357,9
DIK_8 = $09;
DIK_9 = $0A;
DIK_0 = $0B;
DIK_MINUS = $0C; (* - on main keyboard *)
DIK_MINUS = $0C; // - on main keyboard
DIK_EQUALS = $0D;
DIK_BACK = $0E; (* backspace *)
DIK_BACK = $0E; // backspace
DIK_TAB = $0F;
DIK_Q = $10;
DIK_W = $11;
13118,7 → 9373,7
DIK_P = $19;
DIK_LBRACKET = $1A;
DIK_RBRACKET = $1B;
DIK_RETURN = $1C; (* Enter on main keyboard *)
DIK_RETURN = $1C; // Enter on main keyboard
DIK_LCONTROL = $1D;
DIK_A = $1E;
DIK_S = $1F;
13131,7 → 9386,7
DIK_L = $26;
DIK_SEMICOLON = $27;
DIK_APOSTROPHE = $28;
DIK_GRAVE = $29; (* accent grave *)
DIK_GRAVE = $29; // accent grave
DIK_LSHIFT = $2A;
DIK_BACKSLASH = $2B;
DIK_Z = $2C;
13142,11 → 9397,11
DIK_N = $31;
DIK_M = $32;
DIK_COMMA = $33;
DIK_PERIOD = $34; (* . on main keyboard *)
DIK_SLASH = $35; (* / on main keyboard *)
DIK_PERIOD = $34; // . on main keyboard
DIK_SLASH = $35; // / on main keyboard
DIK_RSHIFT = $36;
DIK_MULTIPLY = $37; (* * on numeric keypad *)
DIK_LMENU = $38; (* left Alt *)
DIK_MULTIPLY = $37; // * on numeric keypad
DIK_LMENU = $38; // left Alt
DIK_SPACE = $39;
DIK_CAPITAL = $3A;
DIK_F1 = $3B;
13160,677 → 9415,154
DIK_F9 = $43;
DIK_F10 = $44;
DIK_NUMLOCK = $45;
DIK_SCROLL = $46; (* Scroll Lock *)
DIK_SCROLL = $46; // Scroll Lock
DIK_NUMPAD7 = $47;
DIK_NUMPAD8 = $48;
DIK_NUMPAD9 = $49;
DIK_SUBTRACT = $4A; (* - on numeric keypad *)
DIK_SUBTRACT = $4A; // - on numeric keypad
DIK_NUMPAD4 = $4B;
DIK_NUMPAD5 = $4C;
DIK_NUMPAD6 = $4D;
DIK_ADD = $4E; (* + on numeric keypad *)
DIK_ADD = $4E; // + on numeric keypad
DIK_NUMPAD1 = $4F;
DIK_NUMPAD2 = $50;
DIK_NUMPAD3 = $51;
DIK_NUMPAD0 = $52;
DIK_DECIMAL = $53; (* . on numeric keypad *)
// $54 to $56 unassigned
DIK_DECIMAL = $53; // . on numeric keypad
DIK_F11 = $57;
DIK_F12 = $58;
// $59 to $63 unassigned
DIK_F13 = $64; (* (NEC PC98) *)
DIK_F14 = $65; (* (NEC PC98) *)
DIK_F15 = $66; (* (NEC PC98) *)
// $67 to $6F unassigned
DIK_KANA = $70; (* (Japanese keyboard) *)
DIK_CONVERT = $79; (* (Japanese keyboard) *)
DIK_NOCONVERT = $7B; (* (Japanese keyboard) *)
DIK_YEN = $7D; (* (Japanese keyboard) *)
DIK_NUMPADEQUALS = $8D; (* = on numeric keypad (NEC PC98) *)
// $8E to $8F unassigned
DIK_CIRCUMFLEX = $90; (* (Japanese keyboard) *)
DIK_AT = $91; (* (NEC PC98) *)
DIK_COLON = $92; (* (NEC PC98) *)
DIK_UNDERLINE = $93; (* (NEC PC98) *)
DIK_KANJI = $94; (* (Japanese keyboard) *)
DIK_STOP = $95; (* (NEC PC98) *)
DIK_AX = $96; (* (Japan AX) *)
DIK_UNLABELED = $97; (* (J3100) *)
// $98 to $99 unassigned
DIK_NUMPADENTER = $9C; (* Enter on numeric keypad *)
 
DIK_F13 = $64; // (NEC PC98)
DIK_F14 = $65; // (NEC PC98)
DIK_F15 = $66; // (NEC PC98)
 
DIK_KANA = $70; // (Japanese keyboard)
DIK_CONVERT = $79; // (Japanese keyboard)
DIK_NOCONVERT = $7B; // (Japanese keyboard)
DIK_YEN = $7D; // (Japanese keyboard)
DIK_NUMPADEQUALS = $8D; // = on numeric keypad (NEC PC98)
DIK_CIRCUMFLEX = $90; // (Japanese keyboard)
DIK_AT = $91; // (NEC PC98)
DIK_COLON = $92; // (NEC PC98)
DIK_UNDERLINE = $93; // (NEC PC98)
DIK_KANJI = $94; // (Japanese keyboard)
DIK_STOP = $95; // (NEC PC98)
DIK_AX = $96; // (Japan AX)
DIK_UNLABELED = $97; // (J3100)
DIK_NUMPADENTER = $9C; // Enter on numeric keypad
DIK_RCONTROL = $9D;
// $9E to $B2 unassigned
DIK_NUMPADCOMMA = $B3; (* , on numeric keypad (NEC PC98) *)
// $B4 unassigned
DIK_DIVIDE = $B5; (* / on numeric keypad *)
// $B6 unassigned
DIK_NUMPADCOMMA = $B3; // , on numeric keypad (NEC PC98)
DIK_DIVIDE = $B5; // / on numeric keypad
DIK_SYSRQ = $B7;
DIK_RMENU = $B8; (* right Alt *)
// $B9 to $C4 unassigned
DIK_PAUSE = $C5; (* Pause (watch out - not realiable on some kbds) *)
// $C6 unassigned
DIK_HOME = $C7; (* Home on arrow keypad *)
DIK_UP = $C8; (* UpArrow on arrow keypad *)
DIK_PRIOR = $C9; (* PgUp on arrow keypad *)
// $CA unassigned
DIK_LEFT = $CB; (* LeftArrow on arrow keypad *)
DIK_RIGHT = $CD; (* RightArrow on arrow keypad *)
// $CF unassigned
DIK_END = $CF; (* End on arrow keypad *)
DIK_DOWN = $D0; (* DownArrow on arrow keypad *)
DIK_NEXT = $D1; (* PgDn on arrow keypad *)
DIK_INSERT = $D2; (* Insert on arrow keypad *)
DIK_DELETE = $D3; (* Delete on arrow keypad *)
DIK_LWIN = $DB; (* Left Windows key *)
DIK_RWIN = $DC; (* Right Windows key *)
DIK_APPS = $DD; (* AppMenu key *)
// New with DX 6.1 & Win98
DIK_POWER = $DE;
DIK_SLEEP = $DF;
// $E0 to $E2 unassigned
// $E3 = Wake up ("translated" in German DInput to "Kielwasser" (ship's wake) ;-)
DIK_RMENU = $B8; // right Alt
DIK_HOME = $C7; // Home on arrow keypad
DIK_UP = $C8; // UpArrow on arrow keypad
DIK_PRIOR = $C9; // PgUp on arrow keypad
DIK_LEFT = $CB; // LeftArrow on arrow keypad
DIK_RIGHT = $CD; // RightArrow on arrow keypad
DIK_END = $CF; // End on arrow keypad
DIK_DOWN = $D0; // DownArrow on arrow keypad
DIK_NEXT = $D1; // PgDn on arrow keypad
DIK_INSERT = $D2; // Insert on arrow keypad
DIK_DELETE = $D3; // Delete on arrow keypad
DIK_LWIN = $DB; // Left Windows key
DIK_RWIN = $DC; // Right Windows key
DIK_APPS = $DD; // AppMenu key
 
(*
* Alternate names for keys, to facilitate transition from DOS.
*)
DIK_BACKSPACE = DIK_BACK ; (* backspace *)
DIK_NUMPADSTAR = DIK_MULTIPLY; (* * on numeric keypad *)
DIK_LALT = DIK_LMENU ; (* left Alt *)
DIK_CAPSLOCK = DIK_CAPITAL ; (* CapsLock *)
DIK_NUMPADMINUS = DIK_SUBTRACT; (* - on numeric keypad *)
DIK_NUMPADPLUS = DIK_ADD ; (* + on numeric keypad *)
DIK_NUMPADPERIOD = DIK_DECIMAL ; (* . on numeric keypad *)
DIK_NUMPADSLASH = DIK_DIVIDE ; (* / on numeric keypad *)
DIK_RALT = DIK_RMENU ; (* right Alt *)
DIK_UPARROW = DIK_UP ; (* UpArrow on arrow keypad *)
DIK_PGUP = DIK_PRIOR ; (* PgUp on arrow keypad *)
DIK_LEFTARROW = DIK_LEFT ; (* LeftArrow on arrow keypad *)
DIK_RIGHTARROW = DIK_RIGHT ; (* RightArrow on arrow keypad *)
DIK_DOWNARROW = DIK_DOWN ; (* DownArrow on arrow keypad *)
DIK_PGDN = DIK_NEXT ; (* PgDn on arrow keypad *)
//
// Alternate names for keys, to facilitate transition from DOS.
//
DIK_BACKSPACE = DIK_BACK; // backspace
DIK_NUMPADSTAR = DIK_MULTIPLY; // * on numeric keypad
DIK_LALT = DIK_LMENU; // left Alt
DIK_CAPSLOCK = DIK_CAPITAL; // CapsLock
DIK_NUMPADMINUS = DIK_SUBTRACT; // - on numeric keypad
DIK_NUMPADPLUS = DIK_ADD; // + on numeric keypad
DIK_NUMPADPERIOD = DIK_DECIMAL; // . on numeric keypad
DIK_NUMPADSLASH = DIK_DIVIDE; // / on numeric keypad
DIK_RALT = DIK_RMENU; // right Alt
DIK_UPARROW = DIK_UP; // UpArrow on arrow keypad
DIK_PGUP = DIK_PRIOR; // PgUp on arrow keypad
DIK_LEFTARROW = DIK_LEFT; // LeftArrow on arrow keypad
DIK_RIGHTARROW = DIK_RIGHT; // RightArrow on arrow keypad
DIK_DOWNARROW = DIK_DOWN; // DownArrow on arrow keypad
DIK_PGDN = DIK_NEXT; // PgDn on arrow keypad
 
(****************************************************************************
*
* Keyboard
*
****************************************************************************)
{ Joystick }
 
 
type
TDIKeyboardState = array[0..255] of Byte;
(*
const
_c_dfDIKeyboard_Objects: array[0..255] of TDIObjectDataFormat = (
( pguid: @GUID_Key;
dwOfs: DIK_ESCAPE;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// -------- top row (except function keys) on main kbd ------------
( pguid: @GUID_Key;
dwOfs: DIK_1; // "1" on main kbd, Offset 2
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_2; // "2" on main kbd, Offset 3
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_3; // "3" on main kbd, etc.
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_4;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_5;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_6;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_7;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_8;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_9;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_0; // "0", main kbd
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_MINUS; // "-" on US kbds, "ß" on german kbds
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_EQUALS; // "=" for US, "´" for german
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_BACK; // backspace
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// ----------- 2nd row -----------------------
( pguid: @GUID_Key;
dwOfs: DIK_TAB;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_Q;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_W;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_E;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_R;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_T;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_Y; // "Z" on german & french keyboards
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_U;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_I;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_O;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_P;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_LBRACKET; // "Ü" on german keyboards
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_RBRACKET; // "+" on german keyboards
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_RETURN; // Enter on main kbd
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// next row should really start with caps lock but doesn't ;-)
// (DIK_CAPITAL is Offset $3A, i.e. after 4th row)
( pguid: @GUID_Key;
dwOfs: DIK_LCONTROL; // Left Ctrl (german kbds: "Strg")
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// ----------- 3rd row ------------------------------
( pguid: @GUID_Key;
dwOfs: DIK_A;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_S;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_D;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_G;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_H;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_J;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_K;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_L;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_SEMICOLON; // "Ö" on german kbds
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_APOSTROPHE; // "Ä" on german kbds
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_GRAVE; // accent grave, "'" on german kbds
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// ---------------- 4th row -----------------------
( pguid: @GUID_Key;
dwOfs: DIK_LSHIFT; // left shift
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_BACKSLASH; // "<" on german kbds
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_Z; // "Y" on german kbds
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_X;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_C;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_V;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_B;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_N;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_M;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_COMMA;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_PERIOD; // on main kbd
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_SLASH; // "-" on german kbds
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_RSHIFT;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// --- misc keys (bye, bye, order) ----------------
( pguid: @GUID_Key;
dwOfs: DIK_MULTIPLY; // on numeric keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_LMENU; // left ALT
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_SPACE; // space bar
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_CAPITAL; // caps lock (on main kbd, above LSHIFT)
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// ---------- function keys -----------
( pguid: @GUID_Key;
dwOfs: DIK_F1;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F2;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F3;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F4;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F5;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F6;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F7;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F8;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F9;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F10;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// ------- F11, F12 after numeric keypad (for "historical reasons" -- XT kbd)
PDIJoyState = ^TDIJoyState;
TDIJoyState = record
lX: Longint; // x-axis position
lY: Longint; // y-axis position
lZ: Longint; // z-axis position
lRx: Longint; // x-axis rotation
lRy: Longint; // y-axis rotation
lRz: Longint; // z-axis rotation
rglSlider: array[0..1] of Longint; // extra axes positions
rgdwPOV: array[0..3] of DWORD; // POV directions
rgbButtons: array[0..31] of BYTE; // 32 buttons
end;
 
// --------- numeric keypad (mostly, that is) -----------
( pguid: @GUID_Key;
dwOfs: DIK_NUMLOCK; // numeric keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_SCROLL; // scroll lock
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD7;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD8;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD9;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_SUBTRACT; // "-" on numeric keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD4;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD5;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD6;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_ADD; // "+" on numeric keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD1;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD2;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD3;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NUMPAD0; // "0" or "Insert" on numeric keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_DECIMAL; // "." or "Del" on numeric keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: $54;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// "extended" function keys; F13 to F15 only on NEC PC98
( pguid: @GUID_Key;
dwOfs: DIK_F11;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_F12;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// -------------------------------------------------
// a whole lot of keys for asian kbds only
// -------------------------------------------------
( pguid: @GUID_Key;
dwOfs: DIK_NUMPADENTER; // Enter on numeric keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_RCONTROL; // right Ctrl on main kbd
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key; // "," on numeric keypad (NEC PC98 only)
dwOfs: DIK_NUMPADCOMMA;
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_DIVIDE; // "/" on numeric keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_SYSRQ; // "System request", "Druck/S-Abf" on german kbds
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_RMENU; // right ALT
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_PAUSE; // "Pause" - not reliable on some kbds
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
DIJOYSTATE = TDIJoyState;
 
// ----------- arrow keypad -----------------
( pguid: @GUID_Key;
dwOfs: DIK_HOME; // Home on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
PDIJOYSTATE2 = ^TDIJoyState2;
TDIJoyState2 = record
lX: Longint; // x-axis position
lY: Longint; // y-axis position
lZ: Longint; // z-axis position
lRx: Longint; // x-axis rotation
lRy: Longint; // y-axis rotation
lRz: Longint; // z-axis rotation
rglSlider: array[0..1] of Longint; // extra axes positions
rgdwPOV: array[0..3] of DWORD; // POV directions
rgbButtons: array[0..127] of BYTE; // 128 buttons
lVX: Longint; // x-axis velocity
lVY: Longint; // y-axis velocity
lVZ: Longint; // z-axis velocity
lVRx: Longint; // x-axis angular velocity
lVRy: Longint; // y-axis angular velocity
lVRz: Longint; // z-axis angular velocity
rglVSlider: array[0..1] of Longint; // extra axes velocities
lAX: Longint; // x-axis acceleration
lAY: Longint; // y-axis acceleration
lAZ: Longint; // z-axis acceleration
lARx: Longint; // x-axis angular acceleration
lARy: Longint; // y-axis angular acceleration
lARz: Longint; // z-axis angular acceleration
rglASlider: array[0..1] of Longint; // extra axes accelerations
lFX: Longint; // x-axis force
lFY: Longint; // y-axis force
lFZ: Longint; // z-axis force
lFRx: Longint; // x-axis torque
lFRy: Longint; // y-axis torque
lFRz: Longint; // z-axis torque
rglFSlider: array[0..1] of Longint; // extra axes forces
end;
 
DIJOYSTATE2 = TDIJoyState2;
 
{const
_c_dfDIJoystick_Objects: array[0..1] of TDIObjectDataFormat = (
( pguid: nil;
dwOfs: 0;
dwType: DIDFT_AXIS or DIDFT_ANYINSTANCE;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_UP; // UpArrow on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_PRIOR; // PgUp on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_LEFT; // LeftArrow on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_RIGHT; // RightArrow on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_END; // End on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_DOWN; // DownArrow on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_NEXT; // PgDn on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_INSERT; // Insert on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_DELETE; // Delete on arrow keypad
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_LWIN; // Left Windows key
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_RWIN; // Right Windows key
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: DIK_APPS; // AppMenu key
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
// -------- added with Win 98 / DirectX 6.1 ------------
( pguid: @GUID_Key;
dwOfs: 222; // Power on key
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: 223; // Sleep key
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
dwFlags: 0),
( pguid: @GUID_Key;
dwOfs: 227; // Wake (up) key. The german "translation"
// reads "Kielwasser" (ship's wake) ;-)
dwType: DIDFT_BUTTON or DIDFT_NOCOLLECTION;
( pguid: nil;
dwOfs: 48;
dwType: DIDFT_BUTTON or DIDFT_ANYINSTANCE;
dwFlags: 0)
);
*)
 
var // set by initialization - I was simply too lazy
_c_dfDIKeyboard_Objects: array[0..255] of TDIObjectDataFormat;
const
c_dfDIKeyboard: TDIDataFormat = (
dwSize: Sizeof(c_dfDIKeyboard);
c_dfDIJoystick: TDIDataFormat = (
dwSize: Sizeof(c_dfDIJoystick);
dwObjSize: Sizeof(TDIObjectDataFormat);
dwFlags: DIDF_RELAXIS;
dwDataSize: Sizeof(TDIKeyboardState);
dwNumObjs: High(_c_dfDIKeyboard_Objects)+1;
rgodf: @_c_dfDIKeyboard_Objects[Low(_c_dfDIKeyboard_Objects)]
);
 
(****************************************************************************
*
* Joystick
*
****************************************************************************)
 
 
type
PDIJoyState = ^TDIJoyState;
TDIJoyState = packed record
lX: Longint; (* x-axis position *)
lY: Longint; (* y-axis position *)
lZ: Longint; (* z-axis position *)
lRx: Longint; (* x-axis rotation *)
lRy: Longint; (* y-axis rotation *)
lRz: Longint; (* z-axis rotation *)
rglSlider: Array [0..1] of Longint; (* extra axes positions *)
rgdwPOV: Array [0..3] of DWORD; (* POV directions *)
rgbButtons: Array [0..31] of BYTE; (* 32 buttons *)
end;
 
PDIJoyState2 = ^TDIJoyState2;
TDIJoyState2 = packed record
lX: Longint; (* x-axis position *)
lY: Longint; (* y-axis position *)
lZ: Longint; (* z-axis position *)
lRx: Longint; (* x-axis rotation *)
lRy: Longint; (* y-axis rotation *)
lRz: Longint; (* z-axis rotation *)
rglSlider: Array [0..1] of Longint; (* extra axes positions *)
rgdwPOV: Array [0..3] of DWORD; (* POV directions *)
rgbButtons: Array [0..127] of BYTE; (* 128 buttons *)
lVX: Longint; (* x-axis velocity *)
lVY: Longint; (* y-axis velocity *)
lVZ: Longint; (* z-axis velocity *)
lVRx: Longint; (* x-axis angular velocity *)
lVRy: Longint; (* y-axis angular velocity *)
lVRz: Longint; (* z-axis angular velocity *)
rglVSlider: Array [0..1] of Longint; (* extra axes velocities *)
lAX: Longint; (* x-axis acceleration *)
lAY: Longint; (* y-axis acceleration *)
lAZ: Longint; (* z-axis acceleration *)
lARx: Longint; (* x-axis angular acceleration *)
lARy: Longint; (* y-axis angular acceleration *)
lARz: Longint; (* z-axis angular acceleration *)
rglASlider: Array [0..1] of Longint; (* extra axes accelerations *)
lFX: Longint; (* x-axis force *)
lFY: Longint; (* y-axis force *)
lFZ: Longint; (* z-axis force *)
lFRx: Longint; (* x-axis torque *)
lFRy: Longint; (* y-axis torque *)
lFRz: Longint; (* z-axis torque *)
rglFSlider: Array [0..1] of Longint; (* extra axes forces *)
end;
 
 
function DIJOFS_SLIDER(n: variant) : variant;
 
function DIJOFS_POV(n: variant) : variant;
 
function DIJOFS_BUTTON(n: variant) : variant;
dwFlags: DIDF_ABSAXIS;
dwDataSize: SizeOf(DIJOYSTATE);
dwNumObjs: High(_c_dfDIJoystick_Objects)+1;
rgodf: @_c_dfDIJoystick_Objects);
}
const
DIJOFS_BUTTON_ = 48;
 
const
DIJOFS_BUTTON0 = DIJOFS_BUTTON_ + 0;
DIJOFS_BUTTON1 = DIJOFS_BUTTON_ + 1;
DIJOFS_BUTTON2 = DIJOFS_BUTTON_ + 2;
DIJOFS_BUTTON3 = DIJOFS_BUTTON_ + 3;
DIJOFS_BUTTON4 = DIJOFS_BUTTON_ + 4;
DIJOFS_BUTTON5 = DIJOFS_BUTTON_ + 5;
DIJOFS_BUTTON6 = DIJOFS_BUTTON_ + 6;
DIJOFS_BUTTON7 = DIJOFS_BUTTON_ + 7;
DIJOFS_BUTTON8 = DIJOFS_BUTTON_ + 8;
DIJOFS_BUTTON9 = DIJOFS_BUTTON_ + 9;
DIJOFS_BUTTON10 = DIJOFS_BUTTON_ + 10;
DIJOFS_BUTTON11 = DIJOFS_BUTTON_ + 11;
DIJOFS_BUTTON12 = DIJOFS_BUTTON_ + 12;
DIJOFS_BUTTON13 = DIJOFS_BUTTON_ + 13;
DIJOFS_BUTTON14 = DIJOFS_BUTTON_ + 14;
DIJOFS_BUTTON15 = DIJOFS_BUTTON_ + 15;
DIJOFS_BUTTON16 = DIJOFS_BUTTON_ + 16;
DIJOFS_BUTTON17 = DIJOFS_BUTTON_ + 17;
DIJOFS_BUTTON18 = DIJOFS_BUTTON_ + 18;
DIJOFS_BUTTON19 = DIJOFS_BUTTON_ + 19;
DIJOFS_BUTTON20 = DIJOFS_BUTTON_ + 20;
DIJOFS_BUTTON21 = DIJOFS_BUTTON_ + 21;
DIJOFS_BUTTON22 = DIJOFS_BUTTON_ + 22;
DIJOFS_BUTTON23 = DIJOFS_BUTTON_ + 23;
DIJOFS_BUTTON24 = DIJOFS_BUTTON_ + 24;
DIJOFS_BUTTON25 = DIJOFS_BUTTON_ + 25;
DIJOFS_BUTTON26 = DIJOFS_BUTTON_ + 26;
DIJOFS_BUTTON27 = DIJOFS_BUTTON_ + 27;
DIJOFS_BUTTON28 = DIJOFS_BUTTON_ + 28;
DIJOFS_BUTTON29 = DIJOFS_BUTTON_ + 29;
DIJOFS_BUTTON30 = DIJOFS_BUTTON_ + 30;
DIJOFS_BUTTON31 = DIJOFS_BUTTON_ + 31;
 
 
const
DIJOFS_X =0;
DIJOFS_Y =4;
DIJOFS_Z =8;
13837,172 → 9569,45
DIJOFS_RX =12;
DIJOFS_RY =16;
DIJOFS_RZ =20;
DIJOFS_SLIDER = 24;
DIJOFS_POV = 32;
DIJOFS_BUTTON = 48;
 
_c_dfDIJoystick_Objects: array[0..43] of TDIObjectDataFormat = (
( pguid: @GUID_XAxis;
dwOfs: DIJOFS_X; dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION; dwFlags: $100),
( pguid: @GUID_YAxis;
dwOfs: DIJOFS_Y; dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION; dwFlags: $100),
( pguid: @GUID_ZAxis;
dwOfs: DIJOFS_Z; dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION; dwFlags: $100),
( pguid: @GUID_RxAxis;
dwOfs: DIJOFS_RX; dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION; dwFlags: $100),
( pguid: @GUID_RyAxis;
dwOfs: DIJOFS_RY; dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION; dwFlags: $100),
( pguid: @GUID_RzAxis;
dwOfs: DIJOFS_RZ; dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION; dwFlags: $100),
{ IDirectInput }
 
( pguid: @GUID_Slider; // 2 Sliders
dwOfs: 24; dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION; dwFlags: $100),
( pguid: @GUID_Slider;
dwOfs: 28; dwType: $80000000 or DIDFT_AXIS or DIDFT_NOCOLLECTION; dwFlags: $100),
 
( pguid: @GUID_POV; // 4 POVs (yes, really)
dwOfs: 32; dwType: $80000000 or DIDFT_POV or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: @GUID_POV;
dwOfs: 36; dwType: $80000000 or DIDFT_POV or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: @GUID_POV;
dwOfs: 40; dwType: $80000000 or DIDFT_POV or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: @GUID_POV;
dwOfs: 44; dwType: $80000000 or DIDFT_POV or DIDFT_NOCOLLECTION; dwFlags: 0),
 
( pguid: nil; // Buttons
dwOfs: DIJOFS_BUTTON0; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON1; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON2; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON3; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON4; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON5; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON6; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON7; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON8; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON9; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON10; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON11; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON12; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON13; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON14; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON15; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON16; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON17; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON18; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON19; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON20; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON21; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON22; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON23; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON24; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON25; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON26; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON27; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON28; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON29; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON30; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0),
( pguid: nil;
dwOfs: DIJOFS_BUTTON31; dwType: $80000000 or DIDFT_BUTTON or DIDFT_NOCOLLECTION; dwFlags: 0)
);
 
c_dfDIJoystick: TDIDataFormat = (
dwSize: Sizeof(c_dfDIJoystick);
dwObjSize: Sizeof(TDIObjectDataFormat); // $10
dwFlags: DIDF_ABSAXIS;
dwDataSize: SizeOf(TDIJoyState); // $10
dwNumObjs: High(_c_dfDIJoystick_Objects)+1; // $2C
rgodf: @_c_dfDIJoystick_Objects[Low(_c_dfDIJoystick_Objects)]
);
 
var // Set by initialization part -- didn't want to type in another 656 consts...
_c_dfDIJoystick2_Objects: array[0..$A3] of TDIObjectDataFormat;
{ Elements $00..$2B: exact copy of _c_dfDIJoystick
Elements $2C..$8B: more "buttons" with nil GUIDs
remaining elements ($8B..$A2):
$8C,$8D,$8E: X axis, Y axis, Z axis with dwFlags = $0200
$8F,$90,$91: rX axis, rY axis, rZ axis with dwFlags = $0200
$92, $93: Slider with dwFlags = $0200
--------
$94,$95,$96: X axis, Y axis, Z axis with dwFlags = $0300
$97,$98,$99: rX axis, rY axis, rZ axis with dwFlags = $0300
$9A,$9B: Slider with dwFlags = $0300
--------
$9C,$9D,$9E: X axis, Y axis, Z axis with dwFlags = $0400
$9F, $A0, $A1: rX axis, rY axis, rZ axis with dwFlags = $0400
$A2, $A3: Slider with dwFlags = $0400
}
const
c_dfDIJoystick2: TDIDataFormat = (
dwSize: Sizeof(c_dfDIJoystick2);
dwObjSize: Sizeof(TDIObjectDataFormat);
dwFlags: DIDF_ABSAXIS;
dwDataSize: SizeOf(TDIJoyState2); // $110
dwNumObjs: High(_c_dfDIJoystick2_Objects)+1;
rgodf: @_c_dfDIJoystick2_Objects[Low(_c_dfDIJoystick2_Objects)]
);
 
(****************************************************************************
*
* IDirectInput
*
****************************************************************************)
 
 
DIENUM_STOP = 0;
DIENUM_CONTINUE = 1;
 
type
// as with the other enum functions: must rtn DIENUM_STOP or DIENUM_CONTINUE
TDIEnumDevicesCallbackA = function (var lpddi: TDIDeviceInstanceA;
pvRef: Pointer): Integer; stdcall; // BOOL; stdcall;
TDIEnumDevicesCallbackW = function (var lpddi: TDIDeviceInstanceW;
pvRef: Pointer): Integer; stdcall; // BOOL; stdcall;
TDIEnumDevicesCallback = function (var lpddi: TDIDeviceInstance;
pvRef: Pointer): Integer; stdcall; // BOOL; stdcall;
TDIEnumDevicesProc = TDIEnumDevicesCallback;
 
TDIEnumDevicesCallbackA = function(const lpddi: TDIDeviceInstanceA;
pvRef: Pointer): HResult; stdcall;
LPDIENUMDEVICESCALLBACKA = TDIEnumDevicesCallbackA;
 
TDIEnumDevicesCallbackW = function(const lpddi: TDIDeviceInstanceW;
pvRef: Pointer): HResult; stdcall;
LPDIENUMDEVICESCALLBACKW = TDIEnumDevicesCallbackW;
 
TDIEnumDevicesCallback = TDIEnumDevicesCallbackA;
LPDIENUMDEVICESCALLBACK = TDIEnumDevicesCallback;
 
const
DIEDFL_ALLDEVICES = $00000000;
DIEDFL_ATTACHEDONLY = $00000001;
DIEDFL_FORCEFEEDBACK = $00000100;
DIEDFL_INCLUDEALIASES = $00010000;
DIEDFL_INCLUDEPHANTOMS = $00020000;
 
type
 
IDirectInputW = interface (IUnknown)
['{89521361-AA8A-11CF-BFC7-444553540000}']
(*** IDirectInputW methods ***)
function CreateDevice(const rguid: TGUID; var lplpDirectInputDevice:
IDirectInputDeviceW; pUnkOuter: IUnknown) : HResult; stdcall;
// IDirectInputW methods
function CreateDevice(const rguid: TGUID;
out lplpDirectInputDevice: IDirectInputDeviceW; pUnkOuter: IUnknown): HResult; stdcall;
function EnumDevices(dwDevType: DWORD; lpCallback: TDIEnumDevicesCallbackW;
pvRef: Pointer; dwFlags: DWORD) : HResult; stdcall;
function GetDeviceStatus(const rguidInstance: TGUID) : HResult; stdcall;
function GetDeviceStatus(var rguidInstance: TGUID): HResult; stdcall;
function RunControlPanel(hwndOwner: HWND; dwFlags: DWORD) : HResult; stdcall;
function Initialize(hinst: THandle; dwVersion: DWORD) : HResult; stdcall;
end;
14009,9 → 9614,9
 
IDirectInputA = interface (IUnknown)
['{89521360-AA8A-11CF-BFC7-444553540000}']
(*** IDirectInputA methods ***)
function CreateDevice(const rguid: TGUID; var lplpDirectInputDevice:
IDirectInputDeviceA; pUnkOuter: IUnknown) : HResult; stdcall;
// IDirectInputA methods
function CreateDevice(const rguid: TGUID;
out lplpDirectInputDevice: IDirectInputDeviceA; pUnkOuter: IUnknown): HResult; stdcall;
function EnumDevices(dwDevType: DWORD; lpCallback: TDIEnumDevicesCallbackA;
pvRef: Pointer; dwFlags: DWORD) : HResult; stdcall;
function GetDeviceStatus(const rguidInstance: TGUID) : HResult; stdcall;
14019,566 → 9624,158
function Initialize(hinst: THandle; dwVersion: DWORD) : HResult; stdcall;
end;
 
{$IFDEF UNICODE}
IDirectInput = IDirectInputW;
{$ELSE}
IDirectInput = IDirectInputA;
{$ENDIF}
 
 
IDirectInput2W = interface (IDirectInputW)
['{5944E663-AA8A-11CF-BFC7-444553540000}']
(*** IDirectInput2W methods ***)
function FindDevice(const rguidClass: TGUID; ptszName: PWideChar; out pguidInstance: TGUID): HResult; stdcall;
// IDirectInput2W methods
function FindDevice(Arg1: PGUID; Arg2: PWideChar; Arg3: PGUID): HResult; stdcall;
end;
 
IDirectInput2A = interface (IDirectInputA)
['{5944E662-AA8A-11CF-BFC7-444553540000}']
(*** IDirectInput2A methods ***)
function FindDevice(const rguidClass: TGUID; ptszName: PAnsiChar; out pguidInstance: TGUID): HResult; stdcall;
// IDirectInput2A methods
function FindDevice(Arg1: PGUID; Arg2: PAnsiChar; Arg3: PGUID): HResult; stdcall;
end;
 
{$IFDEF UNICODE}
IDirectInput2 = IDirectInput2W;
{$ELSE}
IDirectInput2 = IDirectInput2A;
{$ENDIF}
 
 
type
IDirectInput7W = interface (IDirectInput2W)
['{9A4CB685-236D-11D3-8E9D-00C04F6844AE}']
{*** IDirectInput7W methods ***}
function CreateDeviceEx(const rguid, riid: TGUID; out lplpDirectInputDevice;
pUnkOuter: IUnknown) : HResult; stdcall;
// IDirectInput7W methods
function CreateDeviceEx(const rguid: TGUID; const riid: TGUID;
out pvOut; pUnkOuter: IUnknown): HResult; stdcall;
end;
 
IDirectInput7A = interface (IDirectInput2A)
['{9A4CB684-236D-11D3-8E9D-00C04F6844AE}']
{*** IDirectInput7A methods ***}
function CreateDeviceEx(const rguid, riid: TGUID; out lplpDirectInputDevice;
pUnkOuter: IUnknown) : HResult; stdcall;
// IDirectInput7A methods
function CreateDeviceEx(const rguid: TGUID; const riid: TGUID;
out pvOut; pUnkOuter: IUnknown): HResult; stdcall;
end;
 
{$IFDEF UNICODE}
IDirectInput7 = IDirectInput7W;
{$ELSE}
IDirectInput7 = IDirectInput7A;
{$ENDIF}
 
{ Return Codes }
 
var
DirectInputCreateA : function (hinst: THandle; dwVersion: DWORD;
out ppDI: IDirectInputA;
punkOuter: IUnknown) : HResult; stdcall;
DirectInputCreateW : function (hinst: THandle; dwVersion: DWORD;
out ppDI: IDirectInputW;
punkOuter: IUnknown) : HResult; stdcall;
DirectInputCreate : function (hinst: THandle; dwVersion: DWORD;
out ppDI: IDirectInput;
punkOuter: IUnknown) : HResult; stdcall;
 
DirectInputCreateEx : function (
hinst: THandle;
dwVersion: DWORD;
const riidltf: TGUID;
out ppvOut;
punkOuter: IUnknown) : HResult; stdcall;
 
(****************************************************************************
*
* Interfaces
*
****************************************************************************)
type
IID_IDirectInputW = IDirectInputW;
IID_IDirectInputA = IDirectInputA;
IID_IDirectInput = IDirectInput;
 
IID_IDirectInput2W = IDirectInput2W;
IID_IDirectInput2A = IDirectInput2A;
IID_IDirectInput2 = IDirectInput2;
 
IID_IDirectInput7W = IDirectInput7W;
IID_IDirectInput7A = IDirectInput7A;
IID_IDirectInput7 = IDirectInput7;
 
IID_IDirectInputDeviceW = IDirectInputDeviceW;
IID_IDirectInputDeviceA = IDirectInputDeviceA;
IID_IDirectInputDevice = IDirectInputDevice;
 
IID_IDirectInputDevice2W = IDirectInputDevice2W;
IID_IDirectInputDevice2A = IDirectInputDevice2A;
IID_IDirectInputDevice2 = IDirectInputDevice2;
 
IID_IDirectInputEffect = IDirectInputEffect;
 
IID_IDirectInputDevice7W = IDirectInputDevice7W;
IID_IDirectInputDevice7A = IDirectInputDevice7A;
IID_IDirectInputDevice7 = IDirectInputDevice7;
 
(****************************************************************************
*
* Return Codes
*
****************************************************************************)
 
(*
* The operation completed successfully.
*)
const
DI_OK = S_OK;
DI_OK = HResult(S_OK);
DI_NOTATTACHED = HResult(S_FALSE);
DI_BUFFEROVERFLOW = HResult(S_FALSE);
DI_PROPNOEFFECT = HResult(S_FALSE);
DI_NOEFFECT = HResult(S_FALSE);
DI_POLLEDDEVICE = HResult($00000002);
DI_DOWNLOADSKIPPED = HResult($00000003);
DI_EFFECTRESTARTED = HResult($00000004);
DI_TRUNCATED = HResult($00000008);
DI_TRUNCATEDANDRESTARTED = HResult($0000000C);
 
(*
* The device exists but is not currently attached.
*)
DI_NOTATTACHED = S_FALSE;
 
(*
* The device buffer overflowed. Some input was lost.
*)
DI_BUFFEROVERFLOW = S_FALSE;
 
(*
* The change in device properties had no effect.
*)
DI_PROPNOEFFECT = S_FALSE;
 
(*
* The operation had no effect.
*)
DI_NOEFFECT = S_FALSE;
 
(*
* The device is a polled device. As a result, device buffering
* will not collect any data and event notifications will not be
* signalled until GetDeviceState is called.
*)
DI_POLLEDDEVICE = $00000002;
 
(*
* The parameters of the effect were successfully updated by
* IDirectInputEffect::SetParameters, but the effect was not
* downloaded because the device is not exclusively acquired
* or because the DIEP_NODOWNLOAD flag was passed.
*)
DI_DOWNLOADSKIPPED = $00000003;
 
(*
* The parameters of the effect were successfully updated by
* IDirectInputEffect::SetParameters, but in order to change
* the parameters, the effect needed to be restarted.
*)
DI_EFFECTRESTARTED = $00000004;
 
(*
* The parameters of the effect were successfully updated by
* IDirectInputEffect::SetParameters, but some of them were
* beyond the capabilities of the device and were truncated.
*)
DI_TRUNCATED = $00000008;
 
(*
* Equal to DI_EFFECTRESTARTED | DI_TRUNCATED.
*)
DI_TRUNCATEDANDRESTARTED = $0000000C;
 
SEVERITY_ERROR_FACILITY_WIN32 =
HResult(SEVERITY_ERROR shl 31) or HResult(FACILITY_WIN32 shl 16);
 
(*
* The application requires a newer version of DirectInput.
*)
 
DIERR_OLDDIRECTINPUTVERSION = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_OLD_WIN_VERSION;
 
(*
* The application was written for an unsupported prerelease version
* of DirectInput.
*)
DIERR_BETADIRECTINPUTVERSION = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_RMODE_APP;
 
(*
* The object could not be created due to an incompatible driver version
* or mismatched or incomplete driver components.
*)
DIERR_BADDRIVERVER = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_BAD_DRIVER_LEVEL;
 
(*
* The device or device instance or effect is not registered with DirectInput.
*)
DIERR_DEVICENOTREG = REGDB_E_CLASSNOTREG;
 
(*
* The requested object does not exist.
*)
DIERR_NOTFOUND = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_FILE_NOT_FOUND;
 
(*
* The requested object does not exist.
*)
DIERR_OBJECTNOTFOUND = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_FILE_NOT_FOUND;
 
(*
* An invalid parameter was passed to the returning function,
* or the object was not in a state that admitted the function
* to be called.
*)
DIERR_INVALIDPARAM = E_INVALIDARG;
 
(*
* The specified interface is not supported by the object
*)
DIERR_NOINTERFACE = E_NOINTERFACE;
 
(*
* An undetermined error occured inside the DInput subsystem
*)
DIERR_GENERIC = E_FAIL;
 
(*
* The DInput subsystem couldn't allocate sufficient memory to complete the
* caller's request.
*)
DIERR_OUTOFMEMORY = E_OUTOFMEMORY;
 
(*
* The function called is not supported at this time
*)
DIERR_UNSUPPORTED = E_NOTIMPL;
 
(*
* This object has not been initialized
*)
DIERR_NOTINITIALIZED = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_NOT_READY;
 
(*
* This object is already initialized
*)
DIERR_ALREADYINITIALIZED = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_ALREADY_INITIALIZED;
 
(*
* This object does not support aggregation
*)
DIERR_NOAGGREGATION = CLASS_E_NOAGGREGATION;
 
(*
* Another app has a higher priority level, preventing this call from
* succeeding.
*)
DIERR_OTHERAPPHASPRIO = E_ACCESSDENIED;
 
(*
* Access to the device has been lost. It must be re-acquired.
*)
DIERR_INPUTLOST = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_READ_FAULT;
 
(*
* The operation cannot be performed while the device is acquired.
*)
DIERR_ACQUIRED = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_BUSY;
 
(*
* The operation cannot be performed unless the device is acquired.
*)
DIERR_NOTACQUIRED = SEVERITY_ERROR_FACILITY_WIN32
or ERROR_INVALID_ACCESS;
 
(*
* The specified property cannot be changed.
*)
DIERR_READONLY = E_ACCESSDENIED;
 
(*
* The device already has an event notification associated with it.
*)
DIERR_HANDLEEXISTS = E_ACCESSDENIED;
 
(*
* Data is not yet available.
*)
E_PENDING = HResult($80070007);
 
(*
* Unable to IDirectInputJoyConfig_Acquire because the user
* does not have sufficient privileges to change the joystick
* configuration.
*)
DIERR_OLDDIRECTINPUTVERSION = HResult($8007047E);
DIERR_BETADIRECTINPUTVERSION = HResult($80070481);
DIERR_BADDRIVERVER = HResult($80070077);
DIERR_DEVICENOTREG = HResult(REGDB_E_CLASSNOTREG);
DIERR_NOTFOUND = HResult($80070002);
DIERR_OBJECTNOTFOUND = HResult($80070002);
DIERR_INVALIDPARAM = HResult(E_INVALIDARG);
DIERR_NOINTERFACE = HResult(E_NOINTERFACE);
DIERR_GENERIC = HResult(E_FAIL);
DIERR_OUTOFMEMORY = HResult(E_OUTOFMEMORY);
DIERR_UNSUPPORTED = HResult(E_NOTIMPL);
DIERR_NOTINITIALIZED = HResult($80070015);
DIERR_ALREADYINITIALIZED = HResult($800704DF);
DIERR_NOAGGREGATION = HResult(CLASS_E_NOAGGREGATION);
DIERR_OTHERAPPHASPRIO = HResult(E_ACCESSDENIED);
DIERR_INPUTLOST = HResult($8007001E);
DIERR_ACQUIRED = HResult($800700AA);
DIERR_NOTACQUIRED = HResult($8007000C);
DIERR_READONLY = HResult(E_ACCESSDENIED);
DIERR_HANDLEEXISTS = HResult(E_ACCESSDENIED);
DIERR_PENDING = HResult($80070007);
DIERR_INSUFFICIENTPRIVS = HResult($80040200);
DIERR_DEVICEFULL = HResult($80040201);
DIERR_MOREDATA = HResult($80040202);
DIERR_NOTDOWNLOADED = HResult($80040203);
DIERR_HASEFFECTS = HResult($80040204);
DIERR_NOTEXCLUSIVEACQUIRED = HResult($80040205);
DIERR_INCOMPLETEEFFECT = HResult($80040206);
DIERR_NOTBUFFERED = HResult($80040207);
DIERR_EFFECTPLAYING = HResult($80040208);
DIERR_UNPLUGGED = HResult($80040209);
DIERR_REPORTFULL = HResult($8004020A);
 
(*
* The device is full.
*)
DIERR_DEVICEFULL = DIERR_INSUFFICIENTPRIVS + 1;
 
(*
* Not all the requested information fit into the buffer.
*)
DIERR_MOREDATA = DIERR_INSUFFICIENTPRIVS + 2;
{ Definitions for non-IDirectInput (VJoyD) features defined more recently
than the current sdk files }
 
(*
* The effect is not downloaded.
*)
DIERR_NOTDOWNLOADED = DIERR_INSUFFICIENTPRIVS + 3;
 
(*
* The device cannot be reinitialized because there are still effects
* attached to it.
*)
DIERR_HASEFFECTS = DIERR_INSUFFICIENTPRIVS + 4;
 
(*
* The operation cannot be performed unless the device is acquired
* in DISCL_EXCLUSIVE mode.
*)
DIERR_NOTEXCLUSIVEACQUIRED = DIERR_INSUFFICIENTPRIVS + 5;
 
(*
* The effect could not be downloaded because essential information
* is missing. For example, no axes have been associated with the
* effect, or no type-specific information has been created.
*)
DIERR_INCOMPLETEEFFECT = DIERR_INSUFFICIENTPRIVS + 6;
 
(*
* Attempted to read buffered device data from a device that is
* not buffered.
*)
DIERR_NOTBUFFERED = DIERR_INSUFFICIENTPRIVS + 7;
 
(*
* An attempt was made to modify parameters of an effect while it is
* playing. Not all hardware devices support altering the parameters
* of an effect while it is playing.
*)
DIERR_EFFECTPLAYING = DIERR_INSUFFICIENTPRIVS + 8;
 
(*
* The operation could not be completed because the device is not
* plugged in.
*)
DIERR_UNPLUGGED = $80040209;
 
(*
* SendDeviceData failed because more information was requested
* to be sent than can be sent to the device. Some devices have
* restrictions on how much data can be sent to them. (For example,
* there might be a limit on the number of buttons that can be
* pressed at once.)
*)
DIERR_REPORTFULL = $8004020A;
 
 
(****************************************************************************
*
* Definitions for non-IDirectInput (VJoyD) features defined more recently
* than the current sdk files
*
****************************************************************************)
 
(*
* Flag to indicate that the dwReserved2 field of the JOYINFOEX structure
* contains mini-driver specific data to be passed by VJoyD to the mini-
* driver instead of doing a poll.
*)
JOY_PASSDRIVERDATA = $10000000;
 
(*
* Informs the joystick driver that the configuration has been changed
* and should be reloaded from the registery.
* dwFlags is reserved and should be set to zero
*)
 
function joyConfigChanged(dwFlags: DWORD) : MMRESULT; stdcall;
 
const
(*
* Hardware Setting indicating that the device is a headtracker
*)
JOY_HWS_ISHEADTRACKER = $02000000;
 
(*
* Hardware Setting indicating that the VxD is used to replace
* the standard analog polling
*)
JOY_HWS_ISGAMEPORTDRIVER = $04000000;
 
(*
* Hardware Setting indicating that the driver needs a standard
* gameport in order to communicate with the device.
*)
JOY_HWS_ISANALOGPORTDRIVER = $08000000;
 
(*
* Hardware Setting indicating that VJoyD should not load this
* driver, it will be loaded externally and will register with
* VJoyD of it's own accord.
*)
JOY_HWS_AUTOLOAD = $10000000;
 
(*
* Hardware Setting indicating that the driver acquires any
* resources needed without needing a devnode through VJoyD.
*)
JOY_HWS_NODEVNODE = $20000000;
 
(*
* Hardware Setting indicating that the device is a gameport bus
*)
JOY_HWS_ISGAMEPORTBUS = $80000000;
JOY_HWS_GAMEPORTBUSBUSY = $00000001;
 
//from older Verion:
(*
* Hardware Setting indicating that the VxD can be used as
* a port 201h emulator.
*)
JOY_HWS_ISGAMEPORTEMULATOR = $40000000;
 
 
(*
* Usage Setting indicating that the settings are volatile and
* should be removed if still present on a reboot.
*)
JOY_US_VOLATILE = $00000008;
 
(****************************************************************************
*
* Definitions for non-IDirectInput (VJoyD) features defined more recently
* than the current ddk files
*
****************************************************************************)
{ Definitions for non-IDirectInput (VJoyD) features defined more recently
than the current ddk files }
 
(*
* Poll type in which the do_other field of the JOYOEMPOLLDATA
* structure contains mini-driver specific data passed from an app.
*)
JOY_OEMPOLL_PASSDRIVERDATA = 7;
 
{$IFDEF UseDirectPlay} // Daniel Marschall 12.04.2024 Added to avoid Windows showing "This app requires DirectPlay"
//DirectPlay file
function DirectInputCreate(hinst: THandle; dwVersion: DWORD;
out ppDI: IDirectInputA; punkOuter: IUnknown): HResult; stdcall;
function DirectInputCreateEx(hinst: THandle; dwVersion: DWORD;
const riidltf: TGUID; out ppDI: IDirectInputA; punkOuter: IUnknown): HResult; stdcall;
 
(*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: dplay.h dplobby.h
* Content: DirectPlay include files
*
* DirectX 7 Delphi adaptation by Erik Unger
*
* Modified: 4-Jun-2000
*
* Download: http://www.delphi-jedi.org/DelphiGraphics/
* E-Mail: DelphiDirectX@next-reality.com
*
***************************************************************************)
 
var
DPlayDLL : HMODULE = 0;
 
(*==========================================================================;
*
* Copyright (C) 1994-1997 Microsoft Corporation. All Rights Reserved.
*
* File: dplay.h
* Content: DirectPlay include file
*
***************************************************************************)
 
function DPErrorString(Value: HResult) : string;
 
const
// {D1EB6D20-8923-11d0-9D97-00A0C90A43CB}
CLSID_DirectPlay: TGUID =
(D1:$d1eb6d20;D2:$8923;D3:$11d0;D4:($9d,$97,$00,$a0,$c9,$a,$43,$cb));
{ GUIDS used by DirectPlay objects }
 
(*
* GUIDS used by Service Providers shipped with DirectPlay
* Use these to identify Service Provider returned by EnumConnections
*)
CLSID_DirectPlay: TGUID = '{D1EB6D20-8923-11D0-9D97-00A0C90A43CB}';
 
// GUID for IPX service provider
// {685BC400-9D2C-11cf-A9CD-00AA006886E3}
DPSPGUID_IPX: TGUID =
(D1:$685bc400;D2:$9d2c;D3:$11cf;D4:($a9,$cd,$00,$aa,$00,$68,$86,$e3));
IID_IDirectPlay: TGUID = '{5454E9A0-DB65-11CE-921C-00AA006C4972}';
IID_IDirectPlay2: TGUID = '{2B74F7C0-9154-11CF-A9CD-00AA006886E3}';
IID_IDirectPlay2A: TGUID = '{9D460580-A822-11CF-960C-0080C7534E82}';
IID_IDirectPlay3: TGUID = '{133EFE40-32DC-11D0-9CFB-00A0C90A43CB}';
IID_IDirectPlay3A: TGUID = '{133EFE41-32DC-11D0-9CFB-00A0C90A43CB}';
IID_IDirectPlay4: TGUID = '{0AB1C530-4745-11D1-A7A1-0000F803ABFC}';
IID_IDirectPlay4A: TGUID = '{0AB1C531-4745-11D1-A7A1-0000F803ABFC}';
 
// GUID for TCP/IP service provider
// 36E95EE0-8577-11cf-960C-0080C7534E82
DPSPGUID_TCPIP: TGUID =
(D1:$36E95EE0;D2:$8577;D3:$11cf;D4:($96,$0c,$00,$80,$c7,$53,$4e,$82));
{ GUIDS used by Service Providers shipped with DirectPlay
Use these to identify Service Provider returned by EnumConnections }
 
// GUID for Serial service provider
// {0F1D6860-88D9-11cf-9C4E-00A0C905425E}
DPSPGUID_SERIAL: TGUID =
(D1:$f1d6860;D2:$88d9;D3:$11cf;D4:($9c,$4e,$00,$a0,$c9,$05,$42,$5e));
DPSPGUID_IPX: TGUID = '{685BC400-9D2C-11CF-A9CD-00AA006886E3}';
DPSPGUID_TCPIP: TGUID = '{36E95EE0-8577-11CF-960C-0080C7534E82}';
DPSPGUID_SERIAL: TGUID = '{0F1D6860-88D9-11CF-9C4E-00A0C905425E}';
DPSPGUID_MODEM: TGUID = '{44EAA760-CB68-11CF-9C4E-00A0C905425E}';
 
// GUID for Modem service provider
// {44EAA760-CB68-11cf-9C4E-00A0C905425E}
DPSPGUID_MODEM: TGUID =
(D1:$44eaa760;D2:$cb68;D3:$11cf;D4:($9c,$4e,$00,$a0,$c9,$05,$42,$5e));
{ DirectPlay Structures }
 
 
(****************************************************************************
*
* DirectPlay Structures
*
* Various structures used to invoke DirectPlay.
*
****************************************************************************)
 
type
(*
* TDPID
* DirectPlay player and group ID
*)
PDPID = ^TDPID;
TDPID = DWORD;
PDPID = ^TDPID;
 
DPID = TDPID;
LPDPID = PDPID;
 
const
(*
* DPID that system messages come from
*)
DPID_SYSMSG = 0;
DPID_SYSMSG = 0; // DPID that system messages come from
DPID_ALLPLAYERS = 0; // DPID representing all players in the session
DPID_SERVERPLAYER = 1; // DPID representing the server player
DPID_RESERVEDRANGE = 100; // DPID representing the maxiumum ID in the range of DPID's reserved for
// use by DirectPlay.
DPID_UNKNOWN = $FFFFFFFF; // The player ID is unknown (used with e.g. DPSESSION_NOMESSAGEID)
 
(*
* DPID representing all players in the session
*)
DPID_ALLPLAYERS = 0;
 
(*
* DPID representing the server player
*)
DPID_SERVERPLAYER = 1;
 
(*
* DPID representing the maximum ID in the range of DPID's reserved for
* use by DirectPlay.
*)
DPID_RESERVEDRANGE = 100;
 
(*
* The player ID is unknown (used with e.g. DPSESSION_NOMESSAGEID)
*)
DPID_UNKNOWN = $FFFFFFFF;
 
type
(*
* DPCAPS
* Used to obtain the capabilities of a DirectPlay object
*)
PDPCaps = ^TDPCaps;
TDPCaps = packed record
TDPCaps = record
dwSize: DWORD; // Size of structure, in bytes
dwFlags: DWORD; // DPCAPS_xxx flags
dwMaxBufferSize: DWORD; // Maximum message size, in bytes, for this service provider
14595,85 → 9792,27
// responses to system messages
end;
 
DPCAPS = TDPCaps;
LPDPCAPS = PDPCaps;
 
const
(*
* This DirectPlay object is the session host. If the host exits the
* session, another application will become the host and receive a
* DPSYS_HOST system message.
*)
DPCAPS_ISHOST = $00000002;
 
(*
* The service provider bound to this DirectPlay object can optimize
* group messaging.
*)
DPCAPS_GROUPOPTIMIZED = $00000008;
 
(*
* The service provider bound to this DirectPlay object can optimize
* keep alives (see DPSESSION_KEEPALIVE)
*)
DPCAPS_KEEPALIVEOPTIMIZED = $00000010;
 
(*
* The service provider bound to this DirectPlay object can optimize
* guaranteed message delivery.
*)
DPCAPS_GUARANTEEDOPTIMIZED = $00000020;
 
(*
* This DirectPlay object supports guaranteed message delivery.
*)
DPCAPS_GUARANTEEDSUPPORTED = $00000040;
 
(*
* This DirectPlay object supports digital signing of messages.
*)
DPCAPS_SIGNINGSUPPORTED = $00000080;
 
(*
* This DirectPlay object supports encryption of messages.
*)
DPCAPS_ENCRYPTIONSUPPORTED = $00000100;
 
(*
* This DirectPlay player was created on this machine
*)
DPPLAYERCAPS_LOCAL = $00000800;
 
(*
* Current Open settings supports all forms of Cancel
*)
DPCAPS_ASYNCCANCELSUPPORTED = $00001000;
 
(*
* Current Open settings supports CancelAll, but not Cancel
*)
DPCAPS_ASYNCCANCELALLSUPPORTED = $00002000;
 
(*
* Current Open settings supports Send Timeouts for sends
*)
DPCAPS_SENDTIMEOUTSUPPORTED = $00004000;
 
(*
* Current Open settings supports send priority
*)
DPCAPS_SENDPRIORITYSUPPORTED = $00008000;
 
(*
* Current Open settings supports DPSEND_ASYNC flag
*)
DPCAPS_ASYNCSUPPORTED = $00010000;
 
type
(*
* TDPSessionDesc2
* Used to describe the properties of a DirectPlay
* session instance
*)
PDPSessionDesc2 = ^TDPSessionDesc2;
TDPSessionDesc2 = packed record
TDPSessionDesc2 = record
dwSize: DWORD; // Size of structure
dwFlags: DWORD; // DPSESSION_xxx flags
guidInstance: TGUID; // ID for the session instance
14681,10 → 9820,11
// GUID_NULL for all applications.
dwMaxPlayers: DWORD; // Maximum # players allowed in session
dwCurrentPlayers: DWORD; // Current # players in session (read only)
case integer of
 
case Integer of
0 : (
lpszSessionName: PCharAW; // Name of the session
lpszPassword: PCharAW; // Password of the session (optional)
lpszSessionName: LPWSTR; // Name of the session - Unicode
lpszPassword: LPWSTR; // Password of the session (optional) - Unicode
dwReserved1: DWORD; // Reserved for future MS use.
dwReserved2: DWORD;
dwUser1: DWORD; // For use by the application
14693,130 → 9833,49
dwUser4: DWORD;
);
1 : (
lpszSessionNameA: PAnsiChar; // Name of the session
lpszPasswordA: PAnsiChar // Password of the session (optional)
lpszSessionNameA: LPSTR; // Name of the session - ANSI
lpszPasswordA: LPSTR; // Password of the session (optional) - ANSI
);
2 : (
lpszSessionNameW: PWideChar;
lpszPasswordW: PWideChar
);
end;
 
DPSESSIONDESC2 = TDPSessionDesc2;
LPDPSESSIONDESC2 = PDPSessionDesc2;
 
const
(*
* Applications cannot create new players in this session.
*)
DPSESSION_NEWPLAYERSDISABLED = $00000001;
 
(*
* If the DirectPlay object that created the session, the host,
* quits, then the host will attempt to migrate to another
* DirectPlay object so that new players can continue to be created
* and new applications can join the session.
*)
DPSESSION_MIGRATEHOST = $00000004;
 
(*
* This flag tells DirectPlay not to set the idPlayerTo and idPlayerFrom
* fields in player messages. This cuts two DWORD's off the message
* overhead.
*)
DPSESSION_NOMESSAGEID = $00000008;
 
(*
* This flag tells DirectPlay to not allow any new applications to
* join the session. Applications already in the session can still
* create new players.
*)
DPSESSION_JOINDISABLED = $00000020;
 
(*
* This flag tells DirectPlay to detect when remote players
* exit abnormally (e.g. their computer or modem gets unplugged)
*)
DPSESSION_KEEPALIVE = $00000040;
 
(*
* This flag tells DirectPlay not to send a message to all players
* when a players remote data changes
*)
DPSESSION_NODATAMESSAGES = $00000080;
 
(*
* This flag indicates that the session belongs to a secure server
* and needs user authentication
*)
DPSESSION_SECURESERVER = $00000100;
 
(*
* This flag indicates that the session is private and requirs a password
* for EnumSessions as well as Open.
*)
DPSESSION_PRIVATE = $00000200;
 
(*
* This flag indicates that the session requires a password for joining.
*)
DPSESSION_PASSWORDREQUIRED = $00000400;
 
(*
* This flag tells DirectPlay to route all messages through the server
*)
DPSESSION_MULTICASTSERVER = $00000800;
 
(*
* This flag tells DirectPlay to only download information about the
* DPPLAYER_SERVERPLAYER.
*)
DPSESSION_CLIENTSERVER = $00001000;
 
(*
* This flag tells DirectPlay to use the protocol built into dplay
* for reliability and statistics all the time. When this bit is
* set, only other sessions with this bit set can join or be joined.
*)
DPSESSION_DIRECTPLAYPROTOCOL = $00002000;
 
(*
* This flag tells DirectPlay that preserving order of received
* packets is not important, when using reliable delivery. This
* will allow messages to be indicated out of order if preceding
* messages have not yet arrived. Otherwise DPLAY will wait for
* earlier messages before delivering later reliable messages.
*)
DPSESSION_NOPRESERVEORDER = $00004000;
 
(*
* This flag tells DirectPlay to optimize communication for latency
*)
DPSESSION_OPTIMIZELATENCY = $00008000;
 
type
(*
* TDPName
* Used to hold the name of a DirectPlay entity
* like a player or a group
*)
PDPName = ^TDPName;
TDPName = packed record
TDPName = record
dwSize: DWORD; // Size of structure
dwFlags: DWORD; // Not used. Must be zero.
case Integer of
0 : (
lpszShortName : PCharAW; // The short or friendly name
lpszLongName : PCharAW; // The long or formal name
lpszShortName: LPWSTR; // The short or friendly name - Unicode
lpszLongName: LPWSTR // The long or formal name - Unicode
);
1 : (
lpszShortNameA : PAnsiChar;
lpszLongNameA : PAnsiChar;
lpszShortNameA: LPSTR; // The short or friendly name - ANSI
lpszLongNameA: LPSTR // The long or formal name - ANSI
);
2 : (
lpszShortNameW : PWideChar;
lpszLongNameW : PWideChar;
);
end;
 
DPNAME = TDPName;
LPDPNAME = PDPName;
 
(*
* TDPCredentials
* Used to hold the user name and password of a DirectPlay user
14823,75 → 9882,79
*)
 
PDPCredentials = ^TDPCredentials;
TDPCredentials = packed record
TDPCredentials = record
dwSize: DWORD; // Size of structure
dwFlags: DWORD; // Not used. Must be zero.
case Integer of
0 : (
lpszUsername: PCharAW; // User name of the account
lpszPassword: PCharAW; // Password of the account
lpszDomain: PCharAW; // Domain name of the account
lpszUsername: LPWSTR; // User name of the account - Unicode
lpszPassword: LPWSTR; // Password of the account - Unicode
lpszDomain: LPWSTR; // Domain name of the account - Unicode
);
1 : (
lpszUsernameA: PAnsiChar; // User name of the account
lpszPasswordA: PAnsiChar; // Password of the account
lpszDomainA: PAnsiChar; // Domain name of the account
lpszUsernameA: LPSTR; // User name of the account - ANSI
lpszPasswordA: LPSTR; // Password of the account - ANSI
lpszDomainA: LPSTR // Domain name of the account - ANSI
);
2 : (
lpszUsernameW: PWideChar; // User name of the account
lpszPasswordW: PWideChar; // Password of the account
lpszDomainW: PWideChar; // Domain name of the account
);
end;
 
DPCREDENTIALS = TDPCredentials;
LPDPCREDENTIALS = PDPCredentials;
 
(*
* TDPSecurityDesc
* DPSECURITYDESC
* Used to describe the security properties of a DirectPlay
* session instance
*)
 
PDPSecurityDesc = ^TDPSecurityDesc;
TDPSecurityDesc = packed record
TDPSecurityDesc = record
dwSize: DWORD; // Size of structure
dwFlags: DWORD; // Not used. Must be zero.
case Integer of
0 : (
lpszSSPIProvider : PCharAW; // SSPI provider name
lpszCAPIProvider : PCharAW; // CAPI provider name
lpszSSPIProvider: LPWSTR; // SSPI provider name - Unicode
lpszCAPIProvider: LPWSTR; // CAPI provider name - Unicode
dwCAPIProviderType: DWORD; // Crypto Service Provider type
dwEncryptionAlgorithm: DWORD; // Encryption Algorithm type
);
1 : (
lpszSSPIProviderA : PAnsiChar; // SSPI provider name
lpszCAPIProviderA : PAnsiChar; // CAPI provider name
lpszSSPIProviderA: LPSTR; // SSPI provider name - ANSI
lpszCAPIProviderA: LPSTR; // CAPI provider name - ANSI
);
2 : (
lpszSSPIProviderW : PWideChar; // SSPI provider name
lpszCAPIProviderW : PWideChar; // CAPI provider name
);
end;
 
DPSECURITYDESC = TDPSecurityDesc;
LPDPSECURITYDESC = PDPSecurityDesc;
 
(*
* DPACCOUNTDESC
* TDPAccountDesc
* Used to describe a user membership account
*)
 
PDPAccountDesc = ^TDPAccountDesc;
TDPAccountDesc = packed record
TDPAccountDesc = record
dwSize: DWORD; // Size of structure
dwFlags: DWORD; // Not used. Must be zero.
case Integer of
0 : (lpszAccountID : PCharAW); // Account identifier
1 : (lpszAccountIDA : PAnsiChar);
2 : (lpszAccountIDW : PWideChar);
0: (
lpszAccountID: LPWSTR; // Account identifier - Unicode
);
1: (
lpszAccountIDA: LPSTR; // Account identifier - ANSI
);
end;
 
DPACCOUNTDESC = TDPAccountDesc;
LPDPACCOUNTDESC = PDPAccountDesc;
 
(*
* TDPLConnection
* Used to hold all in the informaion needed to connect
* an application to a session or create a session
*)
 
PDPLConnection = ^TDPLConnection;
TDPLConnection = packed record
TDPLConnection = record
dwSize: DWORD; // Size of this structure
dwFlags: DWORD; // Flags specific to this structure
lpSessionDesc: PDPSessionDesc2; // Pointer to session desc to use on connect
14901,796 → 9964,345
dwAddressSize: DWORD; // Size of address data
end;
 
DPLCONNECTION = TDPLConnection;
LPDPLCONNECTION = PDPLConnection;
 
(*
* TDPChat
* Used to hold the a DirectPlay chat message
*)
 
PDPChat = ^TDPChat;
TDPChat = packed record
TDPChat = record
dwSize: DWORD;
dwFlags: DWORD;
case Integer of
0 : (lpszMessage : PCharAW); // Message string
1 : (lpszMessageA : PAnsiChar);
2 : (lpszMessageW : PWideChar);
0: (
lpszMessage: LPWSTR; // Message string - Unicode
);
1: (
lpszMessageA: LPSTR; // Message string - ANSI
);
end;
 
DPCHAT = TDPChat;
LPDPCHAT = PDPChat;
 
(*
* TSGBuffer
* SGBUFFER
* Scatter Gather Buffer used for SendEx
*)
 
PSGBuffer = ^TSGBuffer;
TSGBuffer = packed record
len: UINT;
pData: PUCHAR;
TSGBuffer = record
len: UINT; // length of buffer data
pData: PUChar; // pointer to buffer data
end;
 
(****************************************************************************
*
* Prototypes for DirectPlay callback functions
*
****************************************************************************)
SGBUFFER = TSGBuffer;
LPSGBUFFER = PSGBuffer;
 
(*
* Callback for IDirectPlay2::EnumSessions
*)
TDPEnumSessionsCallback2 = function(lpThisSD: PDPSessionDesc2;
{ Prototypes for DirectPlay callback functions }
 
{ Callback for IDirectPlay2::EnumSessions }
 
TDPEnumSessionsCallback2 = function(const lpThisSD: TDPSessionDesc2;
var lpdwTimeOut: DWORD; dwFlags: DWORD; lpContext: Pointer) : BOOL; stdcall;
LPDPENUMSESSIONSCALLBACK2 = TDPEnumSessionsCallback2;
 
const
(*
* This flag is set on the EnumSessions callback dwFlags parameter when
* the time out has occurred. There will be no session data for this
* callback. If *lpdwTimeOut is set to a non-zero value and the
* EnumSessionsCallback function returns TRUE then EnumSessions will
* continue waiting until the next timeout occurs. Timeouts are in
* milliseconds.
*)
DPESC_TIMEDOUT = $00000001;
 
type
(*
* Callback for IDirectPlay2.EnumPlayers
* IDirectPlay2.EnumGroups
* IDirectPlay2.EnumGroupPlayers
*)
TDPEnumPlayersCallback2 = function(DPID: TDPID; dwPlayerType: DWORD;
TDPEnumPlayersCallback2 = function(dpId: TDPID; dwPlayerType: DWORD;
const lpName: TDPName; dwFlags: DWORD; lpContext: Pointer) : BOOL; stdcall;
LPDPENUMPLAYERSCALLBACK2 = TDPEnumPlayersCallback2;
 
 
(*
* ANSI callback for DirectPlayEnumerate
* This callback prototype will be used if compiling
* for ANSI strings
*)
TDPEnumDPCallbackA = function(const lpguidSP: TGUID; lpSPName: PAnsiChar;
TDPEnumDPCallback = function(const lpguidSP: TGUID; lpSPName: LPWSTR;
dwMajorVersion: DWORD; dwMinorVersion: DWORD; lpContext: Pointer) : BOOL; stdcall;
LPDPENUMDPCALLBACK = TDPEnumDPCallback;
 
(*
* Unicode callback for DirectPlayEnumerate
* This callback prototype will be used if compiling
* for Unicode strings
*)
TDPEnumDPCallbackW = function(const lpguidSP: TGUID; lpSPName: PWideChar;
TDPEnumDPCallbackA = function(const lpguidSP: TGUID; lpSPName: LPSTR;
dwMajorVersion: DWORD; dwMinorVersion: DWORD; lpContext: Pointer) : BOOL; stdcall;
LPDPENUMDPCALLBACKA = TDPEnumDPCallbackA;
 
(*
* Callback for DirectPlayEnumerate
*)
{$IFDEF UNICODE}
TDPEnumDPCallback = TDPEnumDPCallbackW;
{$ELSE}
TDPEnumDPCallback = TDPEnumDPCallbackA;
{$ENDIF}
 
(*
* Callback for IDirectPlay3(A/W).EnumConnections
*)
TDPEnumConnectionsCallback = function(const lpguidSP: TGUID;
lpConnection: Pointer; dwConnectionSize: DWORD; const lpName: TDPName;
dwFlags: DWORD; lpContext: Pointer) : BOOL; stdcall;
LPDPENUMCONNECTIONSCALLBACK = TDPEnumConnectionsCallback;
 
(*
* API's
*)
{ API's }
 
var
DirectPlayEnumerate : function (lpEnumDPCallback: TDPEnumDPCallback;
function DirectPlayEnumerateA(lpEnumDPCallback: TDPEnumDPCallbackA;
lpContext: Pointer) : HResult; stdcall;
DirectPlayEnumerateA : function (lpEnumDPCallback: TDPEnumDPCallbackA;
function DirectPlayEnumerateW(lpEnumDPCallback: TDPEnumDPCallback;
lpContext: Pointer) : HResult; stdcall;
DirectPlayEnumerateW : function (lpEnumDPCallback: TDPEnumDPCallbackW;
function DirectPlayEnumerate(lpEnumDPCallback: TDPEnumDPCallbackA;
lpContext: Pointer) : HResult; stdcall;
 
 
(****************************************************************************
*
* IDirectPlay2 (and IDirectPlay2A) Interface
*
****************************************************************************)
{ IDirectPlay2 (and IDirectPlay2A) Interface }
 
type
IDirectPlay2AW = interface (IUnknown)
(*** IDirectPlay2 methods ***)
IDirectPlay2 = interface(IUnknown)
['{2B74F7C0-9154-11CF-A9CD-00AA006886E3}']
// IDirectPlay2 methods
function AddPlayerToGroup(idGroup: TDPID; idPlayer: TDPID) : HResult; stdcall;
function Close: HResult; stdcall;
function CreateGroup(out lpidGroup: TDPID; lpGroupName: PDPName;
lpData: Pointer; dwDataSize: DWORD; dwFlags: DWORD) : HResult; stdcall;
function CreatePlayer(out lpidPlayer: TDPID; pPlayerName: PDPName;
hEvent: THandle; lpData: Pointer; dwDataSize: DWORD; dwFlags: DWORD) : HResult; stdcall;
function CreateGroup(var lpidGroup: TDPID; const lpGroupName: TDPName;
const lpData; dwDataSize: DWORD; dwFlags: DWORD): HResult; stdcall;
function CreatePlayer(var lpidPlayer: TDPID; const pPlayerName: TDPName;
hEvent: THandle; const lpData; dwDataSize: DWORD; dwFliags: DWORD): HResult; stdcall;
function DeletePlayerFromGroup(idGroup: TDPID; idPlayer: TDPID) : HResult; stdcall;
function DestroyGroup(idGroup: TDPID) : HResult; stdcall;
function DestroyPlayer(idPlayer: TDPID) : HResult; stdcall;
function EnumGroupPlayers(idGroup: TDPID; lpguidInstance: PGUID;
function EnumGroupPlayers(idGroup: TDPID; const lpguidInstance: TGUID;
lpEnumPlayersCallback2: TDPEnumPlayersCallback2; lpContext: Pointer;
dwFlags: DWORD) : HResult; stdcall;
function EnumGroups(lpguidInstance: PGUID; lpEnumPlayersCallback2:
TDPEnumPlayersCallback2; lpContext: Pointer; dwFlags: DWORD) : HResult; stdcall;
function EnumPlayers(lpguidInstance: PGUID; lpEnumPlayersCallback2:
TDPEnumPlayersCallback2; lpContext: Pointer; dwFlags: DWORD) : HResult; stdcall;
function EnumGroups(const lpguidInstance: TGUID; lpEnumPlayersCallback2:
LPDPENUMPLAYERSCALLBACK2; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
function EnumPlayers(const lpguidInstance: TGUID; lpEnumPlayersCallback2:
LPDPENUMPLAYERSCALLBACK2; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
function EnumSessions(const lpsd: TDPSessionDesc2; dwTimeout: DWORD;
lpEnumSessionsCallback2: TDPEnumSessionsCallback2; lpContext: Pointer;
dwFlags: DWORD) : HResult; stdcall;
function GetCaps(var lpDPCaps: TDPCaps; dwFlags: DWORD) : HResult; stdcall;
function GetGroupData(idGroup: TDPID; lpData: Pointer; var lpdwDataSize: DWORD;
function GetGroupData(idGroup: TDPID; var lpData; var lpdwDataSize: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function GetGroupName(idGroup: TDPID; lpData: Pointer; var lpdwDataSize: DWORD) :
HResult; stdcall;
function GetGroupName(idGroup: TDPID; var lpData; var lpdwDataSize: DWORD): HResult; stdcall;
function GetMessageCount(idPlayer: TDPID; var lpdwCount: DWORD) : HResult; stdcall;
function GetPlayerAddress(idPlayer: TDPID; lpAddress: Pointer;
function GetPlayerAddress(idPlayer: TDPID; var lpAddress;
var lpdwAddressSize: DWORD) : HResult; stdcall;
function GetPlayerCaps(idPlayer: TDPID; var lpPlayerCaps: TDPCaps;
dwFlags: DWORD) : HResult; stdcall;
function GetPlayerData(idPlayer: TDPID; lpData: Pointer; var lpdwDataSize: DWORD;
function GetPlayerData(idPlayer: TDPID; var lpData; var lpdwDataSize: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function GetPlayerName(idPlayer: TDPID; lpData: Pointer; var lpdwDataSize: DWORD) : HResult; stdcall;
function GetSessionDesc(lpData: Pointer; var lpdwDataSize: DWORD) : HResult; stdcall;
function GetPlayerName(idPlayer: TDPID; var lpData; var lpdwDataSize: DWORD): HResult; stdcall;
function GetSessionDesc(var lpData; var lpdwDataSize: DWORD): HResult; stdcall;
function Initialize(const lpGUID: TGUID) : HResult; stdcall;
function Open(var lpsd: TDPSessionDesc2; dwFlags: DWORD) : HResult; stdcall;
function Receive(var lpidFrom: TDPID; var lpidTo: TDPID; dwFlags: DWORD;
lpData: Pointer; var lpdwDataSize: DWORD) : HResult; stdcall;
function Send(idFrom: TDPID; lpidTo: TDPID; dwFlags: DWORD; var lpData;
var lpData; var lpdwDataSize: DWORD): HResult; stdcall;
function Send(idFrom: TDPID; lpidTo: TDPID; dwFlags: DWORD; const lpData;
lpdwDataSize: DWORD) : HResult; stdcall;
function SetGroupData(idGroup: TDPID; lpData: Pointer; dwDataSize: DWORD;
function SetGroupData(idGroup: TDPID; const lpData; dwDataSize: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function SetGroupName(idGroup: TDPID; lpGroupName: PDPName;
function SetGroupName(idGroup: TDPID; const lpGroupName: TDPName;
dwFlags: DWORD) : HResult; stdcall;
function SetPlayerData(idPlayer: TDPID; lpData: Pointer; dwDataSize: DWORD;
function SetPlayerData(idPlayer: TDPID; const lpData; dwDataSize: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function SetPlayerName(idPlayer: TDPID; lpPlayerName: PDPName;
function SetPlayerName(idPlayer: TDPID; const lpPlayerName: TDPName;
dwFlags: DWORD) : HResult; stdcall;
function SetSessionDesc(var lpSessDesc: TDPSessionDesc2; dwFlags: DWORD) :
HResult; stdcall;
function SetSessionDesc(const lpSessDesc: TDPSessionDesc2; dwFlags: DWORD): HResult; stdcall;
end;
 
IDirectPlay2W = interface (IDirectPlay2AW)
['{2B74F7C0-9154-11CF-A9CD-00AA006886E3}']
IDirectPlay2A = interface(IDirectPlay2)
['{9D460580-A822-11CF-960C-0080C7534E82}']
end;
IDirectPlay2A = interface (IDirectPlay2AW)
['{9d460580-a822-11cf-960c-0080c7534e82}']
end;
 
{$IFDEF UNICODE}
IDirectPlay2 = IDirectPlay2W;
{$ELSE}
IDirectPlay2 = IDirectPlay2A;
{$ENDIF}
{ IDirectPlay3 (and IDirectPlay3A) Interface }
 
(****************************************************************************
*
* IDirectPlay3 (and IDirectPlay3A) Interface
*
****************************************************************************)
 
IDirectPlay3AW = interface (IDirectPlay2AW)
(*** IDirectPlay3 methods ***)
IDirectPlay3 = interface(IDirectPlay2)
['{133EFE40-32DC-11D0-9CFB-00A0C90A43CB}']
// IDirectPlay3 methods
function AddGroupToGroup(idParentGroup: TDPID; idGroup: TDPID) : HResult; stdcall;
function CreateGroupInGroup(idParentGroup: TDPID; var lpidGroup: TDPID;
lpGroupName: PDPName; lpData: Pointer; dwDataSize: DWORD;
var lpGroupName: TDPName; const lpData; dwDataSize: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function DeleteGroupFromGroup(idParentGroup: TDPID; idGroup: TDPID) : HResult; stdcall;
function EnumConnections(lpguidApplication: PGUID;
function EnumConnections(const lpguidApplication: TGUID;
lpEnumCallback: TDPEnumConnectionsCallback; lpContext: Pointer;
dwFlags: DWORD) : HResult; stdcall;
function EnumGroupsInGroup(idGroup: TDPID; lpguidInstance: PGUID;
function EnumGroupsInGroup(idGroup: TDPID; const lpguidInstance: TGUID;
lpEnumPlayersCallback2: TDPEnumPlayersCallback2; lpContext: Pointer;
dwFlags: DWORD) : HResult; stdcall;
function GetGroupConnectionSettings(dwFlags: DWORD; idGroup: TDPID;
lpData: Pointer; var lpdwDataSize: DWORD) : HResult; stdcall;
var lpData; var lpdwDataSize: DWORD): HResult; stdcall;
function InitializeConnection(lpConnection: Pointer; dwFlags: DWORD) : HResult; stdcall;
function SecureOpen(var lpsd: TDPSessionDesc2; dwFlags: DWORD;
var lpSecurity: TDPSecurityDesc; var lpCredentials: TDPCredentials) : HResult; stdcall;
function SecureOpen(const lpsd: TDPSessionDesc2; dwFlags: DWORD;
const lpSecurity: TDPSecurityDesc; const lpCredentials: TDPCredentials): HResult; stdcall;
function SendChatMessage(idFrom: TDPID; idTo: TDPID; dwFlags: DWORD;
var lpChatMessage: TDPChat) : HResult; stdcall;
const lpChatMessage: TDPChat): HResult; stdcall;
function SetGroupConnectionSettings(dwFlags: DWORD; idGroup: TDPID;
var lpConnection: TDPLConnection) : HResult; stdcall;
const lpConnection: TDPLConnection): HResult; stdcall;
function StartSession(dwFlags: DWORD; idGroup: TDPID) : HResult; stdcall;
function GetGroupFlags(idGroup: TDPID; out lpdwFlags: DWORD) : HResult; stdcall;
function GetGroupParent(idGroup: TDPID; out lpidParent: TDPID) : HResult; stdcall;
function GetGroupFlags(idGroup: TDPID; var lpdwFlags: DWORD): HResult; stdcall;
function GetGroupParent(idGroup: TDPID; var lpidParent: TDPID): HResult; stdcall;
function GetPlayerAccount(idPlayer: TDPID; dwFlags: DWORD; var lpData;
var lpdwDataSize: DWORD) : HResult; stdcall;
function GetPlayerFlags(idPlayer: TDPID; out lpdwFlags: DWORD) : HResult; stdcall;
function GetPlayerFlags(idPlayer: TDPID; var lpdwFlags: DWORD): HResult; stdcall;
end;
 
 
IDirectPlay3W = interface (IDirectPlay3AW)
['{133EFE40-32DC-11D0-9CFB-00A0C90A43CB}']
IDirectPlay3A = interface(IDirectPlay3)
['{133EFE41-32DC-11D0-9CFB-00A0C90A43CB}']
end;
IDirectPlay3A = interface (IDirectPlay3AW)
['{133efe41-32dc-11d0-9cfb-00a0c90a43cb}']
end;
 
{$IFDEF UNICODE}
IDirectPlay3 = IDirectPlay3W;
{$ELSE}
IDirectPlay3 = IDirectPlay3A;
{$ENDIF}
{ IDirectPlay4 (and IDirectPlay4A) Interface }
 
 
(****************************************************************************
*
* IDirectPlay4 (and IDirectPlay4A) Interface
*
****************************************************************************)
 
IDirectPlay4AW = interface (IDirectPlay3AW)
(*** IDirectPlay4 methods ***)
function GetGroupOwner(idGroup: TDPID; out idOwner: TDPID) : HResult; stdcall;
IDirectPlay4 = interface(IDirectPlay3)
['{0AB1C530-4745-11D1-A7A1-0000F803ABFC}']
// IDirectPlay4 methods
function GetGroupOwner(idGroup: TDPID; var idOwner: TDPID): HResult; stdcall;
function SetGroupOwner(idGroup: TDPID; idOwner: TDPID) : HResult; stdcall;
function SendEx(idFrom: TDPID; idTo: TDPID; dwFlags: DWORD; lpData: Pointer;
function SendEx(idFrom: TDPID; idTo: TDPID; dwFlags: DWORD; const pData;
dwDataSize: DWORD; dwPriority: DWORD; dwTimeout: DWORD;
lpContext: Pointer; lpdwMsgId: PDWORD) : HResult; stdcall;
function GetMessageQueue(idFrom: TDPID; idTo: TDPID; dwFlags: DWORD;
lpdwNumMsgs: PDWORD; lpdwNumBytes: PDWORD) : HResult; stdcall;
var lpdwNumMsgs: DWORD; var lpdwNumBytes: DWORD): HResult; stdcall;
function CancelMessage(dwMessageID: DWORD; dwFlags: DWORD) : HResult; stdcall;
function CancelPriority(dwMinPriority: DWORD; dwMaxPriority: DWORD; dwFlags: DWORD) : HResult; stdcall;
end;
 
 
IDirectPlay4W = interface (IDirectPlay4AW)
['{0ab1c530-4745-11D1-a7a1-0000f803abfc}']
IDirectPlay4A = interface(IDirectPlay4)
['{0AB1C531-4745-11D1-A7A1-0000F803ABFC}']
end;
IDirectPlay4A = interface (IDirectPlay4AW)
['{0ab1c531-4745-11D1-a7a1-0000f803abfc}']
end;
 
{$IFDEF UNICODE}
IDirectPlay4 = IDirectPlay4W;
{$ELSE}
IDirectPlay4 = IDirectPlay4A;
{$ENDIF}
 
 
const
(****************************************************************************
*
* EnumConnections API flags
*
****************************************************************************)
{ EnumConnections API flags }
 
(*
* Enumerate Service Providers
*)
DPCONNECTION_DIRECTPLAY = $00000001;
 
(*
* Enumerate Lobby Providers
*)
DPCONNECTION_DIRECTPLAYLOBBY = $00000002;
 
(****************************************************************************
*
* EnumPlayers API flags
*
****************************************************************************)
{ EnumPlayers API flags }
 
(*
* Enumerate all players in the current session
*)
DPENUMPLAYERS_ALL = $00000000;
DPENUMGROUPS_ALL = DPENUMPLAYERS_ALL;
 
(*
* Enumerate only local (created by this application) players
* or groups
*)
DPENUMPLAYERS_LOCAL = $00000008;
DPENUMGROUPS_LOCAL = DPENUMPLAYERS_LOCAL;
 
(*
* Enumerate only remote (non-local) players
* or groups
*)
DPENUMPLAYERS_REMOTE = $00000010;
DPENUMGROUPS_REMOTE = DPENUMPLAYERS_REMOTE;
 
(*
* Enumerate groups along with the players
*)
DPENUMPLAYERS_GROUP = $00000020;
 
(*
* Enumerate players or groups in another session
* (must supply lpguidInstance)
*)
DPENUMPLAYERS_SESSION = $00000080;
DPENUMGROUPS_SESSION = DPENUMPLAYERS_SESSION;
 
(*
* Enumerate server players
*)
DPENUMPLAYERS_SERVERPLAYER = $00000100;
 
(*
* Enumerate spectator players
*)
DPENUMPLAYERS_SPECTATOR = $00000200;
 
(*
* Enumerate shortcut groups
*)
DPENUMGROUPS_SHORTCUT = $00000400;
 
(*
* Enumerate staging area groups
*)
DPENUMGROUPS_STAGINGAREA = $00000800;
 
(*
* Enumerate hidden groups
*)
DPENUMGROUPS_HIDDEN = $00001000;
 
(*
* Enumerate the group's owner
*)
DPENUMPLAYERS_OWNER = $00002000;
 
(****************************************************************************
*
* CreatePlayer API flags
*
****************************************************************************)
{ CreatePlayer API flags }
 
(*
* This flag indicates that this player should be designated
* the server player. The app should specify this at CreatePlayer.
*)
DPPLAYER_SERVERPLAYER = DPENUMPLAYERS_SERVERPLAYER;
 
(*
* This flag indicates that this player should be designated
* a spectator. The app should specify this at CreatePlayer.
*)
DPPLAYER_SPECTATOR = DPENUMPLAYERS_SPECTATOR;
 
(*
* This flag indicates that this player was created locally.
* (returned from GetPlayerFlags)
*)
DPPLAYER_LOCAL = DPENUMPLAYERS_LOCAL;
 
(*
* This flag indicates that this player is the group's owner
* (Only returned in EnumGroupPlayers)
*)
DPPLAYER_OWNER = DPENUMPLAYERS_OWNER;
 
(****************************************************************************
*
* CreateGroup API flags
*
****************************************************************************)
{ CreateGroup API flags }
 
(*
* This flag indicates that the StartSession can be called on the group.
* The app should specify this at CreateGroup, or CreateGroupInGroup.
*)
DPGROUP_STAGINGAREA = DPENUMGROUPS_STAGINGAREA;
 
(*
* This flag indicates that this group was created locally.
* (returned from GetGroupFlags)
*)
DPGROUP_LOCAL = DPENUMGROUPS_LOCAL;
 
(*
* This flag indicates that this group was created hidden.
*)
DPGROUP_HIDDEN = DPENUMGROUPS_HIDDEN;
 
(****************************************************************************
*
* EnumSessions API flags
*
****************************************************************************)
{ EnumSessions API flags }
 
(*
* Enumerate sessions which can be joined
*)
DPENUMSESSIONS_AVAILABLE = $00000001;
 
(*
* Enumerate all sessions even if they can't be joined.
*)
DPENUMSESSIONS_ALL = $00000002;
 
(*
* Start an asynchronous enum sessions
*)
DPENUMSESSIONS_ASYNC = $00000010;
 
(*
* Stop an asynchronous enum sessions
*)
DPENUMSESSIONS_STOPASYNC = $00000020;
 
(*
* Enumerate sessions even if they require a password
*)
DPENUMSESSIONS_PASSWORDREQUIRED = $00000040;
 
(*
* Return status about progress of enumeration instead of
* showing any status dialogs.
*)
DPENUMSESSIONS_RETURNSTATUS = $00000080;
 
(****************************************************************************
*
* GetCaps and GetPlayerCaps API flags
*
****************************************************************************)
{ GetCaps and GetPlayerCaps API flags }
 
(*
* The latency returned should be for guaranteed message sending.
* Default is non-guaranteed messaging.
*)
DPGETCAPS_GUARANTEED = $00000001;
 
(****************************************************************************
*
* GetGroupData, GetPlayerData API flags
* Remote and local Group/Player data is maintained separately.
* Default is DPGET_REMOTE.
*
****************************************************************************)
{ GetGroupData, GetPlayerData API flags }
 
(*
* Get the remote data (set by any DirectPlay object in
* the session using DPSET_REMOTE)
*)
DPGET_REMOTE = $00000000;
 
(*
* Get the local data (set by this DirectPlay object
* using DPSET_LOCAL)
*)
DPGET_LOCAL = $00000001;
 
(****************************************************************************
*
* Open API flags
*
****************************************************************************)
{ Open API flags }
 
(*
* Join the session that is described by the DPSESSIONDESC2 structure
*)
DPOPEN_JOIN = $00000001;
 
(*
* Create a new session as described by the DPSESSIONDESC2 structure
*)
DPOPEN_CREATE = $00000002;
 
(*
* Return status about progress of open instead of showing
* any status dialogs.
*)
DPOPEN_RETURNSTATUS = DPENUMSESSIONS_RETURNSTATUS;
 
(****************************************************************************
*
* DPLCONNECTION flags
*
****************************************************************************)
{ TDPLConnection flags }
 
(*
* This application should create a new session as
* described by the DPSESIONDESC structure
*)
DPLCONNECTION_CREATESESSION = DPOPEN_CREATE;
 
(*
* This application should join the session described by
* the DPSESIONDESC structure with the lpAddress data
*)
DPLCONNECTION_JOINSESSION = DPOPEN_JOIN;
 
(****************************************************************************
*
* Receive API flags
* Default is DPRECEIVE_ALL
*
****************************************************************************)
{ Receive API flags }
 
(*
* Get the first message in the queue
*)
DPRECEIVE_ALL = $00000001;
 
(*
* Get the first message in the queue directed to a specific player
*)
DPRECEIVE_TOPLAYER = $00000002;
 
(*
* Get the first message in the queue from a specific player
*)
DPRECEIVE_FROMPLAYER = $00000004;
 
(*
* Get the message but don't remove it from the queue
*)
DPRECEIVE_PEEK = $00000008;
 
(****************************************************************************
*
* Send API flags
*
****************************************************************************)
{ Send API flags }
 
(*
* Send the message using a guaranteed send method.
* Default is non-guaranteed.
*)
DPSEND_GUARANTEED = $00000001;
 
(*
* This flag is obsolete. It is ignored by DirectPlay
*)
DPSEND_HIGHPRIORITY = $00000002;
 
(*
* This flag is obsolete. It is ignored by DirectPlay
*)
DPSEND_OPENSTREAM = $00000008;
 
(*
* This flag is obsolete. It is ignored by DirectPlay
*)
DPSEND_CLOSESTREAM = $00000010;
 
(*
* Send the message digitally signed to ensure authenticity.
*)
DPSEND_SIGNED = $00000020;
 
(*
* Send the message with encryption to ensure privacy.
*)
DPSEND_ENCRYPTED = $00000040;
 
(*
* The message is a lobby system message
*)
DPSEND_LOBBYSYSTEMMESSAGE = $00000080;
 
(*
* andyco - added this so we can make addforward async.
* needs to be sanitized when we add / expose full async
* support. 8/3/97.
*)
DPSEND_ASYNC = $00000200;
 
(*
* When a message is completed, don't tell me.
* by default the application is notified with a system message.
*)
DPSEND_NOSENDCOMPLETEMSG = $00000400;
 
 
(*
* Maximum priority for sends available to applications
*)
DPSEND_MAX_PRI = $0000FFFF;
DPSEND_MAX_PRIORITY = DPSEND_MAX_PRI;
 
(****************************************************************************
*
* SetGroupData, SetGroupName, SetPlayerData, SetPlayerName,
* SetSessionDesc API flags.
* Default is DPSET_REMOTE.
*
****************************************************************************)
{ SetGroupData, SetGroupName, SetPlayerData, SetPlayerName,
SetSessionDesc API flags. }
 
(*
* Propagate the data to all players in the session
*)
DPSET_REMOTE = $00000000;
 
(*
* Do not propagate the data to other players
*)
DPSET_LOCAL = $00000001;
 
(*
* Used with DPSET_REMOTE, use guaranteed message send to
* propagate the data
*)
DPSET_GUARANTEED = $00000002;
 
(****************************************************************************
*
* GetMessageQueue API flags.
* Default is DPMESSAGEQUEUE_SEND
*
****************************************************************************)
{ GetMessageQueue API flags. }
 
(*
* Get Send Queue - requires Service Provider Support
*)
DPMESSAGEQUEUE_SEND = $00000001;
DPMESSAGEQUEUE_SEND = $00000001; // Default
DPMESSAGEQUEUE_RECEIVE = $00000002; // Default
 
(*
* Get Receive Queue
*)
DPMESSAGEQUEUE_RECEIVE = $00000002;
{ Connect API flags }
 
(****************************************************************************
*
* Connect API flags
*
****************************************************************************)
 
(*
* Start an asynchronous connect which returns status codes
*)
DPCONNECT_RETURNSTATUS = DPENUMSESSIONS_RETURNSTATUS;
 
(****************************************************************************
*
* DirectPlay system messages and message data structures
*
* All system message come 'From' player DPID_SYSMSG. To determine what type
* of message it is, cast the lpData from Receive to TDPMsg_Generic and check
* the dwType member against one of the following DPSYS_xxx constants. Once
* a match is found, cast the lpData to the corresponding of the DPMSG_xxx
* structures to access the data of the message.
*
****************************************************************************)
{ DirectPlay system messages and message data structures }
 
(*
* A new player or group has been created in the session
* Use TDPMsg_CreatePlayerOrGroup. Check dwPlayerType to see if it
* is a player or a group.
*)
DPSYS_CREATEPLAYERORGROUP = $0003;
 
(*
* A player has been deleted from the session
* Use TDPMsg_DestroyPlayerOrGroup
*)
DPSYS_DESTROYPLAYERORGROUP = $0005;
 
(*
* A player has been added to a group
* Use DPMSG_ADDPLAYERTOGROUP
*)
DPSYS_ADDPLAYERTOGROUP = $0007;
 
(*
* A player has been removed from a group
* Use DPMSG_DELETEPLAYERFROMGROUP
*)
DPSYS_DELETEPLAYERFROMGROUP = $0021;
 
(*
* This DirectPlay object lost its connection with all the
* other players in the session.
* Use DPMSG_SESSIONLOST.
*)
DPSYS_SESSIONLOST = $0031;
 
(*
* The current host has left the session.
* This DirectPlay object is now the host.
* Use DPMSG_HOST.
*)
DPSYS_HOST = $0101;
 
(*
* The remote data associated with a player or
* group has changed. Check dwPlayerType to see
* if it is a player or a group
* Use DPMSG_SETPLAYERORGROUPDATA
*)
DPSYS_SETPLAYERORGROUPDATA = $0102;
 
(*
* The name of a player or group has changed.
* Check dwPlayerType to see if it is a player
* or a group.
* Use TDPMsg_SetPlayerOrGroupName
*)
DPSYS_SETPLAYERORGROUPNAME = $0103;
 
(*
* The session description has changed.
* Use DPMSG_SETSESSIONDESC
*)
DPSYS_SETSESSIONDESC = $0104;
 
(*
* A group has been added to a group
* Use TDPMsg_AddGroupToGroup
*)
DPSYS_ADDGROUPTOGROUP = $0105;
 
(*
* A group has been removed from a group
* Use DPMsg_DeleteGroupFromGroup
*)
DPSYS_DELETEGROUPFROMGROUP = $0106;
 
(*
* A secure player-player message has arrived.
* Use DPMSG_SECUREMESSAGE
*)
DPSYS_SECUREMESSAGE = $0107;
 
(*
* Start a new session.
* Use DPMSG_STARTSESSION
*)
DPSYS_STARTSESSION = $0108;
 
(*
* A chat message has arrived
* Use DPMSG_CHAT
*)
DPSYS_CHAT = $0109;
 
(*
* The owner of a group has changed
* Use DPMSG_SETGROUPOWNER
*)
DPSYS_SETGROUPOWNER = $010A;
DPSYS_SENDCOMPLETE = $010d;
 
(*
* An async send has finished, failed or been cancelled
* Use DPMSG_SENDCOMPLETE
*)
DPSYS_SENDCOMPLETE = $010D;
 
(*
* Used in the dwPlayerType field to indicate if it applies to a group
* or a player
*)
{ Used in the dwPlayerType field to indicate if it applies to a group or a player}
 
DPPLAYERTYPE_GROUP = $00000000;
DPPLAYERTYPE_PLAYER = $00000001;
 
{ TDPMsg_Generic }
 
type
(*
* TDPMsg_Generic
* Generic message structure used to identify the message type.
*)
PDPMsg_Generic = ^TDPMsg_Generic;
TDPMsg_Generic = packed record
TDPMsg_Generic = record
dwType: DWORD; // Message type
end;
 
(*
* TDPMsg_CreatePlayerOrGroup
* System message generated when a new player or group
* created in the session with information about it.
*)
DPMSG_GENERIC = TDPMsg_Generic;
LPDPMSG_GENERIC = PDPMsg_Generic;
 
{ TDPMsg_CreatePlayerOrGroup }
 
PDPMsg_CreatePlayerOrGroup = ^TDPMsg_CreatePlayerOrGroup;
TDPMsg_CreatePlayerOrGroup = packed record
TDPMsg_CreatePlayerOrGroup = record
dwType: DWORD; // Message type
dwPlayerType: DWORD; // Is it a player or group
DPID: TDPID; // ID of the player or group
dpId: TDPID; // ID of the player or group
dwCurrentPlayers: DWORD; // current # players & groups in session
lpData: Pointer; // pointer to remote data
dwDataSize: DWORD; // size of remote data
15701,16 → 10313,16
dwFlags: DWORD; // player or group flags
end;
 
(*
* TDPMsg_DestroyPlayerOrGroup
* System message generated when a player or group is being
* destroyed in the session with information about it.
*)
DPMSG_CREATEPLAYERORGROUP = TDPMsg_CreatePlayerOrGroup;
LPDPMSG_CREATEPLAYERORGROUP = PDPMsg_CreatePlayerOrGroup;
 
{ TDPMsg_DestroyPlayerOrGroup }
 
PDPMsg_DestroyPlayerOrGroup= ^TDPMsg_DestroyPlayerOrGroup;
TDPMsg_DestroyPlayerOrGroup = packed record
TDPMsg_DestroyPlayerOrGroup = record
dwType: DWORD; // Message type
dwPlayerType: DWORD; // Is it a player or group
DPID: TDPID; // player ID being deleted
dpId: TDPID; // player ID being deleted
lpLocalData: Pointer; // copy of players local data
dwLocalDataSize: DWORD; // sizeof local data
lpRemoteData: Pointer; // copy of players remote data
15722,106 → 10334,107
dwFlags: DWORD; // player or group flags
end;
 
(*
* DPMSG_ADDPLAYERTOGROUP
* System message generated when a player is being added
* to a group.
*)
PDPMsg_AddPlayerToGroup = ^TDPMsg_AddPlayerToGroup;
TDPMsg_AddPlayerToGroup = packed record
DPMSG_DESTROYPLAYERORGROUP = TDPMsg_DestroyPlayerOrGroup;
LPDPMSG_DESTROYPLAYERORGROUP = PDPMsg_DestroyPlayerOrGroup;
 
{ TDPMsg_AddPlayerOrGroup }
 
PDPMsg_AddPlayerOrGroup = ^TDPMsg_AddPlayerOrGroup;
TDPMsg_AddPlayerOrGroup = record
dwType: DWORD; // Message type
dpIdGroup: TDPID; // group ID being added to
dpIdPlayer: TDPID; // player ID being added
end;
 
(*
* DPMSG_DELETEPLAYERFROMGROUP
* System message generated when a player is being
* removed from a group
*)
PDPMsg_DeletePlayerFromGroup = ^TDPMsg_DeletePlayerFromGroup;
TDPMsg_DeletePlayerFromGroup = TDPMsg_AddPlayerToGroup;
DPMSG_ADDPLAYERTOGROUP = TDPMsg_AddPlayerOrGroup;
LPDPMSG_ADDPLAYERTOGROUP = PDPMsg_AddPlayerOrGroup;
 
(*
* TDPMsg_AddGroupToGroup
* System message generated when a group is being added
* to a group.
*)
{ TDPMsg_DeletePlayerFromGroup }
 
TDPMsg_DeletePlayerFromGroup = TDPMsg_AddPlayerOrGroup;
PDPMsg_DeletePlayerFromGroup = PDPMsg_AddPlayerOrGroup;
 
DPMSG_DELETEPLAYERFROMGROUP = TDPMsg_DeletePlayerFromGroup;
LPDPMSG_DELETEPLAYERFROMGROUP = PDPMsg_DeletePlayerFromGroup;
 
{ TDPMsg_AddGroupToGroup }
 
PDPMsg_AddGroupToGroup = ^TDPMsg_AddGroupToGroup;
TDPMsg_AddGroupToGroup = packed record
TDPMsg_AddGroupToGroup = record
dwType: DWORD; // Message type
dpIdParentGroup: TDPID; // group ID being added to
dpIdGroup: TDPID; // group ID being added
end;
 
(*
* DPMsg_DeleteGroupFromGroup
* System message generated when a GROUP is being
* removed from a group
*)
PDPMsg_DeleteGroupFromGroup = ^TDPMsg_DeleteGroupFromGroup;
DPMSG_ADDGROUPTOGROUP = TDPMsg_AddGroupToGroup;
LPDPMSG_ADDGROUPTOGROUP = PDPMsg_AddGroupToGroup;
 
{ TDPMsg_DeleteGroupFromGroup }
 
TDPMsg_DeleteGroupFromGroup = TDPMsg_AddGroupToGroup;
PDPMsg_DeleteGroupFromGroup = PDPMsg_AddGroupToGroup;
 
(*
* DPMSG_SETPLAYERORGROUPDATA
* System message generated when remote data for a player or
* group has changed.
*)
DPMSG_DELETEGROUPFROMGROUP = TDPMsg_DeleteGroupFromGroup;
LPDPMSG_DELETEGROUPFROMGROUP = PDPMsg_DeleteGroupFromGroup;
 
{ TDPMsg_SetPlayerOrGroupData }
 
PDPMsg_SetPlayerOrGroupData = ^TDPMsg_SetPlayerOrGroupData;
TDPMsg_SetPlayerOrGroupData = packed record
TDPMsg_SetPlayerOrGroupData = record
dwType: DWORD; // Message type
dwPlayerType: DWORD; // Is it a player or group
DPID: TDPID; // ID of player or group
dpId: TDPID; // ID of player or group
lpData: Pointer; // pointer to remote data
dwDataSize: DWORD; // size of remote data
end;
 
(*
* DPMSG_SETPLAYERORGROUPNAME
* System message generated when the name of a player or
* group has changed.
*)
DPMSG_SETPLAYERORGROUPDATA = TDPMsg_SetPlayerOrGroupData;
LPDPMSG_SETPLAYERORGROUPDATA = PDPMsg_SetPlayerOrGroupData;
 
{ TDPMsg_SetPlayerOrGroupName }
 
PDPMsg_SetPlayerOrGroupName = ^TDPMsg_SetPlayerOrGroupName;
TDPMsg_SetPlayerOrGroupName = packed record
TDPMsg_SetPlayerOrGroupName = record
dwType: DWORD; // Message type
dwPlayerType: DWORD; // Is it a player or group
DPID: TDPID; // ID of player or group
dpId: TDPID; // ID of player or group
dpnName: TDPName; // structure with new name info
end;
 
(*
* DPMSG_SETSESSIONDESC
* System message generated when session desc has changed
*)
DPMSG_SETPLAYERORGROUPNAME = TDPMsg_SetPlayerOrGroupName;
LPDPMSG_SETPLAYERORGROUPNAME = PDPMsg_SetPlayerOrGroupName;
 
{ TDPMsg_SetSessionDesc }
 
PDPMsg_SetSessionDesc = ^TDPMsg_SetSessionDesc;
TDPMsg_SetSessionDesc = packed record
TDPMsg_SetSessionDesc = record
dwType: DWORD; // Message type
dpDesc: TDPSessionDesc2; // Session desc
end;
 
(*
* DPMSG_HOST
* System message generated when the host has migrated to this
* DirectPlay object.
*
*)
DPMSG_SETSESSIONDESC = TDPMsg_SetSessionDesc;
LPDPMSG_SETSESSIONDESC = PDPMsg_SetSessionDesc;
 
{ TDPMsg_Host }
 
PDPMsg_Host = ^TDPMsg_Host;
TDPMsg_Host = TDPMsg_Generic;
 
(*
* DPMSG_SESSIONLOST
* System message generated when the connection to the session is lost.
*
*)
DPMSG_HOST = TDPMsg_Host;
LPDPMSG_HOST = PDPMsg_Host;
 
{ TDPMsg_SessionLost }
 
PDPMsg_SessionLost = ^TDPMsg_SessionLost;
TDPMsg_SessionLost = TDPMsg_Generic;
 
(*
* DPMSG_SECUREMESSAGE
* System message generated when a player requests a secure send
*)
DPMSG_SESSIONLOST = TDPMsg_SessionLost;
LPDPMSG_SESSIONLOST = PDPMsg_SessionLost;
 
{ TDPMsg_SecureMessage }
 
PDPMsg_SecureMessage = ^TDPMsg_SecureMessage;
TDPMsg_SecureMessage = packed record
TDPMsg_SecureMessage = record
dwType: DWORD; // Message Type
dwFlags: DWORD; // Signed/Encrypted
dpIdFrom: TDPID; // ID of Sending Player
15829,23 → 10442,24
dwDataSize: DWORD; // Size of player message
end;
 
(*
* DPMSG_STARTSESSION
* System message containing all information required to
* start a new session
*)
DPMSG_SECUREMESSAGE = TDPMsg_SecureMessage;
LPDPMSG_SECUREMESSAGE = PDPMsg_SecureMessage;
 
{ TDPMsg_StartSession }
 
PDPMsg_StartSession = ^TDPMsg_StartSession;
TDPMsg_StartSession = packed record
TDPMsg_StartSession = record
dwType: DWORD; // Message type
lpConn: PDPLConnection; // TDPLConnection structure
end;
 
(*
* DPMSG_CHAT
* System message containing a chat message
*)
DPMSG_STARTSESSION = TDPMsg_StartSession;
LPDPMSG_STARTSESSION = PDPMsg_StartSession;
 
{ TDPMsg_Chat }
 
PDPMsg_Chat = ^TDPMsg_Chat;
TDPMsg_Chat = packed record
TDPMsg_Chat = record
dwType: DWORD; // Message type
dwFlags: DWORD; // Message flags
idFromPlayer: TDPID; // ID of the Sending Player
15854,12 → 10468,13
lpChat: PDPChat; // Pointer to a structure containing the chat message
end;
 
(*
* DPMSG_SETGROUPOWNER
* System message generated when the owner of a group has changed
*)
DPMSG_CHAT = TDPMsg_Chat;
LPDPMSG_CHAT = PDPMsg_Chat;
 
{ TDPMsg_SetGroupOwner }
 
PDPMsg_SetGroupOwner = ^TDPMsg_SetGroupOwner;
TDPMsg_SetGroupOwner = packed record
TDPMsg_SetGroupOwner = record
dwType: DWORD; // Message type
idGroup: TDPID; // ID of the group
idNewOwner: TDPID; // ID of the player that is the new owner
15866,15 → 10481,13
idOldOwner: TDPID; // ID of the player that used to be the owner
end;
 
(*
* DPMSG_SENDCOMPLETE
* System message generated when finished with an Async Send message
*
* NOTE SENDPARMS has an overlay for DPMSG_SENDCOMPLETE, don't
* change this message w/o changing SENDPARMS.
*)
DPMSG_SETGROUPOWNER = TDPMsg_SetGroupOwner;
LPDPMSG_SETGROUPOWNER = PDPMsg_SetGroupOwner;
 
{ TDPMsg_SendComplete }
 
PDPMsg_SendComplete = ^TDPMsg_SendComplete;
TDPMsg_SendComplete = packed record
TDPMsg_SendComplete = record
dwType: DWORD; // Message type
idFrom: TDPID;
idTo: TDPID;
15887,98 → 10500,84
dwSendTime: DWORD;
end;
 
(****************************************************************************
*
* DIRECTPLAY ERRORS
*
* Errors are represented by negative values and cannot be combined.
*
****************************************************************************)
DPMSG_SENDCOMPLETE = TDPMsg_SendComplete;
LPDPMSG_SENDCOMPLETE = PDPMsg_SendComplete;
 
{ DIRECTPLAY ERRORS }
const
MAKE_DPHRESULT = HResult($88770000);
DP_OK = HResult(S_OK);
DPERR_ALREADYINITIALIZED = HResult($88770000 + 5);
DPERR_ACCESSDENIED = HResult($88770000 + 10);
DPERR_ACTIVEPLAYERS = HResult($88770000 + 20);
DPERR_BUFFERTOOSMALL = HResult($88770000 + 30);
DPERR_CANTADDPLAYER = HResult($88770000 + 40);
DPERR_CANTCREATEGROUP = HResult($88770000 + 50);
DPERR_CANTCREATEPLAYER = HResult($88770000 + 60);
DPERR_CANTCREATESESSION = HResult($88770000 + 70);
DPERR_CAPSNOTAVAILABLEYET = HResult($88770000 + 80);
DPERR_EXCEPTION = HResult($88770000 + 90);
DPERR_GENERIC = HResult(E_FAIL);
DPERR_INVALIDFLAGS = HResult($88770000 + 120);
DPERR_INVALIDOBJECT = HResult($88770000 + 130);
DPERR_INVALIDPARAM = HResult(E_INVALIDARG);
DPERR_INVALIDPARAMS = HResult(DPERR_INVALIDPARAM);
DPERR_INVALIDPLAYER = HResult($88770000 + 150);
DPERR_INVALIDGROUP = HResult($88770000 + 155);
DPERR_NOCAPS = HResult($88770000 + 160);
DPERR_NOCONNECTION = HResult($88770000 + 170);
DPERR_NOMEMORY = HResult(E_OUTOFMEMORY);
DPERR_OUTOFMEMORY = HResult(DPERR_NOMEMORY);
DPERR_NOMESSAGES = HResult($88770000 + 190);
DPERR_NONAMESERVERFOUND = HResult($88770000 + 200);
DPERR_NOPLAYERS = HResult($88770000 + 210);
DPERR_NOSESSIONS = HResult($88770000 + 220);
DPERR_PENDING = HResult(E_PENDING);
DPERR_SENDTOOBIG = HResult($88770000 + 230);
DPERR_TIMEOUT = HResult($88770000 + 240);
DPERR_UNAVAILABLE = HResult($88770000 + 250);
DPERR_UNSUPPORTED = HResult(E_NOTIMPL);
DPERR_BUSY = HResult($88770000 + 270);
DPERR_USERCANCEL = HResult($88770000 + 280);
DPERR_NOINTERFACE = HResult(E_NOINTERFACE);
DPERR_CANNOTCREATESERVER = HResult($88770000 + 290);
DPERR_PLAYERLOST = HResult($88770000 + 300);
DPERR_SESSIONLOST = HResult($88770000 + 310);
DPERR_UNINITIALIZED = HResult($88770000 + 320);
DPERR_NONEWPLAYERS = HResult($88770000 + 330);
DPERR_INVALIDPASSWORD = HResult($88770000 + 340);
DPERR_CONNECTING = HResult($88770000 + 350);
DPERR_CONNECTIONLOST = HResult($88770000 + 360);
DPERR_UNKNOWNMESSAGE = HResult($88770000 + 370);
DPERR_CANCELFAILED = HResult($88770000 + 380);
DPERR_INVALIDPRIORITY = HResult($88770000 + 390);
DPERR_NOTHANDLED = HResult($88770000 + 400);
DPERR_CANCELLED = HResult($88770000 + 410);
DPERR_ABORTED = HResult($88770000 + 420);
DPERR_BUFFERTOOLARGE = HResult($88770000 + 1000);
DPERR_CANTCREATEPROCESS = HResult($88770000 + 1010);
DPERR_APPNOTSTARTED = HResult($88770000 + 1020);
DPERR_INVALIDINTERFACE = HResult($88770000 + 1030);
DPERR_NOSERVICEPROVIDER = HResult($88770000 + 1040);
DPERR_UNKNOWNAPPLICATION = HResult($88770000 + 1050);
DPERR_NOTLOBBIED = HResult($88770000 + 1070);
DPERR_SERVICEPROVIDERLOADED = HResult($88770000 + 1080);
DPERR_ALREADYREGISTERED = HResult($88770000 + 1090);
DPERR_NOTREGISTERED = HResult($88770000 + 1100);
 
DP_OK = S_OK;
DPERR_ALREADYINITIALIZED = MAKE_DPHRESULT + 5;
DPERR_ACCESSDENIED = MAKE_DPHRESULT + 10;
DPERR_ACTIVEPLAYERS = MAKE_DPHRESULT + 20;
DPERR_BUFFERTOOSMALL = MAKE_DPHRESULT + 30;
DPERR_CANTADDPLAYER = MAKE_DPHRESULT + 40;
DPERR_CANTCREATEGROUP = MAKE_DPHRESULT + 50;
DPERR_CANTCREATEPLAYER = MAKE_DPHRESULT + 60;
DPERR_CANTCREATESESSION = MAKE_DPHRESULT + 70;
DPERR_CAPSNOTAVAILABLEYET = MAKE_DPHRESULT + 80;
DPERR_EXCEPTION = MAKE_DPHRESULT + 90;
DPERR_GENERIC = E_FAIL;
DPERR_INVALIDFLAGS = MAKE_DPHRESULT + 120;
DPERR_INVALIDOBJECT = MAKE_DPHRESULT + 130;
DPERR_INVALIDPARAM = E_INVALIDARG;
DPERR_INVALIDPARAMS = DPERR_INVALIDPARAM;
DPERR_INVALIDPLAYER = MAKE_DPHRESULT + 150;
DPERR_INVALIDGROUP = MAKE_DPHRESULT + 155;
DPERR_NOCAPS = MAKE_DPHRESULT + 160;
DPERR_NOCONNECTION = MAKE_DPHRESULT + 170;
DPERR_NOMEMORY = E_OUTOFMEMORY;
DPERR_OUTOFMEMORY = DPERR_NOMEMORY;
DPERR_NOMESSAGES = MAKE_DPHRESULT + 190;
DPERR_NONAMESERVERFOUND = MAKE_DPHRESULT + 200;
DPERR_NOPLAYERS = MAKE_DPHRESULT + 210;
DPERR_NOSESSIONS = MAKE_DPHRESULT + 220;
DPERR_PENDING = E_PENDING;
DPERR_SENDTOOBIG = MAKE_DPHRESULT + 230;
DPERR_TIMEOUT = MAKE_DPHRESULT + 240;
DPERR_UNAVAILABLE = MAKE_DPHRESULT + 250;
DPERR_UNSUPPORTED = E_NOTIMPL;
DPERR_BUSY = MAKE_DPHRESULT + 270;
DPERR_USERCANCEL = MAKE_DPHRESULT + 280;
DPERR_NOINTERFACE = E_NOINTERFACE;
DPERR_CANNOTCREATESERVER = MAKE_DPHRESULT + 290;
DPERR_PLAYERLOST = MAKE_DPHRESULT + 300;
DPERR_SESSIONLOST = MAKE_DPHRESULT + 310;
DPERR_UNINITIALIZED = MAKE_DPHRESULT + 320;
DPERR_NONEWPLAYERS = MAKE_DPHRESULT + 330;
DPERR_INVALIDPASSWORD = MAKE_DPHRESULT + 340;
DPERR_CONNECTING = MAKE_DPHRESULT + 350;
DPERR_CONNECTIONLOST = MAKE_DPHRESULT + 360;
DPERR_UNKNOWNMESSAGE = MAKE_DPHRESULT + 370;
DPERR_CANCELFAILED = MAKE_DPHRESULT + 380;
DPERR_INVALIDPRIORITY = MAKE_DPHRESULT + 390;
DPERR_NOTHANDLED = MAKE_DPHRESULT + 400;
DPERR_CANCELLED = MAKE_DPHRESULT + 410;
DPERR_ABORTED = MAKE_DPHRESULT + 420;
{ Security related errors }
 
DPERR_AUTHENTICATIONFAILED = HResult($88770000 + 2000);
DPERR_CANTLOADSSPI = HResult($88770000 + 2010);
DPERR_ENCRYPTIONFAILED = HResult($88770000 + 2020);
DPERR_SIGNFAILED = HResult($88770000 + 2030);
DPERR_CANTLOADSECURITYPACKAGE = HResult($88770000 + 2040);
DPERR_ENCRYPTIONNOTSUPPORTED = HResult($88770000 + 2050);
DPERR_CANTLOADCAPI = HResult($88770000 + 2060);
DPERR_NOTLOGGEDIN = HResult($88770000 + 2070);
DPERR_LOGONDENIED = HResult($88770000 + 2080);
 
DPERR_BUFFERTOOLARGE = MAKE_DPHRESULT + 1000;
DPERR_CANTCREATEPROCESS = MAKE_DPHRESULT + 1010;
DPERR_APPNOTSTARTED = MAKE_DPHRESULT + 1020;
DPERR_INVALIDINTERFACE = MAKE_DPHRESULT + 1030;
DPERR_NOSERVICEPROVIDER = MAKE_DPHRESULT + 1040;
DPERR_UNKNOWNAPPLICATION = MAKE_DPHRESULT + 1050;
DPERR_NOTLOBBIED = MAKE_DPHRESULT + 1070;
DPERR_SERVICEPROVIDERLOADED = MAKE_DPHRESULT + 1080;
DPERR_ALREADYREGISTERED = MAKE_DPHRESULT + 1090;
DPERR_NOTREGISTERED = MAKE_DPHRESULT + 1100;
// define this to ignore obsolete interfaces and constants
 
//
// Security related errors
//
DPERR_AUTHENTICATIONFAILED = MAKE_DPHRESULT + 2000;
DPERR_CANTLOADSSPI = MAKE_DPHRESULT + 2010;
DPERR_ENCRYPTIONFAILED = MAKE_DPHRESULT + 2020;
DPERR_SIGNFAILED = MAKE_DPHRESULT + 2030;
DPERR_CANTLOADSECURITYPACKAGE = MAKE_DPHRESULT + 2040;
DPERR_ENCRYPTIONNOTSUPPORTED = MAKE_DPHRESULT + 2050;
DPERR_CANTLOADCAPI = MAKE_DPHRESULT + 2060;
DPERR_NOTLOGGEDIN = MAKE_DPHRESULT + 2070;
DPERR_LOGONDENIED = MAKE_DPHRESULT + 2080;
 
(****************************************************************************
*
* dplay 1.0 obsolete structures + interfaces
* Included for compatibility only. New apps should
* use IDirectPlay2
*
****************************************************************************)
 
DPOPEN_OPENSESSION = DPOPEN_JOIN;
DPOPEN_CREATESESSION = DPOPEN_CREATE;
 
16006,41 → 10605,71
DPSYS_DELETEPLAYERFROMGRP = $0021;
DPSYS_CONNECT = $484b;
 
{ TDPMsg_AddPlayer }
 
type
PDPMsg_AddPlayer = ^TDPMsg_AddPlayer;
TDPMsg_AddPlayer = packed record
TDPMsg_AddPlayer = record
dwType: DWORD;
dwPlayerType: DWORD;
DPID: TDPID;
dpId: TDPID;
szLongName: array[0..DPLONGNAMELEN-1] of Char;
szShortName: array[0..DPSHORTNAMELEN-1] of Char;
dwCurrentPlayers: DWORD;
end;
 
DPMSG_ADDPLAYER = TDPMsg_AddPlayer;
LPDPMSG_ADDPLAYER = PDPMsg_AddPlayer;
 
{ TDPMsg_AddGroup }
 
PDPMsg_AddGroup = ^TDPMsg_AddGroup;
TDPMsg_AddGroup = TDPMsg_AddPlayer;
 
DPMSG_ADDGROUP = TDPMsg_AddGroup;
LPDPMSG_ADDGROUP = PDPMsg_AddGroup;
 
{ TDPMsg_GroupAdd }
 
PDPMsg_GroupAdd = ^TDPMsg_GroupAdd;
TDPMsg_GroupAdd = packed record
TDPMsg_GroupAdd = record
dwType: DWORD;
dpIdGroup: TDPID;
dpIdPlayer: TDPID;
end;
 
DPMSG_GROUPADD = TDPMsg_GroupAdd;
LPDPMSG_GROUPADD = PDPMsg_GroupAdd;
 
{ TDPMsg_GroupDelete }
 
PDPMsg_GroupDelete = ^TDPMsg_GroupDelete;
TDPMsg_GroupDelete = TDPMsg_GroupAdd;
 
DPMSG_GROUPDELETE = TDPMsg_GroupDelete;
LPDPMSG_GROUPDELETE = PDPMsg_GroupDelete;
 
{ TDPMsg_DeletePlayer }
 
PDPMsg_DeletePlayer = ^TDPMsg_DeletePlayer;
TDPMsg_DeletePlayer = packed record
TDPMsg_DeletePlayer = record
dwType: DWORD;
DPID: TDPID;
dpId: TDPID;
end;
 
TDPEnumPlayersCallback = function(dpId: TDPID; lpFriendlyName: PChar;
lpFormalName: PChar; dwFlags: DWORD; lpContext: Pointer) : BOOL; stdcall;
DPMSG_DELETEPLAYER = TDPMsg_DeletePlayer;
LPDPMSG_DELETEPLAYER = PDPMsg_DeletePlayer;
 
{ TDPEnumPlayersCallback }
 
TDPEnumPlayersCallback = function(dpId: TDPID; lpFriendlyName: LPSTR;
lpFormalName: LPSTR; dwFlags: DWORD; lpContext: Pointer): BOOL; stdcall;
LPDPENUMPLAYERSCALLBACK = TDPEnumPlayersCallback;
 
{ TDPSessionDesc }
 
PDPSessionDesc = ^TDPSessionDesc;
TDPSessionDesc = packed record
TDPSessionDesc = record
dwSize: DWORD;
guidSession: TGUID;
dwSession: DWORD;
16047,10 → 10676,10
dwMaxPlayers: DWORD;
dwCurrentPlayers: DWORD;
dwFlags: DWORD;
szSessionName: Array [0..DPSESSIONNAMELEN-1] of char;
szUserField: Array [0..DPUSERRESERVED-1] of char;
szSessionName: array[0..DPSESSIONNAMELEN-1] of char;
szUserField: array[0..DPUSERRESERVED-1] of char;
dwReserved1: DWORD;
szPassword: Array [0..DPPASSWORDLEN-1] of char;
szPassword: array[0..DPPASSWORDLEN-1] of char;
dwReserved2: DWORD;
dwUser1: DWORD;
dwUser2: DWORD;
16058,68 → 10687,57
dwUser4: DWORD;
end;
 
TDPEnumSessionsCallback = function(const lpDPSessionDesc: TDPSessionDesc;
DPSESSIONDESC = TDPSessionDesc;
LPDPSESSIONDESC = PDPSessionDesc;
 
{ TDPEnumSessionsCallback }
 
TDPEnumSessionsCallback = function(var lpDPSessionDesc: TDPSessionDesc;
lpContext: Pointer; var lpdwTimeOut: DWORD; dwFlags: DWORD) : BOOL; stdcall;
LPDPENUMSESSIONSCALLBACK = TDPEnumSessionsCallback;
 
type
IDirectPlay = interface (IUnknown)
['{5454e9a0-db65-11ce-921c-00aa006c4972}']
(*** IDirectPlay methods ***)
// IDirectPlay methods
function AddPlayerToGroup(pidGroup: TDPID; pidPlayer: TDPID) : HResult; stdcall;
function Close: HResult; stdcall;
function CreatePlayer(out lppidID: TDPID; lpPlayerFriendlyName: PChar;
lpPlayerFormalName: PChar; lpEvent: PHandle) : HResult; stdcall;
function CreateGroup(out lppidID: TDPID; lpGroupFriendlyName: PChar;
lpGroupFormalName: PChar) : HResult; stdcall;
function CreatePlayer(var lppidID: TDPID; lpPlayerFriendlyName: LPSTR;
lpPlayerFormalName: LPSTR; lpEvent: PHandle): HResult; stdcall;
function CreateGroup(var lppidID: TDPID; lpGroupFriendlyName: LPSTR;
lpGroupFormalName: LPSTR): HResult; stdcall;
function DeletePlayerFromGroup(pidGroup: TDPID; pidPlayer: TDPID) : HResult; stdcall;
function DestroyPlayer(pidID: TDPID) : HResult; stdcall;
function DestroyGroup(pidID: TDPID) : HResult; stdcall;
function EnableNewPlayers(bEnable: BOOL) : HResult; stdcall;
function EnumGroupPlayers(pidGroupPID: TDPID; lpEnumPlayersCallback:
TDPEnumPlayersCallback; lpContext: Pointer; dwFlags: DWORD) : HResult; stdcall;
LPDPENUMPLAYERSCALLBACK; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
function EnumGroups(dwSessionID: DWORD; lpEnumPlayersCallback:
TDPEnumPlayersCallback; lpContext: Pointer; dwFlags: DWORD) : HResult; stdcall;
LPDPENUMPLAYERSCALLBACK; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
function EnumPlayers(dwSessionId: DWORD; lpEnumPlayersCallback:
TDPEnumPlayersCallback; lpContext: Pointer; dwFlags: DWORD) : HResult; stdcall;
function EnumSessions(var lpSDesc: TDPSessionDesc; dwTimeout: DWORD;
lpEnumSessionsCallback: TDPEnumSessionsCallback; lpContext: Pointer;
LPDPENUMPLAYERSCALLBACK; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
function EnumSessions(const lpSDesc: TDPSessionDesc; dwTimeout: DWORD;
lpEnumSessionsCallback: TDPEnumPlayersCallback; lpContext: Pointer;
dwFlags: DWORD) : HResult; stdcall;
function GetCaps(var lpDPCaps: TDPCaps) : HResult; stdcall;
function GetCaps(const lpDPCaps: TDPCaps): HResult; stdcall;
function GetMessageCount(pidID: TDPID; var lpdwCount: DWORD) : HResult; stdcall;
function GetPlayerCaps(pidID: TDPID; var lpDPPlayerCaps: TDPCaps) : HResult; stdcall;
function GetPlayerName(pidID: TDPID; lpPlayerFriendlyName: PChar;
var lpdwFriendlyNameLength: DWORD; lpPlayerFormalName: PChar;
function GetPlayerCaps(pidID: TDPID; const lpDPPlayerCaps: TDPCaps): HResult; stdcall;
function GetPlayerName(pidID: TDPID; lpPlayerFriendlyName: LPSTR;
var lpdwFriendlyNameLength: DWORD; lpPlayerFormalName: LPSTR;
var lpdwFormalNameLength: DWORD) : HResult; stdcall;
function Initialize(const lpGUID: TGUID) : HResult; stdcall;
function Open(var lpSDesc: TDPSessionDesc) : HResult; stdcall;
function Open(const lpSDesc: TDPSessionDesc): HResult; stdcall;
function Receive(var lppidFrom, lppidTo: TDPID; dwFlags: DWORD;
var lpvBuffer; var lpdwSize: DWORD) : HResult; stdcall;
function SaveSession(lpSessionName: PChar) : HResult; stdcall;
function SaveSession(lpSessionName: LPSTR): HResult; stdcall;
function Send(pidFrom: TDPID; pidTo: TDPID; dwFlags: DWORD;
var lpvBuffer; dwBuffSize: DWORD) : HResult; stdcall;
function SetPlayerName(pidID: TDPID; lpPlayerFriendlyName: PChar;
lpPlayerFormalName: PChar) : HResult; stdcall;
const lpvBuffer; dwBuffSize: DWORD): HResult; stdcall;
function SetPlayerName(pidID: TDPID; lpPlayerFriendlyName: LPSTR;
lpPlayerFormalName: LPSTR): HResult; stdcall;
end;
 
(*
* GUIDS used by DirectPlay objects
*)
IID_IDirectPlay2W = IDirectPlay2W;
IID_IDirectPlay2A = IDirectPlay2A;
IID_IDirectPlay2 = IDirectPlay2;
{ API's (cont.) }
 
IID_IDirectPlay3W = IDirectPlay3W;
IID_IDirectPlay3A = IDirectPlay3A;
IID_IDirectPlay3 = IDirectPlay3;
 
IID_IDirectPlay4W = IDirectPlay4W;
IID_IDirectPlay4A = IDirectPlay4A;
IID_IDirectPlay4 = IDirectPlay4;
 
IID_IDirectPlay = IDirectPlay;
 
var
DirectPlayCreate : function (lpGUID: PGUID; out lplpDP: IDirectPlay;
function DirectPlayCreate(const lpGUID: TGUID; out lplpDP: IDirectPlay;
pUnk: IUnknown) : HResult; stdcall;
 
(*==========================================================================;
16128,345 → 10746,238
*
* File: dplobby.h
* Content: DirectPlayLobby include file
*
***************************************************************************)
 
(*
* GUIDS used by DirectPlay objects
*)
{ GUIDS used by DirectPlay objects }
 
const
(* {2FE8F810-B2A5-11d0-A787-0000F803ABFC} *)
CLSID_DirectPlayLobby: TGUID =
(D1:$2fe8f810;D2:$b2a5;D3:$11d0;D4:($a7,$87,$00,$00,$f8,$3,$ab,$fc));
CLSID_DirectPlayLobby: TGUID = '{2FE8F810-B2A5-11D0-A787-0000F803ABFC}';
 
(****************************************************************************
*
* IDirectPlayLobby Structures
*
* Various structures used to invoke DirectPlayLobby.
*
****************************************************************************)
IID_IDirectPlayLobby: TGUID = '{AF465C71-9588-11cf-A020-00AA006157AC}';
IID_IDirectPlayLobbyA: TGUID = '{26C66A70-B367-11cf-A024-00AA006157AC}';
IID_IDirectPlayLobby2: TGUID = '{0194C220-A303-11d0-9C4F-00A0C905425E}';
IID_IDirectPlayLobby2A: TGUID = '{1BB4AF80-A303-11d0-9C4F-00A0C905425E}';
IID_IDirectPlayLobby3: TGUID = '{2DB72490-652C-11d1-A7A8-0000F803ABFC}';
IID_IDirectPlayLobby3A: TGUID = '{2DB72491-652C-11d1-A7A8-0000F803ABFC}';
 
{ IDirectPlayLobby Structures }
 
{ TDPLAppInfo }
 
type
(*
* TDPLAppInfo
* Used to hold information about a registered DirectPlay
* application
*)
PDPLAppInfo = ^TDPLAppInfo;
TDPLAppInfo = packed record
TDPLAppInfo = record
dwSize: DWORD; // Size of this structure
guidApplication: TGUID; // GUID of the Application
case Integer of // Pointer to the Application Name
0: (lpszAppName: PCharAW);
1: (lpszAppNameW: PWideChar);
3: (lpszAppNameA: PChar);
0: (lpszAppNameA: LPSTR);
1: (lpszAppName: LPWSTR);
end;
 
(*
* TDPCompoundAddressElement
*
* An array of these is passed to CreateCompoundAddresses()
*)
DPLAPPINFO = TDPLAppInfo;
LPDPLAPPINFO = PDPLAppInfo;
 
{ TDPCompoundAddressElement }
 
PDPCompoundAddressElement = ^TDPCompoundAddressElement;
TDPCompoundAddressElement = packed record
TDPCompoundAddressElement = record
guidDataType: TGUID;
dwDataSize: DWORD;
lpData: Pointer;
end;
 
(*
* TDPApplicationDesc
* Used to register a DirectPlay application
*)
DPCOMPOUNDADDRESSELEMENT = TDPCompoundAddressElement;
LPDPCOMPOUNDADDRESSELEMENT = PDPCompoundAddressElement;
 
{ TDPApplicationDesc }
 
PDPApplicationDesc = ^TDPApplicationDesc;
TDPApplicationDesc = packed record
TDPApplicationDesc = record
dwSize: DWORD;
dwFlags: DWORD;
case integer of
0 : (lpszApplicationName: PCharAW;
case Integer of
0: (
lpszApplicationNameA: LPSTR; // ANSI
guidApplication: TGUID;
lpszFilename: PCharAW;
lpszCommandLine: PCharAW;
lpszPath: PCharAW;
lpszCurrentDirectory: PCharAW;
lpszDescriptionA: PAnsiChar;
lpszDescriptionW: PWideChar);
1 : (lpszApplicationNameA: PAnsiChar;
filler1: TGUID;
lpszFilenameA: PAnsiChar;
lpszCommandLineA: PAnsiChar;
lpszPathA: PAnsiChar;
lpszCurrentDirectoryA: PAnsiChar);
2 : (lpszApplicationNameW: PWideChar;
filler2: TGUID;
lpszFilenameW: PWideChar;
lpszCommandLineW: PWideChar;
lpszPathW: PWideChar;
lpszCurrentDirectoryW: PWideChar);
lpszFilenameA: LPSTR;
lpszCommandLineA: LPSTR;
lpszPathA: LPSTR;
lpszCurrentDirectoryA: LPSTR;
lpszDescriptionA: LPSTR;
lpszDescriptionW: LPWSTR;
);
1: (
lpszApplicationName: LPWSTR; // Unicode
_union1b: TGUID;
lpszFilename: LPWSTR;
lpszCommandLine: LPWSTR;
lpszPath: LPWSTR;
lpszCurrentDirectory: LPWSTR;
_union1g: LPWSTR;
);
end;
 
(*
* TDPApplicationDesc2
* Used to register a DirectPlay application
*)
DPAPPLICATIONDESC = TDPApplicationDesc;
LPDPAPPLICATIONDESC = PDPApplicationDesc;
 
{ TDPApplicationDesc2 }
 
PDPApplicationDesc2 = ^TDPApplicationDesc2;
TDPApplicationDesc2 = packed record
TDPApplicationDesc2 = record
dwSize: DWORD;
dwFlags: DWORD;
case integer of
0 : (lpszApplicationName: PCharAW;
case Integer of
0: (
lpszApplicationNameA: LPSTR; // ANSI
guidApplication: TGUID;
lpszFilename: PCharAW;
lpszCommandLine: PCharAW;
lpszPath: PCharAW;
lpszCurrentDirectory: PCharAW;
lpszDescriptionA: PAnsiChar;
lpszDescriptionW: PWideChar;
lpszAppLauncherName: PCharAW);
1 : (lpszApplicationNameA: PAnsiChar;
filler1: TGUID;
lpszFilenameA: PAnsiChar;
lpszCommandLineA: PAnsiChar;
lpszPathA: PAnsiChar;
lpszCurrentDirectoryA: PAnsiChar;
filler3: PChar;
filler4: PChar;
lpszAppLauncherNameA: PAnsiChar);
2 : (lpszApplicationNameW: PWideChar;
filler2: TGUID;
lpszFilenameW: PWideChar;
lpszCommandLineW: PWideChar;
lpszPathW: PWideChar;
lpszCurrentDirectoryW: PWideChar;
filler5: PChar;
filler6: PChar;
lpszAppLauncherNameW: PWideChar);
lpszFilenameA: LPSTR;
lpszCommandLineA: LPSTR;
lpszPathA: LPSTR;
lpszCurrentDirectoryA: LPSTR;
lpszDescriptionA: LPSTR;
lpszDescriptionW: LPWSTR;
lpszAppLauncherNameA: LPSTR;
);
1: (
lpszApplicationName: LPWSTR; // Unicode
_union1b: TGUID;
lpszFilename: LPWSTR;
lpszCommandLine: LPWSTR;
lpszPath: LPWSTR;
lpszCurrentDirectory: LPWSTR;
_union1g: LPWSTR;
lpszAppLauncherName: LPWSTR;
);
end;
 
DPAPPLICATIONDESC2 = TDPApplicationDesc2;
LPDPAPPLICATIONDESC2 = PDPApplicationDesc2;
 
(****************************************************************************
*
* Enumeration Method Callback Prototypes
*
****************************************************************************)
{ Enumeration Method Callback Prototypes }
 
(*
* Callback for EnumAddress()
*)
TDPEnumAdressCallback = function(const guidDataType: TGUID;
TDPEnumAddressCallback = function(const guidDataType: TGUID;
dwDataSize: DWORD; lpData: Pointer; lpContext: Pointer) : BOOL; stdcall;
LPDPENUMADDRESSCALLBACK = TDPEnumAddressCallback;
 
(*
* Callback for EnumAddressTypes()
*)
TDPLEnumAddressTypesCallback = function(const guidDataType: TGUID;
lpContext: Pointer; dwFlags: DWORD) : BOOL; stdcall;
LPDPLENUMADDRESSTYPESCALLBACK = TDPLEnumAddressTypesCallback;
 
(*
* Callback for EnumLocalApplications()
*)
TDPLEnumLocalApplicationsCallback = function(const lpAppInfo: TDPLAppInfo;
lpContext: Pointer; dwFlags: DWORD) : BOOL; stdcall;
LPDPLENUMLOCALAPPLICATIONSCALLBACK = TDPLEnumLocalApplicationsCallback;
 
(****************************************************************************
*
* IDirectPlayLobby (and IDirectPlayLobbyA) Interface
*
****************************************************************************)
{ IDirectPlayLobby (and IDirectPlayLobbyA) Interface }
 
type
IDirectPlayLobbyAW = interface (IUnknown)
(*** IDirectPlayLobby methods ***)
IDirectPlayLobby = interface(IUnknown)
['{AF465C71-9588-11CF-A020-00AA006157AC}']
// IDirectPlayLobby methods
function Connect(dwFlags: DWORD; out lplpDP: IDirectPlay2;
pUnk: IUnknown) : HResult; stdcall;
function CreateAddress(const guidSP, guidDataType: TGUID; var lpData;
function CreateAddress(const guidSP, guidDataType: TGUID; const lpData;
dwDataSize: DWORD; var lpAddress; var lpdwAddressSize: DWORD) : HResult; stdcall;
function EnumAddress(lpEnumAddressCallback: TDPEnumAdressCallback;
var lpAddress; dwAddressSize: DWORD; lpContext : Pointer) : HResult; stdcall;
function EnumAddress(lpEnumAddressCallback: TDPEnumAddressCallback;
const lpAddress; dwAddressSize: DWORD; lpContext : Pointer): HResult; stdcall;
function EnumAddressTypes(lpEnumAddressTypeCallback:
TDPLEnumAddressTypesCallback; const guidSP: TGUID; lpContext: Pointer;
dwFlags: DWORD) : HResult; stdcall;
function EnumLocalApplications(lpEnumLocalAppCallback: TDPLEnumLocalApplicationsCallback;
lpContext: Pointer; dwFlags: DWORD) : HResult; stdcall;
function GetConnectionSettings(dwAppID: DWORD; lpData: PDPLConnection;
function EnumLocalApplications(lpEnumLocalAppCallback:
TDPLEnumLocalApplicationsCallback; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
function GetConnectionSettings(dwAppID: DWORD; var lpData: TDPLConnection;
var lpdwDataSize: DWORD) : HResult; stdcall;
function ReceiveLobbyMessage(dwFlags: DWORD; dwAppID: DWORD;
var lpdwMessageFlags: DWORD; lpData: Pointer; var lpdwDataSize: DWORD) : HResult; stdcall;
var lpdwMessageFlags: DWORD; var lpData; var lpdwDataSize: DWORD): HResult; stdcall;
function RunApplication(dwFlags: DWORD; var lpdwAppId: DWORD;
const lpConn: TDPLConnection; hReceiveEvent: THandle) : HResult; stdcall;
function SendLobbyMessage(dwFlags: DWORD; dwAppID: DWORD; const lpData;
dwDataSize: DWORD) : HResult; stdcall;
function SetConnectionSettings(dwFlags: DWORD; dwAppID: DWORD;
var lpConn: TDPLConnection) : HResult; stdcall;
const lpConn: TDPLConnection): HResult; stdcall;
function SetLobbyMessageEvent(dwFlags: DWORD; dwAppID: DWORD;
hReceiveEvent: THandle) : HResult; stdcall;
end;
 
IDirectPlayLobbyW = interface (IDirectPlayLobbyAW)
['{AF465C71-9588-11CF-A020-00AA006157AC}']
IDirectPlayLobbyA = interface(IDirectPlayLobby)
['{26C66A70-B367-11CF-A024-00AA006157AC}']
end;
IDirectPlayLobbyA = interface (IDirectPlayLobbyAW)
['{26C66A70-B367-11cf-A024-00AA006157AC}']
end;
 
{$IFDEF UNICODE}
IDirectPlayLobby = IDirectPlayLobbyW;
{$ELSE}
IDirectPlayLobby = IDirectPlayLobbyA;
{$ENDIF}
{ IDirectPlayLobby2 (and IDirectPlayLobby2A) Interface }
 
 
(****************************************************************************
*
* IDirectPlayLobby2 (and IDirectPlayLobby2A) Interface
*
****************************************************************************)
 
IDirectPlayLobby2AW = interface(IDirectPlayLobbyAW)
(*** IDirectPlayLobby2 methods ***)
IDirectPlayLobby2 = interface(IDirectPlayLobby)
['{0194C220-A303-11D0-9C4F-00A0C905425E}']
// IDirectPlayLobby2 methods
function CreateCompoundAddress(const lpElements: TDPCompoundAddressElement;
dwElementCount: DWORD; lpAddress: Pointer; var lpdwAddressSize: DWORD) : HResult; stdcall;
dwElementCount: DWORD; var lpAddress; var lpdwAddressSize: DWORD): HResult; stdcall;
end;
 
IDirectPlayLobby2W = interface (IDirectPlayLobby2AW)
['{0194C220-A303-11D0-9C4F-00A0C905425E}']
IDirectPlayLobby2A = interface(IDirectPlayLobby2)
['{1BB4AF80-A303-11D0-9C4F-00A0C905425E}']
end;
IDirectPlayLobby2A = interface (IDirectPlayLobby2AW)
['{1BB4AF80-A303-11d0-9C4F-00A0C905425E}']
end;
 
{$IFDEF UNICODE}
IDirectPlayLobby2 = IDirectPlayLobby2W;
{$ELSE}
IDirectPlayLobby2 = IDirectPlayLobby2A;
{$ENDIF}
{ IDirectPlayLobby3 (and IDirectPlayLobby3A) Interface }
 
(****************************************************************************
*
* IDirectPlayLobby3 (and IDirectPlayLobby3A) Interface
*
****************************************************************************)
 
IDirectPlayLobby3AW = interface(IDirectPlayLobby2AW)
(*** IDirectPlayLobby3 methods ***)
function ConnectEx(dwFlags: DWORD; const riid: TGUID;
out lplpDP; pUnk: IUnknown) : HResult; stdcall;
function RegisterApplication(dwFlags: DWORD;
var lpAppDesc: TDPApplicationDesc) : HResult; stdcall;
function UnregisterApplication(dwFlags: DWORD;
const guidApplication: TGUID) : HResult; stdcall;
IDirectPlayLobby3 = interface(IDirectPlayLobby2)
['{2DB72490-652C-11d1-A7A8-0000F803ABFC}']
// IDirectPlayLobby3 Methods
function ConnectEx(dwFlags: DWORD; const riid: TGUID; var lplpDP: Pointer;
pUnk: IUnknown): HResult; stdcall;
function RegisterApplication(dwFlags: DWORD; const lpAppDesc: TDPApplicationDesc): HResult; stdcall;
function UnRegisterApplication(dwFlags: DWORD; const guidApplication: TGUID): HResult; stdcall;
function WaitForConnectionSettings(dwFlags: DWORD) : HResult; stdcall;
end;
 
IDirectPlayLobby3W = interface (IDirectPlayLobby3AW)
['{2DB72490-652C-11d1-A7A8-0000F803ABFC}']
end;
IDirectPlayLobby3A = interface (IDirectPlayLobby3AW)
IDirectPlayLobby3A = interface(IDirectPlayLobby3)
['{2DB72491-652C-11d1-A7A8-0000F803ABFC}']
end;
 
{$IFDEF UNICODE}
IDirectPlayLobby3 = IDirectPlayLobby3W;
{$ELSE}
IDirectPlayLobby3 = IDirectPlayLobby3A;
{$ENDIF}
{ DirectPlayLobby API Prototypes }
 
IID_IDirectPlayLobbyW = IDirectPlayLobbyW;
IID_IDirectPlayLobbyA = IDirectPlayLobbyA;
IID_IDirectPlayLobby = IDirectPlayLobby;
function DirectPlayLobbyCreateW(const lpguidSP: TGUID; out lplpDPL: IDirectPlayLobby;
lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD): HResult; stdcall;
function DirectPlayLobbyCreateA(const lpguidSP: TGUID; out lplpDPL: IDirectPlayLobbyA;
lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD): HResult; stdcall;
function DirectPlayLobbyCreate(const lpguidSP: TGUID; out lplpDPL: IDirectPlayLobbyA;
lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD): HResult; stdcall;
 
IID_IDirectPlayLobby2W = IDirectPlayLobby2W;
IID_IDirectPlayLobby2A = IDirectPlayLobby2A;
IID_IDirectPlayLobby2 = IDirectPlayLobby2;
{ DirectPlayLobby Flags }
 
IID_IDirectPlayLobby3W = IDirectPlayLobby3W;
IID_IDirectPlayLobby3A = IDirectPlayLobby3A;
IID_IDirectPlayLobby3 = IDirectPlayLobby3;
 
(****************************************************************************
*
* DirectPlayLobby API Prototypes
*
****************************************************************************)
 
var
DirectPlayLobbyCreateW : function (lpguidSP: PGUID; out lplpDPL:
IDirectPlayLobbyW; lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD) : HResult; stdcall;
DirectPlayLobbyCreateA : function (lpguidSP: PGUID; out lplpDPL:
IDirectPlayLobbyA; lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD) : HResult; stdcall;
DirectPlayLobbyCreate : function (lpguidSP: PGUID; out lplpDPL:
IDirectPlayLobby; lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD) : HResult; stdcall;
 
const
(****************************************************************************
*
* DirectPlayLobby Flags
*
****************************************************************************)
 
(*
* This flag is used by IDirectPlayLobby.WaitForConnectionSettings to
* cancel a current wait that is in progress.
*)
DPLWAIT_CANCEL = $00000001;
 
(*
* This is a message flag used by ReceiveLobbyMessage. It can be
* returned in the dwMessageFlags parameter to indicate a message from
* the system.
*)
DPLMSG_SYSTEM = $00000001;
 
(*
* This is a message flag used by ReceiveLobbyMessage and SendLobbyMessage.
* It is used to indicate that the message is a standard lobby message.
* TDPLMsg_SetProperty, TDPLMsg_SetPropertyResponse, TDPLMsg_GetProperty,
* TDPLMsg_GetPropertyResponse
*)
DPLMSG_STANDARD = $00000002;
 
 
{ DirectPlayLobby messages and message data structures }
 
{ TDPLMsg_Generic }
 
type
(****************************************************************************
*
* DirectPlayLobby messages and message data structures
*
* All system messages have a dwMessageFlags value of DPLMSG_SYSTEM returned
* from a call to ReceiveLobbyMessage.
*
* All standard messages have a dwMessageFlags value of DPLMSG_STANDARD returned
* from a call to ReceiveLobbyMessage.
*
****************************************************************************)
 
(*
* TDPLMsg_Generic
* Generic message structure used to identify the message type.
*)
PDPLMsg_Generic = ^TDPLMsg_Generic;
TDPLMsg_Generic = packed record
TDPLMsg_Generic = record
dwType: DWORD; // Message type
end;
 
(*
* TDPLMsg_SystemMessage
* Generic message format for all system messages --
* DPLSYS_CONNECTIONSETTINGSREAD, DPLSYS_DPLYCONNECTSUCCEEDED,
* DPLSYS_DPLAYCONNECTFAILED, DPLSYS_APPTERMINATED, DPLSYS_NEWCONNECTIONSETTINGS
*)
DPLMSG_GENERIC = TDPLMsg_Generic;
LPDPLMSG_GENERIC = PDPLMsg_Generic;
 
{ TDPLMsg_SystemMessage }
 
PDPLMsg_SystemMessage = ^TDPLMsg_SystemMessage;
TDPLMsg_SystemMessage = packed record
TDPLMsg_SystemMessage = record
dwType: DWORD; // Message type
guidInstance: TGUID; // Instance GUID of the dplay session the message corresponds to
end;
 
(*
* TDPLMsg_SetProperty
* Standard message sent by an application to a lobby to set a
* property
*)
DPLMSG_SYSTEMMESSAGE = TDPLMsg_SystemMessage;
LPDPLMSG_SYSTEMMESSAGE = PDPLMsg_SystemMessage;
 
{ TDPLMsg_SetProperty }
 
PDPLMsg_SetProperty = ^TDPLMsg_SetProperty;
TDPLMsg_SetProperty = packed record
TDPLMsg_SetProperty = record
dwType: DWORD; // Message type
dwRequestID: DWORD; // Request ID (DPL_NOCONFIRMATION if no confirmation desired)
guidPlayer: TGUID; // Player GUID
16475,17 → 10986,17
dwPropertyData: array[0..0] of DWORD; // Buffer containing data
end;
 
DPLMSG_SETPROPERTY = TDPLMsg_SetProperty;
LPDPLMSG_SETPROPERTY = PDPLMsg_SetProperty;
 
const
DPL_NOCONFIRMATION = 0;
 
{ TDPLMsg_SetPropertyResponse }
 
type
(*
* TDPLMsg_SetPropertyResponse
* Standard message returned by a lobby to confirm a
* TDPLMsg_SetProperty message.
*)
PDPLMsg_SetPropertyResponse = ^TDPLMsg_SetPropertyResponse;
TDPLMsg_SetPropertyResponse = packed record
TDPLMsg_SetPropertyResponse = record
dwType: DWORD; // Message type
dwRequestID: DWORD; // Request ID
guidPlayer: TGUID; // Player GUID
16493,27 → 11004,26
hr: HResult; // Return Code
end;
 
(*
* TDPLMsg_GetProperty
* Standard message sent by an application to a lobby to request
* the current value of a property
*)
DPLMSG_SETPROPERTYRESPONSE = TDPLMsg_SetPropertyResponse;
LPDPLMSG_SETPROPERTYRESPONSE = PDPLMsg_SetPropertyResponse;
 
{ TDPLMsg_GetProperty }
 
PDPLMsg_GetProperty = ^TDPLMsg_GetProperty;
TDPLMsg_GetProperty = packed record
TDPLMsg_GetProperty = record
dwType: DWORD; // Message type
dwRequestID: DWORD; // Request ID
guidPlayer: TGUID; // Player GUID
guidPropertyTag: TGUID; // Property GUID
end;
LPDPLMSG_GETPROPERTY = ^TDPLMsg_GetProperty;
 
(*
* TDPLMsg_GetPropertyResponse
* Standard message returned by a lobby in response to a
* TDPLMsg_GetProperty message.
*)
DPLMSG_GETPROPERTY = TDPLMsg_GetProperty;
LPDPLMSG_GETPROPERTY = PDPLMsg_GetProperty;
 
{ TDPLMsg_GetPropertyResponse }
 
PDPLMsg_GetPropertyResponse = ^TDPLMsg_GetPropertyResponse;
TDPLMsg_GetPropertyResponse = packed record
TDPLMsg_GetPropertyResponse = record
dwType: DWORD; // Message type
dwRequestID: DWORD; // Request ID
guidPlayer: TGUID; // Player GUID
16523,297 → 11033,97
dwPropertyData: array[0..0] of DWORD; // Buffer containing data
end;
 
(*
* TDPLMsg_NewSessionHost
* Standard message returned by a lobby in response to a
* the session host migrating to a new client
*)
DPLMSG_GETPROPERTYRESPONSE = TDPLMsg_GetPropertyResponse;
LPDPLMSG_GETPROPERTYRESPONSE = PDPLMsg_GetPropertyResponse;
 
{ TDPLMsg_NewSessionHost }
 
PDPLMsg_NewSessionHost = ^TDPLMsg_NewSessionHost;
TDPLMsg_NewSessionHost = packed record
TDPLMsg_NewSessionHost = record
dwType: DWORD; // Message type
guidInstance: TGUID; // Property GUID
guidInstance: TGUID; // GUID Instance of the session
end;
 
DPLMSG_NEWSESSIONHOST = TDPLMsg_NewSessionHost;
LPDPLMSG_NEWSESSIONHOST = PDPLMsg_NewSessionHost;
 
{ DirectPlay Lobby message dwType values }
 
const
(******************************************
*
* DirectPlay Lobby message dwType values
*
*****************************************)
 
(*
* The application has read the connection settings.
* It is now O.K. for the lobby client to release
* its IDirectPlayLobby interface.
*)
DPLSYS_CONNECTIONSETTINGSREAD = $00000001;
 
(*
* The application's call to DirectPlayConnect failed
*)
DPLSYS_DPLAYCONNECTFAILED = $00000002;
 
(*
* The application has created a DirectPlay session.
*)
DPLSYS_DPLAYCONNECTSUCCEEDED = $00000003;
 
(*
* The application has terminated.
*)
DPLSYS_APPTERMINATED = $00000004;
 
(*
* The message is a TDPLMsg_SetProperty message.
*)
DPLSYS_SETPROPERTY = $00000005;
 
(*
* The message is a TDPLMsg_SetPropertyResponse message.
*)
DPLSYS_SETPROPERTYRESPONSE = $00000006;
 
(*
* The message is a TDPLMsg_GetProperty message.
*)
DPLSYS_GETPROPERTY = $00000007;
 
(*
* The message is a TDPLMsg_GetPropertyResponse message.
*)
DPLSYS_GETPROPERTYRESPONSE = $00000008;
 
(*
* The message is a TDPLMsg_NewSessionHost message.
*)
DPLSYS_NEWSESSIONHOST = $00000009;
 
(*
* New connection settings are available.
*)
DPLSYS_NEWCONNECTIONSETTINGS = $0000000A;
 
(****************************************************************************
*
* DirectPlay defined property GUIDs and associated data structures
*
****************************************************************************)
{ DirectPlay defined property GUIDs and associated data structures }
 
(*
* DPLPROPERTY_MessagesSupported
*
* Request whether the lobby supports standard. Lobby with respond with either
* TRUE or FALSE or may not respond at all.
*
* Property data is a single BOOL with TRUE or FALSE
*)
// {762CCDA1-D916-11d0-BA39-00C04FD7ED67}
DPLPROPERTY_MessagesSupported: TGUID =
(D1:$762ccda1;D2:$d916;D3:$11d0;D4:($ba,$39,$00,$c0,$4f,$d7,$ed,$67));
DPLPROPERTY_MessagesSupported: TGUID = '{762CCDA1-D916-11d0-BA39-00C04FD7ED67}';
DPLPROPERTY_LobbyGuid: TGUID = '{F56920A0-D218-11d0-BA39-00C04FD7ED67}';
DPLPROPERTY_PlayerGuid: TGUID = '{B4319322-D20D-11d0-BA39-00C04FD7ED67}';
 
(*
* DPLPROPERTY_LobbyGuid
*
* Request the GUID that identifies the lobby software that the application
* is communicating with.
*
* Property data is a single GUID.
*)
// {F56920A0-D218-11d0-BA39-00C04FD7ED67}
DPLPROPERTY_LobbyGuid: TGUID =
(D1:$F56920A0;D2:$D218;D3:$11d0;D4:($ba,$39,$00,$c0,$4f,$d7,$ed,$67));
{ TDPLData_PlayerGUID }
 
(*
* DPLPROPERTY_PlayerGuid
*
* Request the GUID that identifies the player on this machine for sending
* property data back to the lobby.
*
* Property data is the DPLDATA_PLAYERDATA structure
*)
// {B4319322-D20D-11d0-BA39-00C04FD7ED67}
DPLPROPERTY_PlayerGuid: TGUID =
(D1:$b4319322;D2:$d20d;D3:$11d0;D4:($ba,$39,$00,$c0,$4f,$d7,$ed,$67));
 
type
(*
* TDPLData_PlayerGUID
*
* Data structure to hold the GUID of the player and player creation flags
* from the lobby.
*)
PDPLData_PlayerGUID = ^TDPLData_PlayerGUID;
TDPLData_PlayerGUID = packed record
TDPLData_PlayerGUID = record
guidPlayer: TGUID;
dwPlayerFlags: DWORD;
end;
 
DPLDATA_PLAYERGUID = TDPLData_PlayerGUID;
LPDPLDATA_PLAYERGUID = PDPLData_PlayerGUID;
 
{ DPLPROPERTY_PlayerScore }
 
const
(*
* DPLPROPERTY_PlayerScore
*
* Used to send an array of long integers to the lobby indicating the
* score of a player.
*
* Property data is the TDPLData_PlayerScore structure.
*)
// {48784000-D219-11d0-BA39-00C04FD7ED67}
DPLPROPERTY_PlayerScore: TGUID =
(D1:$48784000;D2:$d219;D3:$11d0;D4:($ba,$39,$00,$c0,$4f,$d7,$ed,$67));
DPLPROPERTY_PlayerScore: TGUID = '{48784000-D219-11d0-BA39-00C04FD7ED67}';
 
{ TDPLData_PlayerScore }
 
type
(*
* TDPLData_PlayerScore
*
* Data structure to hold an array of long integers representing a player score.
* Application must allocate enough memory to hold all the scores.
*)
PDPLData_PlayerScore = ^TDPLData_PlayerScore;
TDPLData_PlayerScore = packed record
TDPLData_PlayerScore = record
dwScoreCount: DWORD;
Score: array[0..0] of LongInt;
Score: array[0..0] of Longint;
end;
 
(****************************************************************************
*
* DirectPlay Address ID's
*
****************************************************************************)
DPLDATA_PLAYERSCORE = TDPLData_PlayerScore;
LPDPLDATA_PLAYERSCORE = PDPLData_PlayerScore;
 
(* DirectPlay Address
*
* A DirectPlay address consists of multiple chunks of data, each tagged
* with a GUID signifying the type of data in the chunk. The chunk also
* has a length so that unknown chunk types can be skipped.
*
* The EnumAddress() function is used to parse these address data chunks.
*)
{ DirectPlay Address ID's }
 
(*
* TDPAddress
*
* Header for block of address data elements
*)
type
PDPAddress = ^TDPAddress;
TDPAddress = packed record
TDPAddress = record
guidDataType: TGUID;
dwDataSize: DWORD;
end;
 
DPADDRESS = TDPAddress;
LPDPADDRESS = PDPAddress;
 
const
(*
* DPAID_TotalSize
*
* Chunk is a DWORD containing size of entire TDPAddress structure
*)
DPAID_TotalSize: TGUID = '{1318F560-912C-11d0-9DAA-00A0C90A43CB}';
DPAID_ServiceProvider: TGUID = '{07D916C0-E0AF-11cf-9C4E-00A0C905425E}';
DPAID_LobbyProvider: TGUID = '{59B95640-9667-11d0-A77D-0000F803ABFC}';
DPAID_Phone: TGUID = '{78EC89A0-E0AF-11cf-9C4E-00A0C905425E}';
DPAID_PhoneW: TGUID = '{BA5A7A70-9DBF-11d0-9CC1-00A0C905425E}';
DPAID_Modem: TGUID = '{F6DCC200-A2FE-11d0-9C4F-00A0C905425E}';
DPAID_ModemW: TGUID = '{01FD92E0-A2FF-11d0-9C4F-00A0C905425E}';
DPAID_INet: TGUID = '{C4A54DA0-E0AF-11cf-9C4E-00A0C905425E}';
DPAID_INetW: TGUID = '{E63232A0-9DBF-11d0-9CC1-00A0C905425E}';
DPAID_INetPort: TGUID = '{E4524541-8EA5-11d1-8A96-006097B01411}';
DPAID_MaxMessageSize: TGUID = '{F5D09980-F0C4-11d1-8326-006097B01411}';
 
// {1318F560-912C-11d0-9DAA-00A0C90A43CB}
DPAID_TotalSize: TGUID =
(D1:$1318f560;D2:$912c;D3:$11d0;D4:($9d,$aa,$00,$a0,$c9,$a,$43,$cb));
{ TDPComPortAddress }
 
(*
* DPAID_ServiceProvider
*
* Chunk is a GUID describing the service provider that created the chunk.
* All addresses must contain this chunk.
*)
 
// {07D916C0-E0AF-11cf-9C4E-00A0C905425E}
DPAID_ServiceProvider: TGUID =
(D1:$7d916c0;D2:$e0af;D3:$11cf;D4:($9c,$4e,$00,$a0,$c9,$5,$42,$5e));
 
(*
* DPAID_LobbyProvider
*
* Chunk is a GUID describing the lobby provider that created the chunk.
* All addresses must contain this chunk.
*)
 
// {59B95640-9667-11d0-A77D-0000F803ABFC}
DPAID_LobbyProvider: TGUID =
(D1:$59b95640;D2:$9667;D3:$11d0;D4:($a7,$7d,$00,$00,$f8,$3,$ab,$fc));
 
(*
* DPAID_Phone and DPAID_PhoneW
*
* Chunk is a string containing a phone number (i.e. "1-800-555-1212")
* in ANSI or UNICODE format
*)
 
// {78EC89A0-E0AF-11cf-9C4E-00A0C905425E}
DPAID_Phone: TGUID =
(D1:$78ec89a0;D2:$e0af;D3:$11cf;D4:($9c,$4e,$00,$a0,$c9,$5,$42,$5e));
 
// {BA5A7A70-9DBF-11d0-9CC1-00A0C905425E}
DPAID_PhoneW: TGUID =
(D1:$ba5a7a70;D2:$9dbf;D3:$11d0;D4:($9c,$c1,$00,$a0,$c9,$5,$42,$5e));
 
(*
* DPAID_Modem and DPAID_ModemW
*
* Chunk is a string containing a modem name registered with TAPI
* in ANSI or UNICODE format
*)
 
// {F6DCC200-A2FE-11d0-9C4F-00A0C905425E}
DPAID_Modem: TGUID =
(D1:$f6dcc200;D2:$a2fe;D3:$11d0;D4:($9c,$4f,$00,$a0,$c9,$5,$42,$5e));
 
// {01FD92E0-A2FF-11d0-9C4F-00A0C905425E}
DPAID_ModemW: TGUID =
(D1:$1fd92e0;D2:$a2ff;D3:$11d0;D4:($9c,$4f,$00,$a0,$c9,$5,$42,$5e));
 
(*
* DPAID_Inet and DPAID_InetW
*
* Chunk is a string containing a TCP/IP host name or an IP address
* (i.e. "dplay.microsoft.com" or "137.55.100.173") in ANSI or UNICODE format
*)
 
// {C4A54DA0-E0AF-11cf-9C4E-00A0C905425E}
DPAID_INet: TGUID =
(D1:$c4a54da0;D2:$e0af;D3:$11cf;D4:($9c,$4e,$00,$a0,$c9,$5,$42,$5e));
 
// {E63232A0-9DBF-11d0-9CC1-00A0C905425E}
DPAID_INetW: TGUID =
(D1:$e63232a0;D2:$9dbf;D3:$11d0;D4:($9c,$c1,$00,$a0,$c9,$5,$42,$5e));
 
(*
* DPAID_InetPort
*
* Chunk is the port number used for creating the apps TCP and UDP sockets.
* WORD value (i.e. 47624)
*)
 
// {E4524541-8EA5-11d1-8A96-006097B01411}
DPAID_INetPort: TGUID =
(D1:$e4524541;D2:$8ea5;D3:$11d1;D4:($8a,$96,$00,$60,$97,$b0,$14,$11));
 
//@@BEGIN_MSINTERNAL
(*
* DPAID_MaxMessageSize
*
* Tells DPLAY what the maximum allowed message size is. Enables SPs to
* combat Denial of Service attacks
*)
 
// this terrible hack is needed so the SP can work with the Elmer build.
// it can be removed when the MSINTERNAL stuff is removed
{$DEFINE MAXMSGSIZEGUIDDEFINED}
 
// {F5D09980-F0C4-11d1-8326-006097B01411}
DPAID_MaxMessageSize: TGUID =
(D1:$f5d09980;D2:$f0c4;D3:$11d1;D4:($83,$26,$00,$60,$97,$b0,$14,$11));
//@@END_MSINTERNAL
 
(*
* TDPComPortAddress
*
* Used to specify com port settings. The constants that define baud rate,
* stop bits and parity are defined in WINBASE.H. The constants for flow
* control are given below.
*)
 
const
DPCPA_NOFLOW = 0; // no flow control
DPCPA_XONXOFFFLOW = 1; // software flow control
DPCPA_RTSFLOW = 2; // hardware flow control with RTS
16822,7 → 11132,7
 
type
PDPComPortAddress = ^TDPComPortAddress;
TDPComPortAddress = packed record
TDPComPortAddress = record
dwComPort: DWORD; // COM port to use (1-4)
dwBaudRate: DWORD; // baud rate (100-256k)
dwStopBits: DWORD; // no. stop bits (1-2)
16830,28 → 11140,16
dwFlowControl: DWORD; // flow control (none, xon/xoff, rts, dtr)
end;
 
DPCOMPORTADDRESS = TDPComPortAddress;
LPDPCOMPORTADDRESS = PDPComPortAddress;
 
const
(*
* DPAID_ComPort
*
* Chunk contains a TDPComPortAddress structure defining the serial port.
*)
DPAID_ComPort: TGUID = '{F2F0CE00-E0AF-11cf-9C4E-00A0C905425E}';
 
// {F2F0CE00-E0AF-11cf-9C4E-00A0C905425E}
DPAID_ComPort: TGUID =
(D1:$f2f0ce00;D2:$e0af;D3:$11cf;D4:($9c,$4e,$00,$a0,$c9,$5,$42,$5e));
{ dplobby 1.0 obsolete definitions }
 
(****************************************************************************
*
* dplobby 1.0 obsolete definitions
* Included for compatibility only.
*
****************************************************************************)
 
DPLAD_SYSTEM = DPLMSG_SYSTEM;
{$ENDIF} // UseDirectPlay
 
//DirectSetup file
(*==========================================================================
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
16859,28 → 11157,10
* File: dsetup.h
* Content: DirectXSetup, error codes and flags
*
* DirectX 7.0 Delphi adaptation by Erik Unger
*
* Modyfied: 05-Oct-99
*
* Download: http://www.delphi-jedi.org/DelphiGraphics/
* E-Mail: DelphiDirectX@next-reality.com
*
***************************************************************************)
 
var
DSetupDLL : HModule;
 
type
PDLSVersion = ^TDLSVersion;
TDLSVersion = packed record
dwVersionMS: DWORD;
dwVersionLS: DWORD;
end;
 
 
const
FOURCC_VERS : array[0..3] of Char = ('v','e','r','s');
FOURCC_VERS = Ord('v') + Ord('e')*$100 + Ord('r')*$10000 + Ord('s')*$1000000;
 
// DSETUP Error Codes, must remain compatible with previous setup.
DSETUPERR_SUCCESS_RESTART = HResult(1);
16894,7 → 11174,6
DSETUPERR_CANTFINDINF = HResult(-7);
DSETUPERR_CANTFINDDIR = HResult(-8);
DSETUPERR_INTERNAL = HResult(-9);
DSETUPERR_NTWITHNO3D = HResult(-10); // REM: obsolete, you'll never see this
DSETUPERR_UNKNOWNOS = HResult(-11);
DSETUPERR_USERHITCANCEL = HResult(-12);
DSETUPERR_NOTPREINSTALLEDONNT = HResult(-13);
16907,12 → 11186,11
DSETUP_DIRECTX = DSETUP_DXCORE or DSETUP_DDRAWDRV or DSETUP_DSOUNDDRV;
DSETUP_TESTINSTALL = $00020000; (* just test install, don't do anything *)
DSETUP_USEROLDERFLAG= $02000000; (* enable return DSETUPERR_NEWERVERSION *)
// Bug #22730
DSETUP_NTINSTALL = $00080000; (* install on Win2K platform *)
 
// These OBSOLETE flags are here for compatibility with pre-DX5 apps only.
// They are present to allow DX3 apps to be recompiled with DX5 and still work.
// DO NOT USE THEM for DX5. They will go away in future DX releases.
 
DSETUP_DDRAW = $00000001; (* OBSOLETE. install DirectDraw *)
DSETUP_DSOUND = $00000002; (* OBSOLETE. install DirectSound *)
DSETUP_DPLAY = $00000004; (* OBSOLETE. install DirectPlay *)
16964,21 → 11242,45
DSETUP_CB_UPGRADE_DEVICE_DISPLAY = $1000;
DSETUP_CB_UPGRADE_DEVICE_MEDIA = $2000;
 
type
 
type
{ TDLSVersion }
 
PDLSVersion = ^TDLSVersion;
TDLSVersion = record
dwVersionMS: DWORD;
dwVersionLS: WORD;
end;
 
DLSVERSION = TDLSVersion;
LPDLSVERSION = PDLSVersion;
 
{ TDSetup_CB_UpgradeInfo }
 
PDSetup_CB_UpgradeInfo = ^TDSetup_CB_UpgradeInfo;
TDSetup_CB_UpgradeInfo = record
UpgradeFlags: DWORD;
end;
 
DSETUP_CB_UPGRADEINFO = TDSetup_CB_UpgradeInfo;
LPDSETUP_CB_UPGRADEINFO = PDSetup_CB_UpgradeInfo;
 
{ TDSetup_CB_FileCopyError }
 
PDSetup_CB_FileCopyError = ^TDSetup_CB_FileCopyError;
TDSetup_CB_FileCopyError = record
dwError: DWORD;
end;
 
DSETUP_CB_FILECOPYERROR = TDSetup_CB_FileCopyError;
LPDSETUP_CB_FILECOPYERROR = PDSetup_CB_FileCopyError;
 
//
// Data Structures
//
 
{ TDirectXRegisterAppA }
 
PDirectXRegisterAppA = ^TDirectXRegisterAppA;
TDirectXRegisterAppA = record
dwSize: DWORD;
16991,6 → 11293,11
lpszCurrentDirectory: PAnsiChar;
end;
 
DIRECTXREGISTERAPPA = TDirectXRegisterAppA;
LPDIRECTXREGISTERAPPA = PDirectXRegisterAppA;
 
{ TDirectXRegisterApp2A }
 
PDirectXRegisterApp2A = ^TDirectXRegisterApp2A;
TDirectXRegisterApp2A = record
dwSize: DWORD;
17004,6 → 11311,11
lpszLauncherName: PAnsiChar;
end;
 
DIRECTXREGISTERAPP2A = TDirectXRegisterApp2A;
LPDIRECTXREGISTERAPP2A = PDirectXRegisterApp2A;
 
{ TDirectXRegisterAppW }
 
PDirectXRegisterAppW = ^TDirectXRegisterAppW;
TDirectXRegisterAppW = record
dwSize: DWORD;
17016,6 → 11328,11
lpszCurrentDirectory: PWideChar;
end;
 
DIRECTXREGISTERAPPW = TDirectXRegisterAppW;
LPDIRECTXREGISTERAPPW = PDirectXRegisterAppW;
 
{ TDirectXRegisterApp2W }
 
PDirectXRegisterApp2W = ^TDirectXRegisterApp2W;
TDirectXRegisterApp2W = record
dwSize: DWORD;
17029,102 → 11346,75
lpszLauncherName: PWideChar;
end;
 
PDirectXRegisterApp = ^TDirectXRegisterApp;
PDirectXRegisterApp2 = ^TDirectXRegisterApp2;
{$IFDEF UNICODE}
TDirectXRegisterApp = TDirectXRegisterAppW;
TDirectXRegisterApp2 = TDirectXRegisterApp2W;
{$ELSE}
DIRECTXREGISTERAPP2W = TDirectXRegisterApp2W;
LPDIRECTXREGISTERAPP2W = PDirectXRegisterApp2W;
 
{ TDirectXRegisterApp }
 
PDirectXRegisterApp = PDirectXRegisterAppA;
TDirectXRegisterApp = TDirectXRegisterAppA;
 
PDirectXRegisterApp2 = PDirectXRegisterApp2A;
TDirectXRegisterApp2 = TDirectXRegisterApp2A;
{$ENDIF}
 
//
// API
//
var
DirectXSetupW : function (hWnd: HWND; lpszRootPath: PWideChar; dwFlags: DWORD) : Integer; stdcall;
DirectXSetupA : function (hWnd: HWND; lpszRootPath: PAnsiChar; dwFlags: DWORD) : Integer; stdcall;
DirectXSetup : function (hWnd: HWND; lpszRootPath: PCharAW; dwFlags: DWORD) : Integer; stdcall;
DIRECTXREGISTERAPP = TDirectXRegisterApp;
LPDIRECTXREGISTERAPP = PDirectXRegisterApp;
 
DirectXDeviceDriverSetupW : function (hWnd: HWND; lpszDriverClass: PWideChar;
lpszDriverPath: PWideChar; dwFlags: DWORD) : Integer; stdcall;
DirectXDeviceDriverSetupA : function (hWnd: HWND; lpszDriverClass: PAnsiChar;
lpszDriverPath: PAnsiChar; dwFlags: DWORD) : Integer; stdcall;
DirectXDeviceDriverSetup : function (hWnd: HWND; lpszDriverClass: PCharAW;
lpszDriverPath: PCharAW; dwFlags: DWORD) : Integer; stdcall;
DIRECTXREGISTERAPP2 = TDirectXRegisterApp2;
LPDIRECTXREGISTERAPP2 = PDirectXRegisterApp2;
 
DirectXRegisterApplicationW : function
(hWnd: HWND; const lpDXRegApp: TDirectXRegisterAppW) : Integer; stdcall;
DirectXRegisterApplicationA : function
(hWnd: HWND; const lpDXRegApp: TDirectXRegisterAppA) : Integer; stdcall;
DirectXRegisterApplication : function
(hWnd: HWND; const lpDXRegApp: TDirectXRegisterApp) : Integer; stdcall;
{ API }
 
DirectXUnRegisterApplication : function
(hWnd: HWND; const lpGUID: TGUID) : Integer; stdcall;
function DirectXSetupA(hWnd: HWND; lpszRootPath: PAnsiChar; dwFlags: DWORD): Longint; stdcall;
function DirectXSetupW(hWnd: HWND; lpszRootPath: PWideChar; dwFlags: DWORD): Longint; stdcall;
function DirectXSetup(hWnd: HWND; lpszRootPath: PAnsiChar; dwFlags: DWORD): Longint; stdcall;
 
function DirectXDeviceDriverSetupA(hWnd: HWND; lpszDriverClass: PAnsiChar;
lpszDriverPath: PAnsiChar; dwFlags: DWORD): Longint; stdcall;
function DirectXDeviceDriverSetupW(hWnd: HWND; lpszDriverClass: PWideChar;
lpszDriverPath: PWideChar; dwFlags: DWORD): Longint; stdcall;
function DirectXDeviceDriverSetup(hWnd: HWND; lpszDriverClass: PAnsiChar;
lpszDriverPath: PAnsiChar; dwFlags: DWORD): Longint; stdcall;
 
function DirectXRegisterApplicationA(hWnd: HWND; const lpDXRegApp: TDirectXRegisterAppA): Longint; stdcall;
function DirectXRegisterApplicationW(hWnd: HWND; const lpDXRegApp: TDirectXRegisterAppW): Longint; stdcall;
function DirectXRegisterApplication(hWnd: HWND; const lpDXRegApp: TDirectXRegisterAppA): Longint; stdcall;
function DirectXUnRegisterApplication(hWnd: HWND; const lpGUID: TGUID): Longint; stdcall;
 
type
TDSetup_Callback = function (Reason: DWORD; MsgType: DWORD; // Same as flags to MessageBox
szMessage: PChar; szName: PChar; pInfo: Pointer) : DWORD; stdcall;
TDSetup_Callback = function (Reason: DWORD; MsgType: DWORD;
szMessage: PAnsiChar; szName: PAnsiChar; pInfo: Pointer): DWORD; stdcall;
DSETUP_CALLBACK = TDSetup_Callback;
 
var
DirectXSetupSetCallback : function (Callback: TDSetup_Callback) : Integer; stdcall;
function DirectXSetupSetCallback(Callback: TDSetup_Callback): Longint; stdcall;
function DirectXSetupGetVersion(var lpdwVersion, lpdwMinorVersion: DWORD): Longint; stdcall;
 
DirectXSetupGetVersion : function (out lpdwVersion, lpdwMinorVersion: DWORD) : Integer; stdcall;
 
//DirectSound file
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
* Copyright (C) 1995,1996 Microsoft Corporation. All Rights Reserved.
*
* File: dsound.h
* Content: DirectSound include file
*
* DirectX 7.0 Delphi adaptation by Erik Unger
*
* Modified: 10-Sep-2000
*
* Download: http://www.delphi-jedi.org/DelphiGraphics/
* E-Mail: DelphiDirectX@next-reality.com
*
***************************************************************************)
**************************************************************************)
 
{
Windows 98 and debug versions DInput and DSound
{ GUIDS used by DirectDraw objects }
 
Under Windows 98, the "debug" setup of the DirectX SDK 6.x skips DInput.DLL
and DSound.DLL, i.e. makes you end up with the retail version of these two
files without any notice.
The debug versions of DInput.DLL and DSound.DLL can be found in the
\extras\Win98\Win98Dbg folder of the SDK CD; they need to be installed
"manually".
}
 
 
var
DSoundDLL : HMODULE;
function DSErrorString(Value: HResult) : string;
 
const
_FACDS = $878;
function MAKE_DSHResult(code: DWORD) : HResult;
CLSID_DirectSound: TGUID = '{47D4D946-62E8-11cf-93BC-444553540000}';
CLSID_DirectSoundCapture: TGUID = '{B0210780-89CD-11d0-AF08-00A0C925CD16}';
 
const
FLT_MIN = 1.175494351E-38;
FLT_MAX = 3.402823466E+38;
IID_IDirectSound: TGUID = '{279AFA83-4981-11CE-A521-0020AF0BE560}';
IID_IDirectSoundBuffer: TGUID = '{279AFA85-4981-11CE-A521-0020AF0BE560}';
IID_IDirectSound3DListener: TGUID = '{279AFA84-4981-11CE-A521-0020AF0BE560}';
IID_IDirectSound3DBuffer: TGUID = '{279AFA86-4981-11CE-A521-0020AF0BE560}';
IID_IDirectSoundCapture: TGUID = '{B0210781-89CD-11D0-AF08-00A0C925CD16}';
IID_IDirectSoundCaptureBuffer: TGUID = '{B0210782-89CD-11D0-AF08-00A0C925CD16}';
const
// Direct Sound Component GUID {47D4D946-62E8-11cf-93BC-444553540000}
CLSID_DirectSound: TGUID = '{47D4D946-62E8-11cf-93BC-444553540000}';
IID_IDirectSoundNotify: TGUID = '{B0210783-89CD-11D0-AF08-00A0C925CD16}';
 
// DirectSound Capture Component GUID {B0210780-89CD-11d0-AF08-00A0C925CD16}
CLSID_DirectSoundCapture: TGUID = '{47D4D946-62E8-11cf-93BC-444553540000}';
{ DirectSound Structures }
 
//
// Structures
//
type
IDirectSound = interface;
IDirectSoundBuffer = interface;
17133,10 → 11423,11
IDirectSoundCapture = interface;
IDirectSoundCaptureBuffer = interface;
IDirectSoundNotify = interface;
IKsPropertySet = interface;
 
{ TDSCaps }
 
PDSCaps = ^TDSCaps;
TDSCaps = packed record
TDSCaps = record
dwSize: DWORD;
dwFlags: DWORD;
dwMinSecondarySampleRate: DWORD;
17162,10 → 11453,14
dwReserved1: DWORD;
dwReserved2: DWORD;
end;
PCDSCaps = ^TDSCaps;
 
DSCAPS = TDSCaps;
LPDSCAPS = PDSCaps;
 
{ TDSBCaps }
 
PDSBCaps = ^TDSBCaps;
TDSBCaps = packed record
TDSBCaps = record
dwSize: DWORD;
dwFlags: DWORD;
dwBufferBytes: DWORD;
17172,61 → 11467,45
dwUnlockTransferRate: DWORD;
dwPlayCpuOverhead: DWORD;
end;
PCDSBCaps = ^TDSBCaps;
 
TDSBufferDesc_DX6 = packed record
DSBCAPS = TDSBCaps;
LPDSBCAPS = DSBCAPS;
 
{ TDSBufferDesc }
 
PDSBufferDesc = ^TDSBufferDesc;
TDSBufferDesc = record
dwSize: DWORD;
dwFlags: DWORD;
dwBufferBytes: DWORD;
dwReserved: DWORD;
lpwfxFormat: PWaveFormatEx;
{$IFDEF SupportDirectX7}
guid3DAlgorithm: TGUID;
{$ENDIF}
end;
 
TDSBufferDesc1 = TDSBufferDesc_DX6;
DSBUFFERDESC = TDSBufferDesc;
LPDSBUFFERDESC = PDSBufferDesc;
 
{ TDSBufferDesc1 }
 
PDSBufferDesc1 = ^TDSBufferDesc1;
PCDSBufferDesc1 = PDSBufferDesc1;
 
TDSBufferDesc_DX7 = packed record
TDSBufferDesc1 = record
dwSize: DWORD;
dwFlags: DWORD;
dwBufferBytes: DWORD;
dwReserved: DWORD;
lpwfxFormat: PWaveFormatEx;
guid3DAlgorithm: TGUID;
end;
 
{$IFDEF DIRECTX6}
TDSBufferDesc = TDSBufferDesc_DX6;
{$ELSE}
TDSBufferDesc = TDSBufferDesc_DX7;
{$ENDIF}
DSBUFFERDESC1 = TDSBufferDesc1;
LPDSBUFFERDESC1 = PDSBufferDesc1;
 
PDSBufferDesc = ^TDSBufferDesc;
PCDSBufferDesc = PDSBufferDesc;
{ TDS3DBuffer }
 
(***
// Snipped from D3DTypes.pas:
 
TD3DValue = Single;
 
PD3DVector = ^TD3DVector;
TD3DVector = packed record
case Integer of
0: (
x: TD3DValue;
y: TD3DValue;
z: TD3DValue;
);
1: (
dvX: TD3DValue;
dvY: TD3DValue;
dvZ: TD3DValue;
);
end;
*)
 
PDS3DBuffer = ^TDS3DBuffer;
TDS3DBuffer = packed record
TDS3DBuffer = record
dwSize: DWORD;
vPosition: TD3DVector;
vVelocity: TD3DVector;
17233,15 → 11512,19
dwInsideConeAngle: DWORD;
dwOutsideConeAngle: DWORD;
vConeOrientation: TD3DVector;
lConeOutsideVolume: LongInt;
lConeOutsideVolume: Longint;
flMinDistance: TD3DValue;
flMaxDistance: TD3DValue;
dwMode: DWORD;
end;
TCDS3DBuffer = ^TDS3DBuffer;
 
DS3DBUFFER = TDS3DBuffer;
LPDS3DBUFFER = PDS3DBuffer;
 
{ TDS3DListener }
 
PDS3DListener = ^TDS3DListener;
TDS3DListener = packed record
TDS3DListener = record
dwSize: DWORD;
vPosition: TD3DVector;
vVelocity: TD3DVector;
17251,19 → 11534,27
flRolloffFactor: TD3DValue;
flDopplerFactor: TD3DValue;
end;
PCDS3DListener = ^TDS3DListener;
 
DS3DLISTENER = TDS3DListener;
LPDS3DLISTENER = PDS3DListener;
 
{ TDSCCaps }
 
PDSCCaps = ^TDSCCaps;
TDSCCaps = packed record
TDSCCaps = record
dwSize: DWORD;
dwFlags: DWORD;
dwFormats: DWORD;
dwChannels: DWORD;
end;
PCDSCCaps = ^TDSCCaps;
 
DSCCAPS = TDSCCaps;
LPDSCCAPS = PDSCCaps;
 
{ TDSCBufferDesc }
 
PDSCBufferDesc = ^TDSCBufferDesc;
TDSCBufferDesc = packed record
TDSCBufferDesc = record
dwSize: DWORD;
dwFlags: DWORD;
dwBufferBytes: DWORD;
17270,45 → 11561,41
dwReserved: DWORD;
lpwfxFormat: PWaveFormatEx;
end;
PCDSCBufferDesc = ^TDSCBufferDesc;
 
DSCBUFFERDESC = TDSCBufferDesc;
LPDSCBUFFERDESC = PDSCBufferDesc;
 
{ TDSCBCaps }
 
PDSCBCaps = ^TDSCBCaps;
TDSCBCaps = packed record
TDSCBCaps = record
dwSize: DWORD;
dwFlags: DWORD;
dwBufferBytes: DWORD;
dwReserved: DWORD;
end;
PCDSCBCaps = ^TDSCBCaps;
 
DSCBCAPS = TDSCBCaps;
LPDSCBCAPS = PDSCBCaps;
 
{ TDSBPositionNotify }
 
PDSBPositionNotify = ^TDSBPositionNotify;
TDSBPositionNotify = packed record
TDSBPositionNotify = record
dwOffset: DWORD;
hEventNotify: THandle;
end;
PCDSBPositionNotify = ^TDSBPositionNotify;
 
//
// DirectSound API
//
TDSEnumCallbackW = function (lpGuid: PGUID; lpstrDescription: PWideChar;
lpstrModule: PWideChar; lpContext: Pointer) : BOOL; stdcall;
TDSEnumCallbackA = function (lpGuid: PGUID; lpstrDescription: PAnsiChar;
lpstrModule: PAnsiChar; lpContext: Pointer) : BOOL; stdcall;
{$IFDEF UNICODE}
TDSEnumCallback = TDSEnumCallbackW;
{$ELSE}
TDSEnumCallback = TDSEnumCallbackA;
{$ENDIF}
DSBPOSITIONNOTIFY = TDSBPositionNotify;
LPDSBPOSITIONNOTIFY = PDSBPositionNotify;
 
//
// IDirectSound
//
{ IDirectSound }
 
IDirectSound = interface (IUnknown)
['{279AFA83-4981-11CE-A521-0020AF0BE560}']
// IDirectSound methods
function CreateSoundBuffer(const lpDSBufferDesc: TDSBufferDesc;
out lpIDirectSoundBuffer: IDirectSoundBuffer;
out lplpDirectSoundBuffer: IDirectSoundBuffer;
pUnkOuter: IUnknown) : HResult; stdcall;
function GetCaps(var lpDSCaps: TDSCaps) : HResult; stdcall;
function DuplicateSoundBuffer(lpDsbOriginal: IDirectSoundBuffer;
17320,32 → 11607,31
function Initialize(lpGuid: PGUID) : HResult; stdcall;
end;
 
//
// IDirectSoundBuffer
//
{ IDirectSoundBuffer }
 
IDirectSoundBuffer = interface (IUnknown)
['{279AFA85-4981-11CE-A521-0020AF0BE560}']
// IDirectSoundBuffer methods
function GetCaps(var lpDSCaps: TDSBCaps) : HResult; stdcall;
function GetCurrentPosition
(lpdwCapturePosition, lpdwReadPosition : PDWORD) : HResult; stdcall;
function GetFormat(lpwfxFormat: PWaveFormatEx; dwSizeAllocated: DWORD;
lpdwSizeWritten: PWORD) : HResult; stdcall;
function GetVolume(var lplVolume: integer) : HResult; stdcall;
function GetPan(var lplPan: integer) : HResult; stdcall;
function GetCaps(var lpDSBufferCaps: TDSBCaps): HResult; stdcall;
function GetCurrentPosition(var lpdwCurrentPlayCursor,
lpdwCurrentWriteCursor: DWORD): HResult; stdcall;
function GetFormat(var lpwfxFormat: TWaveFormatEx; dwSizeAllocated: DWORD;
var lpdwSizeWritten: DWORD): HResult; stdcall;
function GetVolume(var lplVolume: Longint): HResult; stdcall;
function GetPan(var lplPan: Longint): HResult; stdcall;
function GetFrequency(var lpdwFrequency: DWORD) : HResult; stdcall;
function GetStatus(var lpdwStatus: DWORD) : HResult; stdcall;
function Initialize(lpDirectSound: IDirectSound;
const lpcDSBufferDesc: TDSBufferDesc) : HResult; stdcall;
function Lock(dwWriteCursor, dwWriteBytes: DWORD;
function Initialize(lpDirectSound: IDirectSound; const
lpDSBufferDesc: TDSBufferDesc): HResult; stdcall;
function Lock(dwWriteCursor: DWORD; dwWriteBytes: DWORD;
var lplpvAudioPtr1: Pointer; var lpdwAudioBytes1: DWORD;
var lplpvAudioPtr2: Pointer; var lpdwAudioBytes2: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function Play(dwReserved1,dwReserved2,dwFlags: DWORD) : HResult; stdcall;
function SetCurrentPosition(dwPosition: DWORD) : HResult; stdcall;
function SetFormat(const lpcfxFormat: TWaveFormatEx) : HResult; stdcall;
function SetVolume(lVolume: integer) : HResult; stdcall;
function SetPan(lPan: integer) : HResult; stdcall;
function Play(dwReserved1, dwReserved2: DWORD; dwFlags: DWORD): HResult; stdcall;
function SetCurrentPosition(dwNewPosition: DWORD): HResult; stdcall;
function SetFormat(const lpfxFormat: TWaveFormatEx): HResult; stdcall;
function SetVolume(lVolume: Longint): HResult; stdcall;
function SetPan(lPan: Longint): HResult; stdcall;
function SetFrequency(dwFrequency: DWORD) : HResult; stdcall;
function Stop: HResult; stdcall;
function Unlock(lpvAudioPtr1: Pointer; dwAudioBytes1: DWORD;
17353,59 → 11639,49
function Restore: HResult; stdcall;
end;
 
//
// IDirectSound3DListener
//
{ IDirectSound3DListener }
 
IDirectSound3DListener = interface (IUnknown)
['{279AFA84-4981-11CE-A521-0020AF0BE560}']
// IDirectSound3D methods
// IDirectSound3DListener methods
function GetAllParameters(var lpListener: TDS3DListener) : HResult; stdcall;
function GetDistanceFactor(var lpflDistanceFactor: TD3DValue) : HResult; stdcall;
function GetDopplerFactor(var lpflDopplerFactor: TD3DValue) : HResult; stdcall;
function GetOrientation
(var lpvOrientFront, lpvOrientTop: TD3DVector) : HResult; stdcall;
function GetOrientation(var lpvOrientFront, lpvOrientTop: TD3DVector): HResult; stdcall;
function GetPosition(var lpvPosition: TD3DVector) : HResult; stdcall;
function GetRolloffFactor(var lpflRolloffFactor: TD3DValue) : HResult; stdcall;
function GetVelocity(var lpvVelocity: TD3DVector) : HResult; stdcall;
function SetAllParameters
(const lpcListener: TDS3DListener; dwApply: DWORD) : HResult; stdcall;
function SetDistanceFactor
(flDistanceFactor: TD3DValue; dwApply: DWORD) : HResult; stdcall;
function SetDopplerFactor
(flDopplerFactor: TD3DValue; dwApply: DWORD) : HResult; stdcall;
function SetAllParameters(const lpListener: TDS3DListener; dwApply: DWORD): HResult; stdcall;
function SetDistanceFactor(flDistanceFactor: TD3DValue; dwApply: DWORD): HResult; stdcall;
function SetDopplerFactor(flDopplerFactor: TD3DValue; dwApply: DWORD): HResult; stdcall;
function SetOrientation(xFront, yFront, zFront, xTop, yTop, zTop: TD3DValue;
dwApply: DWORD) : HResult; stdcall;
function SetPosition(x, y, z: TD3DValue; dwApply: DWORD) : HResult; stdcall;
function SetRolloffFactor
(flRolloffFactor: TD3DValue; dwApply: DWORD) : HResult; stdcall;
function SetRolloffFactor(flRolloffFactor: TD3DValue; dwApply: DWORD): HResult; stdcall;
function SetVelocity(x, y, z: TD3DValue; dwApply: DWORD) : HResult; stdcall;
function CommitDeferredSettings: HResult; stdcall;
end;
 
{ IDirectSound3DBuffer }
 
//
// IDirectSound3DBuffer
//
IDirectSound3DBuffer = interface (IUnknown)
['{279AFA86-4981-11CE-A521-0020AF0BE560}']
// IDirectSoundBuffer3D methods
// IDirectSound3DBuffer methods
function GetAllParameters(var lpDs3dBuffer: TDS3DBuffer) : HResult; stdcall;
function GetConeAngles
(var lpdwInsideConeAngle, lpdwOutsideConeAngle: DWORD) : HResult; stdcall;
function GetConeAngles(var lpdwInsideConeAngle: DWORD;
var lpdwOutsideConeAngle: DWORD): HResult; stdcall;
function GetConeOrientation(var lpvOrientation: TD3DVector) : HResult; stdcall;
function GetConeOutsideVolume(var lplConeOutsideVolume: integer) : HResult; stdcall;
function GetConeOutsideVolume(var lplConeOutsideVolume: Longint): HResult; stdcall;
function GetMaxDistance(var lpflMaxDistance: TD3DValue) : HResult; stdcall;
function GetMinDistance(var lpflMinDistance: TD3DValue) : HResult; stdcall;
function GetMode(var lpdwMode: DWORD) : HResult; stdcall;
function GetMode(var lpdwMod: DWORD): HResult; stdcall;
function GetPosition(var lpvPosition: TD3DVector) : HResult; stdcall;
function GetVelocity(var lpvVelocity: TD3DVector) : HResult; stdcall;
function SetAllParameters
(const lpcDs3dBuffer: TDS3DBuffer; dwApply: DWORD) : HResult; stdcall;
function SetConeAngles
(dwInsideConeAngle, dwOutsideConeAngle, dwApply: DWORD) : HResult; stdcall;
function SetAllParameters(const lpDs3dBuffer: TDS3DBuffer; dwApply: DWORD): HResult; stdcall;
function SetConeAngles(dwInsideConeAngle: DWORD; dwOutsideConeAngle: DWORD;
dwApply: DWORD): HResult; stdcall;
function SetConeOrientation(x, y, z: TD3DValue; dwApply: DWORD) : HResult; stdcall;
function SetConeOutsideVolume
(lConeOutsideVolume: LongInt; dwApply: DWORD) : HResult; stdcall;
function SetConeOutsideVolume(lConeOutsideVolume: Longint; dwApply: DWORD): HResult; stdcall;
function SetMaxDistance(flMaxDistance: TD3DValue; dwApply: DWORD) : HResult; stdcall;
function SetMinDistance(flMinDistance: TD3DValue; dwApply: DWORD) : HResult; stdcall;
function SetMode(dwMode: DWORD; dwApply: DWORD) : HResult; stdcall;
17413,36 → 11689,32
function SetVelocity(x, y, z: TD3DValue; dwApply: DWORD) : HResult; stdcall;
end;
 
{ IDirectSoundCapture }
 
//
// IDirectSoundCapture
//
IDirectSoundCapture = interface (IUnknown)
['{b0210781-89cd-11d0-af08-00a0c925cd16}']
['{B0210781-89CD-11D0-AF08-00A0C925CD16}']
// IDirectSoundCapture methods
function CreateCaptureBuffer(const lpDSCBufferDesc: TDSCBufferDesc;
var lplpDirectSoundCaptureBuffer: IDirectSoundCaptureBuffer;
out lplpDirectSoundCaptureBuffer: IDirectSoundCaptureBuffer;
pUnkOuter: IUnknown) : HResult; stdcall;
function GetCaps(var lpdwCaps: TDSCCaps) : HResult; stdcall;
function GetCaps(var lpDSCCaps: TDSCCaps): HResult; stdcall;
function Initialize(lpGuid: PGUID) : HResult; stdcall;
end;
 
{ IDirectSoundCaptureBuffer }
 
//
// IDirectSoundCaptureBuffer
//
IDirectSoundCaptureBuffer = interface (IUnknown)
['{b0210782-89cd-11d0-af08-00a0c925cd16}']
['{B0210782-89CD-11D0-AF08-00A0C925CD16}']
// IDirectSoundCaptureBuffer methods
function GetCaps(var lpdwCaps: TDSCBCaps) : HResult; stdcall;
function GetCurrentPosition
(lpdwCapturePosition, lpdwReadPosition: PDWORD) : HResult; stdcall;
function GetFormat(lpwfxFormat: PWaveFormatEx; dwSizeAllocated: DWORD;
lpdwSizeWritten : PDWORD) : HResult; stdcall;
function GetCaps(var lpDSCBCaps: TDSCBCaps): HResult; stdcall;
function GetCurrentPosition(var lpdwCapturePosition,
lpdwReadPosition: DWORD): HResult; stdcall;
function GetFormat(var lpwfxFormat: TWaveFormatEx; dwSizeAllocated: DWORD;
var lpdwSizeWritten: DWORD): HResult; stdcall;
function GetStatus(var lpdwStatus: DWORD) : HResult; stdcall;
function Initialize(lpDirectSoundCapture: IDirectSoundCapture;
const lpcDSBufferDesc: TDSCBufferDesc) : HResult; stdcall;
function Lock(dwReadCursor, dwReadBytes: DWORD;
function Lock(dwReadCursor: DWORD; dwReadBytes: DWORD;
var lplpvAudioPtr1: Pointer; var lpdwAudioBytes1: DWORD;
var lplpvAudioPtr2: Pointer; var lpdwAudioBytes2: DWORD;
dwFlags: DWORD) : HResult; stdcall;
17452,148 → 11724,65
lpvAudioPtr2: Pointer; dwAudioBytes2: DWORD) : HResult; stdcall;
end;
 
//
// IDirectSoundNotify
//
{ IDirectSoundNotify }
 
IDirectSoundNotify = interface (IUnknown)
['{b0210783-89cd-11d0-af08-00a0c925cd16}']
['{B0210783-89CD-11D0-AF08-00A0C925CD16}']
// IDirectSoundNotify methods
function SetNotificationPositions(cPositionNotifies: DWORD;
const lpcPositionNotifies: TDSBPositionNotify) : HResult; stdcall;
const lpcPositionNotifies): HResult; stdcall;
end;
 
//
// IKsPropertySet
//
IKsPropertySet = interface (IUnknown)
['{31efac30-515c-11d0-a9aa-00aa0061be93}']
// IKsPropertySet methods
function Get(const rguidPropSet: TGUID; ulId: DWORD; var pInstanceData;
ulInstanceLength: DWORD; var pPropertyData; ulDataLength: DWORD;
var pulBytesReturned: DWORD) : HResult; stdcall;
// Warning: The following method is defined as Set() in DirectX
// which is a reserved word in Delphi!
function SetProperty(const rguidPropSet: TGUID; ulId: DWORD;
var pInstanceData; ulInstanceLength: DWORD;
var pPropertyData; pulDataLength: DWORD) : HResult; stdcall;
function QuerySupport(const rguidPropSet: TGUID; ulId: DWORD;
var pulTypeSupport: DWORD) : HResult; stdcall;
end;
{ IKsPropertySet }
 
 
const
KSPROPERTY_SUPPORT_GET = $00000001;
KSPROPERTY_SUPPORT_SET = $00000002;
 
//
// GUID's for all the objects
//
IID_IKsPropertySet: TGUID = (D1:$31efac30;D2:$515c;D3:$11d0;D4:($a9,$aa,$00,$aa,$00,$61,$be,$93));
 
type
IID_IDirectSound = IDirectSound;
IID_IDirectSoundBuffer = IDirectSoundBuffer;
IID_IDirectSound3DListener = IDirectSound3DListener;
IID_IDirectSound3DBuffer = IDirectSound3DBuffer;
IID_IDirectSoundCapture = IDirectSoundCapture;
IID_IDirectSoundCaptureBuffer = IDirectSoundCaptureBuffer;
IID_IDirectSoundNotify = IDirectSoundNotify;
IID_IKsPropertySet = IKsPropertySet;
IKsPropertySet = interface;
 
//
// Creation Routines
//
var
DirectSoundCreate : function ( lpGuid: PGUID; out ppDS: IDirectSound;
pUnkOuter: IUnknown) : HResult; stdcall;
IKsPropertySet = interface(IUnknown)
['{31EFAC30-515C-11D0-A9AA-00AA0061BE93}']
// IKsPropertySet methods
function GetProperty(const PropertySetId: TGUID; PropertyId: DWORD;
var pPropertyParams; cbPropertyParams: DWORD;
var pPropertyData; cbPropertyData: DWORD;
var pcbReturnedData: ULONG): HResult; stdcall;
function SetProperty(const PropertySetId: TGUID; PropertyId: DWORD;
const pPropertyParams; cbPropertyParams: DWORD;
const pPropertyData; cbPropertyData: DWORD): HResult; stdcall;
function QuerySupport(const PropertySetId: TGUID; PropertyId: DWORD;
var pSupport: ULONG): HResult; stdcall;
end;
 
DirectSoundEnumerateW : function (lpDSEnumCallback: TDSEnumCallbackW;
lpContext: Pointer) : HResult; stdcall;
DirectSoundEnumerateA : function (lpDSEnumCallback: TDSEnumCallbackA;
lpContext: Pointer) : HResult; stdcall;
DirectSoundEnumerate : function (lpDSEnumCallback: TDSEnumCallback;
lpContext: Pointer) : HResult; stdcall;
{ Return Codes }
 
DirectSoundCaptureCreate : function (lpGUID: PGUID;
out lplpDSC: IDirectSoundCapture;
pUnkOuter: IUnknown) : HResult; stdcall;
 
DirectSoundCaptureEnumerateW : function (lpDSEnumCallback: TDSEnumCallbackW;
lpContext: Pointer) : HResult; stdcall;
DirectSoundCaptureEnumerateA : function (lpDSEnumCallback: TDSEnumCallbackA;
lpContext: Pointer) : HResult; stdcall;
DirectSoundCaptureEnumerate : function(lpDSEnumCallback: TDSEnumCallback;
lpContext: Pointer) : HResult; stdcall;
 
 
//
// Return Codes
//
 
const
MAKE_DSHRESULT_ = HResult($88780000);
DS_OK = HResult(S_OK);
DS_NO_VIRTUALIZATION = HResult($878000A);
DSERR_ALLOCATED = HResult($88780000 + 10);
DSERR_CONTROLUNAVAIL = HResult($88780000 + 30);
DSERR_INVALIDPARAM = HResult(E_INVALIDARG);
DSERR_INVALIDCALL = HResult($88780000 + 50);
DSERR_GENERIC = HResult(E_FAIL);
DSERR_PRIOLEVELNEEDED = HResult($88780000 + 70);
DSERR_OUTOFMEMORY = HResult(E_OUTOFMEMORY);
DSERR_BADFORMAT = HResult($88780000 + 100);
DSERR_UNSUPPORTED = HResult(E_NOTIMPL);
DSERR_NODRIVER = HResult($88780000 + 120);
DSERR_ALREADYINITIALIZED = HResult($88780000 + 130);
DSERR_NOAGGREGATION = HResult(CLASS_E_NOAGGREGATION);
DSERR_BUFFERLOST = HResult($88780000 + 150);
DSERR_OTHERAPPHASPRIO = HResult($88780000 + 160);
DSERR_UNINITIALIZED = HResult($88780000 + 170);
DSERR_NOINTERFACE = HResult(E_NOINTERFACE);
DSERR_ACCESSDENIED = HResult(E_ACCESSDENIED);
 
DS_OK = 0;
{ Flags }
 
// The function completed successfully, but we had to substitute the 3D algorithm
DS_NO_VIRTUALIZATION = MAKE_DSHRESULT_ + 10;
 
// The call failed because resources (such as a priority level)
// were already being used by another caller.
DSERR_ALLOCATED = MAKE_DSHRESULT_ + 10;
 
// The control (vol,pan,etc.) requested by the caller is not available.
DSERR_CONTROLUNAVAIL = MAKE_DSHRESULT_ + 30;
 
// An invalid parameter was passed to the returning function
DSERR_INVALIDPARAM = E_INVALIDARG;
 
// This call is not valid for the current state of this object
DSERR_INVALIDCALL = MAKE_DSHRESULT_ + 50;
 
// An undetermined error occured inside the DirectSound subsystem
DSERR_GENERIC = E_FAIL;
 
// The caller does not have the priority level required for the function to
// succeed.
DSERR_PRIOLEVELNEEDED = MAKE_DSHRESULT_ + 70;
 
// Not enough free memory is available to complete the operation
DSERR_OUTOFMEMORY = E_OUTOFMEMORY;
 
// The specified WAVE format is not supported
DSERR_BADFORMAT = MAKE_DSHRESULT_ + 100;
 
// The function called is not supported at this time
DSERR_UNSUPPORTED = E_NOTIMPL;
 
// No sound driver is available for use
DSERR_NODRIVER = MAKE_DSHRESULT_ + 120;
 
// This object is already initialized
DSERR_ALREADYINITIALIZED = MAKE_DSHRESULT_ + 130;
 
// This object does not support aggregation
DSERR_NOAGGREGATION = CLASS_E_NOAGGREGATION;
 
// The buffer memory has been lost, and must be restored.
DSERR_BUFFERLOST = MAKE_DSHRESULT_ + 150;
 
// Another app has a higher priority level, preventing this call from
// succeeding.
DSERR_OTHERAPPHASPRIO = MAKE_DSHRESULT_ + 160;
 
// This object has not been initialized
DSERR_UNINITIALIZED = MAKE_DSHRESULT_ + 170;
 
// The requested COM interface is not available
DSERR_NOINTERFACE = E_NOINTERFACE;
 
// Access is denied
DSERR_ACCESSDENIED = E_ACCESSDENIED;
 
//
// Flags
//
 
DSCAPS_PRIMARYMONO = $00000001;
DSCAPS_PRIMARYSTEREO = $00000002;
DSCAPS_PRIMARY8BIT = $00000004;
17618,16 → 11807,11
DSSPEAKER_SURROUND = $00000005;
DSSPEAKER_5POINT1 = $00000006;
 
DSSPEAKER_GEOMETRY_MIN = $00000005; // 5 degrees
DSSPEAKER_GEOMETRY_NARROW = $0000000A; // 10 degrees
DSSPEAKER_GEOMETRY_WIDE = $00000014; // 20 degrees
DSSPEAKER_GEOMETRY_MAX = $000000B4; // 180 degrees
DSSPEAKER_GEOMETRY_MIN = $00000005;
DSSPEAKER_GEOMETRY_NARROW = $0000000A;
DSSPEAKER_GEOMETRY_WIDE = $00000014;
DSSPEAKER_GEOMETRY_MAX = $000000B4;
 
function DSSPEAKER_COMBINED(c, g: variant) : DWORD;
function DSSPEAKER_CONFIG(a: variant) : byte;
function DSSPEAKER_GEOMETRY(a: variant) : byte;
 
const
DSBCAPS_PRIMARYBUFFER = $00000001;
DSBCAPS_STATIC = $00000002;
DSBCAPS_LOCHARDWARE = $00000004;
17637,6 → 11821,8
DSBCAPS_CTRLPAN = $00000040;
DSBCAPS_CTRLVOLUME = $00000080;
DSBCAPS_CTRLPOSITIONNOTIFY = $00000100;
DSBCAPS_CTRLDEFAULT = $000000E0;
DSBCAPS_CTRLALL = $000001F0;
DSBCAPS_STICKYFOCUS = $00004000;
DSBCAPS_GLOBALFOCUS = $00008000;
DSBCAPS_GETCURRENTPOSITION2 = $00010000;
17647,8 → 11833,8
DSBPLAY_LOCHARDWARE = $00000002;
DSBPLAY_LOCSOFTWARE = $00000004;
DSBPLAY_TERMINATEBY_TIME = $00000008;
DSBPLAY_TERMINATEBY_DISTANCE = $000000010;
DSBPLAY_TERMINATEBY_PRIORITY = $000000020;
DSBPLAY_TERMINATEBY_DISTANCE = $00000010;
DSBPLAY_TERMINATEBY_PRIORITY = $00000020;
 
DSBSTATUS_PLAYING = $00000001;
DSBSTATUS_BUFFERLOST = $00000002;
17681,8 → 11867,8
DS3D_IMMEDIATE = $00000000;
DS3D_DEFERRED = $00000001;
 
DS3D_MINDISTANCEFACTOR = FLT_MIN;
DS3D_MAXDISTANCEFACTOR = FLT_MAX;
DS3D_MINDISTANCEFACTOR = 0.0;
DS3D_MAXDISTANCEFACTOR = 10.0;
DS3D_DEFAULTDISTANCEFACTOR = 1.0;
 
DS3D_MINROLLOFFFACTOR = 0.0;
17702,16 → 11888,11
 
DS3D_DEFAULTCONEOUTSIDEVOLUME = DSBVOLUME_MAX;
 
DSCCAPS_EMULDRIVER = $00000020;
DSCCAPS_EMULDRIVER = DSCAPS_EMULDRIVER;
DSCCAPS_CERTIFIED = DSCAPS_CERTIFIED;
 
DSCBCAPS_WAVEMAPPED = $80000000;
 
 
 
DSBCAPS_CTRLDEFAULT = $000000E0;
DSBCAPS_CTRLALL = $000001F0;
 
DSCBLOCK_ENTIREBUFFER = $00000001;
 
DSCBSTATUS_CAPTURING = $00000001;
17719,50 → 11900,42
 
DSCBSTART_LOOPING = $00000001;
 
DSBPN_OFFSETSTOP = DWORD(-1);
DSBPN_OFFSETSTOP = $FFFFFFFF;
 
//
// DirectSound3D Algorithms
//
 
// Default DirectSound3D algorithm {00000000-0000-0000-0000-000000000000}
DS3DALG_DEFAULT: TGUID = '{00000000-0000-0000-0000-000000000000}';
DS3DALG_NO_VIRTUALIZATION: TGUID = '{C241333F-1C1B-11D2-94F5-00C04FC28ACA}';
DS3DALG_HRTF_FULL: TGUID = '{C2413340-1C1B-11D2-94F5-00C04FC28ACA}';
DS3DALG_HRTF_LIGHT: TGUID = '{C2413342-1C1B-11D2-94F5-00C04FC28ACA}';
 
// No virtualization {C241333F-1C1B-11d2-94F5-00C04FC28ACA}
DS3DALG_NO_VIRTUALIZATION: TGUID = '';
function DSSPEAKER_COMBINED(c, g: Byte): DWORD;
function DSSPEAKER_CONFIG(a: DWORD): Byte;
function DSSPEAKER_GEOMETRY(a: DWORD): Byte;
 
// High-quality HRTF algorithm {C2413340-1C1B-11d2-94F5-00C04FC28ACA}
DS3DALG_HRTF_FULL: TGUID = '{C2413340-1C1B-11d2-94F5-00C04FC28ACA}';
{ DirectSound API }
 
// Lower-quality HRTF algorithm {C2413342-1C1B-11d2-94F5-00C04FC28ACA}
DS3DALG_HRTF_LIGHT: TGUID = '{C2413342-1C1B-11d2-94F5-00C04FC28ACA}';
type
TDSEnumCallbackW = function(lpGuid: PGUID; lpstrDescription: LPCWSTR;
lpstrModule: LPCWSTR; lpContext: Pointer): BOOL; stdcall;
LPDSENUMCALLBACKW = TDSEnumCallbackW;
 
//DirectMusic file
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* Files: dls1.h dls2.h dmdls.h dmerror.h dmksctrl.h
dmusicc.h dmusici.h dmusicf.h dmusbuff.h
* Content: DirectMusic, DirectSetup
*
* DirectX 7.0 Delphi adaptation by Erik Unger
*
* Modyfied: 10-Sep-2000
*
* Download: http://www.delphi-jedi.org/DelphiGraphics/
* E-Mail: DelphiDirectX@next-reality.com
*
***************************************************************************)
TDSEnumCallbackA = function(lpGuid: PGUID; lpstrDescription: LPCSTR;
lpstrModule: LPCSTR; lpContext: Pointer): BOOL; stdcall;
LPDSENUMCALLBACKA = TDSEnumCallbackA;
 
TDSEnumCallback = TDSEnumCallbackA;
LPDSENUMCALLBACK = TDSEnumCallback;
 
function MAKE_HRESULT(sev,fac,code: DWORD) : HResult;
function DirectSoundCreate(lpGUID: PGUID; out lpDS: IDirectSound; pUnkOuter: IUnknown): HResult; stdcall;
function DirectSoundEnumerateA(lpDSEnumCallback: TDSEnumCallbackA; lpContext: Pointer): HResult; stdcall;
function DirectSoundEnumerateW(lpDSEnumCallback: TDSEnumCallbackW; lpContext: Pointer): HResult; stdcall;
function DirectSoundEnumerate(lpDSEnumCallback: TDSEnumCallbackA; lpContext: Pointer): HResult; stdcall;
 
type
mmioFOURCC = array [0..3] of Char;
function DirectSoundCaptureCreate(lpGUID: PGUID; out lplpDSC: IDirectSoundCapture; pUnkOuter: IUnknown): HResult; stdcall;
function DirectSoundCaptureEnumerateA(lpDSEnumCallback: TDSEnumCallbackA; lpContext: Pointer): HResult; stdcall;
function DirectSoundCaptureEnumerateW(lpDSEnumCallback: TDSEnumCallbackW; lpContext: Pointer): HResult; stdcall;
function DirectSoundCaptureEnumerate(lpDSEnumCallback: TDSEnumCallbackA; lpContext: Pointer): HResult; stdcall;
 
 
(*==========================================================================;
//==========================================================================;
//
// dls1.h
//
17775,9 → 11948,9
//
// Written by Sonic Foundry 1996. Released for public use.
//
//=========================================================================*)
//=========================================================================
 
(*//////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//
//
// Layout of an instrument collection:
17820,37 → 11993,37
// 'icmt' 'One of those crazy comments.'
// 'icop' 'Copyright (C) 1996 Sonic Foundry'
//
////////////////////////////////////////////////////////////////////////(*)
//////////////////////////////////////////////////////////////////////////
 
(*/////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
// FOURCC's used in the DLS file
////////////////////////////////////////////////////////////////////////(*)
 
//////////////////////////////////////////////////////////////////////////
const
FOURCC_DLS : mmioFOURCC = ('D','L','S',' ');
FOURCC_DLID : mmioFOURCC = ('d','l','i','d');
FOURCC_COLH : mmioFOURCC = ('c','o','l','h');
FOURCC_WVPL : mmioFOURCC = ('w','v','p','l');
FOURCC_PTBL : mmioFOURCC = ('p','t','b','l');
FOURCC_PATH : mmioFOURCC = ('p','a','t','h');
FOURCC_wave : mmioFOURCC = ('w','a','v','e');
FOURCC_LINS : mmioFOURCC = ('l','i','n','s');
FOURCC_INS : mmioFOURCC = ('i','n','s',' ');
FOURCC_INSH : mmioFOURCC = ('i','n','s','h');
FOURCC_LRGN : mmioFOURCC = ('l','r','g','n');
FOURCC_RGN : mmioFOURCC = ('r','g','n',' ');
FOURCC_RGNH : mmioFOURCC = ('r','g','n','h');
FOURCC_LART : mmioFOURCC = ('l','a','r','t');
FOURCC_ART1 : mmioFOURCC = ('a','r','t','1');
FOURCC_WLNK : mmioFOURCC = ('w','l','n','k');
FOURCC_WSMP : mmioFOURCC = ('w','s','m','p');
//FOURCC_VERS : mmioFOURCC = ('v','e','r','s');
FOURCC_DLS = Ord('D') + Ord('L') shl 8 + Ord('S') shl 16 + Ord(' ') shl 24;
FOURCC_DLID = Ord('d') + Ord('l') shl 8 + Ord('i') shl 16 + Ord('d') shl 24;
FOURCC_COLH = Ord('c') + Ord('o') shl 8 + Ord('l') shl 16 + Ord('h') shl 24;
FOURCC_WVPL = Ord('w') + Ord('v') shl 8 + Ord('p') shl 16 + Ord('l') shl 24;
FOURCC_PTBL = Ord('p') + Ord('t') shl 8 + Ord('b') shl 16 + Ord('l') shl 24;
FOURCC_PATH = Ord('p') + Ord('a') shl 8 + Ord('t') shl 16 + Ord('h') shl 24;
FOURCC_wave = Ord('w') + Ord('a') shl 8 + Ord('v') shl 16 + Ord('e') shl 24;
FOURCC_LINS = Ord('l') + Ord('i') shl 8 + Ord('n') shl 16 + Ord('s') shl 24;
FOURCC_INS = Ord('i') + Ord('n') shl 8 + Ord('s') shl 16 + Ord(' ') shl 24;
FOURCC_INSH = Ord('i') + Ord('n') shl 8 + Ord('s') shl 16 + Ord('h') shl 24;
FOURCC_LRGN = Ord('l') + Ord('r') shl 8 + Ord('g') shl 16 + Ord('n') shl 24;
FOURCC_RGN = Ord('r') + Ord('g') shl 8 + Ord('n') shl 16 + Ord(' ') shl 24;
FOURCC_RGNH = Ord('r') + Ord('g') shl 8 + Ord('n') shl 16 + Ord('h') shl 24;
FOURCC_LART = Ord('l') + Ord('a') shl 8 + Ord('r') shl 16 + Ord('t') shl 24;
FOURCC_ART1 = Ord('a') + Ord('r') shl 8 + Ord('t') shl 16 + Ord('1') shl 24;
FOURCC_WLNK = Ord('w') + Ord('l') shl 8 + Ord('n') shl 16 + Ord('k') shl 24;
FOURCC_WSMP = Ord('w') + Ord('s') shl 8 + Ord('m') shl 16 + Ord('p') shl 24;
//FOURCC_VERS = Ord('v') + Ord('e') shl 8 + Ord('r') shl 16 + Ord('s') shl 24;
 
(*/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Articulation connection graph definitions
////////////////////////////////////////////////////////////////////////(*)
//////////////////////////////////////////////////////////////////////////
 
(* Generic Sources *)
// Generic Sources
CONN_SRC_NONE = $0000;
CONN_SRC_LFO = $0001;
CONN_SRC_KEYONVELOCITY = $0002;
17859,126 → 12032,133
CONN_SRC_EG2 = $0005;
CONN_SRC_PITCHWHEEL = $0006;
 
(* Midi Controllers 0-127 *)
// Midi Controllers 0-127
CONN_SRC_CC1 = $0081;
CONN_SRC_CC7 = $0087;
CONN_SRC_CC10 = $008a;
CONN_SRC_CC11 = $008b;
CONN_SRC_CC10 = $008A;
CONN_SRC_CC11 = $008B;
 
(* Generic Destinations *)
// Generic Destinations
CONN_DST_NONE = $0000;
CONN_DST_ATTENUATION = $0001;
CONN_DST_PITCH = $0003;
CONN_DST_PAN = $0004;
 
(* LFO Destinations *)
// LFO Destinations
CONN_DST_LFO_FREQUENCY = $0104;
CONN_DST_LFO_STARTDELAY = $0105;
 
(* EG1 Destinations *)
// EG1 Destinations
CONN_DST_EG1_ATTACKTIME = $0206;
CONN_DST_EG1_DECAYTIME = $0207;
CONN_DST_EG1_RELEASETIME = $0209;
CONN_DST_EG1_SUSTAINLEVEL = $020a;
CONN_DST_EG1_SUSTAINLEVEL = $020A;
 
(* EG2 Destinations *)
CONN_DST_EG2_ATTACKTIME = $030a;
CONN_DST_EG2_DECAYTIME = $030b;
CONN_DST_EG2_RELEASETIME = $030d;
CONN_DST_EG2_SUSTAINLEVEL = $030e;
// EG2 Destinations
CONN_DST_EG2_ATTACKTIME = $030A;
CONN_DST_EG2_DECAYTIME = $030B;
CONN_DST_EG2_RELEASETIME = $030D;
CONN_DST_EG2_SUSTAINLEVEL = $030E;
 
CONN_TRN_NONE = $0000;
CONN_TRN_CONCAVE = $0001;
 
type
PDLSId = ^TDLSId;
TDLSId = packed record
ulData1 : ULONG;
TDLSID = record
ulData1 : Cardinal;
usData2 : Word;
usData3 : Word;
abData4 : array [0..7] of BYTE;
abData4 : array[0..7] of Byte;
end;
DLSID = TDLSID;
LPDLSID = ^DLSID;
 
// PDLSVersion = ^TDLSVersion;
// TDLSVersion = packed record
// dwVersionMS,
// dwVersionLS : DWORD;
// end;
 
PConnection = ^TConnection;
TConnection = packed record
{TDLSVERSION = record
dwVersionMS : DWORD;
dwVersionLS : DWORD;
end;
DLSVERSION = TDLSVERSION;
LPDLSVERSION = ^DLSVERSION;
}
TCONNECTION = record
usSource : Word;
usControl : Word;
SuDestination : Word;
usDestination : Word;
usTransform : Word;
lScale : LongInt;
lScale : Cardinal;
end;
CONNECTION = TCONNECTION;
LPCONNECTION = ^CONNECTION;
 
(* Level 1 Articulation Data *)
// Level 1 Articulation Data
 
PConnectionList = ^TConnectionList;
TConnectionList = packed record
cbSize : ULONG; (* size of the connection list structure *)
cConnections : ULONG; (* count of connections in the list *)
TCONNECTIONLIST = record
cbSize : Cardinal; // size of the connection list structure
cConnections : Cardinal; // count of connections in the list
end;
CONNECTIONLIST = TCONNECTIONLIST;
LPCONNECTIONLIST = ^CONNECTIONLIST;
 
(*/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Generic type defines for regions and instruments
////////////////////////////////////////////////////////////////////////(*)
 
PRGNRange = ^TRGNRange;
TRGNRange = packed record
//////////////////////////////////////////////////////////////////////////
type
TRGNRANGE = record
usLow : Word;
usHigh : Word;
end;
RGNRANGE = TRGNRANGE;
LPRGNRANGE = ^RGNRANGE;
 
const
F_INSTRUMENT_DRUMS = $80000000;
FTINSTRUMENTTDRUMS = $80000000;
 
type
PMIDILocale = ^TMIDILocale;
TMIDILocale = packed record
ulBank : ULONG;
ulInstrument : ULONG;
TMIDILOCALE = record
ulBank : Cardinal;
ulInstrument : Cardinal;
end;
MIDILOCALE = TMIDILOCALE;
LPMIDILOCALE = ^MIDILOCALE;
 
(*/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Header structures found in an DLS file for collection, instruments, and
// regions.
////////////////////////////////////////////////////////////////////////(*)
 
//////////////////////////////////////////////////////////////////////////
const
F_RGN_OPTION_SELFNONEXCLUSIVE = $0001;
 
type
PRGNHeader = ^TRGNHeader;
TRGNHeader = packed record
RangeKey : TRGNRange; (* Key range *)
RangeVelocity : TRGNRange; (* Velocity Range *)
fusOptions : Word ; (* Synthesis options for this range *)
usKeyGroup : Word ; (* Key grouping for non simultaneous play *)
(* 0 = no group, 1 up is group *)
(* for Level 1 only groups 1-15 are allowed *)
end;
TRGNHEADER = record
RangeKey : RGNRANGE; // Key range
RangeVelocity : RGNRANGE; // Velocity Range
fusOptions : Word; // Synthesis options for this range
usKeyGroup : Word; // Key grouping for non simultaneous play
end; // 0 = no group, 1 up is group
// for Level 1 only groups 1-15 are allowed
RGNHEADER = TRGNHEADER;
LPRGNHEADER = ^RGNHEADER;
 
PInstHeader = ^TInstHeader;
TInstHeader = packed record
cRegions : ULONG; (* Count of regions in this instrument *)
Locale : TMIDILocale; (* Intended MIDI locale of this instrument *)
TINSTHEADER = record
cRegions : Cardinal; // Count of regions in this instrument
Locale : MIDILOCALE; // Intended MIDI locale of this instrument
end;
INSTHEADER = TINSTHEADER;
LPINSTHEADER = ^INSTHEADER;
 
PDLSHeader = ^TDLSHeader;
TDLSHeader = packed record
cInstruments : ULONG;
TDLSHEADER = record
cInstruments : Cardinal; // Count of instruments in the collection
end;
DLSHEADER = TDLSHEADER;
LPDLSHEADER = ^DLSHEADER;
 
(*////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// definitions for the Wave link structure
///////////////////////////////////////////////////////////////////////////(*)
/////////////////////////////////////////////////////////////////////////////
 
(* **** For level 1 only WAVELINK_CHANNEL_MONO is valid **** *)
(* ulChannel allows for up to 32 channels of audio with each bit position *)
(* specifiying a channel of playback *)
// **** For level 1 only WAVELINK_CHANNEL_MONO is valid ****
// ulChannel allows for up to 32 channels of audio with each bit position
// specifiying a channel of playback
 
const
WAVELINK_CHANNEL_LEFT = $0001;
17987,65 → 12167,69
F_WAVELINK_PHASE_MASTER = $0001;
 
type
PWaveLink = ^TWaveLink;
TWaveLink = packed record (* any paths or links are stored right after struct *)
fusOptions : Word; (* options flags for this wave *)
usPhaseGroup : Word; (* Phase grouping for locking channels *)
ulChannel : ULONG; (* channel placement *)
ulTableIndex : ULONG; (* index into the wave pool table, 0 based *)
TWAVELINK = record // any paths or links are stored right after struct
fusOptions : Word; // options flags for this wave
usPhaseGroup : Word; // Phase grouping for locking channels
ulChannel : Cardinal; // channel placement
ulTableIndex : Cardinal; // index into the wave pool table, 0 based
end;
WAVELINK = TWAVELINK;
LPWAVELINK = ^WAVELINK;
 
const
POOL_CUE_NULL = $ffffffff;
POOL_CUE_NULL = $FFFFFFFF;
 
type
PPoolCUE = ^TPoolCUE;
TPoolCUE = packed record
ulOffset : ULONG;
TPOOLCUE = record
ulOffset : Cardinal; // Offset to the entry in the list
end;
POOLCUE = TPOOLCUE;
LPPOOLCUE = ^POOLCUE;
 
PPoolTable = ^TPoolTable;
TPoolTable = packed record
cbSize : ULONG; (* size of the pool table structure *)
cCues : ULONG; (* count of cues in the list *)
TPOOLTABLE = record
cbSize : Cardinal; // size of the pool table structure
cCues : Cardinal; // count of cues in the list
end;
POOLTABLE = TPOOLTABLE;
LPPOOLTABLE = ^POOLTABLE;
 
(*////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Structures for the "wsmp" chunk
///////////////////////////////////////////////////////////////////////////(*)
 
/////////////////////////////////////////////////////////////////////////////
const
F_WSMP_NO_TRUNCATION = $0001;
F_WSMP_NO_COMPRESSION = $0002;
 
type
PWSMPL = ^TWSMPL;
TWSMPL = packed record
cbSize : ULONG;
usUnityNote : Word; (* MIDI Unity Playback Note *)
sFineTune : SmallInt; (* Fine Tune in log tuning *)
lAttenuation : Integer; (* Overall Attenuation to be applied to data *)
fulOptions : ULONG; (* Flag options *)
cSampleLoops : ULONG; (* Count of Sample loops, 0 loops is one shot *)
Trwsmp = record
cbSize : Cardinal;
usUnityNote : Word; // MIDI Unity Playback Note
sFineTune : Smallint; // Fine Tune in log tuning
lAttenuation : Longint; // Overall Attenuation to be applied to data
fulOptions : Cardinal; // Flag options
cSampleLoops : Cardinal; // Count of Sample loops, 0 loops is one shot
end;
WSMPL = Trwsmp;
LPWSMPL = ^WSMPL;
 
 
(* This loop type is a normal forward playing loop which is continually *)
(* played until the envelope reaches an off threshold in the release *)
(* portion of the volume envelope *)
 
// This loop type is a normal forward playing loop which is continually
// played until the envelope reaches an off threshold in the release
// portion of the volume envelope
const
WLOOP_TYPE_FORWARD = 0;
 
type
TWLoop = packed record
cbSize : ULONG;
ulType : ULONG; (* Loop Type *)
ulStart : ULONG; (* Start of loop in samples *)
ulLength : ULONG; (* Length of loop in samples *)
Trloop = record
cbSize : Cardinal;
ulType : Cardinal; // Loop Type
ulStart : Cardinal; // Start of loop in samples
ulLength : Cardinal; // Length of loop in samples
end;
WLOOP = Trloop;
LPWLOOP = ^WLOOP;
 
(*******************************************************************************
{/*
 
dls2.h
 
18056,931 → 12240,940
 
Written by Microsoft 1998. Released for public use.
 
*******************************************************************************)
}
 
(*
FOURCC's used in the DLS2 file, in addition to DLS1 chunks
*)
const
FOURCC_RGN2 : mmioFOURCC = ('r','g','n','2');
FOURCC_LAR2 : mmioFOURCC = ('l','a','r','2');
FOURCC_ART2 : mmioFOURCC = ('a','r','t','2');
FOURCC_CDL : mmioFOURCC = ('c','d','l',' ');
// FOURCC_DLID : mmioFOURCC = ('d','l','i','d');
//
// FOURCC's used in the DLS2 file, in addition to DLS1 chunks
///
 
(*
Articulation connection graph definitions. These are in addition to
the definitions in the DLS1 header.
*)
FOURCC_RGN2 = Ord('r') + Ord('g') shl 8 + Ord('n') shl 16 + Ord('2') shl 24;
FOURCC_LAR2 = Ord('l') + Ord('a') shl 8 + Ord('r') shl 16 + Ord('2') shl 24;
FOURCC_ART2 = Ord('a') + Ord('r') shl 8 + Ord('t') shl 16 + Ord('2') shl 24;
FOURCC_CDL = Ord('c') + Ord('d') shl 8 + Ord('l') shl 16 + Ord(' ') shl 24;
//FOURCC_DLID = Ord('d') + Ord('l') shl 8 + Ord('i') shl 16 + Ord('d') shl 24;
 
const
(* Generic Sources (in addition to DLS1 sources. *)
CONN_SRC_POLYPRESSURE = $0007; (* Polyphonic Pressure *)
CONN_SRC_CHANNELPRESSURE = $0008; (* Channel Pressure *)
CONN_SRC_VIBRATO = $0009; (* Vibrato LFO *)
CONN_SRC_MONOPRESSURE = $000a; (* MIDI Mono pressure *)
//
// Articulation connection graph definitions. These are in addition to
// the definitions in the DLS1 header.
///
 
// Generic Sources (in addition to DLS1 sources.
CONN_SRC_POLYPRESSURE = $0007; // Polyphonic Pressure
CONN_SRC_CHANNELPRESSURE = $0008; // Channel Pressure
CONN_SRC_VIBRATO = $0009; // Vibrato LFO
CONN_SRC_MONOPRESSURE = $000a; // MIDI Mono pressure
 
(* Midi Controllers *)
CONN_SRC_CC91 = $00db; (* Reverb Send *)
CONN_SRC_CC93 = $00dd; (* Chorus Send *)
 
// Midi Controllers
CONN_SRC_CC91 = $00db; // Reverb Send
CONN_SRC_CC93 = $00dd; // Chorus Send
 
(* Generic Destinations *)
CONN_DST_GAIN = $0001; (* Same as CONN_DST_ ATTENUATION *)
CONN_DST_KEYNUMBER = $0005; (* Key Number Generator *)
 
(* Audio Channel Output Destinations *)
CONN_DST_LEFT = $0010; (* Left Channel Send *)
CONN_DST_RIGHT = $0011; (* Right Channel Send *)
CONN_DST_CENTER = $0012; (* Center Channel Send *)
CONN_DST_LEFTREAR = $0013; (* Left Rear Channel Send *)
CONN_DST_RIGHTREAR = $0014; (* Right Rear Channel Send *)
CONN_DST_LFE_CHANNEL = $0015; (* LFE Channel Send *)
CONN_DST_CHORUS = $0080; (* Chorus Send *)
CONN_DST_REVERB = $0081; (* Reverb Send *)
// Generic Destinations
CONN_DST_GAIN = $0001; // Same as CONN_DST_ ATTENUATION
CONN_DST_KEYNUMBER = $0005; // Key Number Generator
 
(* Vibrato LFO Destinations *)
CONN_DST_VIB_FREQUENCY = $0114; (* Vibrato Frequency *)
CONN_DST_VIB_STARTDELAY = $0115; (* Vibrato Start Delay *)
// Audio Channel Output Destinations
CONN_DST_LEFT = $0010; // Left Channel Send
CONN_DST_RIGHT = $0011; // Right Channel Send
CONN_DST_CENTER = $0012; // Center Channel Send
CONN_DST_LEFTREAR = $0013; // Left Rear Channel Send
CONN_DST_RIGHTREAR = $0014; // Right Rear Channel Send
CONN_DST_LFE_CHANNEL = $0015; // LFE Channel Send
CONN_DST_CHORUS = $0080; // Chorus Send
CONN_DST_REVERB = $0081; // Reverb Send
 
(* EG1 Destinations *)
CONN_DST_EG1_DELAYTIME = $020B; (* EG1 Delay Time *)
CONN_DST_EG1_HOLDTIME = $020C; (* EG1 Hold Time *)
// Vibrato LFO Destinations
CONN_DST_VIB_FREQUENCY = $0114; // Vibrato Frequency
CONN_DST_VIB_STARTDELAY = $0115; // Vibrato Start Delay
 
// EG1 Destinations
CONN_DST_EG1_DELAYTIME = $020B; // EG1 Delay Time
CONN_DST_EG1_HOLDTIME = $020C; // EG1 Hold Time
 
(* EG2 Destinations *)
CONN_DST_EG2_DELAYTIME = $030F; (* EG2 Delay Time *)
CONN_DST_EG2_HOLDTIME = $0310; (* EG2 Hold Time *)
 
// EG2 Destinations
CONN_DST_EG2_DELAYTIME = $030F; // EG2 Delay Time
CONN_DST_EG2_HOLDTIME = $0310; // EG2 Hold Time
 
(* Filter Destinations *)
CONN_DST_FILTER_CUTOFF = $0500; (* Filter Cutoff Frequency *)
CONN_DST_FILTER_Q = $0501; (* Filter Resonance *)
 
// Filter Destinations
CONN_DST_FILTER_CUTOFF = $0500; // Filter Cutoff Frequency
CONN_DST_FILTER_Q = $0501; // Filter Resonance
 
(* Transforms *)
CONN_TRN_CONVEX = $0002; (* Convex Transform *)
CONN_TRN_SWITCH = $0003; (* Switch Transform *)
 
// Transforms
CONN_TRN_CONVEX = $0002; // Convex Transform
CONN_TRN_SWITCH = $0003; // Switch Transform
 
(* Conditional chunk operators *)
DLS_CDL_AND = $0001; (* X = X & Y *)
DLS_CDL_OR = $0002; (* X = X | Y *)
DLS_CDL_XOR = $0003; (* X = X ^ Y *)
DLS_CDL_ADD = $0004; (* X = X + Y *)
DLS_CDL_SUBTRACT = $0005; (* X = X - Y *)
DLS_CDL_MULTIPLY = $0006; (* X = X * Y *)
DLS_CDL_DIVIDE = $0007; (* X = X / Y *)
DLS_CDL_LOGICAL_AND = $0008; (* X = X && Y *)
DLS_CDL_LOGICAL_OR = $0009; (* X = X || Y *)
DLS_CDL_LT = $000A; (* X = (X < Y) *)
DLS_CDL_LE = $000B; (* X = (X <= Y) *)
DLS_CDL_GT = $000C; (* X = (X > Y) *)
DLS_CDL_GE = $000D; (* X = (X >= Y) *)
DLS_CDL_EQ = $000E; (* X = (X == Y) *)
DLS_CDL_NOT = $000F; (* X = !X *)
DLS_CDL_CONST = $0010; (* 32-bit constant *)
DLS_CDL_QUERY = $0011; (* 32-bit value returned from query *)
DLS_CDL_QUERYSUPPORTED = $0012; (* Test to see if DLSID Query is supported *)
 
(*
Loop and release
*)
// Conditional chunk operators
DLS_CDL_AND = $0001; // X = X & Y
DLS_CDL_OR = $0002; // X = X | Y
DLS_CDL_XOR = $0003; // X = X ^ Y
DLS_CDL_ADD = $0004; // X = X + Y
DLS_CDL_SUBTRACT = $0005; // X = X - Y
DLS_CDL_MULTIPLY = $0006; // X = X * Y
DLS_CDL_DIVIDE = $0007; // X = X / Y
DLS_CDL_LOGICAL_AND = $0008; // X = X && Y
DLS_CDL_LOGICAL_OR = $0009; // X = X || Y
DLS_CDL_LT = $000A; // X = (X < Y)
DLS_CDL_LE = $000B; // X = (X <= Y)
DLS_CDL_GT = $000C; // X = (X > Y)
DLS_CDL_GE = $000D; // X = (X >= Y)
DLS_CDL_EQ = $000E; // X = (X == Y)
DLS_CDL_NOT = $000F; // X = !X
DLS_CDL_CONST = $0010; // 32-bit constant
DLS_CDL_QUERY = $0011; // 32-bit value returned from query
DLS_CDL_QUERYSUPPORTED = $0012; // Test to see if DLSID Query is supported
 
//Loop and release
 
WLOOP_TYPE_RELEASE = 2;
 
(*
DLSID queries for <cdl-ck>
*)
//DLSID queries for <cdl-ck>
 
DLSID_GMInHardware : TGUID = '{178f2f24-c364-11d1-a760-0000f875ac12}';
DLSID_GSInHardware : TGUID = '{178f2f25-c364-11d1-a760-0000f875ac12}';
DLSID_XGInHardware : TGUID = '{178f2f26-c364-11d1-a760-0000f875ac12}';
DLSID_SupportsDLS1 : TGUID = '{178f2f27-c364-11d1-a760-0000f875ac12}';
DLSID_SupportsDLS2 : TGUID = '{f14599e5-4689-11d2-afa6-00aa0024d8b6}';
DLSID_SampleMemorySize : TGUID = '{178f2f28-c364-11d1-a760-0000f875ac12}';
DLSID_ManufacturersID : TGUID = '{b03e1181-8095-11d2-a1ef-00600833dbd8}';
DLSID_ProductID : TGUID = '{b03e1182-8095-11d2-a1ef-00600833dbd8}';
DLSID_SamplePlaybackRate : TGUID = '{2a91f713-a4bf-11d2-bbdf-00600833dbd8}';
DLSID_GMInHardware : TGUID = '{178F2F24-C364-11D1-A760-0000F875AC12}';
DLSID_GSInHardware : TGUID = '{178F2F25-C364-11D1-A760-0000F875AC12}';
DLSID_XGInHardware : TGUID = '{178F2F26-C364-11D1-A760-0000F875AC12}';
DLSID_SupportsDLS1 : TGUID = '{178F2F27-C364-11D1-A760-0000F875AC12}';
DLSID_SupportsDLS2 : TGUID = '{F14599E5-4689-11D2-AFA6-00AA0024D8B6}';
DLSID_SampleMemorySize : TGUID = '{178F2F28-C364-11D1-A760-0000F875AC12}';
DLSID_ManufacturersID : TGUID = '{B03E1181-8095-11D2-A1EF-00600833DBD8}';
DLSID_ProductID : TGUID = '{B03E1182-8095-11D2-A1EF-00600833DBD8}';
DLSID_SamplePlaybackRate : TGUID = '{2A91F713-A4BF-11D2-BBDF-00600833DBD8}';
 
(************************************************************************
* *
* dmdls.h -- DLS download definitions for DirectMusic API's *
* *
* Copyright (c) 1998, Microsoft Corp. All rights reserved. *
* *
************************************************************************)
//***********************************************************************
// *
// dmdls.h -- DLS download definitions for DirectMusic API's *
// *
// Copyright (c) 1998, Microsoft Corp. All rights reserved. *
// *
//**********************************************************************
 
type
TPCent = LongInt; (* Pitch cents *)
TGCent = LongInt; (* Gain cents *)
TTCent = LongInt; (* Time cents *)
TPercent = LongInt; (* Per.. cent! *)
PCENT = Longint; // Pitch cents
GCENT = Longint; // Gain cents
TCENT = Longint; // Time cents
PERCENT = Longint; // Per.. cent!
 
PReference_Time = ^TReference_Time;
TReference_Time = LongLong;
TReference_Time = LONGLONG;
 
TFourCC = DWORD; (* a four character code *)
Reference_Time = TReference_Time;
LPREFERENCE_TIME = PReference_Time;
 
//function MAKEFOURCC (ch0, ch1, ch2, ch3: Char) : TFourCC;
function MAKEFOURCC(ch0, ch1, ch2, ch3: Char) : DWORD;
 
type
TDMus_DownloadInfor = packed record
dwDLType: DWORD; (* Instrument or Wave *)
dwDLId: DWORD; (* Unique identifier to tag this download. *)
dwNumOffsetTableEntries: DWORD; (* Number of index in the offset address table. *)
cbSize: DWORD; (* Total size of this memory chunk. *)
FOURCC = DWORD; // a four character code
 
TDMUS_DOWNLOADINFO = record
dwDLType : DWORD; // Instrument or Wave
dwDLId : DWORD; // Unique identifier to tag this download.
dwNumOffsetTableEntries : DWORD; // Number of index in the offset address table.
cbSize : DWORD; // Total size of this memory chunk.
end;
DMUS_DOWNLOADINFO = TDMUS_DOWNLOADINFO;
 
const
DMUS_DOWNLOADINFO_INSTRUMENT = 1;
DMUS_DOWNLOADINFO_WAVE = 2;
DMUS_DOWNLOADINFO_INSTRUMENT2 = 3; (* New version for better DLS2 support. *)
 
DMUS_DEFAULT_SIZE_OFFSETTABLE = 1;
 
(* Flags for DMUS_INSTRUMENT's ulFlags member *)
// Flags for DMUS_INSTRUMENT's ulFlags member
 
DMUS_INSTRUMENT_GM_INSTRUMENT = 1 shl 0;
DMUS_INSTRUMENT_GM_INSTRUMENT = 1; // (1 << 0) ????
 
type
TDMus_OffsetTable = packed record
ulOffsetTable : array [0..DMUS_DEFAULT_SIZE_OFFSETTABLE-1] of ULONG;
TDMUS_OFFSETTABLE = record
ulOffsetTable : array [0..DMUS_DEFAULT_SIZE_OFFSETTABLE] of Cardinal;
end;
DMUS_OFFSETTABLE = TDMUS_OFFSETTABLE;
 
TDMus_Instrument = packed record
ulPatch: ULONG;
ulFirstRegionIdx: ULONG;
ulGlobalArtIdx: ULONG; (* If zero the instrument does not have an articulation *)
ulFirstExtCkIdx: ULONG; (* If zero no 3rd party entenstion chunks associated with the instrument *)
ulCopyrightIdx: ULONG; (* If zero no Copyright information associated with the instrument *)
ulFlags: ULONG;
TDMUS_INSTRUMENT = record
ulPatch : Cardinal;
ulFirstRegionIdx : Cardinal;
ulGlobalArtIdx : Cardinal; // If zero the instrument does not have an articulation
ulFirstExtCkIdx : Cardinal; // If zero no 3rd party entenstion chunks associated with the instrument
ulCopyrightIdx : Cardinal; // If zero no Copyright information associated with the instrument
ulFlags : Cardinal;
end;
DMUS_INSTRUMENT = TDMUS_INSTRUMENT;
 
TDMus_Region = packed record
RangeKey: TRGNRange;
RangeVelocity: TRGNRange;
TDMUS_REGION = record
RangeKey : RGNRANGE;
RangeVelocity : RGNRANGE;
fusOptions: Word;
usKeyGroup: Word;
ulRegionArtIdx: ULONG; (* If zero the region does not have an articulation *)
ulNextRegionIdx: ULONG; (* If zero no more regions *)
ulFirstExtCkIdx: ULONG; (* If zero no 3rd party entenstion chunks associated with the region *)
WaveLink: TWaveLink;
WSMP: TWSMPL; (* If WSMP.cSampleLoops > 1 then a WLOOP is included *)
WLOOP: array [0..0] of TWLoop;
ulRegionArtIdx : Cardinal; // If zero the region does not have an articulation
ulNextRegionIdx : Cardinal; // If zero no more regions
ulFirstExtCkIdx : Cardinal; // If zero no 3rd party entenstion chunks associated with the region
WaveLink : WAVELINK;
WSMP : WSMPL; // If WSMP.cSampleLoops > 1 then a WLOOP is included
WLOOP : array[0..0] of WLOOP;
end;
DMUS_REGION = TDMUS_REGION;
 
TDMus_LFOParams = packed record
pcFrequency: TPCent;
tcDelay: TTCent;
gcVolumeScale: TGCent;
pcPitchScale: TPCent;
gcMWToVolume: TGCent;
pcMWToPitch: TPCent;
TDMUS_LFOPARAMS = record
pcFrequency : PCENT;
tcDelay : TCENT;
gcVolumeScale : GCENT;
pcPitchScale : PCENT;
gcMWToVolume : GCENT;
pcMWToPitch : PCENT;
end;
DMUS_LFOPARAMS = TDMUS_LFOPARAMS;
 
TDMus_VEGParams = packed record
tcAttack: TTCent;
tcDecay: TTCent;
ptSustain: TPercent;
tcRelease: TTCent;
tcVel2Attack: TTCent;
tcKey2Decay: TTCent;
TDMUS_VEGPARAMS = record
tcAttack : TCENT;
tcDecay : TCENT;
ptSustain : PERCENT;
tcRelease : TCENT;
tcVel2Attack : TCENT;
tcKey2Decay : TCENT;
end;
DMUS_VEGPARAMS = TDMUS_VEGPARAMS;
 
TDMus_PEGParams = packed record
tcAttack: TTCent;
tcDecay: TTCent;
ptSustain: TPercent;
tcRelease: TTCent;
tcVel2Attack: TTCent;
tcKey2Decay: TTCent;
pcRange: TPCent;
TDMUS_PEGPARAMS = record
tcAttack : TCENT;
tcDecay : TCENT;
ptSustain : PERCENT;
tcRelease : TCENT;
tcVel2Attack : TCENT;
tcKey2Decay : TCENT;
pcRange : PCENT;
end;
DMUS_PEGPARAMS = TDMUS_PEGPARAMS;
 
TDMus_MSCParams = packed record
ptDefaultPan: TPercent;
TDMUS_MSCPARAMS = record
ptDefaultPan : PERCENT;
end;
DMUS_MSCPARAMS = TDMUS_MSCPARAMS;
 
TDMus_ArticParams = packed record
LFO: TDMus_LFOParams;
VolEG: TDMus_VEGParams;
PitchEG: TDMus_PEGParams;
Misc: TDMus_MSCParams;
TDMUS_ARTICPARAMS = record
LFO : DMUS_LFOPARAMS;
VolEG : DMUS_VEGPARAMS;
PitchEG : DMUS_PEGPARAMS;
Misc : DMUS_MSCPARAMS;
end;
DMUS_ARTICPARAMS = TDMUS_ARTICPARAMS;
 
TDMus_Articulation = packed record
ulArt1Idx: ULONG; (* If zero no DLS Level 1 articulation chunk *)
ulFirstExtCkIdx: ULONG; (* If zero no 3rd party entenstion chunks associated with the articulation *)
TDMUS_ARTICULATION = record
ulArt1Idx : Cardinal; // If zero no DLS Level 1 articulation chunk
ulFirstExtCkIdx : Cardinal; // If zero no 3rd party entenstion chunks associated with the articulation
ulNextArtIdx : Cardinal; // Additional articulation chunks
end;
DMUS_ARTICULATION = TDMUS_ARTICULATION;
 
TDMUS_ARTICULATION2 = record
ulArt1Idx : Cardinal; // If zero no DLS Level 1 articulation chunk
ulFirstExtCkIdx : Cardinal; // If zero no 3rd party entenstion chunks associated with the articulation
end;
DMUS_ARTICULATION2 = TDMUS_ARTICULATION2;
 
const
DMUS_MIN_DATA_SIZE = 4;
// The actual number is determined by cbSize of struct _DMUS_EXTENSIONCHUNK
 
(* The actual number is determined by cbSize of struct _DMUS_EXTENSIONCHUNK *)
 
type
DMus_ExtensionChunk = packed record
cbSize: ULONG; (* Size of extension chunk *)
ulNextExtCkIdx: ULONG; (* If zero no more 3rd party entenstion chunks *)
ExtCkID: TFourCC;
byExtCk: array [0..DMUS_MIN_DATA_SIZE-1] of BYTE; (* The actual number that follows is determined by cbSize *)
TDMUS_EXTENSIONCHUNK = record
cbSize : Cardinal; // Size of extension chunk
ulNextExtCkIdx : Cardinal; // If zero no more 3rd party entenstion chunks
ExtCkID : FOURCC;
byExtCk : array[0..DMUS_MIN_DATA_SIZE - 1] of Byte; // The actual number that follows is determined by cbSize
end;
DMUS_EXTENSIONCHUNK = TDMUS_EXTENSIONCHUNK;
 
(* The actual number is determined by cbSize of struct _DMUS_COPYRIGHT *)
// The actual number is determined by cbSize of struct TDMUS_COPYRIGHT
 
TDmus_Copyright = packed record
cbSize: ULONG; (* Size of copyright information *)
byCopyright: array [0..DMUS_MIN_DATA_SIZE-1] of BYTE; (* The actual number that follows is determined by cbSize *)
TDMUS_COPYRIGHT = record
cbSize : Cardinal; // Size of copyright information
byCopyright : array[0..DMUS_MIN_DATA_SIZE - 1] of Byte; // The actual number that follows is determined by cbSize
end;
DMUS_COPYRIGHT = TDMUS_COPYRIGHT;
 
TDMus_WaveData = packed record
cbSize: ULONG;
byData: array [0..DMUS_MIN_DATA_SIZE-1] of BYTE;
TDMUS_WAVEDATA = record
cbSize : Cardinal;
byData : array[0..DMUS_MIN_DATA_SIZE - 1] of Byte;
end;
DMUS_WAVEDATA = TDMUS_WAVEDATA;
 
TDMus_Wave = packed record
ulFirstExtCkIdx: ULONG; (* If zero no 3rd party entenstion chunks associated with the wave *)
ulCopyrightIdx: ULONG; (* If zero no Copyright information associated with the wave *)
ulWaveDataIdx: ULONG; (* Location of actual wave data. *)
/// WaveformatEx: TWaveFormatEx;
TDMUS_WAVE = record
ulFirstExtCkIdx : Cardinal; // If zero no 3rd party entenstion chunks associated with the wave
ulCopyrightIdx : Cardinal; // If zero no Copyright information associated with the wave
ulWaveDataIdx : Cardinal; // Location of actual wave data.
WaveformatEx : TWAVEFORMATEX;
end;
DMUS_WAVE = TDMUS_WAVE;
 
PDMus_NoteRange = ^TDMus_NoteRange;
TDMus_NoteRange = packed record
dwLowNote: DWORD; (* Sets the low note for the range of MIDI note events to which the instrument responds.*)
dwHighNote: DWORD; (* Sets the high note for the range of MIDI note events to which the instrument responds.*)
LPDMUS_NOTERANGE = ^TDMUS_NOTERANGE;
TDMUS_NOTERANGE = record
dwLowNote : DWORD; // Sets the low note for the range of MIDI note events to which the instrument responds.
dwHighNote : DWORD; // Sets the high note for the range of MIDI note events to which the instrument responds.
end;
DMUS_NOTERANGE = TDMUS_NOTERANGE;
 
(************************************************************************
* *
* dmerror.h -- Error code returned by DirectMusic API's *
* *
* Copyright (c) 1998, Microsoft Corp. All rights reserved. *
* *
************************************************************************)
 
const
FACILITY_DIRECTMUSIC = $878; (* Shared with DirectSound *)
DMUS_ERRBASE = $1000; (* Make error codes human readable in hex *)
 
MAKE_DMHRESULTSUCCESS = (0 shl 31) or (FACILITY_DIRECTMUSIC shl 16) or DMUS_ERRBASE;
MAKE_DMHRESULTERROR = (1 shl 31) or (FACILITY_DIRECTMUSIC shl 16) or DMUS_ERRBASE;
 
 
(* DMUS_S_PARTIALLOAD
*
* The object could only load partially. This can happen if some components are
* not registered properly, such as embedded tracks and tools.
*)
DMUS_S_PARTIALLOAD = MAKE_DMHRESULTSUCCESS + $091;
//***********************************************************************
// *
// dmerror.h -- Error code returned by DirectMusic API's *
// *
// Copyright (c) 1998, Microsoft Corp. All rights reserved. *
// *
//**********************************************************************
 
(* DMUS_S_PARTIALDOWNLOAD
*
* This code indicates that a band download was only successful in reaching
* some, but not all, of the referenced ports. Some samples may not play
* correctly.
*)
DMUS_S_PARTIALDOWNLOAD = MAKE_DMHRESULTSUCCESS + $092;
const
FACILITY_DIRECTMUSIC = $878; // Shared with DirectSound
DMUS_ERRBASE = $1000; // Make error codes human readable in hex
 
(* DMUS_S_REQUEUE
*
* Return value from IDirectMusicTool::ProcessPMsg() which indicates to the
* performance that it should cue the PMsg again automatically.
*)
DMUS_S_REQUEUE = MAKE_DMHRESULTSUCCESS + $200;
function MAKE_DMHRESULTSUCCESS(code: Cardinal) : HResult;
function MAKE_DMHRESULTERROR(code: Cardinal) : HResult;
 
(* DMUS_S_FREE
*
* Return value from IDirectMusicTool::ProcessPMsg() which indicates to the
* performance that it should free the PMsg automatically.
*)
DMUS_S_FREE = MAKE_DMHRESULTSUCCESS + $201;
// DMUS_S_PARTIALLOAD
//
// The object could only load partially. This can happen if some components are
// not registered properly, such as embedded tracks and tools.
///
const
DMUS_S_PARTIALLOAD = (0 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $091;// MAKE_DMHRESULTSUCCESS($091);
 
(* DMUS_S_END
*
* Return value from IDirectMusicTrack::Play() which indicates to the
* segment that the track has no more data after mtEnd.
*)
DMUS_S_END = MAKE_DMHRESULTSUCCESS + $202;
// DMUS_S_REQUEUE
//
// Return value from IDirectMusicTool::ProcessPMsg() which indicates to the
// performance that it should cue the PMsg again automatically.
///
DMUS_S_REQUEUE = (0 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $200;//MAKE_DMHRESULTSUCCESS(0x200)
 
(* DMUS_S_STRING_TRUNCATED
*
* Returned string has been truncated to fit the buffer size.
*)
DMUS_S_STRING_TRUNCATED = MAKE_DMHRESULTSUCCESS + $210;
// DMUS_S_FREE
//
// Return value from IDirectMusicTool::ProcessPMsg() which indicates to the
// performance that it should free the PMsg automatically.
///
DMUS_S_FREE = (0 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $201;//MAKE_DMHRESULTSUCCESS(0x201)
 
(* DMUS_S_LAST_TOOL
*
* Returned from IDirectMusicGraph::StampPMsg(), this indicates that the PMsg
* is already stamped with the last tool in the graph. The returned PMsg's
* tool pointer is now NULL.
*)
DMUS_S_LAST_TOOL = MAKE_DMHRESULTSUCCESS + $211;
// DMUS_S_END
//
// Return value from IDirectMusicTrack::Play() which indicates to the
// segment that the track has no more data after mtEnd.
///
DMUS_S_END = (0 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $202;//MAKE_DMHRESULTSUCCESS(0x202)
 
(* DMUS_S_OVER_CHORD
*
* Returned from IDirectMusicPerformance::MusicToMIDI(), this indicates
* that no note has been calculated because the music value has the note
* at a position higher than the top note of the chord. This applies only
* to DMUS_PLAYMODE_NORMALCHORD play mode. This success code indicates
* that the caller should not do anything with the note. It is not meant
* to be played against this chord.
*)
DMUS_S_OVER_CHORD = MAKE_DMHRESULTSUCCESS + $212;
// DMUS_S_STRING_TRUNCATED
//
// Returned string has been truncated to fit the buffer size.
///
DMUS_S_STRING_TRUNCATED = (0 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $210;//MAKE_DMHRESULTSUCCESS(0x210)
 
(* DMUS_S_UP_OCTAVE
*
* Returned from IDirectMusicPerformance::MIDIToMusic(), and
* IDirectMusicPerformance::MusicToMIDI(), this indicates
* that the note conversion generated a note value that is below 0,
* so it has been bumped up one or more octaves to be in the proper
* MIDI range of 0 through 127.
* Note that this is valid for MIDIToMusic() when using play modes
* DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of
* which store MIDI values in wMusicValue. With MusicToMIDI(), it is
* valid for all play modes.
* Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code.
*)
DMUS_S_UP_OCTAVE = MAKE_DMHRESULTSUCCESS + $213;
// DMUS_S_LAST_TOOL
//
// Returned from IDirectMusicGraph::StampPMsg(), this indicates that the PMsg
// is already stamped with the last tool in the graph. The returned PMsg's
// tool pointer is now NULL.
///
DMUS_S_LAST_TOOL = (0 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $211;//MAKE_DMHRESULTSUCCESS(0x211)
 
(* DMUS_S_DOWN_OCTAVE
*
* Returned from IDirectMusicPerformance::MIDIToMusic(), and
* IDirectMusicPerformance::MusicToMIDI(), this indicates
* that the note conversion generated a note value that is above 127,
* so it has been bumped down one or more octaves to be in the proper
* MIDI range of 0 through 127.
* Note that this is valid for MIDIToMusic() when using play modes
* DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of
* which store MIDI values in wMusicValue. With MusicToMIDI(), it is
* valid for all play modes.
* Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code.
*)
DMUS_S_DOWN_OCTAVE = MAKE_DMHRESULTSUCCESS + $214;
// DMUS_S_OVER_CHORD
//
// Returned from IDirectMusicPerformance::MusicToMIDI(), this indicates
// that no note has been calculated because the music value has the note
// at a position higher than the top note of the chord. This applies only
// to DMUS_PLAYMODE_NORMALCHORD play mode. This success code indicates
// that the caller should not do anything with the note. It is not meant
// to be played against this chord.
///
DMUS_S_OVER_CHORD = (0 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $212;//MAKE_DMHRESULTSUCCESS(0x212)
 
(* DMUS_S_NOBUFFERCONTROL
*
* Although the audio output from the port will be routed to the
* same device as the given DirectSound buffer, buffer controls
* such as pan and volume will not affect the output.
*
*)
DMUS_S_NOBUFFERCONTROL = MAKE_DMHRESULTSUCCESS + $215;
// DMUS_S_UP_OCTAVE
//
// Returned from IDirectMusicPerformance::MIDIToMusic(), and
// IDirectMusicPerformance::MusicToMIDI(), this indicates
// that the note conversion generated a note value that is below 0,
// so it has been bumped up one or more octaves to be in the proper
// MIDI range of 0 through 127.
// Note that this is valid for MIDIToMusic() when using play modes
// DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of
// which store MIDI values in wMusicValue. With MusicToMIDI(), it is
// valid for all play modes.
// Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code.
///
DMUS_S_UP_OCTAVE = (0 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $213;//MAKE_DMHRESULTSUCCESS(0x213)
 
(* DMUS_E_DRIVER_FAILED
*
* An unexpected error was returned from a device driver, indicating
* possible failure of the driver or hardware.
*)
DMUS_E_DRIVER_FAILED = MAKE_DMHRESULTERROR + $0101;
// DMUS_S_DOWN_OCTAVE
//
// Returned from IDirectMusicPerformance::MIDIToMusic(), and
// IDirectMusicPerformance::MusicToMIDI(), this indicates
// that the note conversion generated a note value that is above 127,
// so it has been bumped down one or more octaves to be in the proper
// MIDI range of 0 through 127.
// Note that this is valid for MIDIToMusic() when using play modes
// DMUS_PLAYMODE_FIXEDTOCHORD and DMUS_PLAYMODE_FIXEDTOKEY, both of
// which store MIDI values in wMusicValue. With MusicToMIDI(), it is
// valid for all play modes.
// Ofcourse, DMUS_PLAYMODE_FIXED will never return this success code.
///
DMUS_S_DOWN_OCTAVE = (0 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $214;//MAKE_DMHRESULTSUCCESS(0x214)
 
(* DMUS_E_PORTS_OPEN
*
* The requested operation cannot be performed while there are
* instantiated ports in any process in the system.
*)
DMUS_E_PORTS_OPEN = MAKE_DMHRESULTERROR + $0102;
// DMUS_E_DRIVER_FAILED
//
// An unexpected error was returned from a device driver, indicating
// possible failure of the driver or hardware.
///
DMUS_E_DRIVER_FAILED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0101;//MAKE_DMHRESULTERROR(0x0101)
 
(* DMUS_E_DEVICE_IN_USE
*
* The requested device is already in use (possibly by a non-DirectMusic
* client) and cannot be opened again.
*)
DMUS_E_DEVICE_IN_USE = MAKE_DMHRESULTERROR + $0103;
// DMUS_E_PORTS_OPEN
//
// The requested operation cannot be performed while there are
// instantiated ports in any process in the system.
///
DMUS_E_PORTS_OPEN = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0102;//MAKE_DMHRESULTERROR(0x0102)
 
(* DMUS_E_INSUFFICIENTBUFFER
*
* Buffer is not large enough for requested operation.
*)
DMUS_E_INSUFFICIENTBUFFER = MAKE_DMHRESULTERROR + $0104;
// DMUS_E_DEVICE_IN_USE
//
// The requested device is already in use (possibly by a non-DirectMusic
// client) and cannot be opened again.
///
DMUS_E_DEVICE_IN_USE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0103;//MAKE_DMHRESULTERROR(0x0103)
 
(* DMUS_E_BUFFERNOTSET
*
* No buffer was prepared for the download data.
*)
DMUS_E_BUFFERNOTSET = MAKE_DMHRESULTERROR + $0105;
// DMUS_E_INSUFFICIENTBUFFER
//
// Buffer is not large enough for requested operation.
///
DMUS_E_INSUFFICIENTBUFFER = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0104;//MAKE_DMHRESULTERROR(0x0104)
 
(* DMUS_E_BUFFERNOTAVAILABLE
*
* Download failed due to inability to access or create download buffer.
*)
DMUS_E_BUFFERNOTAVAILABLE = MAKE_DMHRESULTERROR + $0106;
// DMUS_E_BUFFERNOTSET
//
// No buffer was prepared for the download data.
///
DMUS_E_BUFFERNOTSET = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0105;//MAKE_DMHRESULTERROR(0x0105)
 
(* DMUS_E_NOTADLSCOL
*
* Error parsing DLS collection. File is corrupt.
*)
DMUS_E_NOTADLSCOL = MAKE_DMHRESULTERROR + $0108;
// DMUS_E_BUFFERNOTAVAILABLE
//
// Download failed due to inability to access or create download buffer.
///
DMUS_E_BUFFERNOTAVAILABLE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0106;//MAKE_DMHRESULTERROR(0x0106)
 
(* DMUS_E_INVALIDOFFSET
*
* Wave chunks in DLS collection file are at incorrect offsets.
*)
DMUS_E_INVALIDOFFSET = MAKE_DMHRESULTERROR + $0109;
// DMUS_E_NOTADLSCOL
//
// Error parsing DLS collection. File is corrupt.
///
DMUS_E_NOTADLSCOL = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0108;//MAKE_DMHRESULTERROR(0x0108)
 
(* DMUS_E_ALREADY_LOADED
*
* Second attempt to load a DLS collection that is currently open.
*)
DMUS_E_ALREADY_LOADED = MAKE_DMHRESULTERROR + $0111;
// DMUS_E_INVALIDOFFSET
//
// Wave chunks in DLS collection file are at incorrect offsets.
///
DMUS_E_INVALIDOFFSET = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0109;//MAKE_DMHRESULTERROR(0x0109)
 
(* DMUS_E_INVALIDPOS
*
* Error reading wave data from DLS collection. Indicates bad file.
*)
DMUS_E_INVALIDPOS = MAKE_DMHRESULTERROR + $0113;
// DMUS_E_ALREADY_LOADED
//
// Second attempt to load a DLS collection that is currently open.
///
DMUS_E_ALREADY_LOADED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0111;//MAKE_DMHRESULTERROR(0x0111)
 
(* DMUS_E_INVALIDPATCH
*
* There is no instrument in the collection that matches patch number.
*)
DMUS_E_INVALIDPATCH = MAKE_DMHRESULTERROR + $0114;
// DMUS_E_INVALIDPOS
//
// Error reading wave data from DLS collection. Indicates bad file.
///
DMUS_E_INVALIDPOS = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0113;//MAKE_DMHRESULTERROR(0x0113)
 
(* DMUS_E_CANNOTSEEK
*
* The IStream* doesn't support Seek().
*)
DMUS_E_CANNOTSEEK = MAKE_DMHRESULTERROR + $0115;
// DMUS_E_INVALIDPATCH
//
// There is no instrument in the collection that matches patch number.
///
DMUS_E_INVALIDPATCH = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0114;//MAKE_DMHRESULTERROR(0x0114)
 
(* DMUS_E_CANNOTWRITE
*
* The IStream* doesn't support Write().
*)
DMUS_E_CANNOTWRITE = MAKE_DMHRESULTERROR + $0116;
// DMUS_E_CANNOTSEEK
//
// The IStream* doesn't support Seek().
///
DMUS_E_CANNOTSEEK = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0115;//MAKE_DMHRESULTERROR(0x0115)
 
(* DMUS_E_CHUNKNOTFOUND
*
* The RIFF parser doesn't contain a required chunk while parsing file.
*)
DMUS_E_CHUNKNOTFOUND = MAKE_DMHRESULTERROR + $0117;
// DMUS_E_CANNOTWRITE
//
// The IStream* doesn't support Write().
///
DMUS_E_CANNOTWRITE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0116;//MAKE_DMHRESULTERROR(0x0116)
 
(* DMUS_E_INVALID_DOWNLOADID
*
* Invalid download id was used in the process of creating a download buffer.
*)
DMUS_E_INVALID_DOWNLOADID = MAKE_DMHRESULTERROR + $0119;
// DMUS_E_CHUNKNOTFOUND
//
// The RIFF parser doesn't contain a required chunk while parsing file.
///
DMUS_E_CHUNKNOTFOUND = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0117;//MAKE_DMHRESULTERROR(0x0117)
 
(* DMUS_E_NOT_DOWNLOADED_TO_PORT
*
* Tried to unload an object that was not downloaded or previously unloaded.
*)
DMUS_E_NOT_DOWNLOADED_TO_PORT = MAKE_DMHRESULTERROR + $0120;
// DMUS_E_INVALID_DOWNLOADID
//
// Invalid download id was used in the process of creating a download buffer.
///
DMUS_E_INVALID_DOWNLOADID = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0119;//MAKE_DMHRESULTERROR(0x0119)
 
(* DMUS_E_ALREADY_DOWNLOADED
*
* Buffer was already downloaded to synth.
*)
DMUS_E_ALREADY_DOWNLOADED = MAKE_DMHRESULTERROR + $0121;
// DMUS_E_NOT_DOWNLOADED_TO_PORT
//
// Tried to unload an object that was not downloaded or previously unloaded.
///
DMUS_E_NOT_DOWNLOADED_TO_PORT = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0120;//MAKE_DMHRESULTERROR(0x0120)
 
(* DMUS_E_UNKNOWN_PROPERTY
*
* The specified property item was not recognized by the target object.
*)
DMUS_E_UNKNOWN_PROPERTY = MAKE_DMHRESULTERROR + $0122;
// DMUS_E_ALREADY_DOWNLOADED
//
// Buffer was already downloaded to synth.
///
DMUS_E_ALREADY_DOWNLOADED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0121;//MAKE_DMHRESULTERROR(0x0121)
 
(* DMUS_E_SET_UNSUPPORTED
*
* The specified property item may not be set on the target object.
*)
DMUS_E_SET_UNSUPPORTED = MAKE_DMHRESULTERROR + $0123;
// DMUS_E_UNKNOWN_PROPERTY
//
// The specified property item was not recognized by the target object.
///
DMUS_E_UNKNOWN_PROPERTY = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0122;//MAKE_DMHRESULTERROR(0x0122)
 
(* DMUS_E_GET_UNSUPPORTED
*
* The specified property item may not be retrieved from the target object.
*)
DMUS_E_GET_UNSUPPORTED = MAKE_DMHRESULTERROR + $0124;
// DMUS_E_SET_UNSUPPORTED
//
// The specified property item may not be set on the target object.
///
DMUS_E_SET_UNSUPPORTED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0123;//MAKE_DMHRESULTERROR(0x0123)
 
(* DMUS_E_NOTMONO
*
* Wave chunk has more than one interleaved channel. DLS format requires MONO.
*)
DMUS_E_NOTMONO = MAKE_DMHRESULTERROR + $0125;
// DMUS_E_GET_UNSUPPORTED
//
// The specified property item may not be retrieved from the target object.
///
DMUS_E_GET_UNSUPPORTED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0124;//MAKE_DMHRESULTERROR(0x0124)
 
(* DMUS_E_BADARTICULATION
*
* Invalid articulation chunk in DLS collection.
*)
DMUS_E_BADARTICULATION = MAKE_DMHRESULTERROR + $0126;
// DMUS_E_NOTMONO
//
// Wave chunk has more than one interleaved channel. DLS format requires MONO.
///
DMUS_E_NOTMONO = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0125;//MAKE_DMHRESULTERROR(0x0125)
 
(* DMUS_E_BADINSTRUMENT
*
* Invalid instrument chunk in DLS collection.
*)
DMUS_E_BADINSTRUMENT = MAKE_DMHRESULTERROR + $0127;
// DMUS_E_BADARTICULATION
//
// Invalid articulation chunk in DLS collection.
///
DMUS_E_BADARTICULATION = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0126;//MAKE_DMHRESULTERROR(0x0126)
 
(* DMUS_E_BADWAVELINK
*
* Wavelink chunk in DLS collection points to invalid wave.
*)
DMUS_E_BADWAVELINK = MAKE_DMHRESULTERROR + $0128;
// DMUS_E_BADINSTRUMENT
//
// Invalid instrument chunk in DLS collection.
///
DMUS_E_BADINSTRUMENT = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0127;//MAKE_DMHRESULTERROR(0x0127)
 
(* DMUS_E_NOARTICULATION
*
* Articulation missing from instrument in DLS collection.
*)
DMUS_E_NOARTICULATION = MAKE_DMHRESULTERROR + $0129;
// DMUS_E_BADWAVELINK
//
// Wavelink chunk in DLS collection points to invalid wave.
///
DMUS_E_BADWAVELINK = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0128;//MAKE_DMHRESULTERROR(0x0128)
 
(* DMUS_E_NOTPCM
*
* Downoaded DLS wave is not in PCM format.
*)
DMUS_E_NOTPCM = MAKE_DMHRESULTERROR + $012A;
// DMUS_E_NOARTICULATION
//
// Articulation missing from instrument in DLS collection.
///
DMUS_E_NOARTICULATION = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0129;//MAKE_DMHRESULTERROR(0x0129)
 
(* DMUS_E_BADWAVE
*
* Bad wave chunk in DLS collection
*)
DMUS_E_BADWAVE = MAKE_DMHRESULTERROR + $012B;
// DMUS_E_NOTPCM
//
// Downoaded DLS wave is not in PCM format.
///
DMUS_E_NOTPCM = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $012A;//MAKE_DMHRESULTERROR(0x012A)
 
(* DMUS_E_BADOFFSETTABLE
*
* Offset Table for download buffer has errors.
*)
DMUS_E_BADOFFSETTABLE = MAKE_DMHRESULTERROR + $012C;
// DMUS_E_BADWAVE
//
// Bad wave chunk in DLS collection
///
DMUS_E_BADWAVE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $012B;//MAKE_DMHRESULTERROR(0x012B)
 
(* DMUS_E_UNKNOWNDOWNLOAD
*
* Attempted to download unknown data type.
*)
DMUS_E_UNKNOWNDOWNLOAD = MAKE_DMHRESULTERROR + $012D;
// DMUS_E_BADOFFSETTABLE
//
// Offset Table for download buffer has errors.
///
DMUS_E_BADOFFSETTABLE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $012C;//MAKE_DMHRESULTERROR(0x012C)
 
(* DMUS_E_NOSYNTHSINK
*
* The operation could not be completed because no sink was connected to
* the synthesizer.
*)
DMUS_E_NOSYNTHSINK = MAKE_DMHRESULTERROR + $012E;
// DMUS_E_UNKNOWNDOWNLOAD
//
// Attempted to download unknown data type.
///
DMUS_E_UNKNOWNDOWNLOAD = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $012D;//MAKE_DMHRESULTERROR(0x012D)
 
(* DMUS_E_ALREADYOPEN
*
* An attempt was made to open the software synthesizer while it was already
* open.
* ASSERT?
*)
DMUS_E_ALREADYOPEN = MAKE_DMHRESULTERROR + $012F;
// DMUS_E_NOSYNTHSINK
//
// The operation could not be completed because no sink was connected to
// the synthesizer.
///
DMUS_E_NOSYNTHSINK = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $012E;//MAKE_DMHRESULTERROR(0x012E)
 
(* DMUS_E_ALREADYCLOSE
*
* An attempt was made to close the software synthesizer while it was already
* open.
* ASSERT?
*)
DMUS_E_ALREADYCLOSED = MAKE_DMHRESULTERROR + $0130;
// DMUS_E_ALREADYOPEN
//
// An attempt was made to open the software synthesizer while it was already
// open.
// ASSERT?
///
DMUS_E_ALREADYOPEN = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $012F;//MAKE_DMHRESULTERROR(0x012F)
 
(* DMUS_E_SYNTHNOTCONFIGURED
*
* The operation could not be completed because the software synth has not
* yet been fully configured.
* ASSERT?
*)
DMUS_E_SYNTHNOTCONFIGURED = MAKE_DMHRESULTERROR + $0131;
// DMUS_E_ALREADYCLOSE
//
// An attempt was made to close the software synthesizer while it was already
// open.
// ASSERT?
///
DMUS_E_ALREADYCLOSED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0130;//MAKE_DMHRESULTERROR(0x0130)
 
(* DMUS_E_SYNTHACTIVE
*
* The operation cannot be carried out while the synthesizer is active.
*)
DMUS_E_SYNTHACTIVE = MAKE_DMHRESULTERROR + $0132;
// DMUS_E_SYNTHNOTCONFIGURED
//
// The operation could not be completed because the software synth has not
// yet been fully configured.
// ASSERT?
///
DMUS_E_SYNTHNOTCONFIGURED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0131;//MAKE_DMHRESULTERROR(0x0131)
 
(* DMUS_E_CANNOTREAD
*
* An error occurred while attempting to read from the IStream* object.
*)
DMUS_E_CANNOTREAD = MAKE_DMHRESULTERROR + $0133;
// DMUS_E_SYNTHACTIVE
//
// The operation cannot be carried out while the synthesizer is active.
///
DMUS_E_SYNTHACTIVE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0132;//MAKE_DMHRESULTERROR(0x0132)
 
(* DMUS_E_DMUSIC_RELEASED
*
* The operation cannot be performed because the final instance of the
* DirectMusic object was released. Ports cannot be used after final
* release of the DirectMusic object.
*)
DMUS_E_DMUSIC_RELEASED = MAKE_DMHRESULTERROR + $0134;
// DMUS_E_CANNOTREAD
//
// An error occurred while attempting to read from the IStream* object.
///
DMUS_E_CANNOTREAD = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0133;//MAKE_DMHRESULTERROR(0x0133)
 
(* DMUS_E_BUFFER_EMPTY
*
* There was no data in the referenced buffer.
*)
DMUS_E_BUFFER_EMPTY = MAKE_DMHRESULTERROR + $0135;
// DMUS_E_DMUSIC_RELEASED
//
// The operation cannot be performed because the final instance of the
// DirectMusic object was released. Ports cannot be used after final
// release of the DirectMusic object.
///
DMUS_E_DMUSIC_RELEASED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0134;//MAKE_DMHRESULTERROR(0x0134)
 
(* DMUS_E_BUFFER_FULL
*
* There is insufficient space to insert the given event into the buffer.
*)
DMUS_E_BUFFER_FULL = MAKE_DMHRESULTERROR + $0136;
// DMUS_E_BUFFER_EMPTY
//
// There was no data in the referenced buffer.
///
DMUS_E_BUFFER_EMPTY = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0135;//MAKE_DMHRESULTERROR(0x0135)
 
(* DMUS_E_PORT_NOT_CAPTURE
*
* The given operation could not be carried out because the port is a
* capture port.
*)
DMUS_E_PORT_NOT_CAPTURE = MAKE_DMHRESULTERROR + $0137;
// DMUS_E_BUFFER_FULL
//
// There is insufficient space to insert the given event into the buffer.
///
DMUS_E_BUFFER_FULL = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0136;//MAKE_DMHRESULTERROR(0x0136)
 
(* DMUS_E_PORT_NOT_RENDER
*
* The given operation could not be carried out because the port is a
* render port.
*)
DMUS_E_PORT_NOT_RENDER = MAKE_DMHRESULTERROR + $0138;
// DMUS_E_PORT_NOT_CAPTURE
//
// The given operation could not be carried out because the port is a
// capture port.
///
DMUS_E_PORT_NOT_CAPTURE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0137;//MAKE_DMHRESULTERROR(0x0137)
 
(* DMUS_E_DSOUND_NOT_SET
*
* The port could not be created because no DirectSound has been specified.
* Specify a DirectSound interface via the IDirectMusic::SetDirectSound
* method; pass NULL to have DirectMusic manage usage of DirectSound.
*)
DMUS_E_DSOUND_NOT_SET = MAKE_DMHRESULTERROR + $0139;
// DMUS_E_PORT_NOT_RENDER
//
// The given operation could not be carried out because the port is a
// render port.
///
DMUS_E_PORT_NOT_RENDER = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0138;//MAKE_DMHRESULTERROR(0x0138)
 
(* DMUS_E_ALREADY_ACTIVATED
*
* The operation cannot be carried out while the port is active.
*)
DMUS_E_ALREADY_ACTIVATED = MAKE_DMHRESULTERROR + $013A;
// DMUS_E_DSOUND_NOT_SET
//
// The port could not be created because no DirectSound has been specified.
// Specify a DirectSound interface via the IDirectMusic::SetDirectSound
// method; pass NULL to have DirectMusic manage usage of DirectSound.
///
DMUS_E_DSOUND_NOT_SET = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0139;//MAKE_DMHRESULTERROR(0x0139)
 
(* DMUS_E_INVALIDBUFFER
*
* Invalid DirectSound buffer was handed to port.
*)
DMUS_E_INVALIDBUFFER = MAKE_DMHRESULTERROR + $013B;
// DMUS_E_ALREADY_ACTIVATED
//
// The operation cannot be carried out while the port is active.
///
DMUS_E_ALREADY_ACTIVATED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $013A;//MAKE_DMHRESULTERROR(0x013A)
 
(* DMUS_E_WAVEFORMATNOTSUPPORTED
*
* Invalid buffer format was handed to the synth sink.
*)
DMUS_E_WAVEFORMATNOTSUPPORTED = MAKE_DMHRESULTERROR + $013C;
// DMUS_E_INVALIDBUFFER
//
// Invalid DirectSound buffer was handed to port.
///
DMUS_E_INVALIDBUFFER = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $013B;//MAKE_DMHRESULTERROR(0x013B)
 
(* DMUS_E_SYNTHINACTIVE
*
* The operation cannot be carried out while the synthesizer is inactive.
*)
DMUS_E_SYNTHINACTIVE = MAKE_DMHRESULTERROR + $013D;
// DMUS_E_WAVEFORMATNOTSUPPORTED
//
// Invalid buffer format was handed to the synth sink.
///
DMUS_E_WAVEFORMATNOTSUPPORTED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $013C;//MAKE_DMHRESULTERROR(0x013C)
 
(* DMUS_E_DSOUND_ALREADY_SET
*
* IDirectMusic::SetDirectSound has already been called. It may not be
* changed while in use.
*)
DMUS_E_DSOUND_ALREADY_SET = MAKE_DMHRESULTERROR + $013E;
// DMUS_E_SYNTHINACTIVE
//
// The operation cannot be carried out while the synthesizer is inactive.
///
DMUS_E_SYNTHINACTIVE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $013D;//MAKE_DMHRESULTERROR(0x013D)
 
(* DMUS_E_INVALID_EVENT
*
* The given event is invalid (either it is not a valid MIDI message
* or it makes use of running status). The event cannot be packed
* into the buffer.
*)
DMUS_E_INVALID_EVENT = MAKE_DMHRESULTERROR + $013F;
// DMUS_E_DSOUND_ALREADY_SET
//
// IDirectMusic::SetDirectSound has already been called. It may not be
// changed while in use.
///
DMUS_E_DSOUND_ALREADY_SET = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $013E;//MAKE_DMHRESULTERROR(0x013E)
 
(* DMUS_E_UNSUPPORTED_STREAM
*
* The IStream* object does not contain data supported by the loading object.
*)
DMUS_E_UNSUPPORTED_STREAM = MAKE_DMHRESULTERROR + $0150;
// DMUS_E_INVALID_EVENT
//
// The given event is invalid (either it is not a valid MIDI message
// or it makes use of running status). The event cannot be packed
// into the buffer.
///
DMUS_E_INVALID_EVENT = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $013F;//MAKE_DMHRESULTERROR(0x013F)
 
(* DMUS_E_ALREADY_INITED
*
* The object has already been initialized.
*)
DMUS_E_ALREADY_INITED = MAKE_DMHRESULTERROR + $0151;
// DMUS_E_UNSUPPORTED_STREAM
//
// The IStream* object does not contain data supported by the loading object.
///
DMUS_E_UNSUPPORTED_STREAM = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0150;//MAKE_DMHRESULTERROR(0x0150)
 
(* DMUS_E_INVALID_BAND
*
* The file does not contain a valid band.
*)
DMUS_E_INVALID_BAND = MAKE_DMHRESULTERROR + $0152;
// DMUS_E_ALREADY_INITED
//
// The object has already been initialized.
///
DMUS_E_ALREADY_INITED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0151;//MAKE_DMHRESULTERROR(0x0151)
 
(* DMUS_E_TRACK_HDR_NOT_FIRST_CK
*
* The IStream* object's data does not have a track header as the first chunk,
* and therefore can not be read by the segment object.
*)
DMUS_E_TRACK_HDR_NOT_FIRST_CK = MAKE_DMHRESULTERROR + $0155;
// DMUS_E_INVALID_BAND
//
// The file does not contain a valid band.
///
DMUS_E_INVALID_BAND = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0152;//MAKE_DMHRESULTERROR(0x0152)
 
(* DMUS_E_TOOL_HDR_NOT_FIRST_CK
*
* The IStream* object's data does not have a tool header as the first chunk,
* and therefore can not be read by the graph object.
*)
DMUS_E_TOOL_HDR_NOT_FIRST_CK = MAKE_DMHRESULTERROR + $0156;
// DMUS_E_TRACK_HDR_NOT_FIRST_CK
//
// The IStream* object's data does not have a track header as the first chunk,
// and therefore can not be read by the segment object.
///
DMUS_E_TRACK_HDR_NOT_FIRST_CK = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0155;//MAKE_DMHRESULTERROR(0x0155)
 
(* DMUS_E_INVALID_TRACK_HDR
*
* The IStream* object's data contains an invalid track header (ckid is 0 and
* fccType is NULL,) and therefore can not be read by the segment object.
*)
DMUS_E_INVALID_TRACK_HDR = MAKE_DMHRESULTERROR + $0157;
// DMUS_E_TOOL_HDR_NOT_FIRST_CK
//
// The IStream* object's data does not have a tool header as the first chunk,
// and therefore can not be read by the graph object.
///
DMUS_E_TOOL_HDR_NOT_FIRST_CK = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0156;//MAKE_DMHRESULTERROR(0x0156)
 
(* DMUS_E_INVALID_TOOL_HDR
*
* The IStream* object's data contains an invalid tool header (ckid is 0 and
* fccType is NULL,) and therefore can not be read by the graph object.
*)
DMUS_E_INVALID_TOOL_HDR = MAKE_DMHRESULTERROR + $0158;
// DMUS_E_INVALID_TRACK_HDR
//
// The IStream* object's data contains an invalid track header (ckid is 0 and
// fccType is NULL,) and therefore can not be read by the segment object.
///
DMUS_E_INVALID_TRACK_HDR = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0157;//MAKE_DMHRESULTERROR(0x0157)
 
(* DMUS_E_ALL_TOOLS_FAILED
*
* The graph object was unable to load all tools from the IStream* object data.
* This may be due to errors in the stream, or the tools being incorrectly
* registered on the client.
*)
DMUS_E_ALL_TOOLS_FAILED = MAKE_DMHRESULTERROR + $0159;
// DMUS_E_INVALID_TOOL_HDR
//
// The IStream* object's data contains an invalid tool header (ckid is 0 and
// fccType is NULL,) and therefore can not be read by the graph object.
///
DMUS_E_INVALID_TOOL_HDR = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0158;//MAKE_DMHRESULTERROR(0x0158)
 
(* DMUS_E_ALL_TRACKS_FAILED
*
* The segment object was unable to load all tracks from the IStream* object data.
* This may be due to errors in the stream, or the tracks being incorrectly
* registered on the client.
*)
DMUS_E_ALL_TRACKS_FAILED = MAKE_DMHRESULTERROR + $0160;
// DMUS_E_ALL_TOOLS_FAILED
//
// The graph object was unable to load all tools from the IStream* object data.
// This may be due to errors in the stream, or the tools being incorrectly
// registered on the client.
///
DMUS_E_ALL_TOOLS_FAILED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0159;//MAKE_DMHRESULTERROR(0x0159)
 
(* DMUS_E_NOT_FOUND
*
* The requested item was not contained by the object.
*)
DMUS_E_NOT_FOUND = MAKE_DMHRESULTERROR + $0161;
// DMUS_E_ALL_TRACKS_FAILED
//
// The segment object was unable to load all tracks from the IStream* object data.
// This may be due to errors in the stream, or the tracks being incorrectly
// registered on the client.
///
DMUS_E_ALL_TRACKS_FAILED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0160;//MAKE_DMHRESULTERROR(0x0160)
 
(* DMUS_E_NOT_INIT
*
* A required object is not initialized or failed to initialize.
*)
DMUS_E_NOT_INIT = MAKE_DMHRESULTERROR + $0162;
// DMUS_E_NOT_FOUND
//
// The requested item was not contained by the object.
///
DMUS_E_NOT_FOUND = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0161;//MAKE_DMHRESULTERROR(0x0161)
 
(* DMUS_E_TYPE_DISABLED
*
* The requested parameter type is currently disabled. Parameter types may
* be enabled and disabled by certain calls to SetParam().
*)
DMUS_E_TYPE_DISABLED = MAKE_DMHRESULTERROR + $0163;
// DMUS_E_NOT_INIT
//
// A required object is not initialized or failed to initialize.
///
DMUS_E_NOT_INIT = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0162;//MAKE_DMHRESULTERROR(0x0162)
 
(* DMUS_E_TYPE_UNSUPPORTED
*
* The requested parameter type is not supported on the object.
*)
DMUS_E_TYPE_UNSUPPORTED = MAKE_DMHRESULTERROR + $0164;
// DMUS_E_TYPE_DISABLED
//
// The requested parameter type is currently disabled. Parameter types may
// be enabled and disabled by certain calls to SetParam().
///
DMUS_E_TYPE_DISABLED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0163;//MAKE_DMHRESULTERROR(0x0163)
 
(* DMUS_E_TIME_PAST
*
* The time is in the past, and the operation can not succeed.
*)
DMUS_E_TIME_PAST = MAKE_DMHRESULTERROR + $0165;
// DMUS_E_TYPE_UNSUPPORTED
//
// The requested parameter type is not supported on the object.
///
DMUS_E_TYPE_UNSUPPORTED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0164;//MAKE_DMHRESULTERROR(0x0164)
 
(* DMUS_E_TRACK_NOT_FOUND
*
* The requested track is not contained by the segment.
*)
DMUS_E_TRACK_NOT_FOUND = MAKE_DMHRESULTERROR + $0166;
// DMUS_E_TIME_PAST
//
// The time is in the past, and the operation can not succeed.
///
DMUS_E_TIME_PAST = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0165;//MAKE_DMHRESULTERROR(0x0165)
 
(* DMUS_E_NO_MASTER_CLOCK
*
* There is no master clock in the performance. Be sure to call
* IDirectMusicPerformance::Init().
*)
DMUS_E_NO_MASTER_CLOCK = MAKE_DMHRESULTERROR + $0170;
// DMUS_E_TRACK_NOT_FOUND
//
// The requested track is not contained by the segment.
///
DMUS_E_TRACK_NOT_FOUND = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0166;//MAKE_DMHRESULTERROR(0x0166)
 
(* DMUS_E_LOADER_NOCLASSID
*
* The class id field is required and missing in the DMUS_OBJECTDESC.
*)
DMUS_E_LOADER_NOCLASSID = MAKE_DMHRESULTERROR + $0180;
// DMUS_E_NO_MASTER_CLOCK
//
// There is no master clock in the performance. Be sure to call
// IDirectMusicPerformance::Init().
///
DMUS_E_NO_MASTER_CLOCK = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0170;//MAKE_DMHRESULTERROR(0x0170)
 
(* DMUS_E_LOADER_BADPATH
*
* The requested file path is invalid.
*)
DMUS_E_LOADER_BADPATH = MAKE_DMHRESULTERROR + $0181;
// DMUS_E_LOADER_NOCLASSID
//
// The class id field is required and missing in the DMUS_OBJECTDESC.
///
DMUS_E_LOADER_NOCLASSID = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0180;//MAKE_DMHRESULTERROR(0x0180)
 
(* DMUS_E_LOADER_FAILEDOPEN
*
* File open failed - either file doesn't exist or is locked.
*)
DMUS_E_LOADER_FAILEDOPEN = MAKE_DMHRESULTERROR + $0182;
// DMUS_E_LOADER_BADPATH
//
// The requested file path is invalid.
///
DMUS_E_LOADER_BADPATH = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0181;//MAKE_DMHRESULTERROR(0x0181)
 
(* DMUS_E_LOADER_FORMATNOTSUPPORTED
*
* Search data type is not supported.
*)
DMUS_E_LOADER_FORMATNOTSUPPORTED = MAKE_DMHRESULTERROR + $0183;
// DMUS_E_LOADER_FAILEDOPEN
//
// File open failed - either file doesn't exist or is locked.
///
DMUS_E_LOADER_FAILEDOPEN = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0182;//MAKE_DMHRESULTERROR(0x0182)
 
(* DMUS_E_LOADER_FAILEDCREATE
*
* Unable to find or create object.
*)
DMUS_E_LOADER_FAILEDCREATE = MAKE_DMHRESULTERROR + $0184;
// DMUS_E_LOADER_FORMATNOTSUPPORTED
//
// Search data type is not supported.
///
DMUS_E_LOADER_FORMATNOTSUPPORTED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0183;//MAKE_DMHRESULTERROR(0x0183)
 
(* DMUS_E_LOADER_OBJECTNOTFOUND
*
* Object was not found.
*)
DMUS_E_LOADER_OBJECTNOTFOUND = MAKE_DMHRESULTERROR + $0185;
// DMUS_E_LOADER_FAILEDCREATE
//
// Unable to find or create object.
///
DMUS_E_LOADER_FAILEDCREATE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0184;//MAKE_DMHRESULTERROR(0x0184)
 
(* DMUS_E_LOADER_NOFILENAME
*
* The file name is missing from the DMUS_OBJECTDESC.
*)
DMUS_E_LOADER_NOFILENAME = MAKE_DMHRESULTERROR + $0186;
// DMUS_E_LOADER_OBJECTNOTFOUND
//
// Object was not found.
///
DMUS_E_LOADER_OBJECTNOTFOUND = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0185;//MAKE_DMHRESULTERROR(0x0185)
 
(* DMUS_E_INVALIDFILE
*
* The file requested is not a valid file.
*)
DMUS_E_INVALIDFILE = MAKE_DMHRESULTERROR + $0200;
// DMUS_E_LOADER_NOFILENAME
//
// The file name is missing from the DMUS_OBJECTDESC.
///
DMUS_E_LOADER_NOFILENAME = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0186;//MAKE_DMHRESULTERROR(0x0186)
 
(* DMUS_E_ALREADY_EXISTS
*
* The tool is already contained in the graph. Create a new instance.
*)
DMUS_E_ALREADY_EXISTS = MAKE_DMHRESULTERROR + $0201;
// DMUS_E_INVALIDFILE
//
// The file requested is not a valid file.
///
DMUS_E_INVALIDFILE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0200;//MAKE_DMHRESULTERROR(0x0200)
 
(* DMUS_E_OUT_OF_RANGE
*
* Value is out of range, for instance the requested length is longer than
* the segment.
*)
DMUS_E_OUT_OF_RANGE = MAKE_DMHRESULTERROR + $0202;
// DMUS_E_ALREADY_EXISTS
//
// The tool is already contained in the graph. Create a new instance.
///
DMUS_E_ALREADY_EXISTS = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0201;//MAKE_DMHRESULTERROR(0x0201)
 
(* DMUS_E_SEGMENT_INIT_FAILED
*
* Segment initialization failed, most likely due to a critical memory situation.
*)
DMUS_E_SEGMENT_INIT_FAILED = MAKE_DMHRESULTERROR + $0203;
// DMUS_E_OUT_OF_RANGE
//
// Value is out of range, for instance the requested length is longer than
// the segment.
///
DMUS_E_OUT_OF_RANGE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0202;//MAKE_DMHRESULTERROR(0x0202)
 
(* DMUS_E_ALREADY_SENT
*
* The DMUS_PMSG has already been sent to the performance object via
* IDirectMusicPerformance::SendPMsg().
*)
DMUS_E_ALREADY_SENT = MAKE_DMHRESULTERROR + $0204;
// DMUS_E_SEGMENT_INIT_FAILED
//
// Segment initialization failed, most likely due to a critical memory situation.
///
DMUS_E_SEGMENT_INIT_FAILED = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0203;//MAKE_DMHRESULTERROR(0x0203)
 
(* DMUS_E_CANNOT_FREE
*
* The DMUS_PMSG was either not allocated by the performance via
* IDirectMusicPerformance::AllocPMsg(), or it was already freed via
* IDirectMusicPerformance::FreePMsg().
*)
DMUS_E_CANNOT_FREE = MAKE_DMHRESULTERROR + $0205;
// DMUS_E_ALREADY_SENT
//
// The DMUS_PMSG has already been sent to the performance object via
// IDirectMusicPerformance::SendPMsg().
///
DMUS_E_ALREADY_SENT = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0204;//MAKE_DMHRESULTERROR(0x0204)
 
(* DMUS_E_CANNOT_OPEN_PORT
*
* The default system port could not be opened.
*)
DMUS_E_CANNOT_OPEN_PORT = MAKE_DMHRESULTERROR + $0206;
// DMUS_E_CANNOT_FREE
//
// The DMUS_PMSG was either not allocated by the performance via
// IDirectMusicPerformance::AllocPMsg(), or it was already freed via
// IDirectMusicPerformance::FreePMsg().
///
DMUS_E_CANNOT_FREE = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0205;//MAKE_DMHRESULTERROR(0x0205)
 
(* DMUS_E_CONNOT_CONVERT
*
* A call to MIDIToMusic() or MusicToMIDI() resulted in an error because
* the requested conversion could not happen. This usually occurs when the
* provided DMUS_CHORD_KEY structure has an invalid chord or scale pattern.
*)
DMUS_E_CONNOT_CONVERT = MAKE_DMHRESULTERROR + $0207;
// DMUS_E_CANNOT_OPEN_PORT
//
// The default system port could not be opened.
///
DMUS_E_CANNOT_OPEN_PORT = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0206;//MAKE_DMHRESULTERROR(0x0206)
 
(* DMUS_E_DESCEND_CHUNK_FAIL
*
* DMUS_E_DESCEND_CHUNK_FAIL is returned when the end of the file
* was reached before the desired chunk was found.
*)
DMUS_E_DESCEND_CHUNK_FAIL = MAKE_DMHRESULTERROR + $0210;
// DMUS_E_CONNOT_CONVERT
//
// A call to MIDIToMusic() or MusicToMIDI() resulted in an error because
// the requested conversion could not happen. This usually occurs when the
// provided DMUS_CHORD_KEY structure has an invalid chord or scale pattern.
///
DMUS_E_CONNOT_CONVERT = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0207;//MAKE_DMHRESULTERROR(0x0207)
 
// DMUS_E_DESCEND_CHUNK_FAIL
//
// DMUS_E_DESCEND_CHUNK_FAIL is returned when the end of the file
// was reached before the desired chunk was found.
///
DMUS_E_DESCEND_CHUNK_FAIL = (1 shl 31) + (FACILITY_DIRECTMUSIC shl 16) + DMUS_ERRBASE + $0210;//MAKE_DMHRESULTERROR(0x0210)
(************************************************************************
* *
* dmksctrl.h -- Definition of IKsControl *
* *
* Copyright (c) 1998, Microsoft Corp. All rights reserved. *
* *
* *
* This header file contains the definition of IKsControl, which *
* duplicates definitions from ks.h and ksproxy.h. Your code should *
* include ks.h and ksproxy.h directly if you have them (they are *
* provided in the Windows 98 DDK and will be in the Windows NT 5 *
* SDK). *
* *
************************************************************************)
 
(*
* Warning: This will prevent the rest of ks.h from being pulled in if ks.h is
* included after dmksctrl.h. Make sure you do not include both headers in
* the same source file.
*)
//************************************************************************
// *
// dmksctrl.h -- Definition of IKsControl *
// *
// Copyright (c) 1998, Microsoft Corp. All rights reserved. *
// *
// *
// This header file contains the definition of IKsControl, which *
// duplicates definitions from ks.h and ksproxy.h. Your code should *
// include ks.h and ksproxy.h directly if you have them (they are *
// provided in the Windows 98 DDK and will be in the Windows NT 5 *
// SDK). *
// *
//**********************************************************************
 
//
// Warning: This will prevent the rest of ks.h from being pulled in if ks.h is
// included after dmksctrl.h. Make sure you do not include both headers in
// the same source file.
///
type
PKsIdentifier = ^TKsIdentifier;
TKsIdentifier = packed record
case integer of
1 : (
Set_: TGUID;
Id : ULONG;
Flags: ULONG
);
2 : (Alignment: LONGLONG);
TData = record
_Set : TGUID;
Id : Cardinal;
Flags : Cardinal;
end;
 
PKsProperty = ^TKsProperty;
TKsProperty = TKsIdentifier;
TKSIDENTIFIER = record
Data : TData;
Alignment : LONGLONG;
end;
 
PKsMethod = ^TKsMethod;
TKsMethod = TKsIdentifier;
KSIDENTIFIER = TKSIDENTIFIER;
PKSIDENTIFIER = ^KSIDENTIFIER;
 
PKsEvent = ^TKsEvent;
TKsEvent = TKsIdentifier;
TKSPROPERTY = KSIDENTIFIER;
KSPROPERTY = KSIDENTIFIER;
PKSPROPERTY = ^KSIDENTIFIER;
TKSMETHOD = KSIDENTIFIER;
KSMETHOD = KSIDENTIFIER;
PKSMETHOD = ^KSIDENTIFIER;
TKSEVENT = KSIDENTIFIER;
KSEVENT = KSIDENTIFIER;
PKSEVENT = ^KSIDENTIFIER;
 
const
KSMETHOD_TYPE_NONE = $00000000;
19010,33 → 13203,64
type
IKsControl = interface (IUnknown)
['{28F54685-06FD-11D2-B27A-00A0C9223196}']
function KsProperty (const pProperty: TKsProperty; PropertyLength: ULONG;
var PropertyData; DataLength: ULONG; out BytesReturned: ULONG) : HResult; stdcall;
function KsMethod(const Method: TKsMethod; MethodLength: ULONG;
var MethodData; DataLength: ULONG; out BytesReturned: ULONG) : HResult; stdcall;
function KsEvent (const Event: TKsEvent; EventLength: ULONG;
var EventData; DataLength: ULONG; out BytesReturned: ULONG) : HResult; stdcall;
//IKsControl
function KsProperty(const _Property: TKSPROPERTY; PropertyLength: Cardinal; var PropertyData;
DataLength: Cardinal; var BytesReturned: Cardinal) : HResult; stdcall;
function KsMethod(const Method: TKSMETHOD; MethodLength: Cardinal; var PropertyData;
DataLength: Cardinal; var BytesReturned: Cardinal) : HResult; stdcall;
function KsEvent(const Event: TKSEVENT; EventLength: Cardinal; var EventData;
DataLength: Cardinal; var BytesReturned: Cardinal) : HResult; stdcall;
end;
 
const
IID_IKsControl : TGUID = '{28F54685-06FD-11D2-B27A-00A0C9223196}';
 
// These formats are in ksmedia.h
KSDATAFORMAT_SUBTYPE_MIDI : TGUID = '{1D262760-E957-11CF-A5D6-28DB04C10000}';
KSDATAFORMAT_SUBTYPE_DIRECTMUSIC : TGUID = '{1A82F8BC-3F8B-11D2-B774-0060083316C1}';
 
//**************************************************************************
// *
// DMusBuff.h -- This module defines the buffer format for DirectMusic *
// Shared file between user mode and kernel mode components *
// *
// Copyright (c) 1998, Microsoft Corp. All rights reserved. *
// *
//*************************************************************************
 
// Format of DirectMusic events in a buffer
//
// A buffer contains 1 or more events, each with the following header.
// Immediately following the header is the event data. The header+data
// size is rounded to the nearest quadword (8 bytes).
///
// Do not pad at end - that's where the data is
type
IID_IKsControl = IKsControl;
STATIC_IID_IKsControl = IID_IKsControl;
TDMUS_EVENTHEADER = record
cbEvent : DWORD; // Unrounded bytes in event
dwChannelGroup : DWORD; // Channel group of event
rtDelta : REFERENCE_TIME; // Delta from start time of entire buffer
dwFlags : DWORD; // Flags DMUS_EVENT_xxx
end;
DMUS_EVENTHEADER = TDMUS_EVENTHEADER;
LPDMUS_EVENTHEADER = ^TDMUS_EVENTHEADER;
 
 
const
(* These formats are in ksmedia.h
*)
KSDATAFORMAT_SUBTYPE_MIDI : TGUID = '{1D262760-E957-11CF-A5D6-28DB04C10000}';
DMUS_EVENT_STRUCTURED = $00000001; // Unstructured data (SysEx, etc.)
 
KSDATAFORMAT_SUBTYPE_DIRECTMUSIC : TGUID = '{1a82f8bc-3f8b-11d2-b774-0060083316c1}';
// The number of bytes to allocate for an event with 'cb' data bytes.
//
function QWORD_ALIGN(x: LONGLONG) : LONGLONG; //(((x) + 7) & ~7)
function DMUS_EVENT_SIZE(cb: LONGLONG) : LONGLONG; //QWORD_ALIGN(sizeof(DMUS_EVENTHEADER) + cb)
(************************************************************************
* *
* dmusicc.h -- This module defines the DirectMusic core API's *
* *
* Copyright (c) 1998, Microsoft Corp. All rights reserved. *
* *
************************************************************************)
//***********************************************************************
// *
// dmusicc.h -- This module defines the DirectMusic core API's *
// *
// Copyright (c) 1998, Microsoft Corp. All rights reserved. *
// *
//**********************************************************************
 
const
DMUS_MAX_DESCRIPTION = 128;
19043,44 → 13267,44
DMUS_MAX_DRIVER = 128;
 
type
PDMus_BufferDesc = ^TDMus_BufferDesc;
TDMus_BufferDesc = packed record
dwSize,
TDMUS_BUFFERDESC = record
dwSize : DWORD;
dwFlags : DWORD;
guidBufferFormat : TGUID;
cbBuffer : DWORD;
end;
DMUS_BUFFERDESC = TDMUS_BUFFERDESC;
LPDMUS_BUFFERDESC = ^TDMUS_BUFFERDESC;
 
// DMUS_EFFECT_ flags are used in the dwEffectFlags fields of both DMUS_PORTCAPS
// and DMUS_PORTPARAMS.
///
const
(* DMUS_EFFECT_ flags are used in the dwEffectFlags fields of both DMUS_PORTCAPS
* and DMUS_PORTPARAMS.
*)
DMUS_EFFECT_NONE = $00000000;
DMUS_EFFECT_REVERB = $00000001;
DMUS_EFFECT_CHORUS = $00000002;
 
(* For DMUS_PORTCAPS dwClass
*)
DMUS_PC_INPUTCLASS = 0;
DMUS_PC_OUTPUTCLASS = 1;
// For DMUS_PORTCAPS dwClass
//
DMUS_PC_INPUTCLASS = (0);
DMUS_PC_OUTPUTCLASS = (1);
 
(* For DMUS_PORTCAPS dwFlags
*)
DMUS_PC_DLS = $00000001;
DMUS_PC_EXTERNAL = $00000002;
DMUS_PC_SOFTWARESYNTH = $00000004;
DMUS_PC_MEMORYSIZEFIXED = $00000008;
DMUS_PC_GMINHARDWARE = $00000010;
DMUS_PC_GSINHARDWARE = $00000020;
DMUS_PC_XGINHARDWARE = $00000040;
DMUS_PC_DIRECTSOUND = $00000080;
DMUS_PC_SHAREABLE = $00000100;
DMUS_PC_DLS2 = $00000200;
DMUS_PC_SYSTEMMEMORY = $7FFFFFFF;
// For DMUS_PORTCAPS dwFlags
//
DMUS_PC_DLS = ($00000001);
DMUS_PC_EXTERNAL = ($00000002);
DMUS_PC_SOFTWARESYNTH = ($00000004);
DMUS_PC_MEMORYSIZEFIXED = ($00000008);
DMUS_PC_GMINHARDWARE = ($00000010);
DMUS_PC_GSINHARDWARE = ($00000020);
DMUS_PC_XGINHARDWARE = ($00000040);
DMUS_PC_DIRECTSOUND = ($00000080);
DMUS_PC_SHAREABLE = ($00000100);
DMUS_PC_SYSTEMMEMORY = ($7FFFFFFF);
 
type
PDMus_PortCaps = ^TDMus_PortCaps;
TDMus_PortCaps = packed record
 
TDMUS_PORTCAPS = record
dwSize: DWORD;
dwFlags: DWORD;
guidPort: TGUID;
19091,20 → 13315,22
dwMaxVoices: DWORD;
dwMaxAudioChannels: DWORD;
dwEffectFlags: DWORD;
wszDescription: array [0..DMUS_MAX_DESCRIPTION-1] of WideChar;
wszDescription : array[0..DMUS_MAX_DESCRIPTION - 1] of WCHAR;
end;
DMUS_PORTCAPS = TDMUS_PORTCAPS;
LPDMUS_PORTCAPS = ^TDMUS_PORTCAPS;
 
// Values for DMUS_PORTCAPS dwType. This field indicates the underlying
// driver type of the port.
///
const
(* Values for DMUS_PORTCAPS dwType. This field indicates the underlying
* driver type of the port.
*)
DMUS_PORT_WINMM_DRIVER = 0;
DMUS_PORT_USER_MODE_SYNTH = 1;
DMUS_PORT_KERNEL_MODE = 2;
DMUS_PORT_WINMM_DRIVER = (0);
DMUS_PORT_USER_MODE_SYNTH = (1);
DMUS_PORT_KERNEL_MODE = (2);
 
(* These flags (set in dwValidParams) indicate which other members of the *)
(* DMUS_PORTPARAMS are valid. *)
(* *)
// These flags (set in dwValidParams) indicate which other members of the
// DMUS_PORTPARAMS are valid.
//
DMUS_PORTPARAMS_VOICES = $00000001;
DMUS_PORTPARAMS_CHANNELGROUPS = $00000002;
DMUS_PORTPARAMS_AUDIOCHANNELS = $00000004;
19113,8 → 13339,7
DMUS_PORTPARAMS_SHARE = $00000040;
 
type
PDMus_PortParams = ^TDMus_PortParams;
TDMus_PortParams = packed record
TDMUS_PORTPARAMS = record
dwSize: DWORD;
dwValidParams: DWORD;
dwVoices: DWORD;
19124,447 → 13349,476
dwEffectFlags: DWORD;
fShare: BOOL;
end;
DMUS_PORTPARAMS = TDMUS_PORTPARAMS;
LPDMUS_PORTPARAMS = ^TDMUS_PORTPARAMS;
 
PDMus_SynthStats = ^TDMus_SynthStats;
TDMus_SynthStats = packed record
dwSize: DWORD; (* Size in bytes of the structure *)
dwValidStats: DWORD; (* Flags indicating which fields below are valid. *)
dwVoices: DWORD; (* Average number of voices playing. *)
dwTotalCPU: DWORD; (* Total CPU usage as percent * 100. *)
dwCPUPerVoice: DWORD; (* CPU per voice as percent * 100. *)
dwLostNotes: DWORD; (* Number of notes lost in 1 second. *)
dwFreeMemory: DWORD; (* Free memory in bytes *)
lPeakVolume: LongInt; (* Decibel level * 100. *)
TDMUS_SYNTHSTATS = record
dwSize : DWORD; // Size in bytes of the structure
dwValidStats : DWORD; // Flags indicating which fields below are valid.
dwVoices : DWORD; // Average number of voices playing.
dwTotalCPU : DWORD; // Total CPU usage as percent * 100.
dwCPUPerVoice : DWORD; // CPU per voice as percent * 100.
dwLostNotes : DWORD; // Number of notes lost in 1 second.
dwFreeMemory : DWORD; // Free memory in bytes
lPeakVolume : Longint; // Decibel level * 100.
end;
DMUS_SYNTHSTATS = TDMUS_SYNTHSTATS;
LPDMUS_SYNTHSTATS = ^TDMUS_SYNTHSTATS;
 
const
DMUS_SYNTHSTATS_VOICES = 1 shl 0;
DMUS_SYNTHSTATS_TOTAL_CPU = 1 shl 1;
DMUS_SYNTHSTATS_CPU_PER_VOICE = 1 shl 2;
DMUS_SYNTHSTATS_LOST_NOTES = 1 shl 3;
DMUS_SYNTHSTATS_PEAK_VOLUME = 1 shl 4;
DMUS_SYNTHSTATS_FREE_MEMORY = 1 shl 5;
DMUS_SYNTHSTATS_VOICES = 1;
DMUS_SYNTHSTATS_TOTAL_CPU = 2;
DMUS_SYNTHSTATS_CPU_PER_VOICE = 4;
DMUS_SYNTHSTATS_LOST_NOTES = 8;
DMUS_SYNTHSTATS_PEAK_VOLUME = 16;
DMUS_SYNTHSTATS_FREE_MEMORY = 32;
 
DMUS_SYNTHSTATS_SYSTEMMEMORY = DMUS_PC_SYSTEMMEMORY;
 
type
TDMus_Waves_Reverb_Params = packed record
fInGain, (* Input gain in dB (to avoid output overflows) *)
fReverbMix, (* Reverb mix in dB. 0dB means 100% wet reverb (no direct signal)
Negative values gives less wet signal.
The coeficients are calculated so that the overall output level stays
(approximately) constant regardless of the ammount of reverb mix. *)
fReverbTime, (* The reverb decay time, in milliseconds. *)
fHighFreqRTRatio : Single; (* The ratio of the high frequencies to the global reverb time.
Unless very 'splashy-bright' reverbs are wanted, this should be set to
a value < 1.0.
For example if dRevTime==1000ms and dHighFreqRTRatio=0.1 than the
decay time for high frequencies will be 100ms.*)
 
TDMUS_WAVES_REVERB_PARAMS = record
fInGain : Single; // Input gain in dB (to avoid output overflows)
fReverbMix : Single; // Reverb mix in dB. 0dB means 100% wet reverb (no direct signal)
//Negative values gives less wet signal.
//The coeficients are calculated so that the overall output level stays
//(approximately) constant regardless of the ammount of reverb mix.
fReverbTime : Single; // The reverb decay time, in milliseconds.
fHighFreqRTRatio : Single; // The ratio of the high frequencies to the global reverb time.
//Unless very 'splashy-bright' reverbs are wanted, this should be set to
//a value < 1.0.
//For example if dRevTime==1000ms and dHighFreqRTRatio=0.1 than the
//decay time for high frequencies will be 100ms.
end;
DMUS_WAVES_REVERB_PARAMS = TDMUS_WAVES_REVERB_PARAMS;
 
// Note: Default values for Reverb are:
// fInGain = 0.0dB (no change in level)
// fReverbMix = -10.0dB (a reasonable reverb mix)
// fReverbTime = 1000.0ms (one second global reverb time)
// fHighFreqRTRatio = 0.001 (the ratio of the high frequencies to the global reverb time)
///
 
(* Note: Default values for Reverb are:
fInGain = 0.0dB (no change in level)
fReverbMix = -10.0dB (a reasonable reverb mix)
fReverbTime = 1000.0ms (one second global reverb time)
fHighFreqRTRatio = 0.001 (the ratio of the high frequencies to the global reverb time)
*)
DMUS_CLOCKTYPE = (DMUS_CLOCK_SYSTEM, DMUS_CLOCK_WAVE); //DMUS_CLOCK_SYSTEM = 0,
//DMUS_CLOCK_WAVE = 1
 
TDMus_ClockType = (
DMUS_CLOCK_SYSTEM,
DMUS_CLOCK_WAVE
);
 
PDMus_ClockInfo = ^TDMus_ClockInfo;
TDMus_ClockInfo = packed record
dwSize : WORD;
ctType : TDMus_ClockType;
guidClock : TGUID; (* Identifies this time source *)
wszDescription : array [0..DMUS_MAX_DESCRIPTION-1] of WideChar;
TDMUS_CLOCKINFO = record
dwSize : DWORD;
ctType : DMUS_CLOCKTYPE;
guidClock : TGUID; // Identifies this time source
wszDescription : array[0..DMUS_MAX_DESCRIPTION - 1] of WCHAR;
end;
DMUS_CLOCKINFO = TDMUS_CLOCKINFO;
LPDMUS_CLOCKINFO = ^TDMUS_CLOCKINFO;
 
const
DMUS_EVENT_STRUCTURED = $00000001; (* Unstructured data (SysEx, etc.) *)
 
(* Standard values for voice priorities. Numerically higher priorities are higher in priority.
* These priorities are used to set the voice priority for all voices on a channel. They are
* used in the dwPriority parameter of IDirectMusicPort::GetPriority and returned in the
* lpwPriority parameter of pdwPriority.
*
* These priorities are shared with DirectSound.
*)
 
const
DAUD_CRITICAL_VOICE_PRIORITY = $F0000000;
DAUD_HIGH_VOICE_PRIORITY = $C0000000;
DAUD_STANDARD_VOICE_PRIORITY = $80000000;
DAUD_LOW_VOICE_PRIORITY = $40000000;
DAUD_PERSIST_VOICE_PRIORITY = $10000000;
 
(* These are the default priorities assigned if not overridden. By default priorities are
* equal across channel groups (e.g. channel 5 on channel group 1 has the same priority as
* channel 5 on channel group 2;.
*
* In accordance with DLS level 1, channel 10 has the highest priority, followed by 1 through 16
* except for 10.
*)
DAUD_CHAN1_VOICE_PRIORITY_OFFSET = $0000000E;
DAUD_CHAN2_VOICE_PRIORITY_OFFSET = $0000000D;
DAUD_CHAN3_VOICE_PRIORITY_OFFSET = $0000000C;
DAUD_CHAN4_VOICE_PRIORITY_OFFSET = $0000000B;
DAUD_CHAN5_VOICE_PRIORITY_OFFSET = $0000000A;
DAUD_CHAN6_VOICE_PRIORITY_OFFSET = $00000009;
DAUD_CHAN7_VOICE_PRIORITY_OFFSET = $00000008;
DAUD_CHAN8_VOICE_PRIORITY_OFFSET = $00000007;
DAUD_CHAN9_VOICE_PRIORITY_OFFSET = $00000006;
DAUD_CHAN10_VOICE_PRIORITY_OFFSET = $0000000F;
DAUD_CHAN11_VOICE_PRIORITY_OFFSET = $00000005;
DAUD_CHAN12_VOICE_PRIORITY_OFFSET = $00000004;
DAUD_CHAN13_VOICE_PRIORITY_OFFSET = $00000003;
DAUD_CHAN14_VOICE_PRIORITY_OFFSET = $00000002;
DAUD_CHAN15_VOICE_PRIORITY_OFFSET = $00000001;
DAUD_CHAN16_VOICE_PRIORITY_OFFSET = $00000000;
 
 
DAUD_CHAN1_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN1_VOICE_PRIORITY_OFFSET);
DAUD_CHAN2_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN2_VOICE_PRIORITY_OFFSET);
DAUD_CHAN3_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN3_VOICE_PRIORITY_OFFSET);
DAUD_CHAN4_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN4_VOICE_PRIORITY_OFFSET);
DAUD_CHAN5_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN5_VOICE_PRIORITY_OFFSET);
DAUD_CHAN6_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN6_VOICE_PRIORITY_OFFSET);
DAUD_CHAN7_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN7_VOICE_PRIORITY_OFFSET);
DAUD_CHAN8_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN8_VOICE_PRIORITY_OFFSET);
DAUD_CHAN9_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN9_VOICE_PRIORITY_OFFSET);
DAUD_CHAN10_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN10_VOICE_PRIORITY_OFFSET);
DAUD_CHAN11_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN11_VOICE_PRIORITY_OFFSET);
DAUD_CHAN12_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN12_VOICE_PRIORITY_OFFSET);
DAUD_CHAN13_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN13_VOICE_PRIORITY_OFFSET);
DAUD_CHAN14_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN14_VOICE_PRIORITY_OFFSET);
DAUD_CHAN15_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN15_VOICE_PRIORITY_OFFSET);
DAUD_CHAN16_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN16_VOICE_PRIORITY_OFFSET);
 
type
IDirectMusicBuffer = interface;
IDirectMusicPort = interface;
IDirectMusicThru = interface;
IReferenceClock = interface;
PIReferenceClock = IReferenceClock;
 
LPDIRECTMUSICBUFFER = IDirectMusicBuffer;
LPDIRECTMUSICPORT = IDirectMusicPort;
 
IDirectMusic = interface (IUnknown)
['{6536115a-7b2d-11d2-ba18-0000f875ac12}']
function EnumPort (dwIndex: DWORD;
var pPortCaps: TDMus_PortCaps) : HResult; stdcall;
function CreateMusicBuffer (var pBufferDesc: TDMus_BufferDesc;
out ppBuffer: IDirectMusicBuffer;
['{6536115A-7B2D-11D2-BA18-0000F875AC12}']
// IDirectMusic
function EnumPort(dwIndex: DWORD; var pPortCaps: TDMUS_PORTCAPS) : HResult; stdcall;
function CreateMusicBuffer(const pBufferDesc: TDMUS_BUFFERDESC; out ppBuffer: IDirectMusicBuffer;
pUnkOuter: IUnknown) : HResult; stdcall;
function CreatePort (const rclsidPort: TGUID;
const pPortParams: TDMus_PortParams;
out ppPort: IDirectMusicPort;
pUnkOuter: IUnknown) : HResult; stdcall;
function EnumMasterClock (dwIndex: DWORD;
var lpClockInfo: TDMus_ClockInfo) : HResult; stdcall;
function GetMasterClock (pguidClock: PGUID;
ppReferenceClock : PIReferenceClock) : HResult; stdcall;
function CreatePort(const rclsidPort: TGUID; const pPortParams: TDMUS_PORTPARAMS;
out ppPort: IDirectMusicPort; pUnkOuter: IUnknown) : HResult; stdcall;
function EnumMasterClock(dwIndex: DWORD; var lpClockInfo: TDMUS_CLOCKINFO) : HResult; stdcall;
function GetMasterClock(pguidClock: PGUID; out ppReferenceClock: IReferenceClock) : HResult; stdcall;
function SetMasterClock (const rguidClock: TGUID) : HResult; stdcall;
function Activate (fEnable: BOOL) : HResult; stdcall;
function GetDefaultPort (out pguidPort: TGUID) : HResult; stdcall;
function SetDirectSound (pDirectSound: IDirectSound;
hWnd: HWND) : HResult; stdcall;
 
function GetDefaultPort(var pguidPort: TGUID) : HResult; stdcall;
function SetDirectSound(pDirectSound: IDirectSound; hWnd: HWND) : HResult; stdcall;
end;
 
IDirectMusicBuffer = interface (IUnknown)
['{d2ac2878-b39b-11d1-8704-00600893b1bd}']
['{D2AC2878-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicBuffer
function Flush : HResult; stdcall;
function TotalTime (out prtTime: TReference_Time) : HResult; stdcall;
function PackStructured (const rt: TReference_Time;
dwChannelGroup: DWORD;
function TotalTime(var prtTime: TREFERENCE_TIME) : HResult; stdcall;
function PackStructured(rt: TREFERENCE_TIME; dwChannelGroup: DWORD;
dwChannelMessage: DWORD ) : HResult; stdcall;
function PackUnstructured (const rt: TReference_Time;
dwChannelGroup: DWORD;
cb: DWORD;
const lpb) : HResult; stdcall;
function PackUnstructured(rt: TREFERENCE_TIME; dwChannelGroup: DWORD;
cb: DWORD; const lpb) : HResult; stdcall;
function ResetReadPtr : HResult; stdcall;
function GetNextEvent (out prt: TReference_Time;
out pdwChannelGroup: DWORD;
out pdwLength: DWORD;
out ppData: Pointer) : HResult; stdcall;
 
function GetRawBufferPtr (out ppData: Pointer) : HResult; stdcall;
function GetStartTime (out prt: TReference_Time) : HResult; stdcall;
function GetUsedBytes (out pcb: DWORD) : HResult; stdcall;
function GetMaxBytes (out pcb: DWORD) : HResult; stdcall;
function GetBufferFormat (out pGuidFormat: TGUID) : HResult; stdcall;
function SetStartTime (const rt: TReference_Time) : HResult; stdcall;
function GetNextEvent(var prt: TREFERENCE_TIME; var pdwChannelGroup: DWORD;
var pdwLength: DWORD; var ppData: Pointer) : HResult; stdcall;
function GetRawBufferPtr(var ppData: Pointer) : HResult; stdcall;
function GetStartTime(var prt: TREFERENCE_TIME) : HResult; stdcall;
function GetUsedBytes(var pcb: DWORD) : HResult; stdcall;
function GetMaxBytes(var pcb: DWORD) : HResult; stdcall;
function GetBufferFormat(var pGuidFormat: TGUID) : HResult; stdcall;
function SetStartTime(rt: TREFERENCE_TIME) : HResult; stdcall;
function SetUsedBytes (cb: DWORD) : HResult; stdcall;
end;
 
 
(* Format of DirectMusic events in a buffer
*
* A buffer contains 1 or more events, each with the following header.
* Immediately following the header is the event data. The header+data
* size is rounded to the nearest quadword (8 bytes).
*)
 
TDMus_EventHeader = packed record
cbEvent: DWORD; (* Unrounded bytes in event *)
dwChannelGroup: DWORD; (* Channel group of event *)
rtDelta: TReference_Time; (* Delta from start time of entire buffer *)
dwFlags: DWORD; (* Flags DMUS_EVENT_xxx *)
// Format of DirectMusic events in a buffer
//
// A buffer contains 1 or more events, each with the following header.
// Immediately following the header is the event data. The header+data
// size is rounded to the nearest quadword (8 bytes).
///
{TDMUS_EVENTHEADER = record
cbEvent : DWORD; // Unrounded bytes in event
dwChannelGroup : DWORD; // Channel group of event
rtDelta : REFERENCE_TIME; // Delta from start time of entire buffer
dwFlags : DWORD; // Flags DMUS_EVENT_xxx
end;
DMUS_EVENTHEADER = TDMUS_EVENTHEADER;
LPDMUS_EVENTHEADER = ^TDMUS_EVENTHEADER;}
 
IDirectMusicInstrument = interface (IUnknown)
['{d2ac287d-b39b-11d1-8704-00600893b1bd}']
function GetPatch (out pdwPatch: DWORD ) : HResult; stdcall;
['{D2AC287D-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicInstrument
function GetPatch(var pdwPatch: DWORD) : HResult; stdcall;
function SetPatch (dwPatch: DWORD) : HResult; stdcall;
end;
 
 
IDirectMusicDownloadedInstrument = interface (IUnknown)
['{d2ac287e-b39b-11d1-8704-00600893b1bd}']
(* None at this time *)
['{D2AC287E-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicDownloadedInstrument
// None at this time
end;
 
IDirectMusicCollection = interface (IUnknown)
['{d2ac287c-b39b-11d1-8704-00600893b1bd}']
function GetInstrument (dwPatch: DWORD;
out ppInstrument: IDirectMusicInstrument) : HResult; stdcall;
function EnumInstrument (dwIndex: DWORD;
out pdwPatch: DWORD;
pwszName: LPWSTR;
dwNameLen: DWORD) : HResult; stdcall;
['{D2AC287C-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicCollection
function GetInstrument(dwPatch: DWORD; out ppInstrument: IDirectMusicInstrument) : HResult; stdcall;
function EnumInstrument(dwIndex: DWORD; var pdwPatch: DWORD;
pwszName: LPWSTR; dwNameLen: DWORD) : HResult; stdcall;
end;
 
 
IDirectMusicDownload = interface (IUnknown)
['{d2ac287b-b39b-11d1-8704-00600893b1bd}']
function GetBuffer (out ppvBuffer: Pointer;
out pdwSize: DWORD) : HResult; stdcall;
['{D2AC287B-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicDownload
function GetBuffer(var ppvBuffer: Pointer; var pdwSize: DWORD) : HResult; stdcall;
end;
 
IDirectMusicPortDownload = interface (IUnknown)
['{d2ac287a-b39b-11d1-8704-00600893b1bd}']
function GetBuffer (dwDLId: DWORD;
out ppIDMDownload: IDirectMusicDownload) : HResult; stdcall;
function AllocateBuffer (dwSize: DWORD;
out ppIDMDownload: IDirectMusicDownload) : HResult; stdcall;
function GetDLId (out pdwStartDLId: DWORD;
dwCount: DWORD) : HResult; stdcall;
function GetAppend (out pdwAppend: DWORD) : HResult; stdcall;
['{D2AC287A-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicPortDownload
function GetBuffer(dwDLId: DWORD; out ppIDMDownload: IDirectMusicDownload) : HResult; stdcall;
function AllocateBuffer(dwSize: DWORD; out ppIDMDownload: IDirectMusicDownload) : HResult; stdcall;
function GetDLId(var pdwStartDLId; dwCount: DWORD) : HResult; stdcall;
function GetAppend(var pdwAppend: DWORD) : HResult; stdcall;
function Download (pIDMDownload: IDirectMusicDownload) : HResult; stdcall;
function Unload(pIDMDownload: IDirectMusicDownload) : HResult; stdcall;
end;
 
// These are the default priorities assigned if not overridden. By default priorities are
// equal across channel groups (e.g. channel 5 on channel group 1 has the same priority as
// channel 5 on channel group 2).
//
// In accordance with DLS level 1, channel 10 has the highest priority, followed by 1 through 16
// except for 10.
///
 
IDirectMusicPort = interface (IUnknown)
['{08f2d8c9-37c2-11d2-b9f9-0000f875ac12}']
['{08F2D8C9-37C2-11D2-B9F9-0000F875AC12}']
// IDirectMusicPort
//
function PlayBuffer (pBuffer: IDirectMusicBuffer) : HResult; stdcall;
function SetReadNotificationHandle (hEvent: THANDLE) : HResult; stdcall;
function SetReadNotificationHandle(hEvent: THandle) : HResult; stdcall;
function Read (pBuffer: IDirectMusicBuffer) : HResult; stdcall;
function DownloadInstrument (pInstrument: IDirectMusicInstrument;
out ppDownloadedInstrument: IDirectMusicDownloadedInstrument;
pNoteRanges: PDMus_NoteRange;
const pNoteRanges;
dwNumNoteRanges: DWORD) : HResult; stdcall;
function UnloadInstrument (pDownloadedInstrument: IDirectMusicDownloadedInstrument) : HResult; stdcall;
function GetLatencyClock (out ppClock: IReferenceClock) : HResult; stdcall;
function GetRunningStats (var pStats: TDMus_SynthStats) : HResult; stdcall;
function GetRunningStats(var pStats: TDMUS_SYNTHSTATS) : HResult stdcall;
function Compact : HResult; stdcall;
function GetCaps (var pPortCaps: TDMus_PortCaps) : HResult; stdcall;
function GetCaps(var pPortCaps: TDMUS_PORTCAPS) : HResult; stdcall;
function DeviceIoControl (dwIoControlCode: DWORD;
const lpInBuffer;
nInBufferSize: DWORD;
out lpOutBuffer;
var lpOutBuffer;
nOutBufferSize: DWORD;
out lpBytesReturned: DWORD;
var lpBytesReturned: DWORD;
var lpOverlapped: TOVERLAPPED) : HResult; stdcall;
function SetNumChannelGroups (dwChannelGroups: DWORD) : HResult; stdcall;
function GetNumChannelGroups (out pdwChannelGroups: DWORD) : HResult; stdcall;
function GetNumChannelGroups(var pdwChannelGroups: DWORD) : HResult; stdcall;
function Activate (fActive: BOOL) : HResult; stdcall;
function SetChannelPriority (dwChannelGroup, dwChannel,
dwPriority: DWORD) : HResult; stdcall;
function GetChannelPriority (dwChannelGroup, dwChannel: DWORD;
out pdwPriority: DWORD) : HResult; stdcall;
function SetDirectSound (pDirectSound: IDirectSound;
pDirectSoundBuffer: IDirectSoundBuffer) : HResult; stdcall;
function GetFormat (pWaveFormatEx: PWaveFormatEx;
var pdwWaveFormatExSize: DWORD;
out pdwBufferSize: DWORD) : HResult; stdcall;
function SetChannelPriority(dwChannelGroup: DWORD; dwChannel: DWORD; dwPriority: DWORD) : HResult; stdcall;
function GetChannelPriority(dwChannelGroup: DWORD; dwChannel: DWORD; var pdwPriority: DWORD) : HResult; stdcall;
function SetDirectSound(pDirectSound: IDirectSound; pDirectSoundBuffer: IDirectSoundBuffer) : HResult; stdcall;
function GetFormat(var pWaveFormatEx: TWAVEFORMATEX; var pdwWaveFormatExSize: DWORD; var pdwBufferSize: DWORD) : HResult; stdcall;
end;
 
IDirectMusicThru = interface (IUnknown)
['{ced153e7-3606-11d2-b9f9-0000f875ac12}']
function ThruChannel (dwSourceChannelGroup,
dwSourceChannel,
dwDestinationChannelGroup,
['{CED153E7-3606-11D2-B9F9-0000F875AC12}']
// IDirectMusicThru
///
function ThruChannel(dwSourceChannelGroup: DWORD;
dwSourceChannel: DWORD;
dwDestinationChannelGroup: DWORD;
dwDestinationChannel: DWORD;
pDestinationPort: IDirectMusicPort) : HResult; stdcall;
end;
 
 
IReferenceClock = interface (IUnknown)
['{56a86897-0ad4-11ce-b03a-0020af0ba770}']
(* get the time now *)
function GetTime (out pTime: TReference_Time) : HResult; stdcall;
['{56A86897-0AD4-11CE-B03A-0020AF0BA770}']
// IReferenceClock
//
 
(* ask for an async notification that a time has elapsed *)
function AdviseTime (const baseTime, (* base time *)
streamTime: TReference_Time; (* stream offset time *)
hEvent: THANDLE; (* advise via this event *)
var pdwAdviseCookie: DWORD) : HResult; stdcall; (* where your cookie goes *)
// get the time now
function GetTime(var pTime: TREFERENCE_TIME) : HResult; stdcall;
 
(* ask for an async periodic notification that a time has elapsed *)
function AdvisePeriodic (const startTime, (* starting at this time *)
periodTime: TReference_Time; (* time between notifications *)
hSemaphore: THANDLE; (* advise via a semaphore *)
var pdwAdviseCookie: DWORD) : HResult; stdcall; (* where your cookie goes *)
// ask for an async notification that a time has elapsed
function AdviseTime(baseTime: TREFERENCE_TIME; // base time
streamTime: TREFERENCE_TIME; // stream offset time
hEvent: THandle; // advise via this event
var pdwAdviseCookie: DWORD) : HResult; stdcall; // where your cookie goes
 
(* cancel a request for notification *)
// ask for an async periodic notification that a time has elapsed
function AdvisePeriodic(startTime: REFERENCE_TIME; // starting at this time
periodTime: REFERENCE_TIME; // time between notifications
hSemaphore: THandle; // advise via a semaphore
var pdwAdviseCookie: DWORD) : HResult; stdcall; // where your cookie goes
 
// cancel a request for notification
function Unadvise (dwAdviseCookie: DWORD) : HResult; stdcall;
end;
 
type
IID_IDirectMusic = IDirectMusic;
IID_IDirectMusicBuffer = IDirectMusicBuffer;
IID_IDirectMusicPort = IDirectMusicPort;
IID_IDirectMusicThru = IDirectMusicThru;
IID_IDirectMusicPortDownload = IDirectMusicPortDownload;
IID_IDirectMusicDownload = IDirectMusicDownload;
IID_IDirectMusicCollection = IDirectMusicCollection;
IID_IDirectMusicInstrument = IDirectMusicInstrument;
IID_IDirectMusicDownloadedInstrument = IDirectMusicDownloadedInstrument;
IID_IReferenceClock = IReferenceClock;
// Delphi‚̐«ŠiãAéŒ¾‚ðˆÚ“®‚³‚¹‚½‚à‚́BinterfaceAclassŒ^‚ÌforwardéŒ¾‚Í“¯‚¶typeƒ†ƒjƒbƒg“à‚ōĐ錾‚³‚ê‚È‚­‚Ä‚Í‚È‚ç‚È‚¢I
//const
// Format of DirectMusic events in a buffer
//
// A buffer contains 1 or more events, each with the following header.
// Immediately following the header is the event data. The header+data
// size is rounded to the nearest quadword (8 bytes).
///
 
//DMUS_EVENT_STRUCTURED = $00000001; // Unstructured data (SysEx, etc.)
 
// The number of bytes to allocate for an event with 'cb' data bytes.
///
//function QWORD_ALIGN(x: Cardinal) : Cardinal;
//function DMUS_EVENT_SIZE(cb: Cardinal) : Cardinal;
 
// Standard values for voice priorities. Numerically higher priorities are higher in priority.
// These priorities are used to set the voice priority for all voices on a channel. They are
// used in the dwPriority parameter of IDirectMusicPort::GetPriority and returned in the
// lpwPriority parameter of pdwPriority.
//
// These priorities are shared with DirectSound.
///
 
const
CLSID_DirectMusic: TGUID = '{636b9f10-0c7d-11d1-95b2-0020afdc7421}';
DAUD_CRITICAL_VOICE_PRIORITY = $F0000000;
DAUD_HIGH_VOICE_PRIORITY = $C0000000;
DAUD_STANDARD_VOICE_PRIORITY = $80000000;
DAUD_LOW_VOICE_PRIORITY = $40000000;
DAUD_PERSIST_VOICE_PRIORITY = $10000000;
 
CLSID_DirectMusicCollection: TGUID = '{480ff4b0-28b2-11d1-bef7-00c04fbf8fef}';
// These are the default priorities assigned if not overridden. By default priorities are
// equal across channel groups (e.g. channel 5 on channel group 1 has the same priority as
// channel 5 on channel group 2).
//
// In accordance with DLS level 1, channel 10 has the highest priority, followed by 1 through 16
// except for 10.
///
 
DAUD_CHAN1_VOICE_PRIORITY_OFFSET = $0000000E;
DAUD_CHAN2_VOICE_PRIORITY_OFFSET = $0000000D;
DAUD_CHAN3_VOICE_PRIORITY_OFFSET = $0000000C;
DAUD_CHAN4_VOICE_PRIORITY_OFFSET = $0000000B;
DAUD_CHAN5_VOICE_PRIORITY_OFFSET = $0000000A;
DAUD_CHAN6_VOICE_PRIORITY_OFFSET = $00000009;
DAUD_CHAN7_VOICE_PRIORITY_OFFSET = $00000008;
DAUD_CHAN8_VOICE_PRIORITY_OFFSET = $00000007;
DAUD_CHAN9_VOICE_PRIORITY_OFFSET = $00000006;
DAUD_CHAN10_VOICE_PRIORITY_OFFSET = $0000000F;
DAUD_CHAN11_VOICE_PRIORITY_OFFSET = $00000005;
DAUD_CHAN12_VOICE_PRIORITY_OFFSET = $00000004;
DAUD_CHAN13_VOICE_PRIORITY_OFFSET = $00000003;
DAUD_CHAN14_VOICE_PRIORITY_OFFSET = $00000002;
DAUD_CHAN15_VOICE_PRIORITY_OFFSET = $00000001;
DAUD_CHAN16_VOICE_PRIORITY_OFFSET = $00000000;
DAUD_CHAN1_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN1_VOICE_PRIORITY_OFFSET);
DAUD_CHAN2_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN2_VOICE_PRIORITY_OFFSET);
DAUD_CHAN3_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN3_VOICE_PRIORITY_OFFSET);
DAUD_CHAN4_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN4_VOICE_PRIORITY_OFFSET);
DAUD_CHAN5_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN5_VOICE_PRIORITY_OFFSET);
DAUD_CHAN6_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN6_VOICE_PRIORITY_OFFSET);
DAUD_CHAN7_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN7_VOICE_PRIORITY_OFFSET);
DAUD_CHAN8_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN8_VOICE_PRIORITY_OFFSET);
DAUD_CHAN9_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN9_VOICE_PRIORITY_OFFSET);
DAUD_CHAN10_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN10_VOICE_PRIORITY_OFFSET);
DAUD_CHAN11_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN11_VOICE_PRIORITY_OFFSET);
DAUD_CHAN12_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN12_VOICE_PRIORITY_OFFSET);
DAUD_CHAN13_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN13_VOICE_PRIORITY_OFFSET);
DAUD_CHAN14_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN14_VOICE_PRIORITY_OFFSET);
DAUD_CHAN15_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN15_VOICE_PRIORITY_OFFSET);
DAUD_CHAN16_DEF_VOICE_PRIORITY = (DAUD_STANDARD_VOICE_PRIORITY or DAUD_CHAN16_VOICE_PRIORITY_OFFSET);
 
 
//GUID definition
IID_IReferenceClock : TGUID = '{56A86897-0AD4-11CE-B03A-0020AF0BA770}';
 
CLSID_DirectMusic : TGUID = '{636B9F10-0C7D-11D1-95B2-0020AFDC7421}';
CLSID_DirectMusicCollection : TGUID = '{480FF4B0-28B2-11D1-BEF7-00C04FBF8FEF}';
CLSID_DirectMusicSynth: TGUID = '{58C2B4D0-46E7-11D1-89AC-00A0C9054129}';
 
(* Property Query GUID_DMUS_PROP_GM_Hardware - Local GM set, no need to download
* Property Query GUID_DMUS_PROP_GS_Hardware - Local GS set, no need to download
* Property Query GUID_DMUS_PROP_XG_Hardware - Local XG set, no need to download
* Property Query GUID_DMUS_PROP_DLS1 - Support DLS level 1
* Property Query GUID_DMUS_PROP_XG_Capable - Support minimum requirements of XG
* Property Query GUID_DMUS_PROP_GS_Capable - Support minimum requirements of GS
* Property Query GUID_DMUS_PROP_SynthSink_DSOUND - Synthsink talks to DSound
* Property Query GUID_DMUS_PROP_SynthSink_WAVE - Synthsink talks to Wave device
*
* Item 0: Supported
* Returns a DWORD which is non-zero if the feature is supported
*)
GUID_DMUS_PROP_GM_Hardware: TGUID = '{178f2f24-c364-11d1-a760-0000f875ac12}';
GUID_DMUS_PROP_GS_Hardware: TGUID = '{178f2f25-c364-11d1-a760-0000f875ac12}';
GUID_DMUS_PROP_XG_Hardware: TGUID = '{178f2f26-c364-11d1-a760-0000f875ac12}';
GUID_DMUS_PROP_XG_Capable: TGUID = '{6496aba1-61b0-11d2-afa6-00aa0024d8b6}';
GUID_DMUS_PROP_GS_Capable: TGUID = '{6496aba2-61b0-11d2-afa6-00aa0024d8b6}';
GUID_DMUS_PROP_DLS1: TGUID = '{178f2f27-c364-11d1-a760-0000f875ac12}';
GUID_DMUS_PROP_DLS2: TGUID = '{f14599e5-4689-11d2-afa6-00aa0024d8b6}';
GUID_DMUS_PROP_INSTRUMENT2: TGUID = '{865fd372-9f67-11d2-872a-00600893b1bd}';
GUID_DMUS_PROP_SynthSink_DSOUND: TGUID = '{0aa97844-c877-11d1-870c-00600893b1bd}';
GUID_DMUS_PROP_SynthSink_WAVE: TGUID = '{0aa97845-c877-11d1-870c-00600893b1bd}';
GUID_DMUS_PROP_SampleMemorySize: TGUID = '{178f2f28-c364-11d1-a760-0000f875ac12}';
GUID_DMUS_PROP_SamplePlaybackRate: TGUID = '{2a91f713-a4bf-11d2-bbdf-00600833dbd8}';
IID_IDirectMusic : TGUID = '{6536115A-7B2D-11D2-BA18-0000F875AC12}';
IID_IDirectMusicBuffer : TGUID = '{D2AC2878-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicPort : TGUID = '{08F2D8C9-37C2-11D2-B9F9-0000F875AC12}';
IID_IDirectMusicThru : TGUID = '{CED153E7-3606-11D2-B9F9-0000F875AC12}';
IID_IDirectMusicPortDownload: TGUID = '{D2AC287A-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicDownload : TGUID = '{D2AC287B-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicCollection : TGUID = '{D2AC287C-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicInstrument : TGUID = '{D2AC287D-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicDownloadedInstrument: TGUID = '{D2AC287E-B39B-11D1-8704-00600893B1BD}';
 
(* Property Get/Set GUID_DMUS_PROP_WriteLatency
*
* Item 0: Synth buffer write latency, in milliseconds
* Get/Set SynthSink latency, the average time after the play head that the next buffer gets written.
*)
GUID_DMUS_PROP_WriteLatency: TGUID = '{268a0fa0-60f2-11d2-afa6-00aa0024d8b6}';
// Alternate interface ID for IID_IDirectMusic, available in DX7 release and after.
IID_IDirectMusic2 : TGUID = '{6FC2CAE1-BC78-11D2-AFA6-00AA0024D8B6}';
 
(* Property Get/Set GUID_DMUS_PROP_WritePeriod
*
* Item 0: Synth buffer write period, in milliseconds
* Get/Set SynthSink buffer write period, time span between successive writes.
*)
GUID_DMUS_PROP_WritePeriod: TGUID = '{268a0fa1-60f2-11d2-afa6-00aa0024d8b6}';
// Property Query GUID_DMUS_PROP_GM_Hardware - Local GM set, no need to download
// Property Query GUID_DMUS_PROP_GS_Hardware - Local GS set, no need to download
// Property Query GUID_DMUS_PROP_XG_Hardware - Local XG set, no need to download
// Property Query GUID_DMUS_PROP_DLS1 - Support DLS level 1
// Property Query GUID_DMUS_PROP_XG_Capable - Support minimum requirements of XG
// Property Query GUID_DMUS_PROP_GS_Capable - Support minimum requirements of GS
// Property Query GUID_DMUS_PROP_SynthSink_DSOUND - Synthsink talks to DSound
// Property Query GUID_DMUS_PROP_SynthSink_WAVE - Synthsink talks to Wave device
//
// Item 0: Supported
// Returns a DWORD which is non-zero if the feature is supported
///
GUID_DMUS_PROP_GM_Hardware : TGUID = '{178F2F24-C364-11D1-A760-0000F875AC12}';
GUID_DMUS_PROP_GS_Hardware : TGUID = '{178F2F25-C364-11D1-A760-0000F875AC12}';
GUID_DMUS_PROP_XG_Hardware : TGUID = '{178F2F26-C364-11D1-A760-0000F875AC12}';
GUID_DMUS_PROP_XG_Capable : TGUID = '{6496ABA1-61B0-11D2-AFA6-00AA0024D8B6}';
GUID_DMUS_PROP_GS_Capable : TGUID = '{6496ABA2-61B0-11D2-AFA6-00AA0024D8B6}';
GUID_DMUS_PROP_DLS1 : TGUID = '{178F2F27-C364-11D1-A760-0000F875AC12}';
GUID_DMUS_PROP_SynthSink_DSOUND: TGUID = '{0AA97844-C877-11D1-870C-00600893B1BD}';
GUID_DMUS_PROP_SynthSink_WAVE : TGUID = '{0AA97845-C877-11D1-870C-00600893B1BD}';
 
(* Property Get GUID_DMUS_PROP_MemorySize
*
* Item 0: Memory size
* Returns a DWORD containing the total number of bytes of sample RAM
*)
GUID_DMUS_PROP_MemorySize: TGUID = '{178f2f28-c364-11d1-a760-0000f875ac12}';
// Property Get/Set GUID_DMUS_PROP_WriteLatency
//
// Item 0: Synth buffer write latency, in milliseconds
// Get/Set SynthSink latency, the average time after the play head that the next buffer gets written.
///
GUID_DMUS_PROP_WriteLatency : TGUID = '{268A0FA0-60F2-11D2-AFA6-00AA0024D8B6}';
 
(* Property Set GUID_DMUS_PROP_WavesReverb
*
* Item 0: DMUS_WAVES_REVERB structure
* Sets reverb parameters
*)
GUID_DMUS_PROP_WavesReverb: TGUID = '{04cb5622-32e5-11d2-afa6-00aa0024d8b6}';
// Property Get/Set GUID_DMUS_PROP_WritePeriod
//
// Item 0: Synth buffer write period, in milliseconds
// Get/Set SynthSink buffer write period, time span between successive writes.
///
GUID_DMUS_PROP_WritePeriod : TGUID = '{268A0FA1-60F2-11D2-AFA6-00AA0024D8B6}';
 
(* Property Set GUID_DMUS_PROP_Effects
*
* Item 0: DWORD with effects flags.
* Get/Set effects bits, same as dwEffectFlags in DMUS_PORTPARAMS and DMUS_PORTCAPS:
* DMUS_EFFECT_NONE
* DMUS_EFFECT_REVERB
* DMUS_EFFECT_CHORUS
*)
GUID_DMUS_PROP_Effects: TGUID = '{cda8d611-684a-11d2-871e-00600893b1bd}';
// Property Get GUID_DMUS_PROP_MemorySize
//
// Item 0: Memory size
// Returns a DWORD containing the total number of bytes of sample RAM
///
GUID_DMUS_PROP_MemorySize : TGUID = '{178F2F28-C364-11D1-A760-0000F875AC12}';
 
(* Property Set GUID_DMUS_PROP_LegacyCaps
*
* Item 0: The MIDINCAPS or MIDIOUTCAPS which describes the port's underlying WinMM device. This property is only supported
* by ports which wrap WinMM devices.
*)
// Property Set GUID_DMUS_PROP_WavesReverb
//
// Item 0: DMUS_WAVES_REVERB structure
// Sets reverb parameters
///
GUID_DMUS_PROP_WavesReverb : TGUID = '{04CB5622-32E5-11D2-AFA6-00AA0024D8B6}';
 
GUID_DMUS_PROP_LegacyCaps: TGUID = '{cfa7cdc2-00a1-11d2-aad5-0000f875ac12}';
// Property Set GUID_DMUS_PROP_Effects
//
// Item 0: DWORD with effects flags.
// Get/Set effects bits, same as dwEffectFlags in DMUS_PORTPARAMS and DMUS_PORTCAPS:
// DMUS_EFFECT_NONE
// DMUS_EFFECT_REVERB
// DMUS_EFFECT_CHORUS
///
GUID_DMUS_PROP_Effects : TGUID = '{CDA8D611-684A-11D2-871E-00600893B1BD}';
 
(* Property Set GUID_DMUS_Volume
*
* Item 0: A long which contains an offset, in 1/100 dB, to be added to the final volume
*
*)
GUID_DMUS_PROP_Volume: TGUID = '{fedfae25-e46e-11d1-aace-0000f875ac12}';
// Property Set GUID_DMUS_PROP_LegacyCaps
//
// Item 0: The MIDINCAPS or MIDIOUTCAPS which describes the port's underlying WinMM device. This property is only supported
// by ports which wrap WinMM devices.
///
 
(* Min and Max values for setting volume with GUID_DMUS_PROP_Volume *)
GUID_DMUS_PROP_LegacyCaps : TGUID = '{CFA7CDC2-00A1-11D2-AAD5-0000F875AC12}';
 
DMUS_VOLUME_MAX = 2000; (* +20 dB *)
DMUS_VOLUME_MIN = -20000; (* -200 dB *)
// Property Set GUID_DMUS_Volume
//
// Item 0: A long which contains an offset, in 1/100 dB, to be added to the final volume
//
///
GUID_DMUS_PROP_Volume : TGUID = '{FEDFAE25-E46E-11D1-AACE-0000F875AC12}';
 
(************************************************************************
* *
* dmusici.h -- This module contains the API for the *
* DirectMusic performance layer *
* *
* Copyright (c) 1998, Microsoft Corp. All rights reserved. *
* *
************************************************************************)
 
 
 
 
//***********************************************************************
// *
// dmusici.h -- This module contains the API for the *
// DirectMusic performance layer *
// *
// Copyright (c) 1998, Microsoft Corp. All rights reserved. *
// *
//**********************************************************************
type
TTransition_Type = WORD;
PMusic_Time = ^TMusic_Time;
TMusic_Time = LongInt;
TRANSITION_TYPE = Word;
MUSIC_TIME = Longint;
 
const
DMUS_PPQ = 768; (* parts per quarter note *)
DMUS_PPQ = 768; // parts per quarter note
 
type
TDMus_CommandT_Types = (
DMUS_COMMANDT_GROOVE,
DMUS_COMMANDT_FILL ,
DMUS_COMMANDT_INTRO ,
DMUS_COMMANDT_BREAK ,
DMUS_COMMANDT_END ,
DMUS_COMMANDT_ENDANDINTRO
);
const
DMUS_MAX_NAME = 64; // Maximum object name length.
DMUS_MAX_CATEGORY = 64; // Maximum object category name length.
DMUS_MAX_FILENAME = MAX_PATH;
 
TDMus_ShapeT_Types = (
DMUS_SHAPET_FALLING ,
DMUS_SHAPET_LEVEL ,
DMUS_SHAPET_LOOPABLE,
DMUS_SHAPET_LOUD ,
DMUS_SHAPET_QUIET ,
DMUS_SHAPET_PEAKING ,
DMUS_SHAPET_RANDOM ,
DMUS_SHAPET_RISING ,
DMUS_SHAPET_SONG
);
 
type
TDMus_ComposeF_Flags = DWORD;
 
const
DMUS_COMMANDT_GROOVE = 0;
DMUS_COMMANDT_FILL = 1;
DMUS_COMMANDT_INTRO = 2;
DMUS_COMMANDT_BREAK = 3;
DMUS_COMMANDT_END = 4;
DMUS_COMMANDT_ENDANDINTRO = 5;
{typedef enum enumDMUS_COMMANDT_TYPES
{
DMUS_COMMANDT_GROOVE = 0,
DMUS_COMMANDT_FILL = 1,
DMUS_COMMANDT_INTRO = 2,
DMUS_COMMANDT_BREAK = 3,
DMUS_COMMANDT_END = 4,
DMUS_COMMANDT_ENDANDINTRO = 5
DMUS_COMMANDT_TYPES;}
 
DMUS_SHAPET_FALLING = 0;
DMUS_SHAPET_LEVEL = 1;
DMUS_SHAPET_LOOPABLE = 2;
DMUS_SHAPET_LOUD = 3;
DMUS_SHAPET_QUIET = 4;
DMUS_SHAPET_PEAKING = 5;
DMUS_SHAPET_RANDOM = 6;
DMUS_SHAPET_RISING = 7;
DMUS_SHAPET_SONG = 8;
{typedef enum enumDMUS_SHAPET_TYPES
{
DMUS_SHAPET_FALLING = 0,
DMUS_SHAPET_LEVEL = 1,
DMUS_SHAPET_LOOPABLE = 2,
DMUS_SHAPET_LOUD = 3,
DMUS_SHAPET_QUIET = 4,
DMUS_SHAPET_PEAKING = 5,
DMUS_SHAPET_RANDOM = 6,
DMUS_SHAPET_RISING = 7,
DMUS_SHAPET_SONG = 8
DMUS_SHAPET_TYPES;}
 
DMUS_COMPOSEF_NONE = 0;
DMUS_COMPOSEF_ALIGN = $1;
DMUS_COMPOSEF_OVERLAP = $2;
19575,198 → 13829,643
DMUS_COMPOSEF_AFTERPREPARETIME = $40;
DMUS_COMPOSEF_MODULATE = $1000;
DMUS_COMPOSEF_LONG = $2000;
{typedef enum enumDMUS_COMPOSEF_FLAGS
{
DMUS_COMPOSEF_NONE = 0,
DMUS_COMPOSEF_ALIGN = 0x1,
DMUS_COMPOSEF_OVERLAP = 0x2,
DMUS_COMPOSEF_IMMEDIATE = 0x4,
DMUS_COMPOSEF_GRID = 0x8,
DMUS_COMPOSEF_BEAT = 0x10,
DMUS_COMPOSEF_MEASURE = 0x20,
DMUS_COMPOSEF_AFTERPREPARETIME = 0x40,
DMUS_COMPOSEF_MODULATE = 0x1000,
DMUS_COMPOSEF_LONG = 0x2000
DMUS_COMPOSEF_FLAGS;}
 
const
// DMUS_PMSGF_FLAGS fill the DMUS_PMSG's dwFlags member
DMUS_PMSGF_REFTIME = 1; // if rtTime is valid
DMUS_PMSGF_MUSICTIME = 2; // if mtTime is valid
DMUS_PMSGF_TOOL_IMMEDIATE = 4; // if PMSG should be processed immediately
DMUS_PMSGF_TOOL_QUEUE = 8; // if PMSG should be processed a little early, at Queue time
DMUS_PMSGF_TOOL_ATTIME = 16; // if PMSG should be processed at the time stamp
DMUS_PMSGF_TOOL_FLUSH = 32; // if PMSG is being flushed
// The values of DMUS_TIME_RESOLVE_FLAGS may also be used inside the
// DMUS_PMSG's dwFlags member.
 
type
(* DMUS_PMsgF_FLAGS fill the TDMus_PMsg's dwFlags member *)
TDMus_PMsgF_Flags = DWORD;
TDMUS_PMSGF_FLAGS = Cardinal;
DMUS_PMSGF_FLAGS = TDMUS_PMSGF_FLAGS;
{typedef enum enumDMUS_PMSGF_FLAGS
{
DMUS_PMSGF_REFTIME = 1, /* if rtTime is valid
DMUS_PMSGF_MUSICTIME = 2, /* if mtTime is valid
DMUS_PMSGF_TOOL_IMMEDIATE = 4, /* if PMSG should be processed immediately
DMUS_PMSGF_TOOL_QUEUE = 8, /* if PMSG should be processed a little early, at Queue time
DMUS_PMSGF_TOOL_ATTIME = 16, /* if PMSG should be processed at the time stamp
DMUS_PMSGF_TOOL_FLUSH = 32 /* if PMSG is being flushed
/* The values of DMUS_TIME_RESOLVE_FLAGS may also be used inside the
/* DMUS_PMSG's dwFlags member.
DMUS_PMSGF_FLAGS;}
 
const
DMUS_PMsgF_REFTIME = 1; (* if rtTime is valid *)
DMUS_PMsgF_MUSICTIME = 2; (* if mtTime is valid *)
DMUS_PMsgF_TOOL_IMMEDIATE = 4; (* if PMSG should be processed immediately *)
DMUS_PMsgF_TOOL_QUEUE = 8; (* if PMSG should be processed a little early, at Queue time *)
DMUS_PMsgF_TOOL_ATTIME = 16; (* if PMSG should be processed at the time stamp *)
DMUS_PMsgF_TOOL_FLUSH = 32; (* if PMSG is being flushed *)
(* The values of DMUS_TIME_RESOLVE_FLAGS may also be used inside the *)
(* TDMus_PMsg's dwFlags member. *)
// DMUS_PMSGT_TYPES fill the DMUS_PMSG's dwType member
DMUS_PMSGT_MIDI = 0; // MIDI short message
DMUS_PMSGT_NOTE = 1; // Interactive Music Note
DMUS_PMSGT_SYSEX = 2; // MIDI long message (system exclusive message)
DMUS_PMSGT_NOTIFICATION = 3; // Notification message
DMUS_PMSGT_TEMPO = 4; // Tempo message
DMUS_PMSGT_CURVE = 5; // Control change / pitch bend, etc. curve
DMUS_PMSGT_TIMESIG = 6; // Time signature
DMUS_PMSGT_PATCH = 7; // Patch changes
DMUS_PMSGT_TRANSPOSE = 8; // Transposition messages
DMUS_PMSGT_CHANNEL_PRIORITY = 9; // Channel priority
DMUS_PMSGT_STOP = 10; // Stop message
DMUS_PMSGT_DIRTY = 11; // Tells Tools that cache GetParam() info to refresh
DMUS_PMSGT_USER = 255; // User message
 
type
(* DMUS_PMsgT_TYPES fill the TDMus_PMsg's dwType member *)
TDMus_PMsgT_Types = (
DMUS_PMsgT_MIDI , (* MIDI short message *)
DMUS_PMsgT_NOTE , (* Interactive Music Note *)
DMUS_PMsgT_SYSEX , (* MIDI long message (system exclusive message) *)
DMUS_PMsgT_NOTIFICATION , (* Notification message *)
DMUS_PMsgT_TEMPO , (* Tempo message *)
DMUS_PMsgT_CURVE , (* Control change / pitch bend, etc. curve *)
DMUS_PMsgT_TIMESIG , (* Time signature *)
DMUS_PMsgT_PATCH , (* Patch changes *)
DMUS_PMsgT_TRANSPOSE , (* Transposition messages *)
DMUS_PMsgT_CHANNEL_PRIORITY, (* Channel priority *)
DMUS_PMsgT_STOP , (* Stop message *)
DMUS_PMsgT_DIRTY (* Tells Tools that cache GetParam() info to refresh *)
);
TDMUS_PMSGT_TYPES = Cardinal;
DMUS_PMSGT_TYPES = TDMUS_PMSGT_TYPES;
 
{typedef enum enumDMUS_PMSGT_TYPES
{
DMUS_PMSGT_MIDI = 0, /* MIDI short message
DMUS_PMSGT_NOTE = 1, /* Interactive Music Note
DMUS_PMSGT_SYSEX = 2, /* MIDI long message (system exclusive message)
DMUS_PMSGT_NOTIFICATION = 3, /* Notification message
DMUS_PMSGT_TEMPO = 4, /* Tempo message
DMUS_PMSGT_CURVE = 5, /* Control change / pitch bend, etc. curve
DMUS_PMSGT_TIMESIG = 6, /* Time signature
DMUS_PMSGT_PATCH = 7, /* Patch changes
DMUS_PMSGT_TRANSPOSE = 8, /* Transposition messages
DMUS_PMSGT_CHANNEL_PRIORITY = 9, /* Channel priority
DMUS_PMSGT_STOP = 10, /* Stop message
DMUS_PMSGT_DIRTY = 11, /* Tells Tools that cache GetParam() info to refresh
DMUS_PMSGT_USER = 255 /* User message
DMUS_PMSGT_TYPES;}
 
const
DMUS_PMsgT_USER = TDMus_PMsgT_Types(255); (* User message *)
// DMUS_SEGF_FLAGS correspond to IDirectMusicPerformance::PlaySegment, and other API
DMUS_SEGF_REFTIME = 64; // time parameter is in reference time
DMUS_SEGF_SECONDARY = 128; // secondary segment
DMUS_SEGF_QUEUE = 256; // queue at the end of the primary segment queue (primary only)
DMUS_SEGF_CONTROL = 512; // play as a control track (secondary segments only)
DMUS_SEGF_AFTERPREPARETIME = 1 shl 10; // play after the prepare time (See IDirectMusicPerformance::GetPrepareTime)
DMUS_SEGF_GRID = 1 shl 11; // play on grid boundary
DMUS_SEGF_BEAT = 1 shl 12; // play on beat boundary
DMUS_SEGF_MEASURE = 1 shl 13; // play on measure boundary
DMUS_SEGF_DEFAULT = 1 shl 14; // use segment's default boundary
DMUS_SEGF_NOINVALIDATE = 1 shl 15; // play without invalidating the currently playing segment(s)
 
type
(* DMUS_SEGF_FLAGS correspond to IDirectMusicPerformance::PlaySegment, and other API *)
TDMus_SegF_Flags = DWORD;
TDMUS_SEGF_FLAGS = Cardinal;
DMUS_SEGF_FLAGS = TDMUS_SEGF_FLAGS;
 
{typedef enum enumDMUS_SEGF_FLAGS
{
DMUS_SEGF_REFTIME = 64, /* time parameter is in reference time
DMUS_SEGF_SECONDARY = 128, /* secondary segment
DMUS_SEGF_QUEUE = 256, /* queue at the end of the primary segment queue (primary only)
DMUS_SEGF_CONTROL = 512, /* play as a control track (secondary segments only)
DMUS_SEGF_AFTERPREPARETIME = 1<<10, /* play after the prepare time (See IDirectMusicPerformance::GetPrepareTime)
DMUS_SEGF_GRID = 1<<11, /* play on grid boundary
DMUS_SEGF_BEAT = 1<<12, /* play on beat boundary
DMUS_SEGF_MEASURE = 1<<13, /* play on measure boundary
DMUS_SEGF_DEFAULT = 1<<14, /* use segment's default boundary
DMUS_SEGF_NOINVALIDATE = 1<<15 /* play without invalidating the currently playing segment(s)
DMUS_SEGF_FLAGS;}
 
const
DMUS_SEGF_REFTIME = 64; (* time parameter is in reference time *)
DMUS_SEGF_SECONDARY = 128; (* secondary segment *)
DMUS_SEGF_QUEUE = 256; (* queue at the end of the primary segment queue (primary only) *)
DMUS_SEGF_CONTROL = 512; (* play as a control track (secondary segments only) *)
DMUS_SEGF_AFTERPREPARETIME = 1 shl 10; (* play after the prepare time (See IDirectMusicPerformance::GetPrepareTime) *)
DMUS_SEGF_GRID = 1 shl 11; (* play on grid boundary *)
DMUS_SEGF_BEAT = 1 shl 12; (* play on beat boundary *)
DMUS_SEGF_MEASURE = 1 shl 13; (* play on measure boundary *)
DMUS_SEGF_DEFAULT = 1 shl 14; (* use segment's default boundary *)
DMUS_SEGF_NOINVALIDATE = 1 shl 15; (* play without invalidating the currently playing segment(s) *)
// DMUS_TIME_RESOLVE_FLAGS correspond to IDirectMusicPerformance::GetResolvedTime, and can
// also be used interchangeably with the corresponding DMUS_SEGF_FLAGS, since their values
// are intentionally the same
DMUS_TIME_RESOLVE_AFTERPREPARETIME = 1 shl 10; // resolve to a time after the prepare time
DMUS_TIME_RESOLVE_GRID = 1 shl 11; // resolve to a time on a grid boundary
DMUS_TIME_RESOLVE_BEAT = 1 shl 12; // resolve to a time on a beat boundary
DMUS_TIME_RESOLVE_MEASURE = 1 shl 13; // resolve to a time on a measure boundary
 
(* DMUS_TIME_RESOLVE_FLAGS correspond to IDirectMusicPerformance::GetResolvedTime, and can *)
(* also be used interchangeably with the corresponding DMUS_SEGF_FLAGS, since their values *)
(* are intentionally the same *)
type
TDMus_Time_Resolve_Flags = DWORD;
TDMUS_TIME_RESOLVE_FLAGS = Cardinal;
DMUS_TIME_RESOLVE_FLAGS = TDMUS_TIME_RESOLVE_FLAGS;
 
{typedef enum enumDMUS_TIME_RESOLVE_FLAGS
{
DMUS_TIME_RESOLVE_AFTERPREPARETIME = 1<<10, /* resolve to a time after the prepare time
DMUS_TIME_RESOLVE_GRID = 1<<11, /* resolve to a time on a grid boundary
DMUS_TIME_RESOLVE_BEAT = 1<<12, /* resolve to a time on a beat boundary
DMUS_TIME_RESOLVE_MEASURE = 1<<13 /* resolve to a time on a measure boundary
DMUS_TIME_RESOLVE_FLAGS;}
 
const
DMUS_TIME_RESOLVE_AFTERPREPARETIME = 1 shl 10; (* resolve to a time after the prepare time *)
DMUS_TIME_RESOLVE_GRID = 1 shl 11; (* resolve to a time on a grid boundary *)
DMUS_TIME_RESOLVE_BEAT = 1 shl 12; (* resolve to a time on a beat boundary *)
DMUS_TIME_RESOLVE_MEASURE = 1 shl 13; (* resolve to a time on a measure boundary *)
// The following flags are sent in the IDirectMusicTrack::Play() method
// inside the dwFlags parameter
DMUS_TRACKF_SEEK = 1; // set on a seek
DMUS_TRACKF_LOOP = 2; // set on a loop (repeat)
DMUS_TRACKF_START = 4; // set on first call to Play
DMUS_TRACKF_FLUSH = 8; // set when this call is in response to a flush on the perfomance
DMUS_TRACKF_DIRTY = 16; // set when the track should consider any cached values from a previous call to GetParam to be invalidated
 
(* The following flags are sent in the IDirectMusicTrack::Play() method *)
(* inside the dwFlags parameter *)
type
TDMus_TrackF_Flags = DWORD;
TDMUS_TRACKF_FLAGS = Cardinal;
DMUS_TRACKF_FLAGS = TDMUS_TRACKF_FLAGS;
 
{typedef enum enumDMUS_TRACKF_FLAGS
{
DMUS_TRACKF_SEEK = 1, /* set on a seek
DMUS_TRACKF_LOOP = 2, /* set on a loop (repeat)
DMUS_TRACKF_START = 4, /* set on first call to Play
DMUS_TRACKF_FLUSH = 8, /* set when this call is in response to a flush on the perfomance
DMUS_TRACKF_DIRTY = 16, /* set when the track should consider any cached values from a previous call to GetParam to be invalidated
DMUS_TRACKF_FLAGS;}
 
const
DMUS_TRACKF_SEEK = 1; (* set on a seek *)
DMUS_TRACKF_LOOP = 2; (* set on a loop (repeat) *)
DMUS_TRACKF_START = 4; (* set on first call to Play *)
DMUS_TRACKF_FLUSH = 8; (* set when this call is in response to a flush on the perfomance *)
DMUS_TRACKF_DIRTY = 16; (* set when the track should consider any cached values from a previous call to GetParam to be invalidated *)
 
DMUS_MAXSUBCHORD = 8;
 
type
TDMUS_SUBCHORD = record
dwChordPattern : DWORD; // Notes in the subchord
dwScalePattern : DWORD; // Notes in the scale
dwInversionPoints : DWORD; // Where inversions can occur
dwLevels : DWORD; // Which levels are supported by this subchord
bChordRoot : Byte; // Root of the subchord
bScaleRoot : Byte; // Root of the scale
end;
DMUS_SUBCHORD = TDMUS_SUBCHORD;
 
TDMUS_CHORD_KEY = record
wszName : array[0..15] of WideChar; // Name of the chord
wMeasure : Word; // Measure this falls on
bBeat : Byte; // Beat this falls on
bSubChordCount : Byte; // Number of chords in the list of subchords
SubChordList : array[0..DMUS_MAXSUBCHORD - 1] of TDMUS_SUBCHORD;// List of sub chords
dwScale : DWORD; // Scale underlying the entire chord
bKey : Byte; // Key underlying the entire chord
end;
DMUS_CHORD_KEY = TDMUS_CHORD_KEY;
 
const
//typedef enum enumDMUS_NOTEF_FLAGS
DMUS_NOTEF_NOTEON = 1; // Set if this is a MIDI Note On. Otherwise, it is MIDI Note Off
 
type
TDMUS_NOTEF_FLAGS = Cardinal;
DMUS_NOTEF_FLAGS = TDMUS_NOTEF_FLAGS;
 
// The DMUS_PLAYMODE_FLAGS are used to determine how to convert wMusicValue
// into the appropriate bMidiValue.
///
const
//typedef enum enumDMUS_PLAYMODE_FLAGS
DMUS_PLAYMODE_KEY_ROOT = 1; // Transpose on top of the key root.
DMUS_PLAYMODE_CHORD_ROOT = 2; // Transpose on top of the chord root.
DMUS_PLAYMODE_SCALE_INTERVALS = 4; // Use scale intervals from scale pattern.
DMUS_PLAYMODE_CHORD_INTERVALS = 8; // Use chord intervals from chord pattern.
DMUS_PLAYMODE_NONE = 16; // No mode. Indicates the parent part's mode should be used.
 
type
TDMUS_PLAYMODE_FLAGS = Cardinal;
DMUS_PLAYMODE_FLAGS = TDMUS_PLAYMODE_FLAGS;
 
// The following are playback modes that can be created by combining the DMUS_PLAYMODE_FLAGS
// in various ways:
///
 
// Fixed. wMusicValue holds final MIDI note value. This is used for drums, sound effects, and sequenced
// notes that should not be transposed by the chord or scale.
///
const
DMUS_PLAYMODE_FIXED = 0;
// In fixed to key, the musicvalue is again a fixed MIDI value, but it
// is transposed on top of the key root.
///
DMUS_PLAYMODE_FIXEDTOKEY = DMUS_PLAYMODE_KEY_ROOT;
// In fixed to chord, the musicvalue is also a fixed MIDI value, but it
// is transposed on top of the chord root.
///
DMUS_PLAYMODE_FIXEDTOCHORD = DMUS_PLAYMODE_CHORD_ROOT;
// In Pedalpoint, the key root is used and the notes only track the intervals in
// the scale. The chord root and intervals are completely ignored. This is useful
// for melodic lines that play relative to the key root.
///
DMUS_PLAYMODE_PEDALPOINT = (DMUS_PLAYMODE_KEY_ROOT or DMUS_PLAYMODE_SCALE_INTERVALS);
// In the Melodic mode, the chord root is used but the notes only track the intervals in
// the scale. The key root and chord intervals are completely ignored. This is useful
// for melodic lines that play relative to the chord root.
///
DMUS_PLAYMODE_MELODIC = (DMUS_PLAYMODE_CHORD_ROOT or DMUS_PLAYMODE_SCALE_INTERVALS);
// Normal chord mode is the prevalent playback mode.
// The notes track the intervals in the chord, which is based on the chord root.
// If there is a scale component to the MusicValue, the additional intervals
// are pulled from the scale and added.
// If the chord does not have an interval to match the chord component of
// the MusicValue, the note is silent.
///
DMUS_PLAYMODE_NORMALCHORD = (DMUS_PLAYMODE_CHORD_ROOT or DMUS_PLAYMODE_CHORD_INTERVALS);
// If it is desirable to play a note that is above the top of the chord, the
// always play mode (known as "purpleized" in a former life) finds a position
// for the note by using intervals from the scale. Essentially, this mode is
// a combination of the Normal and Melodic playback modes, where a failure
// in Normal causes a second try in Melodic mode.
///
DMUS_PLAYMODE_ALWAYSPLAY = (DMUS_PLAYMODE_MELODIC or DMUS_PLAYMODE_NORMALCHORD);
 
// Legacy names for modes...
DMUS_PLAYMODE_PURPLEIZED = DMUS_PLAYMODE_ALWAYSPLAY;
DMUS_PLAYMODE_SCALE_ROOT = DMUS_PLAYMODE_KEY_ROOT;
DMUS_PLAYMODE_FIXEDTOSCALE = DMUS_PLAYMODE_FIXEDTOKEY;
 
const
DMUS_TEMPO_MAX = 350;
DMUS_TEMPO_MIN = 10;
 
DMUS_MASTERTEMPO_MAX = 2.0;
DMUS_MASTERTEMPO_MIN = 0.25;
 
const
DMUS_CURVE_RESET = 1; // Set if the curve needs to be reset.
 
type
TDMUS_CURVE_FLAGS = Cardinal;
DMUS_CURVE_FLAGS = TDMUS_CURVE_FLAGS;
{
DMUS_CURVE_RESET = 1, /* Set if the curve needs to be reset.
DMUS_CURVE_FLAGS; }
 
 
const
//DMUS_CURVE_RESET = 1;
 
// Curve shapes
DMUS_CURVES_LINEAR = 0;
DMUS_CURVES_INSTANT = 1;
DMUS_CURVES_EXP = 2;
DMUS_CURVES_LOG = 3;
DMUS_CURVES_SINE = 4;
 
// curve types
DMUS_CURVET_PBCURVE = $03;
DMUS_CURVET_CCCURVE = $04;
DMUS_CURVET_MATCURVE = $05;
DMUS_CURVET_PATCURVE = $06;
 
// notification type values
// The following correspond to GUID_NOTIFICATION_SEGMENT
const
DMUS_NOTIFICATION_SEGSTART = 0;
DMUS_NOTIFICATION_SEGEND = 1;
DMUS_NOTIFICATION_SEGALMOSTEND = 2;
DMUS_NOTIFICATION_SEGLOOP = 3;
DMUS_NOTIFICATION_SEGABORT = 4;
// The following correspond to GUID_NOTIFICATION_PERFORMANCE
DMUS_NOTIFICATION_MUSICSTARTED = 0;
DMUS_NOTIFICATION_MUSICSTOPPED = 1;
// The following corresponds to GUID_NOTIFICATION_MEASUREANDBEAT
DMUS_NOTIFICATION_MEASUREBEAT = 0;
// The following corresponds to GUID_NOTIFICATION_CHORD
DMUS_NOTIFICATION_CHORD = 0;
// The following correspond to GUID_NOTIFICATION_COMMAND
DMUS_NOTIFICATION_GROOVE = 0;
DMUS_NOTIFICATION_EMBELLISHMENT= 1;
 
type
// Time Signature structure, used by IDirectMusicStyle
// Also used as a parameter for GetParam() and SetParam
TDMUS_TIMESIGNATURE = record
mtTime : MUSIC_TIME;
bBeatsPerMeasure : Byte; // beats per measure (top of time sig)
bBeat : Byte; // what note receives the beat (bottom of time sig.)
// we can assume that 0 means 256th note
wGridsPerBeat : Word; // grids per beat
end;
DMUS_TIMESIGNATURE = TDMUS_TIMESIGNATURE;
 
// Flags for dwValidData. When set, a flag indicates that the
// corresponding field in DMUSOBJECTDESC holds valid data.
const
DMUS_OBJ_OBJECT = 1 shl 0; // Object GUID is valid.
DMUS_OBJ_CLASS = 1 shl 1; // Class GUID is valid.
DMUS_OBJ_NAME = 1 shl 2; // Name is valid.
DMUS_OBJ_CATEGORY = 1 shl 3; // Category is valid.
DMUS_OBJ_FILENAME = 1 shl 4; // File path is valid.
DMUS_OBJ_FULLPATH = 1 shl 5; // Path is full path.
DMUS_OBJ_URL = 1 shl 6; // Path is URL.
DMUS_OBJ_VERSION = 1 shl 7; // Version is valid.
DMUS_OBJ_DATE = 1 shl 8; // Date is valid.
DMUS_OBJ_LOADED = 1 shl 9; // Object is currently loaded in memory.
DMUS_OBJ_MEMORY = 1 shl 10; // Object is pointed to by pbMemData.
 
const
DMUSB_LOADED = 1 shl 0; // Set when band has been loaded
DMUSB_DEFAULT = 1 shl 1; // Set when band is default band for a style
 
type
IDirectMusicTrack = interface;
IDirectMusicPerformance = interface;
IDirectMusicTool = interface;
IDirectMusicSegment = interface;
IDirectMusicSegmentState = interface;
IDirectMusicTool = interface;
IDirectMusicGraph = interface;
//IDirectMusicPort = interface;
//IDirectMusicBuffer = interface;
//IDirectMusicInstrument = interface;
//IDirectMusicDownloadedInstrument = interface;
IDirectMusicBand = interface;
IDirectMusicChordMap = interface;
IDirectMusicLoader = interface;
IDirectMusicObject = interface;
{#ifndef __cplusplus
typedef interface IDirectMusic IDirectMusic;
typedef interface IDirectMusicTrack IDirectMusicTrack;
typedef interface IDirectMusicPerformance IDirectMusicPerformance;
typedef interface IDirectMusicTool IDirectMusicTool;
typedef interface IDirectMusicSegment IDirectMusicSegment;
typedef interface IDirectMusicSegmentState IDirectMusicSegmentState;
typedef interface IDirectMusicGraph IDirectMusicGraph;
typedef interface IDirectMusicPort IDirectMusicPort;
typedef interface IDirectMusicBuffer IDirectMusicBuffer;
typedef interface IDirectMusicInstrument IDirectMusicInstrument;
typedef interface IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument;
typedef interface IDirectMusicBand IDirectMusicBand;
typedef interface IDirectMusicChordMap IDirectMusicChordMap;
typedef interface IDirectMusicObject IDirectMusicObject;
typedef interface IDirectMusicLoader IDirectMusicLoader;
#endif}
 
LPDMUS_OBJECT = IDirectMusicObject;
LPDMUS_LOADER = IDirectMusicLoader;
LPDMUS_BAND = IDirectMusicBand;
 
PIDirectMusicSegmentState = ^IDirectMusicSegmentState;
 
TDMus_PMsg_Part = record
TDMUS_PMSG_PART = record
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
rtTime : REFERENCE_TIME; // real time (in 100 nanosecond increments) \
mtTime : MUSIC_TIME; // music time \
dwFlags : DWORD; // various bits (see DMUS_PMSG_FLAGS enumeration) \
dwPChannel : DWORD; // Performance Channel. The Performance can \
// use this to determine the port/channel. \
dwVirtualTrackID : DWORD; // virtual track ID \
pTool : IDirectMusicTool; // tool interface pointer \
pGraph : IDirectMusicGraph; // tool graph interface pointer \
dwType : DWORD; // PMSG type (see DMUS_PMSGT_TYPES defines) \
dwVoiceID : DWORD; // unique voice id which allows synthesizers to \
// identify a specific event. For DirectX 6.0, \
// this field should always be 0. \
dwGroupID : DWORD; // Track group id \
punkUser : IUnknown; // user com pointer, auto released upon PMSG free
end;
// every DMUS_PMSG is based off of this structure. The Performance needs
// to access these members consistently in every PMSG that goes through it.
{typedef struct _DMUS_PMSG
{
/* begin DMUS_PMSG_PART
DMUS_PMSG_PART
/* end DMUS_PMSG_PART
 
(* every TDMus_PMsg is based off of this structure. The Performance needs
to access these members consistently in every PMSG that goes through it. *)
DMUS_PMSG;}
TDMUS_PMSG = TDMUS_PMSG_PART;
DMUS_PMSG = TDMUS_PMSG;
 
(* begin DMUS_PMsg_PART *)
PDMus_PMsg = ^TDMus_PMsg;
TDMus_PMsg = TDMus_PMsg_Part;
(* end DMUS_PMsg_PART *)
// DMUS_NOTE_PMSG
TDMUS_NOTE_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
(* DMUS_NOTIFICATION_PMsg *)
PDMus_Notification_PMsg = ^TDMus_Notification_PMsg;
TDMus_Notification_PMsg = record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
mtDuration : MUSIC_TIME; // duration
wMusicValue : Word; // Description of note in chord and key.
wMeasure : Word; // Measure in which this note occurs
nOffset : Smallint; // Offset from grid at which this note occurs
bBeat : Byte; // Beat (in measure) at which this note occurs
bGrid : Byte; // Grid offset from beat at which this note occurs
bVelocity : Byte; // Note velocity
bFlags : Byte; // see DMUS_NOTE_FLAGS
bTimeRange : Byte; // Range to randomize time.
bDurRange : Byte; // Range to randomize duration.
bVelRange : Byte; // Range to randomize velocity.
bPlayModeFlags : Byte; // Play mode
bSubChordLevel : Byte; // Which subchord level this note uses.
bMidiValue : Byte; // The MIDI note value, converted from wMusicValue
cTranspose : Shortint; // Transposition to add to midi note value after converted from wMusicValue.
end;
DMUS_NOTE_PMSG = TDMUS_NOTE_PMSG;
 
// DMUS_MIDI_PMSG
TDMUS_MIDI_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
bStatus : Byte;
bByte1 : Byte;
bByte2 : Byte;
bPad : array[0..0] of Byte;
end;
DMUS_MIDI_PMSG = TDMUS_MIDI_PMSG;
 
// DMUS_PATCH_PMSG
TDMUS_PATCH_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
byInstrument : Byte;
byMSB : Byte;
byLSB : Byte;
byPad : array[0..0] of Byte;
end;
DMUS_PATCH_PMSG = TDMUS_PATCH_PMSG;
 
// DMUS_TRANSPOSE_PMSG
TDMUS_TRANSPOSE_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
nTranspose : Smallint;
end;
DMUS_TRANSPOSE_PMSG = TDMUS_TRANSPOSE_PMSG;
 
// DMUS_CHANNEL_PRIORITY_PMSG
TDMUS_CHANNEL_PRIORITY_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
dwChannelPriority : DWORD;
end;
DMUS_CHANNEL_PRIORITY_PMSG = TDMUS_CHANNEL_PRIORITY_PMSG;
 
// DMUS_TEMPO_PMSG
TDMUS_TEMPO_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
dblTempo : Double; // the tempo
end;
DMUS_TEMPO_PMSG = TDMUS_TEMPO_PMSG;
 
// DMUS_SYSEX_PMSG
TDMUS_SYSEX_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
dwLen : DWORD; // length of the data
abData : array[0..0] of Byte; // array of data, length equal to dwLen
end;
DMUS_SYSEX_PMSG = TDMUS_SYSEX_PMSG;
 
// DMUS_CURVE_PMSG
TDMUS_CURVE_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
mtDuration : MUSIC_TIME; // how long this curve lasts
mtOriginalStart : MUSIC_TIME; // must be set to either zero when this PMSG is created or to the original mtTime of the curve
mtResetDuration : MUSIC_TIME; // how long after the curve is finished to reset to the
// reset value, nResetValue
nStartValue : Smallint; // curve's start value
nEndValue : Smallint; // curve's end value
nResetValue : Smallint; // curve's reset value, sent after mtResetDuration or
// upon a flush or invalidation
wMeasure : Word; // Measure in which this curve occurs
nOffset : Smallint; // Offset from grid at which this curve occurs
bBeat : Byte; // Beat (in measure) at which this curve occurs
bGrid : Byte; // Grid offset from beat at which this curve occurs
bType : Byte; // type of curve
bCurveShape : Byte; // shape of curve
bCCData : Byte; // CC# if this is a control change type
bFlags : Byte; // set to 1 if the nResetValue must be sent when the
// time is reached or an invalidate occurs because
// of a transition. If 0, the curve stays
// permanently stuck at the new value. All bits besides
// 1 are reserved.
 
end;
DMUS_CURVE_PMSG = TDMUS_CURVE_PMSG;
 
// DMUS_TIMESIG_PMSG
TDMUS_TIMESIG_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
// Time signatures define how many beats per measure, which note receives
// the beat, and the grid resolution.
bBeatsPerMeasure : Byte; // beats per measure (top of time sig)
bBeat : Byte; // what note receives the beat (bottom of time sig.)
// we can assume that 0 means 256th note
wGridsPerBeat : Word; // grids per beat
end;
DMUS_TIMESIG_PMSG = TDMUS_TIMESIG_PMSG;
 
// DMUS_NOTIFICATION_PMSG
PDMUS_NOTIFICATION_PMSG = ^TDMUS_NOTIFICATION_PMSG;
TDMUS_NOTIFICATION_PMSG = record
// begin DMUS_PMSG_PART
DMUS_PMSG_PART : TDMUS_PMSG_PART;
// end DMUS_PMSG_PART
 
guidNotificationType: TGUID;
dwNotificationOption: DWORD;
dwField1: DWORD;
dwField2: DWORD;
end;
DMUS_NOTIFICATION_PMSG = TDMUS_NOTIFICATION_PMSG;
 
TDMus_SubChord = packed record
dwChordPattern: DWORD; (* Notes in the subchord *)
dwScalePattern: DWORD; (* Notes in the scale *)
dwInversionPoints: DWORD; (* Where inversions can occur *)
dwLevels: DWORD; (* Which levels are supported by this subchord *)
bChordRoot: BYTE; (* Root of the subchord *)
bScaleRoot: BYTE; (* Root of the scale *)
TDMUS_VERSION = record
dwVersionMS : DWORD;
dwVersionLS : DWORD;
end;
DMUS_VERSION = TDMUS_VERSION;
LPDMUS_VERSION = ^TDMUS_VERSION;
 
TDMus_Chord_Key = packed record
wszName: array [0..15] of WideChar; (* Name of the chord *)
wMeasure: WORD; (* Measure this falls on *)
bBeat: BYTE; (* Beat this falls on *)
bSubChordCount: BYTE; (* Number of chords in the list of subchords *)
SubChordList: array [0..DMUS_MAXSUBCHORD-1] of TDMus_SubChord; (* List of sub chords *)
dwScale: DWORD; (* Scale underlying the entire chord *)
bKey: BYTE; (* Key underlying the entire chord *)
// The DMUSOBJECTDESC structure is used to communicate everything you could
// possibly use to describe a DirectMusic object.
 
TDMUS_OBJECTDESC = record
dwSize : DWORD; // Size of this structure.
dwValidData : DWORD; // Flags indicating which fields below are valid.
guidObject : TGUID; // Unique ID for this object.
guidClass : TGUID; // GUID for the class of object.
ftDate : TFILETIME; // Last edited date of object.
vVersion : TDMUS_VERSION; // Version.
wszName : array[0..DMUS_MAX_NAME - 1] of WCHAR; // Name of object.
wszCategory : array[0..DMUS_MAX_CATEGORY - 1] of WCHAR; // Category for object (optional).
wszFileName : array[0..DMUS_MAX_FILENAME - 1] of WCHAR; // File path.
llMemLength : LONGLONG; // Size of Memory data.
pbMemData : Pointer; // Memory pointer for data.
end;
DMUS_OBJECTDESC = TDMUS_OBJECTDESC;
LPDMUS_OBJECTDESC = ^TDMUS_OBJECTDESC;
 
(* Time Signature structure, used by IDirectMusicStyle *)
(* Also used as a parameter for GetParam() and SetParam *)
TDMus_TimeSignature = packed record
mtTime: TMusic_Time;
bBeatsPerMeasure: BYTE; (* beats per measure (top of time sig) *)
bBeat: BYTE; (* what note receives the beat (bottom of time sig.) *)
(* we can assume that 0 means 256th note *)
wGridsPerBeat: WORD; (* grids per beat *)
IDirectMusicBand = interface(IUnknown)
['{D2AC28C0-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicBand
function CreateSegment(out ppSegment: IDirectMusicSegment) : HResult; stdcall;
function Download(pPerformance: IDirectMusicPerformance) : HResult; stdcall;
function Unload(pPerformance: IDirectMusicPerformance) : HResult; stdcall;
end;
(*/////////////////////////////////////////////////////////////////////
// IDirectMusicSegmentState *)
IDirectMusicSegmentState = interface (IUnknown)
['{a3afdcc7-d3ee-11d1-bc8d-00a0c922e6eb}']
function GetRepeats (out pdwRepeats: DWORD) : HResult; stdcall;
function GetSegment (out ppSegment: IDirectMusicSegment) : HResult; stdcall;
function GetStartTime (out pmtStart: TMusic_Time) : HResult; stdcall;
function GetSeek (out pmtSeek: TMusic_Time) : HResult; stdcall;
function GetStartPoint (out pmtStart: TMusic_Time) : HResult; stdcall;
IDirectMusicObject = interface(IUnknown)
['{D2AC28B5-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicObject
function GetDescriptor(var pDesc: TDMUS_OBJECTDESC) : HResult; stdcall;
function SetDescriptor(const pDesc: TDMUS_OBJECTDESC) : HResult; stdcall;
function ParseDescriptor(pStream: IStream;
var pDesc: TDMUS_OBJECTDESC) : HResult; stdcall;
end;
 
(*////////////////////////////////////////////////////////////////////
// IDirectMusicSegment *)
IDirectMusicLoader = interface(IUnknown)
['{2FFAACA2-5DCA-11D2-AFA6-00AA0024D8B6}']
// IDirectMusicLoader
function GetObject(const pDesc: TDMUS_OBJECTDESC;
const riid: TGUID;
out ppv) : HResult; stdcall;
function SetObject(const pDesc: TDMUS_OBJECTDESC) : HResult; stdcall;
function SetSearchDirectory(const rguidClass: TGUID;
pwzPath: PWCHAR;
fClear: BOOL) : HResult; stdcall;
function ScanDirectory(const rguidClass: TGUID;
pwzFileExtension: PWCHAR;
var pwzScanFileName: PWCHAR) : HResult; stdcall;
function CacheObject(pObject: IDirectMusicObject) : HResult; stdcall;
function ReleaseObject(pObject: IDirectMusicObject) : HResult; stdcall;
function ClearCache(const rguidClass: TGUID) : HResult; stdcall;
function EnableCache(const rguidClass: TGUID;
fEnable: BOOL) : HResult; stdcall;
function EnumObject(const rguidClass: TGUID;
dwIndex: DWORD;
var pDesc: TDMUS_OBJECTDESC) : HResult; stdcall;
end;
 
// Stream object supports IDirectMusicGetLoader interface to access loader while file parsing.
IDirectMusicGetLoader = interface(IUnknown)
['{68A04844-D13D-11D1-AFA6-00AA0024D8B6}']
// IDirectMusicGetLoader
function GetLoader(out ppLoader: IDirectMusicLoader) : HResult; stdcall;
end;
 
{ IDirectMusicSegment }
 
IDirectMusicSegment = interface (IUnknown)
['{f96029a2-4282-11d2-8717-00600893b1bd}']
function GetLength (out pmtLength: TMusic_Time) : HResult; stdcall;
function SetLength (mtLength: TMusic_Time) : HResult; stdcall;
function GetRepeats (out pdwRepeats: DWORD) : HResult; stdcall;
['{F96029A2-4282-11D2-8717-00600893B1BD}']
// IDirectMusicSegment
function GetLength(var pmtLength: MUSIC_TIME) : HResult; stdcall;
function SetLength(mtLength: MUSIC_TIME) : HResult; stdcall;
function GetRepeats(var pdwRepeats: DWORD) : HResult; stdcall;
function SetRepeats (dwRepeats: DWORD) : HResult; stdcall;
function GetDefaultResolution (out pdwResolution: DWORD) : HResult; stdcall;
function GetDefaultResolution(var pdwResolution: DWORD) : HResult; stdcall;
function SetDefaultResolution (dwResolution: DWORD) : HResult; stdcall;
function GetTrack (const rguidType: TGUID;
dwGroupBits, dwIndex: DWORD;
dwGroupBits: DWORD;
dwIndex: DWORD;
out ppTrack: IDirectMusicTrack) : HResult; stdcall;
function GetTrackGroup (pTrack: IDirectMusicTrack;
out pdwGroupBits: DWORD) : HResult; stdcall;
var pdwGroupBits: DWORD) : HResult; stdcall;
function InsertTrack (pTrack: IDirectMusicTrack;
dwGroupBits: DWORD) : HResult; stdcall;
function RemoveTrack (pTrack: IDirectMusicTrack) : HResult; stdcall;
19778,100 → 14477,115
function AddNotificationType (const rguidNotificationType: TGUID) : HResult; stdcall;
function RemoveNotificationType (const rguidNotificationType: TGUID) : HResult; stdcall;
function GetParam (const rguidType: TGUID;
dwGroupBits, dwIndex: DWORD;
mtTime: TMusic_Time;
out pmtNext: TMusic_Time;
dwGroupBits: DWORD;
dwIndex: DWORD;
mtTime: MUSIC_TIME;
var pmtNext: MUSIC_TIME;
pParam: Pointer) : HResult; stdcall;
function SetParam (const rguidType: TGUID;
dwGroupBits, dwIndex: DWORD;
mtTime: TMusic_Time;
dwGroupBits: DWORD;
dwIndex: DWORD;
mtTime: MUSIC_TIME;
pParam: Pointer) : HResult; stdcall;
function Clone (mtStart: TMusic_Time;
mtEnd: TMusic_Time;
function Clone(mtStart: MUSIC_TIME;
mtEnd: MUSIC_TIME;
out ppSegment: IDirectMusicSegment) : HResult; stdcall;
function SetStartPoint (mtStart: TMusic_Time) : HResult; stdcall;
function GetStartPoint (out pmtStart: TMusic_Time) : HResult; stdcall;
function SetLoopPoints (mtStart: TMusic_Time;
mtEnd: TMusic_Time) : HResult; stdcall;
function GetLoopPoints (out pmtStart, pmtEnd: TMusic_Time) : HResult; stdcall;
function SetStartPoint(mtStart: MUSIC_TIME) : HResult; stdcall;
function GetStartPoint(var pmtStart: MUSIC_TIME) : HResult; stdcall;
function SetLoopPoints(mtStart: MUSIC_TIME;
mtEnd: MUSIC_TIME) : HResult; stdcall;
function GetLoopPoints(var pmtStart: MUSIC_TIME;
var pmtEnd: MUSIC_TIME) : HResult; stdcall;
function SetPChannelsUsed (dwNumPChannels: DWORD;
var paPChannels: DWORD) : HResult; stdcall;
const paPChannels) : HResult; stdcall;
end;
 
{ IDirectMusicSegmentState }
 
(*////////////////////////////////////////////////////////////////////
// IDirectMusicTrack *)
IDirectMusicSegmentState = interface(IUnknown)
['{A3AFDCC7-D3EE-11D1-BC8D-00A0C922E6EB}']
// IDirectMusicSegmentState
function GetRepeats(var pdwRepeats: DWORD) : HResult; stdcall;
function GetSegment(out ppSegment: IDirectMusicSegment) : HResult; stdcall;
function GetStartTime(var pmtStart: MUSIC_TIME) : HResult; stdcall;
function GetSeek(var pmtSeek: MUSIC_TIME) : HResult; stdcall;
function GetStartPoint(var pmtStart: MUSIC_TIME) : HResult; stdcall;
end;
 
{ IDirectMusicTrack }
 
IDirectMusicTrack = interface (IUnknown)
['{f96029a1-4282-11d2-8717-00600893b1bd}']
['{F96029A1-4282-11D2-8717-00600893B1BD}']
// IDirectMusicTrack
function Init (pSegment: IDirectMusicSegment) : HResult; stdcall;
function InitPlay (pSegmentState: IDirectMusicSegmentState;
pPerformance: IDirectMusicPerformance;
out ppStateData: Pointer;
dwVirtualTrackID, dwFlags: DWORD) : HResult; stdcall;
function EndPlay (pStateData: Pointer) : HResult; stdcall;
function Play (pStateData: Pointer;
mtStart: TMusic_Time;
mtEnd: TMusic_Time;
mtOffset: TMusic_Time;
var ppStateData: Pointer;
dwVirtualTrackID: DWORD;
dwFlags: DWORD) : HResult; stdcall;
function EndPlay(const pStateData) : HResult; stdcall;
function Play(const pStateData;
mtStart: MUSIC_TIME;
mtEnd: MUSIC_TIME;
mtOffset: MUSIC_TIME;
dwFlags: DWORD;
pPerf: IDirectMusicPerformance;
pSegSt: IDirectMusicSegmentState;
dwVirtualID:DWORD) : HResult; stdcall;
function GetParam (const rguidType: TGUID;
mtTime: TMusic_Time;
out pmtNext: TMusic_Time;
pParam: Pointer) : HResult; stdcall;
mtTime: MUSIC_TIME;
var pmtNext: MUSIC_TIME;
var pParam) : HResult; stdcall;
function SetParam (const rguidType: TGUID;
mtTime: TMusic_Time;
pParam: Pointer) : HResult; stdcall;
mtTime: MUSIC_TIME;
const pParam) : HResult; stdcall;
function IsParamSupported (const rguidType: TGUID) : HResult; stdcall;
function AddNotificationType (const rguidNotificationType: TGUID) : HResult; stdcall;
function RemoveNotificationType (const rguidNotificationType: TGUID) : HResult; stdcall;
function Clone (mtStart: TMusic_Time;
mtEnd: TMusic_Time;
function Clone(mtStart: MUSIC_TIME;
mtEnd: MUSIC_TIME;
out ppTrack: IDirectMusicTrack) : HResult; stdcall;
end;
 
PIDirectMusic = ^IDirectMusic;
{ IDirectMusicPerformance }
 
(*////////////////////////////////////////////////////////////////////
// IDirectMusicPerformance *)
IDirectMusicPerformance = interface (IUnknown)
['{07d43d03-6523-11d2-871d-00600893b1bd}']
function Init (ppDirectMusic: PIDirectMusic;
['{07D43D03-6523-11D2-871D-00600893B1BD}']
// IDirectMusicPerformance
function Init(out ppDirectMusic: IDirectMusic;
pDirectSound: IDirectSound;
hWnd: HWND ) : HResult; stdcall;
function PlaySegment (pSegment: IDirectMusicSegment;
dwFlags: DWORD;
i64StartTime: LongLong;
ppSegmentState: PIDirectMusicSegmentState) : HResult; stdcall;
i64StartTime: LONGLONG;
out ppSegmentState: IDirectMusicSegmentState) : HResult; stdcall;
function Stop (pSegment: IDirectMusicSegment;
pSegmentState: IDirectMusicSegmentState;
mtTime: TMusic_Time;
mtTime: MUSIC_TIME;
dwFlags: DWORD) : HResult; stdcall;
function GetSegmentState (out ppSegmentState: IDirectMusicSegmentState;
mtTime: TMusic_Time) : HResult; stdcall;
mtTime: MUSIC_TIME) : HResult; stdcall;
function SetPrepareTime (dwMilliSeconds: DWORD) : HResult; stdcall;
function GetPrepareTime (out pdwMilliSeconds: DWORD) : HResult; stdcall;
function GetPrepareTime(var pdwMilliSeconds: DWORD) : HResult; stdcall;
function SetBumperLength (dwMilliSeconds: DWORD) : HResult; stdcall;
function GetBumperLength (out pdwMilliSeconds: DWORD) : HResult; stdcall;
function SendPMsg (out pPMSG: TDMus_PMsg) : HResult; stdcall;
function MusicToReferenceTime (mtTime: TMusic_Time;
out prtTime: TReference_Time) : HResult; stdcall;
function ReferenceToMusicTime (rtTime: TReference_Time;
out pmtTime: TMusic_Time) : HResult; stdcall;
function GetBumperLength(var pdwMilliSeconds: DWORD) : HResult; stdcall;
function SendPMsg(const pPMSG: TDMUS_PMSG) : HResult; stdcall;
function MusicToReferenceTime(mtTime: MUSIC_TIME;
var prtTime: TREFERENCE_TIME) : HResult; stdcall;
function ReferenceToMusicTime(rtTime: TREFERENCE_TIME;
var pmtTime: MUSIC_TIME) : HResult; stdcall;
function IsPlaying (pSegment: IDirectMusicSegment;
pSegState: IDirectMusicSegmentState) : HResult; stdcall;
function GetTime (prtNow: PReference_Time;
pmtNow: PMusic_Time) : HResult; stdcall;
function AllocPMsg (cb: ULONG;
out ppPMSG: PDMus_PMsg) : HResult; stdcall;
function FreePMsg (pPMSG: PDMus_PMsg) : HResult; stdcall;
function GetTime(var prtNow: TREFERENCE_TIME;
var pmtNow: MUSIC_TIME) : HResult; stdcall;
function AllocPMsg(cb: Cardinal;
var ppPMSG: TDMUS_PMSG) : HResult; stdcall;
function FreePMsg(const pPMSG: TDMUS_PMSG) : HResult; stdcall;
function GetGraph (out ppGraph: IDirectMusicGraph) : HResult; stdcall;
function SetGraph (pGraph: IDirectMusicGraph) : HResult; stdcall;
function SetNotificationHandle (hNotification: THANDLE;
rtMinimum: TReference_Time) : HResult; stdcall;
function GetNotificationPMsg (out ppNotificationPMsg: PDMus_Notification_PMsg) : HResult; stdcall;
function SetNotificationHandle(hNotification: THandle;
rtMinimum: TREFERENCE_TIME) : HResult; stdcall;
function GetNotificationPMsg(var ppNotificationPMsg: PDMUS_NOTIFICATION_PMSG) : HResult; stdcall;
function AddNotificationType (const rguidNotificationType: TGUID) : HResult; stdcall;
function RemoveNotificationType (const rguidNotificationType: TGUID) : HResult; stdcall;
function AddPort (pPort: IDirectMusicPort) : HResult; stdcall;
19881,600 → 14595,151
dwGroup: DWORD) : HResult; stdcall;
function AssignPChannel (dwPChannel: DWORD;
pPort: IDirectMusicPort;
dwGroup, dwMChannel: DWORD) : HResult; stdcall;
dwGroup: DWORD;
dwMChannel: DWORD) : HResult; stdcall;
function PChannelInfo (dwPChannel: DWORD;
out ppPort: IDirectMusicPort;
out pdwGroup, pdwMChannel: DWORD ) : HResult; stdcall;
var pdwGroup: DWORD;
var pdwMChannel: DWORD) : HResult; stdcall;
function DownloadInstrument (pInst: IDirectMusicInstrument;
dwPChannel: DWORD;
out ppDownInst: IDirectMusicDownloadedInstrument;
var pNoteRanges: TDMus_NoteRange;
const pNoteRanges;
dwNumNoteRanges: DWORD;
out ppPort: IDirectMusicPort;
out pdwGroup, pdwMChannel: DWORD) : HResult; stdcall;
function Invalidate (mtTime: TMusic_Time;
var pdwGroup: DWORD;
var pdwMChannel: DWORD) : HResult; stdcall;
function Invalidate(mtTime: MUSIC_TIME;
dwFlags: DWORD) : HResult; stdcall;
function GetParam (const rguidType: TGUID;
dwGroupBits, dwIndex: DWORD;
mtTime: TMusic_Time;
out pmtNext: TMusic_Time;
pParam: Pointer) : HResult; stdcall;
dwGroupBits: DWORD;
dwIndex: DWORD;
mtTime: MUSIC_TIME;
var pmtNext: MUSIC_TIME;
var pParam) : HResult; stdcall;
function SetParam (const rguidType: TGUID;
dwGroupBits, dwIndex: DWORD;
mtTime: TMusic_Time;
dwGroupBits: DWORD;
dwIndex: DWORD;
mtTime: MUSIC_TIME;
pParam: Pointer) : HResult; stdcall;
function GetGlobalParam (const rguidType: TGUID;
pParam: Pointer;
var pParam;
dwSize: DWORD) : HResult; stdcall;
function SetGlobalParam (const rguidType: TGUID;
pParam: Pointer;
const pParam;
dwSize: DWORD) : HResult; stdcall;
function GetLatencyTime (out prtTime: TReference_Time) : HResult; stdcall;
function GetQueueTime (out prtTime: TReference_Time) : HResult; stdcall;
function AdjustTime (rtAmount: TReference_Time) : HResult; stdcall;
function GetLatencyTime(var prtTime: TREFERENCE_TIME) : HResult; stdcall;
function GetQueueTime(var prtTime: TREFERENCE_TIME) : HResult; stdcall;
function AdjustTime(rtAmount: TREFERENCE_TIME) : HResult; stdcall;
function CloseDown : HResult; stdcall;
function GetResolvedTime (rtTime: TReference_Time;
out prtResolved: TReference_Time;
function GetResolvedTime(rtTime: TREFERENCE_TIME;
var prtResolved: TREFERENCE_TIME;
dwTimeResolveFlags: DWORD) : HResult; stdcall;
function MIDIToMusic (bMIDIValue: BYTE;
const pChord: TDMus_Chord_Key;
bPlayMode, bChordLevel: Byte;
out pwMusicValue: WORD) : HResult; stdcall;
function MusicToMIDI (wMusicValue: WORD;
const pChord: TDMus_Chord_Key;
bPlayMode, bChordLevel: BYTE;
out pbMIDIValue: BYTE) : HResult; stdcall;
function TimeToRhythm (mtTime: TMusic_Time;
const pTimeSig: TDMus_TimeSignature;
out pwMeasure: WORD;
out pbBeat, pbGrid: BYTE;
out pnOffset: SmallInt) : HResult; stdcall;
function RhythmToTime (wMeasure: WORD;
bBeat, bGrid: BYTE;
nOffset: SmallInt;
const pTimeSig: TDMus_TimeSignature;
out pmtTime: TMusic_Time) : HResult; stdcall;
function MIDIToMusic(bMIDIValue: Byte;
const pChord: TDMUS_CHORD_KEY;
bPlayMode: Byte;
bChordLevel: Byte;
var pwMusicValue: Word) : HResult; stdcall;
function MusicToMIDI(wMusicValue: Word;
const pChord: TDMUS_CHORD_KEY;
bPlayMode: Byte;
bChordLevel: Byte;
var pbMIDIValue: Byte) : HResult; stdcall;
function TimeToRhythm(mtTime: MUSIC_TIME;
const pTimeSig: TDMUS_TIMESIGNATURE;
var pwMeasure: Word;
var pbBeat: Byte;
var pbGrid: Byte;
var pnOffset: Smallint) : HResult; stdcall;
function RhythmToTime(wMeasure: Word;
bBeat: Byte;
bGrid: Byte;
nOffset: Smallint;
const pTimeSig: TDMUS_TIMESIGNATURE;
var pmtTime: MUSIC_TIME) : HResult; stdcall;
end;
 
(*////////////////////////////////////////////////////////////////////
// IDirectMusicTool *)
{ IDirectMusicTool }
 
IDirectMusicTool = interface (IUnknown)
['{d2ac28ba-b39b-11d1-8704-00600893b1bd}']
['{D2AC28BA-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicTool
function Init (pGraph: IDirectMusicGraph) : HResult; stdcall;
function GetMsgDeliveryType (out pdwDeliveryType: DWORD) : HResult; stdcall;
function GetMediaTypeArraySize (out pdwNumElements: DWORD) : HResult; stdcall;
function GetMediaTypes (out padwMediaTypes: PDWORD;
function GetMsgDeliveryType(var pdwDeliveryType: DWORD) : HResult; stdcall;
function GetMediaTypeArraySize(var pdwNumElements: DWORD) : HResult; stdcall;
function GetMediaTypes(var padwMediaTypes;
dwNumElements: DWORD) : HResult; stdcall;
function ProcessPMsg (pPerf: IDirectMusicPerformance;
var pPMSG: TDMus_PMsg) : HResult; stdcall;
const pPMSG: TDMUS_PMSG) : HResult; stdcall;
function Flush (pPerf: IDirectMusicPerformance;
const pPMSG: TDMus_PMsg;
rtTime: TReference_Time) : HResult; stdcall;
const pPMSG: TDMUS_PMSG;
rtTime: TREFERENCE_TIME) : HResult; stdcall;
end;
 
(*////////////////////////////////////////////////////////////////////
// IDirectMusicGraph *)
{ IDirectMusicGraph }
 
IDirectMusicGraph = interface (IUnknown)
['{2befc277-5497-11d2-bccb-00a0c922e6eb}']
function StampPMsg (var pPMSG: TDMus_PMsg ) : HResult; stdcall;
['{2BEFC277-5497-11D2-BCCB-00A0C922E6EB}']
// IDirectMusicGraph
function StampPMsg(const pPMSG: TDMUS_PMSG) : HResult; stdcall;
function InsertTool (pTool: IDirectMusicTool;
var pdwPChannels: DWORD;
const pdwPChannels;
cPChannels: DWORD;
lIndex: LongInt) : HResult; stdcall;
lIndex: Longint) : HResult; stdcall;
function GetTool (dwIndex: DWORD;
out ppTool: IDirectMusicTool) : HResult; stdcall;
function RemoveTool (pTool: IDirectMusicTool) : HResult; stdcall;
end;
 
{ IDirectMusicStyle }
 
(* DMUS_NOTE_PMsg *)
TDMus_Note_PMsg = packed record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
 
mtDuration: TMusic_Time; (* duration *)
wMusicValue: WORD; (* Description of note in chord and key. *)
wMeasure: WORD; (* Measure in which this note occurs *)
nOffset: SmallInt; (* Offset from grid at which this note occurs *)
bBeat: BYTE; (* Beat (in measure) at which this note occurs *)
bGrid: BYTE; (* Grid offset from beat at which this note occurs *)
bVelocity: BYTE; (* Note velocity *)
bFlags: BYTE; (* see DMUS_NOTE_FLAGS *)
bTimeRange: BYTE; (* Range to randomize time. *)
bDurRange: BYTE; (* Range to randomize duration. *)
bVelRange: BYTE; (* Range to randomize velocity. *)
bPlayModeFlags: BYTE; (* Play mode *)
bSubChordLevel: BYTE; (* Which subchord level this note uses. *)
bMidiValue: BYTE; (* The MIDI note value, converted from wMusicValue *)
cTranspose: char; (* Transposition to add to midi note value after converted from wMusicValue. *)
end;
 
TDMus_NoteF_Flags = DWORD;
const
DMUS_NOTEF_NOTEON = 1; (* Set if this is a MIDI Note On. Otherwise, it is MIDI Note Off *)
 
(* The DMUS_PLAYMODE_FLAGS are used to determine how to convert wMusicValue
into the appropriate bMidiValue.
*)
type
TDMus_PlayMode_Flags = DWORD;
const
DMUS_PLAYMODE_KEY_ROOT = 1; (* Transpose on top of the key root. *)
DMUS_PLAYMODE_CHORD_ROOT = 2; (* Transpose on top of the chord root. *)
DMUS_PLAYMODE_SCALE_INTERVALS = 4; (* Use scale intervals from scale pattern. *)
DMUS_PLAYMODE_CHORD_INTERVALS = 8; (* Use chord intervals from chord pattern. *)
DMUS_PLAYMODE_NONE = 16; (* No mode. Indicates the parent part's mode should be used. *)
 
(* The following are playback modes that can be created by combining the DMUS_PLAYMODE_FLAGS
in various ways:
*)
 
(* Fixed. wMusicValue holds final MIDI note value. This is used for drums, sound effects, and sequenced
notes that should not be transposed by the chord or scale.
*)
DMUS_PLAYMODE_FIXED = 0;
(* In fixed to key, the musicvalue is again a fixed MIDI value, but it
is transposed on top of the key root.
*)
DMUS_PLAYMODE_FIXEDTOKEY = DMUS_PLAYMODE_KEY_ROOT;
(* In fixed to chord, the musicvalue is also a fixed MIDI value, but it
is transposed on top of the chord root.
*)
DMUS_PLAYMODE_FIXEDTOCHORD = DMUS_PLAYMODE_CHORD_ROOT;
(* In Pedalpoint, the key root is used and the notes only track the intervals in
the scale. The chord root and intervals are completely ignored. This is useful
for melodic lines that play relative to the key root.
*)
DMUS_PLAYMODE_PEDALPOINT = (DMUS_PLAYMODE_KEY_ROOT or DMUS_PLAYMODE_SCALE_INTERVALS);
(* In the Melodic mode, the chord root is used but the notes only track the intervals in
the scale. The key root and chord intervals are completely ignored. This is useful
for melodic lines that play relative to the chord root.
*)
DMUS_PLAYMODE_MELODIC = (DMUS_PLAYMODE_CHORD_ROOT or DMUS_PLAYMODE_SCALE_INTERVALS);
(* Normal chord mode is the prevalent playback mode.
The notes track the intervals in the chord, which is based on the chord root.
If there is a scale component to the MusicValue, the additional intervals
are pulled from the scale and added.
If the chord does not have an interval to match the chord component of
the MusicValue, the note is silent.
*)
DMUS_PLAYMODE_NORMALCHORD = (DMUS_PLAYMODE_CHORD_ROOT or DMUS_PLAYMODE_CHORD_INTERVALS);
(* If it is desirable to play a note that is above the top of the chord, the
always play mode (known as "purpleized" in a former life) finds a position
for the note by using intervals from the scale. Essentially, this mode is
a combination of the Normal and Melodic playback modes, where a failure
in Normal causes a second try in Melodic mode.
*)
DMUS_PLAYMODE_ALWAYSPLAY = (DMUS_PLAYMODE_MELODIC or DMUS_PLAYMODE_NORMALCHORD);
 
(* Legacy names for modes... *)
DMUS_PLAYMODE_PURPLEIZED = DMUS_PLAYMODE_ALWAYSPLAY;
DMUS_PLAYMODE_SCALE_ROOT = DMUS_PLAYMODE_KEY_ROOT;
DMUS_PLAYMODE_FIXEDTOSCALE = DMUS_PLAYMODE_FIXEDTOKEY;
 
type
(* DMUS_MIDI_PMsg *)
TDMus_Midi_PMsg = record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
 
bStatus: BYTE;
bByte1: BYTE;
bByte2: BYTE;
bPad: array [0..0] of BYTE;
end;
 
(* DMUS_PATCH_PMsg *)
TDMus_Patch_PMsg = packed record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
 
byInstrument: BYTE;
byMSB: BYTE;
byLSB: BYTE;
byPad: array [0..0] of BYTE;
end;
 
(* DMUS_TRANSPOSE_PMsg *)
TDMus_Transpose_PMsg = packed record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
 
nTranspose: SmallInt;
end;
 
(* DMUS_CHANNEL_PRIORITY_PMsg *)
TDMus_Channel_Priority_PMsg = packed record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
 
dwChannelPriority: DWORD;
end;
 
(* DMUS_TEMPO_PMsg *)
TDMus_Tempo_PMsg = packed record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
 
dblTempo: double; (* the tempo *)
end;
 
const
DMUS_TEMPO_MAX = 1000;
DMUS_TEMPO_MIN = 1;
 
DMUS_MASTERTEMPO_MAX = 100.0;
DMUS_MASTERTEMPO_MIN = 0.01;
 
type
(* DMUS_SYSEX_PMsg *)
TDMus_SysEx_PMsg = packed record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
 
dwLen: DWORD; (* length of the data *)
abData: array [0..0] of BYTE; (* array of data, length equal to dwLen *)
end;
 
(* DMUS_CURVE_PMsg *)
TDMus_Curve_PMsg = packed record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
 
mtDuration: TMusic_Time; (* how long this curve lasts *)
mtOriginalStart: TMusic_Time; (* must be set to either zero when this PMSG is created or to the original mtTime of the curve *)
mtResetDuration: TMusic_Time; (* how long after the curve is finished to reset to the
reset value, nResetValue *)
nStartValue: SmallInt; (* curve's start value *)
nEndValue: SmallInt; (* curve's end value *)
nResetValue: SmallInt; (* curve's reset value, sent after mtResetDuration or
upon a flush or invalidation *)
wMeasure: WORD; (* Measure in which this curve occurs *)
nOffset: SmallInt; (* Offset from grid at which this curve occurs *)
bBeat: BYTE; (* Beat (in measure) at which this curve occurs *)
bGrid: BYTE; (* Grid offset from beat at which this curve occurs *)
bType: BYTE; (* type of curve *)
bCurveShape: BYTE; (* shape of curve *)
bCCData: BYTE; (* CC# if this is a control change type *)
bFlags: BYTE; (* set to 1 if the nResetValue must be sent when the
time is reached or an invalidate occurs because
of a transition. If 0, the curve stays
permanently stuck at the new value. All bits besides
1 are reserved. *)
end;
 
TDMus_Curve_Flags = DWORD;
const
DMUS_CURVE_RESET = 1; (* Set if the curve needs to be reset. *)
 
(* Curve shapes *)
type
TDMus_Curve_Shapes = (
DMUS_CURVES_LINEAR ,
DMUS_CURVES_INSTANT,
DMUS_CURVES_EXP ,
DMUS_CURVES_LOG ,
DMUS_CURVES_SINE
);
 
const
(* curve types *)
DMUS_CURVET_PBCURVE = $03;
DMUS_CURVET_CCCURVE = $04;
DMUS_CURVET_MATCURVE = $05;
DMUS_CURVET_PATCURVE = $06;
 
type
(* DMUS_TIMESIG_PMsg *)
TDMus_TimeSig_PMsg = packed record
(* begin DMUS_PMsg_PART *)
dwSize: DWORD;
rtTime: TReference_Time; (* real time (in 100 nanosecond increments) *)
mtTime: TMusic_Time; (* music time *)
dwFlags: DWORD; (* various bits (see DMUS_PMsg_FLAGS enumeration) *)
dwPChannel: DWORD; (* Performance Channel. The Performance can *)
(* use this to determine the port/channel. *)
dwVirtualTrackID:DWORD; (* virtual track ID *)
pTool: IDirectMusicTool; (* tool interface pointer *)
pGraph: IDirectMusicGraph; (* tool graph interface pointer *)
dwType: DWORD; (* PMSG type (see DMUS_PMsgT_TYPES defines) *)
dwVoiceID: DWORD; (* unique voice id which allows synthesizers to *)
(* identify a specific event. For DirectX 6.0, *)
(* this field should always be 0. *)
dwGroupID: DWORD; (* Track group id *)
punkUser: IUnknown; (* user com pointer, auto released upon PMSG free *)
(* end DMUS_PMsg_PART *)
 
(* Time signatures define how many beats per measure, which note receives *)
(* the beat, and the grid resolution. *)
bBeatsPerMeasure: BYTE; (* beats per measure (top of time sig) *)
bBeat: BYTE; (* what note receives the beat (bottom of time sig.) *)
(* we can assume that 0 means 256th note *)
wGridsPerBeat: WORD; (* grids per beat *)
end;
 
const
(* notification type values *)
(* The following correspond to GUID_NOTIFICATION_SEGMENT *)
DMUS_NOTIFICATION_SEGSTART = 0;
DMUS_NOTIFICATION_SEGEND = 1;
DMUS_NOTIFICATION_SEGALMOSTEND = 2;
DMUS_NOTIFICATION_SEGLOOP = 3;
DMUS_NOTIFICATION_SEGABORT = 4;
(* The following correspond to GUID_NOTIFICATION_PERFORMANCE *)
DMUS_NOTIFICATION_MUSICSTARTED = 0;
DMUS_NOTIFICATION_MUSICSTOPPED = 1;
(* The following corresponds to GUID_NOTIFICATION_MEASUREANDBEAT *)
DMUS_NOTIFICATION_MEASUREBEAT = 0;
(* The following corresponds to GUID_NOTIFICATION_CHORD *)
DMUS_NOTIFICATION_CHORD = 0;
(* The following correspond to GUID_NOTIFICATION_COMMAND *)
DMUS_NOTIFICATION_GROOVE = 0;
DMUS_NOTIFICATION_EMBELLISHMENT = 1;
 
const
DMUS_MAX_NAME = 64; (* Maximum object name length. *)
DMUS_MAX_CATEGORY = 64; (* Maximum object category name length. *)
DMUS_MAX_FILENAME = MAX_PATH;
 
type
PDMus_Version = ^TDMus_Version;
TDMus_Version = packed record
dwVersionMS: DWORD;
dwVersionLS: DWORD;
end;
 
(* The DMUSOBJECTDESC structure is used to communicate everything you could *)
(* possibly use to describe a DirectMusic object. *)
PDMus_ObjectDesc = ^TDMus_ObjectDesc;
TDMus_ObjectDesc = packed record
dwSize: DWORD; (* Size of this structure. *)
dwValidData: DWORD; (* Flags indicating which fields below are valid. *)
guidObject: TGUID; (* Unique ID for this object. *)
guidClass: TGUID; (* GUID for the class of object. *)
ftDate: TFileTime; (* Last edited date of object. *)
vVersion: TDMus_Version; (* Version. *)
wszName: array [0..DMUS_MAX_NAME-1] of WCHAR; (* Name of object. *)
wszCategory: array [0..DMUS_MAX_CATEGORY-1] of WCHAR; (* Category for object (optional). *)
wszFileName: array [0..DMUS_MAX_FILENAME-1] of WCHAR; (* File path. *)
llMemLength: LongLong; (* Size of Memory data. *)
pbMemData: Pointer; (* Memory pointer for data. *)
dwDummy: DWORD; ///?
end;
 
(* Flags for dwValidData. When set, a flag indicates that the *)
(* corresponding field in DMUSOBJECTDESC holds valid data. *)
const
DMUS_OBJ_OBJECT = (1 shl 0); (* Object GUID is valid. *)
DMUS_OBJ_CLASS = (1 shl 1); (* Class GUID is valid. *)
DMUS_OBJ_NAME = (1 shl 2); (* Name is valid. *)
DMUS_OBJ_CATEGORY = (1 shl 3); (* Category is valid. *)
DMUS_OBJ_FILENAME = (1 shl 4); (* File path is valid. *)
DMUS_OBJ_FULLPATH = (1 shl 5); (* Path is full path. *)
DMUS_OBJ_URL = (1 shl 6); (* Path is URL. *)
DMUS_OBJ_VERSION = (1 shl 7); (* Version is valid. *)
DMUS_OBJ_DATE = (1 shl 8); (* Date is valid. *)
DMUS_OBJ_LOADED = (1 shl 9); (* Object is currently loaded in memory. *)
DMUS_OBJ_MEMORY = (1 shl 10); (* Object is pointed to by pbMemData. *)
 
DMUSB_LOADED = (1 shl 0); (* Set when band has been loaded *)
DMUSB_DEFAULT = (1 shl 1); (* Set when band is default band for a style *)
 
type
IDirectMusicBand = interface;
IDirectMusicChordMap = interface;
IDirectMusicLoader = interface;
IDirectMusicObject = interface;
 
 
IDirectMusicBand = interface (IUnknown)
['{d2ac28c0-b39b-11d1-8704-00600893b1bd}']
function CreateSegment (out ppSegment: IDirectMusicSegment) : HResult; stdcall;
function Download (pPerformance: IDirectMusicPerformance) : HResult; stdcall;
function Unload (pPerformance: IDirectMusicPerformance) : HResult; stdcall;
end;
 
IDirectMusicObject = interface (IUnknown)
['{d2ac28b5-b39b-11d1-8704-00600893b1bd}']
function GetDescriptor (out pDesc: TDMus_ObjectDesc) : HResult; stdcall;
function SetDescriptor (const pDesc: TDMus_ObjectDesc) : HResult; stdcall;
function ParseDescriptor (var pStream;
out pDesc: TDMus_ObjectDesc) : HResult; stdcall;
end;
 
IDirectMusicLoader = interface (IUnknown)
['{2ffaaca2-5dca-11d2-afa6-00aa0024d8b6}']
function GetObject (const pDesc: TDMus_ObjectDesc;
const riid : TGUID;
out ppv) : HResult; stdcall;
function SetObject (const pDesc: TDMus_ObjectDesc) : HResult; stdcall;
function SetSearchDirectory (const rguidClass: TGUID;
pwzPath: PWideChar;
fClear: BOOL) : HResult; stdcall;
function ScanDirectory (const rguidClass: TGUID;
pwzFileExtension,
pwzScanFileName: PWideChar) : HResult; stdcall;
function CacheObject (pObject: IDirectMusicObject) : HResult; stdcall;
function ReleaseObject (pObject: IDirectMusicObject) : HResult; stdcall;
function ClearCache (const rguidClass: TGUID) : HResult; stdcall;
function EnableCache (const rguidClass: TGUID;
fEnable: BOOL) : HResult; stdcall;
function EnumObject (const rguidClass: TGUID;
dwIndex: DWORD;
const pDesc: TDMus_ObjectDesc) : HResult; stdcall;
end;
 
(* Stream object supports IDirectMusicGetLoader interface to access loader while file parsing. *)
 
IDirectMusicGetLoader = interface (IUnknown)
['{68a04844-d13d-11d1-afa6-00aa0024d8b6}']
function GetLoader (out ppLoader: IDirectMusicLoader) : HResult; stdcall;
end;
 
(*/////////////////////////////////////////////////////////////////////
// IDirectMusicStyle *)
IDirectMusicStyle = interface (IUnknown)
['{d2ac28bd-b39b-11d1-8704-00600893b1bd}']
function GetBand (pwszName: PWideChar;
['{D2AC28BD-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicStyle
function GetBand(pwszName: PWCHAR;
out ppBand: IDirectMusicBand) : HResult; stdcall;
function EnumBand (dwIndex: DWORD;
pwszName: PWideChar) : HResult; stdcall;
pwszName: PWCHAR) : HResult; stdcall;
function GetDefaultBand (out ppBand: IDirectMusicBand) : HResult; stdcall;
function EnumMotif (dwIndex: DWORD;
pwszName: PWideChar) : HResult; stdcall;
function GetMotif (pwszName: PWideChar;
pwszName: PWCHAR) : HResult; stdcall;
function GetMotif(pwszName: PWCHAR;
out ppSegment: IDirectMusicSegment) : HResult; stdcall;
function GetDefaultChordMap (out ppChordMap: IDirectMusicChordMap) : HResult; stdcall;
function EnumChordMap (dwIndex: DWORD;
pwszName: PWideChar) : HResult; stdcall;
function GetChordMap (pwszName: PWideChar;
pwszName: PWCHAR) : HResult; stdcall;
function GetChordMap(pwszName: PWCHAR;
out ppChordMap: IDirectMusicChordMap) : HResult; stdcall;
function GetTimeSignature (out pTimeSig: TDMus_TimeSignature) : HResult; stdcall;
function GetEmbellishmentLength (dwType, dwLevel: DWORD;
out pdwMin, pdwMax: DWORD) : HResult; stdcall;
function GetTempo (out pTempo: double) : HResult; stdcall;
function GetTimeSignature(var pTimeSig: TDMUS_TIMESIGNATURE) : HResult; stdcall;
function GetEmbellishmentLength(dwType: DWORD;
dwLevel: DWORD;
var pdwMin: DWORD;
var pdwMax: DWORD) : HResult; stdcall;
function GetTempo(var pTempo: Double) : HResult; stdcall;
end;
 
(*/////////////////////////////////////////////////////////////////////
// IDirectMusicChordMap *)
{ IDirectMusicChordMap }
 
IDirectMusicChordMap = interface (IUnknown)
['{d2ac28be-b39b-11d1-8704-00600893b1bd}']
function GetScale (out pdwScale: DWORD) : HResult; stdcall;
['{D2AC28BE-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicChordMap
function GetScale(var pdwScale: DWORD) : HResult; stdcall;
end;
 
(*/////////////////////////////////////////////////////////////////////
// IDirectMusicComposer *)
{ IDirectMusicComposer }
 
IDirectMusicComposer = interface (IUnknown)
['{d2ac28bf-b39b-11d1-8704-00600893b1bd}']
['{D2AC28BF-B39B-11D1-8704-00600893B1BD}']
// IDirectMusicComposer
function ComposeSegmentFromTemplate (pStyle: IDirectMusicStyle;
pTempSeg: IDirectMusicSegment;
wActivity: WORD;
wActivity: Word;
pChordMap: IDirectMusicChordMap;
out ppSectionSeg: IDirectMusicSegment) : HResult; stdcall;
function ComposeSegmentFromShape (pStyle: IDirectMusicStyle;
wNumMeasures,
wShape,
wActivity: WORD;
wNumMeasures: Word;
wShape: Word;
wActivity: Word;
fIntro: BOOL;
fEnd: BOOL;
pChordMap: IDirectMusicChordMap;
20481,24 → 14746,24
out ppSectionSeg: IDirectMusicSegment) : HResult; stdcall;
function ComposeTransition (pFromSeg: IDirectMusicSegment;
pToSeg: IDirectMusicSegment;
mtTime: TMusic_Time;
wCommand: WORD;
mtTime: MUSIC_TIME;
wCommand: Word;
dwFlags: DWORD;
pChordMap:IDirectMusicChordMap;
out ppSectionSeg: IDirectMusicSegment) : HResult; stdcall;
function AutoTransition (pPerformance: IDirectMusicPerformance;
pToSeg: IDirectMusicSegment;
wCommand: WORD;
wCommand: Word;
dwFlags: DWORD;
pChordMap: IDirectMusicChordMap;
out ppTransSeg: IDirectMusicSegment;
out ppToSegState: IDirectMusicSegmentState;
out ppTransSegState: IDirectMusicSegmentState) : HResult; stdcall;
function ComposeTemplateFromShape (wNumMeasures: WORD;
wShape: WORD;
function ComposeTemplateFromShape(wNumMeasures: Word;
wShape: Word;
fIntro: BOOL;
fEnd: BOOL;
wEndLength: WORD;
wEndLength: Word;
out ppTempSeg:IDirectMusicSegment) : HResult; stdcall;
function ChangeChordMap (pSectionSeg: IDirectMusicSegment;
fTrackScale: BOOL;
20506,978 → 14771,592
end;
 
const
(* CLSID's *)
CLSID_DirectMusicPerformance : TGUID = '{d2ac2881-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicSegment : TGUID = '{d2ac2882-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicSegmentState : TGUID = '{d2ac2883-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicGraph : TGUID = '{d2ac2884-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicTempoTrack : TGUID = '{d2ac2885-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicSeqTrack : TGUID = '{d2ac2886-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicSysExTrack : TGUID = '{d2ac2887-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicTimeSigTrack : TGUID = '{d2ac2888-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicStyle : TGUID = '{d2ac288a-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicChordTrack : TGUID = '{d2ac288b-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicCommandTrack : TGUID = '{d2ac288c-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicStyleTrack : TGUID = '{d2ac288d-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicMotifTrack : TGUID = '{d2ac288e-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicChordMap : TGUID = '{d2ac288f-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicComposer : TGUID = '{d2ac2890-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicSignPostTrack : TGUID = '{f17e8672-c3b4-11d1-870b-00600893b1bd}';
CLSID_DirectMusicLoader : TGUID = '{d2ac2892-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicBandTrack : TGUID = '{d2ac2894-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicBand : TGUID = '{79ba9e00-b6ee-11d1-86be-00c04fbf8fef}';
CLSID_DirectMusicChordMapTrack : TGUID = '{d2ac2896-b39b-11d1-8704-00600893b1bd}';
CLSID_DirectMusicMuteTrack : TGUID = '{d2ac2898-b39b-11d1-8704-00600893b1bd}';
// CLSID's
CLSID_DirectMusicPerformance : TGUID = '{D2AC2881-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicSegment : TGUID = '{D2AC2882-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicSegmentState : TGUID = '{D2AC2883-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicGraph : TGUID = '{D2AC2884-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicTempoTrack : TGUID = '{D2AC2885-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicSeqTrack : TGUID = '{D2AC2886-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicSysExTrack : TGUID = '{D2AC2887-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicTimeSigTrack : TGUID = '{D2AC2888-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicStyle : TGUID = '{D2AC288A-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicChordTrack : TGUID = '{D2AC288B-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicCommandTrack : TGUID = '{D2AC288C-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicStyleTrack : TGUID = '{D2AC288D-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicMotifTrack : TGUID = '{D2AC288E-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicChordMap : TGUID = '{D2AC288F-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicComposer : TGUID = '{D2AC2890-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicSignPostTrack: TGUID = '{F17E8672-C3B4-11D1-870B-00600893B1BD}';
CLSID_DirectMusicLoader : TGUID = '{D2AC2892-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicBandTrack : TGUID = '{D2AC2894-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicBand : TGUID = '{79BA9E00-B6EE-11D1-86BE-00C04FBF8FEF}';
CLSID_DirectMusicChordMapTrack: TGUID = '{D2AC2896-B39B-11D1-8704-00600893B1BD}';
CLSID_DirectMusicMuteTrack : TGUID = '{D2AC2898-B39B-11D1-8704-00600893B1BD}';
 
(* Special GUID for all object types. This is used by the loader. *)
GUID_DirectMusicAllTypes : TGUID = '{d2ac2893-b39b-11d1-8704-00600893b1bd}';
// Special GUID for all object types. This is used by the loader.
GUID_DirectMusicAllTypes : TGUID = '{D2AC2893-B39B-11D1-8704-00600893B1BD}';
 
(* Notification guids *)
GUID_NOTIFICATION_SEGMENT : TGUID = '{d2ac2899-b39b-11d1-8704-00600893b1bd}';
GUID_NOTIFICATION_PERFORMANCE : TGUID = '{81f75bc5-4e5d-11d2-bcc7-00a0c922e6eb}';
GUID_NOTIFICATION_MEASUREANDBEAT : TGUID = '{d2ac289a-b39b-11d1-8704-00600893b1bd}';
GUID_NOTIFICATION_CHORD : TGUID = '{d2ac289b-b39b-11d1-8704-00600893b1bd}';
GUID_NOTIFICATION_COMMAND : TGUID = '{d2ac289c-b39b-11d1-8704-00600893b1bd}';
// Notification guids
GUID_NOTIFICATION_SEGMENT : TGUID = '{D2AC2899-B39B-11D1-8704-00600893B1BD}';
GUID_NOTIFICATION_PERFORMANCE : TGUID = '{81F75BC5-4E5D-11D2-BCC7-00A0C922E6EB}';
GUID_NOTIFICATION_MEASUREANDBEAT: TGUID = '{D2AC289A-B39B-11D1-8704-00600893B1BD}';
GUID_NOTIFICATION_CHORD : TGUID = '{D2AC289B-B39B-11D1-8704-00600893B1BD}';
GUID_NOTIFICATION_COMMAND : TGUID = '{D2AC289C-B39B-11D1-8704-00600893B1BD}';
 
(* Track param type guids *)
(* Use to get/set a DMUS_COMMAND_PARAM param in the Command track *)
GUID_CommandParam : TGUID = '{d2ac289d-b39b-11d1-8704-00600893b1bd}';
// Track param type guids
// Use to get/set a DMUS_COMMAND_PARAM param in the Command track
GUID_CommandParam : TGUID = '{D2AC289D-B39B-11D1-8704-00600893B1BD}';
 
(* Use to get a DMUS_COMMAND_PARAM_2 param in the Command track *)
GUID_CommandParam2 : TGUID = '{28f97ef7-9538-11d2-97a9-00c04fa36e58}';
// Use to get/set a DMUS_CHORD_PARAM param in the Chord track
GUID_ChordParam : TGUID = '{D2AC289E-B39B-11D1-8704-00600893B1BD}';
 
(* Use to get/set a DMUS_CHORD_PARAM param in the Chord track *)
GUID_ChordParam : TGUID = '{d2ac289e-b39b-11d1-8704-00600893b1bd}';
// Use to get a DMUS_RHYTHM_PARAM param in the Chord track
GUID_RhythmParam : TGUID = '{D2AC289F-B39B-11D1-8704-00600893B1BD}';
 
(* Use to get a DMUS_RHYTHM_PARAM param in the Chord track *)
GUID_RhythmParam : TGUID = '{d2ac289f-b39b-11d1-8704-00600893b1bd}';
// Use to get/set an IDirectMusicStyle param in the Style track
GUID_IDirectMusicStyle : TGUID = '{D2AC28A1-B39B-11D1-8704-00600893B1BD}';
 
(* Use to get/set an IDirectMusicStyle param in the Style track *)
GUID_IDirectMusicStyle : TGUID = '{d2ac28a1-b39b-11d1-8704-00600893b1bd}';
// Use to get a DMUS_TIMESIGNATURE param in the Style and TimeSig tracks
GUID_TimeSignature : TGUID = '{D2AC28A4-B39B-11D1-8704-00600893B1BD}';
 
(* Use to get a DMUS_TIMESIGNATURE param in the Style and TimeSig tracks *)
GUID_TimeSignature : TGUID = '{d2ac28a4-b39b-11d1-8704-00600893b1bd}';
// Use to get/set a DMUS_TEMPO_PARAM param in the Tempo track
GUID_TempoParam : TGUID = '{D2AC28A5-B39B-11D1-8704-00600893B1BD}';
 
(* Use to get/set a DMUS_TEMPO_PARAM param in the Tempo track *)
GUID_TempoParam : TGUID = '{d2ac28a5-b39b-11d1-8704-00600893b1bd}';
// Use to set an IDirectMusicBand param in the Band track
GUID_IDirectMusicBand : TGUID = '{D2AC28AC-B39B-11D1-8704-00600893B1BD}';
 
(* Use to set an IDirectMusicBand param in the Band track *)
GUID_IDirectMusicBand : TGUID = '{d2ac28ac-b39b-11d1-8704-00600893b1bd}';
// Use to get/set an IDirectMusicChordMap param in the ChordMap track
GUID_IDirectMusicChordMap : TGUID = '{D2AC28AD-B39B-11D1-8704-00600893B1BD}';
 
(* Use to get/set an IDirectMusicChordMap param in the ChordMap track *)
GUID_IDirectMusicChordMap : TGUID = '{d2ac28ad-b39b-11d1-8704-00600893b1bd}';
// Use to get/set a DMUS_MUTE_PARAM param in the Mute track
GUID_MuteParam : TGUID = '{D2AC28AF-B39B-11D1-8704-00600893B1BD}';
 
(* Use to get/set a DMUS_MUTE_PARAM param in the Mute track *)
GUID_MuteParam : TGUID = '{d2ac28af-b39b-11d1-8704-00600893b1bd}';
// These guids are used in IDirectMusicSegment::SetParam to tell the band track to perform various actions.
///
/// Download bands for the IDirectMusicSegment
GUID_Download : TGUID = '{D2AC28A7-B39B-11D1-8704-00600893B1BD}';
 
(* These guids are used in IDirectMusicSegment::SetParam to tell the band track to perform various actions.
*)
(* Download bands for the IDirectMusicSegment *)
GUID_Download : TGUID = '{d2ac28a7-b39b-11d1-8704-00600893b1bd}';
// Unload bands for the IDirectMusicSegment
GUID_Unload : TGUID = '{D2AC28A8-B39B-11D1-8704-00600893B1BD}';
 
(* Unload bands for the IDirectMusicSegment *)
GUID_Unload : TGUID = '{d2ac28a8-b39b-11d1-8704-00600893b1bd}';
// Connect segment's bands to an IDirectMusicCollection
GUID_ConnectToDLSCollection : TGUID = '{1DB1AE6B-E92E-11D1-A8C5-00C04FA3726E}';
 
(* Connect segment's bands to an IDirectMusicCollection *)
GUID_ConnectToDLSCollection : TGUID = '{1db1ae6b-e92e-11d1-a8c5-00c04fa3726e}';
// Enable/disable autodownloading of bands
GUID_Enable_Auto_Download : TGUID = '{D2AC28A9-B39B-11D1-8704-00600893B1BD}';
GUID_Disable_Auto_Download : TGUID = '{D2AC28AA-B39B-11D1-8704-00600893B1BD}';
 
(* Enable/disable autodownloading of bands *)
GUID_Enable_Auto_Download : TGUID = '{d2ac28a9-b39b-11d1-8704-00600893b1bd}';
GUID_Disable_Auto_Download : TGUID = '{d2ac28aa-b39b-11d1-8704-00600893b1bd}';
// Clear all bands
GUID_Clear_All_Bands : TGUID = '{D2AC28AB-B39B-11D1-8704-00600893B1BD}';
 
(* Clear all bands *)
GUID_Clear_All_Bands : TGUID = '{d2ac28ab-b39b-11d1-8704-00600893b1bd}';
// Set segment to manage all program changes, bank selects, etc. for simple playback of a standard MIDI file
GUID_StandardMIDIFile : TGUID = '{06621075-E92E-11D1-A8C5-00C04FA3726E}';
// For compatibility with beta releases...
GUID_IgnoreBankSelectForGM : TGUID = '{06621075-E92E-11D1-A8C5-00C04FA3726E}'; //same as GUID_StandardMIDIFile;
 
(* Set segment to manage all program changes, bank selects, etc. for simple playback of a standard MIDI file *)
_GUID_StandardMIDIFile = '{06621075-e92e-11d1-a8c5-00c04fa3726e}';
GUID_StandardMIDIFile : TGUID = _GUID_StandardMIDIFile;
(* For compatibility with beta releases... *)
GUID_IgnoreBankSelectForGM : TGUID = _GUID_StandardMIDIFile;
// Disable/enable param guids. Use these in SetParam calls to disable or enable sending
// specific PMsg types.
///
GUID_DisableTimeSig : TGUID = '{45FC707B-1DB4-11D2-BCAC-00A0C922E6EB}';
GUID_EnableTimeSig : TGUID = '{45FC707C-1DB4-11D2-BCAC-00A0C922E6EB}';
GUID_DisableTempo : TGUID = '{45FC707D-1DB4-11D2-BCAC-00A0C922E6EB}';
GUID_EnableTempo : TGUID = '{45FC707E-1DB4-11D2-BCAC-00A0C922E6EB}';
 
(* Disable/enable param guids. Use these in SetParam calls to disable or enable sending
* specific PMsg types.
*)
GUID_DisableTimeSig : TGUID = '{45fc707b-1db4-11d2-bcac-00a0c922e6eb}';
GUID_EnableTimeSig : TGUID = '{45fc707c-1db4-11d2-bcac-00a0c922e6eb}';
GUID_DisableTempo : TGUID = '{45fc707d-1db4-11d2-bcac-00a0c922e6eb}';
GUID_EnableTempo : TGUID = '{45fc707e-1db4-11d2-bcac-00a0c922e6eb}';
// Global data guids
GUID_PerfMasterTempo : TGUID = '{D2AC28B0-B39B-11D1-8704-00600893B1BD}';
GUID_PerfMasterVolume : TGUID = '{D2AC28B1-B39B-11D1-8704-00600893B1BD}';
GUID_PerfMasterGrooveLevel : TGUID = '{D2AC28B2-B39B-11D1-8704-00600893B1BD}';
GUID_PerfAutoDownload : TGUID = '{FB09565B-3631-11D2-BCB8-00A0C922E6EB}';
 
(* Used in SetParam calls for pattern-based tracks. A nonzero value seeds the random number
generator for variation selection; a value of zero reverts to the default behavior of
getting the seed from the system clock.
*)
GUID_SeedVariations : TGUID = '{65b76fa5-ff37-11d2-814e-00c04fa36e58}';
// GUID for default GM/GS dls collection.
GUID_DefaultGMCollection : TGUID = '{F17E8673-C3B4-11D1-870B-00600893B1BD}';
(* Global data guids *)
GUID_PerfMasterTempo : TGUID = '{d2ac28b0-b39b-11d1-8704-00600893b1bd}';
GUID_PerfMasterVolume : TGUID = '{d2ac28b1-b39b-11d1-8704-00600893b1bd}';
GUID_PerfMasterGrooveLevel : TGUID = '{d2ac28b2-b39b-11d1-8704-00600893b1bd}';
GUID_PerfAutoDownload : TGUID = '{fb09565b-3631-11d2-bcb8-00a0c922e6eb}';
// IID's
IID_IDirectMusicLoader : TGUID = '{2FFAACA2-5DCA-11D2-AFA6-00AA0024D8B6}';
IID_IDirectMusicGetLoader : TGUID = '{68A04844-D13D-11D1-AFA6-00AA0024D8B6}';
IID_IDirectMusicObject : TGUID = '{D2AC28B5-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicSegment : TGUID = '{F96029A2-4282-11D2-8717-00600893B1BD}';
IID_IDirectMusicSegmentState : TGUID = '{A3AFDCC7-D3EE-11D1-BC8D-00A0C922E6EB}';
IID_IDirectMusicTrack : TGUID = '{F96029A1-4282-11D2-8717-00600893B1BD}';
IID_IDirectMusicPerformance : TGUID = '{07D43D03-6523-11D2-871D-00600893B1BD}';
IID_IDirectMusicTool : TGUID = '{D2AC28BA-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicGraph : TGUID = '{2BEFC277-5497-11D2-BCCB-00A0C922E6EB}';
IID_IDirectMusicStyle : TGUID = '{D2AC28BD-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicChordMap : TGUID = '{D2AC28BE-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicComposer : TGUID = '{D2AC28BF-B39B-11D1-8704-00600893B1BD}';
IID_IDirectMusicBand : TGUID = '{D2AC28C0-B39B-11D1-8704-00600893B1BD}';
 
(* GUID for default GM/GS dls collection. *)
GUID_DefaultGMCollection : TGUID = '{f17e8673-c3b4-11d1-870b-00600893b1bd}';
// Alternate interface IDs, available in DX7 release and after.
IID_IDirectMusicPerformance2 : TGUID = '{6FC2CAE0-BC78-11D2-AFA6-00AA0024D8B6}';
IID_IDirectMusicSegment2 : TGUID = '{D38894D1-C052-11D2-872F-00600893B1BD}';
 
type
(* IID's *)
IID_IDirectMusicLoader = IDirectMusicLoader;
IID_IDirectMusicGetLoader = IDirectMusicGetLoader;
IID_IDirectMusicObject = IDirectMusicObject;
IID_IDirectMusicSegment = IDirectMusicSegment;
IID_IDirectMusicSegmentState = IDirectMusicSegmentState;
IID_IDirectMusicTrack = IDirectMusicTrack;
IID_IDirectMusicPerformance = IDirectMusicPerformance;
IID_IDirectMusicTool = IDirectMusicTool;
IID_IDirectMusicGraph = IDirectMusicGraph;
IID_IDirectMusicStyle = IDirectMusicStyle;
IID_IDirectMusicChordMap = IDirectMusicChordMap;
IID_IDirectMusicComposer = IDirectMusicComposer;
IID_IDirectMusicBand = IDirectMusicBand;
 
//***********************************************************************
// *
// dmusicf.h -- This module defines the DirectMusic file formats *
// *
// Copyright (c) 1998, Microsoft Corp. All rights reserved. *
// *
//**********************************************************************
// Common chunks
const
(* Alternate interface IDs, available in DX7 release and after. *)
IID_IDirectMusicPerformance2 : TGUID = '{6fc2cae0-bc78-11d2-afa6-00aa0024d8b6}';
IID_IDirectMusicSegment2 : TGUID = '{d38894d1-c052-11d2-872f-00600893b1bd}';
DMUS_FOURCC_GUID_CHUNK = Ord('g') + Ord('u') shl 8 + Ord('i') shl 16 + Ord('d') shl 24;
DMUS_FOURCC_INFO_LIST = Ord('I') + Ord('N') shl 8 + Ord('F') shl 16 + Ord('O') shl 24;
DMUS_FOURCC_UNFO_LIST = Ord('U') + Ord('N') shl 8 + Ord('F') shl 16 + Ord('O') shl 24;
DMUS_FOURCC_UNAM_CHUNK = Ord('U') + Ord('N') shl 8 + Ord('A') shl 16 + Ord('M') shl 24;
DMUS_FOURCC_UART_CHUNK = Ord('U') + Ord('A') shl 8 + Ord('R') shl 16 + Ord('T') shl 24;
DMUS_FOURCC_UCOP_CHUNK = Ord('U') + Ord('C') shl 8 + Ord('O') shl 16 + Ord('P') shl 24;
DMUS_FOURCC_USBJ_CHUNK = Ord('U') + Ord('S') shl 8 + Ord('B') shl 16 + Ord('J') shl 24;
DMUS_FOURCC_UCMT_CHUNK = Ord('U') + Ord('C') shl 8 + Ord('M') shl 16 + Ord('T') shl 24;
DMUS_FOURCC_CATEGORY_CHUNK = Ord('c') + Ord('a') shl 8 + Ord('t') shl 16 + Ord('g') shl 24;
DMUS_FOURCC_VERSION_CHUNK = Ord('v') + Ord('e') shl 8 + Ord('r') shl 16 + Ord('s') shl 24;
 
(************************************************************************
* *
* dmusicf.h -- This module defines the DirectMusic file formats *
* *
* Copyright (c) 1998, Microsoft Corp. All rights reserved. *
* *
************************************************************************)
// The following structures are used by the Tracks, and are the packed structures
// that are passed to the Tracks inside the IStream.
 
//type IDirectMusicCollection = interface;
 
const
(* Common chunks *)
 
DMUS_FOURCC_GUID_CHUNK : mmioFOURCC = ('g','u','i','d');
DMUS_FOURCC_INFO_LIST : mmioFOURCC = ('I','N','F','O');
DMUS_FOURCC_UNFO_LIST : mmioFOURCC = ('U','N','F','O');
DMUS_FOURCC_UNAM_CHUNK : mmioFOURCC = ('U','N','A','M');
DMUS_FOURCC_UART_CHUNK : mmioFOURCC = ('U','A','R','T');
DMUS_FOURCC_UCOP_CHUNK : mmioFOURCC = ('U','C','O','P');
DMUS_FOURCC_USBJ_CHUNK : mmioFOURCC = ('U','S','B','J');
DMUS_FOURCC_UCMT_CHUNK : mmioFOURCC = ('U','C','M','T');
DMUS_FOURCC_CATEGORY_CHUNK : mmioFOURCC = ('c','a','t','g');
DMUS_FOURCC_VERSION_CHUNK : mmioFOURCC = ('v','e','r','s');
 
(* The following structures are used by the Tracks, and are the packed structures *)
(* that are passed to the Tracks inside the IStream. *)
 
type
TDMus_IO_Seq_Item = packed record
mtTime: TMusic_Time;
mtDuration: TMusic_Time;
TDMUS_IO_SEQ_ITEM = record
mtTime : MUSIC_TIME;
mtDuration : MUSIC_TIME;
dwPChannel: DWORD;
nOffset: SmallInt;
bStatus: BYTE;
bByte1: BYTE;
bByte2: BYTE;
nOffset : Smallint;
bStatus : Byte;
bByte1 : Byte;
bByte2 : Byte;
end;
DMUS_IO_SEQ_ITEM = TDMUS_IO_SEQ_ITEM;
 
TDMus_IO_Curve_Item = packed record
mtStart: TMusic_Time;
mtDuration: TMusic_Time;
mtResetDuration: TMusic_Time;
 
TDMUS_IO_CURVE_ITEM = record
mtStart : MUSIC_TIME;
mtDuration : MUSIC_TIME;
mtResetDuration : MUSIC_TIME;
dwPChannel: DWORD;
nOffset: SmallInt;
nStartValue: SmallInt;
nEndValue: SmallInt;
nResetValue: SmallInt;
bType: BYTE;
bCurveShape: BYTE;
bCCData: BYTE;
bFlags: BYTE;
nOffset : Smallint;
nStartValue : Smallint;
nEndValue : Smallint;
nResetValue : Smallint;
bType : Byte;
bCurveShape : Byte;
bCCData : Byte;
bFlags : Byte;
end;
DMUS_IO_CURVE_ITEM = TDMUS_IO_CURVE_ITEM;
 
TDMus_IO_Tempo_Item = packed record
lTime: TMusic_Time;
dblTempo: double;
 
TDMUS_IO_TEMPO_ITEM = record
lTime : MUSIC_TIME;
dblTempo : Double;
end;
DMUS_IO_TEMPO_ITEM = TDMUS_IO_TEMPO_ITEM;
 
TDMus_IO_SysEx_Item = packed record
mtTime: TMusic_Time;
 
TDMUS_IO_SYSEX_ITEM = record
mtTime : MUSIC_TIME;
dwPChannel: DWORD;
dwSysExLength: DWORD;
end;
DMUS_IO_SYSEX_ITEM = TDMUS_IO_SYSEX_ITEM;
 
TDMus_IO_TimeSignature_Item = packed record
lTime: TMusic_Time;
bBeatsPerMeasure: BYTE; (* beats per measure (top of time sig) *)
bBeat: BYTE; (* what note receives the beat (bottom of time sig.) *)
(* we can assume that 0 means 256th note *)
wGridsPerBeat: WORD; (* grids per beat *)
end;
 
(* PARAM structures, used by GetParam() and SetParam() *)
TDMus_Command_Param = packed record
bCommand: BYTE;
bGrooveLevel: BYTE;
bGrooveRange: BYTE;
TDMUS_IO_TIMESIGNATURE_ITEM = record
lTime : MUSIC_TIME;
bBeatsPerMeasure : Byte; // beats per measure (top of time sig)
bBeat : Byte; // what note receives the beat (bottom of time sig.)
// we can assume that 0 means 256th note
wGridsPerBeat : Word; // grids per beat
end;
DMUS_IO_TIMESIGNATURE_ITEM = TDMUS_IO_TIMESIGNATURE_ITEM;
 
TDMus_Command_Param_2 = packed record
mtTime : TMusic_Time;
bCommand: BYTE;
bGrooveLevel: BYTE;
bGrooveRange: BYTE;
// PARAM structures, used by GetParam() and SetParam()
TDMUS_COMMAND_PARAM = record
bCommand : Byte;
bGrooveLevel : Byte;
bGrooveRange : Byte;
end;
DMUS_COMMAND_PARAM = TDMUS_COMMAND_PARAM;
 
TDMus_Chord_Param = TDMus_Chord_Key; (* DMUS_CHORD_KEY defined in dmusici.h *)
//DMUS_CHORD_KEY = DMUS_CHORD_PARAM; // DMUS_CHORD_KEY defined in dmusici.h
 
TDMus_Rhythm_Param = packed record
TimeSig: TDMus_TimeSignature;
TDMUS_RHYTHM_PARAM = record
TimeSig : TDMUS_TIMESIGNATURE;
dwRhythmPattern: DWORD;
end;
DMUS_RHYTHM_PARAM = TDMUS_RHYTHM_PARAM;
 
TDMus_Tempo_Param = packed record
mtTime: TMusic_Time;
dblTempo: double;
TDMUS_TEMPO_PARAM = record
mtTime : MUSIC_TIME;
dblTempo : Double;
end;
DMUS_TEMPO_PARAM = TDMUS_TEMPO_PARAM;
 
TDMus_Mute_Param = packed record
 
TDMUS_MUTE_PARAM = record
dwPChannel: DWORD;
dwPChannelMap: DWORD;
fMute: BOOL;
end;
DMUS_MUTE_PARAM = TDMUS_MUTE_PARAM;
 
const
(* Style chunks *)
// Style chunks
 
DMUS_FOURCC_STYLE_FORM : mmioFOURCC = ('D','M','S','T');
DMUS_FOURCC_STYLE_CHUNK : mmioFOURCC = ('s','t','y','h');
DMUS_FOURCC_PART_LIST : mmioFOURCC = ('p','a','r','t');
DMUS_FOURCC_PART_CHUNK : mmioFOURCC = ('p','r','t','h');
DMUS_FOURCC_NOTE_CHUNK : mmioFOURCC = ('n','o','t','e');
DMUS_FOURCC_CURVE_CHUNK : mmioFOURCC = ('c','r','v','e');
DMUS_FOURCC_PATTERN_LIST : mmioFOURCC = ('p','t','t','n');
DMUS_FOURCC_PATTERN_CHUNK : mmioFOURCC = ('p','t','n','h');
DMUS_FOURCC_RHYTHM_CHUNK : mmioFOURCC = ('r','h','t','m');
DMUS_FOURCC_PARTREF_LIST : mmioFOURCC = ('p','r','e','f');
DMUS_FOURCC_PARTREF_CHUNK : mmioFOURCC = ('p','r','f','c');
DMUS_FOURCC_STYLE_PERS_REF_LIST : mmioFOURCC = ('p', 'r', 'r', 'f');
DMUS_FOURCC_MOTIFSETTINGS_CHUNK : mmioFOURCC = ('m', 't', 'f', 's');
DMUS_FOURCC_STYLE_FORM = Ord('D') + Ord('M') shl 8 + Ord('S') shl 16 + Ord('T') shl 24;
DMUS_FOURCC_STYLE_CHUNK = Ord('s') + Ord('t') shl 8 + Ord('y') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_PART_LIST = Ord('p') + Ord('a') shl 8 + Ord('r') shl 16 + Ord('t') shl 24;
DMUS_FOURCC_PART_CHUNK = Ord('p') + Ord('r') shl 8 + Ord('t') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_NOTE_CHUNK = Ord('n') + Ord('o') shl 8 + Ord('t') shl 16 + Ord('e') shl 24;
DMUS_FOURCC_CURVE_CHUNK = Ord('c') + Ord('r') shl 8 + Ord('v') shl 16 + Ord('e') shl 24;
DMUS_FOURCC_PATTERN_LIST = Ord('p') + Ord('t') shl 8 + Ord('t') shl 16 + Ord('n') shl 24;
DMUS_FOURCC_PATTERN_CHUNK = Ord('p') + Ord('t') shl 8 + Ord('n') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_RHYTHM_CHUNK = Ord('r') + Ord('h') shl 8 + Ord('t') shl 16 + Ord('m') shl 24;
DMUS_FOURCC_PARTREF_LIST = Ord('p') + Ord('r') shl 8 + Ord('e') shl 16 + Ord('f') shl 24;
DMUS_FOURCC_PARTREF_CHUNK = Ord('p') + Ord('r') shl 8 + Ord('f') shl 16 + Ord('c') shl 24;
DMUS_FOURCC_STYLE_PERS_REF_LIST = Ord('p') + Ord('r') shl 8 + Ord('r') shl 16 + Ord('f') shl 24;
DMUS_FOURCC_MOTIFSETTINGS_CHUNK = Ord('m') + Ord('t') shl 8 + Ord('f') shl 16 + Ord('s') shl 24;
 
(* Flags used by variations: these make up the DWORDs in dwVariationChoices. *)
// Flags used by variations: these make up the DWORDs in dwVariationChoices.
 
(* These flags determine the types of chords supported by a given variation in DirectMusic *)
(* mode. The first seven flags (bits 1-7) are set if the variation supports major chords *)
(* rooted in scale positions, so, e.g., if bits 1, 2, and 4 are set, the variation *)
(* supports major chords rooted in the tonic, second, and fourth scale positions. The *)
(* next seven flags serve the same purpose, but for minor chords, and the following seven *)
(* flags serve the same purpose for chords that are not major or minor (e.g., SUS 4 *)
(* chords). Bits 22, 23, and 24 are set if the variation supports chords rooted in the *)
(* scale, chords rooted sharp of scale tones, and chords rooted flat of scale tones, *)
(* respectively. For example, to support a C# minor chord in the scale of C Major, *)
(* bits 8 (for tonic minor) and 24 (for sharp) need to be set. Bits 25, 26, an 27 handle *)
(* chords that are triads, 6th or 7th chords, and chords with extensions, respectively. *)
(* bits 28 and 29 handle chords that are followed by tonic and dominant chords, *)
(* respectively. *)
DMUS_VARIATIONF_MAJOR = $0000007F; (* Seven positions in the scale - major chords. *)
DMUS_VARIATIONF_MINOR = $00003F80; (* Seven positions in the scale - minor chords. *)
DMUS_VARIATIONF_OTHER = $001FC000; (* Seven positions in the scale - other chords. *)
DMUS_VARIATIONF_ROOT_SCALE = $00200000; (* Handles chord roots in the scale. *)
DMUS_VARIATIONF_ROOT_FLAT = $00400000; (* Handles flat chord roots (based on scale notes). *)
DMUS_VARIATIONF_ROOT_SHARP = $00800000; (* Handles sharp chord roots (based on scale notes). *)
DMUS_VARIATIONF_TYPE_TRIAD = $01000000; (* Handles simple chords - triads. *)
DMUS_VARIATIONF_TYPE_6AND7 = $02000000; (* Handles simple chords - 6 and 7. *)
DMUS_VARIATIONF_TYPE_COMPLEX = $04000000; (* Handles complex chords. *)
DMUS_VARIATIONF_DEST_TO1 = $08000000; (* Handles transitions to 1 chord. *)
DMUS_VARIATIONF_DEST_TO5 = $10000000; (* Handles transitions to 5 chord. *)
// These flags determine the types of chords supported by a given variation in DirectMusic
// mode. The first seven flags (bits 1-7) are set if the variation supports major chords
// rooted in scale positions, so, e.g., if bits 1, 2, and 4 are set, the variation
// supports major chords rooted in the tonic, second, and fourth scale positions. The
// next seven flags serve the same purpose, but for minor chords, and the following seven
// flags serve the same purpose for chords that are not major or minor (e.g., SUS 4
// chords). Bits 22, 23, and 24 are set if the variation supports chords rooted in the
// scale, chords rooted sharp of scale tones, and chords rooted flat of scale tones,
// respectively. For example, to support a C# minor chord in the scale of C Major,
// bits 8 (for tonic minor) and 24 (for sharp) need to be set. Bits 25, 26, an 27 handle
// chords that are triads, 6th or 7th chords, and chords with extensions, respectively.
// bits 28 and 29 handle chords that are followed by tonic and dominant chords,
// respectively.
DMUS_VARIATIONF_MAJOR = $0000007F; // Seven positions in the scale - major chords.
DMUS_VARIATIONF_MINOR = $00003F80; // Seven positions in the scale - minor chords.
DMUS_VARIATIONF_OTHER = $001FC000; // Seven positions in the scale - other chords.
DMUS_VARIATIONF_ROOT_SCALE = $00200000; // Handles chord roots in the scale.
DMUS_VARIATIONF_ROOT_FLAT = $00400000; // Handles flat chord roots (based on scale notes).
DMUS_VARIATIONF_ROOT_SHARP = $00800000; // Handles sharp chord roots (based on scale notes).
DMUS_VARIATIONF_TYPE_TRIAD = $01000000; // Handles simple chords - triads.
DMUS_VARIATIONF_TYPE_6AND7 = $02000000; // Handles simple chords - 6 and 7.
DMUS_VARIATIONF_TYPE_COMPLEX= $04000000; // Handles complex chords.
DMUS_VARIATIONF_DEST_TO1 = $08000000; // Handles transitions to 1 chord.
DMUS_VARIATIONF_DEST_TO5 = $10000000; // Handles transitions to 5 chord.
 
(* The top three bits of the variation flags are the Mode bits. If all are 0, it's IMA. *)
(* If the smallest is 1, it's Direct Music. *)
// The top three bits of the variation flags are the Mode bits. If all are 0, it's IMA.
// If the smallest is 1, it's Direct Music.
DMUS_VARIATIONF_MODES = $E0000000;
DMUS_VARIATIONF_IMA25_MODE = $00000000;
DMUS_VARIATIONF_DMUS_MODE = $20000000;
 
//#pragma pack(2)
 
type BYTE2 = Word;
 
type
TDMus_IO_TimeSig = packed record
(* Time signatures define how many beats per measure, which note receives *)
(* the beat, and the grid resolution. *)
bBeatsPerMeasure: BYTE2; (* beats per measure (top of time sig) *)
bBeat: BYTE2; (* what note receives the beat (bottom of time sig.) *)
(* we can assume that 0 means 256th note *)
wGridsPerBeat: WORD; (* grids per beat *)
TDMUS_IO_TIMESIG = record
// Time signatures define how many beats per measure, which note receives
// the beat, and the grid resolution.
bBeatsPerMeasure : Byte; // beats per measure (top of time sig)
bBeat : Byte; // what note receives the beat (bottom of time sig.)
// we can assume that 0 means 256th note
wGridsPerBeat : Word; // grids per beat
end;
DMUS_IO_TIMESIG = TDMUS_IO_TIMESIG;
 
TDMus_IO_Style = packed record
timeSig: TDMus_IO_TimeSig; (* Styles have a default Time Signature *)
dblTempo: double;
TDMUS_IO_STYLE = record
timeSig : TDMUS_IO_TIMESIG; // Styles have a default Time Signature
dblTempo: Double;
end;
DMUS_IO_STYLE = TDMUS_IO_STYLE;
 
TDMus_IO_Version = packed record
dwVersionMS: DWORD; (* Version # high-order 32 bits *)
dwVersionLS: DWORD; (* Version # low-order 32 bits *)
TDMUS_IO_VERSION = record
dwVersionMS : DWORD; // Version # high-order 32 bits
dwVersionLS : DWORD; // Version # low-order 32 bits
end;
DMUS_IO_VERSION = TDMUS_IO_VERSION;
 
TDMus_IO_Pattern = packed record
timeSig: TDMus_IO_TimeSig; (* Patterns can override the Style's Time sig. *)
bGrooveBottom: BYTE2; (* bottom of groove range *)
bGrooveTop: BYTE2; (* top of groove range *)
wEmbellishment: WORD; (* Fill, Break, Intro, End, Normal, Motif *)
wNbrMeasures: WORD; (* length in measures *)
TDMUS_IO_PATTERN = record
timeSig : TDMUS_IO_TIMESIG; // Patterns can override the Style's Time sig.
bGrooveBottom : Byte; // bottom of groove range
bGrooveTop : Byte; // top of groove range
wEmbellishment : Word; // Fill, Break, Intro, End, Normal, Motif
wNbrMeasures : Word; // length in measures
end;
DMUS_IO_PATTERN = TDMUS_IO_PATTERN;
 
TDMus_IO_StylePart = packed record
timeSig: TDMus_IO_TimeSig; (* can override pattern's *)
dwVariationChoices: array [0..31] of DWORD; (* MOAW choice bitfield *)
guidPartID: TGUID; (* identifies the part *)
wNbrMeasures: WORD; (* length of the Part *)
bPlayModeFlags: BYTE2; (* see PLAYMODE flags *)
bInvertUpper: BYTE2; (* inversion upper limit *)
bInvertLower: BYTE2; (* inversion lower limit *)
TDMUS_IO_STYLEPART = record
timeSig : TDMUS_IO_TIMESIG; // can override pattern's
dwVariationChoices : array[0..31] of DWORD; // MOAW choice bitfield
guidPartID : TGUID; // identifies the part
wNbrMeasures : Word; // length of the Part
bPlayModeFlags : Byte; // see PLAYMODE flags
bInvertUpper : Byte; // inversion upper limit
bInvertLower : Byte; // inversion lower limit
end;
DMUS_IO_STYLEPART = TDMUS_IO_STYLEPART;
 
TDMus_IO_PartRef = packed record
guidPartID: TGUID; (* unique ID for matching up with parts *)
wLogicalPartID: WORD; (* corresponds to port/device/midi channel *)
bVariationLockID: BYTE2; (* parts with the same ID lock variations. *)
(* high bit is used to identify master Part *)
bSubChordLevel: BYTE2; (* tells which sub chord level this part wants *)
bPriority: BYTE2; (* 256 priority levels. Parts with lower priority *)
(* aren't played first when a device runs out of *)
(* notes *)
bRandomVariation: BYTE2; (* when set, matching variations play in random order *)
(* when clear, matching variations play sequentially *)
TDMUS_IO_PARTREF = record
guidPartID : TGUID; // unique ID for matching up with parts
wLogicalPartID : Word; // corresponds to port/device/midi channel
bVariationLockID : Byte; // parts with the same ID lock variations.
// high bit is used to identify master Part
bSubChordLevel : Byte; // tells which sub chord level this part wants
bPriority : Byte; // 256 priority levels. Parts with lower priority
// aren't played first when a device runs out of
// notes
bRandomVariation : Byte; // when set, matching variations play in random order
// when clear, matching variations play sequentially
end;
DMUS_IO_PARTREF = TDMUS_IO_PARTREF;
 
TDMus_IO_StyleNote = packed record
mtGridStart: TMusic_Time ;(* when this note occurs *)
dwVariation: DWORD; (* variation bits *)
mtDuration: TMusic_Time; (* how long this note lasts *)
nTimeOffset: SmallInt; (* offset from mtGridStart *)
wMusicValue: WORD; (* Position in scale. *)
bVelocity: BYTE2; (* Note velocity. *)
bTimeRange: BYTE2; (* Range to randomize start time. *)
bDurRange: BYTE2; (* Range to randomize duration. *)
bVelRange: BYTE2; (* Range to randomize velocity. *)
bInversionID: BYTE2; (* Identifies inversion group to which this note belongs *)
bPlayModeFlags: BYTE2; (* Can override part *)
TDMUS_IO_STYLENOTE = record
mtGridStart : MUSIC_TIME; // when this note occurs
dwVariation : DWORD; // variation bits
mtDuration : MUSIC_TIME; // how long this note lasts
nTimeOffset : Smallint; // offset from mtGridStart
wMusicValue : Word; // Position in scale.
bVelocity : Byte; // Note velocity.
bTimeRange : Byte; // Range to randomize start time.
bDurRange : Byte; // Range to randomize duration.
bVelRange : Byte; // Range to randomize velocity.
bInversionID : Byte; // Identifies inversion group to which this note belongs
bPlayModeFlags : Byte; // Can override part
end;
DMUS_IO_STYLENOTE = TDMUS_IO_STYLENOTE;
 
TDMus_IO_StyleCurve = packed record
mtGridStart: TMusic_Time; (* when this curve occurs *)
dwVariation: DWORD; (* variation bits *)
mtDuration: TMusic_Time; (* how long this curve lasts *)
mtResetDuration: TMusic_Time; (* how long after the end of the curve to reset the curve *)
nTimeOffset: SmallInt; (* offset from mtGridStart *)
nStartValue: SmallInt; (* curve's start value *)
nEndValue: SmallInt; (* curve's end value *)
nResetValue: SmallInt; (* the value to which to reset the curve *)
bEventType: BYTE2; (* type of curve *)
bCurveShape: BYTE2; (* shape of curve *)
bCCData: BYTE2; (* CC# *)
bFlags: BYTE2; (* Bit 1=TRUE means to send nResetValue. Otherwise, don't.
Other bits are reserved. *)
TDMUS_IO_STYLECURVE = record
mtGridStart : MUSIC_TIME;// when this curve occurs
dwVariation : DWORD; // variation bits
mtDuration : MUSIC_TIME;// how long this curve lasts
mtResetDuration : MUSIC_TIME;// how long after the end of the curve to reset the curve
nTimeOffset : Smallint; // offset from mtGridStart
nStartValue : Smallint; // curve's start value
nEndValue : Smallint; // curve's end value
nResetValue : Smallint; // the value to which to reset the curve
bEventType : Byte; // type of curve
bCurveShape : Byte; // shape of curve
bCCData : Byte; // CC#
bFlags : Byte; // Bit 1=TRUE means to send nResetValue. Otherwise, don't.
// Other bits are reserved.
end;
DMUS_IO_STYLECURVE = TDMUS_IO_STYLECURVE;
 
TDMus_IO_MotifSettings = packed record
dwRepeats: DWORD; (* Number of repeats. By default, 0. *)
mtPlayStart: TMusic_Time; (* Start of playback. By default, 0. *)
mtLoopStart: TMusic_Time; (* Start of looping portion. By default, 0. *)
mtLoopEnd: TMusic_Time; (* End of loop. Must be greater than mtLoopStart. By default equal to length of motif. *)
dwResolution: DWORD; (* Default resolution. *)
TDMUS_IO_MOTIFSETTINGS = record
dwRepeats : DWORD; // Number of repeats. By default, 0.
mtPlayStart : MUSIC_TIME; // Start of playback. By default, 0.
mtLoopStart : MUSIC_TIME; // Start of looping portion. By default, 0.
mtLoopEnd : MUSIC_TIME; // End of loop. Must be greater than mtLoopStart. By default equal to length of motif.
dwResolution : DWORD; // Default resolution.
end;
DMUS_IO_MOTIFSETTINGS = TDMUS_IO_MOTIFSETTINGS;
 
//#pragma pack()
 
(*
RIFF
(
'DMST' // Style
<styh-ck> // Style header chunk
<guid-ck> // Every Style has a GUID
[<UNFO-list>] // Name, author, copyright info., comments
[<vers-ck>] // version chunk
<part-list>... // List of parts in the Style, used by patterns
<pttn-list>... // List of patterns in the Style
<DMBD-form>... // List of bands in the Style
[<motf-list>] // List of motifs in the Style
[<prrf-list>] // List of chord map references in the Style
)
const
// Chord and command file formats
 
// <styh-ck>
styh
(
<DMUS_IO_STYLE>
)
DMUS_FOURCC_CHORDTRACK_LIST = Ord('c') + Ord('o') shl 8 + Ord('r') shl 16 + Ord('d') shl 24;
DMUS_FOURCC_CHORDTRACKHEADER_CHUNK = Ord('c') + Ord('r') shl 8 + Ord('d') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_CHORDTRACKBODY_CHUNK = Ord('c') + Ord('r') shl 8 + Ord('d') shl 16 + Ord('b') shl 24;
 
// <guid-ck>
guid
(
<GUID>
)
DMUS_FOURCC_COMMANDTRACK_CHUNK = Ord('c') + Ord('m') shl 8 + Ord('n') shl 16 + Ord('d') shl 24;
 
// <vers-ck>
vers
(
<DMUS_IO_VERSION>
)
 
// <part-list>
LIST
(
'part'
<prth-ck> // Part header chunk
[<UNFO-list>]
[<note-ck>] // List of notes in Part
[<crve-ck>] // List of curves in Part
)
 
// <orth-ck>
prth
(
<DMUS_IO_STYLEPART>
)
 
// <note-ck>
'note'
(
// sizeof DMUS_IO_STYLENOTE:DWORD
<DMUS_IO_STYLENOTE>...
)
 
// <crve-ck>
'crve'
(
// sizeof DMUS_IO_STYLECURVE:DWORD
<DMUS_IO_STYLECURVE>...
)
 
// <pttn-list>
LIST
(
'pttn'
<ptnh-ck> // Pattern header chunk
<rhtm-ck> // List of rhythms for chord matching
[<UNFO-list>]
[<mtfs-ck>] // Motif settings chunk
<pref-list>... // List of part reference id's
)
 
// <ptnh-ck>
ptnh
(
<DMUS_IO_PATTERN>
)
 
// <rhtm-ck>
'rhtm'
(
// DWORD's representing rhythms for chord matching based on number
// of measures in the pattern
)
 
// pref-list
LIST
(
'pref'
<prfc-ck> // part ref chunk
)
 
// <prfc-ck>
prfc
(
<DMUS_IO_PARTREF>
)
 
// <mtfs-ck>
mtfs
(
<DMUS_IO_MOTIFSETTINGS>
)
 
// <prrf-list>
LIST
(
'prrf'
// some number of <DMRF>
)
*)
 
(* Chord and command file formats *)
const
DMUS_FOURCC_CHORDTRACK_LIST : mmioFOURCC = ('c','o','r','d');
DMUS_FOURCC_CHORDTRACKHEADER_CHUNK : mmioFOURCC = ('c','r','d','h');
DMUS_FOURCC_CHORDTRACKBODY_CHUNK : mmioFOURCC = ('c','r','d','b');
 
DMUS_FOURCC_COMMANDTRACK_CHUNK : mmioFOURCC = ('c','m','n','d');
 
type
TDMus_IO_Chord = packed record
wszName: array [0..15] of WCHAR; (* Name of the chord *)
mtTime: TMusic_Time; (* Time of this chord *)
wMeasure: WORD; (* Measure this falls on *)
bBeat: BYTE; (* Beat this falls on *)
TDMUS_IO_CHORD = record
wszName : array[0..15] of WCHAR; // Name of the chord
mtTime : MUSIC_TIME; // Time of this chord
wMeasure : Word; // Measure this falls on
bBeat : Byte; // Beat this falls on
end;
DMUS_IO_CHORD = TDMUS_IO_CHORD;
 
TDMus_IO_SubChord = packed record
dwChordPattern: DWORD; (* Notes in the subchord *)
dwScalePattern: DWORD; (* Notes in the scale *)
dwInversionPoints: DWORD; (* Where inversions can occur *)
dwLevels: DWORD; (* Which levels are supported by this subchord *)
bChordRoot: BYTE; (* Root of the subchord *)
bScaleRoot: BYTE; (* Root of the scale *)
TDMUS_IO_SUBCHORD = record
dwChordPattern : DWORD; // Notes in the subchord
dwScalePattern : DWORD; // Notes in the scale
dwInversionPoints : DWORD; // Where inversions can occur
dwLevels : DWORD; // Which levels are supported by this subchord
bChordRoot : Byte; // Root of the subchord
bScaleRoot : Byte; // Root of the scale
end;
DMUS_IO_SUBCHORD = TDMUS_IO_SUBCHORD;
 
TDMus_IO_Command = packed record
mtTime: TMusic_Time; (* Time of this command *)
wMeasure: WORD; (* Measure this falls on *)
bBeat: BYTE; (* Beat this falls on *)
bCommand: BYTE; (* Command type (see #defines below) *)
bGrooveLevel: BYTE; (* Groove level (0 if command is not a groove) *)
bGrooveRange: BYTE; (* Groove range *)
TDMUS_IO_COMMAND = record
mtTime : MUSIC_TIME; // Time of this command
wMeasure : Word; // Measure this falls on
bBeat : Byte; // Beat this falls on
bCommand : Byte; // Command type (see #defines below)
bGrooveLevel : Byte; // Groove level (0 if command is not a groove)
bGrooveRange : Byte; // Groove range
end;
DMUS_IO_COMMAND = TDMUS_IO_COMMAND;
 
(*
 
// <cord-list>
LIST
(
'cord'
<crdh-ck>
<crdb-ck> // Chord body chunk
)
// File io for DirectMusic Tool and ToolGraph objects
///
 
// <crdh-ck>
crdh
(
// Scale: dword (upper 8 bits for root, lower 24 for scale)
)
const
// RIFF ids:
 
// <crdb-ck>
crdb
(
// sizeof DMUS_IO_CHORD:dword
<DMUS_IO_CHORD>
// # of DMUS_IO_SUBCHORDS:dword
// sizeof DMUS_IO_SUBCHORDS:dword
// a number of <DMUS_IO_SUBCHORD>
)
DMUS_FOURCC_TOOLGRAPH_FORM = Ord('D') + Ord('M') shl 8 + Ord('T') shl 16 + Ord('G') shl 24;
DMUS_FOURCC_TOOL_LIST = Ord('t') + Ord('o') shl 8 + Ord('l') shl 16 + Ord('l') shl 24;
DMUS_FOURCC_TOOL_FORM = Ord('D') + Ord('M') shl 8 + Ord('T') shl 16 + Ord('L') shl 24;
DMUS_FOURCC_TOOL_CHUNK = Ord('t') + Ord('o') shl 8 + Ord('l') shl 16 + Ord('h') shl 24;
 
type
// io structures:
 
// <cmnd-list>
'cmnd'
(
//sizeof DMUS_IO_COMMAND: DWORD
<DMUS_IO_COMMAND>...
)
 
*)
 
(* File io for DirectMusic Tool and ToolGraph objects
*)
 
(* RIFF ids: *)
const
DMUS_FOURCC_TOOLGRAPH_FORM : mmioFOURCC = ('D','M','T','G');
DMUS_FOURCC_TOOL_LIST : mmioFOURCC = ('t','o','l','l');
DMUS_FOURCC_TOOL_FORM : mmioFOURCC = ('D','M','T','L');
DMUS_FOURCC_TOOL_CHUNK : mmioFOURCC = ('t','o','l','h');
 
(* io structures: *)
type
TDMus_IO_Tool_Header = packed record
guidClassID: TGUID; (* Class id of tool. *)
lIndex: LongInt; (* Position in graph. *)
cPChannels: DWORD; (* Number of items in channels array. *)
ckid: TFourCC; (* chunk ID of tool's data chunk if 0 fccType valid. *)
fccType: TFourCC; (* list type if NULL ckid valid. *)
dwPChannels: array [0..0] of DWORD; (* Array of PChannels, size determined by cPChannels. *)
TDMUS_IO_TOOL_HEADER = record
guidClassID : TGUID; // Class id of tool.
lIndex : Longint; // Position in graph.
cPChannels : DWORD; // Number of items in channels array.
ckid : FOURCC; // chunk ID of tool's data chunk if 0 fccType valid.
fccType : FOURCC; // list type if NULL ckid valid.
dwPChannels : array[0..0] of DWORD; // Array of PChannels, size determined by cPChannels.
end;
DMUS_IO_TOOL_HEADER = TDMUS_IO_TOOL_HEADER;
 
(*
RIFF
(
'DMTG' // DirectMusic ToolGraph chunk
[<guid-ck>] // GUID for ToolGraph
[<vers-ck>] // Optional version info
[<UNFO-list>] // Name, author, copyright info., comments
<toll-list> // List of Tools
)
 
// <guid-ck>
'guid'
(
<GUID>
)
// File io for DirectMusic Band Track object
 
// <vers-ck>
vers
(
<DMUS_IO_VERSION>
)
 
// <toll-list>
LIST
(
'toll' // List of tools
<DMTL-form>... // Each tool is encapsulated in a RIFF chunk
)
 
// <DMTL-form> // Tools can be embedded in a graph or stored as separate files.
RIFF
(
'DMTL'
<tolh-ck>
[<guid-ck>] // Optional GUID for tool object instance (not to be confused with Class id in track header)
[<vers-ck>] // Optional version info
[<UNFO-list>] // Optional name, author, copyright info., comments
[<data>] // Tool data. Must be a RIFF readable chunk.
)
 
// <tolh-ck> // Tool header chunk
(
'tolh'
<DMUS_IO_TOOL_HEADER> // Tool header
)
*)
 
(* File io for DirectMusic Band Track object *)
 
 
(* RIFF ids: *)
const
DMUS_FOURCC_BANDTRACK_FORM : mmioFOURCC = ('D','M','B','T');
DMUS_FOURCC_BANDTRACK_CHUNK : mmioFOURCC = ('b','d','t','h');
DMUS_FOURCC_BANDS_LIST : mmioFOURCC = ('l','b','d','l');
DMUS_FOURCC_BAND_LIST : mmioFOURCC = ('l','b','n','d');
DMUS_FOURCC_BANDITEM_CHUNK : mmioFOURCC = ('b','d','i','h');
// RIFF ids:
DMUS_FOURCC_BANDTRACK_FORM = Ord('D') + Ord('M') shl 8 + Ord('B') shl 16 + Ord('T') shl 24;
DMUS_FOURCC_BANDTRACK_CHUNK = Ord('b') + Ord('d') shl 8 + Ord('t') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_BANDS_LIST = Ord('l') + Ord('b') shl 8 + Ord('d') shl 16 + Ord('l') shl 24;
DMUS_FOURCC_BAND_LIST = Ord('l') + Ord('b') shl 8 + Ord('n') shl 16 + Ord('d') shl 24;
DMUS_FOURCC_BANDITEM_CHUNK = Ord('b') + Ord('d') shl 8 + Ord('i') shl 16 + Ord('h') shl 24;
 
type
(* io structures *)
TDMus_IO_Band_Track_Header = packed record
bAutoDownload: BOOL; (* Determines if Auto-Download is enabled. *)
// io structures
TDMUS_IO_BAND_TRACK_HEADER = record
bAutoDownload : BOOL; // Determines if Auto-Download is enabled.
end;
DMUS_IO_BAND_TRACK_HEADER = TDMUS_IO_BAND_TRACK_HEADER;
 
TDMus_IO_Band_Item_Header = packed record
lBandTime: TMusic_Time; (* Position in track list. *)
TDMUS_IO_BAND_ITEM_HEADER = record
lBandTime : MUSIC_TIME; // Position in track list.
end;
DMUS_IO_BAND_ITEM_HEADER = TDMUS_IO_BAND_ITEM_HEADER;
 
(*
RIFF
(
'DMBT' // DirectMusic Band Track form-type
[<bdth-ck>] // Band track header
[<guid-ck>] // GUID for band track
[<vers-ck>] // Optional version info
[<UNFO-list>] // Name, author, copyright info., comments
<lbdl-list> // List of Band Lists
)
 
// <bnth-ck>
'bdth'
(
<DMUS_IO_BAND_TRACK_HEADER>
)
// File io for DirectMusic Band object
///
 
// <guid-ck>
'guid'
(
<GUID>
)
const
// RIFF ids:
 
// <vers-ck>
vers
(
<DMUS_IO_VERSION>
)
DMUS_FOURCC_BAND_FORM = Ord('D') + Ord('M') shl 8 + Ord('B') shl 16 + Ord('D') shl 24;
DMUS_FOURCC_INSTRUMENTS_LIST = Ord('l') + Ord('b') shl 8 + Ord('i') shl 16 + Ord('l') shl 24;
DMUS_FOURCC_INSTRUMENT_LIST = Ord('l') + Ord('b') shl 8 + Ord('i') shl 16 + Ord('n') shl 24;
DMUS_FOURCC_INSTRUMENT_CHUNK = Ord('b') + Ord('i') shl 8 + Ord('n') shl 16 + Ord('s') shl 24;
 
// <lbdl-list>
LIST
(
'lbdl' // List of bands
<lbnd-list> // Each band is encapsulated in a list
)
// Flags for DMUS_IO_INSTRUMENT
///
DMUS_IO_INST_PATCH = (1 shl 0); // dwPatch is valid.
DMUS_IO_INST_BANKSELECT = (1 shl 1); // dwPatch contains a valid Bank Select MSB and LSB part
DMUS_IO_INST_ASSIGN_PATCH = (1 shl 3); // dwAssignPatch is valid
DMUS_IO_INST_NOTERANGES = (1 shl 4); // dwNoteRanges is valid
DMUS_IO_INST_PAN = (1 shl 5); // bPan is valid
DMUS_IO_INST_VOLUME = (1 shl 6); // bVolume is valid
DMUS_IO_INST_TRANSPOSE = (1 shl 7); // nTranspose is valid
DMUS_IO_INST_GM = (1 shl 8); // Instrument is from GM collection
DMUS_IO_INST_GS = (1 shl 9); // Instrument is from GS collection
DMUS_IO_INST_XG = (1 shl 10); // Instrument is from XG collection
DMUS_IO_INST_CHANNEL_PRIORITY = (1 shl 11); // dwChannelPriority is valid
DMUS_IO_INST_USE_DEFAULT_GM_SET = (1 shl 12); // Always use the default GM set for this patch,
// don't rely on the synth caps stating GM or GS in hardware.
 
// <lbnd-list>
LIST
(
'lbnd'
<bdih-ck>
<DMBD-form> // Band
)
 
// <bdih-ck> // band item header
(
<DMUS_IO_BAND_ITEM_HEADER> // Band item header
)
*)
 
 
(* File io for DirectMusic Band object
*)
 
(* RIFF ids: *)
const
DMUS_FOURCC_BAND_FORM : mmioFOURCC = ('D','M','B','D');
DMUS_FOURCC_INSTRUMENTS_LIST : mmioFOURCC = ('l','b','i','l');
DMUS_FOURCC_INSTRUMENT_LIST : mmioFOURCC = ('l','b','i','n');
DMUS_FOURCC_INSTRUMENT_CHUNK : mmioFOURCC = ('b','i','n','s');
 
(* Flags for DMUS_IO_INSTRUMENT
*)
DMUS_IO_INST_PATCH = (1 shl 0); (* dwPatch is valid. *)
DMUS_IO_INST_BANKSELECT = (1 shl 1); (* dwPatch contains a valid Bank Select MSB and LSB part *)
DMUS_IO_INST_ASSIGN_PATCH = (1 shl 3); (* dwAssignPatch is valid *)
DMUS_IO_INST_NOTERANGES = (1 shl 4); (* dwNoteRanges is valid *)
DMUS_IO_INST_PAN = (1 shl 5); (* bPan is valid *)
DMUS_IO_INST_VOLUME = (1 shl 6); (* bVolume is valid *)
DMUS_IO_INST_TRANSPOSE = (1 shl 7); (* nTranspose is valid *)
DMUS_IO_INST_GM = (1 shl 8); (* Instrument is from GM collection *)
DMUS_IO_INST_GS = (1 shl 9); (* Instrument is from GS collection *)
DMUS_IO_INST_XG = (1 shl 10); (* Instrument is from XG collection *)
DMUS_IO_INST_CHANNEL_PRIORITY = (1 shl 11); (* dwChannelPriority is valid *)
DMUS_IO_INST_USE_DEFAULT_GM_SET = (1 shl 12); (* Always use the default GM set for this patch, *)
(* don't rely on the synth caps stating GM or GS in hardware. *)
type
(* io structures *)
TDMus_IO_Instruments = packed record
dwPatch: DWORD; (* MSB, LSB and Program change to define instrument *)
dwAssignPatch: DWORD; (* MSB, LSB and Program change to assign to instrument when downloading *)
dwNoteRanges: array [0..3] of DWORD;(* 128 bits: one for each MIDI note instrument needs to able to play *)
dwPChannel: DWORD; (* PChannel instrument plays on *)
dwFlags: DWORD; (* DMUS_IO_INST_ flags *)
bPan: BYTE; (* Pan for instrument *)
bVolume: BYTE; (* Volume for instrument *)
nTranspose: SmallInt; (* Number of semitones to transpose notes *)
dwChannelPriority: DWORD; (* Channel priority *)
// io structures
TDMUS_IO_INSTRUMENT = record
dwPatch : DWORD; // MSB, LSB and Program change to define instrument
dwAssignPatch : DWORD; // MSB, LSB and Program change to assign to instrument when downloading
dwNoteRanges : array[0..3] of DWORD; // 128 bits; one for each MIDI note instrument needs to able to play
dwPChannel : DWORD; // PChannel instrument plays on
dwFlags : DWORD; // DMUS_IO_INST_ flags
bPan : Byte; // Pan for instrument
bVolume : Byte; // Volume for instrument
nTranspose : Smallint; // Number of semitones to transpose notes
dwChannelPriority : DWORD; // Channel priority
end;
DMUS_IO_INSTRUMENT = TDMUS_IO_INSTRUMENT;
 
(*
// <DMBD-form> bands can be embedded in other forms
RIFF
(
'DMBD' // DirectMusic Band chunk
[<guid-ck>] // GUID for band
[<vers-ck>] // Optional version info
[<UNFO-list>] // Name, author, copyright info., comments
<lbil-list> // List of Instruments
)
 
// <guid-ck>
'guid'
(
<GUID>
)
// File io for DirectMusic Segment object
 
// <vers-ck>
vers
(
<DMUS_IO_VERSION>
)
const
// RIFF ids:
 
// <lbil-list>
LIST
(
'lbil' // List of instruments
<lbin-list> // Each instrument is encapsulated in a list
)
DMUS_FOURCC_SEGMENT_FORM = Ord('D') + Ord('M') shl 8 + Ord('S') shl 16 + Ord('G') shl 24;
DMUS_FOURCC_SEGMENT_CHUNK = Ord('s') + Ord('e') shl 8 + Ord('g') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_TRACK_LIST = Ord('t') + Ord('r') shl 8 + Ord('k') shl 16 + Ord('l') shl 24;
DMUS_FOURCC_TRACK_FORM = Ord('D') + Ord('M') shl 8 + Ord('T') shl 16 + Ord('K') shl 24;
DMUS_FOURCC_TRACK_CHUNK = Ord('t') + Ord('r') shl 8 + Ord('k') shl 16 + Ord('h') shl 24;
 
// <lbin-list>
LIST
(
'lbin'
<bins-ck>
[<DMRF-list>] // Optional reference to DLS Collection file.
)
type
// io structures:
 
// <bins-ck> // Instrument chunk
(
'bins'
<DMUS_IO_INSTRUMENT> // Instrument header
)
*)
 
(* File io for DirectMusic Segment object *)
 
(* RIFF ids: *)
const
DMUS_FOURCC_SEGMENT_FORM : mmioFOURCC = ('D','M','S','G');
DMUS_FOURCC_SEGMENT_CHUNK : mmioFOURCC = ('s','e','g','h');
DMUS_FOURCC_TRACK_LIST : mmioFOURCC = ('t','r','k','l');
DMUS_FOURCC_TRACK_FORM : mmioFOURCC = ('D','M','T','K');
DMUS_FOURCC_TRACK_CHUNK : mmioFOURCC = ('t','r','k','h');
 
(* io structures:*)
type
TDMus_IO_Segment_Header = packed record
dwRepeats: DWORD; (* Number of repeats. By default, 0. *)
mtLength: TMusic_Time; (* Length, in music time. *)
mtPlayStart: TMusic_Time; (* Start of playback. By default, 0. *)
mtLoopStart: TMusic_Time; (* Start of looping portion. By default, 0. *)
mtLoopEnd: TMusic_Time; (* End of loop. Must be greater than dwPlayStart. By default equal to length. *)
dwResolution: DWORD; (* Default resolution. *)
TDMUS_IO_SEGMENT_HEADER = record
dwRepeats : DWORD; // Number of repeats. By default, 0.
mtLength : MUSIC_TIME; // Length, in music time.
mtPlayStart : MUSIC_TIME; // Start of playback. By default, 0.
mtLoopStart : MUSIC_TIME; // Start of looping portion. By default, 0.
mtLoopEnd : MUSIC_TIME; // End of loop. Must be greater than dwPlayStart. By default equal to length.
dwResolution : DWORD; // Default resolution.
end;
DMUS_IO_SEGMENT_HEADER = TDMUS_IO_SEGMENT_HEADER;
 
TDMus_IO_Track_Header = packed record
guidClassID: TGUID; (* Class id of track. *)
dwPosition: DWORD; (* Position in track list. *)
dwGroup: DWORD; (* Group bits for track. *)
ckid: TFourCC; (* chunk ID of track's data chunk if 0 fccType valid. *)
fccType: TFourCC; (* list type if NULL ckid valid *)
TDMUS_IO_TRACK_HEADER = record
guidClassID : TGUID; // Class id of track.
dwPosition : DWORD; // Position in track list.
dwGroup : DWORD; // Group bits for track.
ckid : FOURCC; // chunk ID of track's data chunk if 0 fccType valid.
fccType : FOURCC; // list type if NULL ckid valid
end;
DMUS_IO_TRACK_HEADER = TDMUS_IO_TRACK_HEADER;
 
(*
RIFF
(
'DMSG' // DirectMusic Segment chunk
<segh-ck> // Segment header chunk
[<guid-ck>] // GUID for segment
[<vers-ck>] // Optional version info
[<UNFO-list>] // Name, author, copyright info., comments
<trkl-list> // List of Tracks
[<DMTG-form>] // Optional ToolGraph
)
// File io for DirectMusic reference chunk.
// This is used to embed a reference to an object.
 
// <segh-ck>
'segh'
(
<DMUS_IO_SEGMENT_HEADER>
)
const
// RIFF ids:
// <guid-ck>
'guid'
(
<GUID>
)
DMUS_FOURCC_REF_LIST = Ord('D') + Ord('M') shl 8 + Ord('R') shl 16 + Ord('F') shl 24;
DMUS_FOURCC_REF_CHUNK = Ord('r') + Ord('e') shl 8 + Ord('f') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_DATE_CHUNK = Ord('d') + Ord('a') shl 8 + Ord('t') shl 16 + Ord('e') shl 24;
DMUS_FOURCC_NAME_CHUNK = Ord('n') + Ord('a') shl 8 + Ord('m') shl 16 + Ord('e') shl 24;
DMUS_FOURCC_FILE_CHUNK = Ord('f') + Ord('i') shl 8 + Ord('l') shl 16 + Ord('e') shl 24;
 
// <vers-ck>
vers
(
<DMUS_IO_VERSION>
)
 
// <trkl-list>
LIST
(
'trkl' // List of tracks
<DMTK-form>... // Each track is encapsulated in a RIFF chunk
)
 
// <DMTK-form> // Tracks can be embedded in a segment or stored as separate files.
RIFF
(
'DMTK'
<trkh-ck>
[<guid-ck>] // Optional GUID for track object instance (not to be confused with Class id in track header)
[<vers-ck>] // Optional version info
[<UNFO-list>] // Optional name, author, copyright info., comments
[<data>] // Track data. Must be a RIFF readable chunk.
)
 
// <trkh-ck> // Track header chunk
(
'trkh'
<DMUS_IO_TRACK_HEADER> // Track header
)
*)
 
(* File io for DirectMusic reference chunk.
This is used to embed a reference to an object.
*)
 
(* RIFF ids: *)
const
DMUS_FOURCC_REF_LIST : mmioFOURCC = ('D','M','R','F');
DMUS_FOURCC_REF_CHUNK : mmioFOURCC = ('r','e','f','h');
DMUS_FOURCC_DATE_CHUNK : mmioFOURCC = ('d','a','t','e');
DMUS_FOURCC_NAME_CHUNK : mmioFOURCC = ('n','a','m','e');
DMUS_FOURCC_FILE_CHUNK : mmioFOURCC = ('f','i','l','e');
 
type
TDMus_IO_Reference = packed record
guidClassID: TGUID; (* Class id is always required. *)
dwValidData: DWORD; (* Flags. *)
TDMUS_IO_REFERENCE = record
guidClassID : TGUID; // Class id is always required.
dwValidData : DWORD; // Flags.
end;
DMUS_IO_REFERENCE = TDMUS_IO_REFERENCE;
 
(*
LIST
(
'DMRF' // DirectMusic Reference chunk
<refh-ck> // Reference header chunk
[<guid-ck>] // Optional object GUID.
[<date-ck>] // Optional file date.
[<name-ck>] // Optional name.
[<file-ck>] // Optional file name.
[<catg-ck>] // Optional category name.
[<vers-ck>] // Optional version info.
)
 
// <refh-ck>
'refh'
(
<DMUS_IO_REFERENCE>
)
// Chord Maps
 
// <guid-ck>
'guid'
(
<GUID>
)
 
// <date-ck>
date
(
<FILETIME>
)
 
// <name-ck>
name
(
// Name, stored as NULL terminated string of WCHARs
)
 
// <file-ck>
file
(
// File name, stored as NULL terminated string of WCHARs
)
 
// <catg-ck>
catg
(
// Category name, stored as NULL terminated string of WCHARs
)
 
// <vers-ck>
vers
(
<DMUS_IO_VERSION>
)
*)
 
(* Chord Maps *)
const
(* runtime chunks *)
DMUS_FOURCC_CHORDMAP_FORM : mmioFOURCC = ('D','M','P','R');
DMUS_FOURCC_IOCHORDMAP_CHUNK : mmioFOURCC = ('p','e','r','h');
DMUS_FOURCC_SUBCHORD_CHUNK : mmioFOURCC = ('c','h','d','t');
DMUS_FOURCC_CHORDENTRY_CHUNK : mmioFOURCC = ('c','h','e','h');
DMUS_FOURCC_SUBCHORDID_CHUNK : mmioFOURCC = ('s','b','c','n');
DMUS_FOURCC_IONEXTCHORD_CHUNK : mmioFOURCC = ('n','c','r','d');
DMUS_FOURCC_NEXTCHORDSEQ_CHUNK : mmioFOURCC = ('n','c','s','q');
DMUS_FOURCC_IOSIGNPOST_CHUNK : mmioFOURCC = ('s','p','s','h');
DMUS_FOURCC_CHORDNAME_CHUNK : mmioFOURCC = ('I','N','A','M');
// runtime chunks
DMUS_FOURCC_CHORDMAP_FORM = Ord('D') + Ord('M') shl 8 + Ord('P') shl 16 + Ord('R') shl 24;
DMUS_FOURCC_IOCHORDMAP_CHUNK = Ord('p') + Ord('e') shl 8 + Ord('r') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_SUBCHORD_CHUNK = Ord('c') + Ord('h') shl 8 + Ord('d') shl 16 + Ord('t') shl 24;
DMUS_FOURCC_CHORDENTRY_CHUNK = Ord('c') + Ord('h') shl 8 + Ord('e') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_SUBCHORDID_CHUNK = Ord('s') + Ord('b') shl 8 + Ord('c') shl 16 + Ord('n') shl 24;
DMUS_FOURCC_IONEXTCHORD_CHUNK = Ord('n') + Ord('c') shl 8 + Ord('r') shl 16 + Ord('d') shl 24;
DMUS_FOURCC_NEXTCHORDSEQ_CHUNK = Ord('n') + Ord('c') shl 8 + Ord('s') shl 16 + Ord('q') shl 24;
DMUS_FOURCC_IOSIGNPOST_CHUNK = Ord('s') + Ord('p') shl 8 + Ord('s') shl 16 + Ord('h') shl 24;
DMUS_FOURCC_CHORDNAME_CHUNK = Ord('I') + Ord('N') shl 8 + Ord('A') shl 16 + Ord('M') shl 24;
 
(* runtime list chunks *)
DMUS_FOURCC_CHORDENTRY_LIST : mmioFOURCC = ('c','h','o','e');
DMUS_FOURCC_CHORDMAP_LIST : mmioFOURCC = ('c','m','a','p');
DMUS_FOURCC_CHORD_LIST : mmioFOURCC = ('c','h','r','d');
DMUS_FOURCC_CHORDPALETTE_LIST : mmioFOURCC = ('c','h','p','l');
DMUS_FOURCC_CADENCE_LIST : mmioFOURCC = ('c','a','d','e');
DMUS_FOURCC_SIGNPOSTITEM_LIST : mmioFOURCC = ('s','p','s','t');
// runtime list chunks
DMUS_FOURCC_CHORDENTRY_LIST = Ord('c') + Ord('h') shl 8 + Ord('o') shl 16 + Ord('e') shl 24;
DMUS_FOURCC_CHORDMAP_LIST = Ord('c') + Ord('m') shl 8 + Ord('a') shl 16 + Ord('p') shl 24;
DMUS_FOURCC_CHORD_LIST = Ord('c') + Ord('h') shl 8 + Ord('r') shl 16 + Ord('d') shl 24;
DMUS_FOURCC_CHORDPALETTE_LIST = Ord('c') + Ord('h') shl 8 + Ord('p') shl 16 + Ord('l') shl 24;
DMUS_FOURCC_CADENCE_LIST = Ord('c') + Ord('a') shl 8 + Ord('d') shl 16 + Ord('e') shl 24;
DMUS_FOURCC_SIGNPOSTITEM_LIST = Ord('s') + Ord('p') shl 8 + Ord('s') shl 16 + Ord('t') shl 24;
 
DMUS_FOURCC_SIGNPOST_LIST : mmioFOURCC = ('s','p','s','q');
DMUS_FOURCC_SIGNPOST_LIST = Ord('s') + Ord('p') shl 8 + Ord('s') shl 16 + Ord('q') shl 24;
 
(* values for dwChord field of DMUS_IO_PERS_SIGNPOST *)
(* DMUS_SIGNPOSTF_ flags are also used in templates (DMUS_IO_SIGNPOST) *)
// values for dwChord field of DMUS_IO_PERS_SIGNPOST
// DMUS_SIGNPOSTF_ flags are also used in templates (DMUS_IO_SIGNPOST)
DMUS_SIGNPOSTF_A = 1;
DMUS_SIGNPOSTF_B = 2;
DMUS_SIGNPOSTF_C = 4;
21495,663 → 15374,271
DMUS_SIGNPOSTF_ROOT = (DMUS_SIGNPOSTF_1 or DMUS_SIGNPOSTF_2 or DMUS_SIGNPOSTF_3 or DMUS_SIGNPOSTF_4 or DMUS_SIGNPOSTF_5 or DMUS_SIGNPOSTF_6 or DMUS_SIGNPOSTF_7);
DMUS_SIGNPOSTF_CADENCE = $8000;
 
(* values for dwChord field of DMUS_IO_PERS_SIGNPOST *)
DMUS_SPOSTCADENCEF_1 = 2; (* Use the first cadence chord. *)
DMUS_SPOSTCADENCEF_2 = 4; (* Use the second cadence chord. *)
// values for dwChord field of DMUS_IO_PERS_SIGNPOST
DMUS_SPOSTCADENCEF_1 = 2; // Use the first cadence chord.
DMUS_SPOSTCADENCEF_2 = 4; // Use the second cadence chord.
 
type
(* run time data structs *)
TDMus_IO_ChordMap = packed record
// run time data structs
TDMUS_IO_CHORDMAP = record
wszLoadName: array [0..19] of WCHAR;
dwScalePattern: DWORD;
dwFlags: DWORD;
end;
DMUS_IO_CHORDMAP = TDMUS_IO_CHORDMAP;
 
TDMus_IO_ChordMap_SubChord = packed record
TDMUS_IO_CHORDMAP_SUBCHORD = record
dwChordPattern: DWORD;
dwScalePattern: DWORD;
dwInvertPattern: DWORD;
bChordRoot: BYTE;
bScaleRoot: BYTE;
wCFlags: WORD;
dwLevels: DWORD; (* parts or which subchord levels this chord supports *)
bChordRoot : Byte;
bScaleRoot : Byte;
wCFlags : Word;
dwLevels : DWORD; // parts or which subchord levels this chord supports
end;
DMUS_IO_CHORDMAP_SUBCHORD = TDMUS_IO_CHORDMAP_SUBCHORD;
 
(* Legacy name... *)
TDMus_IO_Pers_SubChord = TDMus_IO_ChordMap_SubChord;
// Legacy name...
DMUS_IO_PERS_SUBCHORD = TDMUS_IO_CHORDMAP_SUBCHORD;
 
TDMus_IO_ChordEntry = packed record
TDMUS_IO_CHORDENTRY = record
dwFlags: DWORD;
wConnectionID: WORD; (* replaces runtime "pointer to this" *)
wConnectionID : Word; // replaces runtime "pointer to this"
end;
DMUS_IO_CHORDENTRY = TDMUS_IO_CHORDENTRY;
 
TDMus_IO_NextChord = packed record
TDMUS_IO_NEXTCHORD = record
dwFlags: DWORD;
nWeight: WORD;
wMinBeats: WORD;
wMaxBeats: WORD;
wConnectionID: WORD; (* points to an ioChordEntry *)
nWeight : Word;
wMinBeats : Word;
wMaxBeats : Word;
wConnectionID : Word; // points to an ioChordEntry
end;
DMUS_IO_NEXTCHORD = TDMUS_IO_NEXTCHORD;
 
TDMus_IO_ChordMap_SignPost = packed record
dwChords: DWORD; (* 1bit per group *)
TDMUS_IO_CHORDMAP_SIGNPOST = record
dwChords : DWORD; // 1bit per group
dwFlags: DWORD;
end;
DMUS_IO_CHORDMAP_SIGNPOST = TDMUS_IO_CHORDMAP_SIGNPOST;
 
(* Legacy name... *)
TDMus_IO_Pers_SignPost = TDMus_IO_ChordMap_SignPost;
// Legacy name...
DMUS_IO_PERS_SIGNPOST = TDMUS_IO_CHORDMAP_SIGNPOST;
 
(*
RIFF
(
'DMPR'
<perh-ck> // Chord map header chunk
[<guid-ck>] // guid chunk
[<vers-ck>] // version chunk (two DWORDS)
[<UNFO-list>] // Unfo chunk
<chdt-ck> // subchord database
<chpl-list> // chord palette
<cmap-list> // chord map
<spsq-list> // signpost list
)
 
<cmap-list> ::= LIST('cmap' <choe-list> )
 
<choe-list> ::= LIST('choe'
<cheh-ck> // chord entry data
<chrd-list> // chord definition
<ncsq-ck> // connecting(next) chords
)
 
<chrd-list> ::= LIST('chrd'
<INAM-ck> // name of chord in wide char format
<sbcn-ck> // list of subchords composing chord
)
 
<chpl-list> ::= LIST('chpl'
<chrd-list> ... // chord definition
)
 
<spsq-list> ::== LIST('spsq' <spst-list> ... )
 
<spst-list> ::= LIST('spst'
<spsh-ck>
<chrd-list>
[<cade-list>]
)
 
<cade-list> ::= LIST('cade' <chrd-list> ...)
 
<perh-ck> ::= perh(<DMUS_IO_CHORDMAP>)
 
<chdt-ck> ::= chdt(<cbChordSize::WORD>
<DMUS_IO_PERS_SUBCHORD> ... )
 
<cheh-ck> ::= cheh(<DMUS_IO_CHORDENTRY>)
 
<sbcn-ck> ::= sbcn(<cSubChordID:WORD> ...)
 
<ncsq-ck> ::= ncsq(<wNextChordSize:WORD>
<DMUS_IO_NEXTCHORD>...)
 
<spsh-ck> ::= spsh(<DMUS_IO_PERS_SIGNPOST>)
 
*)
 
(* Signpost tracks *)
const
DMUS_FOURCC_SIGNPOST_TRACK_CHUNK : mmioFOURCC = ( 's', 'g', 'n', 'p' );
// Signpost tracks
DMUS_FOURCC_SIGNPOST_TRACK_CHUNK = Ord('s') + Ord('g') shl 8 + Ord('n') shl 16 + Ord('p') shl 24;
 
type
TDMus_IO_SignPost = packed record
mtTime: TMusic_Time;
TDMUS_IO_SIGNPOST = record
mtTime : MUSIC_TIME;
dwChords: DWORD;
wMeasure: WORD;
wMeasure : Word;
end;
DMUS_IO_SIGNPOST = TDMUS_IO_SIGNPOST;
 
(*
 
// <sgnp-list>
'sgnp'
(
//sizeof DMUS_IO_SIGNPOST: DWORD
<DMUS_IO_SIGNPOST>...
)
 
*)
 
const
DMUS_FOURCC_MUTE_CHUNK : mmioFOURCC = ('m','u','t','e');
DMUS_FOURCC_MUTE_CHUNK = Ord('m') + Ord('u') shl 8 + Ord('t') shl 16 + Ord('e') shl 24;
 
type
TDMus_IO_Mute = packed record
mtTime: TMusic_Time;
TDMUS_IO_MUTE = record
mtTime : MUSIC_TIME;
dwPChannel: DWORD;
dwPChannelMap: DWORD;
end;
DMUS_IO_MUTE = TDMUS_IO_MUTE;
 
(*
// Used for both style and chord map tracks
const
DMUS_FOURCC_TIME_STAMP_CHUNK = Ord('s') + Ord('t') shl 8 + Ord('m') shl 16 + Ord('p') shl 24;
 
// <mute-list>
'mute'
(
//sizeof DMUS_IO_MUTE:DWORD
<DMUS_IO_MUTE>...
)
// Style tracks
DMUS_FOURCC_STYLE_TRACK_LIST = Ord('s') + Ord('t') shl 8 + Ord('t') shl 16 + Ord('r') shl 24;
DMUS_FOURCC_STYLE_REF_LIST = Ord('s') + Ord('t') shl 8 + Ord('r') shl 16 + Ord('f') shl 24;
 
// Chord map tracks
DMUS_FOURCC_PERS_TRACK_LIST = Ord('p') + Ord('f') shl 8 + Ord('t') shl 16 + Ord('r') shl 24;
DMUS_FOURCC_PERS_REF_LIST = Ord('p') + Ord('f') shl 8 + Ord('r') shl 16 + Ord('f') shl 24;
DMUS_FOURCC_TEMPO_TRACK = Ord('t') + Ord('e') shl 8 + Ord('t') shl 16 + Ord('r') shl 24;
DMUS_FOURCC_SEQ_TRACK = Ord('s') + Ord('e') shl 8 + Ord('q') shl 16 + Ord('t') shl 24;
DMUS_FOURCC_SEQ_LIST = Ord('e') + Ord('v') shl 8 + Ord('t') shl 16 + Ord('l') shl 24;
DMUS_FOURCC_CURVE_LIST = Ord('c') + Ord('u') shl 8 + Ord('r') shl 16 + Ord('l') shl 24;
DMUS_FOURCC_SYSEX_TRACK = Ord('s') + Ord('y') shl 8 + Ord('e') shl 16 + Ord('x') shl 24;
DMUS_FOURCC_TIMESIGNATURE_TRACK = Ord('t') + Ord('i') shl 8 + Ord('m') shl 16 + Ord('s') shl 24;
 
*)
implementation
 
const
(* Used for both style and chord map tracks *)
DDrawLib = 'DDraw.dll';
D3DRMLib = 'D3DRM.dll';
D3DXofLib = 'd3dxof.dll';
DInputLib = 'DInput.dll';
DPlayXLib = 'DPlayX.dll';
DSetupLib = 'DSetup.dll';
DSoundLib = 'DSound.dll';
 
DMUS_FOURCC_TIME_STAMP_CHUNK : mmioFOURCC = ('s', 't', 'm', 'p');
 
(* Style tracks *)
{ DirectDraw }
 
DMUS_FOURCC_STYLE_TRACK_LIST : mmioFOURCC = ('s', 't', 't', 'r');
DMUS_FOURCC_STYLE_REF_LIST : mmioFOURCC = ('s', 't', 'r', 'f');
 
(*
 
// <sttr-list>
LIST('sttr'
(
// some number of <strf-list>
)
 
// <strf-list>
LIST('strf'
(
<stmp-ck>
<DMRF>
)
 
// <stmp-ck> defined in ..\dmcompos\dmcompp.h
 
*)
 
(* Chord map tracks *)
 
DMUS_FOURCC_PERS_TRACK_LIST : mmioFOURCC = ('p', 'f', 't', 'r');
DMUS_FOURCC_PERS_REF_LIST : mmioFOURCC = ('p', 'f', 'r', 'f');
 
(*
 
// <pftr-list>
LIST('pftr'
(
// some number of <pfrf-list>
)
 
// <pfrf-list>
LIST('pfrf'
(
<stmp-ck>
<DMRF>
)
 
// <stmp-ck>
'stmp'
(
// time:DWORD
)
 
 
 
*)
 
DMUS_FOURCC_TEMPO_TRACK : mmioFOURCC = ('t','e','t','r');
 
(*
// tempo list
'tetr'
(
// sizeof DMUS_IO_TEMPO_ITEM: DWORD
<DMUS_IO_TEMPO_ITEM>...
)
*)
 
DMUS_FOURCC_SEQ_TRACK : mmioFOURCC = ('s','e','q','t');
DMUS_FOURCC_SEQ_LIST : mmioFOURCC = ('e','v','t','l');
DMUS_FOURCC_CURVE_LIST : mmioFOURCC = ('c','u','r','l');
 
(*
// sequence track
'seqt'
(
// sequence list
'evtl'
(
// sizeof DMUS_IO_SEQ_ITEM: DWORD
<DMUS_IO_SEQ_ITEM>...
)
// curve list
'curl'
(
// sizeof DMUS_IO_CURVE_ITEM: DWORD
<DMUS_IO_CURVE_ITEM>...
)
)
*)
 
DMUS_FOURCC_SYSEX_TRACK : mmioFOURCC = ('s','y','e','x');
 
(*
// sysex track
'syex'
(
// list of:
// {
// <DMUS_IO_SYSEX_ITEM>
// sys-ex: data
// }...
)
*)
 
DMUS_FOURCC_TIMESIGNATURE_TRACK : mmioFOURCC = ('t','i','m','s');
 
(*
// time signature track
'tims'
(
// size of DMUS_IO_TIMESIGNATURE_ITEM : DWORD
<DMUS_IO_TIMESIGNATURE_ITEM>...
)
*)
 
(***************************************************************************
* *
* DMusBuff.h -- This module defines the buffer format for DirectMusic *
* Shared file between user mode and kernel mode components *
* *
* Copyright (c) 1998, Microsoft Corp. All rights reserved. *
* *
***************************************************************************)
 
(* The number of bytes to allocate for an event with 'cb' data bytes.
*)
function QWORD_ALIGN(x: DWORD) : DWORD;
 
function DMUS_EVENT_SIZE(cb: DWORD) : DWORD;
 
 
 
Implementation
 
//DirectDraw file
 
 
{
#define GET_WHQL_YEAR( dwWHQLLevel ) \
( (dwWHQLLevel) / 0x10000 )
#define GET_WHQL_MONTH( dwWHQLLevel ) \
( ( (dwWHQLLevel) / 0x100 ) & 0x00ff )
#define GET_WHQL_DAY( dwWHQLLevel ) \
( (dwWHQLLevel) & 0xff )
}
function GET_WHQL_YEAR(dwWHQLLevel: DWORD) : DWORD;
begin
Result := (dwWHQLLevel) div $10000;
Result := dwWHQLLevel div $10000;
end;
 
function GET_WHQL_MONTH(dwWHQLLevel: DWORD) : DWORD;
begin
Result := ( (dwWHQLLevel) div $100 ) and $00ff;
Result := (dwWHQLLevel div $100) and $FF;
end;
 
function GET_WHQL_DAY(dwWHQLLevel: DWORD) : DWORD;
begin
Result := (dwWHQLLevel) and $ff;
Result := dwWHQLLevel and $FF;
end;
 
function DirectDrawEnumerateA; external DDrawLib;
function DirectDrawEnumerateW; external DDrawLib;
function DirectDrawEnumerate; external DDrawLib name 'DirectDrawEnumerateA';
 
function MAKEFOURCC(ch0, ch1, ch2, ch3: Char) : DWORD;
begin
Result := DWORD(byte(ch0) shl 0) or
DWORD(byte(ch1) shl 8) or
DWORD(byte(ch2) shl 16) or
DWORD(byte(ch3) shl 24);
end;
function DirectDrawEnumerateExA; external DDrawLib;
function DirectDrawEnumerateExW; external DDrawLib;
function DirectDrawEnumerateEx; external DDrawLib name 'DirectDrawEnumerateExA';
 
function DDErrorString(Value: HResult) : string;
begin
case Value of
DD_OK: Result := 'The request completed successfully.';
DDERR_ALREADYINITIALIZED: Result := 'This object is already initialized.';
DDERR_BLTFASTCANTCLIP: Result := ' if a clipper object is attached to the source surface passed into a BltFast call.';
DDERR_CANNOTATTACHSURFACE: Result := 'This surface can not be attached to the requested surface.';
DDERR_CANNOTDETACHSURFACE: Result := 'This surface can not be detached from the requested surface.';
DDERR_CANTCREATEDC: Result := 'Windows can not create any more DCs.';
DDERR_CANTDUPLICATE: Result := 'Cannot duplicate primary & 3D surfaces, or surfaces that are implicitly created.';
DDERR_CLIPPERISUSINGHWND: Result := 'An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd.';
DDERR_COLORKEYNOTSET: Result := 'No src color key specified for this operation.';
DDERR_CURRENTLYNOTAVAIL: Result := 'Support is currently not available.';
DDERR_DIRECTDRAWALREADYCREATED: Result := 'A DirectDraw object representing this driver has already been created for this process.';
DDERR_EXCEPTION: Result := 'An exception was encountered while performing the requested operation.';
DDERR_EXCLUSIVEMODEALREADYSET: Result := 'An attempt was made to set the cooperative level when it was already set to exclusive.';
DDERR_GENERIC: Result := 'Generic failure.';
DDERR_HEIGHTALIGN: Result := 'Height of rectangle provided is not a multiple of reqd alignment.';
DDERR_HWNDALREADYSET: Result := 'The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created.';
DDERR_HWNDSUBCLASSED: Result := 'HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state.';
DDERR_IMPLICITLYCREATED: Result := 'This surface can not be restored because it is an implicitly created surface.';
DDERR_INCOMPATIBLEPRIMARY: Result := 'Unable to match primary surface creation request with existing primary surface.';
DDERR_INVALIDCAPS: Result := 'One or more of the caps bits passed to the callback are incorrect.';
DDERR_INVALIDCLIPLIST: Result := 'DirectDraw does not support the provided cliplist.';
DDERR_INVALIDDIRECTDRAWGUID: Result := 'The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier.';
DDERR_INVALIDMODE: Result := 'DirectDraw does not support the requested mode.';
DDERR_INVALIDOBJECT: Result := 'DirectDraw received a pointer that was an invalid DIRECTDRAW object.';
DDERR_INVALIDPARAMS: Result := 'One or more of the parameters passed to the function are incorrect.';
DDERR_INVALIDPIXELFORMAT: Result := 'The pixel format was invalid as specified.';
DDERR_INVALIDPOSITION: Result := 'Returned when the position of the overlay on the destination is no longer legal for that destination.';
DDERR_INVALIDRECT: Result := 'Rectangle provided was invalid.';
DDERR_LOCKEDSURFACES: Result := 'Operation could not be carried out because one or more surfaces are locked.';
DDERR_NO3D: Result := 'There is no 3D present.';
DDERR_NOALPHAHW: Result := 'Operation could not be carried out because there is no alpha accleration hardware present or available.';
DDERR_NOBLTHW: Result := 'No blitter hardware present.';
DDERR_NOCLIPLIST: Result := 'No cliplist available.';
DDERR_NOCLIPPERATTACHED: Result := 'No clipper object attached to surface object.';
DDERR_NOCOLORCONVHW: Result := 'Operation could not be carried out because there is no color conversion hardware present or available.';
DDERR_NOCOLORKEY: Result := 'Surface does not currently have a color key';
DDERR_NOCOLORKEYHW: Result := 'Operation could not be carried out because there is no hardware support of the destination color key.';
DDERR_NOCOOPERATIVELEVELSET: Result := 'Create function called without DirectDraw object method SetCooperativeLevel being called.';
DDERR_NODC: Result := 'No DC was ever created for this surface.';
DDERR_NODDROPSHW: Result := 'No DirectDraw ROP hardware.';
DDERR_NODIRECTDRAWHW: Result := 'A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware.';
DDERR_NOEMULATION: Result := 'Software emulation not available.';
DDERR_NOEXCLUSIVEMODE: Result := 'Operation requires the application to have exclusive mode but the application does not have exclusive mode.';
DDERR_NOFLIPHW: Result := 'Flipping visible surfaces is not supported.';
DDERR_NOGDI: Result := 'There is no GDI present.';
DDERR_NOHWND: Result := 'Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND.';
DDERR_NOMIRRORHW: Result := 'Operation could not be carried out because there is no hardware present or available.';
DDERR_NOOVERLAYDEST: Result := 'Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination.';
DDERR_NOOVERLAYHW: Result := 'Operation could not be carried out because there is no overlay hardware present or available.';
DDERR_NOPALETTEATTACHED: Result := 'No palette object attached to this surface.';
DDERR_NOPALETTEHW: Result := 'No hardware support for 16 or 256 color palettes.';
DDERR_NORASTEROPHW: Result := 'Operation could not be carried out because there is no appropriate raster op hardware present or available.';
DDERR_NOROTATIONHW: Result := 'Operation could not be carried out because there is no rotation hardware present or available.';
DDERR_NOSTRETCHHW: Result := 'Operation could not be carried out because there is no hardware support for stretching.';
DDERR_NOT4BITCOLOR: Result := 'DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette.';
DDERR_NOT4BITCOLORINDEX: Result := 'DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette.';
DDERR_NOT8BITCOLOR: Result := 'DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color.';
DDERR_NOTAOVERLAYSURFACE: Result := 'Returned when an overlay member is called for a non-overlay surface.';
DDERR_NOTEXTUREHW: Result := 'Operation could not be carried out because there is no texture mapping hardware present or available.';
DDERR_NOTFLIPPABLE: Result := 'An attempt has been made to flip a surface that is not flippable.';
DDERR_NOTFOUND: Result := 'Requested item was not found.';
DDERR_NOTLOCKED: Result := 'Surface was not locked. An attempt to unlock a surface that was not locked at all, or by this process, has been attempted.';
DDERR_NOTPALETTIZED: Result := 'The surface being used is not a palette-based surface.';
DDERR_NOVSYNCHW: Result := 'Operation could not be carried out because there is no hardware support for vertical blank synchronized operations.';
DDERR_NOZBUFFERHW: Result := 'Operation could not be carried out because there is no hardware support for zbuffer blitting.';
DDERR_NOZOVERLAYHW: Result := 'Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays.';
DDERR_OUTOFCAPS: Result := 'The hardware needed for the requested operation has already been allocated.';
DDERR_OUTOFMEMORY: Result := 'DirectDraw does not have enough memory to perform the operation.';
DDERR_OUTOFVIDEOMEMORY: Result := 'DirectDraw does not have enough memory to perform the operation.';
DDERR_OVERLAYCANTCLIP: Result := 'The hardware does not support clipped overlays.';
DDERR_OVERLAYCOLORKEYONLYONEACTIVE: Result := 'Can only have ony color key active at one time for overlays.';
DDERR_OVERLAYNOTVISIBLE: Result := 'Returned when GetOverlayPosition is called on a hidden overlay.';
DDERR_PALETTEBUSY: Result := 'Access to this palette is being refused because the palette is already locked by another thread.';
DDERR_PRIMARYSURFACEALREADYEXISTS: Result := 'This process already has created a primary surface.';
DDERR_REGIONTOOSMALL: Result := 'Region passed to Clipper::GetClipList is too small.';
DDERR_SURFACEALREADYATTACHED: Result := 'This surface is already attached to the surface it is being attached to.';
DDERR_SURFACEALREADYDEPENDENT: Result := 'This surface is already a dependency of the surface it is being made a dependency of.';
DDERR_SURFACEBUSY: Result := 'Access to this surface is being refused because the surface is already locked by another thread.';
DDERR_SURFACEISOBSCURED: Result := 'Access to surface refused because the surface is obscured.';
DDERR_SURFACELOST: Result := 'Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it.';
DDERR_SURFACENOTATTACHED: Result := 'The requested surface is not attached.';
DDERR_TOOBIGHEIGHT: Result := 'Height requested by DirectDraw is too large.';
DDERR_TOOBIGSIZE: Result := 'Size requested by DirectDraw is too large, but the individual height and width are OK.';
DDERR_TOOBIGWIDTH: Result := 'Width requested by DirectDraw is too large.';
DDERR_UNSUPPORTED: Result := 'Action not supported.';
DDERR_UNSUPPORTEDFORMAT: Result := 'FOURCC format requested is unsupported by DirectDraw.';
DDERR_UNSUPPORTEDMASK: Result := 'Bitmask in the pixel format requested is unsupported by DirectDraw.';
DDERR_VERTICALBLANKINPROGRESS: Result := 'Vertical blank is in progress.';
DDERR_WASSTILLDRAWING: Result := 'Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete.';
DDERR_WRONGMODE: Result := 'This surface can not be restored because it was created in a different mode.';
DDERR_XALIGN: Result := 'Rectangle provided was not horizontally aligned on required boundary.';
// new:
DDERR_OVERLAPPINGRECTS: Result := 'Operation could not be carried out because the source and destination rectangles are on the same surface and overlap each other.';
DDERR_INVALIDSTREAM: Result := 'The specified stream contains invalid data';
DDERR_UNSUPPORTEDMODE: Result := 'The display is currently in an unsupported mode';
DDERR_NOMIPMAPHW: Result := 'Operation could not be carried out because there is no mip-map texture mapping hardware present or available.';
DDERR_INVALIDSURFACETYPE: Result := 'The requested action could not be performed because the surface was of the wrong type.';
DDERR_NOOPTIMIZEHW: Result := 'Device does not support optimized surfaces, therefore no video memory optimized surfaces';
DDERR_NOTLOADED: Result := 'Surface is an optimized surface, but has not yet been allocated any memory';
DDERR_NOFOCUSWINDOW: Result := 'Attempt was made to create or set a device window without first setting the focus window';
DDERR_DCALREADYCREATED: Result := 'A DC has already been returned for this surface. Only one DC can be retrieved per surface.';
DDERR_NONONLOCALVIDMEM: Result := 'An attempt was made to allocate non-local video memory from a device that does not support non-local video memory.';
DDERR_CANTPAGELOCK: Result := 'The attempt to page lock a surface failed.';
DDERR_CANTPAGEUNLOCK: Result := 'The attempt to page unlock a surface failed.';
DDERR_NOTPAGELOCKED: Result := 'An attempt was made to page unlock a surface with no outstanding page locks.';
DDERR_MOREDATA: Result := 'There is more data available than the specified buffer size could hold';
DDERR_EXPIRED: Result := 'The data has expired and is therefore no longer valid.';
DDERR_VIDEONOTACTIVE: Result := 'The video port is not active';
DDERR_DEVICEDOESNTOWNSURFACE: Result := 'Surfaces created by one direct draw device cannot be used directly by another direct draw device.';
DDERR_NOTINITIALIZED: Result := 'An attempt was made to invoke an interface member of a DirectDraw object created by CoCreateInstance() before it was initialized.';
else Result := 'Unrecognized Error';
end;
end;
function DirectDrawCreate; external DDrawLib;
function DirectDrawCreateEx; external DDrawLib;
function DirectDrawCreateClipper; external DDrawLib;
 
//Direct3D file
{ Direct3D }
 
function DXFileErrorString(Value: HResult) : string;
function D3DVALP(val: TD3DValue; prec: Integer): TD3DValue;
begin
case Value of
DXFILE_OK: Result := 'Command completed successfully. Equivalent to DD_OK.';
DXFILEERR_BADVALUE: Result := 'Parameter is invalid.';
DXFILEERR_BADTYPE: Result := 'Object type is invalid.';
DXFILEERR_BADALLOC: Result := 'Memory allocation failed.';
DXFILEERR_NOTFOUND: Result := 'Object could not be found.';
DXFILEERR_FILENOTFOUND: Result := 'File could not be found.';
DXFILEERR_RESOURCENOTFOUND: Result := 'Resource could not be found.';
DXFILEERR_URLNOTFOUND: Result := 'URL could not be found.';
DXFILEERR_BADRESOURCE: Result := 'Resource is invalid.';
DXFILEERR_BADFILETYPE: Result := 'File is not a DirectX file.';
DXFILEERR_BADFILEVERSION: Result := 'File version is not valid.';
DXFILEERR_BADFILEFLOATSIZE: Result := 'Floating-point size is invalid.';
DXFILEERR_BADFILE: Result := 'File is invalid.';
DXFILEERR_PARSEERROR: Result := 'File could not be parsed.';
DXFILEERR_BADARRAYSIZE: Result := 'Array size is invalid.';
DXFILEERR_BADDATAREFERENCE: Result := 'Data reference is invalid.';
DXFILEERR_NOMOREOBJECTS: Result := 'All objects have been enumerated.';
DXFILEERR_NOMOREDATA: Result := 'No further data is available.';
else Result := 'Unrecognized Error';
Result := val;
end;
end;
 
function D3DFVF_TEXCOORDSIZE3(CoordIndex: DWORD) : DWORD;
function D3DVAL(val: TD3DValue): TD3DValue;
begin
Result := (D3DFVF_TEXTUREFORMAT3 shl (CoordIndex*2 + 16));
end;
 
function D3DFVF_TEXCOORDSIZE2(CoordIndex: DWORD) : DWORD;
begin
Result := (D3DFVF_TEXTUREFORMAT2);
end;
 
function D3DFVF_TEXCOORDSIZE4(CoordIndex: DWORD) : DWORD;
begin
Result := (D3DFVF_TEXTUREFORMAT4 shl (CoordIndex*2 + 16));
end;
 
function D3DFVF_TEXCOORDSIZE1(CoordIndex: DWORD) : DWORD;
begin
Result := (D3DFVF_TEXTUREFORMAT1 shl (CoordIndex*2 + 16));
end;
 
 
function D3DVal(val: variant) : float;
begin
Result := val;
end;
 
function D3DDivide(a,b: double) : float;
function D3DDivide(a, b: TD3DValue): TD3DValue;
begin
Result := a / b;
end;
 
function D3DMultiply(a,b: double) : float;
function D3DMultiply(a, b: TD3DValue): TD3DValue;
begin
Result := a * b;
end;
 
// #define CI_GETALPHA(ci) ((ci) >> 24)
function CI_GETALPHA(ci: DWORD) : DWORD;
function CI_GETALPHA(ci: Integer): Byte;
begin
Result := ci shr 24;
end;
 
// #define CI_GETINDEX(ci) (((ci) >> 8) & 0xffff)
function CI_GETINDEX(ci: DWORD) : DWORD;
function CI_GETINDEX(ci: Integer): Word;
begin
Result := (ci shr 8) and $ffff;
Result := ci shr 8;
end;
 
// #define CI_GETFRACTION(ci) ((ci) & 0xff)
function CI_GETFRACTION(ci: DWORD) : DWORD;
function CI_GETFRACTION(ci: Integer): Byte;
begin
Result := ci and $ff;
Result := ci;
end;
 
// #define CI_ROUNDINDEX(ci) CI_GETINDEX((ci) + 0x80)
function CI_ROUNDINDEX(ci: DWORD) : DWORD;
function CI_ROUNDINDEX(ci: Integer): Integer;
begin
Result := CI_GETINDEX(ci + $80);
Result := CI_GETINDEX(ci)+$80;
end;
 
// #define CI_MASKALPHA(ci) ((ci) & 0xffffff)
function CI_MASKALPHA(ci: DWORD) : DWORD;
function CI_MASKALPHA(ci: Integer): Integer;
begin
Result := ci and $ffffff;
Result := ci and $FFFFFF;
end;
 
// #define CI_MAKE(a, i, f) (((a) << 24) | ((i) << 8) | (f))
function CI_MAKE(a,i,f: DWORD) : DWORD;
function CI_MAKE(a: Byte; i: Word; f: Byte): Integer;
begin
Result := (a shl 24) or (i shl 8) or f;
end;
 
// #define RGBA_GETALPHA(rgb) ((rgb) >> 24)
function RGBA_GETALPHA(rgb: TD3DColor) : DWORD;
function RGBA_GETALPHA(rgb: TD3DColor): Byte;
begin
Result := rgb shr 24;
end;
 
// #define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff)
function RGBA_GETRED(rgb: TD3DColor) : DWORD;
function RGBA_GETRED(rgb: TD3DColor): Byte;
begin
Result := (rgb shr 16) and $ff;
Result := rgb shr 16;
end;
 
// #define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
function RGBA_GETGREEN(rgb: TD3DColor) : DWORD;
function RGBA_GETGREEN(rgb: TD3DColor): Byte;
begin
Result := (rgb shr 8) and $ff;
Result := rgb shr 8;
end;
 
// #define RGBA_GETBLUE(rgb) ((rgb) & 0xff)
function RGBA_GETBLUE(rgb: TD3DColor) : DWORD;
function RGBA_GETBLUE(rgb: TD3DColor): Byte;
begin
Result := rgb and $ff;
Result := rgb;
end;
 
// #define RGBA_MAKE(r, g, b, a) ((TD3DColor) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
function RGBA_MAKE(r, g, b, a: DWORD) : TD3DColor;
function RGBA_MAKE(r, g, b, a: Byte): TD3DColor;
begin
Result := (a shl 24) or (r shl 16) or (g shl 8) or b;
end;
 
// #define D3DRGB(r, g, b) \
// (0xff000000L | (((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
function D3DRGB(r, g, b: float) : TD3DColor;
function D3DRGB(r, g, b: TD3DValue): TD3DColor;
begin
Result := $ff000000 or (round(r * 255) shl 16)
or (round(g * 255) shl 8)
or round(b * 255);
Result := $FF000000 or (Trunc(r*255) shl 16) or (Trunc(g*255) shl 8) or
(Trunc(b*255));
end;
 
// #define D3DRGBA(r, g, b, a) \
// ( (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
// | (((long)((g) * 255)) << 8) | (long)((b) * 255) \
// )
function D3DRGBA(r, g, b, a: float) : TD3DColor;
function D3DRGBA(r, g, b, a: TD3DValue): TD3DColor;
begin
Result := (round(a * 255) shl 24) or (round(r * 255) shl 16)
or (round(g * 255) shl 8)
or round(b * 255);
Result := (Trunc(a*255) shl 24) or (Trunc(r*255) shl 16) or (Trunc(g*255) shl 8) or
(Trunc(b*255));
end;
 
// #define RGB_GETRED(rgb) (((rgb) >> 16) & 0xff)
function RGB_GETRED(rgb: TD3DColor) : DWORD;
function RGB_GETRED(rgb: TD3DColor): Byte;
begin
Result := (rgb shr 16) and $ff;
Result := rgb shr 16;
end;
 
// #define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
function RGB_GETGREEN(rgb: TD3DColor) : DWORD;
function RGB_GETGREEN(rgb: TD3DColor): Byte;
begin
Result := (rgb shr 8) and $ff;
Result := rgb shr 8;
end;
 
// #define RGB_GETBLUE(rgb) ((rgb) & 0xff)
function RGB_GETBLUE(rgb: TD3DColor) : DWORD;
function RGB_GETBLUE(rgb: TD3DColor): Byte;
begin
Result := rgb and $ff;
Result := rgb;
end;
 
// #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
function RGBA_SETALPHA(rgba: TD3DColor; x: DWORD) : TD3DColor;
function RGBA_SETALPHA(rgba: TD3DColor; x: Byte): TD3DColor;
begin
Result := (x shl 24) or (rgba and $00ffffff);
Result := (x shl 24) or (rgba and $00FFFFFF);
end;
 
// #define RGB_MAKE(r, g, b) ((TD3DColor) (((r) << 16) | ((g) << 8) | (b)))
function RGB_MAKE(r, g, b: DWORD) : TD3DColor;
function RGB_MAKE(r, g, b: Byte): TD3DColor;
begin
Result := (r shl 16) or (g shl 8) or b;
end;
 
// #define RGBA_TORGB(rgba) ((TD3DColor) ((rgba) & 0xffffff))
function RGBA_TORGB(rgba: TD3DColor) : TD3DColor;
begin
Result := rgba and $00ffffff;
Result := rgba and $00FFFFFF;
end;
 
// #define RGB_TORGBA(rgb) ((TD3DColor) ((rgb) | 0xff000000))
function RGB_TORGBA(rgb: TD3DColor) : TD3DColor;
begin
Result := rgb or $ff000000;
Result := rgb or $FF000000;
end;
 
 
function D3DSTATE_OVERRIDE(StateType: DWORD) : DWORD;
function VectorAdd(v1, v2: TD3DVector) : TD3DVector;
begin
Result := StateType + D3DSTATE_OVERRIDE_BIAS;
end;
 
function D3DTRIFLAG_STARTFLAT(len: DWORD) : DWORD;
begin
if not (len in [1..29]) then len := 0;
result := len;
end;
 
// #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
function D3DRENDERSTATE_STIPPLEPATTERN(y: integer) : TD3DRenderStateType;
begin
Result := TD3DRenderStateType(Ord(D3DRENDERSTATE_STIPPLEPATTERN00) + y);
end;
 
 
 
 
// Addition and subtraction
function VectorAdd(const v1, v2: TD3DVector) : TD3DVector;
begin
result.x := v1.x+v2.x;
result.y := v1.y+v2.y;
result.z := v1.z+v2.z;
end;
 
function VectorSub(const v1, v2: TD3DVector) : TD3DVector;
function VectorSub(v1, v2: TD3DVector) : TD3DVector;
begin
result.x := v1.x-v2.x;
result.y := v1.y-v2.y;
22158,8 → 15645,7
result.z := v1.z-v2.z;
end;
 
// Scalar multiplication and division
function VectorMulS(const v: TD3DVector; s: TD3DValue) : TD3DVector;
function VectorMulS(v: TD3DVector; s: TD3DValue) : TD3DVector;
begin
result.x := v.x*s;
result.y := v.y*s;
22166,7 → 15652,7
result.z := v.z*s;
end;
 
function VectorDivS(const v: TD3DVector; s: TD3DValue) : TD3DVector;
function VectorDivS(v: TD3DVector; s: TD3DValue) : TD3DVector;
begin
result.x := v.x/s;
result.y := v.y/s;
22173,8 → 15659,7
result.z := v.z/s;
end;
 
// Memberwise multiplication and division
function VectorMul(const v1, v2: TD3DVector) : TD3DVector;
function VectorMul(v1, v2: TD3DVector) : TD3DVector;
begin
result.x := v1.x*v2.x;
result.y := v1.y*v2.y;
22181,7 → 15666,7
result.z := v1.z*v2.z;
end;
 
function VectorDiv(const v1, v2: TD3DVector) : TD3DVector;
function VectorDiv(v1, v2: TD3DVector) : TD3DVector;
begin
result.x := v1.x/v2.x;
result.y := v1.y/v2.y;
22188,7 → 15673,6
result.z := v1.z/v2.z;
end;
 
// Vector dominance
function VectorSmaller(v1, v2: TD3DVector) : boolean;
begin
result := (v1.x < v2.x) and (v1.y < v2.y) and (v1.z < v2.z);
22199,13 → 15683,11
result := (v1.x <= v2.x) and (v1.y <= v2.y) and (v1.z <= v2.z);
end;
 
// Bitwise equality
function VectorEquel(v1, v2: TD3DVector) : boolean;
begin
result := (v1.x = v2.x) and (v1.y = v2.y) and (v1.z = v2.z);
end;
 
// Length-related functions
function VectorSquareMagnitude(v: TD3DVector) : TD3DValue;
begin
result := (v.x*v.x) + (v.y*v.y) + (v.z*v.z);
22216,13 → 15698,11
result := sqrt((v.x*v.x) + (v.y*v.y) + (v.z*v.z));
end;
 
// Returns vector with same direction and unit length
function VectorNormalize(const v: TD3DVector) : TD3DVector;
function VectorNormalize(v: TD3DVector) : TD3DVector;
begin
result := VectorDivS(v,VectorMagnitude(v));
end;
 
// Return min/max component of the input vector
function VectorMin(v: TD3DVector) : TD3DValue;
var
ret : TD3DValue;
22243,8 → 15723,7
result := ret;
end;
 
// Return memberwise min/max of input vectors
function VectorMinimize(const v1, v2: TD3DVector) : TD3DVector;
function VectorMinimize(v1, v2: TD3DVector) : TD3DVector;
begin
if v1.x < v2.x then result.x := v1.x else result.x := v2.x;
if v1.y < v2.y then result.y := v1.y else result.y := v2.y;
22251,7 → 15730,7
if v1.z < v2.z then result.z := v1.z else result.z := v2.z;
end;
 
function VectorMaximize(const v1, v2: TD3DVector) : TD3DVector;
function VectorMaximize(v1, v2: TD3DVector) : TD3DVector;
begin
if v1.x > v2.x then result.x := v1.x else result.x := v2.x;
if v1.y > v2.y then result.y := v1.y else result.y := v2.y;
22258,13 → 15737,12
if v1.z > v2.z then result.z := v1.z else result.z := v2.z;
end;
 
// Dot and cross product
function VectorDotProduct(v1, v2: TD3DVector) : TD3DValue;
begin
result := (v1.x*v2.x) + (v1.y * v2.y) + (v1.z*v2.z);
end;
 
function VectorCrossProduct(const v1, v2: TD3DVector) : TD3DVector;
function VectorCrossProduct(v1, v2: TD3DVector) : TD3DVector;
begin
result.x := (v1.y*v2.z) - (v1.z*v2.y);
result.y := (v1.z*v2.x) - (v1.x*v2.z);
22271,819 → 15749,245
result.z := (v1.x*v2.y) - (v1.y*v2.x);
end;
 
procedure DisableFPUExceptions;
var
FPUControlWord: WORD;
asm
FSTCW FPUControlWord;
OR FPUControlWord, $4 + $1; { Divide by zero + invalid operation }
FLDCW FPUControlWord;
end;
 
procedure EnableFPUExceptions;
var
FPUControlWord: WORD;
asm
FSTCW FPUControlWord;
AND FPUControlWord, $FFFF - $4 - $1; { Divide by zero + invalid operation }
FLDCW FPUControlWord;
end;
 
function D3DErrorString(Value: HResult) : string; //Full description not available yet
function D3DSTATE_OVERRIDE(typ: DWORD): DWORD;
begin
case Value of
D3D_OK: Result := 'No error';
 
D3DERR_BADMAJORVERSION: Result := 'D3DERR_BADMAJORVERSION';
D3DERR_BADMINORVERSION: Result := 'D3DERR_BADMINORVERSION';
 
D3DERR_INVALID_DEVICE: Result := 'D3DERR_INITFAILED';
D3DERR_INITFAILED: Result := 'D3DERR_INITFAILED';
 
D3DERR_DEVICEAGGREGATED: Result := 'D3DERR_DEVICEAGGREGATED';
 
D3DERR_EXECUTE_CREATE_FAILED: Result := 'D3DERR_EXECUTE_CREATE_FAILED';
D3DERR_EXECUTE_DESTROY_FAILED: Result := 'D3DERR_EXECUTE_DESTROY_FAILED';
D3DERR_EXECUTE_LOCK_FAILED: Result := 'D3DERR_EXECUTE_LOCK_FAILED';
D3DERR_EXECUTE_UNLOCK_FAILED: Result := 'D3DERR_EXECUTE_UNLOCK_FAILED';
D3DERR_EXECUTE_LOCKED: Result := 'D3DERR_EXECUTE_LOCKED';
D3DERR_EXECUTE_NOT_LOCKED: Result := 'D3DERR_EXECUTE_NOT_LOCKED';
 
D3DERR_EXECUTE_FAILED: Result := 'D3DERR_EXECUTE_FAILED';
D3DERR_EXECUTE_CLIPPED_FAILED: Result := 'D3DERR_EXECUTE_CLIPPED_FAILED';
 
D3DERR_TEXTURE_NO_SUPPORT: Result := 'D3DERR_TEXTURE_NO_SUPPORT';
D3DERR_TEXTURE_CREATE_FAILED: Result := 'D3DERR_TEXTURE_CREATE_FAILED';
D3DERR_TEXTURE_DESTROY_FAILED: Result := 'D3DERR_TEXTURE_DESTROY_FAILED';
D3DERR_TEXTURE_LOCK_FAILED: Result := 'D3DERR_TEXTURE_LOCK_FAILED';
D3DERR_TEXTURE_UNLOCK_FAILED: Result := 'D3DERR_TEXTURE_UNLOCK_FAILED';
D3DERR_TEXTURE_LOAD_FAILED: Result := 'D3DERR_TEXTURE_LOAD_FAILED';
D3DERR_TEXTURE_SWAP_FAILED: Result := 'D3DERR_TEXTURE_SWAP_FAILED';
D3DERR_TEXTURE_LOCKED: Result := 'D3DERR_TEXTURELOCKED';
D3DERR_TEXTURE_NOT_LOCKED: Result := 'D3DERR_TEXTURE_NOT_LOCKED';
D3DERR_TEXTURE_GETSURF_FAILED: Result := 'D3DERR_TEXTURE_GETSURF_FAILED';
 
D3DERR_MATRIX_CREATE_FAILED: Result := 'D3DERR_MATRIX_CREATE_FAILED';
D3DERR_MATRIX_DESTROY_FAILED: Result := 'D3DERR_MATRIX_DESTROY_FAILED';
D3DERR_MATRIX_SETDATA_FAILED: Result := 'D3DERR_MATRIX_SETDATA_FAILED';
D3DERR_MATRIX_GETDATA_FAILED: Result := 'D3DERR_MATRIX_GETDATA_FAILED';
D3DERR_SETVIEWPORTDATA_FAILED: Result := 'D3DERR_SETVIEWPORTDATA_FAILED';
 
D3DERR_INVALIDCURRENTVIEWPORT: Result := 'D3DERR_INVALIDCURRENTVIEWPORT';
D3DERR_INVALIDPRIMITIVETYPE: Result := 'D3DERR_INVALIDPRIMITIVETYPE';
D3DERR_INVALIDVERTEXTYPE: Result := 'D3DERR_INVALIDVERTEXTYPE';
D3DERR_TEXTURE_BADSIZE: Result := 'D3DERR_TEXTURE_BADSIZE';
D3DERR_INVALIDRAMPTEXTURE: Result := 'D3DERR_INVALIDRAMPTEXTURE';
 
D3DERR_MATERIAL_CREATE_FAILED: Result := 'D3DERR_MATERIAL_CREATE_FAILED';
D3DERR_MATERIAL_DESTROY_FAILED: Result := 'D3DERR_MATERIAL_DESTROY_FAILED';
D3DERR_MATERIAL_SETDATA_FAILED: Result := 'D3DERR_MATERIAL_SETDATA_FAILED';
D3DERR_MATERIAL_GETDATA_FAILED: Result := 'D3DERR_MATERIAL_GETDATA_FAILED';
 
D3DERR_INVALIDPALETTE: Result := 'D3DERR_INVALIDPALETTE';
 
D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY: Result := 'D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY';
D3DERR_ZBUFF_NEEDS_VIDEOMEMORY: Result := 'D3DERR_ZBUFF_NEEDS_VIDEOMEMORY';
D3DERR_SURFACENOTINVIDMEM: Result := 'D3DERR_SURFACENOTINVIDMEM';
 
D3DERR_LIGHT_SET_FAILED: Result := 'D3DERR_LIGHT_SET_FAILED';
D3DERR_LIGHTHASVIEWPORT: Result := 'D3DERR_LIGHTHASVIEWPORT';
D3DERR_LIGHTNOTINTHISVIEWPORT: Result := 'D3DERR_LIGHTNOTINTHISVIEWPORT';
 
D3DERR_SCENE_IN_SCENE: Result := 'D3DERR_SCENE_IN_SCENE';
D3DERR_SCENE_NOT_IN_SCENE: Result := 'D3DERR_SCENE_NOT_IN_SCENE';
D3DERR_SCENE_BEGIN_FAILED: Result := 'D3DERR_SCENE_BEGIN_FAILED';
D3DERR_SCENE_END_FAILED: Result := 'D3DERR_SCENE_END_FAILED';
 
D3DERR_INBEGIN: Result := 'D3DERR_INBEGIN';
D3DERR_NOTINBEGIN: Result := 'D3DERR_NOTINBEGIN';
D3DERR_NOVIEWPORTS: Result := 'D3DERR_NOVIEWPORTS';
D3DERR_VIEWPORTDATANOTSET: Result := 'D3DERR_VIEWPORTDATANOTSET';
D3DERR_VIEWPORTHASNODEVICE: Result := 'D3DERR_VIEWPORTHASNODEVICE';
D3DERR_NOCURRENTVIEWPORT: Result := 'D3DERR_NOCURRENTVIEWPORT';
 
D3DERR_INVALIDVERTEXFORMAT: Result := 'D3DERR_INVALIDVERTEXFORMAT';
 
D3DERR_COLORKEYATTACHED: Result := 'D3DERR_COLORKEYATTACHED';
 
D3DERR_VERTEXBUFFEROPTIMIZED: Result := 'D3DERR_VERTEXBUFFEROPTIMIZED';
D3DERR_VBUF_CREATE_FAILED: Result := 'D3DERR_VBUF_CREATE_FAILED';
D3DERR_VERTEXBUFFERLOCKED: Result := 'D3DERR_VERTEXBUFFERLOCKED';
 
D3DERR_ZBUFFER_NOTPRESENT: Result := 'D3DERR_ZBUFFER_NOTPRESENT';
D3DERR_STENCILBUFFER_NOTPRESENT: Result := 'D3DERR_STENCILBUFFER_NOTPRESENT';
 
D3DERR_WRONGTEXTUREFORMAT: Result := 'D3DERR_WRONGTEXTUREFORMAT';
D3DERR_UNSUPPORTEDCOLOROPERATION: Result := 'D3DERR_UNSUPPORTEDCOLOROPERATION';
D3DERR_UNSUPPORTEDCOLORARG: Result := 'D3DERR_UNSUPPORTEDCOLORARG';
D3DERR_UNSUPPORTEDALPHAOPERATION: Result := 'D3DERR_UNSUPPORTEDALPHAOPERATION';
D3DERR_UNSUPPORTEDALPHAARG: Result := 'D3DERR_UNSUPPORTEDALPHAARG';
D3DERR_TOOMANYOPERATIONS: Result := 'D3DERR_TOOMANYOPERATIONS';
D3DERR_CONFLICTINGTEXTUREFILTER: Result := 'D3DERR_CONFLICTINGTEXTUREFILTER';
D3DERR_UNSUPPORTEDFACTORVALUE: Result := 'D3DERR_UNSUPPORTEDFACTORVALUE';
 
D3DERR_CONFLICTINGRENDERSTATE: Result := 'D3DERR_CONFLICTINGRENDERSTATE';
D3DERR_UNSUPPORTEDTEXTUREFILTER: Result := 'D3DERR_UNSUPPORTEDTEXTUREFILTER';
D3DERR_TOOMANYPRIMITIVES: Result := 'D3DERR_TOOMANYPRIMITIVES';
D3DERR_INVALIDMATRIX: Result := 'D3DERR_INVALIDMATRIX';
D3DERR_TOOMANYVERTICES: Result := 'D3DERR_TOOMANYVERTICES';
D3DERR_CONFLICTINGTEXTUREPALETTE: Result := 'D3DERR_CONFLICTINGTEXTUREPALETTE';
 
else Result := 'Unrecognized Error';
Result := typ + D3DSTATE_OVERRIDE_BIAS;
end;
end;
{$IFDEF D3DRM}
//Direct3DRM file
 
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: d3drmdef.h
* Content: Direct3DRM include file
*
***************************************************************************)
 
procedure D3DRMAnimationGetRotateKey
(var rmKey: TD3DRMAnimationKey; var rmQuat: TD3DRMQuaternion);
function D3DRENDERSTATE_STIPPLEPATTERN(y: DWORD): TD3DRenderStateType;
begin
rmQuat := rmKey.dqRotateKey;
Result := TD3DRenderStateType(Ord(D3DRENDERSTATE_STIPPLEPATTERN00)+y);
end;
 
procedure D3DRMAnimationGetScaleKey
(var rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
function D3DTRIFLAG_STARTFLAT(len: DWORD) : DWORD;
begin
dvVec := rmKey.dvScaleKey;
if not (len in [1..29]) then len := 0;
result := len;
end;
 
procedure D3DRMAnimationGetPositionKey
(var rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
function D3DFVF_TEXCOORDSIZE3(CoordIndex: DWORD): DWORD;
begin
dvVec := rmKey.dvPositionKey;
Result := D3DFVF_TEXTUREFORMAT3 shl (CoordIndex*2 + 16);
end;
 
procedure D3DRMAnimatioSetRotateKey
(var rmKey: TD3DRMAnimationKey; var rmQuat: TD3DRMQuaternion);
function D3DFVF_TEXCOORDSIZE2(CoordIndex: DWORD): DWORD;
begin
rmKey.dqRotateKey := rmQuat;
Result := D3DFVF_TEXTUREFORMAT2;
end;
 
procedure D3DRMAnimationSetScaleKey
(var rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
function D3DFVF_TEXCOORDSIZE4(CoordIndex: DWORD): DWORD;
begin
rmKey.dvScaleKey := dvVec;
Result := D3DFVF_TEXTUREFORMAT4 shl (CoordIndex*2 + 16);
end;
 
procedure D3DRMAnimationSetPositionKey
(var rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
function D3DFVF_TEXCOORDSIZE1(CoordIndex: DWORD): DWORD;
begin
rmKey.dvPositionKey := dvVec;
Result := D3DFVF_TEXTUREFORMAT1 shl (CoordIndex*2 + 16);
end;
 
(*==========================================================================;
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: d3drm.h
* Content: Direct3DRM include file
*
***************************************************************************)
{ Direct3DRM }
 
function D3DRMErrorString(Value: HResult) : string;
procedure D3DRMAnimationGetRotateKey(const rmKey: TD3DRMAnimationKey; var rmQuat: TD3DRMQuaternion);
begin
case Value of
D3DRM_OK: Result := 'No error. Equivalent to DD_OK.';
D3DRMERR_BADALLOC: Result := 'Out of memory.';
D3DRMERR_BADDEVICE: Result := 'Device is not compatible with renderer.';
D3DRMERR_BADFILE: Result := 'Data file is corrupt.';
D3DRMERR_BADMAJORVERSION: Result := 'Bad DLL major version.';
D3DRMERR_BADMINORVERSION: Result := 'Bad DLL minor version.';
D3DRMERR_BADOBJECT: Result := 'Object expected in argument.';
D3DRMERR_BADPMDATA: Result := 'The data in the .x file is corrupted. The conversion to a progressive mesh succeeded but produced an invalid progressive mesh in the .x file.';
D3DRMERR_BADTYPE: Result := 'Bad argument type passed.';
D3DRMERR_BADVALUE: Result := 'Bad argument value passed.';
D3DRMERR_BOXNOTSET: Result := 'An attempt was made to access a bounding box (for example, with IDirect3DRMFrame3::GetBox) when no bounding box was set on the frame.';
D3DRMERR_CLIENTNOTREGISTERED: Result := 'Client has not been registered. Call IDirect3DRM3::RegisterClient.';
D3DRMERR_CONNECTIONLOST: Result := 'Data connection was lost during a load, clone, or duplicate.';
D3DRMERR_ELEMENTINUSE: Result := 'Element can´t be modified or deleted while in use. To empty a submesh, call Empty() against its parent.';
// D3DRMERR_ENTRYINUSE: Result := 'Vertex or normal entries are currently in use by a face and cannot be deleted.';
D3DRMERR_FACEUSED: Result := 'Face already used in a mesh.';
D3DRMERR_FILENOTFOUND: Result := 'File cannot be opened.';
// D3DRMERR_INCOMPATIBLEKEY: Result := 'Specified animation key is incompatible. The key cannot be modified.';
D3DRMERR_INVALIDLIBRARY: Result := 'Specified libary is invalid.';
// D3DRMERR_INVALIDOBJECT: Result := 'Method received a pointer to an object that is invalid.';
// D3DRMERR_INVALIDPARAMS: Result := 'One of the parameters passed to the method is invalid.';
D3DRMERR_LIBRARYNOTFOUND: Result := 'Specified libary not found.';
D3DRMERR_LOADABORTED: Result := 'Load aborted by user.';
D3DRMERR_NOSUCHKEY: Result := 'Specified animation key does not exist.';
D3DRMERR_NOTCREATEDFROMDDS: Result := 'Specified texture was not created from a DirectDraw Surface.';
D3DRMERR_NOTDONEYET: Result := 'Unimplemented.';
D3DRMERR_NOTENOUGHDATA: Result := 'Not enough data has been loaded to perform the requested operation.';
D3DRMERR_NOTFOUND: Result := 'Object not found in specified place.';
// D3DRMERR_OUTOFRANGE: Result := 'Specified value is out of range.';
D3DRMERR_PENDING: Result := 'Data required to supply the requested information has not finished loading.';
D3DRMERR_REQUESTTOOLARGE: Result := 'Attempt was made to set a level of detail in a progressive mesh greater than the maximum available.';
D3DRMERR_REQUESTTOOSMALL: Result := 'Attempt was made to set the minimum rendering detail of a progressive mesh smaller than the detail in the base mesh (the minimum for rendering).';
D3DRMERR_TEXTUREFORMATNOTFOUND: Result := 'Texture format could not be found that meets the specified criteria and that the underlying Immediate Mode device supports.';
D3DRMERR_UNABLETOEXECUTE: Result := 'Unable to carry out procedure.';
DDERR_INVALIDOBJECT: Result := 'Received pointer that was an invalid object.';
DDERR_INVALIDPARAMS: Result := 'One or more of the parameters passed to the method are incorrect.';
DDERR_NOTFOUND: Result := 'The requested item was not found.';
DDERR_NOTINITIALIZED: Result := 'An attempt was made to call an interface method of an object created by CoCreateInstance before the object was initialized.';
DDERR_OUTOFMEMORY: Result := 'DirectDraw does not have enough memory to perform the operation.';
else Result := 'Unrecognized Error';
rmQuat.s := rmKey.dvK[0];
rmQuat.v.x := rmKey.dvK[1];
rmQuat.v.y := rmKey.dvK[2];
rmQuat.v.z := rmKey.dvK[3];
end;
end;
{$ENDIF}
//DirectInput file
 
 
function DIMAKEUSAGEDWORD(UsagePage, Usage: WORD) : DWORD;
procedure D3DRMAnimationGetScaleKey(const rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
begin
Result := Usage or (UsagePage shl 16);
dvVec.x := rmKey.dvK[0];
dvVec.y := rmKey.dvK[1];
dvVec.z := rmKey.dvK[2];
end;
 
 
function DIEFT_GETTYPE(n: variant) : byte;
procedure D3DRMAnimationGetPositionKey(const rmKey: TD3DRMAnimationKey; var dvVec: TD3DVector);
begin
Result := byte(n);
dvVec.x := rmKey.dvK[0];
dvVec.y := rmKey.dvK[1];
dvVec.z := rmKey.dvK[2];
end;
 
function GET_DIDEVICE_TYPE(dwDevType: variant) : byte;
procedure D3DRMAnimationSetRotateKey(var rmKey: TD3DRMAnimationKey; const rmQuat: TD3DRMQuaternion);
begin
Result := byte(dwDevType);
rmKey.dvK[0] := rmQuat.s;
rmKey.dvK[1] := rmQuat.v.x;
rmKey.dvK[2] := rmQuat.v.y;
rmKey.dvK[3] := rmQuat.v.z;
end;
 
function GET_DIDEVICE_SUBTYPE(dwDevType: variant) : byte;
procedure D3DRMAnimationSetScaleKey(var rmKey: TD3DRMAnimationKey; const dvVec: TD3DVector);
begin
Result := hi(word(dwDevType));
rmKey.dvK[0] := dvVec.x;
rmKey.dvK[1] := dvVec.y;
rmKey.dvK[2] := dvVec.z;
end;
 
function DIDFT_MAKEINSTANCE(n: variant) : DWORD;
procedure D3DRMAnimationSetPositionKey(var rmKey: TD3DRMAnimationKey; const dvVec: TD3DVector);
begin
Result := word(n) shl 8;
rmKey.dvK[0] := dvVec.x;
rmKey.dvK[1] := dvVec.y;
rmKey.dvK[2] := dvVec.z;
end;
 
function DIDFT_GETTYPE(n: variant) : byte;
begin
Result := byte(n);
end;
function Direct3DRMCreate; external D3DRMLib;
 
function DIDFT_GETINSTANCE(n: variant) : DWORD;
begin
Result := word(n) shr 8;
end;
function D3DRMCreateColorRGB; external D3DRMLib;
function D3DRMCreateColorRGBA; external D3DRMLib;
function D3DRMColorGetRed; external D3DRMLib;
function D3DRMColorGetGreen; external D3DRMLib;
function D3DRMColorGetBlue; external D3DRMLib;
function D3DRMColorGetAlpha; external D3DRMLib;
function D3DRMVectorAdd; external D3DRMLib;
function D3DRMVectorSubtract; external D3DRMLib;
function D3DRMVectorReflect; external D3DRMLib;
function D3DRMVectorCrossProduct; external D3DRMLib;
function D3DRMVectorDotProduct; external D3DRMLib;
function D3DRMVectorNormalize; external D3DRMLib;
function D3DRMVectorModulus; external D3DRMLib;
function D3DRMVectorRotate; external D3DRMLib;
function D3DRMVectorScale; external D3DRMLib;
function D3DRMVectorRandom; external D3DRMLib;
function D3DRMQuaternionFromRotation; external D3DRMLib;
function D3DRMQuaternionMultiply; external D3DRMLib;
function D3DRMQuaternionSlerp; external D3DRMLib;
procedure D3DRMMatrixFromQuaternion; external D3DRMLib;
function D3DRMQuaternionFromMatrix; external D3DRMLib;
 
function DIDFT_ENUMCOLLECTION(n: variant) : DWORD;
begin
Result := word(n) shl 8;
end;
function DirectXFileCreate; external D3DXofLib;
 
function DIJOFS_SLIDER(n: variant) : variant;
begin
Result := n * 4 + 24;
end;
{ DirectInput }
 
function DIJOFS_POV(n: variant) : variant;
function GET_DIDEVICE_TYPE(dwDevType: DWORD): DWORD;
begin
Result := n * 4 + 32;
Result := LOBYTE(dwDevType);
end;
 
function DIJOFS_BUTTON(n: variant) : variant;
function GET_DIDEVICE_SUBTYPE(dwDevType: DWORD): DWORD;
begin
Result := 48 + n;
Result := HIBYTE(dwDevType);
end;
 
function DIErrorString(Value: HResult) : string;
var
sValue: array[0..255] of char;
function DIEFT_GETTYPE(n: DWORD): DWORD;
begin
case Value of
DI_OK: Result := 'The operation completed successfully.';
S_FALSE: Result := '"The operation had no effect." or "The device buffer overflowed and some input was lost." or "The device exists but is not currently attached." or "The change in device properties had no effect."';
// DI_BUFFEROVERFLOW: Result := 'The device buffer overflowed and some input was lost. This value is equal to the S_FALSE standard COM return value.';
DI_DOWNLOADSKIPPED: Result := 'The parameters of the effect were successfully updated, but the effect could not be downloaded because the associated device was not acquired in exclusive mode.';
DI_EFFECTRESTARTED: Result := 'The effect was stopped, the parameters were updated, and the effect was restarted.';
// DI_NOEFFECT: Result := 'The operation had no effect. This value is equal to the S_FALSE standard COM return value.';
// DI_NOTATTACHED: Result := 'The device exists but is not currently attached. This value is equal to the S_FALSE standard COM return value.';
DI_POLLEDDEVICE: Result := 'The device is a polled device. As a result, device buffering will not collect any data and event notifications will not be signaled until the IDirectInputDevice2::Poll method is called.';
// DI_PROPNOEFFECT: Result := 'The change in device properties had no effect. This value is equal to the S_FALSE standard COM return value.';
DI_TRUNCATED: Result := 'The parameters of the effect were successfully updated, but some of them were beyond the capabilities of the device and were truncated to the nearest supported value.';
DI_TRUNCATEDANDRESTARTED: Result := 'Equal to DI_EFFECTRESTARTED | DI_TRUNCATED.';
DIERR_ACQUIRED: Result := 'The operation cannot be performed while the device is acquired.';
DIERR_ALREADYINITIALIZED: Result := 'This object is already initialized';
DIERR_BADDRIVERVER: Result := 'The object could not be created due to an incompatible driver version or mismatched or incomplete driver components.';
DIERR_BETADIRECTINPUTVERSION: Result := 'The application was written for an unsupported prerelease version of DirectInput.';
DIERR_DEVICEFULL: Result := 'The device is full.';
DIERR_DEVICENOTREG: Result := 'The device or device instance is not registered with DirectInput. This value is equal to the REGDB_E_CLASSNOTREG standard COM return value.';
DIERR_EFFECTPLAYING: Result := 'The parameters were updated in memory but were not downloaded to the device because the device does not support updating an effect while it is still playing.';
DIERR_HASEFFECTS: Result := 'The device cannot be reinitialized because there are still effects attached to it.';
DIERR_GENERIC: Result := 'An undetermined error occurred inside the DirectInput subsystem. This value is equal to the E_FAIL standard COM return value.';
// DIERR_HANDLEEXISTS: Result := 'The device already has an event notification associated with it. This value is equal to the E_ACCESSDENIED standard COM return value.';
DIERR_INCOMPLETEEFFECT: Result := 'The effect could not be downloaded because essential information is missing. For example, no axes have been associated with the effect, or no type-specific information has been supplied.';
DIERR_INPUTLOST: Result := 'Access to the input device has been lost. It must be reacquired.';
DIERR_INVALIDPARAM: Result := 'An invalid parameter was passed to the returning function, or the object was not in a state that permitted the function to be called. This value is equal to the E_INVALIDARG standard COM return value.';
DIERR_MOREDATA: Result := 'Not all the requested information fitted into the buffer.';
DIERR_NOAGGREGATION: Result := 'This object does not support aggregation.';
DIERR_NOINTERFACE: Result := 'The specified interface is not supported by the object. This value is equal to the E_NOINTERFACE standard COM return value.';
DIERR_NOTACQUIRED: Result := 'The operation cannot be performed unless the device is acquired.';
DIERR_NOTBUFFERED: Result := 'The device is not buffered. Set the DIPROP_BUFFERSIZE property to enable buffering.';
DIERR_NOTDOWNLOADED: Result := 'The effect is not downloaded.';
DIERR_NOTEXCLUSIVEACQUIRED: Result := 'The operation cannot be performed unless the device is acquired in DISCL_EXCLUSIVE mode.';
DIERR_NOTFOUND: Result := 'The requested object does not exist.';
DIERR_NOTINITIALIZED: Result := 'This object has not been initialized.';
// DIERR_OBJECTNOTFOUND: Result := 'The requested object does not exist.';
DIERR_OLDDIRECTINPUTVERSION: Result := 'The application requires a newer version of DirectInput.';
DIERR_OTHERAPPHASPRIO: Result := '"The device already has an event notification associated with it." or "The specified property cannot be changed." or "Another application has a higher priority level, preventing this call from succeeding. "';
DIERR_OUTOFMEMORY: Result := 'The DirectInput subsystem could not allocate sufficient memory to complete the call. This value is equal to the E_OUTOFMEMORY standard COM return value.';
// DIERR_READONLY: Result := 'The specified property cannot be changed. This value is equal to the E_ACCESSDENIED standard COM return value.';
DIERR_UNSUPPORTED: Result := 'The function called is not supported at this time. This value is equal to the E_NOTIMPL standard COM return value.';
E_PENDING: Result := 'Data is not yet available.';
HResult($800405CC): Result := 'No more memory for effects of this kind (not documented)';
else Result := 'Unrecognized Error: $' + sValue;
Result := LOBYTE(n);
end;
end;
 
function joyConfigChanged(dwFlags: DWORD) : MMRESULT; external 'WinMM.dll';
 
procedure Init_c_dfDIKeyboard_Objects; // XRef: Initialization
var x: Cardinal;
function DIDFT_MAKEINSTANCE(n: WORD): DWORD;
begin
for x := 0 to 255 do
with _c_dfDIKeyboard_Objects[x] do
begin
pGuid := @GUID_Key; dwOfs := x; dwFlags := 0;
dwType := $80000000 or DIDFT_BUTTON or x shl 8;
Result := n shl 8;
end;
end;
 
procedure Init_c_dfDIJoystick2_Objects; // XRef: Initialization
var x,y, OfVal: Cardinal;
function DIDFT_GETTYPE(n: DWORD): DWORD;
begin
Move(_c_dfDIJoystick_Objects,_c_dfDIJoystick2_Objects,SizeOf(_c_dfDIJoystick_Objects));
// all those empty "buttons"
for x := $2C to $8B do
Move(_c_dfDIJoystick_Objects[$2B],_c_dfDIJoystick2_Objects[x],SizeOf(TDIObjectDataFormat));
for x := 0 to 2 do
begin // 3 more blocks of X axis..Sliders
Move(_c_dfDIJoystick_Objects,_c_dfDIJoystick2_Objects[$8C+8*x],8*SizeOf(TDIObjectDataFormat));
for y := 0 to 7 do _c_dfDIJoystick2_Objects[$8C+8*x+y].dwFlags := (x+1) shl 8;
Result := LOBYTE(n);
end;
OfVal := _c_dfDIJoystick2_Objects[$2B].dwOfs+1;
for x := $2C to $A3 do
begin
_c_dfDIJoystick2_Objects[x].dwOfs := OfVal;
if x < $8C then Inc(OfVal) else Inc(OfVal,4);
end;
end;
 
//DirectPlay file
{$IFDEF UseDirectPlay} // Daniel Marschall 12.04.2024 Added to avoid Windows showing "This app requires DirectPlay"
 
(*==========================================================================;
*
* Copyright (C) 1994-1997 Microsoft Corporation. All Rights Reserved.
*
* File: dplay.h
* Content: DirectPlay include file
*
***************************************************************************)
 
function DPErrorString(Value: HResult) : string;
function DIDFT_GETINSTANCE(n: DWORD): WORD;
begin
case Value of
CLASS_E_NOAGGREGATION: Result := 'A non-NULL value was passed for the pUnkOuter parameter in DirectPlayCreate, DirectPlayLobbyCreate, or IDirectPlayLobby2::Connect.';
DPERR_ACCESSDENIED: Result := 'The session is full or an incorrect password was supplied.';
DPERR_ACTIVEPLAYERS: Result := 'The requested operation cannot be performed because there are existing active players.';
DPERR_ALREADYINITIALIZED: Result := 'This object is already initialized.';
DPERR_APPNOTSTARTED: Result := 'The application has not been started yet.';
DPERR_AUTHENTICATIONFAILED: Result := 'The password or credentials supplied could not be authenticated.';
DPERR_BUFFERTOOLARGE: Result := 'The data buffer is too large to store.';
DPERR_BUSY: Result := 'A message cannot be sent because the transmission medium is busy.';
DPERR_BUFFERTOOSMALL: Result := 'The supplied buffer is not large enough to contain the requested data.';
DPERR_CANTADDPLAYER: Result := 'The player cannot be added to the session.';
DPERR_CANTCREATEGROUP: Result := 'A new group cannot be created.';
DPERR_CANTCREATEPLAYER: Result := 'A new player cannot be created.';
DPERR_CANTCREATEPROCESS: Result := 'Cannot start the application.';
DPERR_CANTCREATESESSION: Result := 'A new session cannot be created.';
DPERR_CANTLOADCAPI: Result := 'No credentials were supplied and the CryptoAPI package (CAPI) to use for cryptography services cannot be loaded.';
DPERR_CANTLOADSECURITYPACKAGE: Result := 'The software security package cannot be loaded.';
DPERR_CANTLOADSSPI: Result := 'No credentials were supplied and the software security package (SSPI) that will prompt for credentials cannot be loaded.';
DPERR_CAPSNOTAVAILABLEYET: Result := 'The capabilities of the DirectPlay object have not been determined yet. This error will occur if the DirectPlay object is implemented on a connectivity solution that requires polling to determine available bandwidth and latency.';
DPERR_CONNECTING: Result := 'The method is in the process of connecting to the network. The application should keep calling the method until it returns DP_OK, indicating successful completion, or it returns a different error.';
DPERR_ENCRYPTIONFAILED: Result := 'The requested information could not be digitally encrypted. Encryption is used for message privacy. This error is only relevant in a secure session.';
DPERR_EXCEPTION: Result := 'An exception occurred when processing the request.';
DPERR_GENERIC: Result := 'An undefined error condition occurred.';
// DPERR_INVALIDCREDENTIALS: Result := 'The credentials supplied (as to IDirectPlay3::SecureOpen) were not valid.';
DPERR_INVALIDFLAGS: Result := 'The flags passed to this method are invalid.';
DPERR_INVALIDGROUP: Result := 'The group ID is not recognized as a valid group ID for this game session.';
DPERR_INVALIDINTERFACE: Result := 'The interface parameter is invalid.';
DPERR_INVALIDOBJECT: Result := 'The DirectPlay object pointer is invalid.';
DPERR_INVALIDPARAMS: Result := 'One or more of the parameters passed to the method are invalid.';
DPERR_INVALIDPASSWORD: Result := 'An invalid password was supplied when attempting to join a session that requires a password.';
DPERR_INVALIDPLAYER: Result := 'The player ID is not recognized as a valid player ID for this game session.';
DPERR_LOGONDENIED: Result := 'The session could not be opened because credentials are required and either no credentials were supplied or the credentials were invalid.';
DPERR_NOCAPS: Result := 'The communication link that DirectPlay is attempting to use is not capable of this function.';
DPERR_NOCONNECTION: Result := 'No communication link was established.';
DPERR_NOINTERFACE: Result := 'The interface is not supported.';
DPERR_NOMESSAGES: Result := 'There are no messages in the receive queue.';
DPERR_NONAMESERVERFOUND: Result := 'No name server (host) could be found or created. A host must exist to create a player.';
DPERR_NONEWPLAYERS: Result := 'The session is not accepting any new players.';
DPERR_NOPLAYERS: Result := 'There are no active players in the session.';
DPERR_NOSESSIONS: Result := 'There are no existing sessions for this game.';
DPERR_NOTLOBBIED: Result := 'Returned by the IDirectPlayLobby2::Connect method if the application was not started by using the IDirectPlayLobby2::RunApplication method or if there is no DPLCONNECTION structure currently initialized for this DirectPlayLobby object.';
DPERR_NOTLOGGEDIN: Result := 'An action cannot be performed because a player or client application is not logged in. Returned by the IDirectPlay3::Send method when the client application tries to send a secure message without being logged in.';
DPERR_OUTOFMEMORY: Result := 'There is insufficient memory to perform the requested operation.';
DPERR_PLAYERLOST: Result := 'A player has lost the connection to the session.';
DPERR_SENDTOOBIG: Result := 'The message being sent by the IDirectPlay3::Send method is too large.';
DPERR_SESSIONLOST: Result := 'The connection to the session has been lost.';
DPERR_SIGNFAILED: Result := 'The requested information could not be digitally signed. Digital signatures are used to establish the authenticity of messages.';
DPERR_TIMEOUT: Result := 'The operation could not be completed in the specified time.';
DPERR_UNAVAILABLE: Result := 'The requested function is not available at this time.';
DPERR_UNINITIALIZED: Result := 'The requested object has not been initialized.';
DPERR_UNKNOWNAPPLICATION: Result := 'An unknown application was specified.';
DPERR_UNSUPPORTED: Result := 'The function is not available in this implementation. Returned from IDirectPlay3::GetGroupConnectionSettings and IDirectPlay3::SetGroupConnectionSettings if they are called from a session that is not a lobby session.';
DPERR_USERCANCEL: Result := 'Can be returned in two ways. 1) The user canceled the connection process during a call to the IDirectPlay3::Open method. 2) The user clicked Cancel in one of the DirectPlay service provider dialog boxes during a call to IDirectPlay3::EnumSessions.';
else Result := 'Unrecognized Error';
Result := n shr 8;
end;
end;
{$ENDIF} // UseDirectPlay
 
//DirectSetup file
 
(*==========================================================================
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: dsetup.h
* Content: DirectXSetup, error codes and flags
***************************************************************************)
 
procedure LoadDSetup;
 
function RegGetStringValue(Hive: HKEY; const KeyName, ValueName: string): string;
var EnvKey : HKEY;
Buf : array[0..255] of char;
BufSize : DWord;
RegType : DWord;
rc : DWord;
function DIDFT_ENUMCOLLECTION(n: WORD): DWORD;
begin
Result := '';
BufSize := Sizeof(Buf);
ZeroMemory(@Buf, BufSize);
RegType := REG_SZ;
try
if (RegOpenKeyEx(Hive, PChar(KeyName), 0, KEY_READ, EnvKey) = ERROR_SUCCESS) then
begin
try
if (ValueName = '') then rc := RegQueryValueEx(EnvKey, nil, nil, @RegType, @Buf, @BufSize)
else rc := RegQueryValueEx(EnvKey, PChar(ValueName), nil, @RegType, @Buf, @BufSize);
if rc = ERROR_SUCCESS then Result := string(Buf);
finally
RegCloseKey(EnvKey);
Result := n shl 8;
end;
end;
finally
RegCloseKey(Hive);
end;
end;
 
 
function ExistFile(const FileName: string): Boolean;
var hFile: THandle;
function DIMAKEUSAGEDWORD(UsagePage, Usage: Word): DWORD;
begin
hFile := CreateFile(PChar(FileName), 0, 0, nil, OPEN_EXISTING, 0, 0);
Result := hFile <> INVALID_HANDLE_VALUE;
if hFile = INVALID_HANDLE_VALUE then CloseHandle(hFile);
Result := MAKELONG(Usage, UsagePage);
end;
 
function GetDSetupDLLPath : string;
begin
Result := RegGetStringValue(HKEY_LOCAL_MACHINE,
'Software\Microsoft\Windows\CurrentVersion\Uninstall\DirectXDrivers',
'UninstallString');
if Result <> '' then
Result := Copy(Result,1,Length(Result)-Length('dxsetup.exe')) + 'DSetup.dll';
end;
function DirectInputCreate; external DInputLib name 'DirectInputCreateA';
function DirectInputCreateEx; external DInputLib name 'DirectInputCreateEx';
 
begin
DSetupDLL := LoadLibrary(PChar(GetDSetupDLLPath));
{ DirectPlay }
 
DirectXSetupA := GetProcAddress(DSetupDLL,'DirectXSetupA');
DirectXSetupW := GetProcAddress(DSetupDLL,'DirectXSetupW');
{$IFDEF UNICODE}
DirectXSetup := DirectXSetupW;
{$ELSE}
DirectXSetup := DirectXSetupA;
{$ENDIF}
function DirectPlayEnumerateA; external DPlayXLib;
function DirectPlayEnumerateW; external DPlayXLib;
function DirectPlayEnumerate; external DPlayXLib name 'DirectPlayEnumerateA';
 
DirectXDeviceDriverSetupA :=
GetProcAddress(DSetupDLL,'DirectXDeviceDriverSetupA');
DirectXDeviceDriverSetupW :=
GetProcAddress(DSetupDLL,'DirectXDeviceDriverSetupW');
{$IFDEF UNICODE}
DirectXDeviceDriverSetup := DirectXDeviceDriverSetupW;
{$ELSE}
DirectXDeviceDriverSetup := DirectXDeviceDriverSetupA;
{$ENDIF}
function DirectPlayCreate; external DPlayXLib;
 
DirectXRegisterApplicationA :=
GetProcAddress(DSetupDLL,'DirectXRegisterApplicationA');
DirectXRegisterApplicationW :=
GetProcAddress(DSetupDLL,'DirectXRegisterApplicationW');
{$IFDEF UNICODE}
DirectXRegisterApplication := DirectXRegisterApplicationW;
{$ELSE}
DirectXRegisterApplication := DirectXRegisterApplicationA;
{$ENDIF}
function DirectPlayLobbyCreateW; external DPlayXLib;
function DirectPlayLobbyCreateA; external DPlayXLib;
function DirectPlayLobbyCreate; external DPlayXLib name 'DirectPlayLobbyCreateA';
 
DirectXUnRegisterApplication :=
GetProcAddress(DSetupDLL,'DirectXUnRegisterApplication');
{ DirectSetup }
 
DirectXSetupSetCallback :=
GetProcAddress(DSetupDLL,'DirectXSetupSetCallback');
function DirectXSetupA; external DSetupLib;
function DirectXSetupW; external DSetupLib;
function DirectXSetup; external DSetupLib name 'DirectXSetupA';
 
DirectXSetupGetVersion := GetProcAddress(DSetupDLL,'DirectXSetupGetVersion');
function DirectXDeviceDriverSetupA; external DSetupLib;
function DirectXDeviceDriverSetupW; external DSetupLib;
function DirectXDeviceDriverSetup; external DSetupLib name 'DirectXDeviceDriverSetupA';
 
end;
function DirectXRegisterApplicationA; external DSetupLib;
function DirectXRegisterApplicationW; external DSetupLib;
function DirectXRegisterApplication; external DSetupLib name 'DirectXRegisterApplicationA';
 
//DirectSound file
function DirectXUnRegisterApplication; external DSetupLib;
 
function MAKE_DSHRESULT(code: DWORD) : HResult;
begin
Result := HResult(1 shl 31) or HResult(_FACDS shl 16)
or HResult(code);
end;
function DirectXSetupSetCallback; external DSetupLib;
 
function DSSPEAKER_COMBINED(c, g: variant) : DWORD;
begin
Result := byte(c) or (byte(g) shl 16)
end;
function DirectXSetupGetVersion; external DSetupLib;
 
function DSSPEAKER_CONFIG(a: variant) : byte;
begin
Result := byte(a);
end;
{ DirectSound }
 
function DSSPEAKER_GEOMETRY(a: variant) : byte;
function DSSPEAKER_COMBINED(c, g: Byte): DWORD;
begin
Result := byte(a shr 16 and $FF);
Result := c or (g shl 16);
end;
 
 
function DSErrorString(Value: HResult) : string;
function DSSPEAKER_CONFIG(a: DWORD): Byte;
begin
case Value of
DS_OK: Result := 'The request completed successfully.';
DSERR_ALLOCATED: Result := 'The request failed because resources, such as a priority level, were already in use by another caller.';
DSERR_ALREADYINITIALIZED: Result := 'The object is already initialized.';
DSERR_BADFORMAT: Result := 'The specified wave format is not supported.';
DSERR_BUFFERLOST: Result := 'The buffer memory has been lost and must be restored.';
DSERR_CONTROLUNAVAIL: Result := 'The control (volume, pan, and so forth) requested by the caller is not available.';
DSERR_GENERIC: Result := 'An undetermined error occurred inside the DirectSound subsystem.';
DSERR_INVALIDCALL: Result := 'This function is not valid for the current state of this object.';
DSERR_INVALIDPARAM: Result := 'An invalid parameter was passed to the returning function.';
DSERR_NOAGGREGATION: Result := 'The object does not support aggregation.';
DSERR_NODRIVER: Result := 'No sound driver is available for use.';
DSERR_NOINTERFACE: Result := 'The requested COM interface is not available.';
DSERR_OTHERAPPHASPRIO: Result := 'Another application has a higher priority level, preventing this call from succeeding.';
DSERR_OUTOFMEMORY: Result := 'The DirectSound subsystem could not allocate sufficient memory to complete the caller´s request.';
DSERR_PRIOLEVELNEEDED: Result := 'The caller does not have the priority level required for the function to succeed.';
DSERR_UNINITIALIZED: Result := 'The IDirectSound::Initialize method has not been called or has not been called successfully before other methods were called.';
DSERR_UNSUPPORTED: Result := 'The function called is not supported at this time.';
else Result := 'Unrecognized Error';
Result := a;
end;
end;
 
//DirectMusic file
 
function MAKE_HRESULT(sev,fac,code: DWORD) : HResult;
function DSSPEAKER_GEOMETRY(a: DWORD): Byte;
begin
Result := (sev shl 31) or (fac shl 16) or code;
Result := a shr 16;
end;
 
//function MAKEFOURCC (ch0, ch1, ch2, ch3: Char) : TFourCC;
//type
// tfcc = array [0..3] of Char;
//begin
// tfcc(Result)[0] := ch0;
// tfcc(Result)[1] := ch1;
// tfcc(Result)[2] := ch2;
// tfcc(Result)[3] := ch3;
//end;
function DirectSoundCreate; external DSoundLib;
function DirectSoundEnumerateA; external DSoundLib;
function DirectSoundEnumerateW; external DSoundLib;
function DirectSoundEnumerate; external DSoundLib name 'DirectSoundEnumerateA';
 
function QWORD_ALIGN(x: DWORD) : DWORD;
begin
Result := (x + 7) and (not 7); // (((x) + 7) & ~7)
end;
function DirectSoundCaptureCreate; external DSoundLib;
function DirectSoundCaptureEnumerateA; external DSoundLib;
function DirectSoundCaptureEnumerateW; external DSoundLib;
function DirectSoundCaptureEnumerate; external DSoundLib name 'DirectSoundCaptureEnumerateA';
 
function DMUS_EVENT_SIZE(cb: DWORD) : DWORD;
function MAKEFOURCC(ch0, ch1, ch2, ch3: Char) : DWORD;
begin
Result := QWORD_ALIGN(SizeOf(TDMus_EventHeader) + cb); // QWORD_ALIGN(sizeof(DMUS_EVENTHEADER) + cb)
Result := Ord(ch0) + (Ord(ch1) shl 8) + (Ord(ch2) shl 16) + (Ord(ch3) shl 24);
end;
 
function IsNTandDelphiRunning : boolean;
var
OSVersion : TOSVersionInfo;
AppName : array[0..255] of char;
function MAKE_DMHRESULTSUCCESS(code: Cardinal) : HResult;
begin
OSVersion.dwOsVersionInfoSize := sizeof(OSVersion);
GetVersionEx(OSVersion);
// Not running in NT or program is not Delphi itself ?
AppName[0] := #0;
lstrcat(AppName, PChar(ParamStr(0))); // ParamStr(0) = Application.ExeName
{$IFDEF VER12UP}
CharUpperBuff(AppName, High(AppName) + 1);
{$ELSE}
CharUpperBuff(AppName, SizeOf(AppName));
{$ENDIF}
result := ( (OSVersion.dwPlatformID = VER_PLATFORM_WIN32_NT) and
(Pos('DELPHI32.EXE', AppName) = Length(AppName) - Length('DELPHI32.EXE') + 1) );
Result := MakeResult(0, FACILITY_DIRECTMUSIC, (DMUS_ERRBASE + (code)));
end;
 
initialization
function MAKE_DMHRESULTERROR(code: Cardinal) : HResult;
begin
{DirectDraw}
 
if not IsNTandDelphiRunning then
begin
DDrawDLL := LoadLibrary('DDraw.dll');
DirectDrawEnumerateA := GetProcAddress(DDrawDLL,'DirectDrawEnumerateA');
DirectDrawEnumerateW := GetProcAddress(DDrawDLL,'DirectDrawEnumerateW');
{$IFDEF UNICODE}
DirectDrawEnumerate := DirectDrawEnumerateW;
{$ELSE}
DirectDrawEnumerate := DirectDrawEnumerateA;
{$ENDIF}
 
DirectDrawEnumerateExA := GetProcAddress(DDrawDLL,'DirectDrawEnumerateExA');
DirectDrawEnumerateExW := GetProcAddress(DDrawDLL,'DirectDrawEnumerateExW');
{$IFDEF UNICODE}
DirectDrawEnumerateEx := DirectDrawEnumerateExW;
{$ELSE}
DirectDrawEnumerateEx := DirectDrawEnumerateExA;
{$ENDIF}
 
DirectDrawCreate := GetProcAddress(DDrawDLL,'DirectDrawCreate');
DirectDrawCreateEx := GetProcAddress(DDrawDLL,'DirectDrawCreateEx');
DirectDrawCreateClipper := GetProcAddress(DDrawDLL,'DirectDrawCreateClipper');
{$IFDEF WINNT}
NtDirectDrawCreate := GetProcAddress(DDrawDLL,'NtDirectDrawCreate');
{$ENDIF}
Result := MakeResult(1, FACILITY_DIRECTMUSIC, (DMUS_ERRBASE + (code)));
end;
{DirectDraw}
{Direct3D}
DisableFPUExceptions;
{$IFDEF D3DRM}
if not IsNTandDelphiRunning then
begin
DXFileDLL := LoadLibrary('D3DXOF.DLL');
DirectXFileCreate := GetProcAddress(DXFileDLL,'DirectXFileCreate');
end;
{Direct3D}
{Direct3DRM}
if not IsNTandDelphiRunning then
begin
D3DRMDLL := LoadLibrary('D3DRM.dll');
//d3drmdef:
D3DRMCreateColorRGB := GetProcAddress(D3DRMDLL,'D3DRMCreateColorRGB');
D3DRMCreateColorRGBA := GetProcAddress(D3DRMDLL,'D3DRMCreateColorRGBA');
D3DRMColorGetRed := GetProcAddress(D3DRMDLL,'D3DRMColorGetRed');
D3DRMColorGetGreen := GetProcAddress(D3DRMDLL,'D3DRMColorGetGreen');
D3DRMColorGetBlue := GetProcAddress(D3DRMDLL,'D3DRMColorGetBlue');
D3DRMColorGetAlpha := GetProcAddress(D3DRMDLL,'D3DRMColorGetAlpha');
D3DRMVectorAdd := GetProcAddress(D3DRMDLL,'D3DRMVectorAdd');
D3DRMVectorSubtract := GetProcAddress(D3DRMDLL,'D3DRMVectorSubtract');
D3DRMVectorReflect := GetProcAddress(D3DRMDLL,'D3DRMVectorReflect');
D3DRMVectorCrossProduct := GetProcAddress(D3DRMDLL,'D3DRMVectorCrossProduct');
D3DRMVectorDotProduct := GetProcAddress(D3DRMDLL,'D3DRMVectorDotProduct');
D3DRMVectorNormalize := GetProcAddress(D3DRMDLL,'D3DRMVectorNormalize');
D3DRMVectorModulus := GetProcAddress(D3DRMDLL,'D3DRMVectorModulus');
D3DRMVectorRotate := GetProcAddress(D3DRMDLL,'D3DRMVectorRotate');
D3DRMVectorScale := GetProcAddress(D3DRMDLL,'D3DRMVectorScale');
D3DRMVectorRandom := GetProcAddress(D3DRMDLL,'D3DRMVectorRandom');
D3DRMQuaternionFromRotation := GetProcAddress(D3DRMDLL,'D3DRMQuaternionFromRotation');
D3DRMQuaternionMultiply := GetProcAddress(D3DRMDLL,'D3DRMQuaternionMultiply');
D3DRMQuaternionSlerp := GetProcAddress(D3DRMDLL,'D3DRMQuaternionSlerp');
D3DRMMatrixFromQuaternion := GetProcAddress(D3DRMDLL,'D3DRMMatrixFromQuaternion');
D3DRMQuaternionFromMatrix := GetProcAddress(D3DRMDLL,'D3DRMQuaternionFromMatrix');
//d3drm:
Direct3DRMCreate := GetProcAddress(D3DRMDLL,'Direct3DRMCreate');
end;
{$ENDIF}
{Direct3DRM}
{DirectInput}
Init_c_dfDIKeyboard_Objects; // set kbd GUIDs & flags
Init_c_dfDIJoystick2_Objects; // construct Joystick2 from Joystick fmt
 
if not IsNTandDelphiRunning then
// The number of bytes to allocate for an event with 'cb' data bytes.
//
function QWORD_ALIGN(x: LONGLONG): LONGLONG;
begin
DInputDLL := LoadLibrary('DInput.dll');
 
DirectInputCreateA := GetProcAddress(DInputDLL,'DirectInputCreateA');
DirectInputCreateW := GetProcAddress(DInputDLL,'DirectInputCreateW');
// no A/W version
DirectInputCreateEx := GetProcAddress(DInputDLL,'DirectInputCreateEx');
{$IFDEF UNICODE}
DirectInputCreate := DirectInputCreateW;
{$ELSE}
DirectInputCreate := DirectInputCreateA;
{$ENDIF}
Result := x + 7;
PDWORD(@Result)^ := PDWORD(@Result)^ and (not 7);
end;
{DirectInput}
{DirectPlay}
{$IFDEF UseDirectPlay} // Daniel Marschall 12.04.2024 Added to avoid Windows showing "This app requires DirectPlay"
if not IsNTandDelphiRunning then
begin
DPlayDLL := LoadLibrary('DPlayX.dll');
 
DirectPlayEnumerateA := GetProcAddress(DPlayDLL,'DirectPlayEnumerateA');
DirectPlayEnumerateW := GetProcAddress(DPlayDLL,'DirectPlayEnumerateW');
{$IFDEF UNICODE}
DirectPlayEnumerate := DirectPlayEnumerateW;
{$ELSE}
DirectPlayEnumerate := DirectPlayEnumerateA;
{$ENDIF}
 
DirectPlayCreate := GetProcAddress(DPlayDLL,'DirectPlayCreate');
 
// File: dplay.h
 
DirectPlayLobbyCreateW := GetProcAddress(DPlayDLL,'DirectPlayLobbyCreateW');
DirectPlayLobbyCreateA := GetProcAddress(DPlayDLL,'DirectPlayLobbyCreateA');
{$IFDEF UNICODE}
DirectPlayLobbyCreate := DirectPlayLobbyCreateW;
{$ELSE}
DirectPlayLobbyCreate := DirectPlayLobbyCreateA;
{$ENDIF}
 
end;
{$ENDIF} // UseDirectPlay
{DirectPlay}
{DirectSetup}
if not IsNTandDelphiRunning then
function DMUS_EVENT_SIZE(cb: LONGLONG): LONGLONG;
begin
LoadDSetup;
Result := QWORD_ALIGN(SizeOf(DMUS_EVENTHEADER) + cb);
end;
{DirectSetup}
{DirectSound}
if not IsNTandDelphiRunning then
begin
DSoundDLL := LoadLibrary('DSound.dll');
DirectSoundCreate := GetProcAddress(DSoundDLL,'DirectSoundCreate');
 
DirectSoundEnumerateW := GetProcAddress(DSoundDLL,'DirectSoundEnumerateW');
DirectSoundEnumerateA := GetProcAddress(DSoundDLL,'DirectSoundEnumerateA');
{$IFDEF UNICODE}
DirectSoundEnumerate := DirectSoundEnumerateW;
{$ELSE}
DirectSoundEnumerate := DirectSoundEnumerateA;
{$ENDIF}
end.
 
DirectSoundCaptureCreate :=
GetProcAddress(DSoundDLL,'DirectSoundCaptureCreate');
 
DirectSoundCaptureEnumerateW :=
GetProcAddress(DSoundDLL,'DirectSoundCaptureEnumerateW');
DirectSoundCaptureEnumerateA :=
GetProcAddress(DSoundDLL,'DirectSoundCaptureEnumerateA');
{$IFDEF UNICODE}
DirectSoundCaptureEnumerate := DirectSoundCaptureEnumerateW;
{$ELSE}
DirectSoundCaptureEnumerate := DirectSoundCaptureEnumerateA;
{$ENDIF}
end;
{DirectSound}
end;
 
finalization
begin
{DirectDraw}
if DDrawDLL <> 0 then FreeLibrary(DDrawDLL);
{DirectDraw}
{Direct3D}
FreeLibrary(DXFileDLL);
{Direct3D}
{Direct3DRM}
{$IFDEF D3DRM}
if D3DRMDLL <> 0 then FreeLibrary(D3DRMDLL);
{$ENDIF}
{Direct3DRM}
{DirectInput}
FreeLibrary(DInputDLL);
{DirectInput}
{DirectPlay}
{$IFDEF UseDirectPlay} // Daniel Marschall 12.04.2024 Added to avoid Windows showing "This app requires DirectPlay"
if DPlayDLL <> 0 then FreeLibrary(DPlayDLL);
{$ENDIF} // UseDirectPlay
{DirectPlay}
{DirectSetup}
FreeLibrary(DSetupDLL);
{DirectSetup}
{DirectSound}
FreeLibrary(DSoundDLL);
{DirectSound}
end;
 
 
End.
/VCL_DELPHIX_D6/DXSprite.pas
5,13 → 5,7
{$INCLUDE DelphiXcfg.inc}
 
uses
Windows, SysUtils, Classes, Graphics, DXClass, DXDraws,
{$IFDEF VER9UP} Types,{$ENDIF}
{$IFDEF StandardDX}
DirectDraw;
{$ELSE}
DirectX;
{$ENDIF}
Windows, SysUtils, Classes, DXClass, DXDraws, DirectX;
 
type
 
23,13 → 17,7
 
TSpriteEngine = class;
 
TSprite = class;
TCollisionEvent = procedure(Sender: TObject; var Done: Boolean) of object;
TMoveEvent = procedure(Sender: TObject; var MoveCount: Integer) of object;
TDrawEvent = procedure(Sender: TObject) of object;
TGetImage = procedure(Sender: TObject; var Image: TPictureCollectionItem) of object;
 
TSprite = class(TPersistent)
TSprite = class
private
FEngine: TSpriteEngine;
FParent: TSprite;
44,31 → 32,16
FZ: Integer;
FWidth: Integer;
FHeight: Integer;
{$IFDEF Ver4Up}
FSelected: Boolean;
FGroupNumber: Integer;
{$ENDIF}
FCaption: string;
FTag: Integer;
 
FDXImageList: TCustomDXImageList;
FDXImage: TPictureCollectionItem;
FDXImageName: string;
 
FOnDraw: TDrawEvent;
FOnMove: TMoveEvent;
FOnCollision: TCollisionEvent;
FOnGetImage: TGetImage;
procedure Add(Sprite: TSprite);
procedure Remove(Sprite: TSprite);
procedure AddDrawList(Sprite: TSprite);
procedure Collision2;
procedure Draw; {$IFDEF VER9UP}inline;{$ENDIF}
procedure Draw;
function GetClientRect: TRect;
function GetCount: Integer;
function GetItem(Index: Integer): TSprite;
function GetWorldX: Double; {$IFDEF VER9UP}inline;{$ENDIF}
function GetWorldY: Double; {$IFDEF VER9UP}inline;{$ENDIF}
function GetWorldX: Double;
function GetWorldY: Double;
procedure SetZ(Value: Integer);
protected
procedure DoCollision(Sprite: TSprite; var Done: Boolean); virtual;
76,10 → 49,6
procedure DoMove(MoveCount: Integer); virtual;
function GetBoundsRect: TRect; virtual;
function TestCollision(Sprite: TSprite): Boolean; virtual;
{$IFDEF Ver4Up}
procedure SetGroupNumber(AGroupNumber: Integer); virtual;
procedure SetSelected(ASelected: Boolean); virtual;
{$ENDIF}
public
constructor Create(AParent: TSprite); virtual;
destructor Destroy; override;
87,46 → 56,25
function Collision: Integer;
procedure Dead;
procedure Move(MoveCount: Integer);
procedure ReAnimate(MoveCount: Integer); virtual;
function GetSpriteAt(X, Y: Integer): TSprite;
property BoundsRect: TRect read GetBoundsRect;
property ClientRect: TRect read GetClientRect;
property Collisioned: Boolean read FCollisioned write FCollisioned;
property Count: Integer read GetCount;
property Engine: TSpriteEngine read FEngine;
property Items[Index: Integer]: TSprite read GetItem; default;
property Deaded: Boolean read FDeaded;
property Moved: Boolean read FMoved write FMoved;
property Parent: TSprite read FParent;
property Visible: Boolean read FVisible write FVisible;
property Width: Integer read FWidth write FWidth;
property WorldX: Double read GetWorldX;
property WorldY: Double read GetWorldY;
// Group handling support
{$IFDEF Ver4Up} // if GroupNumber < 0 then no group is assigned
property GroupNumber: Integer read FGroupNumber write SetGroupNumber;
property Selected: Boolean read FSelected write SetSelected;
{$ENDIF}
procedure Assign(Source: TPersistent); override;
published
property Height: Integer read FHeight write FHeight;
property Moved: Boolean read FMoved write FMoved;
property Visible: Boolean read FVisible write FVisible;
property Width: Integer read FWidth write FWidth;
property X: Double read FX write FX;
property Y: Double read FY write FY;
property Z: Integer read FZ write SetZ;
property Collisioned: Boolean read FCollisioned write FCollisioned;
property Tag: Integer read FTag write FTag;
property Caption: string read FCaption write FCaption;
 
property DXImageList: TCustomDXImageList read FDXImageList write FDXImageList;
property DXImageName: string read FDXImageName write FDXImageName;
 
property OnDraw: TDrawEvent read FOnDraw write FOnDraw;
property OnMove: TMoveEvent read FOnMove write FOnMove;
property OnCollision: TCollisionEvent read FOnCollision write FOnCollision;
property OnGetImage: TGetImage read FOnGetImage write FOnGetImage;
end;
 
TSpriteClass = class of TSprite;
 
{ TImageSprite }
 
TImageSprite = class(TSprite)
136,136 → 84,55
FAnimPos: Double;
FAnimSpeed: Double;
FAnimStart: Integer;
FImage: TPictureCollectionItem;
FPixelCheck: Boolean;
FTile: Boolean;
FTransparent: Boolean;
FAngle: Single;
FAlpha: Integer;
FBlendMode: TRenderType;
FCenterX: Double;
FCenterY: Double;
FBlurImageArr: TBlurImageArr;
FBlurImage: Boolean;
FMirrorFlip: TRenderMirrorFlipSet;
FTextureFilter: TD2DTextureFilter;
function GetDrawImageIndex: Integer;
function GetDrawRect: TRect;
function ImageCollisionTest(suf1, suf2: TDirectDrawSurface;
const rect1, rect2: TRect; x1, y1, x2, y2: Integer;
DoPixelCheck: Boolean): Boolean;
function StoreCenterX: Boolean;
function StoreCenterY: Boolean;
function StoreAlpha: Boolean;
procedure SetBlurImage(const Value: Boolean);
procedure SetBlurImageArr(const Value: TBlurImageArr);
function GetImage: TPictureCollectionItem;
procedure SetMirrorFlip(const Value: TRenderMirrorFlipSet);
procedure ReadMirrorFlip(Reader: TReader);
procedure WriteMirrorFlip(Writer: TWriter);
protected
{accessed methods}
procedure ReadAlpha(Reader: TReader);
procedure ReadAngle(Reader: TReader);
procedure ReadAnimCount(Reader: TReader);
procedure ReadAnimLooped(Reader: TReader);
procedure ReadAnimPos(Reader: TReader);
procedure ReadAnimSpeed(Reader: TReader);
procedure ReadAnimStart(Reader: TReader);
procedure ReadBlendMode(Reader: TReader);
procedure ReadCenterX(Reader: TReader);
procedure ReadCenterY(Reader: TReader);
procedure ReadPixelCheck(Reader: TReader);
procedure ReadTile(Reader: TReader);
procedure ReadBlurImage(Reader: TReader);
procedure ReadTextureFilter(Reader: TReader);
procedure WriteAlpha(Writer: TWriter);
procedure WriteAngle(Writer: TWriter);
procedure WriteAnimCount(Writer: TWriter);
procedure WriteAnimLooped(Writer: TWriter);
procedure WriteAnimPos(Writer: TWriter);
procedure WriteAnimSpeed(Writer: TWriter);
procedure WriteAnimStart(Writer: TWriter);
procedure WriteBlendMode(Writer: TWriter);
procedure WriteCenterX(Writer: TWriter);
procedure WriteCenterY(Writer: TWriter);
procedure WritePixelCheck(Writer: TWriter);
procedure WriteTile(Writer: TWriter);
procedure WriteBlurImage(Writer: TWriter);
procedure WriteTextureFilter(Writer: TWriter);
{own store of properties}
procedure DefineProperties(Filer: TFiler); override;
procedure LoadImage; virtual;
procedure DoDraw; override;
procedure DoMove(MoveCount: Integer); override;
function GetBoundsRect: TRect; override;
function TestCollision(Sprite: TSprite): Boolean; override;
procedure SetImage(AImage: TPictureCollectionItem); virtual;
public
constructor Create(AParent: TSprite); override;
procedure Assign(Source: TPersistent); override;
procedure ReAnimate(MoveCount: Integer); override;
property Image: TPictureCollectionItem read GetImage write SetImage;
property BlurImageArr: TBlurImageArr read FBlurImageArr write SetBlurImageArr;
{un-published property}
property BlendMode: TRenderType read FBlendMode write FBlendMode default rtDraw;
property Angle: Single read FAngle write FAngle stored StoreAlpha;
property Alpha: Integer read FAlpha write FAlpha default $FF;
property CenterX: Double read FCenterX write FCenterX stored StoreCenterX;
property CenterY: Double read FCenterY write FCenterY stored StoreCenterY;
property AnimCount: Integer read FAnimCount write FAnimCount default 0;
property AnimLooped: Boolean read FAnimLooped write FAnimLooped default False;
property AnimCount: Integer read FAnimCount write FAnimCount;
property AnimLooped: Boolean read FAnimLooped write FAnimLooped;
property AnimPos: Double read FAnimPos write FAnimPos;
property AnimSpeed: Double read FAnimSpeed write FAnimSpeed;
property AnimStart: Integer read FAnimStart write FAnimStart default 0;
property PixelCheck: Boolean read FPixelCheck write FPixelCheck default False;
property Tile: Boolean read FTile write FTile default False;
property BlurImage: Boolean read FBlurImage write SetBlurImage default False;
property MirrorFlip: TRenderMirrorFlipSet read FMirrorFlip write SetMirrorFlip default [];
property TextureFilter: TD2DTextureFilter read FTextureFilter write FTextureFilter default D2D_POINT;
published
property DXImageList;
property DXImageName;
 
property OnDraw;
property OnMove;
property OnCollision;
property OnGetImage;
property AnimStart: Integer read FAnimStart write FAnimStart;
property PixelCheck: Boolean read FPixelCheck write FPixelCheck;
property Image: TPictureCollectionItem read FImage write FImage;
property Tile: Boolean read FTile write FTile;
end;
 
{ TImageSpriteEx }
 
TImageSpriteEx = class(TImageSprite)
end{$IFDEF VER9UP}deprecated{$IFDEF VER14UP} 'Use for backward compatibility only or replace by TImageSprite instead...'{$ENDIF}{$ENDIF};
private
FAngle: Integer;
FAlpha: Integer;
protected
procedure DoDraw; override;
function GetBoundsRect: TRect; override;
function TestCollision(Sprite: TSprite): Boolean; override;
public
constructor Create(AParent: TSprite); override;
property Angle: Integer read FAngle write FAngle;
property Alpha: Integer read FAlpha write FAlpha;
end;
 
{ TBackgroundSprite }
 
PMapType = ^TMapType;
TMapType = packed record
MapChip: Integer; {image chip as number}
//ImageName: string[127];
CollisionChip: Boolean; {is collision brick}
CollisionRect: TRect; {dirty vollision area, can be smaller or bigger than silhouette}
Overlap: Integer; {for pulse image, like zoom etc.}
AnimLooped: Boolean; {chip can be live}
AnimStart, AnimCount: Integer;
AnimSpeed, AnimPos: Double; {phase of picture by one map chip}
Rendered: TRenderType; {can be blended}
Alpha: Byte; {and blend level}
Angle: Single;
CenterX, CenterY: Double;
MirrorFlip: TRenderMirrorFlipSet;
TextureFilter: TD2DTextureFilter;
Tag: Integer; {for application use}
end;
 
TBackgroundSprite = class(TImageSprite)
TBackgroundSprite = class(TSprite)
private
FImage: TPictureCollectionItem;
FCollisionMap: Pointer;
FMap: Pointer;
FMapWidth: Integer;
FMapHeight: Integer;
 
FChipsRect: TRect;
FChipsPatternIndex: Integer;
FTile: Boolean;
function GetCollisionMapItem(X, Y: Integer): Boolean;
function GetChip(X, Y: Integer): Integer;
procedure SetChip(X, Y: Integer; Value: Integer);
272,60 → 139,26
procedure SetCollisionMapItem(X, Y: Integer; Value: Boolean);
procedure SetMapHeight(Value: Integer);
procedure SetMapWidth(Value: Integer);
 
function GetCollisionRectItem(X, Y: Integer): TRect;
function GetMap(X, Y: Integer): TMapType;
function GetTagMap(X, Y: Integer): Integer;
procedure SetCollisionRectItem(X, Y: Integer; Value: TRect);
procedure SetMap(X, Y: Integer; Value: TMapType);
procedure SetTagMap(X, Y, Value: Integer);
function GetOverlap(X, Y: Integer): Integer;
procedure SetOverlap(X, Y: Integer; const Value: Integer);
protected
procedure ReadMapData(Stream: TStream);
procedure WriteMapData(Stream: TStream);
procedure DoDraw; override;
function GetBoundsRect: TRect; override;
function TestCollision(Sprite: TSprite): Boolean; override;
procedure SetImage(Img: TPictureCollectionItem); override;
procedure DefineProperties(Filer: TFiler); override;
public
constructor Create(AParent: TSprite); override;
destructor Destroy; override;
procedure ChipsDraw(Image: TPictureCollectionItem; X, Y, PatternIndex: Integer);
procedure SetMapSize(AMapWidth, AMapHeight: Integer);
function IsMapEmpty: Boolean;
property Chips[X, Y: Integer]: Integer read GetChip write SetChip;
property CollisionMap[X, Y: Integer]: Boolean read GetCollisionMapItem write SetCollisionMapItem;
property CollisionRect[X, Y: Integer]: TRect read GetCollisionRectItem write SetCollisionRectItem;
property Overlap[X, Y: Integer]: Integer read GetOverlap write SetOverlap;
property TagMap[X, Y: Integer]: Integer read GetTagMap write SetTagMap;
property Map[X, Y: Integer]: TMapType read GetMap write SetMap;
procedure Assign(Source: TPersistent); override;
property ChipsRect: TRect read FChipsRect write FChipsRect;
property ChipsPatternIndex: Integer read FChipsPatternIndex write FChipsPatternIndex default 0;
{un-published property}
property Image: TPictureCollectionItem read FImage write FImage;
property MapHeight: Integer read FMapHeight write SetMapHeight;
property MapWidth: Integer read FMapWidth write SetMapWidth;
published
property DXImageList;
property DXImageName;
 
property OnDraw;
property OnMove;
property OnCollision;
property OnGetImage;
property Tile: Boolean read FTile write FTile;
end;
 
{ forward class }
 
TCustomDXSpriteEngine = class;
 
{ TSpriteEngine }
 
TSpriteEngine = class(TSprite)
private
FOwner: TCustomDXSpriteEngine;
FAllCount: Integer;
FCollisionCount: Integer;
FCollisionDone: Boolean;
335,18 → 168,7
FDrawCount: Integer;
FSurface: TDirectDrawSurface;
FSurfaceRect: TRect;
{$IFDEF Ver4Up}
FObjectsSelected: Boolean;
FGroupCount: Integer;
FGroups: array of Tlist;
FCurrentSelected: Tlist;
{$ENDIF}
protected
procedure SetSurface(Value: TDirectDrawSurface); virtual;
{$IFDEF Ver4Up}
procedure SetGroupCount(AGroupCount: Integer); virtual;
function GetGroup(Index: Integer): Tlist; virtual;
{$ENDIF}
procedure SetSurface(Value: TDirectDrawSurface);
public
constructor Create(AParent: TSprite); override;
destructor Destroy; override;
356,26 → 178,6
property DrawCount: Integer read FDrawCount;
property Surface: TDirectDrawSurface read FSurface write SetSurface;
property SurfaceRect: TRect read FSurfaceRect;
 
// Extended Sprite Engine
procedure Collisions;
 
// Group handling support
{$IFDEF Ver4Up}
procedure ClearCurrent;
procedure ClearGroup(GroupNumber: Integer);
procedure GroupToCurrent(GroupNumber: Integer; Add: Boolean = False);
procedure CurrentToGroup(GroupNumber: Integer; Add: Boolean = False);
procedure GroupSelect(const Area: TRect; Filter: array of TSpriteClass; Add: Boolean = False); overload;
procedure GroupSelect(const Area: TRect; Add: Boolean = False); overload;
function Select(Point: TPoint; Filter: array of TSpriteClass; Add: Boolean = False): Tsprite; overload;
function Select(Point: TPoint; Add: Boolean = False): Tsprite; overload;
 
property CurrentSelected: TList read fCurrentSelected;
property ObjectsSelected: Boolean read fObjectsSelected;
property Groups[Index: Integer]: Tlist read GetGroup;
property GroupCount: Integer read fGroupCount write SetGroupCount;
{$ENDIF}
end;
 
{ EDXSpriteEngineError }
382,90 → 184,6
 
EDXSpriteEngineError = class(Exception);
 
TSpriteCollection = class;
 
{ TSpriteType }
 
TSpriteType = (stSprite, stImageSprite, stImageSpriteEx, stBackgroundSprite);
 
{ TSpriteCollectionItem }
 
TSpriteCollectionItem = class(THashCollectionItem)
private
FOwner: TPersistent;
FOwnerItem: TSpriteEngine;
FSpriteType: TSpriteType;
FSprite: TSprite;
procedure Finalize;
procedure Initialize;
function GetSpriteCollection: TSpriteCollection;
procedure SetSprite(const Value: TSprite);
procedure SetOnCollision(const Value: TCollisionEvent);
procedure SetOnDraw(const Value: TDrawEvent);
procedure SetOnMove(const Value: TMoveEvent);
function GetSpriteType: TSpriteType;
procedure SetSpriteType(const Value: TSpriteType);
function GetOnCollision: TCollisionEvent;
function GetOnDraw: TDrawEvent;
function GetOnMove: TMoveEvent;
function GetOnGetImage: TGetImage;
procedure SetOnGetImage(const Value: TGetImage);
function GetImageList: TCustomDXImageList;
procedure SetImageList(const Value: TCustomDXImageList);
protected
function GetDisplayName: string; override;
procedure SetDisplayName(const Value: string); override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property SpriteCollection: TSpriteCollection read GetSpriteCollection;
function Clone(NewName: string): TSprite;
published
{published property of sprite}
property KindSprite: TSpriteType read GetSpriteType write SetSpriteType;
property ImageList: TCustomDXImageList read GetImageList write SetImageList;
property Sprite: TSprite read FSprite write SetSprite;
{published events of sprite}
property OnDraw: TDrawEvent read GetOnDraw write SetOnDraw;
property OnMove: TMoveEvent read GetOnMove write SetOnMove;
property OnCollision: TCollisionEvent read GetOnCollision write SetOnCollision;
property OnGetImage: TGetImage read GetOnGetImage write SetOnGetImage;
end;
 
{ ESpriteCollectionError }
 
ESpriteCollectionError = class(Exception);
 
{ TSpriteCollection }
 
TSCInitialize = procedure(Owner: TSpriteEngine) of object;
TSCFinalize = procedure(Owner: TSpriteEngine) of object;
 
TSpriteCollection = class(THashCollection)
private
FInitializeFlag: Boolean;
FOwner: TPersistent;
FOwnerItem: TSpriteEngine;
FOnInitialize: TSCInitialize;
FOnFinalize: TSCFinalize;
function GetItem(Index: Integer): TSpriteCollectionItem;
protected
function GetOwner: TPersistent; override;
public
constructor Create(AOwner: TPersistent);
destructor Destroy; override;
function Initialized: Boolean;
function Find(const Name: string): TSpriteCollectionItem;
function Add: TSpriteCollectionItem;
procedure Finalize;
function Initialize(DXSpriteEngine: TSpriteEngine): Boolean;
property Items[Index: Integer]: TSpriteCollectionItem read GetItem; default;
published
property OnInitialize: TSCInitialize read FOnInitialize write FOnInitialize;
property OnFinalize: TSCFinalize read FOnFinalize write FOnFinalize;
end;
 
{ TCustomDXSpriteEngine }
 
TCustomDXSpriteEngine = class(TComponent)
472,67 → 190,31
private
FDXDraw: TCustomDXDraw;
FEngine: TSpriteEngine;
FItems: TSpriteCollection;
procedure DXDrawNotifyEvent(Sender: TCustomDXDraw; NotifyType: TDXDrawNotifyType);
procedure SetDXDraw(Value: TCustomDXDraw);
procedure SetItems(const Value: TSpriteCollection);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
constructor Create(AOnwer: TComponent); override;
destructor Destroy; override;
procedure Dead;
procedure Draw;
procedure Move(MoveCount: Integer);
procedure Clone(const Amount: Word; const BaseNameOfSprite: string);
function ForEach(PrefixNameOdSprite: string; var Names: TStringList): Boolean;
property DXDraw: TCustomDXDraw read FDXDraw write SetDXDraw;
property Engine: TSpriteEngine read FEngine;
property Items: TSpriteCollection read FItems write SetItems;
end;
 
{ TDXSpriteEngine }
 
TDXSpriteEngine = class(TCustomDXSpriteEngine)
property Items;
published
property DXDraw;
end;
 
function Mod2(i, i2: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
function Mod2f(i: Double; i2: Integer): Double; {$IFDEF VER9UP}inline;{$ENDIF}
function DefaultMapChip(iMapChip: Integer = -1; iCollisionChip: Boolean = False): TMapType; {$IFDEF VER9UP}inline;{$ENDIF}
 
implementation
 
uses DXConsts, TypInfo;
uses DXConsts;
 
const
SSpriteNotFound = 'Sprite not found';
SSpriteDuplicateName = 'Item duplicate name "%s" error';
 
function DefaultMapChip(iMapChip: Integer = -1; iCollisionChip: Boolean = False): TMapType;
begin
FillChar(Result, SizeOf(Result), 0);
with Result do
begin
MapChip := iMapChip; {image chip as number}
CollisionChip := iCollisionChip; {is collision brick}
// CollisionRect: TRect; {dirty vollision area, can be smaller or bigger than silhouette}
// Overlap: Integer; {for pulse image, like zoom etc.}
// AnimLooped: Boolean; {chip can be live}
// AnimStart, AnimCount: Integer;
// AnimSpeed, AnimPos: Double; {phase of picture by one map chip}
Rendered := rtDraw; {can be blended}
Alpha := $FF; {and blend level}
Angle := 0;
CenterX := 0.5;
CenterY := 0.5;
TextureFilter := D2D_POINT;
// Tag: Integer; {for application use}
end;
end;
 
function Mod2(i, i2: Integer): Integer;
begin
Result := i mod i2;
546,7 → 228,7
Result := i
else
begin
Result := i - Round(i / i2) * i2;
Result := i-Trunc(i/i2)*i2;
if Result < 0 then
Result := i2 + Result;
end;
557,9 → 239,6
constructor TSprite.Create(AParent: TSprite);
begin
inherited Create;
{$IFDEF Ver4Up}
fGroupnumber := -1;
{$ENDIF}
FParent := AParent;
if FParent <> nil then
begin
578,10 → 257,6
 
destructor TSprite.Destroy;
begin
{$IFDEF Ver4Up}
GroupNumber := -1;
Selected := False;
{$ENDIF}
Clear;
if FParent <> nil then
begin
594,33 → 269,6
inherited Destroy;
end;
 
{$IFDEF Ver4Up}
 
procedure TSprite.SetGroupNumber(AGroupNumber: Integer);
begin
if (AGroupNumber <> GroupNumber) and (Engine <> nil) then
begin
if Groupnumber >= 0 then
Engine.Groups[GroupNumber].Remove(self);
if AGroupNumber >= 0 then
Engine.Groups[AGroupNumber].Add(self);
end;
end; {SetGroupNumber}
 
procedure TSprite.SetSelected(ASelected: Boolean);
begin
if (ASelected <> fSelected) and (Engine <> nil) then
begin
fSelected := ASelected;
if Selected then
Engine.CurrentSelected.Add(self)
else
Engine.CurrentSelected.Remove(self);
Engine.fObjectsSelected := Engine.CurrentSelected.count <> 0;
end;
end;
{$ENDIF}
 
procedure TSprite.Add(Sprite: TSprite);
begin
if FList = nil then
655,9 → 303,7
begin
I := (L + H) div 2;
C := TSprite(FDrawList[I]).Z - Sprite.Z;
if C < 0 then
L := I + 1
else
if C < 0 then L := I + 1 else
H := I - 1;
end;
FDrawList.Insert(L, Sprite);
697,20 → 343,17
begin
if Collisioned then
begin
if (Self <> FEngine.FCollisionSprite) and OverlapRect(BoundsRect,
FEngine.FCollisionRect) and FEngine.FCollisionSprite.TestCollision(Self) and
TestCollision(FEngine.FCollisionSprite) then
if (Self<>FEngine.FCollisionSprite) and OverlapRect(BoundsRect, FEngine.FCollisionRect) and
FEngine.FCollisionSprite.TestCollision(Self) and TestCollision(FEngine.FCollisionSprite) then
begin
Inc(FEngine.FCollisionCount);
FEngine.FCollisionSprite.DoCollision(Self, FEngine.FCollisionDone);
if (not FEngine.FCollisionSprite.Collisioned) or
(FEngine.FCollisionSprite.FDeaded) then
if (not FEngine.FCollisionSprite.Collisioned) or (FEngine.FCollisionSprite.FDeaded) then
begin
FEngine.FCollisionDone := True;
end;
end;
if FEngine.FCollisionDone then
Exit;
if FEngine.FCollisionDone then Exit;
for i := 0 to Count - 1 do
Items[i].Collision2;
end;
725,22 → 368,16
end;
end;
 
procedure TSprite.DoMove(MoveCount: Integer);
procedure TSprite.DoMove;
begin
if AsSigned(FOnMove) then
FOnMove(Self, MoveCount);
end;
 
procedure TSprite.DoDraw;
begin
if AsSigned(FOnDraw) then
FOnDraw(Self);
end;
 
procedure TSprite.DoCollision(Sprite: TSprite; var Done: Boolean);
begin
if AsSigned(FOnCollision) then
FOnCollision(Sprite, Done);
end;
 
function TSprite.TestCollision(Sprite: TSprite): Boolean;
754,7 → 391,7
begin
if FMoved then
begin
DoMove(MoveCount); ReAnimate(MoveCount);
DoMove(MoveCount);
for i := 0 to Count - 1 do
Items[i].Move(MoveCount);
end;
778,12 → 415,10
if FDrawList <> nil then
begin
for i := 0 to FDrawList.Count - 1 do
begin
TSprite(FDrawList[i]).Draw;
end;
end;
end;
end;
 
function TSprite.GetSpriteAt(X, Y: Integer): TSprite;
 
792,8 → 427,7
i: Integer;
X2, Y2: Double;
begin
if Sprite.Visible and PointInRect(Point(Round(X), Round(Y)),
Bounds(Round(Sprite.X), Round(Sprite.Y), Sprite.Width, Sprite.Height)) then //corrected by Sergey
if Sprite.Visible and PointInRect(Point(Round(X), Round(Y)), Bounds(Round(Sprite.X), Round(Sprite.Y), Sprite.Width, Sprite.Width)) then
begin
if (Result = nil) or (Sprite.Z > Result.Z) then
Result := Sprite;
819,7 → 453,7
 
function TSprite.GetBoundsRect: TRect;
begin
Result := Bounds(Round(WorldX), Round(WorldY), Width, Height);
Result := Bounds(Trunc(WorldX), Trunc(WorldY), Width, Height);
end;
 
function TSprite.GetClientRect: TRect;
872,41 → 506,6
end;
end;
 
procedure TSprite.Assign(Source: TPersistent);
begin
if Source is TSprite then
begin
FCollisioned := TSprite(Source).FCollisioned;
FMoved := TSprite(Source).FMoved;
FVisible := TSprite(Source).FVisible;
FHeight := TSprite(Source).FHeight;
FWidth := TSprite(Source).FWidth;
FX := TSprite(Source).FX;
FY := TSprite(Source).FY;
FZ := TSprite(Source).FZ;
{$IFDEF Ver4Up}
FSelected := TSprite(Source).FSelected;
FGroupNumber := TSprite(Source).FGroupNumber;
{$ENDIF}
{copy image base - when exists}
FDXImage := TSprite(Source).FDXImage;
FDXImageName := TSprite(Source).FDXImageName;
FDXImageList := TSprite(Source).FDXImageList;
{events}
FOnDraw := TSprite(Source).FOnDraw;
FOnMove := TSprite(Source).FOnMove;
FOnCollision := TSprite(Source).FOnCollision;
FOnGetImage := TSprite(Source).FOnGetImage;
end
else
inherited;
end;
 
procedure TSprite.ReAnimate(MoveCount: Integer);
begin
 
end;
 
{ TImageSprite }
 
constructor TImageSprite.Create(AParent: TSprite);
913,39 → 512,14
begin
inherited Create(AParent);
FTransparent := True;
FAlpha := 255;
FAngle := 0;
FBlendMode := rtDraw;
FCenterX := 0.5;
FCenterY := 0.5;
FBlurImage := False;
FillChar(FBlurImageArr, SizeOf(FBlurImageArr), 0);
FTextureFilter := D2D_POINT;
end;
 
procedure TImageSprite.SetImage(AImage: TPictureCollectionItem);
begin
FDXImage := AImage;
FDXImageName := '';
if AImage <> nil then
begin
Width := AImage.Width;
Height := AImage.Height;
FDXImageName := FDXImage.Name;
end
else
begin
Width := 0;
Height := 0;
end;
end; {SetImage}
 
function TImageSprite.GetBoundsRect: TRect;
var
dx, dy: Integer;
begin
dx := Round(WorldX);
dy := Round(WorldY);
dx := Trunc(WorldX);
dy := Trunc(WorldY);
if FTile then
begin
dx := Mod2(dx, FEngine.SurfaceRect.Right + Width);
963,17 → 537,32
 
procedure TImageSprite.DoMove(MoveCount: Integer);
begin
if AsSigned(FOnMove) then
FOnMove(Self, MoveCount)
FAnimPos := FAnimPos + FAnimSpeed*MoveCount;
 
if FAnimLooped then
begin
if FAnimCount>0 then
FAnimPos := Mod2f(FAnimPos, FAnimCount)
else
FAnimPos := 0;
end else
begin
ReAnimate(MoveCount);
if FAnimPos>=FAnimCount then
begin
FAnimPos := FAnimCount-1;
FAnimSpeed := 0;
end;
if FAnimPos<0 then
begin
FAnimPos := 0;
FAnimSpeed := 0;
end;
end;
end;
 
function TImageSprite.GetDrawImageIndex: Integer;
begin
Result := FAnimStart + Trunc(FAnimPos); //solve 1.07f to Round()
Result := FAnimStart+Trunc(FAnimPos);
end;
 
function TImageSprite.GetDrawRect: TRect;
982,52 → 571,19
OffsetRect(Result, (Width - Image.Width) div 2, (Height - Image.Height) div 2);
end;
 
procedure TImageSprite.LoadImage;
var
vImage: TPictureCollectionItem;
begin
if Image = nil then
if AsSigned(FOnGetImage) then
begin
vImage := nil;
FOnGetImage(Self, vImage);
if vImage <> Image then
Image := vImage;
end
else
if FDXImageName <> '' then
if Assigned(FDXImageList) then
begin
Image := FDXImageList.Items.Find(FDXImageName);
end;
end;
 
procedure TImageSprite.DoDraw;
var
ImageIndex: Integer;
r: TRect;
begin
LoadImage;
if Image = nil then
Exit;
if AsSigned(FOnDraw) then {owner draw called here}
FOnDraw(Self)
else {when is not owner draw then go here}
begin
r := Bounds(Round(WorldX), Round(WorldY), Width, Height);
{New function implemented}
if Assigned(FEngine.FOwner) then
DXDraws.DXDraw_Paint(FEngine.FOwner.FDXDraw, Image, r, GetDrawImageIndex,
FBlurImageArr, FBlurImage, FTextureFilter, FMirrorFlip, FBlendMode, FAngle,
FAlpha, FCenterX, FCenterY);
ImageIndex := GetDrawImageIndex;
r := GetDrawRect;
Image.Draw(FEngine.Surface, r.Left, r.Top, ImageIndex);
end;
end;
 
{$WARNINGS OFF}
{$HINTS OFF}
function ImageCollisionTest(suf1, suf2: TDirectDrawSurface; const rect1, rect2: TRect;
x1,y1,x2,y2: Integer; DoPixelCheck: Boolean): Boolean;
 
function TImageSprite.ImageCollisionTest(suf1, suf2: TDirectDrawSurface;
const rect1, rect2: TRect; x1, y1, x2, y2: Integer; DoPixelCheck: Boolean): Boolean;
 
function ClipRect(var DestRect: TRect; const DestRect2: TRect): Boolean;
begin
with DestRect do
1043,42 → 599,31
 
type
PRGB = ^TRGB;
 
TRGB = packed record
R, G, B: byte;
R, G, B: Byte;
end;
var
ddsd1, ddsd2: {$IFDEF D3D_deprecated}TDDSURFACEDESC{$ELSE}TDDSurfaceDesc2{$ENDIF};
r1, r2, r1a, r2a: TRect;
ddsd1, ddsd2: TDDSurfaceDesc;
r1, r2: TRect;
tc1, tc2: DWORD;
x, y, w, h: Integer;
P1, P2: Pointer;
begin
with rect1 do
r1 := Bounds(0, 0, Right - Left, Bottom - Top);
r1a := r1;
with rect2 do
r2 := Bounds(0, 0, Right - Left, Bottom - Top);
r2a := r2;
r1 := rect1;
with rect2 do r2 := Bounds(x2-x1, y2-y1, Right-Left, Bottom-Top);
 
with rect2 do
r2 := Bounds(x2 - x1, y2 - y1, Right - Left, Bottom - Top);
 
Result := OverlapRect(r1, r2);
 
if (suf1 = nil) or (suf2 = nil) then
Exit;
if (suf1=nil) or (suf2=nil) then Exit;
 
if DoPixelCheck and Result then
begin
{ Get Overlapping rectangle }
with r1 do
r1 := Bounds(Max(x2 - x1, 0), Max(y2 - y1, 0), Right - Left, Bottom - Top);
with r2 do
r2 := Bounds(Max(x1 - x2, 0), Max(y1 - y2, 0), Right - Left, Bottom - Top);
with r1 do r1 := Bounds(Max(x2-x1, 0), Max(y2-y1, 0), Right-Left, Bottom-Top);
with r2 do r2 := Bounds(Max(x1-x2, 0), Max(y1-y2, 0), Right-Left, Bottom-Top);
 
ClipRect(r1, r1a);
ClipRect(r2, r2a);
ClipRect(r1, rect1);
ClipRect(r2, rect2);
 
w := Min(r1.Right - r1.Left, r2.Right - r2.Left);
h := Min(r1.Bottom - r1.Top, r2.Bottom - r2.Top);
1088,18 → 633,6
 
{ Pixel check !!! }
ddsd1.dwSize := SizeOf(ddsd1);
 
with rect1 do
r1 := Bounds(r1.Left + left, r1.Top + top, w, h);
with rect2 do
r2 := Bounds(r2.Left + left, r2.Top + top, w, h);
 
if suf1 = suf2 then
begin
suf2.Lock(r2, ddsd2);
suf2.unlock;
end;
 
if suf1.Lock(r1, ddsd1) then
begin
try
1107,10 → 640,8
if (suf1 = suf2) or suf2.Lock(r2, ddsd2) then
begin
try
{this line out: don't test pixel but rect only, its wrong}
{if suf1=suf2 then ddsd2 := ddsd1;}
if ddsd1.ddpfPixelFormat.dwRGBBitCount <> ddsd2.ddpfPixelFormat.dwRGBBitCount then
Exit;
if suf1=suf2 then ddsd2 := ddsd1;
if ddsd1.ddpfPixelFormat.dwRGBBitCount<>ddsd2.ddpfPixelFormat.dwRGBBitCount then Exit;
 
{ Get transparent color }
tc1 := ddsd1.ddckCKSrcBlt.dwColorSpaceLowValue;
1117,8 → 648,7
tc2 := ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue;
 
case ddsd1.ddpfPixelFormat.dwRGBBitCount of
8:
begin
8 : begin
for y := 0 to h - 1 do
begin
P1 := Pointer(Integer(ddsd1.lpSurface) + y * ddsd1.lPitch);
1125,15 → 655,13
P2 := Pointer(Integer(ddsd2.lpSurface) + y * ddsd2.lPitch);
for x := 0 to w - 1 do
begin
if (PByte(P1)^ <> tc1) and (PByte(P2)^ <> tc2) then
Exit;
if (PByte(P1)^<>tc1) and (PByte(P2)^<>tc2) then Exit;
Inc(PByte(P1));
Inc(PByte(P2));
end;
end;
end;
16:
begin
16: begin
for y := 0 to h - 1 do
begin
P1 := Pointer(Integer(ddsd1.lpSurface) + y * ddsd1.lPitch);
1140,15 → 668,13
P2 := Pointer(Integer(ddsd2.lpSurface) + y * ddsd2.lPitch);
for x := 0 to w - 1 do
begin
if (PWord(P1)^ <> tc1) and (PWord(P2)^ <> tc2) then
Exit;
if (PWord(P1)^<>tc1) and (PWord(P2)^<>tc2) then Exit;
Inc(PWord(P1));
Inc(PWord(P2));
end;
end;
end;
24:
begin
24: begin
for y := 0 to h - 1 do
begin
P1 := Pointer(Integer(ddsd1.lpSurface) + y * ddsd1.lPitch);
1155,19 → 681,14
P2 := Pointer(Integer(ddsd2.lpSurface) + y * ddsd2.lPitch);
for x := 0 to w - 1 do
begin
with PRGB(P1)^ do
if (R shl 16) or (G shl 8) or B <> tc1 then
Exit;
with PRGB(P2)^ do
if (R shl 16) or (G shl 8) or B <> tc2 then
Exit;
if ((PRGB(P1)^.R shl 16) or (PRGB(P1)^.G shl 8) or PRGB(P1)^.B<>tc1) and
((PRGB(P2)^.R shl 16) or (PRGB(P2)^.G shl 8) or PRGB(P2)^.B<>tc2) then Exit;
Inc(PRGB(P1));
Inc(PRGB(P2));
end;
end;
end;
32:
begin
32: begin
for y := 0 to h - 1 do
begin
P1 := Pointer(Integer(ddsd1.lpSurface) + y * ddsd1.lPitch);
1174,8 → 695,7
P2 := Pointer(Integer(ddsd2.lpSurface) + y * ddsd2.lPitch);
for x := 0 to w - 1 do
begin
if (PDWORD(P1)^ <> tc1) and (PDWORD(P2)^ <> tc2) then
Exit;
if (PDWORD(P1)^ and $FFFFFF<>tc1) and (PDWORD(P2)^ and $FFFFFF<>tc2) then Exit;
Inc(PDWORD(P1));
Inc(PDWORD(P2));
end;
1183,8 → 703,7
end;
end;
finally
if suf1 <> suf2 then
suf2.UnLock;
if suf1<>suf2 then suf2.UnLock;
end;
end;
finally
1196,351 → 715,85
end;
end;
 
{$HINTS ON}
{$WARNINGS ON}
 
function TImageSprite.TestCollision(Sprite: TSprite): Boolean;
var
img1, img2: Integer;
box1, box2: TRect;
b1, b2: TRect;
begin
if (Sprite is TImageSprite) then
if FPixelCheck then
if (Sprite is TImageSprite) and FPixelCheck then
begin
box1 := GetDrawRect;
box2 := TImageSprite(Sprite).GetDrawRect;
b1 := GetDrawRect;
b2 := TImageSprite(Sprite).GetDrawRect;
 
img1 := GetDrawImageIndex;
img2 := TImageSprite(Sprite).GetDrawImageIndex;
 
Result := ImageCollisionTest(Image.PatternSurfaces[img1],
TImageSprite(Sprite).Image.PatternSurfaces[img2], Image.PatternRects[img1],
TImageSprite(Sprite).Image.PatternRects[img2], box1.Left, box1.Top,
box2.Left, box2.Top, True);
end
else
Result := OverlapRect(Bounds(Round(Sprite.WorldX), Round(Sprite.WorldY),
Sprite.Width, Sprite.Height), Bounds(Round(WorldX), Round(WorldY), Width, Height))
else
Result := ImageCollisionTest(Image.PatternSurfaces[img1], TImageSprite(Sprite).Image.PatternSurfaces[img2],
Image.PatternRects[img1], TImageSprite(Sprite).Image.PatternRects[img2],
b1.Left, b1.Top, b2.Left, b2.Top, True);
end else
Result := inherited TestCollision(Sprite);
end;
 
procedure TImageSprite.Assign(Source: TPersistent);
begin
if Source is TImageSprite then begin
FCenterX := TImageSprite(Source).FCenterX;
FCenterY := TImageSprite(Source).FCenterY;
FAnimCount := TImageSprite(Source).FAnimCount;
FAnimLooped := TImageSprite(Source).FAnimLooped;
FAnimPos := TImageSprite(Source).FAnimPos;
FAnimSpeed := TImageSprite(Source).FAnimSpeed;
FAnimStart := TImageSprite(Source).FAnimStart;
FDXImage := TImageSprite(Source).FDXImage;
FPixelCheck := TImageSprite(Source).FPixelCheck;
FTile := TImageSprite(Source).FTile;
FTransparent := TImageSprite(Source).FTransparent;
FAngle := TImageSprite(Source).FAngle;
FAlpha := TImageSprite(Source).FAlpha;
FBlendMode := TImageSprite(Source).FBlendMode;
FBlurImage := TImageSprite(Source).FBlurImage;
end;
inherited;
end;
{ TImageSpriteEx }
 
procedure TImageSprite.ReAnimate(MoveCount: Integer);
var
I: Integer;
constructor TImageSpriteEx.Create(AParent: TSprite);
begin
FAnimPos := FAnimPos + FAnimSpeed * MoveCount;
 
if FAnimLooped then
begin
if FAnimCount > 0 then
FAnimPos := Mod2f(FAnimPos, FAnimCount)
else
FAnimPos := 0;
end
else
begin
if Round(FAnimPos) >= FAnimCount then
begin
FAnimPos := FAnimCount - 1;
FAnimSpeed := 0;
inherited Create(AParent);
FAlpha := 255;
end;
if FAnimPos < 0 then
begin
FAnimPos := 0;
FAnimSpeed := 0;
end;
end;
if FBlurImage then
begin
{ale jen jsou-li jine souradnice}
if (FBlurImageArr[High(FBlurImageArr)].eX <> Round(WorldX)) or
(FBlurImageArr[High(FBlurImageArr)].eY <> Round(WorldY)) then
begin
for i := Low(FBlurImageArr) + 1 to High(FBlurImageArr) do
begin
FBlurImageArr[i - 1] := FBlurImageArr[i];
{adjust the blur intensity}
FBlurImageArr[i - 1].eIntensity := Round(FAlpha / (High(FBlurImageArr) + 1)) * (i - 1);
end;
with FBlurImageArr[High(FBlurImageArr)] do
begin
eX := Round(WorldX);
eY := Round(WorldY);
ePatternIndex := GetDrawImageIndex;
eIntensity := Round(FAlpha / (High(FBlurImageArr) + 1)) * High(FBlurImageArr);
eBlendMode := FBlendMode;
eActive := True;
end;
end;
end;
end;
 
function TImageSprite.StoreCenterX: Boolean;
begin
Result := FCenterX <> 0.5;
end;
 
function TImageSprite.StoreCenterY: Boolean;
begin
Result := FCenterY <> 0.5;
end;
 
function TImageSprite.StoreAlpha: Boolean;
begin
Result := FAlpha <> 0.0;
end;
 
procedure TImageSprite.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineProperty('BlendMode', ReadBlendMode, WriteBlendMode, FBlendMode <> rtDraw);
Filer.DefineProperty('Angle', ReadAngle, WriteAngle, FAngle <> 0);
Filer.DefineProperty('CenterX', ReadCenterX, WriteCenterX, FCenterX <> 0.5);
Filer.DefineProperty('CenterY', ReadCenterY, WriteCenterY, FCenterY <> 0.5);
Filer.DefineProperty('Alpha', ReadAlpha, WriteAlpha, FAlpha <> $FF);
Filer.DefineProperty('AnimCount', ReadAnimCount, WriteAnimCount, FAnimCount <> 0);
Filer.DefineProperty('AnimLooped', ReadAnimLooped, WriteAnimLooped, FAnimLooped);
Filer.DefineProperty('AnimPos', ReadAnimPos, WriteAnimPos, FAnimPos <> 0);
Filer.DefineProperty('AnimSpeed', ReadAnimSpeed, WriteAnimSpeed, FAnimSpeed <> 0);
Filer.DefineProperty('AnimStart', ReadAnimStart, WriteAnimStart, True);
Filer.DefineProperty('PixelCheck', ReadPixelCheck, WritePixelCheck, FPixelCheck);
Filer.DefineProperty('Tile', ReadTile, WriteTile, FTile);
Filer.DefineProperty('BlurImage', ReadBlurImage, WriteBlurImage, FBlurImage);
Filer.DefineProperty('MirrorFlip', ReadMirrorFlip, WriteMirrorFlip, FMirrorFlip <> []);
Filer.DefineProperty('TextureFilter', ReadTextureFilter, WriteTextureFilter, FTextureFilter <> D2D_POINT);
end;
 
procedure TImageSprite.WriteMirrorFlip(Writer: TWriter);
procedure TImageSpriteEx.DoDraw;
var
q: TRenderMirrorFlip;
s, ss: string;
// I: Integer;
//PI: PPropInfo;
r: TRect;
begin
// PI := GetPropInfo(Self,'MirrorFlip');
// I := Integer(FMirrorFlip);
s := '[]'; ss := '';
for q := Low(TRenderMirrorFlip) to High(TRenderMirrorFlip) do
if q in FMirrorFlip then
ss := ss + GetEnumName(TypeInfo(TRenderMirrorFlip), Ord(q)) + ', ';
if ss <> '' then
s := '[' + Copy(ss, 1, Length(ss) - 2) + ']';
Writer.WriteString(s);
//--- Writer.WriteString(SetToString(PI, GetOrdProp(Self, PI), True));
end;
r := Bounds(Trunc(WorldX), Trunc(WorldY), Width, Height);
 
procedure TImageSprite.ReadMirrorFlip(Reader: TReader);
var
q: TRenderMirrorFlip;
qq: TRenderMirrorFlipSet;
s {, ss}: string;
// PI: PPropInfo;
if FAngle and $FF=0 then
begin
// PI := GetPropInfo(Self,'MirrorFlip');
// SetOrdProp(Self,PI,StringToSet(PI, Reader.ReadString));
qq := [];
s := Reader.ReadString;
for q := Low(TRenderMirrorFlip) to High(TRenderMirrorFlip) do
if Pos(GetEnumName(TypeInfo(TRenderMirrorFlip), Ord(q)), s) <> 0 then
qq := qq + [q];
FMirrorFlip := qq;
end;
 
procedure TImageSprite.ReadAnimLooped(Reader: TReader);
if FAlpha<255 then
begin
FAnimLooped := Reader.ReadBoolean;
end;
 
procedure TImageSprite.WriteAnimLooped(Writer: TWriter);
Image.DrawAlpha(FEngine.FSurface, r, GetDrawImageIndex, FAlpha)
end else
begin
Writer.WriteBoolean(FAnimLooped);
Image.StretchDraw(FEngine.FSurface, r, GetDrawImageIndex);
end;
 
procedure TImageSprite.ReadAnimPos(Reader: TReader);
end else
begin
FAnimPos := Reader.ReadFloat;
end;
 
procedure TImageSprite.WriteAnimPos(Writer: TWriter);
if FAlpha<255 then
begin
Writer.WriteFloat(FAnimPos);
end;
 
procedure TImageSprite.ReadAnimSpeed(Reader: TReader);
Image.DrawRotateAlpha(FEngine.FSurface, (r.Left+r.Right) div 2, (r.Top+r.Bottom) div 2,
Width, Height, GetDrawImageIndex, 0.5, 0.5, FAngle, FAlpha)
end else
begin
FAnimSpeed := Reader.ReadFloat;
Image.DrawRotate(FEngine.FSurface, (r.Left+r.Right) div 2, (r.Top+r.Bottom) div 2,
Width, Height, GetDrawImageIndex, 0.5, 0.5, FAngle)
end;
 
procedure TImageSprite.WriteAnimSpeed(Writer: TWriter);
begin
Writer.WriteFloat(FAnimSpeed);
end;
 
procedure TImageSprite.ReadAnimStart(Reader: TReader);
begin
FAnimStart := Reader.ReadInteger;
end;
 
procedure TImageSprite.WriteAnimStart(Writer: TWriter);
function TImageSpriteEx.GetBoundsRect: TRect;
begin
Writer.WriteInteger(FAnimStart);
Result := FEngine.SurfaceRect;
end;
 
procedure TImageSprite.ReadPixelCheck(Reader: TReader);
function TImageSpriteEx.TestCollision(Sprite: TSprite): Boolean;
begin
FPixelCheck := Reader.ReadBoolean;
end;
 
procedure TImageSprite.WritePixelCheck(Writer: TWriter);
if Sprite is TImageSpriteEx then
begin
Writer.WriteBoolean(FPixelCheck);
end;
 
procedure TImageSprite.ReadTile(Reader: TReader);
Result := OverlapRect(Bounds(Trunc(Sprite.WorldX), Trunc(Sprite.WorldY), Sprite.Width, Sprite.Height),
Bounds(Trunc(WorldX), Trunc(WorldY), Width, Height));
end else
begin
FTile := Reader.ReadBoolean;
Result := OverlapRect(Sprite.BoundsRect, Bounds(Trunc(WorldX), Trunc(WorldY), Width, Height));
end;
 
procedure TImageSprite.WriteTile(Writer: TWriter);
begin
Writer.WriteBoolean(FTile);
end;
 
procedure TImageSprite.ReadAnimCount(Reader: TReader);
begin
FAnimCount := Reader.ReadInteger;
end;
 
procedure TImageSprite.WriteAnimCount(Writer: TWriter);
begin
Writer.WriteInteger(FAnimCount);
end;
 
procedure TImageSprite.ReadAlpha(Reader: TReader);
begin
FAlpha := Reader.ReadInteger;
end;
 
procedure TImageSprite.WriteAlpha(Writer: TWriter);
begin
Writer.WriteInteger(FAlpha);
end;
 
procedure TImageSprite.ReadCenterY(Reader: TReader);
begin
FCenterY := Reader.ReadFloat;
end;
 
procedure TImageSprite.WriteCenterY(Writer: TWriter);
begin
Writer.WriteFloat(FCenterY);
end;
 
procedure TImageSprite.ReadCenterX(Reader: TReader);
begin
FCenterX := Reader.ReadFloat;
end;
 
procedure TImageSprite.WriteCenterX(Writer: TWriter);
begin
Writer.WriteFloat(FCenterX);
end;
 
procedure TImageSprite.ReadAngle(Reader: TReader);
begin
FAngle := Reader.{$IFDEF VER4UP}ReadSingle{$ELSE}ReadFloat{$ENDIF};
end;
 
procedure TImageSprite.WriteAngle(Writer: TWriter);
begin
Writer.{$IFDEF VER4UP}WriteSingle{$ELSE}WriteFloat{$ENDIF}(FAngle);
end;
 
procedure TImageSprite.ReadBlendMode(Reader: TReader);
begin
FBlendMode := TRenderType(GetEnumValue(TypeInfo(TRenderType), Reader.ReadString));
end;
 
procedure TImageSprite.WriteBlendMode(Writer: TWriter);
begin
Writer.WriteString(GetEnumName(TypeInfo(TRenderType), Ord(FBlendMode)));
end;
 
procedure TImageSprite.ReadBlurImage(Reader: TReader);
begin
FBlurImage := Reader.ReadBoolean;
end;
 
procedure TImageSprite.WriteBlurImage(Writer: TWriter);
begin
Writer.WriteBoolean(FBlurImage);
end;
 
procedure TImageSprite.ReadTextureFilter(Reader: TReader);
begin
FTextureFilter := TD2DTextureFilter(Reader.ReadInteger);
end;
 
procedure TImageSprite.WriteTextureFilter(Writer: TWriter);
begin
Writer.WriteInteger(Ord(FTextureFilter));
end;
 
procedure TImageSprite.SetBlurImageArr(const Value: TBlurImageArr);
begin
FBlurImageArr := Value;
end;
 
procedure TImageSprite.SetBlurImage(const Value: Boolean);
begin
if (FBlurImage <> Value) and (Value) then
begin
FillChar(FBlurImageArr, SizeOf(FBlurImageArr), 0); //get out when set up
end;
FBlurImage := Value;
end;
 
function TImageSprite.GetImage: TPictureCollectionItem;
begin
Result := FDXImage;
end;
 
procedure TImageSprite.SetMirrorFlip(const Value: TRenderMirrorFlipSet);
begin
FMirrorFlip := Value;
end;
 
{ TBackgroundSprite }
 
constructor TBackgroundSprite.Create(AParent: TSprite);
begin
inherited Create(AParent);
FMap := nil;
FMapWidth := 0;
FMapHeight := 0;
Collisioned := False;
end;
 
1550,35 → 803,15
inherited Destroy;
end;
 
procedure TBackgroundSprite.ChipsDraw(Image: TPictureCollectionItem; X, Y: Integer; PatternIndex: Integer);
begin
if AsSigned(FOnDraw) then
FOnDraw(Self)
else
begin
//Image.Draw(FEngine.Surface, X, Y, PatternIndex);
{New function implemented}
if Assigned(FEngine.FOwner) then
//Image.DrawAlpha(DXDraw1.Surface,ChipsRect,ChipsPatternIndex,Blend);
DXDraws.DXDraw_Paint(FEngine.FOwner.FDXDraw, Image, ChipsRect, ChipsPatternIndex,
FBlurImageArr, FBlurImage, FTextureFilter, FMirrorFlip, FBlendMode, FAngle,
Map[X,Y].Alpha, FCenterX, FCenterY);
end;
end;
 
procedure TBackgroundSprite.DoDraw;
var
TmpX, TmpY, cx, cy, cx2, cy2, PatternIndex, ChipWidth, ChipHeight: Integer;
_x, _y, cx, cy, cx2, cy2, c, ChipWidth, ChipHeight: Integer;
StartX, StartY, EndX, EndY, StartX_, StartY_, OfsX, OfsY, dWidth, dHeight: Integer;
r: TRect;
Q: TMapType;
begin
LoadImage;
if Image = nil then
Exit;
if Image=nil then Exit;
 
if (FMapWidth <= 0) or (FMapHeight <= 0) then
Exit;
if (FMapWidth<=0) or (FMapHeight<=0) then Exit;
 
r := Image.PatternRects[0];
ChipWidth := r.Right - r.Left;
1587,13 → 820,13
dWidth := (FEngine.SurfaceRect.Right + ChipWidth) div ChipWidth + 1;
dHeight := (FEngine.SurfaceRect.Bottom + ChipHeight) div ChipHeight + 1;
 
TmpX := Round(WorldX);
TmpY := Round(WorldY);
_x := Trunc(WorldX);
_y := Trunc(WorldY);
 
OfsX := TmpX mod ChipWidth;
OfsY := TmpY mod ChipHeight;
OfsX := _x mod ChipWidth;
OfsY := _y mod ChipHeight;
 
StartX := TmpX div ChipWidth;
StartX := _x div ChipWidth;
StartX_ := 0;
 
if StartX < 0 then
1602,7 → 835,7
StartX := 0;
end;
 
StartY := TmpY div ChipHeight;
StartY := _y div ChipHeight;
StartY_ := 0;
 
if StartY < 0 then
1622,87 → 855,52
for cx := -1 to dWidth do
begin
cx2 := Mod2((cx - StartX + StartX_), FMapWidth);
PatternIndex := Chips[cx2, cy2];
ChipsPatternIndex := PatternIndex; //refresh only
ChipsRect := Bounds(cx * ChipWidth + OfsX, cy * ChipHeight + OfsY, ChipWidth, ChipHeight);
if PatternIndex >= 0 then
begin
if AsSigned(FOnDraw) then
FOnDraw(Self)
else
begin
{New function implemented}
if Assigned(FEngine.FOwner) then
begin
Q := Map[cx2,cy2];
DXDraws.DXDraw_Paint(FEngine.FOwner.FDXDraw, Image, ChipsRect, Q.MapChip,
FBlurImageArr, FBlurImage, Q.TextureFilter, Q.MirrorFlip, Q.Rendered, Q.Angle,
Q.Alpha, Q.CenterX, Q.CenterY);
c := Chips[cx2, cy2];
if c>=0 then
Image.Draw(FEngine.Surface, cx*ChipWidth+OfsX, cy*ChipHeight+OfsY, c);
end;
end;
end;
end;
end;
end
else
end else
begin
for cy := StartY to EndY - 1 do
for cx := StartX to EndX - 1 do
begin
PatternIndex := Chips[cx - StartX + StartX_, cy - StartY + StartY_];
ChipsPatternIndex := PatternIndex; //refresh only
ChipsRect := Bounds(cx * ChipWidth + OfsX, cy * ChipHeight + OfsY, ChipWidth, ChipHeight);
if PatternIndex >= 0 then
begin
if AsSigned(FOnDraw) then
FOnDraw(Self)
else
begin
{New function implemented}
if Assigned(FEngine.FOwner) then
begin
Q := Map[cx,cy];
DXDraws.DXDraw_Paint(FEngine.FOwner.FDXDraw, Image, ChipsRect, Q.MapChip,
FBlurImageArr, FBlurImage, Q.TextureFilter, Q.MirrorFlip, Q.Rendered, Q.Angle,
Q.Alpha, Q.CenterX, Q.CenterY);
c := Chips[cx-StartX+StartX_, cy-StartY+StartY_];
if c>=0 then
Image.Draw(FEngine.Surface, cx*ChipWidth+OfsX, cy*ChipHeight+OfsY, c);
end;
end;
end
end;
end;
end;
 
function TBackgroundSprite.TestCollision(Sprite: TSprite): Boolean;
var
box0, box1, box2: TRect;
b, b1, b2: TRect;
cx, cy, ChipWidth, ChipHeight: Integer;
r: TRect;
begin
Result := True;
if Image = nil then
Exit;
if (FMapWidth <= 0) or (FMapHeight <= 0) then
Exit;
if Image=nil then Exit;
if (FMapWidth<=0) or (FMapHeight<=0) then Exit;
 
r := Image.PatternRects[0];
ChipWidth := r.Right - r.Left;
ChipHeight := r.Bottom - r.Top;
 
box1 := Sprite.BoundsRect;
box2 := BoundsRect;
 
IntersectRect(box0, box1, box2);
 
OffsetRect(box0, -Round(WorldX), -Round(WorldY));
OffsetRect(box1, -Round(WorldX), -Round(WorldY));
b1 := Sprite.BoundsRect;
b2 := BoundsRect;
 
for cy := (box0.Top - ChipHeight + 1) div ChipHeight to box0.Bottom div ChipHeight do
for cx := (box0.Left - ChipWidth + 1) div ChipWidth to box0.Right div ChipWidth do
IntersectRect(b, b1, b2);
 
OffsetRect(b, -Trunc(WorldX), -Trunc(WorldY));
OffsetRect(b1, -Trunc(WorldX), -Trunc(WorldY));
 
for cy:=(b.Top-ChipHeight+1) div ChipHeight to b.Bottom div ChipHeight do
for cx:=(b.Left-ChipWidth+1) div ChipWidth to b.Right div ChipWidth do
if CollisionMap[Mod2(cx, MapWidth), Mod2(cy, MapHeight)] then
begin
if OverlapRect(Bounds(cx * ChipWidth, cy * ChipHeight, ChipWidth,
ChipHeight), box1) then
Exit;
if OverlapRect(Bounds(cx*ChipWidth, cy*ChipHeight, ChipWidth, ChipHeight), b1) then Exit;
end;
 
Result := False;
1711,43 → 909,22
function TBackgroundSprite.GetChip(X, Y: Integer): Integer;
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
Result := PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.MapChip
Result := PInteger(Integer(FMap)+(Y*FMapWidth+X)*SizeOf(Integer))^
else
Result := -1;
end;
 
type
PBoolean = ^Boolean;
 
function TBackgroundSprite.GetCollisionMapItem(X, Y: Integer): Boolean;
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
Result := PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.CollisionChip
Result := PBoolean(Integer(FCollisionMap)+(Y*FMapWidth+X)*SizeOf(Boolean))^
else
Result := False;
end;
 
function TBackgroundSprite.GetCollisionRectItem(X, Y: Integer): TRect;
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
Result := PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.CollisionRect
else
Result := Rect(0, 0, 0, 0);
end;
 
function TBackgroundSprite.GetTagMap(X, Y: Integer): Integer;
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
Result := PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.Tag
else
Result := 0;
end;
 
function TBackgroundSprite.GetMap(X, Y: Integer): TMapType;
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
Result := PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^
else
FillChar(Result, SizeOf(Result), 0);
end;
 
function TBackgroundSprite.GetBoundsRect: TRect;
begin
if FTile then
1754,10 → 931,9
Result := FEngine.SurfaceRect
else
begin
LoadImage;
if Image <> nil then
Result := Bounds(Round(WorldX), Round(WorldY), Image.Width * FMapWidth,
Image.Height * FMapHeight)
Result := Bounds(Trunc(WorldX), Trunc(WorldY),
Image.Width*FMapWidth, Image.Height*FMapHeight)
else
Result := Rect(0, 0, 0, 0);
end;
1766,33 → 942,15
procedure TBackgroundSprite.SetChip(X, Y: Integer; Value: Integer);
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.MapChip := Value;
PInteger(Integer(FMap)+(Y*FMapWidth+X)*SizeOf(Integer))^ := Value;
end;
 
procedure TBackgroundSprite.SetCollisionMapItem(X, Y: Integer; Value: Boolean);
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.CollisionChip := Value;
PBoolean(Integer(FCollisionMap)+(Y*FMapWidth+X)*SizeOf(Boolean))^ := Value;
end;
 
procedure TBackgroundSprite.SetCollisionRectItem(X, Y: Integer; Value: TRect);
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.CollisionRect := Value;
end;
 
procedure TBackgroundSprite.SetTagMap(X, Y: Integer; Value: Integer);
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.Tag := Value;
end;
 
procedure TBackgroundSprite.SetMap(X, Y: Integer; Value: TMapType);
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^ := Value;
end;
 
procedure TBackgroundSprite.SetMapHeight(Value: Integer);
begin
SetMapSize(FMapWidth, Value);
1803,116 → 961,25
SetMapSize(Value, FMapHeight);
end;
 
procedure TBackgroundSprite.SetImage(Img: TPictureCollectionItem);
begin
inherited SetImage(Img);
if Assigned(Img) then
begin
FWidth := FMapWidth * Img.Width;
FHeight := FMapHeight * Img.Height;
end
else
begin
FWidth := 0;
FHeight := 0;
end;
end;
 
procedure TBackgroundSprite.SetMapSize(AMapWidth, AMapHeight: Integer);
var I: Integer;
begin
if (FMapWidth <> AMapWidth) or (FMapHeight <> AMapHeight) or (FMap = nil) then
if (FMapWidth<>AMapWidth) or (FMapHeight<>AMapHeight) then
begin
try
if (AMapWidth <= 0) or (AMapHeight <= 0) then
begin
FreeMem(FMap, FMapWidth * FMapHeight * SizeOf(TMapType)); FMap := nil;
AMapWidth := 0;
AMapHeight := 0;
end;
FMapWidth := AMapWidth;
FMapHeight := AMapHeight;
System.ReallocMem(FMap, FMapWidth * FMapHeight * SizeOf(TMapType));
if Assigned(FMap) then
begin
FillChar(FMap^, FMapWidth * FMapHeight * SizeOf(TMapType), 0);
for I := 0 to FMapWidth * FMapHeight - 1 do
PMapType(Integer(FMap) + (I) * SizeOf(TMapType))^.CollisionChip := True;
end
except
FreeMem(FMap, FMapWidth * FMapHeight * SizeOf(TMapType));
FMap := nil;
end;
end
end;
ReAllocMem(FMap, FMapWidth*FMapHeight*SizeOf(Integer));
FillChar(FMap^, FMapWidth*FMapHeight*SizeOf(Integer), 0);
 
procedure TBackgroundSprite.Assign(Source: TPersistent);
begin
if Source is TBackgroundSprite then
begin
FMapWidth := TBackgroundSprite(Source).FMapWidth;
FMapHeight := TBackgroundSprite(Source).FMapHeight;
FTile := TBackgroundSprite(Source).FTile;
ReAllocMem(FCollisionMap, FMapWidth*FMapHeight*SizeOf(Boolean));
FillChar(FCollisionMap^, FMapWidth*FMapHeight*SizeOf(Boolean), 1);
end;
inherited;
end;
 
procedure TBackgroundSprite.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineBinaryProperty('Map', ReadMapData, WriteMapData, FMap <> nil);
end;
 
type
TMapDataHeader = packed record
MapWidth: Integer;
MapHeight: Integer;
end;
 
procedure TBackgroundSprite.ReadMapData(Stream: TStream);
var
Header: TMapDataHeader;
begin
Stream.ReadBuffer(Header, SizeOf(Header));
FMapWidth := Header.MapWidth;
FMapHeight := Header.MapHeight;
SetMapSize(Header.MapWidth, Header.MapHeight);
if Assigned(FMap) and (Header.MapWidth > 0) and (Header.MapHeight > 0) then
begin
Stream.ReadBuffer(FMap^, FMapWidth * FMapHeight * SizeOf(TMapType));
end;
end;
 
procedure TBackgroundSprite.WriteMapData(Stream: TStream);
var
Header: TMapDataHeader;
begin
Header.MapWidth := FMapWidth;
Header.MapHeight := FMapHeight;
Stream.WriteBuffer(Header, SizeOf(Header));
if Assigned(FMap) then
Stream.WriteBuffer(FMap^, FMapWidth * FMapHeight * SizeOf(TMapType));
end;
 
function TBackgroundSprite.GetOverlap(X, Y: Integer): Integer;
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
Result := PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.Overlap
else
Result := 0;
end;
 
procedure TBackgroundSprite.SetOverlap(X, Y: Integer; const Value: Integer);
begin
if (X >= 0) and (X < FMapWidth) and (Y >= 0) and (Y < FMapHeight) then
PMapType(Integer(FMap) + (Y * FMapWidth + X) * SizeOf(TMapType))^.Overlap := Value;
end;
 
function TBackgroundSprite.IsMapEmpty: Boolean;
begin
Result := (FMap = nil) or (FMapWidth <= 0) or (FMapHeight <= 0);
end;
 
{ TSpriteEngine }
 
constructor TSpriteEngine.Create(AParent: TSprite);
1919,199 → 986,14
begin
inherited Create(AParent);
FDeadList := TList.Create;
// group handling
{$IFDEF Ver4Up}
fCurrentSelected := Tlist.create;
GroupCount := 10;
{$ENDIF}
end;
 
destructor TSpriteEngine.Destroy;
begin
// cleanup Group handling
{$IFDEF Ver4Up}
ClearCurrent;
GroupCount := 0;
{$ENDIF}
FDeadList.Free;
inherited Destroy;
{$IFDEF Ver4Up}
fCurrentSelected.free;
{$ENDIF}
end;
 
procedure TSpriteEngine.Collisions;
var
index: Integer;
begin
for index := 0 to Count - 1 do
Items[index].Collision;
end;
{Collisions}
{$IFDEF Ver4Up}
 
procedure TSpriteEngine.GroupSelect(const Area: TRect; Add: Boolean = False);
begin
GroupSelect(Area, [Tsprite], Add);
end; {GroupSelect}
 
procedure TSpriteEngine.GroupSelect(const Area: TRect; Filter: array of TSpriteClass; Add: Boolean = False);
var
index, index2: Integer;
sprite: TSprite;
begin
Assert(length(Filter) <> 0, 'Filter = []');
if not Add then
ClearCurrent;
if length(Filter) = 1 then
begin
for Index := 0 to Count - 1 do
begin
sprite := Items[Index];
if (sprite is Filter[0]) and OverlapRect(sprite.GetBoundsRect, Area) then
sprite.Selected := true;
end
end
else
begin
for Index := 0 to Count - 1 do
begin
sprite := Items[index];
for index2 := 0 to high(Filter) do
if (sprite is Filter[index2]) and OverlapRect(sprite.GetBoundsRect, Area) then
begin
sprite.Selected := true;
break;
end;
end
end;
fObjectsSelected := CurrentSelected.count <> 0;
end; {GroupSelect}
 
function TSpriteEngine.Select(Point: TPoint; Filter: array of TSpriteClass; Add: Boolean = False): Tsprite;
var
index, index2: Integer;
begin
Assert(length(Filter) <> 0, 'Filter = []');
if not Add then
ClearCurrent;
// By searching the Drawlist in reverse
// we select the highest sprite if the sprit is under the point
assert(FDrawList <> nil, 'FDrawList = nil');
if length(Filter) = 1 then
begin
for Index := FDrawList.Count - 1 downto 0 do
begin
Result := FDrawList[Index];
if (Result is Filter[0]) and PointInRect(Point, Result.GetBoundsRect) then
begin
Result.Selected := true;
fObjectsSelected := CurrentSelected.count <> 0;
exit;
end;
end
end
else
begin
for Index := FDrawList.Count - 1 downto 0 do
begin
Result := FDrawList[index];
for index2 := 0 to high(Filter) do
if (Result is Filter[index2]) and PointInRect(Point, Result.GetBoundsRect) then
begin
Result.Selected := true;
fObjectsSelected := CurrentSelected.count <> 0;
exit;
end;
end
end;
Result := nil;
end; {Select}
 
function TSpriteEngine.Select(Point: TPoint; Add: Boolean = False): TSprite;
begin
Result := Select(Point, [Tsprite], Add);
end; {Select}
 
procedure TSpriteEngine.ClearCurrent;
begin
while CurrentSelected.count <> 0 do
TSprite(CurrentSelected[CurrentSelected.count - 1]).Selected := False;
fObjectsSelected := False;
end; {ClearCurrent}
 
procedure TSpriteEngine.ClearGroup(GroupNumber: Integer);
var
index: Integer;
Group: Tlist;
begin
Group := Groups[GroupNumber];
if Group <> nil then
for index := 0 to Group.count - 1 do
TSprite(Group[index]).Selected := False;
end; {ClearGroup}
 
procedure TSpriteEngine.CurrentToGroup(GroupNumber: Integer; Add: Boolean = False);
var
Group: Tlist;
index: Integer;
begin
Group := Groups[GroupNumber];
if Group = nil then
exit;
if not Add then
ClearGroup(GroupNumber);
for index := 0 to Group.count - 1 do
TSprite(Group[index]).GroupNumber := GroupNumber;
end; {CurrentToGroup}
 
procedure TSpriteEngine.GroupToCurrent(GroupNumber: Integer; Add: Boolean = False);
var
Group: Tlist;
index: Integer;
begin
if not Add then
ClearCurrent;
Group := Groups[GroupNumber];
if Group <> nil then
for index := 0 to Group.count - 1 do
TSprite(Group[index]).Selected := true;
end; {GroupToCurrent}
 
function TSpriteEngine.GetGroup(Index: Integer): Tlist;
begin
if (index >= 0) or (index < fGroupCount) then
Result := fGroups[index]
else
Result := nil;
end; {GetGroup}
 
procedure TSpriteEngine.SetGroupCount(AGroupCount: Integer);
var
index: Integer;
begin
if (AGroupCount <> FGroupCount) and (AGroupCount >= 0) then
begin
if FGroupCount > AGroupCount then
begin // remove groups
for index := AGroupCount to FGroupCount - 1 do
begin
ClearGroup(index);
FGroups[index].Free;
end;
SetLength(FGroups, AGroupCount);
end
else
begin // add groups
SetLength(FGroups, AGroupCount);
for index := FGroupCount to AGroupCount - 1 do
FGroups[index] := Tlist.Create;
end;
FGroupCount := Length(FGroups);
end;
end; {SetGroupCount}
{$ENDIF}
 
procedure TSpriteEngine.Dead;
begin
while FDeadList.Count > 0 do
2137,15 → 1019,10
 
{ TCustomDXSpriteEngine }
 
constructor TCustomDXSpriteEngine.Create(AOwner: TComponent);
constructor TCustomDXSpriteEngine.Create(AOnwer: TComponent);
begin
inherited Create(AOwner);
inherited Create(AOnwer);
FEngine := TSpriteEngine.Create(nil);
FEngine.FOwner := Self;
FItems := TSpriteCollection.Create(Self);
FItems.FOwner := Self;
FItems.FOwnerItem := FEngine;
FItems.Initialize(FEngine);
end;
 
destructor TCustomDXSpriteEngine.Destroy;
2199,271 → 1076,4
FDXDraw.RegisterNotifyEvent(DXDrawNotifyEvent);
end;
 
procedure TCustomDXSpriteEngine.SetItems(const Value: TSpriteCollection);
begin
FItems.Assign(Value);
end;
 
procedure TCustomDXSpriteEngine.Clone(const Amount: Word; const BaseNameOfSprite: string);
var
i: Integer;
begin
if Amount = 0 then Exit;
for i := 1 to Amount do
begin
with FItems.Add do
begin
KindSprite := FItems.Find(BaseNameOfSprite).KindSprite;
Sprite.AsSign(FItems.Find(BaseNameOfSprite).Sprite);
{name has to be different}
Name := Format(BaseNameOfSprite + '_%d', [I]); //simple name for sprite like Name_1 etc.
Sprite.Tag := 0; //for sprite you can use Tag property in future as well
end;
end;
end;
 
function TCustomDXSpriteEngine.ForEach(PrefixNameOdSprite: string; var Names: TStringList): Boolean;
var
I: Integer;
begin
if Names = nil then
Names := TStringList.Create;
for I := 0 to Items.Count - 1 do
begin
if PrefixNameOdSprite = '' then
Names.Add(Items[I].Name)
else
{is prefix, fo names like Player????}
if Pos(PrefixNameOdSprite, Items[I].Name) = 1 then
Names.Add(Items[I].Name);
end;
Result := Names.Count > 0;
if not Result then {$IFDEF VER5UP}FreeAndNil(Names){$ELSE}begin Names.Free; names := nil end{$ENDIF};
end;
 
{ TSpriteCollectionItem }
 
function TSpriteCollectionItem.GetSpriteCollection: TSpriteCollection;
begin
Result := Collection as TSpriteCollection;
end;
 
procedure TSpriteCollectionItem.SetSprite(const Value: TSprite);
begin
FSprite.Assign(Value);
end;
 
constructor TSpriteCollectionItem.Create(Collection: TCollection);
begin
inherited Create(Collection);
FOwner := Collection;
FOwnerItem := (Collection as TSpriteCollection).FOwnerItem;
FSpriteType := stSprite;
FSprite := TSprite.Create(FOwnerItem);
end;
 
procedure TSpriteCollectionItem.Assign(Source: TPersistent);
begin
if Source is TSpriteCollectionItem then
begin
Finalize;
FSprite.Assign(TSpriteCollectionItem(Source).FSprite);
inherited Assign(Source);
Initialize;
end
else
inherited;
end;
 
procedure TSpriteCollectionItem.Initialize;
begin
 
end;
 
destructor TSpriteCollectionItem.Destroy;
begin
FSprite.Destroy;
inherited;
end;
 
procedure TSpriteCollectionItem.Finalize;
begin
 
end;
 
procedure TSpriteCollectionItem.SetOnCollision(
const Value: TCollisionEvent);
begin
FSprite.FOnCollision := Value;
end;
 
procedure TSpriteCollectionItem.SetOnDraw(const Value: TDrawEvent);
begin
FSprite.FOnDraw := Value;
end;
 
procedure TSpriteCollectionItem.SetOnMove(const Value: TMoveEvent);
begin
FSprite.FOnMove := Value
end;
 
function TSpriteCollectionItem.GetDisplayName: string;
begin
Result := inherited GetDisplayName
end;
 
procedure TSpriteCollectionItem.SetDisplayName(const Value: string);
begin
if (Value <> '') and (AnsiCompareText(Value, GetDisplayName) <> 0) and
(Collection is TSpriteCollection) and (TSpriteCollection(Collection).IndexOf(Value) >= 0) then
raise Exception.Create(Format(SSpriteDuplicateName, [Value]));
inherited SetDisplayName(Value);
end;
 
function TSpriteCollectionItem.GetSpriteType: TSpriteType;
begin
Result := FSpriteType;
end;
 
procedure TSpriteCollectionItem.SetSpriteType(const Value: TSpriteType);
var
tmpSprite: TSprite;
begin
if Value <> FSpriteType then
begin
case Value of
stSprite: tmpSprite := TSprite.Create(TSpriteEngine(FOwnerItem));
stImageSprite: TImageSprite(tmpSprite) := TImageSprite.Create(TSpriteEngine(FOwnerItem));
{$WARNINGS OFF}
stImageSpriteEx: TImageSpriteEx(tmpSprite) := TImageSpriteEx.Create(TSpriteEngine(FOwnerItem));
{$WARNINGS ON}
stBackgroundSprite: TBackgroundSprite(tmpSprite) := TBackgroundSprite.Create(TSpriteEngine(FOwnerItem));
else
tmpSprite := nil
end;
if Assigned(FSprite) then
try
tmpSprite.Assign(FSprite);
tmpSprite.FOnDraw := FSprite.FOnDraw;
tmpSprite.FOnMove := FSprite.FOnMove;
tmpSprite.FOnCollision := FSprite.FOnCollision;
tmpSprite.FOnGetImage := FSprite.FOnGetImage;
finally
FSprite.Free; FSprite := nil;
end;
FSprite := tmpSprite;
FSpriteType := Value;
end;
end;
 
function TSpriteCollectionItem.GetOnCollision: TCollisionEvent;
begin
Result := FSprite.FOnCollision
end;
 
function TSpriteCollectionItem.GetOnDraw: TDrawEvent;
begin
Result := FSprite.FOnDraw
end;
 
function TSpriteCollectionItem.GetOnMove: TMoveEvent;
begin
Result := FSprite.FOnMove
end;
 
function TSpriteCollectionItem.GetOnGetImage: TGetImage;
begin
Result := FSprite.FOnGetImage;
end;
 
procedure TSpriteCollectionItem.SetOnGetImage(const Value: TGetImage);
begin
FSprite.FOnGetImage := Value;
end;
 
function TSpriteCollectionItem.GetImageList: TCustomDXImageList;
begin
Result := FSprite.FDXImageList;
end;
 
procedure TSpriteCollectionItem.SetImageList(const Value: TCustomDXImageList);
begin
FSprite.FDXImageList := Value;
end;
 
function TSpriteCollectionItem.Clone(NewName: string): TSprite;
var
T: TSpriteCollectionItem;
begin
T := GetSpriteCollection.Add;
T.KindSprite := Self.FSpriteType;
T.Assign(Self);
T.Name := NewName;
Result := T.FSprite;
end;
 
{ TSpriteCollection }
 
function TSpriteCollection.Initialized: Boolean;
begin
Result := FInitializeFlag;
end;
 
constructor TSpriteCollection.Create(AOwner: TPersistent);
begin
inherited Create(TSpriteCollectionItem);
FOwner := AOwner;
FInitializeFlag := Initialize(TSpriteEngine(AOwner));
end;
 
function TSpriteCollection.GetItem(Index: Integer): TSpriteCollectionItem;
begin
Result := TSpriteCollectionItem(inherited Items[Index]);
end;
 
function TSpriteCollection.Initialize(DXSpriteEngine: TSpriteEngine): Boolean;
begin
Result := True;
try
if AsSigned(FOnInitialize) then
FOnInitialize(DXSpriteEngine);
except
Result := False;
end
end;
 
function TSpriteCollection.Find(const Name: string): TSpriteCollectionItem;
var
i: Integer;
begin
i := IndexOf(Name);
if i = -1 then
raise ESpriteCollectionError.CreateFmt(SSpriteNotFound, [Name]);
Result := Items[i];
end;
 
procedure TSpriteCollection.Finalize;
begin
if AsSigned(FOnFinalize) then
FOnFinalize(FOwnerItem);
end;
 
function TSpriteCollection.GetOwner: TPersistent;
begin
Result := FOwner;
end;
 
function TSpriteCollection.Add: TSpriteCollectionItem;
begin
Result := TSpriteCollectionItem(inherited Add);
Result.FOwner := FOwner;
Result.FOwnerItem := FOwnerItem;
end;
 
destructor TSpriteCollection.Destroy;
begin
Finalize;
inherited;
end;
 
end.
/VCL_DELPHIX_D6/DelphiXcfg.inc
1,917 → 1,32
{$B-,J+,Q-,R-,T-,X+}
//*********************************************************************
// Main configuration file for (un)DelphiX
//*********************************************************************
{$IFDEF VER100}
{$DEFINE VER3UP}
{$ENDIF}
{$IFDEF VER120}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$ENDIF}
{$IFDEF VER130}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$ENDIF}
{$IFDEF VER140}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$ENDIF}
{$IFDEF VER150}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$ENDIF}
{$IFDEF VER170}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP} // Delphi 2005
{$ENDIF}
{$IFDEF VER180}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP} // Delphi 2006
{$IFDEF VER185}
{$DEFINE VER11UP} // Delphi 2007
{$ENDIF}
{$ENDIF}
{$IFDEF VER200}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$ENDIF}
{$IFDEF VER210}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$ENDIF}
{$IFDEF VER220}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP} //Delphi XE
{$ENDIF}
 
{$IFDEF VER230}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP} //Delphi XE2
{$ENDIF}
 
{$IFDEF VER240}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP} //Delphi XE3
{$ENDIF}
 
{$IFDEF VER250}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP} //Delphi XE4
{$ENDIF}
 
{$IFDEF VER260}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP} //Delphi XE5
{$ENDIF}
 
{$IFDEF VER270}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP} //Delphi XE6
{$ENDIF}
 
{$IFDEF VER280}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP}
{$DEFINE VER21UP} //Delphi XE7
{$ENDIF}
 
{$IFDEF VER290}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP}
{$DEFINE VER21UP}
{$DEFINE VER22UP} //Delphi XE8
{$ENDIF}
 
{$IFDEF VER300}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP}
{$DEFINE VER21UP}
{$DEFINE VER22UP}
{$DEFINE VER23UP} //Delphi 10 Seattle
{$ENDIF}
 
{$IFDEF VER310}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP}
{$DEFINE VER21UP}
{$DEFINE VER22UP}
{$DEFINE VER23UP}
{$DEFINE VER24UP}//Delphi 10.1 Berlin
{$ENDIF}
 
{$IFDEF VER320}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP}
{$DEFINE VER21UP}
{$DEFINE VER22UP}
{$DEFINE VER23UP}
{$DEFINE VER24UP}
{$DEFINE VER25UP} //Delphi 10.2 Tokyo
{$ENDIF}
 
{$IFDEF VER330}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP}
{$DEFINE VER21UP}
{$DEFINE VER22UP}
{$DEFINE VER23UP}
{$DEFINE VER24UP}
{$DEFINE VER25UP}
{$DEFINE VER26UP} //Delphi 10.3 Rio
{$ENDIF}
 
{$IFDEF VER340}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP}
{$DEFINE VER21UP}
{$DEFINE VER22UP}
{$DEFINE VER23UP}
{$DEFINE VER24UP}
{$DEFINE VER25UP}
{$DEFINE VER26UP}
{$DEFINE VER27UP} //Delphi 10.4 Sydney
{$ENDIF}
 
{$IFDEF VER350}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP}
{$DEFINE VER21UP}
{$DEFINE VER22UP}
{$DEFINE VER23UP}
{$DEFINE VER24UP}
{$DEFINE VER25UP}
{$DEFINE VER26UP}
{$DEFINE VER27UP}
{$DEFINE VER28UP} //Delphi 11 Alexandria
{$ENDIF}
 
{$IFDEF VER360}
{$DEFINE VER3UP}
{$DEFINE VER4UP}
{$DEFINE VER5UP}
{$DEFINE VER6UP}
{$DEFINE VER7UP}
{$DEFINE VER9UP}
{$DEFINE VER10UP}
{$DEFINE VER11UP}
{$DEFINE VER12UP}
{$DEFINE VER14UP}
{$DEFINE VER15UP}
{$DEFINE VER16UP}
{$DEFINE VER17UP}
{$DEFINE VER18UP}
{$DEFINE VER19UP}
{$DEFINE VER20UP}
{$DEFINE VER21UP}
{$DEFINE VER22UP}
{$DEFINE VER23UP}
{$DEFINE VER24UP}
{$DEFINE VER25UP}
{$DEFINE VER26UP}
{$DEFINE VER27UP}
{$DEFINE VER28UP}
{$DEFINE VER29UP}//Delphi 12 Athens
{$ENDIF}
 
{$IFDEF VER100}
// Delphi 3
{$Define D3UP}
{$DEFINE DelphiX_Delphi3}
{$ENDIF}
 
{$IFDEF VER120}
// Delphi 4
{$Define D3UP}
{$Define D4UP}
{$DEFINE DelphiX_Delphi4}
{$ENDIF}
 
{$IFDEF VER130}
// Delphi 5
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$DEFINE DelphiX_Delphi5}
{$ENDIF}
 
{$IFDEF VER140}
// Delphi 6
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$IFDEF DelphiX_Delphi3}
{$DEFINE DelphiX_Spt3}
{$ENDIF}
 
{$IFDEF VER150}
// Delphi 7
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$IFDEF DelphiX_Delphi4}
{$DEFINE DelphiX_Spt3}
{$DEFINE DelphiX_Spt4}
{$ENDIF}
 
{$IFDEF VER170}
// Delphi 9 - 2005
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$IFDEF DelphiX_Delphi5}
{$DEFINE DelphiX_Spt3}
{$DEFINE DelphiX_Spt4}
{$DEFINE DelphiX_Spt5}
{$ENDIF}
 
{$IFDEF VER180}
// Delphi 10 - 2006 or Turbo
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$ENDIF}
 
{$IFDEF VER185}
// Delphi 11 - 2007
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$ENDIF}
 
{$IFDEF VER200}
// Delphi 12 - 2009
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$ENDIF}
 
{$IFDEF VER210}
// Delphi 14 - 2010
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER220}
// Delphi 15 - XE
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER230}
// Delphi 16 - XE2
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER240}
// Delphi 17 - XE3
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER250}
// Delphi 18 - XE4
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER260}
// Delphi 19 - XE5
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER270}
// Delphi 20 - XE6
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER280}
// Delphi 21 - XE7
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D21UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER290}
// Delphi 22 - XE8
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D21UP}
{$Define D22UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER300}
// Delphi 23 - 10 Seattle
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D21UP}
{$Define D22UP}
{$Define D23UP}
{$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER310}
// Delphi 24 - 10.1 Berlin
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D21UP}
{$Define D22UP}
{$Define D23UP}
{$Define D24UP}
//cannot be made, Berlin version lost older interfaces
//{.$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER320}
// Delphi 25 - 10.2 Tokyo
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D21UP}
{$Define D22UP}
{$Define D23UP}
{$Define D24UP}
{$Define D25UP}
//cannot be made, Berlin version lost older interfaces
//{.$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER330}
// Delphi 26 - 10.3 Rio
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D21UP}
{$Define D22UP}
{$Define D23UP}
{$Define D24UP}
{$Define D25UP}
{$Define D26UP}
//cannot be made, Berlin version lost older interfaces
//{.$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER340}
// Delphi 27 - 10.4 Sydney
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D21UP}
{$Define D22UP}
{$Define D23UP}
{$Define D24UP}
{$Define D25UP}
{$Define D26UP}
{$Define D27UP}
//cannot be made, Berlin version lost older interfaces
//{.$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER350}
// Delphi 28 - 11 Alexandria
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D21UP}
{$Define D22UP}
{$Define D23UP}
{$Define D24UP}
{$Define D25UP}
{$Define D26UP}
{$Define D27UP}
{$Define D28UP}
//cannot be made, Berlin version lost older interfaces
//{.$Define D_EE_UP}
{$ENDIF}
 
{$IFDEF VER360}
// Delphi 29 - 12 Athens
{$Define D3UP}
{$Define D4UP}
{$Define D5UP}
{$Define D6UP}
{$Define D7UP}
{$Define D9UP}
{$Define D10UP}
{$Define D11UP}
{$Define D12UP}
{$Define D14UP}
{$Define D15UP}
{$Define D16UP}
{$Define D17UP}
{$Define D18UP}
{$Define D19UP}
{$Define D20UP}
{$Define D21UP}
{$Define D22UP}
{$Define D23UP}
{$Define D24UP}
{$Define D25UP}
{$Define D26UP}
{$Define D27UP}
{$Define D28UP}
{$Define D29UP}
//cannot be made, Berlin version lost older interfaces
//{.$Define D_EE_UP}
{$ENDIF}
 
{standard feature for drawing blend textures}
{this conditional is add-on as is for eliminate bad color key switching}
{$DEFINE DrawHWAcc}
 
{DirectX Double precision activation}
{$DEFINE DXDOUBLEPRECISION}
 
{when you can use this option, you must use separate headers unit }
{if this turn off, you use built-in standard DirectX.pas unit (in one file)}
{$IFDEF D_EE_UP} //Delphi 2010/XE
{$DEFINE StandardDX}
{$ELSE}
{.$DEFINE StandardDX}
{$ENDIF}
 
{Only one can be set!}
{Use standard of DirectX version 7}
{$IFNDEF D_EE_UP}
{$DEFINE DX7}
{$ELSE}
 
{Use standard of DirectX version 9}
{in concert with StandardDX for separate units only}
{$IFDEF StandardDX}
{$DEFINE DX9}
{$ENDIF}
{$ENDIF}
 
{for better texture compression can be use ZLIB here}
{in some Delphi versions it errors occurred because ZLib package is "lock-like" package}
{I recommend use it for final version application only}
{$IFDEF VER5UP} {Delphi 5 (and lower) has any problems with ZLIB, may be replace by 3rd party lib. manually}
{$DEFINE DXTextureImage_UseZLIB}
{$ENDIF}
{when videotexture is used - like change images in texture}
{Note: it consume 2x more memory because texture is store twice unchanged and}
{changed - this conditional add/remove store shadow image in texture buffer}
{$IFDEF VER5UP} {Delphi 5 (and lower) has any problems with ZLIB, may be replace by 3rd party lib. manually}
{$DEFINE VIDEOTEX}
{$ENDIF}
 
{software rendering based on Hori's DXR code}
{this option is only for remove all DXR code, is not recommended remove it}
{it can be remove only for special usage like use PURE DirectX for SW rendering too}
{$DEFINE DXR_deprecated}
 
{$IfDef DX7}
{Retained mode is turn off for Vista as implicit value}
{When you want use it, you have to add the D3DRM.DLL}
{is recommended put library into Windows/System32 system directory}
{in application directory does not works properly under Vista}
{$Define D3D_deprecated} //both must be turn-on
{.$Define D3DRM} //required D3DRM.DLL !!
{for separete unit is DirectRM.pas required !! - it is not include in Delphi 2010/XE !!}
{this class is deprecated; when you can it use, remove dot bellow}
{this add additional component for D3D over DXDraw}
{$IFDEF D3DRM}
{$Define DX3D_deprecated}
{$ENDIF}
 
{$ELSE}
{$Define D3D_deprecated}
{$EndIf}
 
{$IFDEF VER12UP}
{PNG support is added in Delphi 2009 and up as native feature}
{there is turn on, it is for backward compatibility only}
{$DEFINE PNG_GRAPHICS}
{$ELSE}
{for Delphi 2007 and lower when you usen PNG support, you have write}
{name of PNG package into required section of pavkage source .dpk}
{and turn on this support here - remove the dot only bellow}
{.$DEFINE PNG_GRAPHICS}
{$ENDIF}
 
{special feature for enumerate displayis like primary, secondary etc.}
{only for special purpose, multimonitors etc.}
{.$DEFINE _DMO_}
 
{When you need DirectPlay, please remove this definition. It is not enabled by default, because}
{DirectPlay is not shipped with Windows by default, and the user might receive a warning}
{that the app might not work if DirectPlay is not installed.}
{.$Define UseDirectPlay}
/VCL_DELPHIX_D6/DXDraws.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXConsts.pas
22,7 → 22,7
SSession = 'Session';
 
SNotMade = '%s not made';
SStreamNotOpend = 'Stream not opened';
SStreamNotOpend = 'Stream not opend';
SWaveStreamNotSet = 'WaveStream not set';
SCannotMade = '%s cannot be made';
SCannotInitialized = '%s cannot be initialized';
29,7 → 29,7
SCannotChanged = '%s cannot be changed';
SCannotLock = '%s cannot be locked';
SCannotOpened = '%s cannot be opened';
SDLLNotLoaded = '%s is not loaded';
SDLLNotLoaded = '%s not loaded';
SImageNotFound = 'Image ''%s'' not found';
SWaveNotFound = 'Wave ''%s'' not found';
SEffectNotFound = 'Effect ''%s'' not found';
36,32 → 36,32
SListIndexError = 'Index of the list exceeds the range. (%d)';
SScanline = 'Index of the scanning line exceeded the range. (%d)';
SNoForm = 'Form not found';
SSinceDirectX5 = 'Requires DirectX 5.0 or later';
SSinceDirectX6 = 'Requires DirectX 6.0 or later';
SSinceDirectX7 = 'Requires DirectX 7.0 or later';
SSinceDirectX5 = 'Necessary since DirectX 5';
SSinceDirectX6 = 'Necessary since DirectX 6';
SSinceDirectX7 = 'Necessary since DirectX 7';
S3DDeviceNotFound = '3D device not found';
SDisplayModeChange = 'Display mode cannot be changed (%dx%d %dbit)';
SDisplayModeCannotAcquired = 'Display mode cannot be acquired';
SDisplayModeCannotAcquired = 'A present display mode cannot be acquired';
SInvalidDIB = 'DIB is invalid';
SInvalidDIBBitCount = 'Bitcount in invalid (%d)';
SInvalidDIBPixelFormat = 'PixelFormat in invalid';
SInvalidWave = 'Wave is invalid';
SInvalidDisplayBitCount = 'Display requires 8, 16, 24 or 32 bits';
SInvalidDisplayBitCount = 'It should be either of 8 or 16 or 24 or 32';
SInvalidWaveFormat = 'Format is invalid';
SNotSupported = '%s not supported';
SStreamOpend = 'Stream is already open';
SNecessaryDirectInputUseMouse = 'DirectInput is required for mouse support';
SStreamOpend = 'Stream has already been opened';
SNecessaryDirectInputUseMouse = 'DirectInput is necessary to use the mouse';
 
{ DirectPlay }
SDXPlayNotConnectedNow = 'TDXPlay component is disconnected.';
SDXPlayNotConnectedNow = 'TDXPlay component is not connected now.';
SDXPlayProviderNotFound = 'Provider ''%s'' not found';
SDXPlayProviderSpecifiedGUIDNotFound = 'Provider''s specified GUID is not found';
SDXPlayProviderSpecifiedGUIDNotFound = 'Provider of specified GUID is not found';
SDXPlayModemListCannotBeAcquired = 'Modem list cannot be acquired';
SDXPlaySessionListCannotBeAcquired = 'Session list cannot be acquired';
SDXPlaySessionNotFound = 'Session ''%s'' not found';
SDXPlaySessionCannotOpened = 'Session %s cannot be opened';
SDXPlayPlayerNotFound = 'Player''s specified ID is not found';
SDXPlayMessageIllegal = 'Illegal message form';
SDXPlayPlayerNotFound = 'The player of specified ID is not found';
SDXPlayMessageIllegal = 'The message form is illegal';
SDXPlayPlayerNameIsNotSpecified = 'Player name is not specified';
SDXPlaySessionNameIsNotSpecified = 'Session name is not specified';
 
69,11 → 69,12
DXPlayFormComplete = 'Complete';
 
 
SNotSupportGraphicFile = 'Graphic format not suported';
SInvalidDXTFile = 'DXT file is invalid';
SCannotLoadGraphic = 'Can not load graphic';
SOverlay = 'Surface overlay not possible';
 
SNotSupportGraphicFile = 'This format graphic not suported';
SInvalidDXTFile = 'This DXT file is invalid';
SCannotLoadGraphic = 'Can''t Load this Graphic';
SOverlay = 'Not posible Overlay Surface';
 
const
SDIBSize = '(%dx%d)';
SDIBColor = '%d color';
/VCL_DELPHIX_D6/DXDraws.pas
1,95 → 1,3
(*******************************************************************************
EXTEND UNIT DXDRAWS FROM DELPHIX PACK
 
* Copyright (c) 2004-2010 Jaro Benes
* All Rights Reserved
* Version 1.09
* D2D Hardware module
* web site: www.micrel.cz/Dx
* e-mail: delphix_d2d@micrel.cz
 
* Enhanced by User137
 
* DISCLAIMER:
This software is provided "as is" and is without warranty of any kind.
The author of this software does not warrant, guarantee or make any
representations regarding the use or results of use of this software
in terms of reliability, accuracy or fitness for purpose. You assume
the entire risk of direct or indirect, consequential or inconsequential
results from the correct or incorrect usage of this software even if the
author has been informed of the possibilities of such damage. Neither
the author nor anybody connected to this software in any way can assume
any responsibility.
 
Tested in Delphi 4, 5, 6, 7 and Delphi 2005/2006/2007/2009/2010
 
* FEATURES:
a) Implement Hardware acceleration for critical function like DrawAlpha {Blend},
DrawSub and DrawAdd for both way DXIMAGELIST and DIRECTDRAWSURFACE with rotation too.
b) Automatic adjustement for texture size different 2^n.
c) Minimum current source code change, all accelerated code added into:
DXDraw.BeginScene;
//code here
DXDraw.EndScene;
d) DelphiX facade continues using still.
 
* HOW TO USE
a) Design code like as DelphiX and drawing routine put into
DXDraw.BeginScene;
//code here
DXDraw.EndScene;
b) setup options in code or property for turn-on acceleration like:
DXDraw.Finalize; {done DXDraw}
If HardwareSwitch Then
{hardware}
Begin
if NOT (doDirectX7Mode in DXDraw.Options) then
DXDraw.Options := DXDraw.Options + [doDirectX7Mode];
if NOT (doHardware in DXDraw.Options) then
DXDraw.Options := DXDraw.Options + [doHardware];
if NOT (do3D in DXDraw.Options) then
DXDraw.Options := DXDraw.Options + [do3D];
if doSystemMemory in DXDraw.Options then
DXDraw.Options := DXDraw.Options - [doSystemMemory];
End
Else
{software}
Begin
if doDirectX7Mode in DXDraw.Options then
DXDraw.Options := DXDraw.Options - [doDirectX7Mode];
if do3D in DXDraw.Options then
DXDraw.Options := DXDraw.Options - [do3D];
if doHardware in DXDraw.Options then
DXDraw.Options := DXDraw.Options - [doHardware];
if NOT (doSystemMemory in DXDraw.Options) then
DXDraw.Options := DXDraw.Options + [doSystemMemory];
End;
{to fullscreen}
if doFullScreen in DXDraw.Options then
begin
RestoreWindow;
DXDraw.Cursor := crDefault;
BorderStyle := bsSingle;
DXDraw.Options := DXDraw.Options - [doFullScreen];
DXDraw.Options := DXDraw.Options + [doFlip];
end else
begin
StoreWindow;
DXDraw.Cursor := crNone;
BorderStyle := bsNone;
DXDraw.Options := DXDraw.Options + [doFullScreen];
DXDraw.Options := DXDraw.Options - [doFlip];
end;
DXDraw1.Initialize; {up DXDraw now}
 
* NOTE Main form has to declare like:
TForm1 = class(TDXForm)
 
* KNOWN BUGS OR RESTRICTION:
1/ Cannot be use DirectDrawSurface other from DXDraw.Surface in HW mode.
2/ New functions was not tested for two and more DXDraws on form. Sorry.
 
******************************************************************************)
unit DXDraws;
 
interface
98,56 → 6,10
 
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
{$IFDEF VER14UP}
DXTypes,
{$ENDIF}
{$IFDEF VER17UP}System.Types, System.UITypes,{$ENDIF}
{$IFDEF DXTextureImage_UseZLIB}
ZLIB,
{$ENDIF}
DXClass, DIB,
{$IFDEF StandardDX}
DirectDraw, DirectSound,
{$IFDEF DX7}
{$IFDEF D3DRM}
Direct3DRM,
{$ENDIF}
Direct3D;
{$ENDIF}
{$IFDEF DX9}
Direct3D9, Direct3D, D3DX9, {Direct3D8,} DX7toDX8;
{$ENDIF}
{$ELSE}
DirectX;
{$ENDIF}
DXClass, DIB, DXTexImg, DirectX;
 
const
maxTexBlock = 2048; {maximum textures}
maxVideoBlockSize: Integer = 2048; {maximum size block of one texture}
SurfaceDivWidth: Integer = 2048;
SurfaceDivHeight: Integer = 2048;
{This conditional is for force set square texture when use it alphachannel from DIB32}
{$DEFINE FORCE_SQUARE}
DXTextureImageGroupType_Normal = 0; // Normal group
DXTextureImageGroupType_Mipmap = 1; // Mipmap group
 
Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ"at 0123456789<>=()-''!_+\/{}^&%.=$#ÅÖÄ?*';
PowerAlphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=~!@#$%^&*()_+[];'',./\{}:"<>?|©®™ ';
ccDefaultSpecular = $FFFFFFFF;
 
ZeroRect: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
 
type
 
{ TRenderType }
 
TRenderType = (rtDraw, rtBlend, rtAdd, rtSub);
 
{ TRenderMirrorFlip }
 
TRenderMirrorFlip = (rmfMirror, rmfFlip);
TRenderMirrorFlipSet = set of TRenderMirrorFlip;
 
{ EDirectDrawError }
 
EDirectDrawError = class(EDirectXError);
163,10 → 25,8
 
TDirectDraw = class(TDirectX)
private
{$IFDEF D3D_deprecated}
FIDDraw: IDirectDraw;
FIDDraw4: IDirectDraw4;
{$ENDIF}
FIDDraw7: IDirectDraw7;
FDriverCaps: TDDCaps;
FHELCaps: TDDCaps;
175,16 → 35,12
FSurfaces: TList;
function GetClipper(Index: Integer): TDirectDrawClipper;
function GetClipperCount: Integer;
function GetDisplayMode: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
{$IFDEF D3D_deprecated}
function GetDisplayMode: TDDSurfaceDesc;
function GetIDDraw: IDirectDraw;
function GetIDDraw4: IDirectDraw4;
{$ENDIF}
function GetIDDraw7: IDirectDraw7;
{$IFDEF D3D_deprecated}
function GetIDraw: IDirectDraw;
function GetIDraw4: IDirectDraw4;
{$ENDIF}
function GetIDraw7: IDirectDraw7;
function GetPalette(Index: Integer): TDirectDrawPalette;
function GetPaletteCount: Integer;
195,21 → 51,16
constructor CreateEx(GUID: PGUID; DirectX7Mode: Boolean);
destructor Destroy; override;
class function Drivers: TDirectXDrivers;
{$IFDEF _DMO_}class function DriversEx: TDirectXDriversEx;{$ENDIF}
property ClipperCount: Integer read GetClipperCount;
property Clippers[Index: Integer]: TDirectDrawClipper read GetClipper;
property DisplayMode: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF} read GetDisplayMode;
property DisplayMode: TDDSurfaceDesc read GetDisplayMode;
property DriverCaps: TDDCaps read FDriverCaps;
property HELCaps: TDDCaps read FHELCaps;
{$IFDEF D3D_deprecated}
property IDDraw: IDirectDraw read GetIDDraw;
property IDDraw4: IDirectDraw4 read GetIDDraw4;
{$ENDIF}
property IDDraw7: IDirectDraw7 read GetIDDraw7;
{$IFDEF D3D_deprecated}
property IDraw: IDirectDraw read GetIDraw;
property IDraw4: IDirectDraw4 read GetIDraw4;
{$ENDIF}
property IDraw7: IDirectDraw7 read GetIDraw7;
property PaletteCount: Integer read GetPaletteCount;
property Palettes[Index: Integer]: TDirectDrawPalette read GetPalette;
284,63 → 135,35
FCanvas: TDirectDrawSurfaceCanvas;
FHasClipper: Boolean;
FDDraw: TDirectDraw;
{$IFDEF D3D_deprecated}
FIDDSurface: IDirectDrawSurface;
FIDDSurface4: IDirectDrawSurface4;
{$ENDIF}
FIDDSurface7: IDirectDrawSurface7;
FSystemMemory: Boolean;
FStretchDrawClipper: IDirectDrawClipper;
FSurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
FSurfaceDesc: TDDSurfaceDesc;
FGammaControl: IDirectDrawGammaControl;
FLockSurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
FLockSurfaceDesc: TDDSurfaceDesc;
FLockCount: Integer;
FIsLocked: Boolean;
FModified: Boolean;
FCaption: TCaption;
DIB_COLMATCH: TDIB;
function GetBitCount: Integer;
function GetCanvas: TDirectDrawSurfaceCanvas;
function GetClientRect: TRect;
function GetHeight: Integer;
{$IFDEF D3D_deprecated}
function GetIDDSurface: IDirectDrawSurface; {$IFDEF VER9UP}inline;{$ENDIF}
function GetIDDSurface4: IDirectDrawSurface4; {$IFDEF VER9UP}inline;{$ENDIF}
{$ENDIF}
function GetIDDSurface7: IDirectDrawSurface7; {$IFDEF VER9UP}inline;{$ENDIF}
{$IFDEF D3D_deprecated}
function GetIDDSurface: IDirectDrawSurface;
function GetIDDSurface4: IDirectDrawSurface4;
function GetIDDSurface7: IDirectDrawSurface7;
function GetISurface: IDirectDrawSurface;
function GetISurface4: IDirectDrawSurface4;
{$ENDIF}
function GetISurface7: IDirectDrawSurface7;
function GetPixel(X, Y: Integer): Longint;
function GetWidth: Integer;
procedure SetClipper(Value: TDirectDrawClipper);
procedure SetColorKey(Flags: DWORD; const Value: TDDColorKey);
{$IFDEF D3D_deprecated}
procedure SetIDDSurface(Value: IDirectDrawSurface);
procedure SetIDDSurface4(Value: IDirectDrawSurface4);
{$ENDIF}
procedure SetIDDSurface7(Value: IDirectDrawSurface7);
procedure SetPalette(Value: TDirectDrawPalette);
procedure SetPixel(X, Y: Integer; Value: Longint);
procedure SetTransparentColor(Col: Longint);
{support RGB routines}
procedure LoadRGB(Color: cardinal; var R, G, B: Byte);
function SaveRGB(const R, G, B: Byte): cardinal;
{asm routine for direct surface by pixel}
{no clipping}
function GetPixel16(x, y: Integer): Integer; register;
function GetPixel24(x, y: Integer): Integer; register;
function GetPixel32(x, y: Integer): Integer; register;
function GetPixel8(x, y: Integer): Integer; register;
procedure PutPixel16(x, y, color: Integer); register;
procedure PutPixel24(x, y, color: Integer); register;
procedure PutPixel32(x, y, color: Integer); register;
procedure PutPixel8(x, y, color: Integer); register;
{routines calls asm pixel routine}
function Peek(X, Y: Integer): LongInt; {$IFDEF VER9UP} inline; {$ENDIF}
procedure Poke(X, Y: Integer; const Value: LongInt); {$IFDEF VER9UP} inline; {$ENDIF}
public
constructor Create(ADirectDraw: TDirectDraw);
destructor Destroy; override;
347,22 → 170,17
procedure Assign(Source: TPersistent); override;
procedure AssignTo(Dest: TPersistent); override;
function Blt(const DestRect, SrcRect: TRect; Flags: DWORD;
const DF: TDDBltFX; Source: TDirectDrawSurface): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
const DF: TDDBltFX; Source: TDirectDrawSurface): Boolean;
function BltFast(X, Y: Integer; const SrcRect: TRect;
Flags: DWORD; Source: TDirectDrawSurface): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function ColorMatch(Col: TColor): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
{$IFDEF VER4UP}
{$IFDEF D3D_deprecated}
function CreateSurface(SurfaceDesc: TDDSurfaceDesc): Boolean; overload;
{$ENDIF}
function CreateSurface(SurfaceDesc: TDDSurfaceDesc2): Boolean; overload;
Flags: DWORD; Source: TDirectDrawSurface): Boolean;
function ColorMatch(Col: TColor): Integer;
{$IFDEF DelphiX_Spt4}
function CreateSurface(const SurfaceDesc: TDDSurfaceDesc): Boolean; overload;
function CreateSurface(const SurfaceDesc: TDDSurfaceDesc2): Boolean; overload;
{$ELSE}
function CreateSurface(SurfaceDesc: TDDSurfaceDesc): Boolean;
function CreateSurface(const SurfaceDesc: TDDSurfaceDesc): Boolean;
{$ENDIF}
 
procedure MirrorFlip(Value: TRenderMirrorFlipSet);
 
{$IFDEF VER4UP}
{$IFDEF DelphiX_Spt4}
procedure Draw(X, Y: Integer; SrcRect: TRect; Source: TDirectDrawSurface; Transparent: Boolean = True); overload;
procedure Draw(X, Y: Integer; Source: TDirectDrawSurface; Transparent: Boolean = True); overload;
procedure StretchDraw(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
376,94 → 194,38
Transparent: Boolean);
{$ENDIF}
procedure DrawAdd(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
Transparent: Boolean; Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawAlpha(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean; Alpha: Integer);
procedure DrawSub(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
 
procedure DrawAddCol(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean; Color, Alpha: Integer);
procedure DrawAlphaCol(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean; Color, Alpha: Integer);
procedure DrawSubCol(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean; Color, Alpha: Integer);
 
{Rotate}
Transparent: Boolean; Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawRotate(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: single);
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: Integer);
procedure DrawRotateAdd(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: single;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: Integer;
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawRotateAlpha(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: single;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: Integer;
Alpha: Integer);
procedure DrawRotateSub(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: single;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
 
procedure DrawRotateAddCol(X, Y, Width, Height: Integer;
const SrcRect: TRect; Source: TDirectDrawSurface; CenterX,
CenterY: Double; Transparent: Boolean; Angle: Single; Color: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawRotateAlphaCol(X, Y, Width, Height: Integer;
const SrcRect: TRect; Source: TDirectDrawSurface; CenterX,
CenterY: Double; Transparent: Boolean; Angle: Single; Color: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawRotateCol(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double;
Transparent: Boolean; Angle: Single; Color: Integer);
procedure DrawRotateSubCol(X, Y, Width, Height: Integer;
const SrcRect: TRect; Source: TDirectDrawSurface; CenterX,
CenterY: Double; Transparent: Boolean; Angle: Single; Color: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
{WaveX}
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: Integer;
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawWaveX(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph: Integer);
procedure DrawWaveXAdd(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawWaveXAlpha(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
Alpha: Integer);
procedure DrawWaveXSub(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
{WaveY}
procedure DrawWaveY(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph: Integer);
procedure DrawWaveYAdd(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawWaveYAlpha(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawWaveYSub(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
{Poke function}
procedure PokeLine(X1, Y1, X2, Y2: Integer; Color: cardinal); {$IFDEF VER9UP} inline; {$ENDIF}
procedure PokeLinePolar(x, y: Integer; angle, length: extended;
Color: cardinal); {$IFDEF VER9UP} inline; {$ENDIF}
procedure PokeBox(xs, ys, xd, yd: Integer; Color: cardinal);
procedure PokeBlendPixel(const X, Y: Integer; aColor: cardinal;
Alpha: byte);
procedure PokeWuLine(X1, Y1, X2, Y2, aColor: Integer);
procedure Noise(Oblast: TRect; Density: Byte);
procedure Blur;
procedure DoRotate(cent1, cent2, angle: Integer; coord1, coord2: Real;
color: word);
procedure PokeCircle(X, Y, Radius, Color: Integer);
procedure PokeEllipse(exc, eyc, ea, eb, angle, color: Integer);
procedure PokeFilledEllipse(exc, eyc, ea, eb, color: Integer);
procedure PokeVLine(x, y1, y2: Integer; Color: cardinal);
{Fill}
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure Fill(DevColor: Longint);
procedure FillRect(const Rect: TRect; DevColor: Longint);
procedure FillRectAdd(const DestRect: TRect; Color: TColor; Alpha: Byte{$IFDEF VER4UP} = 128{$ENDIF});
procedure FillRectAdd(const DestRect: TRect; Color: TColor);
procedure FillRectAlpha(const DestRect: TRect; Color: TColor; Alpha: Integer);
procedure FillRectSub(const DestRect: TRect; Color: TColor; Alpha: Byte{$IFDEF VER4UP} = 128{$ENDIF});
{Load}
procedure FillRectSub(const DestRect: TRect; Color: TColor);
procedure LoadFromDIB(DIB: TDIB);
procedure LoadFromDIBRect(DIB: TDIB; AWidth, AHeight: Integer; const SrcRect: TRect);
procedure LoadFromGraphic(Graphic: TGraphic);
470,19 → 232,15
procedure LoadFromGraphicRect(Graphic: TGraphic; AWidth, AHeight: Integer; const SrcRect: TRect);
procedure LoadFromFile(const FileName: string);
procedure LoadFromStream(Stream: TStream);
{$IFDEF VER4UP}
function Lock(const Rect: TRect; var SurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF}): Boolean; overload;
function Lock(var SurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF}): Boolean; overload;
function Lock: Boolean; overload;
{$IFDEF DelphiX_Spt4}
function Lock(const Rect: TRect; var SurfaceDesc: TDDSurfaceDesc): Boolean; overload;
function Lock(var SurfaceDesc: TDDSurfaceDesc): Boolean; overload;
{$ELSE}
function LockSurface: Boolean;
function Lock(const Rect: TRect; var SurfaceDesc: TDDSurfaceDesc): Boolean;
{$ENDIF}
procedure UnLock;
function Restore: Boolean;
property IsLocked: Boolean read FIsLocked;
procedure SetSize(AWidth, AHeight: Integer);
property Modified: Boolean read FModified write FModified;
property BitCount: Integer read GetBitCount;
property Canvas: TDirectDrawSurfaceCanvas read GetCanvas;
property ClientRect: TRect read GetClientRect;
491,24 → 249,18
property DDraw: TDirectDraw read FDDraw;
property GammaControl: IDirectDrawGammaControl read FGammaControl;
property Height: Integer read GetHeight;
{$IFDEF D3D_deprecated}
property IDDSurface: IDirectDrawSurface read GetIDDSurface write SetIDDSurface;
property IDDSurface4: IDirectDrawSurface4 read GetIDDSurface4 write SetIDDSurface4;
{$ENDIF}
property IDDSurface7: IDirectDrawSurface7 read GetIDDSurface7 write SetIDDSurface7;
{$IFDEF D3D_deprecated}
property ISurface: IDirectDrawSurface read GetISurface;
property ISurface4: IDirectDrawSurface4 read GetISurface4;
{$ENDIF}
property ISurface7: IDirectDrawSurface7 read GetISurface7;
property Palette: TDirectDrawPalette write SetPalette;
property Pixels[X, Y: Integer]: Longint read GetPixel write SetPixel;
property Pixel[X, Y: Integer]: LongInt read Peek write Poke;
property SurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF} read FSurfaceDesc;
property SurfaceDesc: TDDSurfaceDesc read FSurfaceDesc;
property SystemMemory: Boolean read FSystemMemory write FSystemMemory;
property TransparentColor: Longint write SetTransparentColor;
property Width: Integer read GetWidth;
property Caption: TCaption read FCaption write FCaption;
end;
 
{ TDXDrawDisplay }
545,7 → 297,7
procedure SetBitCount(Value: Integer);
procedure SetHeight(Value: Integer);
procedure SetWidth(Value: Integer);
function SetSize(AWidth, AHeight, ABitCount{$IFNDEF D3D_deprecated}, ARefreshRate, AFlags{$ENDIF}: Integer): Boolean;
function SetSize(AWidth, AHeight, ABitCount: Integer): Boolean;
function DynSetSize(AWidth, AHeight, ABitCount: Integer): Boolean;
public
constructor Create(ADXDraw: TCustomDXDraw);
556,7 → 308,7
property Mode: TDXDrawDisplayMode read GetMode;
property Modes[Index: Integer]: TDXDrawDisplayMode read GetMode2; default;
published
property BitCount: Integer read FBitCount write SetBitCount default 16;
property BitCount: Integer read FBitCount write SetBitCount default 8;
property FixedBitCount: Boolean read FFixedBitCount write FFixedBitCount;
property FixedRatio: Boolean read FFixedRatio write FFixedRatio;
property FixedSize: Boolean read FFixedSize write FFixedSize;
571,23 → 323,11
 
EDXDrawError = class(Exception);
 
{ TD2D HW acceleration}
 
TD2D = class;
 
{ TTracerCollection }
 
TTraces = class;
 
{ TCustomDXDraw }
 
TD2DTextureFilter = (D2D_POINT, D2D_LINEAR, D2D_FLATCUBIC, D2D_GAUSSIANCUBIC, D2D_ANISOTROPIC);
 
 
TDXDrawOption = (doFullScreen, doNoWindowChange, doAllowReboot, doWaitVBlank,
doAllowPalette256, doSystemMemory, doStretch, doCenter, doFlip,
{$IFDEF D3D_deprecated}do3D, doDirectX7Mode,{$ENDIF} {$IFDEF D3DRM} doRetainedMode,{$ENDIF}
doHardware, doSelectDriver, doZBuffer);
do3D, doDirectX7Mode, doRetainedMode, doHardware, doSelectDriver, doZBuffer);
 
TDXDrawOptions = set of TDXDrawOption;
 
596,16 → 336,6
 
TDXDrawNotifyEvent = procedure(Sender: TCustomDXDraw; NotifyType: TDXDrawNotifyType) of object;
 
TD2DTextures = class;
TOnUpdateTextures = procedure(const Sender: TD2DTextures; var Changed: Boolean) of object;
 
TPictureCollectionItem = class;
 
{$IFNDEF D3D_deprecated}
TD3DDeviceType = (dtTnLHAL, dtHAL,dtMMX,dtRGB,dtRamp,dtRef);
TD3DDeviceTypeSet = Set of TD3DDeviceType;
{$ENDIF}
 
TCustomDXDraw = class(TCustomControl)
private
FAutoInitialize: Boolean;
634,9 → 364,6
FDriverGUID: TGUID;
FDDraw: TDirectDraw;
FDisplay: TDXDrawDisplay;
{$IFNDEF D3D_deprecated}
FDeviceTypeSet: TD3DDeviceTypeSet;{$ENDIF}
{$IFDEF _DMO_}FAdapters: TDirectXDriversEx;{$ENDIF}
FClipper: TDirectDrawClipper;
FPalette: TDirectDrawPalette;
FPrimary: TDirectDrawSurface;
644,19 → 371,14
FSurfaceWidth: Integer;
FSurfaceHeight: Integer;
{ Direct3D }
{$IFDEF D3D_deprecated}
FD3D: IDirect3D;
FD3D2: IDirect3D2;
FD3D3: IDirect3D3;
{$ENDIF}
FD3D7: IDirect3D7;
{$IFDEF D3D_deprecated}
FD3DDevice: IDirect3DDevice;
FD3DDevice2: IDirect3DDevice2;
FD3DDevice3: IDirect3DDevice3;
{$ENDIF}
FD3DDevice7: IDirect3DDevice7;
{$IFDEF D3DRM}
FD3DRM: IDirect3DRM;
FD3DRM2: IDirect3DRM2;
FD3DRM3: IDirect3DRM3;
666,18 → 388,14
FCamera: IDirect3DRMFrame;
FScene: IDirect3DRMFrame;
FViewport: IDirect3DRMViewport;
{$ENDIF}
FZBuffer: TDirectDrawSurface;
FD2D: TD2D;
FOnUpdateTextures: TOnUpdateTextures;
FTraces: TTraces;
FOnRender: TNotifyEvent;
procedure FormWndProc(var Message: TMessage; DefWindowProc: TWndMethod);
function GetCanDraw: Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function GetCanDraw: Boolean;
function GetCanPaletteAnimation: Boolean;
function GetSurfaceHeight: Integer;
function GetSurfaceWidth: Integer;
procedure NotifyEventList(NotifyType: TDXDrawNotifyType);
procedure SetAutoSize(Value: Boolean);
procedure SetColorTable(const ColorTable: TRGBQuads);
procedure SetCooperativeLevel;
procedure SetDisplay(Value: TDXDrawDisplay);
687,11 → 405,6
procedure SetSurfaceWidth(Value: Integer);
function TryRestore: Boolean;
procedure WMCreate(var Message: TMessage); message WM_CREATE;
function Fade2Color(colorfrom, colorto: Integer): LongInt;
function Grey2Fade(shadefrom, shadeto: Integer): Integer;
procedure SetTraces(const Value: TTraces);
function CheckD3: Boolean;
function CheckD3D(Dest: TDirectDrawSurface): Boolean;
protected
procedure DoFinalize; virtual;
procedure DoFinalizeSurface; virtual;
703,68 → 416,38
procedure Paint; override;
function PaletteChanged(Foreground: Boolean): Boolean; override;
procedure SetParent(AParent: TWinControl); override;
procedure SetAutoSize(Value: Boolean); {$IFDEF D6UP} override; {$ENDIF}
property OnUpdateTextures: TOnUpdateTextures read FOnUpdateTextures write FOnUpdateTextures;
property OnRender: TNotifyEvent read FOnRender write FOnRender;
public
ColorTable: TRGBQuads;
DefColorTable: TRGBQuads;
//
function Fade2Black(colorfrom: Integer): Longint;
function Fade2White(colorfrom: Integer): Longint;
//
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
class function Drivers: TDirectXDrivers;
{$IFDEF _DMO_}class function DriversEx: TDirectXDriversEx;{$ENDIF}
procedure Finalize;
procedure Flip;
procedure Initialize;
procedure Render(LagCount: Integer{$IFDEF VER4UP} = 0{$ENDIF});
procedure Render;
procedure Restore;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
procedure SetSize(ASurfaceWidth, ASurfaceHeight: Integer);
procedure BeginScene;
procedure EndScene;
procedure TextureFilter(Grade: TD2DTextureFilter);
procedure AntialiasFilter(Grade: TD3DAntialiasMode);
procedure MirrorFlip(Value: TRenderMirrorFlipSet);
procedure SaveTextures(path: string);
procedure ClearStack;
procedure UpdateTextures;
{grab images}
procedure PasteImage(sdib: TDIB; x, y: Integer);
procedure GrabImage(iX, iY, iWidth, iHeight: Integer; ddib: TDIB);
{fades}
function Black2Screen(oldcolor: Integer): Longint;
function Fade2Screen(oldcolor, newcolour: Integer): LongInt;
function White2Screen(oldcolor: Integer): LongInt;
function FadeGrey2Screen(oldcolor, newcolour: LongInt): LongInt;
procedure UpdatePalette;
procedure RegisterNotifyEvent(NotifyEvent: TDXDrawNotifyEvent);
procedure UnRegisterNotifyEvent(NotifyEvent: TDXDrawNotifyEvent);
 
property AutoInitialize: Boolean read FAutoInitialize write FAutoInitialize;
property AutoSize: Boolean read FAutoSize write SetAutoSize;
{$IFDEF D3DRM}property Camera: IDirect3DRMFrame read FCamera; {$ENDIF}
property Camera: IDirect3DRMFrame read FCamera;
property CanDraw: Boolean read GetCanDraw;
property CanPaletteAnimation: Boolean read GetCanPaletteAnimation;
property Clipper: TDirectDrawClipper read FClipper;
property Color;
{$IFDEF D3D_deprecated}
property D3D: IDirect3D read FD3D;
property D3D2: IDirect3D2 read FD3D2;
property D3D3: IDirect3D3 read FD3D3;
{$ENDIF}
property D3D7: IDirect3D7 read FD3D7;
{$IFDEF D3D_deprecated}
property D3DDevice: IDirect3DDevice read FD3DDevice;
property D3DDevice2: IDirect3DDevice2 read FD3DDevice2;
property D3DDevice3: IDirect3DDevice3 read FD3DDevice3;
{$ENDIF}
property D3DDevice7: IDirect3DDevice7 read FD3DDevice7;
{$IFNDEF D3D_deprecated}
property D3DDeviceTypeSet: TD3DDeviceTypeSet read FDeviceTypeSet;{$ENDIF}
{$IFDEF D3DRM}
property D3DRM: IDirect3DRM read FD3DRM;
property D3DRM2: IDirect3DRM2 read FD3DRM2;
property D3DRM3: IDirect3DRM3 read FD3DRM3;
771,10 → 454,8
property D3DRMDevice: IDirect3DRMDevice read FD3DRMDevice;
property D3DRMDevice2: IDirect3DRMDevice2 read FD3DRMDevice2;
property D3DRMDevice3: IDirect3DRMDevice3 read FD3DRMDevice3;
{$ENDIF}
property DDraw: TDirectDraw read FDDraw;
property Display: TDXDrawDisplay read FDisplay write SetDisplay;
{$IFDEF _DMO_}property Adapter: TDirectXDriversEx read FAdapters write FAdapters;{$ENDIF}
property Driver: PGUID read FDriver write SetDriver;
property Initialized: Boolean read FInitialized;
property NowOptions: TDXDrawOptions read FNowOptions;
787,14 → 468,12
property Options: TDXDrawOptions read FOptions write SetOptions;
property Palette: TDirectDrawPalette read FPalette;
property Primary: TDirectDrawSurface read FPrimary;
{$IFDEF D3DRM}property Scene: IDirect3DRMFrame read FScene; {$ENDIF}
property Scene: IDirect3DRMFrame read FScene;
property Surface: TDirectDrawSurface read FSurface;
property SurfaceHeight: Integer read GetSurfaceHeight write SetSurfaceHeight default 480;
property SurfaceWidth: Integer read GetSurfaceWidth write SetSurfaceWidth default 640;
{$IFDEF D3DRM}property Viewport: IDirect3DRMViewport read FViewport; {$ENDIF}
property Viewport: IDirect3DRMViewport read FViewport;
property ZBuffer: TDirectDrawSurface read FZBuffer;
property D2D1: TD2D read FD2D; {public object is here}
property Traces: TTraces read FTraces write SetTraces;
end;
 
{ TDXDraw }
801,7 → 480,6
 
TDXDraw = class(TCustomDXDraw)
published
{$IFDEF _DMO_}property Adapter;{$ENDIF}
property AutoInitialize;
property AutoSize;
property Color;
815,12 → 493,10
property OnInitializeSurface;
property OnInitializing;
property OnRestoreSurface;
property OnUpdateTextures;
property OnRender;
 
property Align;
{$IFDEF VER4UP}property Anchors; {$ENDIF}
{$IFDEF VER4UP}property Constraints; {$ENDIF}
{$IFDEF DelphiX_Spt4}property Anchors;{$ENDIF}
{$IFDEF DelphiX_Spt4}property Constraints;{$ENDIF}
property DragCursor;
property DragMode;
property Enabled;
829,7 → 505,6
property ShowHint;
property TabOrder;
property TabStop;
property Traces;
property Visible;
property OnClick;
property OnDblClick;
844,12 → 519,7
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
{$IFDEF VER9UP}
property OnMouseWheel;
property OnMouseWheelUp;
property OnMouseWheelDown;
{$ENDIF}
{$IFDEF VER4UP}property OnResize; {$ENDIF}
{$IFDEF DelphiX_Spt4}property OnResize;{$ENDIF}
property OnStartDrag;
end;
 
857,314 → 527,6
 
EDX3DError = class(Exception);
 
{ DxTracer }
 
EDXTracerError = class(Exception);
EDXBlitError = class(Exception);
 
TTracePointsType = (tptDot, tptLine, tptCircle, tptCurve);
 
TBlitMoveEvent = procedure(Sender: TObject; LagCount: Integer; var MoveIt: Boolean) of object;
TWaveType = (wtWaveNone, wtWaveX, wtWaveY);
TBlitRec = packed record
FCollisioned: Boolean;
FMoved: Boolean;
FVisible: Boolean;
FX: Double;
FY: Double;
FZ: Integer;
FWidth: Integer;
FHeight: Integer;
//--
FAnimCount: Integer;
FAnimLooped: Boolean;
FAnimPos: Double;
FAnimSpeed: Double;
FAnimStart: Integer;
//FTile: Boolean;
FAngle: Single;
FAlpha: Integer;
FCenterX: Double;
FCenterY: Double;
FScale: Double;
FBlendMode: TRenderType;
FAmplitude: Integer;
FAmpLength: Integer;
FPhase: Integer;
FWaveType: TWaveType;
FSpeedX, FSpeedY: Single;
FGravityX, FGravityY: Single;
FEnergy: Single;
FBlurImage: Boolean;
FMirror: Boolean;
FFlip: Boolean;
FTextureFilter: TD2DTextureFilter;
end;
TBlurImageProp = packed record
eActive: Boolean;
eX, eY: Integer;
ePatternIndex: Integer; {when animated or 0 always}
eAngle: Single; //angle can be saved too
eBlendMode: TRenderType; //blend mode
eIntensity: Byte; {intensity of Blur/Add/Sub}
end;
 
TPath = packed record
X, Y, Z: Single;
StayOn: Integer; {in milisecond}
Reserved: string[28]; {for future use}
Tag: Integer;
end;
TPathArr = array{$IFNDEF VER4UP} [0..0]{$ENDIF} of TPath;
{$IFNDEF VER4UP}
PPathArr = ^TPathArr;
{$ENDIF}
TBlit = class;
 
TOnRender = procedure(Sender: TBlit) of object;
 
TBlurImageArr = array[0..7] of TBlurImageProp;
TBlit = class(TPersistent)
private
FPathArr: {$IFNDEF VER4UP}PPathArr{$ELSE}TPathArr{$ENDIF};
{$IFNDEF VER4UP}
FPathLen: Integer;
{$ENDIF}
FParent: TBlit;
FBlitRec: TBlitRec;
FBlurImageArr: TBlurImageArr;
FActive: Boolean;
//--
FImage: TPictureCollectionItem;
FOnMove: TBlitMoveEvent;
FOnDraw: TNotifyEvent;
FOnCollision: TNotifyEvent;
FOnGetImage: TNotifyEvent;
FEngine: TCustomDXDraw;
FMovingRepeatly: Boolean;
FBustrofedon: Boolean;
FOnRender: TOnRender;
function GetWorldX: Double;
function GetWorldY: Double;
function GetDrawImageIndex: Integer;
function GetAlpha: Byte;
function GetAmpLength: Integer;
function GetAmplitude: Integer;
function GetAngle: Single;
function GetAnimCount: Integer;
function GetAnimLooped: Boolean;
function GetAnimPos: Double;
function GetAnimSpeed: Double;
function GetAnimStart: Integer;
function GetBlendMode: TRenderType;
function GetBlurImage: Boolean;
function GetCenterX: Double;
function GetCenterY: Double;
function GetCollisioned: Boolean;
function GetEnergy: Single;
function GetFlip: Boolean;
function GetGravityX: Single;
function GetGravityY: Single;
function GetHeight: Integer;
function GetMirror: Boolean;
function GetMoved: Boolean;
function GetPhase: Integer;
function GetScale: Double;
function GetSpeedX: Single;
function GetSpeedY: Single;
function GetVisible: Boolean;
function GetWaveType: TWaveType;
function GetWidth: Integer;
function GetX: Double;
function GetY: Double;
function GetZ: Integer;
procedure SetAlpha(const Value: Byte);
procedure SetAmpLength(const Value: Integer);
procedure SetAmplitude(const Value: Integer);
procedure SetAngle(const Value: Single);
procedure SetAnimCount(const Value: Integer);
procedure SetAnimLooped(const Value: Boolean);
procedure SetAnimPos(const Value: Double);
procedure SetAnimSpeed(const Value: Double);
procedure SetAnimStart(const Value: Integer);
procedure SetBlendMode(const Value: TRenderType);
procedure SetBlurImage(const Value: Boolean);
procedure SetCenterX(const Value: Double);
procedure SetCenterY(const Value: Double);
procedure SetCollisioned(const Value: Boolean);
procedure SetEnergy(const Value: Single);
procedure SetFlip(const Value: Boolean);
procedure SetGravityX(const Value: Single);
procedure SetGravityY(const Value: Single);
procedure SetHeight(const Value: Integer);
procedure SetMirror(const Value: Boolean);
procedure SetMoved(const Value: Boolean);
procedure SetPhase(const Value: Integer);
procedure SetScale(const Value: Double);
procedure SetSpeedX(const Value: Single);
procedure SetSpeedY(const Value: Single);
procedure SetVisible(const Value: Boolean);
procedure SetWaveType(const Value: TWaveType);
procedure SetWidth(const Value: Integer);
procedure SetX(const Value: Double);
procedure SetY(const Value: Double);
procedure SetZ(const Value: Integer);
function StoreAngle: Boolean;
function StoreAnimPos: Boolean;
function StoreAnimSpeed: Boolean;
function StoreCenterX: Boolean;
function StoreCenterY: Boolean;
function StoreEnergy: Boolean;
function StoreGravityX: Boolean;
function StoreGravityY: Boolean;
function StoreScale: Boolean;
function StoreSpeedX: Boolean;
function StoreSpeedY: Boolean;
function GetBoundsRect: TRect;
function GetClientRect: TRect;
function GetPath(index: Integer): TPath;
procedure SetPath(index: Integer; const Value: TPath);
procedure ReadPaths(Stream: TStream);
procedure WritePaths(Stream: TStream);
function GetMovingRepeatly: Boolean;
procedure SetMovingRepeatly(const Value: Boolean);
function GetBustrofedon: Boolean;
procedure SetBustrofedon(const Value: Boolean);
function GetTextureFilter: TD2DTextureFilter;
procedure SetTextureFilter(const Value: TD2DTextureFilter);
protected
procedure DoDraw; virtual;
procedure DoMove(LagCount: Integer);
function DoCollision: TBlit; virtual;
procedure DoGetImage; virtual;
procedure DefineProperties(Filer: TFiler); override;
public
FCurrentPosition, FCurrentTime: Integer;
FCurrentDirection: Boolean;
constructor Create(AParent: TObject); virtual;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property Engine: TCustomDXDraw read FEngine write FEngine;
property Parent: TBlit read FParent;
property WorldX: Double read GetWorldX;
property WorldY: Double read GetWorldY;
procedure ReAnimate(MoveCount: Integer); virtual;
property Image: TPictureCollectionItem read FImage write FImage;
property BoundsRect: TRect read GetBoundsRect;
property ClientRect: TRect read GetClientRect;
procedure SetPathLen(Len: Integer);
function IsPathEmpty: Boolean;
function GetPathCount: Integer;
function GetBlitAt(X, Y: Integer): TBlit;
property Path[index: Integer]: TPath read GetPath write SetPath; default;
published
property Active: Boolean read FActive write FActive default False;
//--
property Collisioned: Boolean read GetCollisioned write SetCollisioned default True;
property Moved: Boolean read GetMoved write SetMoved default True;
property Visible: Boolean read GetVisible write SetVisible default True;
property X: Double read GetX write SetX;
property Y: Double read GetY write SetY;
property Z: Integer read GetZ write SetZ;
property Width: Integer read GetWidth write SetWidth;
property Height: Integer read GetHeight write SetHeight;
property MovingRepeatly: Boolean read GetMovingRepeatly write SetMovingRepeatly default True;
property Bustrofedon: Boolean read GetBustrofedon write SetBustrofedon default False;
//--
property AnimCount: Integer read GetAnimCount write SetAnimCount default 0;
property AnimLooped: Boolean read GetAnimLooped write SetAnimLooped default False;
property AnimPos: Double read GetAnimPos write SetAnimPos stored StoreAnimPos;
property AnimSpeed: Double read GetAnimSpeed write SetAnimSpeed stored StoreAnimSpeed;
property AnimStart: Integer read GetAnimStart write SetAnimStart default 0;
property Angle: Single read GetAngle write SetAngle stored StoreAngle;
property Alpha: Byte read GetAlpha write SetAlpha default $FF;
property CenterX: Double read GetCenterX write SetCenterX stored StoreCenterX;
property CenterY: Double read GetCenterY write SetCenterY stored StoreCenterY;
property Scale: Double read GetScale write SetScale stored StoreScale;
property BlendMode: TRenderType read GetBlendMode write SetBlendMode default rtDraw;
property Amplitude: Integer read GetAmplitude write SetAmplitude default 0;
property AmpLength: Integer read GetAmpLength write SetAmpLength default 0;
property Phase: Integer read GetPhase write SetPhase default 0;
property WaveType: TWaveType read GetWaveType write SetWaveType default wtWaveNone;
property SpeedX: Single read GetSpeedX write SetSpeedX stored StoreSpeedX;
property SpeedY: Single read GetSpeedY write SetSpeedY stored StoreSpeedY;
property GravityX: Single read GetGravityX write SetGravityX stored StoreGravityX;
property GravityY: Single read GetGravityY write SetGravityY stored StoreGravityY;
property Energy: Single read GetEnergy write SetEnergy stored StoreEnergy;
property BlurImage: Boolean read GetBlurImage write SetBlurImage default False;
property Mirror: Boolean read GetMirror write SetMirror default False;
property Flip: Boolean read GetFlip write SetFlip default False;
property TextureFilter: TD2DTextureFilter read GetTextureFilter write SetTextureFilter default D2D_POINT;
 
property OnGetImage: TNotifyEvent read FOnGetImage write FOnGetImage;
property OnMove: TBlitMoveEvent read FOnMove write FOnMove;
property OnDraw: TNotifyEvent read FOnDraw write FOnDraw;
property OnCollision: TNotifyEvent read FOnCollision write FOnCollision;
property OnRender: TOnRender read FOnRender write FOnRender;
end;
 
TTrace = class(THashCollectionItem)
private
FActualized: Boolean;
FTag: Integer;
FBlit: TBlit;
function GetTraces: TTraces;
function GetOnCollision: TNotifyEvent;
function GetOnDraw: TNotifyEvent;
function GetOnGetImage: TNotifyEvent;
function GetOnMove: TBlitMoveEvent;
procedure SetOnCollision(const Value: TNotifyEvent);
procedure SetOnDraw(const Value: TNotifyEvent);
procedure SetOnGetImage(const Value: TNotifyEvent);
procedure SetOnMove(const Value: TBlitMoveEvent);
function GetActive: Boolean;
procedure SetActive(const Value: Boolean);
function GetOnRender: TOnRender;
procedure SetOnRender(const Value: TOnRender);
protected
function GetDisplayName: string; override;
procedure SetDisplayName(const Value: string); override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Render(const LagCount: Integer);
function IsActualized: Boolean;
procedure Assign(Source: TPersistent); override;
property Traces: TTraces read GetTraces;
function Clone(NewName: string; OffsetX: Integer{$IFDEF VER4UP} = 0{$ENDIF}; OffsetY: Integer{$IFDEF VER4UP} = 0{$ENDIF}; Angle: Single{$IFDEF VER4UP} = 0{$ENDIF}): TTrace;
published
property Active: Boolean read GetActive write SetActive;
property Tag: Integer read FTag write FTag;
property Blit: TBlit read FBlit write FBlit;
{events}
property OnGetImage: TNotifyEvent read GetOnGetImage write SetOnGetImage;
property OnMove: TBlitMoveEvent read GetOnMove write SetOnMove;
property OnDraw: TNotifyEvent read GetOnDraw write SetOnDraw;
property OnCollision: TNotifyEvent read GetOnCollision write SetOnCollision;
property OnRender: TOnRender read GetOnRender write SetOnRender;
end;
 
TTraces = class(THashCollection)
private
FOwner: TPersistent;
function GetItem(Index: Integer): TTrace;
procedure SetItem(Index: Integer; Value: TTrace);
protected
function GetOwner: TPersistent; override;
public
constructor Create(AOwner: TComponent);
function Add: TTrace;
function Find(const Name: string): TTrace;
{$IFDEF VER4UP}
function Insert(Index: Integer): TTrace;
{$ENDIF}
procedure Update(Item: TCollectionItem); override;
property Items[Index: Integer]: TTrace read GetItem write SetItem;
destructor Destroy; override;
end;
 
{$IFDEF DX3D_deprecated}
 
{ TCustomDX3D }
 
TDX3DOption = (toRetainedMode, toSystemMemory, toHardware, toSelectDriver, toZBuffer);
1174,20 → 536,15
TCustomDX3D = class(TComponent)
private
FAutoSize: Boolean;
{$IFDEF D3DRM}FCamera: IDirect3DRMFrame; {$ENDIF}
{$IFDEF D3D_deprecated}
FCamera: IDirect3DRMFrame;
FD3D: IDirect3D;
FD3D2: IDirect3D2;
FD3D3: IDirect3D3;
{$ENDIF}
FD3D7: IDirect3D7;
{$IFDEF D3D_deprecated}
FD3DDevice: IDirect3DDevice;
FD3DDevice2: IDirect3DDevice2;
FD3DDevice3: IDirect3DDevice3;
{$ENDIF}
FD3DDevice7: IDirect3DDevice7;
{$IFDEF D3DRM}
FD3DRM: IDirect3DRM;
FD3DRM2: IDirect3DRM2;
FD3DRM3: IDirect3DRM3;
1194,7 → 551,6
FD3DRMDevice: IDirect3DRMDevice;
FD3DRMDevice2: IDirect3DRMDevice2;
FD3DRMDevice3: IDirect3DRMDevice3;
{$ENDIF}
FDXDraw: TCustomDXDraw;
FInitFlag: Boolean;
FInitialized: Boolean;
1202,11 → 558,11
FOnFinalize: TNotifyEvent;
FOnInitialize: TNotifyEvent;
FOptions: TDX3DOptions;
{$IFDEF D3DRM}FScene: IDirect3DRMFrame; {$ENDIF}
FScene: IDirect3DRMFrame;
FSurface: TDirectDrawSurface;
FSurfaceHeight: Integer;
FSurfaceWidth: Integer;
{$IFDEF D3DRM}FViewport: IDirect3DRMViewport; {$ENDIF}
FViewport: IDirect3DRMViewport;
FZBuffer: TDirectDrawSurface;
procedure Finalize;
procedure Initialize;
1216,7 → 572,7
function GetSurfaceWidth: Integer;
procedure SetAutoSize(Value: Boolean);
procedure SetDXDraw(Value: TCustomDXDraw);
procedure SetOptions(Value: TDX3DOptions); virtual; {TridenT}
procedure SetOptions(Value: TDX3DOptions);
procedure SetSurfaceHeight(Value: Integer);
procedure SetSurfaceWidth(Value: Integer);
protected
1229,19 → 585,16
procedure Render;
procedure SetSize(ASurfaceWidth, ASurfaceHeight: Integer);
property AutoSize: Boolean read FAutoSize write SetAutoSize;
{$IFDEF D3DRM}property Camera: IDirect3DRMFrame read FCamera; {$ENDIF}
property Camera: IDirect3DRMFrame read FCamera;
property CanDraw: Boolean read GetCanDraw;
property D3D: IDirect3D read FD3D;
property D3D2: IDirect3D2 read FD3D2;
property D3D3: IDirect3D3 read FD3D3;
property D3D7: IDirect3D7 read FD3D7;
{$IFDEF D3D_deprecated}
property D3DDevice: IDirect3DDevice read FD3DDevice;
property D3DDevice2: IDirect3DDevice2 read FD3DDevice2;
property D3DDevice3: IDirect3DDevice3 read FD3DDevice3;
{$ENDIF}
property D3DDevice7: IDirect3DDevice7 read FD3DDevice7;
{$IFDEF D3DRM}
property D3DRM: IDirect3DRM read FD3DRM;
property D3DRM2: IDirect3DRM2 read FD3DRM2;
property D3DRM3: IDirect3DRM3 read FD3DRM3;
1248,7 → 601,6
property D3DRMDevice: IDirect3DRMDevice read FD3DRMDevice;
property D3DRMDevice2: IDirect3DRMDevice2 read FD3DRMDevice2;
property D3DRMDevice3: IDirect3DRMDevice3 read FD3DRMDevice3;
{$ENDIF}
property DXDraw: TCustomDXDraw read FDXDraw write SetDXDraw;
property Initialized: Boolean read FInitialized;
property NowOptions: TDX3DOptions read FNowOptions;
1255,11 → 607,11
property OnFinalize: TNotifyEvent read FOnFinalize write FOnFinalize;
property OnInitialize: TNotifyEvent read FOnInitialize write FOnInitialize;
property Options: TDX3DOptions read FOptions write SetOptions;
{$IFDEF D3DRM}property Scene: IDirect3DRMFrame read FScene; {$ENDIF}
property Scene: IDirect3DRMFrame read FScene;
property Surface: TDirectDrawSurface read FSurface;
property SurfaceHeight: Integer read GetSurfaceHeight write SetSurfaceHeight default 480;
property SurfaceWidth: Integer read GetSurfaceWidth write SetSurfaceWidth default 640;
{$IFDEF D3DRM}property Viewport: IDirect3DRMViewport read FViewport; {$ENDIF}
property Viewport: IDirect3DRMViewport read FViewport;
property ZBuffer: TDirectDrawSurface read FZBuffer;
end;
 
1275,7 → 627,6
property OnFinalize;
property OnInitialize;
end;
{$ENDIF}
 
{ EDirect3DTextureError }
 
1293,13 → 644,13
FHandle: TD3DTextureHandle;
FPaletteEntries: TPaletteEntries;
FSurface: TDirectDrawSurface;
FTexture: {$IFDEF D3D_deprecated}IDirect3DTexture{$ELSE}IDirect3DTexture2{$ENDIF};
FTexture: IDirect3DTexture;
FTransparentColor: TColor;
procedure Clear;
procedure DXDrawNotifyEvent(Sender: TCustomDXDraw; NotifyType: TDXDrawNotifyType);
function GetHandle: TD3DTextureHandle;
function GetSurface: TDirectDrawSurface;
function GetTexture: {$IFDEF D3D_deprecated}IDirect3DTexture{$ELSE}IDirect3DTexture2{$ENDIF};
function GetTexture: IDirect3DTexture;
procedure SetTransparentColor(Value: TColor);
public
constructor Create(Graphic: TGraphic; DXDraw: TComponent);
1308,133 → 659,9
property Handle: TD3DTextureHandle read GetHandle;
property Surface: TDirectDrawSurface read GetSurface;
property TransparentColor: TColor read FTransparentColor write SetTransparentColor;
property Texture: {$IFDEF D3D_deprecated}IDirect3DTexture{$ELSE}IDirect3DTexture2{$ENDIF} read GetTexture;
property Texture: IDirect3DTexture read GetTexture;
end;
 
{ EDXTextureImageError }
 
EDXTextureImageError = class(Exception);
 
{ channel structure }
 
TDXTextureImageChannel = record
Mask: DWORD;
BitCount: Integer;
 
{ Internal use }
_Mask2: DWORD;
_rshift: Integer;
_lshift: Integer;
_BitCount2: Integer;
end;
 
TDXTextureImage_PaletteEntries = array[0..255] of TPaletteEntry;
 
TDXTextureImageType = (
DXTextureImageType_PaletteIndexedColor,
DXTextureImageType_RGBColor
);
 
TDXTextureImageFileCompressType = (
DXTextureImageFileCompressType_None,
DXTextureImageFileCompressType_ZLIB
);
 
{forward}
 
TDXTextureImage = class;
 
{ TDXTextureImageLoadFunc }
 
TDXTextureImageLoadFunc = procedure(Stream: TStream; Image: TDXTextureImage);
 
{ TDXTextureImageProgressEvent }
 
TDXTextureImageProgressEvent = procedure(Sender: TObject; Progress, ProgressCount: Integer) of object;
 
{ TDXTextureImage }
 
TDXTextureImage = class
private
FOwner: TDXTextureImage;
FFileCompressType: TDXTextureImageFileCompressType;
FOnSaveProgress: TDXTextureImageProgressEvent;
FSubImage: TList;
FImageType: TDXTextureImageType;
FWidth: Integer;
FHeight: Integer;
FPBits: Pointer;
FBitCount: Integer;
FPackedPixelOrder: Boolean;
FWidthBytes: Integer;
FNextLine: Integer;
FSize: Integer;
FTopPBits: Pointer;
FTransparent: Boolean;
FTransparentColor: DWORD;
FImageGroupType: DWORD;
FImageID: DWORD;
FImageName: string;
FAutoFreeImage: Boolean;
procedure ClearImage;
function GetPixel(x, y: Integer): DWORD;
procedure SetPixel(x, y: Integer; c: DWORD);
function GetScanLine(y: Integer): Pointer;
function GetSubGroupImageCount(GroupTypeID: DWORD): Integer;
function GetSubGroupImage(GroupTypeID: DWORD; Index: Integer): TDXTextureImage;
function GetSubImageCount: Integer;
function GetSubImage(Index: Integer): TDXTextureImage;
protected
procedure DoSaveProgress(Progress, ProgressCount: Integer); virtual;
public
idx_index: TDXTextureImageChannel;
idx_alpha: TDXTextureImageChannel;
idx_palette: TDXTextureImage_PaletteEntries;
rgb_red: TDXTextureImageChannel;
rgb_green: TDXTextureImageChannel;
rgb_blue: TDXTextureImageChannel;
rgb_alpha: TDXTextureImageChannel;
constructor Create;
constructor CreateSub(AOwner: TDXTextureImage);
destructor Destroy; override;
procedure Assign(Source: TDXTextureImage);
procedure Clear;
procedure SetImage(ImageType: TDXTextureImageType; Width, Height, BitCount, WidthBytes, NextLine: Integer;
PBits, TopPBits: Pointer; Size: Integer; AutoFree: Boolean);
procedure SetSize(ImageType: TDXTextureImageType; Width, Height, BitCount, WidthBytes: Integer);
procedure LoadFromFile(const FileName: string);
procedure LoadFromStream(Stream: TStream);
procedure SaveToFile(const FileName: string);
procedure SaveToStream(Stream: TStream);
function EncodeColor(R, G, B, A: Byte): DWORD;
function PaletteIndex(R, G, B: Byte): DWORD;
class procedure RegisterLoadFunc(LoadFunc: TDXTextureImageLoadFunc);
class procedure UnRegisterLoadFunc(LoadFunc: TDXTextureImageLoadFunc);
property BitCount: Integer read FBitCount;
property PackedPixelOrder: Boolean read FPackedPixelOrder write FPackedPixelOrder;
property Height: Integer read FHeight;
property ImageType: TDXTextureImageType read FImageType;
property ImageGroupType: DWORD read FImageGroupType write FImageGroupType;
property ImageID: DWORD read FImageID write FImageID;
property ImageName: string read FImageName write FImageName;
property NextLine: Integer read FNextLine;
property PBits: Pointer read FPBits;
property Pixels[x, y: Integer]: DWORD read GetPixel write SetPixel;
property ScanLine[y: Integer]: Pointer read GetScanLine;
property Size: Integer read FSize;
property SubGroupImageCount[GroupTypeID: DWORD]: Integer read GetSubGroupImageCount;
property SubGroupImages[GroupTypeID: DWORD; Index: Integer]: TDXTextureImage read GetSubGroupImage;
property SubImageCount: Integer read GetSubImageCount;
property SubImages[Index: Integer]: TDXTextureImage read GetSubImage;
property TopPBits: Pointer read FTopPBits;
property Transparent: Boolean read FTransparent write FTransparent;
property TransparentColor: DWORD read FTransparentColor write FTransparentColor;
property Width: Integer read FWidth;
property WidthBytes: Integer read FWidthBytes;
property FileCompressType: TDXTextureImageFileCompressType read FFileCompressType write FFileCompressType;
property OnSaveProgress: TDXTextureImageProgressEvent read FOnSaveProgress write FOnSaveProgress;
end;
 
{ TDirect3DTexture2 }
 
TDirect3DTexture2 = class
1457,20 → 684,18
FD3DDevDesc: TD3DDeviceDesc;
procedure DXDrawNotifyEvent(Sender: TCustomDXDraw; NotifyType: TDXDrawNotifyType);
procedure SetDXDraw(ADXDraw: TCustomDXDraw);
procedure LoadSubTexture(Dest: {$IFDEF D3D_deprecated}IDirectDrawSurface4{$ELSE}IDirectDrawSurface7{$ENDIF}; SrcImage: TDXTextureImage);
procedure LoadSubTexture(Dest: IDirectDrawSurface4; SrcImage: TDXTextureImage);
procedure SetColorKey;
procedure SetDIB(DIB: TDIB);
function GetIsMipmap: Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function GetSurface: TDirectDrawSurface; {$IFDEF VER9UP}inline;{$ENDIF}
function GetTransparent: Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
procedure SetTransparent(Value: Boolean); {$IFDEF VER9UP}inline;{$ENDIF}
procedure SetTransparentColor(Value: TColorRef); {$IFDEF VER9UP}inline;{$ENDIF}
function GetHeight: Integer;
function GetWidth: Integer;
function GetIsMipmap: Boolean;
function GetSurface: TDirectDrawSurface;
function GetTransparent: Boolean;
procedure SetTransparent(Value: Boolean);
procedure SetTransparentColor(Value: TColorRef);
protected
procedure DoRestoreSurface; virtual;
public
constructor Create(ADXDraw: TCustomDXDraw; Graphic: TObject; AutoFreeGraphic: Boolean{$IFDEF VER4UP} = False{$ENDIF});
constructor Create(ADXDraw: TCustomDXDraw; Graphic: TObject; AutoFreeGraphic: Boolean);
constructor CreateFromFile(ADXDraw: TCustomDXDraw; const FileName: string);
constructor CreateVideoTexture(ADXDraw: TCustomDXDraw);
destructor Destroy; override;
1477,8 → 702,6
procedure Finalize;
procedure Load;
procedure Initialize;
property Height: Integer read GetHeight;
property Width: Integer read GetWidth;
property IsMipmap: Boolean read GetIsMipmap;
property Surface: TDirectDrawSurface read GetSurface;
property TextureFormat: TDDSurfaceDesc2 read FTextureFormat write FTextureFormat;
1487,103 → 710,6
property OnRestoreSurface: TNotifyEvent read FOnRestoreSurface write FOnRestoreSurface;
end;
 
{ EDXTBaseError }
 
EDXTBaseError = class(Exception);
 
{ parameters for DXT generator }
 
TDXTImageChannel = (rgbNone, rgbRed, rgbGreen, rgbBlue, rgbAlpha, yuvY);
TDXTImageChannels = set of TDXTImageChannel;
 
TDXTImageChannelInfo = packed record
Image: TDXTextureImage;
BitCount: Integer;
end;
 
TDXTImageFormat = packed record
ImageType: TDXTextureImageType;
Width: Integer;
Height: Integer;
Bits: Pointer;
BitCount: Integer;
WidthBytes: Integer;
{transparent}
Transparent: Boolean;
TransparentColor: TColorRef;
{texture channels}
idx_index: TDXTextureImageChannel;
idx_alpha: TDXTextureImageChannel;
idx_palette: TDXTextureImage_PaletteEntries;
rgb_red: TDXTextureImageChannel;
rgb_green: TDXTextureImageChannel;
rgb_blue: TDXTextureImageChannel;
rgb_alpha: TDXTextureImageChannel;
{compress level}
Compress: TDXTextureImageFileCompressType;
MipmapCount: Integer;
Name: string;
end;
 
{ TDXTBase }
 
{Note JB.}
{Class for DXT generation files, primary use for load bitmap 32 with alphachannel}
{recoded and class created by JB.}
TDXTBase = class
private
FHasChannels: TDXTImageChannels;
FHasChannelImages: array[TDXTImageChannel] of TDXTImageChannelInfo;
FChannelChangeTable: array[TDXTImageChannel] of TDXTImageChannel;
FHasImageList: TList;
FParamsFormat: TDXTImageFormat;
FStrImageFileName: string;
FDIB: TDIB;
function GetCompression: TDXTextureImageFileCompressType;
function GetHeight: Integer;
function GetMipmap: Integer;
function GetTransparentColor: TColorRef;
function GetWidth: Integer;
procedure SetCompression(const Value: TDXTextureImageFileCompressType);
procedure SetHeight(const Value: Integer);
procedure SetMipmap(const Value: Integer);
procedure SetTransparentColor(const Value: TColorRef);
procedure SetWidth(const Value: Integer);
procedure SetTransparentColorIndexed(const Value: TColorRef);
function GetTexture: TDXTextureImage;
procedure Resize(Image: TDXTextureImage; NewWidth, NewHeight: Integer;
FilterTypeResample: TFilterTypeResample);
procedure EvaluateChannels(const CheckChannelUsed: TDXTImageChannels;
const CheckChannelChanged, CheckBitCountForChannel: string);
function GetPicture: TDXTextureImage;
protected
procedure CalcOutputBitFormat;
procedure BuildImage(Image: TDXTextureImage);
public
constructor Create;
destructor Destroy; override;
procedure SetChannelR(T: TDIB);
procedure SetChannelG(T: TDIB);
procedure SetChannelB(T: TDIB);
procedure SetChannelA(T: TDIB);
procedure LoadChannelAFromFile(const FileName: string);
procedure SetChannelY(T: TDIB);
procedure SetChannelRGB(T: TDIB);
procedure LoadChannelRGBFromFile(const FileName: string);
procedure SetChannelRGBA(T: TDIB);
procedure LoadChannelRGBAFromFile(const FileName: string);
procedure SaveToFile(iFilename: string {$IFDEF VER4UP} = ''{$ENDIF});
function LoadFromFile(iFilename: string): Boolean;
property TransparentColor: TColorRef read GetTransparentColor write SetTransparentColor;
property TransparentColorIndexed: TColorRef read GetTransparentColor write SetTransparentColorIndexed;
property Width: Integer read GetWidth write SetWidth;
property Height: Integer read GetHeight write SetHeight;
property Compression: TDXTextureImageFileCompressType read GetCompression write SetCompression;
property Mipmap: Integer read GetMipmap write SetMipmap;
property Texture: TDXTextureImage read GetTexture;
end;
 
{$IFDEF D3DRM}
{ EDirect3DRMUserVisualError }
 
EDirect3DRMUserVisualError = class(Exception);
1601,7 → 727,6
destructor Destroy; override;
property UserVisual: IDirect3DRMUserVisual read FUserVisual;
end;
{$ENDIF}
 
{ EPictureCollectionError }
 
1631,7 → 756,7
function GetPictureCollection: TPictureCollection;
function GetPatternRect(Index: Integer): TRect;
function GetPatternSurface(Index: Integer): TDirectDrawSurface;
function GetPatternCount: Integer; {$IFDEF VER9UP}inline;{$ENDIF}
function GetPatternCount: Integer;
function GetWidth: Integer;
procedure SetPicture(Value: TPicture);
procedure SetTransparentColor(Value: TColor);
1638,82 → 763,34
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure UpdateTag;
procedure Assign(Source: TPersistent); override;
procedure Draw(Dest: TDirectDrawSurface; X, Y: Integer; PatternIndex: Integer);
// Modifier par MKost d'Uk@Team tous droit réservé.
// 22:02 04/11/2005
// Ajouté :
// Dans TPictureCollectionItem
// procedure DrawFlipH(Dest: TDirectDrawSurface; X, Y: Integer; PatternIndex: Integer);
// -Effectue un flip Horizontale de l'image
// procedure DrawFlipHV(Dest: TDirectDrawSurface; X, Y: Integer; PatternIndex: Integer);
// -Effectue un flip Oblique de l'image
// procedure DrawFlipV(Dest: TDirectDrawSurface; X, Y: Integer; PatternIndex: Integer);
// -Effectue un flip Verticale de l'image
procedure DrawFlipH(Dest: TDirectDrawSurface; X, Y: Integer; PatternIndex: Integer);
procedure DrawFlipHV(Dest: TDirectDrawSurface; X, Y: Integer; PatternIndex: Integer);
procedure DrawFlipV(Dest: TDirectDrawSurface; X, Y: Integer; PatternIndex: Integer);
procedure StretchDraw(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer);
procedure DrawAdd(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawAddCol(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Color: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawAlpha(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawAlphaCol(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Color: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
Alpha: Integer);
procedure DrawSub(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawSubCol(Dest: TDirectDrawSurface; const DestRect: TRect;
PatternIndex, Color: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
{Rotate}
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawRotate(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single);
CenterX, CenterY: Double; Angle: Integer);
procedure DrawRotateAdd(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawRotateAddCol(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single;
Color: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
CenterX, CenterY: Double; Angle: Integer;
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawRotateAlpha(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawRotateAlphaCol(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single;
Color: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
CenterX, CenterY: Double; Angle: Integer;
Alpha: Integer);
procedure DrawRotateSub(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single;
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawRotateSubCol(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single;
Color: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
{WaveX}
CenterX, CenterY: Double; Angle: Integer;
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawWaveX(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
amp, Len, ph: Integer);
procedure DrawWaveXAdd(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
amp, Len, ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
amp, Len, ph: Integer; Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawWaveXAlpha(Dest: TDirectDrawSurface; X, Y, Width, Height, PatternIndex: Integer;
amp, Len, ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
amp, Len, ph: Integer; Alpha: Integer);
procedure DrawWaveXSub(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
amp, Len, ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
{WaveY}
procedure DrawWaveY(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
amp, Len, ph: Integer);
procedure DrawWaveYAdd(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
amp, Len, ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawWaveYAlpha(Dest: TDirectDrawSurface; X, Y, Width, Height, PatternIndex: Integer;
amp, Len, ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawWaveYSub(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
amp, Len, ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
{SpecialDraw}
procedure DrawCol(Dest: TDirectDrawSurface; const DestRect, SourceRect: TRect;
PatternIndex: Integer; Faded: Boolean; RenderType: TRenderType; Color,
Specular: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
procedure DrawRect(Dest: TDirectDrawSurface;
const DestRect, SourceRect: TRect; PatternIndex: Integer;
RenderType: TRenderType; Transparent: Boolean{$IFDEF VER4UP} = True{$ENDIF};
Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF});
amp, Len, ph: Integer; Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure Restore;
property Height: Integer read GetHeight;
property Initialized: Boolean read FInitialized;
1753,7 → 830,6
function Find(const Name: string): TPictureCollectionItem;
procedure Finalize;
procedure Initialize(DXDraw: TCustomDXDraw);
procedure InitializeImages(DXDraw: TCustomDXDraw; Id : Integer);
procedure LoadFromFile(const FileName: string);
procedure LoadFromStream(Stream: TStream);
procedure MakeColorTable;
1815,7 → 891,7
constructor CreateWindowed(WindowHandle: HWND);
destructor Destroy; override;
procedure Finalize;
procedure Initialize(const SurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF});
procedure Initialize(const SurfaceDesc: TDDSurfaceDesc);
procedure Flip;
property OverlayColorKey: TColor read FOverlayColorKey write SetOverlayColorKey;
property OverlayRect: TRect read FOverlayRect write SetOverlayRect;
1824,542 → 900,27
property Visible: Boolean read FVisible write SetVisible;
end;
 
{
Modified by Michael Wilson 2/05/2001
- re-added redundant assignment to Offset
Modified by Marcus Knight 19/12/2000
- replaces all referaces to 'pos' with 'AnsiPos' <- faster
- replaces all referaces to 'uppercase' with 'Ansiuppercase' <- faster
- Now only uppercases outside the loop
- Fixed the non-virtual contructor
- renamed & moved Offset to private(fOffSet), and added the property OffSet
- Commented out the redundant assignment to Offset<- not needed, as Offset is now a readonly property
- Added the Notification method to catch when the image list is destroyed
- removed DXclasses from used list
}
 
TDXFont = class(TComponent)
private
FDXImageList: TDXImageList;
FFont: string;
FFontIndex: Integer;
FOffset: Integer; // renamed from Offset -> fOffset
procedure SetFont(const Value: string);
procedure SetFontIndex(const Value: Integer);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override; // added
public
constructor Create(AOwner: TComponent); override; // Modified
destructor Destroy; override;
procedure TextOut(DirectDrawSurface: TDirectDrawSurface; X, Y: Integer; const Text: string);
property Offset: Integer read FOffset write FOffset; // added
published
property Font: string read FFont write SetFont;
property FontIndex: Integer read FFontIndex write SetFontIndex;
property DXImageList: TDXImageList read FDXImageList write FDXImageList;
end;
 
(*******************************************************************************
* Unit Name: DXPowerFont.pas
* Information: Writed By Ramin.S.Zaghi (Based On Wilson's DXFont Unit)
* Last Changes: Dec 25 2000;
* Unit Information:
* This unit includes a VCL-Component for DelphiX. This component draws the
* Character-Strings on a TDirectDrawSurface. This component helps the
* progarmmers to using custom fonts and printing texts easily such as
* TCanvas.TextOut function...
* Includes:
* 1. TDXPowerFontTextOutEffect ==> The kinds of drawing effects.
* - teNormal: Uses the Draw function. (Normal output)
* - teRotat: Uses the DrawRotate function. (Rotates each character)
* - teAlphaBlend: Uses DrawAlpha function. (Blends each character)
* - teWaveX: Uses DrawWaveX function. (Adds a Wave effect to the each character)
*
* 2. TDXPowerFontTextOutType ==> The kinds of each caracter.
* - ttUpperCase: Uppers all characters automaticaly.
* - ttLowerCase: Lowers all characters automaticaly.
* - ttNormal: Uses all characters with out any converting.
*
* 3. TDXPowerFontEffectsParameters ==> Includes the parameters for adding effects to the characters.
* - (CenterX, CenterY): The rotating center point.
* - (Width, Height): The new size of each character.
* - Angle: The angle of rotate.
* - AlphaValue: The value of Alpha-Chanel.
* - WAmplitude: The Amplitude of Wave function. (See The Help Of DelphiX)
* - WLenght: The Lenght Of Wave function. (See The Help Of DelphiX)
* - WPhase: The Phase Of Wave function. (See The Help Of DelphiX)
*
* 4. TDXPowerFontBeforeTextOutEvent ==> This is an event that occures before
* drawing texts on to TDirectDrawSurface object.
* - Sender: Retrieves the event caller object.
* - Text: Retrieves the text sended text for drawing.
* (NOTE: The changes will have effect)
* - DoTextOut: The False value means that the TextOut function must be stopped.
* (NOTE: The changes will have effect)
*
* 5. TDXPowerFontAfterTextOutEvent ==> This is an event that occures after
* drawing texts on to TDirectDrawSurface object.
* - Sender: Retrieves the event caller object.
* - Text: Retrieves the text sended text for drawing.
* (NOTE: The changes will not have any effects)
*
* 6. TDXPowerFont ==> I sthe main class of PowerFont VCL-Component.
* - property Font: string; The name of custom-font's image in the TDXImageList items.
* - property FontIndex: Integer; The index of custom-font's image in the TDXImageList items.
* - property DXImageList: TDXImageList; The TDXImageList that includes the image of custom-fonts.
* - property UseEnterChar: Boolean; When the value of this property is True, The component caculates Enter character.
* - property EnterCharacter: String;
*==> Note that TDXPowerFont calculates tow kinds of enter character:
*==> E1. The Enter character that draws the characters after it self in a new line and after last drawed character, ONLY.
*==> E2. The Enter character that draws the characters after it self in a new line such as #13#10 enter code in delphi.
*==> Imporatant::
*==> (E1) TDXPowerFont uses the first caracter of EnterCharacter string as the first enter caracter (Default value is '|').
*==> (E2) and uses the second character as the scond enter caracter (Default value is '<')
* - property BeforeTextOut: TDXPowerFontBeforeTextOutEvent; See TDXPowerFontBeforeTextOutEvent.
* - property AfterTextOut: TDXPowerFontAfterTextOutEvent; See TDXPowerFontAfterTextOutEvent.
* - property Alphabets: string; TDXPowerFont uses this character-string for retrieving the pattern number of each character.
* - property TextOutType: TDXPowerFontTextOutType; See TDXPowerFontTextOutType.
* - property TextOutEffect: TDXPowerFontTextOutEffect; See TDXPowerFontTextOutEffect.
* - property EffectsParameters: TDXPowerFontEffectsParameters; See TDXPowerFontEffectsParameters.
*
* - function TextOut(DirectDrawSurface: TDirectDrawSurface; X, Y: Integer; const Text: string): Boolean;
* This function draws/prints the given text on the given TDirectDrawSurface.
* - DirectDrawSurface: The surface for drawing text (character-string).
* - (X , Y): The first point of outputed text. (Such as X,Y parameters in TCanvas.TextOut function)
* - Text: The text for printing.
* Return values: This function returns False when an error occured or...
* - function TextOutFast(DirectDrawSurface: TDirectDrawSurface; X, Y: Integer; const Text: string): Boolean;
* This function works such as TextOut function but,
* with out calculating any Parameters/Effects/Enter-Characters/etc...
* This function calculates the TextOutType, ONLY.
*
* Ramin.S.Zaghi (ramin_zaghi@yahoo.com)
* (Based on wilson's code for TDXFont VCL-Component/Add-On)
* (wilson@no2games.com)
*
* For more information visit:
* www.no2games.com
* turbo.gamedev.net
******************************************************************************)
 
{ DXPowerFont types }
 
TDXPowerFontTextOutEffect = (teNormal, teRotat, teAlphaBlend, teWaveX);
TDXPowerFontTextOutType = (ttUpperCase, ttLowerCase, ttNormal);
TDXPowerFontBeforeTextOutEvent = procedure(Sender: TObject; var Text: string; var DoTextOut: Boolean) of object;
TDXPowerFontAfterTextOutEvent = procedure(Sender: TObject; Text: string) of object;
 
{ TDXPowerFontEffectsParameters }
 
TDXPowerFontEffectsParameters = class(TPersistent)
private
FCenterX: Integer;
FCenterY: Integer;
FHeight: Integer;
FWidth: Integer;
FAngle: Integer;
FAlphaValue: Integer;
FWPhase: Integer;
FWAmplitude: Integer;
FWLenght: Integer;
procedure SetAngle(const Value: Integer);
procedure SetCenterX(const Value: Integer);
procedure SetCenterY(const Value: Integer);
procedure SetHeight(const Value: Integer);
procedure SetWidth(const Value: Integer);
procedure SetAlphaValue(const Value: Integer);
procedure SetWAmplitude(const Value: Integer);
procedure SetWLenght(const Value: Integer);
procedure SetWPhase(const Value: Integer);
published
property CenterX: Integer read FCenterX write SetCenterX;
property CenterY: Integer read FCenterY write SetCenterY;
property Width: Integer read FWidth write SetWidth;
property Height: Integer read FHeight write SetHeight;
property Angle: Integer read FAngle write SetAngle;
property AlphaValue: Integer read FAlphaValue write SetAlphaValue;
property WAmplitude: Integer read FWAmplitude write SetWAmplitude;
property WLenght: Integer read FWLenght write SetWLenght;
property WPhase: Integer read FWPhase write SetWPhase;
end;
 
{ TDXPowerFont }
 
TDXPowerFont = class(TComponent)
private
FDXImageList: TDXImageList;
FFont: string;
FFontIndex: Integer;
FUseEnterChar: Boolean;
FEnterCharacter: string;
FAfterTextOut: TDXPowerFontAfterTextOutEvent;
FBeforeTextOut: TDXPowerFontBeforeTextOutEvent;
FAlphabets: string;
FTextOutType: TDXPowerFontTextOutType;
FTextOutEffect: TDXPowerFontTextOutEffect;
FEffectsParameters: TDXPowerFontEffectsParameters;
procedure SetFont(const Value: string);
procedure SetFontIndex(const Value: Integer);
procedure SetUseEnterChar(const Value: Boolean);
procedure SetEnterCharacter(const Value: string);
procedure SetAlphabets(const Value: string);
procedure SetTextOutType(const Value: TDXPowerFontTextOutType);
procedure SetTextOutEffect(const Value: TDXPowerFontTextOutEffect);
procedure SetEffectsParameters(const Value: TDXPowerFontEffectsParameters);
published
property Font: string read FFont write SetFont;
property FontIndex: Integer read FFontIndex write SetFontIndex;
property DXImageList: TDXImageList read FDXImageList write FDXImageList;
property UseEnterChar: Boolean read FUseEnterChar write SetUseEnterChar;
property EnterCharacter: string read FEnterCharacter write SetEnterCharacter;
property BeforeTextOut: TDXPowerFontBeforeTextOutEvent read FBeforeTextOut write FBeforeTextOut;
property AfterTextOut: TDXPowerFontAfterTextOutEvent read FAfterTextOut write FAfterTextOut;
property Alphabets: string read FAlphabets write SetAlphabets;
property TextOutType: TDXPowerFontTextOutType read FTextOutType write SetTextOutType;
property TextOutEffect: TDXPowerFontTextOutEffect read FTextOutEffect write SetTextOutEffect;
property EffectsParameters: TDXPowerFontEffectsParameters read FEffectsParameters write SetEffectsParameters;
public
Offset: Integer;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function TextOut(DirectDrawSurface: TDirectDrawSurface; X, Y: Integer; const Text: string): Boolean;
function TextOutFast(DirectDrawSurface: TDirectDrawSurface; X, Y: Integer; const Text: string): Boolean;
end;
 
{D2D unit for pure HW support
* Copyright (c) 2004-2010 Jaro Benes
* All Rights Reserved
* Version 1.09
* D2D Hardware module - interface part
* web site: www.micrel.cz/Dx
* e-mail: delphix_d2d@micrel.cz
}
 
{supported texture vertex as substitute type from DirectX}
 
{TD2D4Vertex - used with D2DTexturedOn}
 
TD2D4Vertex = array[0..3] of TD3DTLVERTEX;
 
{TD2DTextures - texture storage used with Direct3D}
TTextureRec = packed record
{$IFDEF VIDEOTEX}
VDIB: TDIB;
{$ENDIF}
D2DTexture: TDirect3DTexture2;
FloatX1, FloatY1, FloatX2, FloatY2: Double; //uschov vyrez
Name: string{$IFNDEF VER4UP} [255]{$ENDIF}; //jmeno obrazku pro snadne dohledani
Width, Height: Integer;
AlphaChannel: Boolean; //.06c
end;
PTextureRec = ^TTextureRec;
TTextureArr = array{$IFNDEF VER4UP} [0..0]{$ENDIF} of TTextureRec;
{$IFNDEF VER4UP}
PTextureArr = ^TTextureArr;
EMaxTexturesError = class(Exception);
{$ENDIF}
TD2DTextures = class
private
FDDraw: TCustomDXDraw;
{$IFNDEF VER4UP}
TexLen: Integer;
Texture: PTextureArr;
{$ELSE}
Texture: TTextureArr;
{$ENDIF}
function GetD2DMaxTextures: Integer;
procedure SetD2DMaxTextures(const Value: Integer);
procedure D2DPruneTextures;
procedure D2DPruneAllTextures;
procedure SizeAdjust(var DIB: TDIB; var FloatX1, FloatY1, FloatX2,
FloatY2: Double);
function SetTransparentColor(dds: TDirectDrawSurface; PixelColor: Integer;
Transparent: Boolean): Integer;
{$IFDEF VIDEOTEX}
function GetTexLayoutByName(name: string): TDIB;
{$ENDIF}
procedure SaveTextures(path: string);
public
constructor Create(DDraw: TCustomDXDraw);
destructor Destroy; override;
procedure D2DFreeTextures;
function Find(byName: string): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
function GetTextureByName(const byName: string): TDirect3DTexture2;
function GetTextureByIndex(const byIndex: Integer): TDirect3DTexture2;
function GetTextureNameByIndex(const byIndex: Integer): string;
function Count: Integer;
{functions support loading image or DDS}
{$IFDEF VER4UP}
function CanFindTexture(aImage: TPictureCollectionItem): Boolean; overload; {$IFDEF VER9UP}inline;{$ENDIF}
function CanFindTexture(const TexName: string): Boolean; overload; {$IFDEF VER9UP}inline;{$ENDIF}
function CanFindTexture(const Color: LongInt): Boolean; overload;{$IFDEF VER9UP}inline;{$ENDIF}
function LoadTextures(aImage: TPictureCollectionItem): Boolean; overload; {$IFDEF VER9UP}inline;{$ENDIF}
function LoadTextures(dds: TDirectDrawSurface; Transparent: Boolean; asTexName: string): Boolean; overload;
function LoadTextures(dds: TDirectDrawSurface; Transparent: Boolean; TransparentColor: Integer; asTexName: string): Boolean; overload;
function LoadTextures(Color: Integer): Boolean; overload;
{$ELSE}
function CanFindTexture(aImage: TPictureCollectionItem): Boolean;
function CanFindTexture2(const TexName: string): Boolean;
function CanFindTexture3(const Color: LongInt): Boolean;
function LoadTextures(aImage: TPictureCollectionItem): Boolean;
function LoadTextures2(dds: TDirectDrawSurface; Transparent: Boolean; asTexName: string): Boolean;
function LoadTextures3(dds: TDirectDrawSurface; Transparent: Boolean; TransparentColor: Integer; asTexName: string): Boolean;
function LoadTextures4(Color: Integer): Boolean;
{$ENDIF}
{$IFDEF VIDEOTEX}
property TexLayoutByName[name: string]: TDIB read GetTexLayoutByName;
{$ENDIF}
//published
property D2DMaxTextures: Integer read GetD2DMaxTextures write SetD2DMaxTextures;
end;
 
{Main component for HW support}
 
TD2D = class
private
FDDraw: TCustomDXDraw;
FCanUseD2D: Boolean;
FBitCount: Integer;
FMirrorFlipSet: TRenderMirrorFlipSet;
FD2DTextureFilter: TD2DTextureFilter;
FD2DAntialiasFilter: TD3DAntialiasMode;
FVertex: TD2D4Vertex;
FD2DTexture: TD2DTextures;
FDIB: TDIB;
FD3DDevDesc7: TD3DDeviceDesc7;
FInitialized: Boolean;
{ukazuje pocet textur}
procedure D2DUpdateTextures; {$IFDEF VER9UP}inline;{$ENDIF}
 
procedure SetCanUseD2D(const Value: Boolean);
function GetCanUseD2D: Boolean;
{create the component}
constructor Create(DDraw: TCustomDXDraw);
procedure SetD2DTextureFilter(const Value: TD2DTextureFilter);
procedure SetD2DAntialiasFilter(const Value: TD3DAntialiasMode);
procedure D2DEffectSolid; {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DEffectAdd; {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DEffectSub; {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DEffectBlend; {$IFDEF VER9UP}inline;{$ENDIF}// used with alpha
 
{verticies}
procedure InitVertex; {$IFDEF VER9UP}inline;{$ENDIF}
function D2DWhite: Integer; {$IFDEF VER9UP}inline;{$ENDIF}
function D2DVertColor(RenderType: TRenderType; Alpha: Byte): DWORD; {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DColoredVertex(C: Integer); {$IFDEF VER9UP}inline;{$ENDIF}
function D2DAlphaVertex(Alpha: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DSpecularVertex(C: Integer); {$IFDEF VER9UP}inline;{$ENDIF}
{Fade used with Add and Sub}
function D2DFade(Alpha: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DFadeColored(C, Alpha: Integer); {$IFDEF VER9UP}inline;{$ENDIF}
 
function RenderQuad: Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
procedure D2DRect(R: TRect); {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DTU(T: TTextureRec); {$IFDEF VER9UP}inline;{$ENDIF}
{low lever version texturing for DDS}
function D2DTexturedOnDDSTex(dds: TDirectDrawSurface; SubPatternRect: TRect;
Transparent: Boolean): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
{texturing}
function D2DTexturedOn(Image: TPictureCollectionItem; Pattern: Integer; SubPatternRect: TRect; RenderType: TRenderType; Alpha: Byte): Boolean;
function D2DTexturedOnDDS(dds: TDirectDrawSurface; SubPatternRect: TRect; Transparent: Boolean; RenderType: TRenderType; Alpha: Byte): Boolean;
function D2DTexturedOnRect(Rect: TRect; Color: Integer): Boolean;
function D2DTexturedOnSubRect(Image: TPictureCollectionItem; Pattern: Integer; SubPatternRect, SubRect: TRect; RenderType: TRenderType; Alpha: Byte): Boolean;
 
{low level for rotate mesh}
procedure D2DRotate(X, Y, W, H: Integer; Px, Py: Double; Angle: single);
{low lever routine for mesh mapping}
function D2DMeshMapToWave(dds: TDirectDrawSurface; Transparent: Boolean;
TransparentColor: Integer; X, Y, iWidth, iHeight, PatternIndex: Integer;
PatternRect: TRect;
Amp, Len, Ph, Alpha: Integer;
Effect: TRenderType; DoY: Boolean{$IFDEF VER4UP} = False{$ENDIF}): Boolean;
property D2DTextures: TD2DTextures read FD2DTexture;
public
//added to public
procedure D2DColAlpha(C, Alpha: Integer); {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DCol4Alpha(C1, C2, C3, C4, Alpha: Integer); {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DFade4Colored(C1, C2, C3, C4, Alpha: Integer); {$IFDEF VER9UP}inline;{$ENDIF}
function RenderTri: Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
procedure D2DMeshMapToRect(R: TRect);
//
{destruction textures and supported objects here}
destructor Destroy; override;
{use before starting rendering}
procedure BeginScene;
{use after all images have been rendered}
procedure EndScene;
{set directly of texture filter}
property TextureFilter: TD2DTextureFilter write SetD2DTextureFilter;
property AntialiasFilter: TD3DAntialiasMode write SetD2DAntialiasFilter;
{indicate using of this object}
property CanUseD2D: Boolean read GetCanUseD2D write SetCanUseD2D;
 
{set property mirror-flip}
property MirrorFlip: TRenderMirrorFlipSet read FMirrorFlipSet write FMirrorFlipSet;
 
{initialize surface}
function D2DInitializeSurface: Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
{Render routines}
function D2DRender(Image: TPictureCollectionItem; DestRect: TRect;
Pattern: Integer; SourceRect: TRect; RenderType: TRenderType; Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean;{$IFDEF VER4UP} overload; {$ENDIF}{$IFDEF VER9UP}inline;{$ENDIF}
 
function {$IFDEF VER4UP}D2DRender{$ELSE}D2DRender2{$ENDIF}(Image: TPictureCollectionItem; R: TRect;
Pattern: Integer; RenderType: TRenderType; Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER4UP} overload; {$ENDIF}{$IFDEF VER9UP}inline;{$ENDIF}
 
function D2DRenderDDS(Source: TDirectDrawSurface; SourceRect, DestRect: TRect; Transparent: Boolean;
Pattern: Integer; RenderType: TRenderType; Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
function D2DRenderCol(Image: TPictureCollectionItem; R: TRect;
Pattern, Color: Integer; RenderType: TRenderType; Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function D2DRenderColDDS(Source: TDirectDrawSurface; SourceRect, DestRect: TRect;
Transparent: Boolean; Pattern, Color: Integer; RenderType:
TRenderType; Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
function D2DRenderDrawDDSXY(Source: TDirectDrawSurface; X, Y: Integer;
Transparent: Boolean; Pattern: Integer; RenderType: TRenderType; Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean;
{$IFDEF VER4UP} overload; {$IFDEF VER9UP}inline;{$ENDIF}
function D2DRenderDrawDDSXY(Source: TDirectDrawSurface; X, Y: Integer;
SrcRect: TRect; Transparent: Boolean; Pattern: Integer; RenderType: TRenderType; Alpha: Byte{$IFDEF Ver4UP} = 255{$ENDIF}): Boolean; overload; {$IFDEF VER9UP}inline;{$ENDIF}
{$ENDIF}
function D2DRenderDrawXY(Image: TPictureCollectionItem; X, Y: Integer;
Pattern: Integer; RenderType: TRenderType; Alpha: Byte{$IFDEF VEr4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
{Rotate}
function D2DRenderRotate(Image: TPictureCollectionItem; RotX, RotY,
PictWidth, PictHeight, PatternIndex: Integer; RenderType: TRenderType;
CenterX, CenterY: Double; Angle: single; Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function D2DRenderRotateDDS(Image: TDirectDrawSurface; SourceRect: TRect; RotX, RotY,
PictWidth, PictHeight: Integer; RenderType: TRenderType;
CenterX, CenterY: Double; Angle: single; Alpha: Byte;
Transparent: Boolean): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
function D2DRenderRotateModeCol(Image: TPictureCollectionItem; RenderType: TRenderType; RotX, RotY,
PictWidth, PictHeight, PatternIndex: Integer; CenterX, CenterY: Double;
Angle: single; Color: Integer; Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function D2DRenderRotateModeColDDS(Image: TDirectDrawSurface;
RotX, RotY, PictWidth, PictHeight: Integer; RenderType: TRenderType;
CenterX, CenterY: Double; Angle: Single; Color: Integer; Alpha: Byte;
Transparent: Boolean): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
{WaveX}
function D2DRenderWaveX(Image: TPictureCollectionItem; X, Y, Width, Height,
PatternIndex: Integer; RenderType: TRenderType; Transparent: Boolean;
Amp, Len, Ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function D2DRenderWaveXDDS(Source: TDirectDrawSurface; X, Y, Width,
Height: Integer; RenderType: TRenderType; Transparent: Boolean;
Amp, Len, Ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
{WaveY}
function D2DRenderWaveY(Image: TPictureCollectionItem; X, Y, Width, Height,
PatternIndex: Integer; RenderType: TRenderType; Transparent: Boolean;
Amp, Len, Ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function D2DRenderWaveYDDS(Source: TDirectDrawSurface; X, Y, Width,
Height: Integer; RenderType: TRenderType; Transparent: Boolean;
Amp, Len, Ph: Integer; Alpha: Integer{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
{Rect}
function D2DRenderFillRect(Rect: TRect; RGBColor: LongInt;
RenderType: TRenderType; Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
{addmod}
function D2DRenderColoredPartition(Image: TPictureCollectionItem; DestRect: TRect; PatternIndex,
Color, Specular: Integer; Faded: Boolean;
SourceRect: TRect;
RenderType: TRenderType;
Alpha: Byte{$IFDEF VER4UP} = 255{$ENDIF}): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
 
procedure SaveTextures(path: string);
end;
 
{ Support functions for texturing }
function dxtMakeChannel(Mask: DWORD; indexed: Boolean): TDXTextureImageChannel;
function dxtEncodeChannel(const Channel: TDXTextureImageChannel; c: DWORD): DWORD;
function dxtDecodeChannel(const Channel: TDXTextureImageChannel; c: DWORD): DWORD;
 
{ Single support routine for convert DIB32 to DXT in one line }
procedure dib2dxt(DIBImage: TDIB; out DXTImage: TDXTextureImage{$IFDEF DXTextureImage_UseZLIB}; const Shrink: Boolean = True{$ENDIF});
 
{ One line call drawing with attributes }
{$IFDEF VER4UP}
procedure DXDraw_Draw(DXDraw: TCustomDXDraw; Image: TPictureCollectionItem;
Rect: TRect; Pattern: Integer; TextureFilter: TD2DTextureFilter = D2D_POINT;
MirrorFlip: TRenderMirrorFlipSet = [];
BlendMode: TRenderType = rtDraw; Angle: Single = 0; Alpha: Byte = 255;
CenterX: Double = 0.5; CenterY: Double = 0.5;
Scale: Single = 1.0); {$IFDEF VER9UP}inline;{$ENDIF}
procedure DXDraw_Paint(DXDraw: TCustomDXDraw; Image: TPictureCollectionItem;
Rect: TRect; Pattern: Integer; var BlurImageArr: TBlurImageArr; BlurImage: Boolean = False;
TextureFilter: TD2DTextureFilter = D2D_POINT;
MirrorFlip: TRenderMirrorFlipSet = [];
BlendMode: TRenderType = rtDraw;
Angle: Single = 0;
Alpha: Byte = 255;
CenterX: Double = 0.5; CenterY: Double = 0.5); {$IFDEF VER9UP}inline;{$ENDIF}
procedure DXDraw_Render(DXDraw: TCustomDXDraw; Image: TPictureCollectionItem;
Rect: TRect; Pattern: Integer; var BlurImageArr: TBlurImageArr; BlurImage: Boolean = False;
TextureFilter: TD2DTextureFilter = D2D_POINT;
MirrorFlip: TRenderMirrorFlipSet = [];
BlendMode: TRenderType = rtDraw;
Angle: Single = 0;
Alpha: Byte = 255;
CenterX: Double = 0.5; CenterY: Double = 0.5;
Scale: Single = 1.0;
WaveType: TWaveType = wtWaveNone;
Amplitude: Integer = 0; AmpLength: Integer = 0; Phase: Integer = 0); {$IFDEF VER9UP}inline;{$ENDIF}
{$ELSE}
procedure DXDraw_Draw(DXDraw: TCustomDXDraw; Image: TPictureCollectionItem;
Rect: TRect; Pattern: Integer; TextureFilter: TD2DTextureFilter;
MirrorFlip: TRenderMirrorFlipSet;
BlendMode: TRenderType; Angle: Single; Alpha: Byte;
CenterX: Double; CenterY: Double;
Scale: Single);
procedure DXDraw_Paint(DXDraw: TCustomDXDraw; Image: TPictureCollectionItem;
Rect: TRect; Pattern: Integer; var BlurImageArr: TBlurImageArr; BlurImage: Boolean;
TextureFilter: TD2DTextureFilter;
MirrorFlip: TRenderMirrorFlipSet;
BlendMode: TRenderType;
Angle: Single;
Alpha: Byte;
CenterX: Double; CenterY: Double);
procedure DXDraw_Render(DXDraw: TCustomDXDraw; Image: TPictureCollectionItem;
Rect: TRect; Pattern: Integer; var BlurImageArr: TBlurImageArr; BlurImage: Boolean;
TextureFilter: TD2DTextureFilter;
MirrorFlip: TRenderMirrorFlipSet;
BlendMode: TRenderType;
Angle: Single;
Alpha: Byte;
CenterX: Double; CenterY: Double;
Scale: Single;
WaveType: TWaveType;
Amplitude: Integer; AmpLength: Integer; Phase: Integer);
{$ENDIF}
 
implementation
 
uses DXConsts{$IFDEF DXR_deprecated}, DXRender{$ENDIF}, D3DUtils;
uses DXConsts, DXRender;
 
function DXDirectDrawEnumerate(lpCallback: {$IFDEF UNICODE}TDDEnumCallbackW{$ELSE}TDDEnumCallbackA{$ENDIF};
function DXDirectDrawEnumerate(lpCallback: TDDEnumCallbackA;
lpContext: Pointer): HRESULT;
type
TDirectDrawEnumerate = function(lpCallback: {$IFDEF UNICODE}TDDEnumCallbackW{$ELSE}TDDEnumCallbackA{$ENDIF};
TDirectDrawEnumerate = function(lpCallback: TDDEnumCallbackA;
lpContext: Pointer): HRESULT; stdcall;
begin
Result := TDirectDrawEnumerate(DXLoadLibrary('DDraw.dll', {$IFDEF UNICODE}'DirectDrawEnumerateW'{$ELSE}'DirectDrawEnumerateA'{$ENDIF}))
Result := TDirectDrawEnumerate(DXLoadLibrary('DDraw.dll', 'DirectDrawEnumerateA'))
(lpCallback, lpContext);
end;
 
var
DirectDrawDrivers: TDirectXDrivers;
{$IFDEF _DMO_}DirectDrawDriversEx: TDirectXDriversEx;{$ENDIF}
D2D: TD2D = nil; {for internal use only, }
RenderError: Boolean = false;
 
function EnumDirectDrawDrivers: TDirectXDrivers;
 
function DDENUMCALLBACK(lpGuid: PGUID; lpstrDescription: {$IFDEF UNICODE}LPCTSTR{$ELSE}LPCSTR{$ENDIF};
lpstrModule: {$IFDEF UNICODE}LPCTSTR{$ELSE}LPCSTR{$ENDIF}; lpContext: Pointer): BOOL; stdcall;
function DDENUMCALLBACK(lpGuid: PGUID; lpstrDescription: LPCSTR;
lpstrModule: LPCSTR; lpContext: Pointer): BOOL; stdcall;
begin
Result := True;
with TDirectXDriver.Create(TDirectXDrivers(lpContext)) do
2385,45 → 946,6
Result := DirectDrawDrivers;
end;
 
{$IFDEF _DMO_}
function EnumDirectDrawDriversEx: TDirectXDriversEx;
 
function DDENUMCALLBACKEX(lpGuid: PGUID; lpstrDescription: {$IFDEF UNICODE}LPCTSTR{$ELSE}LPCSTR{$ENDIF};
lpDriverName: {$IFDEF UNICODE}LPCTSTR{$ELSE}LPCSTR{$ENDIF}; lpContext: Pointer; iMonitor: HMonitor): BOOL; stdcall;
var
X: TDirectXDriverEx;
begin
Result := True;
X := TDirectXDriverEx(DirectDrawDriversEx.Add);
with X do
begin
Guid := lpGuid;
Description := lpstrDescription;
Monitor := iMonitor;
DriverName := lpDriverName;
//GetPhysicalMonitorsFromHMONITOR()
end;
end;
 
//var
// DevMode: TDeviceMode;
begin
if DirectDrawDriversEx = nil then DirectDrawDriversEx := TDirectXDriversEx.Create;
if Assigned(DirectDrawDriversEx) then
begin
//FMonitors.Clear;
try
//FillChar(DevMode, SizeOf(TDeviceMode), 0);
if DirectDrawEnumerateEx(@DDENUMCALLBACKEX, nil{DeviceContext}, DDENUM_ATTACHEDSECONDARYDEVICES or DDENUM_DETACHEDSECONDARYDEVICES or DDENUM_NONDISPLAYDEVICES) = DD_OK then;
except
DirectDrawDriversEx.Free; DirectDrawDriversEx := nil;
raise;
end;
end;
Result := DirectDrawDriversEx;
end;
{$ENDIF}
 
function ClipRect(var DestRect: TRect; const DestRect2: TRect): Boolean;
begin
with DestRect do
2511,13 → 1033,11
FPalettes := TList.Create;
FSurfaces := TList.Create;
 
{$IFDEF D3D_deprecated}
if DirectX7Mode then
begin {$ENDIF}
begin
{ DirectX 7 }
if TDirectDrawCreateEx(DXLoadLibrary('DDraw.dll', 'DirectDrawCreateEx'))(GUID, FIDDraw7, IID_IDirectDraw7, nil) <> DD_OK then
raise EDirectDrawError.CreateFmt(SCannotInitialized, [SDirectDraw]);
{$IFDEF D3D_deprecated}
try
FIDDraw := FIDDraw7 as IDirectDraw;
FIDDraw4 := FIDDraw7 as IDirectDraw4;
2524,8 → 1044,7
except
raise EDirectDrawError.Create(SSinceDirectX7);
end;
{$ENDIF}
{$IFDEF D3D_deprecated}end else
end else
begin
if TDirectDrawCreate(DXLoadLibrary('DDraw.dll', 'DirectDrawCreate'))(GUID, FIDDraw, nil) <> DD_OK then
raise EDirectDrawError.CreateFmt(SCannotInitialized, [SDirectDraw]);
2534,11 → 1053,11
except
raise EDirectDrawError.Create(SSinceDirectX6);
end;
end;{$ENDIF}
end;
 
FDriverCaps.dwSize := SizeOf(FDriverCaps);
FHELCaps.dwSize := SizeOf(FHELCaps);
{$IFDEF D3D_deprecated}FIDDraw{$ELSE}FIDDraw7{$ENDIF}.GetCaps(@FDriverCaps, @FHELCaps);
FIDDraw.GetCaps(FDriverCaps, FHELCaps);
end;
 
destructor TDirectDraw.Destroy;
2563,13 → 1082,6
Result := EnumDirectDrawDrivers;
end;
 
{$IFDEF _DMO_}
class function TDirectDraw.DriversEx: TDirectXDriversEx;
begin
Result := EnumDirectDrawDriversEx;
end;
{$ENDIF}
 
function TDirectDraw.GetClipper(Index: Integer): TDirectDrawClipper;
begin
Result := FClippers[Index];
2580,14 → 1092,14
Result := FClippers.Count;
end;
 
function TDirectDraw.GetDisplayMode: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
function TDirectDraw.GetDisplayMode: TDDSurfaceDesc;
begin
Result.dwSize := SizeOf(Result);
DXResult := {$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.GetDisplayMode(Result);
DXResult := IDraw.GetDisplayMode(Result);
if DXResult <> DD_OK then
FillChar(Result, SizeOf(Result), 0);
end;
{$IFDEF D3D_deprecated}
 
function TDirectDraw.GetIDDraw: IDirectDraw;
begin
if Self <> nil then
2603,7 → 1115,7
else
Result := nil;
end;
{$ENDIF}
 
function TDirectDraw.GetIDDraw7: IDirectDraw7;
begin
if Self <> nil then
2611,7 → 1123,7
else
Result := nil;
end;
{$IFDEF D3D_deprecated}
 
function TDirectDraw.GetIDraw: IDirectDraw;
begin
Result := IDDraw;
2625,7 → 1137,7
if Result = nil then
raise EDirectDrawError.CreateFmt(SNotMade, ['IDirectDraw4']);
end;
{$ENDIF}
 
function TDirectDraw.GetIDraw7: IDirectDraw7;
begin
Result := IDDraw7;
2674,7 → 1186,7
begin
IDDPalette := nil;
 
FDDraw.DXResult := FDDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.CreatePalette(Caps, @Entries, TempPalette, nil);
FDDraw.DXResult := FDDraw.IDraw.CreatePalette(Caps, @Entries, TempPalette, nil);
FDXResult := FDDraw.DXResult;
Result := FDDraw.DXResult = DD_OK;
if Result then
2776,7 → 1288,7
FDDraw := ADirectDraw;
FDDraw.FClippers.Add(Self);
 
FDDraw.DXResult := FDDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.CreateClipper(0, FIDDClipper, nil);
FDDraw.DXResult := FDDraw.IDraw.CreateClipper(0, FIDDClipper, nil);
if FDDraw.DXResult <> DD_OK then
raise EDirectDrawClipperError.CreateFmt(SCannotMade, [SDirectDrawClipper]);
end;
2869,7 → 1381,7
 
procedure TDirectDrawSurfaceCanvas.CreateHandle;
begin
FSurface.DXResult := FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetDC(FDC);
FSurface.DXResult := FSurface.ISurface.GetDC(FDC);
if FSurface.DXResult = DD_OK then
Handle := FDC;
end;
2876,10 → 1388,10
 
procedure TDirectDrawSurfaceCanvas.Release;
begin
if (FSurface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil) and (FDC <> 0) then
if (FSurface.IDDSurface<>nil) and (FDC<>0) then
begin
Handle := 0;
FSurface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF}.ReleaseDC(FDC);
FSurface.IDDSurface.ReleaseDC(FDC);
FDC := 0;
end;
end;
2891,18 → 1403,16
inherited Create;
FDDraw := ADirectDraw;
FDDraw.FSurfaces.Add(Self);
DIB_COLMATCH := TDIB.Create;
end;
 
destructor TDirectDrawSurface.Destroy;
begin
DIB_COLMATCH.Free;
FCanvas.Free;
{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := nil;
IDDSurface := nil;
FDDraw.FSurfaces.Remove(Self);
inherited Destroy;
end;
{$IFDEF D3D_deprecated}
 
function TDirectDrawSurface.GetIDDSurface: IDirectDrawSurface;
begin
if Self <> nil then
2918,7 → 1428,7
else
Result := nil;
end;
{$ENDIF}
 
function TDirectDrawSurface.GetIDDSurface7: IDirectDrawSurface7;
begin
if Self <> nil then
2926,7 → 1436,7
else
Result := nil;
end;
{$IFDEF D3D_deprecated}
 
function TDirectDrawSurface.GetISurface: IDirectDrawSurface;
begin
Result := IDDSurface;
2940,7 → 1450,7
if Result = nil then
raise EDirectDrawSurfaceError.CreateFmt(SNotMade, ['IDirectDrawSurface4']);
end;
{$ENDIF}
 
function TDirectDrawSurface.GetISurface7: IDirectDrawSurface7;
begin
Result := IDDSurface7;
2947,7 → 1457,7
if Result = nil then
raise EDirectDrawSurfaceError.CreateFmt(SNotMade, ['IDirectDrawSurface7']);
end;
{$IFDEF D3D_deprecated}
 
procedure TDirectDrawSurface.SetIDDSurface(Value: IDirectDrawSurface);
var
Clipper: IDirectDrawClipper;
2988,50 → 1498,21
else
SetIDDSurface(Value as IDirectDrawSurface);
end;
{$ENDIF}
 
procedure TDirectDrawSurface.SetIDDSurface7(Value: IDirectDrawSurface7);
{$IFNDEF D3D_deprecated}
var
Clipper: IDirectDrawClipper;
{$ENDIF}
begin
{$IFDEF D3D_deprecated}
if Value = nil then
SetIDDSurface(nil)
else
SetIDDSurface(Value as IDirectDrawSurface);
{$ELSE}
if Value = nil then Exit;
if Value as IDirectDrawSurface7 = FIDDSurface7 then Exit;
FIDDSurface7 := nil;
 
FStretchDrawClipper := nil;
FGammaControl := nil;
FHasClipper := False;
FLockCount := 0;
FillChar(FSurfaceDesc, SizeOf(FSurfaceDesc), 0);
 
if Value <> nil then
begin
if FDDraw.FIDDraw7 <> nil then FIDDSurface7 := Value as IDirectDrawSurface7;
 
FHasClipper := (FIDDSurface7.GetClipper(Clipper) = DD_OK) and (Clipper <> nil);
 
FSurfaceDesc.dwSize := SizeOf(FSurfaceDesc);
{$IFDEF D3D_deprecated}FIDDSurface{$ELSE}FIDDSurface7{$ENDIF}.GetSurfaceDesc(FSurfaceDesc);
 
if FDDraw.DriverCaps.dwCaps2 and DDCAPS2_PRIMARYGAMMA <> 0 then
{$IFDEF D3D_deprecated}FIDDSurface{$ELSE}FIDDSurface7{$ENDIF}.QueryInterface(IID_IDirectDrawGammaControl, FGammaControl);
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.Assign(Source: TPersistent);
var
TempSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF};
TempSurface: IDirectDrawSurface;
begin
if Source = nil then
{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := nil
IDDSurface := nil
else if Source is TGraphic then
LoadFromGraphic(TGraphic(Source))
else if Source is TPicture then
3038,14 → 1519,14
LoadFromGraphic(TPicture(Source).Graphic)
else if Source is TDirectDrawSurface then
begin
if TDirectDrawSurface(Source).{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} = nil then
{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := nil
if TDirectDrawSurface(Source).IDDSurface=nil then
IDDSurface := nil
else begin
FDDraw.DXResult := FDDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.DuplicateSurface(TDirectDrawSurface(Source).{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF},
FDDraw.DXResult := FDDraw.IDraw.DuplicateSurface(TDirectDrawSurface(Source).IDDSurface,
TempSurface);
if FDDraw.DXResult = 0 then
begin
{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := TempSurface;
IDDSurface := TempSurface;
end;
end;
end else
3054,31 → 1535,11
 
procedure TDirectDrawSurface.AssignTo(Dest: TPersistent);
begin
if Dest is TBitmap then
begin
try
TBitmap(Dest).PixelFormat := pf24bit;
if BitCount >= 24 then {please accept the Alphachannel too}
TBitmap(Dest).PixelFormat := pf32bit;
TBitmap(Dest).Width := Width;
TBitmap(Dest).Height := Height;
TBitmap(Dest).Canvas.CopyRect(Rect(0, 0, TBitmap(Dest).Width, TBitmap(Dest).Height), Canvas, ClientRect);
finally
Canvas.Release;
end
end
else
if Dest is TDIB then
begin
try
if BitCount >= 24 then {please accept the Alphachannel too}
TDIB(Dest).SetSize(Width, Height, BitCount)
else
TDIB(Dest).SetSize(Width, Height, 24);
TDIB(Dest).Canvas.CopyRect(Rect(0, 0, TDIB(Dest).Width, TDIB(Dest).Height), Canvas, ClientRect);
finally
Canvas.Release;
end
end else
inherited AssignTo(Dest);
end;
3086,9 → 1547,9
function TDirectDrawSurface.Blt(const DestRect, SrcRect: TRect; Flags: DWORD;
const DF: TDDBltFX; Source: TDirectDrawSurface): Boolean;
begin
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
if IDDSurface<>nil then
begin
DXResult := {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF}.Blt(@DestRect, Source.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF}, @SrcRect, DWORD(Flags), @DF);
DXResult := ISurface.Blt(DestRect, Source.IDDSurface, SrcRect, DWORD(Flags), DF);
Result := DXResult = DD_OK;
end else
Result := False;
3097,9 → 1558,9
function TDirectDrawSurface.BltFast(X, Y: Integer; const SrcRect: TRect;
Flags: DWORD; Source: TDirectDrawSurface): Boolean;
begin
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
if IDDSurface<>nil then
begin
DXResult := {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF}.BltFast(X, Y, Source.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF}, @SrcRect, DWORD(Flags));
DXResult := ISurface.BltFast(X, Y, Source.IDDSurface, SrcRect, DWORD(Flags));
Result := DXResult = DD_OK;
end else
Result := False;
3107,25 → 1568,29
 
function TDirectDrawSurface.ColorMatch(Col: TColor): Integer;
var
DIB: TDIB;
i, oldc: Integer;
begin
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
if IDDSurface<>nil then
begin
oldc := Pixels[0, 0];
 
DIB := TDIB.Create;
try
i := ColorToRGB(Col);
DIB_COLMATCH.SetSize(1, 1, 8);
DIB_COLMATCH.ColorTable[0] := RGBQuad(GetRValue(i), GetGValue(i), GetBValue(i));
DIB_COLMATCH.UpdatePalette;
DIB_COLMATCH.Pixels[0, 0] := 0;
DIB.SetSize(1, 1, 8);
DIB.ColorTable[0] := RGBQuad(GetRValue(i), GetGValue(i), GetBValue(i));
DIB.UpdatePalette;
DIB.Pixels[0, 0] := 0;
 
with Canvas do
try
Draw(0, 0, DIB_COLMATCH);
finally
begin
Draw(0, 0, DIB);
Release;
end;
 
finally
DIB.Free;
end;
Result := Pixels[0, 0];
Pixels[0, 0] := oldc;
end else
3132,8 → 1597,7
Result := 0;
end;
 
{$IFDEF D3D_deprecated}
function TDirectDrawSurface.CreateSurface(SurfaceDesc: TDDSurfaceDesc): Boolean;
function TDirectDrawSurface.CreateSurface(const SurfaceDesc: TDDSurfaceDesc): Boolean;
var
TempSurface: IDirectDrawSurface;
begin
3148,19 → 1612,19
TransparentColor := 0;
end;
end;
{$ENDIF}
{$IFDEF VER4UP}
function TDirectDrawSurface.CreateSurface(SurfaceDesc: TDDSurfaceDesc2): Boolean;
 
{$IFDEF DelphiX_Spt4}
function TDirectDrawSurface.CreateSurface(const SurfaceDesc: TDDSurfaceDesc2): Boolean;
var
TempSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface4{$ELSE}IDirectDrawSurface7{$ENDIF};
TempSurface4: IDirectDrawSurface4;
begin
{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := nil;
FDDraw.DXResult := FDDraw.{$IFDEF D3D_deprecated}IDraw4{$ELSE}IDraw7{$ENDIF}.CreateSurface(SurfaceDesc, TempSurface, nil);
IDDSurface := nil;
FDDraw.DXResult := FDDraw.IDraw4.CreateSurface(SurfaceDesc, TempSurface4, nil);
FDXResult := FDDraw.DXResult;
Result := FDDraw.DXResult = DD_OK;
if Result then
begin
{$IFDEF D3D_deprecated}IDDSurface4{$ELSE}IDDSurface7{$ENDIF} := TempSurface;
IDDSurface4 := TempSurface4;
TransparentColor := 0;
end;
end;
3173,27 → 1637,16
(DDBLTFAST_NOCOLORKEY or DDBLTFAST_WAIT, DDBLTFAST_SRCCOLORKEY or DDBLTFAST_WAIT);
BltFlags: array[Boolean] of Integer =
(DDBLT_WAIT, DDBLT_KEYSRC or DDBLT_WAIT);
{$IFDEF DXR_deprecated}var
var
DestRect: TRect;
DF: TDDBltFX;
Clipper: IDirectDrawClipper;
i: Integer;{$ENDIF}
i: Integer;
begin
if Source <> nil then
begin
if (X > Width) or (Y > Height) then Exit;
{$IFDEF DrawHWAcc}
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then
begin
{$IFDEF VER4UP}
D2D.D2DRenderDrawDDSXY(Source, X, Y, SrcRect, Transparent, 0, rtDraw{$IFNDEF VER4UP}, $FF{$ENDIF});
{$ELSE}
D2D.D2DRenderDDS(Source, SrcRect, Bounds(X, Y, SrcRect.Right - SrcRect.Left, SrcRect.Bottom - SrcRect.Top), Transparent, 0, rtDraw, $FF);
{$ENDIF}
Exit;
end;
{$ENDIF DrawHWAcc}
{$IFDEF DXR_deprecated}
 
if (SrcRect.Left > SrcRect.Right) or (SrcRect.Top > SrcRect.Bottom) then
begin
{ Mirror }
3253,7 → 1706,7
BltFast(DestRect.Left, DestRect.Top, SrcRect, BltFastFlags[Transparent], Source);
if DXResult = DDERR_BLTFASTCANTCLIP then
begin
{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetClipper(Clipper);
ISurface.GetClipper(Clipper);
if Clipper <> nil then FHasClipper := True;
 
DF.dwsize := SizeOf(DF);
3263,11 → 1716,10
end;
end;
end;
{$ENDIF}
end;
end;
 
{$IFDEF VER4UP}
{$IFDEF DelphiX_Spt4}
procedure TDirectDrawSurface.Draw(X, Y: Integer; Source: TDirectDrawSurface; Transparent: Boolean);
const
BltFastFlags: array[Boolean] of Integer =
3276,20 → 1728,14
(DDBLT_WAIT, DDBLT_KEYSRC or DDBLT_WAIT);
var
DestRect, SrcRect: TRect;
{$IFDEF DXR_deprecated}DF: TDDBltFX;
Clipper: IDirectDrawClipper;{$ENDIF}
DF: TDDBltFX;
Clipper: IDirectDrawClipper;
begin
if Source <> nil then
begin
SrcRect := Source.ClientRect;
DestRect := Bounds(X, Y, Source.Width, Source.Height);
{$IFDEF DrawHWAcc}
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderDDS(Source, ZeroRect, DestRect, Transparent, 0, rtDraw{$IFNDEF VER4UP}, $FF{$ENDIF});
Exit;
end;
{$ENDIF DrawHWAcc}
{$IFDEF DXR_deprecated}
 
if ClipRect2(DestRect, SrcRect, ClientRect, Source.ClientRect) then
begin
if FHasClipper then
3302,7 → 1748,7
BltFast(DestRect.Left, DestRect.Top, SrcRect, BltFastFlags[Transparent], Source);
if DXResult = DDERR_BLTFASTCANTCLIP then
begin
{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetClipper(Clipper);
ISurface.GetClipper(Clipper);
if Clipper <> nil then FHasClipper := True;
 
DF.dwsize := SizeOf(DF);
3311,7 → 1757,6
end;
end;
end;
{$ENDIF}
end;
end;
{$ENDIF}
3321,22 → 1766,16
const
BltFlags: array[Boolean] of Integer =
(DDBLT_WAIT, DDBLT_KEYSRC or DDBLT_WAIT);
{$IFDEF DXR_deprecated}var
var
DF: TDDBltFX;
OldClipper: IDirectDrawClipper;
Clipper: TDirectDrawClipper;{$ENDIF}
Clipper: TDirectDrawClipper;
begin
if Source <> nil then
begin
if (DestRect.Bottom <= DestRect.Top) or (DestRect.Right <= DestRect.Left) then Exit;
if (SrcRect.Bottom <= SrcRect.Top) or (SrcRect.Right <= SrcRect.Left) then Exit;
{$IFDEF DrawHWAcc}
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderDDS(Source, SrcRect, DestRect, Transparent, 0, rtDraw{$IFNDEF VER4UP}, $FF{$ENDIF});
Exit;
end;
{$ENDIF DrawHWAcc}
{$IFDEF DXR_deprecated}
 
if FHasClipper then
begin
DF.dwsize := SizeOf(DF);
3355,26 → 1794,27
end;
end;
 
{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetClipper(OldClipper);
{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.SetClipper(FStretchDrawClipper);
ISurface.GetClipper(OldClipper);
ISurface.SetClipper(FStretchDrawClipper);
DF.dwsize := SizeOf(DF);
DF.dwDDFX := 0;
Blt(DestRect, SrcRect, BltFlags[Transparent], df, Source);
{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.SetClipper(nil);
ISurface.SetClipper(nil);
end;
{$ENDIF}
end;
end;
 
{$IFDEF VER4UP}
{$IFDEF DelphiX_Spt4}
procedure TDirectDrawSurface.StretchDraw(const DestRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean);
const
BltFlags: array[Boolean] of Integer = (DDBLT_WAIT, DDBLT_KEYSRC or DDBLT_WAIT);
BltFlags: array[Boolean] of Integer =
 
(DDBLT_WAIT, DDBLT_KEYSRC or DDBLT_WAIT);
var
{$IFDEF DXR_deprecated}DF: TDDBltFX;
DF: TDDBltFX;
OldClipper: IDirectDrawClipper;
Clipper: TDirectDrawClipper;{$ENDIF}
Clipper: TDirectDrawClipper;
SrcRect: TRect;
begin
if Source <> nil then
3382,12 → 1822,7
if (DestRect.Bottom <= DestRect.Top) or (DestRect.Right <= DestRect.Left) then Exit;
SrcRect := Source.ClientRect;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderDDS(Source, ZeroRect, DestRect, Transparent, 0, rtDraw{$IFNDEF VER4UP}, $FF{$ENDIF});
Exit;
end;
{$IFDEF DXR_deprecated}
if {$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetClipper(OldClipper) = DD_OK then
if ISurface.GetClipper(OldClipper)=DD_OK then
begin
DF.dwsize := SizeOf(DF);
DF.dwDDFX := 0;
3405,16 → 1840,15
end;
end;
 
{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.SetClipper(FStretchDrawClipper);
ISurface.SetClipper(FStretchDrawClipper);
try
DF.dwsize := SizeOf(DF);
DF.dwDDFX := 0;
Blt(DestRect, SrcRect, BltFlags[Transparent], df, Source);
finally
{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.SetClipper(nil);
ISurface.SetClipper(nil);
end;
end;
{$ENDIF}
end;
end;
{$ENDIF}
3421,10 → 1855,10
 
procedure TDirectDrawSurface.DrawAdd(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean; Alpha: Integer);
{$IFDEF DXR_deprecated}var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
var
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
Blend: TDXR_Blend;{$ENDIF}
Blend: TDXR_Blend;
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
3433,15 → 1867,10
 
if Alpha <= 0 then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderDDS(Source, SrcRect, DestRect, Transparent, 0, rtAdd, Alpha);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
if DestSurface.ColorType = DXR_COLORTYPE_INDEXED then
3459,22 → 1888,21
dxrCopyRectBlend(DestSurface, SrcSurface,
DestRect, SrcRect, Blend, Alpha, Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawAlpha(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean; Alpha: Integer);
{$IFDEF DXR_deprecated}var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
var
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
Blend: TDXR_Blend;{$ENDIF}
Blend: TDXR_Blend;
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
3483,15 → 1911,10
 
if Alpha <= 0 then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderDDS(Source, SrcRect, DestRect, Transparent, 0, rtBlend, Alpha);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
if DestSurface.ColorType = DXR_COLORTYPE_INDEXED then
3509,22 → 1932,21
dxrCopyRectBlend(DestSurface, SrcSurface,
DestRect, SrcRect, Blend, Alpha, Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawSub(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean; Alpha: Integer);
{$IFDEF DXR_deprecated}var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
var
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
Blend: TDXR_Blend;{$ENDIF}
Blend: TDXR_Blend;
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
3533,15 → 1955,10
 
if Alpha <= 0 then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderDDS(Source, SrcRect, DestRect, Transparent, 0, rtSub, Alpha);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
if DestSurface.ColorType = DXR_COLORTYPE_INDEXED then
3559,79 → 1976,20
dxrCopyRectBlend(DestSurface, SrcSurface,
DestRect, SrcRect, Blend, Alpha, Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawAlphaCol(const DestRect, SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; Color, Alpha: Integer);
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if Alpha <= 0 then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderColDDS(Source, SrcRect, DestRect, Transparent, 0, Color, rtBlend, Alpha);
Exit;
end;
 
// If no hardware acceleration, falls back to non-color DrawAlpha
Self.DrawAlpha(DestRect, SrcRect, Source, Transparent, Alpha);
end;
 
procedure TDirectDrawSurface.DrawSubCol(const DestRect, SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; Color, Alpha: Integer);
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if Alpha <= 0 then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderColDDS(Source, SrcRect, DestRect, Transparent, 0, Color, rtSub, Alpha);
Exit;
end;
 
// If no hardware acceleration, falls back to non-color DrawSub
Self.DrawSub(DestRect, SrcRect, Source, Transparent, Alpha);
end;
 
procedure TDirectDrawSurface.DrawAddCol(const DestRect, SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; Color, Alpha: Integer);
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if Alpha <= 0 then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderColDDS(Source, SrcRect, DestRect, Transparent, 0, Color, rtAdd, Alpha);
Exit;
end;
 
// If no hardware acceleration, falls back to non-color DrawAdd
Self.DrawAdd(DestRect, SrcRect, Source, Transparent, Alpha);
 
end;
 
procedure TDirectDrawSurface.DrawRotate(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: single);
{$IFDEF DXR_deprecated}var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
DestSurface, SrcSurface: TDXR_Surface;{$ENDIF}
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: Integer);
var
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
3638,37 → 1996,31
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderRotateDDS(Source, SrcRect, X, Y, Width, Height, rtDraw, CenterX, CenterY, Angle, $FF, Transparent);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
dxrDrawRotateBlend(DestSurface, SrcSurface,
X, Y, Width, Height, SrcRect, CenterX, CenterY, round(Angle), DXR_BLEND_ONE1, 0,
X, Y, Width, Height, SrcRect, CenterX, CenterY, Angle, DXR_BLEND_ONE1, 0,
Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawRotateAdd(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: single; Alpha: Integer);
{$IFDEF DXR_deprecated}var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle, Alpha: Integer);
var
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
Blend: TDXR_Blend; {$ENDIF}
Blend: TDXR_Blend;
begin
if Alpha <= 0 then Exit;
 
3677,15 → 2029,10
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderRotateDDS(Source, SrcRect, X, Y, Width, Height, rtAdd, CenterX, CenterY, Angle, Alpha, Transparent);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
if DestSurface.ColorType = DXR_COLORTYPE_INDEXED then
3701,25 → 2048,24
end;
 
dxrDrawRotateBlend(DestSurface, SrcSurface,
X, Y, Width, Height, SrcRect, CenterX, CenterY, round(Angle), Blend, Alpha,
X, Y, Width, Height, SrcRect, CenterX, CenterY, Angle, Blend, Alpha,
Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawRotateAlpha(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: single; Alpha: Integer);
{$IFDEF DXR_deprecated}var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle, Alpha: Integer);
var
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
Blend: TDXR_Blend; {$ENDIF}
Blend: TDXR_Blend;
begin
if Alpha <= 0 then Exit;
 
3728,15 → 2074,10
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderRotateDDS(Source, SrcRect, X, Y, Width, Height, rtBlend, CenterX, CenterY, Angle, Alpha, Transparent);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
if DestSurface.ColorType = DXR_COLORTYPE_INDEXED then
3752,25 → 2093,24
end;
 
dxrDrawRotateBlend(DestSurface, SrcSurface,
X, Y, Width, Height, SrcRect, CenterX, CenterY, round(Angle), Blend, Alpha,
X, Y, Width, Height, SrcRect, CenterX, CenterY, Angle, Blend, Alpha,
Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawRotateSub(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: single; Alpha: Integer);
{$IFDEF DXR_deprecated}var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle, Alpha: Integer);
var
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
Blend: TDXR_Blend;{$ENDIF}
Blend: TDXR_Blend;
begin
if Alpha <= 0 then Exit;
 
3779,15 → 2119,10
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderRotateDDS(Source, SrcRect, X, Y, Width, Height, rtSub, CenterX, CenterY, Angle, Alpha, Transparent);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
if DestSurface.ColorType = DXR_COLORTYPE_INDEXED then
3803,94 → 2138,23
end;
 
dxrDrawRotateBlend(DestSurface, SrcSurface,
X, Y, Width, Height, SrcRect, CenterX, CenterY, round(Angle), Blend, Alpha,
X, Y, Width, Height, SrcRect, CenterX, CenterY, Angle, Blend, Alpha,
Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawRotateCol(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: Single; Color: Integer);
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderRotateModeColDDS(Source, X, Y, Width, Height, rtDraw, CenterX, CenterY, Angle, Color, $FF, Transparent);
Exit;
end;
 
// If no hardware acceleration, falls back to non-color, moded DrawRotate
Self.DrawRotate(X, Y, Width, Height, SrcRect, Source, CenterX, CenterY, Transparent, Angle);
end;
 
procedure TDirectDrawSurface.DrawRotateAlphaCol(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: Single; Color, Alpha: Integer);
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderRotateModeColDDS(Source, X, Y, Width, Height, rtBlend, CenterX, CenterY, Angle, Color, Alpha, Transparent);
Exit;
end;
 
// If no hardware acceleration, falls back to non-color, moded DrawRotate
Self.DrawRotateAlpha(X, Y, Width, Height, SrcRect, Source, CenterX, CenterY, Transparent, Angle, Alpha);
end;
 
procedure TDirectDrawSurface.DrawRotateAddCol(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: Single; Color, Alpha: Integer);
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderRotateModeColDDS(Source, X, Y, Width, Height, rtAdd, CenterX, CenterY, Angle, Color, Alpha, Transparent);
Exit;
end;
 
// If no hardware acceleration, falls back to non-color, moded DrawRotate
Self.DrawRotateAdd(X, Y, Width, Height, SrcRect, Source, CenterX, CenterY, Transparent, Angle, Alpha);
end;
 
procedure TDirectDrawSurface.DrawRotateSubCol(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; CenterX, CenterY: Double; Transparent: Boolean; Angle: Single; Color, Alpha: Integer);
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderRotateModeColDDS(Source, X, Y, Width, Height, rtSub, CenterX, CenterY, Angle, Color, Alpha, Transparent);
Exit;
end;
 
// If no hardware acceleration, falls back to non-color, moded DrawRotate
Self.DrawRotateSub(X, Y, Width, Height, SrcRect, Source, CenterX, CenterY, Transparent, Angle, Alpha);
end;
 
//waves
 
procedure TDirectDrawSurface.DrawWaveX(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph: Integer);
{$IFDEF DXR_deprecated}var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
DestSurface, SrcSurface: TDXR_Surface;{$ENDIF}
var
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
3897,15 → 2161,10
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderWaveXDDS(Source, X, Y, Width, Height, rtDraw, Transparent, amp, Len, ph{$IFNDEF VER4UP}, $FF{$ENDIF});
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
dxrDrawWaveXBlend(DestSurface, SrcSurface,
3912,22 → 2171,21
X, Y, Width, Height, SrcRect, amp, Len, ph, DXR_BLEND_ONE1, 0,
Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawWaveXAdd(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph, Alpha: Integer);
{$IFDEF DXR_deprecated}var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
var
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
Blend: TDXR_Blend;{$ENDIF}
Blend: TDXR_Blend;
begin
if Alpha <= 0 then Exit;
 
3936,15 → 2194,10
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderWaveXDDS(Source, X, Y, Width, Height, rtAdd, Transparent, amp, Len, ph, Alpha);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
if DestSurface.ColorType = DXR_COLORTYPE_INDEXED then
3963,23 → 2216,21
X, Y, Width, Height, SrcRect, amp, Len, ph, Blend, Alpha,
Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawWaveXAlpha(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph, Alpha: Integer);
{$IFDEF DXR_deprecated}
var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
Blend: TDXR_Blend;{$ENDIF}
Blend: TDXR_Blend;
begin
if Alpha <= 0 then Exit;
 
3988,15 → 2239,10
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderWaveXDDS(Source, X, Y, Width, Height, rtBlend, Transparent, amp, Len, ph, Alpha);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
if DestSurface.ColorType = DXR_COLORTYPE_INDEXED then
4015,23 → 2261,21
X, Y, Width, Height, SrcRect, amp, Len, ph, Blend, Alpha,
Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawWaveXSub(X, Y, Width, Height: Integer; const SrcRect: TRect;
Source: TDirectDrawSurface; Transparent: Boolean; amp, Len, ph, Alpha: Integer);
{$IFDEF DXR_deprecated}
var
Src_ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
Src_ddsd: TDDSurfaceDesc;
DestSurface, SrcSurface: TDXR_Surface;
Blend: TDXR_Blend;{$ENDIF}
Blend: TDXR_Blend;
begin
if Alpha <= 0 then Exit;
 
4040,15 → 2284,10
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderWaveXDDS(Source, X, Y, Width, Height, rtSub, Transparent, amp, Len, ph, Alpha);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
if dxrDDSurfaceLock2(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, Src_ddsd, SrcSurface) then
if dxrDDSurfaceLock2(Source.ISurface, Src_ddsd, SrcSurface) then
begin
try
if DestSurface.ColorType = DXR_COLORTYPE_INDEXED then
4067,82 → 2306,15
X, Y, Width, Height, SrcRect, amp, Len, ph, Blend, Alpha,
Transparent, Src_ddsd.ddckCKSrcBlt.dwColorSpaceLowValue);
finally
dxrDDSurfaceUnLock(Source.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, SrcSurface)
dxrDDSurfaceUnLock(Source.ISurface, SrcSurface)
end;
end;
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.DrawWaveYSub(X, Y, Width, Height: Integer;
const SrcRect: TRect; Source: TDirectDrawSurface; Transparent: Boolean; amp,
Len, ph, Alpha: Integer);
begin
if Alpha <= 0 then Exit;
 
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderWaveYDDS(Source, X, Y, Width, Height, rtSub, Transparent, amp, Len, ph, Alpha);
Exit;
end;
end;
 
procedure TDirectDrawSurface.DrawWaveY(X, Y, Width, Height: Integer;
const SrcRect: TRect; Source: TDirectDrawSurface; Transparent: Boolean; amp,
Len, ph: Integer);
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderWaveYDDS(Source, X, Y, Width, Height, rtDraw, Transparent, amp, Len, ph{$IFNDEF VER4UP}, $FF{$ENDIF});
Exit;
end;
end;
 
procedure TDirectDrawSurface.DrawWaveYAdd(X, Y, Width, Height: Integer;
const SrcRect: TRect; Source: TDirectDrawSurface; Transparent: Boolean; amp,
Len, ph, Alpha: Integer);
begin
if Alpha <= 0 then Exit;
 
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderWaveYDDS(Source, X, Y, Width, Height, rtAdd, Transparent, amp, Len, ph, Alpha);
Exit;
end;
end;
 
procedure TDirectDrawSurface.DrawWaveYAlpha(X, Y, Width, Height: Integer;
const SrcRect: TRect; Source: TDirectDrawSurface; Transparent: Boolean; amp,
Len, ph, Alpha: Integer);
begin
if Alpha <= 0 then Exit;
 
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if (Width = 0) or (Height = 0) then Exit;
if Source = nil then Exit;
if (Source.Width = 0) or (Source.Height = 0) then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderWaveYDDS(Source, X, Y, Width, Height, rtBlend, Transparent, amp, Len, ph, Alpha);
Exit;
end;
end;
 
procedure TDirectDrawSurface.Fill(DevColor: Longint);
var
DBltEx: TDDBltFX;
4164,9 → 2336,9
Blt(DestRect, TRect(nil^), DDBLT_COLORFILL or DDBLT_WAIT, DBltEx, nil);
end;
 
procedure TDirectDrawSurface.FillRectAdd(const DestRect: TRect; Color: TColor; Alpha: Byte);
{$IFDEF DXR_deprecated}var
DestSurface: TDXR_Surface;{$ENDIF}
procedure TDirectDrawSurface.FillRectAdd(const DestRect: TRect; Color: TColor);
var
DestSurface: TDXR_Surface;
begin
if Color and $FFFFFF = 0 then Exit;
if (Self.Width = 0) or (Self.Height = 0) then Exit;
4173,49 → 2345,38
if SurfaceDesc.ddpfPixelFormat.dwFlags and (DDPF_PALETTEINDEXED1 or DDPF_PALETTEINDEXED2 or
DDPF_PALETTEINDEXED4 or DDPF_PALETTEINDEXED8) <> 0 then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderFillRect(DestRect, ColorToRGB(Color), rtAdd, Alpha);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
dxrFillRectColorBlend(DestSurface, DestRect, DXR_BLEND_ONE1_ADD_ONE2, ColorToRGB(Color));
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;
{$ENDIF}
end;
 
procedure TDirectDrawSurface.FillRectAlpha(const DestRect: TRect; Color: TColor;
Alpha: Integer);
{$IFDEF DXR_deprecated}var
DestSurface: TDXR_Surface;{$ENDIF}
var
DestSurface: TDXR_Surface;
begin
if (Self.Width = 0) or (Self.Height = 0) then Exit;
if SurfaceDesc.ddpfPixelFormat.dwFlags and (DDPF_PALETTEINDEXED1 or DDPF_PALETTEINDEXED2 or
DDPF_PALETTEINDEXED4 or DDPF_PALETTEINDEXED8) <> 0 then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderFillRect(DestRect, ColorToRGB(Color), rtBlend, Alpha);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
dxrFillRectColorBlend(DestSurface, DestRect, DXR_BLEND_SRCALPHA1_ADD_INVSRCALPHA2, ColorToRGB(Color) or (Byte(Alpha) shl 24));
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;{$ENDIF}
end;
end;
 
procedure TDirectDrawSurface.FillRectSub(const DestRect: TRect; Color: TColor; Alpha: Byte);
{$IFDEF DXR_deprecated}var
DestSurface: TDXR_Surface;{$ENDIF}
procedure TDirectDrawSurface.FillRectSub(const DestRect: TRect; Color: TColor);
var
DestSurface: TDXR_Surface;
begin
if Color and $FFFFFF = 0 then Exit;
if (Self.Width = 0) or (Self.Height = 0) then Exit;
4222,20 → 2383,15
if SurfaceDesc.ddpfPixelFormat.dwFlags and (DDPF_PALETTEINDEXED1 or DDPF_PALETTEINDEXED2 or
DDPF_PALETTEINDEXED4 or DDPF_PALETTEINDEXED8) <> 0 then Exit;
 
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin
D2D.D2DRenderFillRect(DestRect, ColorToRGB(Color), rtSub, Alpha);
Exit;
end;
{$IFDEF DXR_deprecated}
if dxrDDSurfaceLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface) then
if dxrDDSurfaceLock(ISurface, DestSurface) then
begin
try
dxrFillRectColorBlend(DestSurface, DestRect, DXR_BLEND_ONE2_SUB_ONE1, ColorToRGB(Color));
finally
dxrDDSurfaceUnLock({$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, DestSurface)
dxrDDSurfaceUnLock(ISurface, DestSurface)
end;
end;{$ENDIF}
end;
end;
 
function TDirectDrawSurface.GetBitCount: Integer;
begin
4267,10 → 2423,10
 
function TDirectDrawSurface.GetPixel(X, Y: Integer): Longint;
var
ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
ddsd: TDDSurfaceDesc;
begin
Result := 0;
if ({$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil) and (X >= 0) and (X < Width) and (Y >= 0) and (Y < Height) then
if (IDDSurface<>nil) and (X>=0) and (X<Width) and (Y>=0) and (Y<Height) then
if Lock(PRect(nil)^, ddsd) then
begin
try
4330,18 → 2486,16
if Graphic is TDIB then
begin
with Canvas do
try
begin
StretchBlt(Handle, 0, 0, AWidth, AHeight, TDIB(Graphic).Canvas.Handle,
Left, Top, Right - Left, Bottom - Top, SRCCOPY);
finally
Release;
end;
end else if (Right - Left = AWidth) and (Bottom - Top = AHeight) then
begin
with Canvas do
try
begin
Draw(-Left, -Top, Graphic);
finally
Release;
end;
end else
4352,9 → 2506,8
Temp.Canvas.Draw(-Left, -Top, Graphic);
 
with Canvas do
try
begin
StretchDraw(Bounds(0, 0, AWidth, AHeight), Temp);
finally
Release;
end;
finally
4390,81 → 2543,63
end;
end;
 
function TDirectDrawSurface.Lock(const Rect: TRect; var SurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF}): Boolean;
function TDirectDrawSurface.Lock(const Rect: TRect; var SurfaceDesc: TDDSurfaceDesc): Boolean;
begin
Result := False;
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} = nil then Exit;
if IDDSurface=nil then Exit;
 
if FLockCount > 0 then Exit;
FIsLocked := False;
 
FLockSurfaceDesc.dwSize := SizeOf(FLockSurfaceDesc);
 
if (@Rect <> nil) and ((Rect.Left <> 0) or (Rect.Top <> 0) or (Rect.Right <> Width) or (Rect.Bottom <> Height)) then
DXResult := {$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.Lock(@Rect, FLockSurfaceDesc, DDLOCK_WAIT, 0)
DXResult := ISurface.Lock(@Rect, FLockSurfaceDesc, DDLOCK_WAIT, 0)
else
DXResult := {$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.Lock(nil, FLockSurfaceDesc, DDLOCK_WAIT, 0);
DXResult := ISurface.Lock(nil, FLockSurfaceDesc, DDLOCK_WAIT, 0);
if DXResult <> DD_OK then Exit;
 
Inc(FLockCount);
SurfaceDesc := FLockSurfaceDesc;
FIsLocked := True;
 
Result := True;
end;
 
{$IFDEF VER4UP}
function TDirectDrawSurface.Lock(var SurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF}): Boolean;
{$IFDEF DelphiX_Spt4}
function TDirectDrawSurface.Lock(var SurfaceDesc: TDDSurfaceDesc): Boolean;
begin
Result := False;
FIsLocked := False;
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} = nil then Exit;
if IDDSurface=nil then Exit;
 
if FLockCount = 0 then
begin
FLockSurfaceDesc.dwSize := SizeOf(FLockSurfaceDesc);
DXResult := {$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.Lock(nil, FLockSurfaceDesc, DDLOCK_WAIT, 0);
DXResult := ISurface.Lock(nil, FLockSurfaceDesc, DDLOCK_WAIT, 0);
if DXResult <> DD_OK then Exit;
end;
 
Inc(FLockCount);
SurfaceDesc := FLockSurfaceDesc;
FIsLocked := True;
Result := True;
end;
 
function TDirectDrawSurface.Lock: Boolean;
var SurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
begin
Result := Lock(SurfaceDesc);
end;
 
{$ELSE}
 
function TDirectDrawSurface.LockSurface: Boolean;
var SurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF}; R: TRect;
begin
Result := Lock(R, SurfaceDesc);
end;
{$ENDIF}
 
procedure TDirectDrawSurface.UnLock;
begin
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} = nil then Exit;
if IDDSurface=nil then Exit;
 
if FLockCount > 0 then
begin
Dec(FLockCount);
if FLockCount = 0 then begin
DXResult := {$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.UnLock(FLockSurfaceDesc.lpSurface);
FIsLocked := False;
if FLockCount=0 then
DXResult := ISurface.UnLock(FLockSurfaceDesc.lpSurface);
end;
end;
end;
 
function TDirectDrawSurface.Restore: Boolean;
begin
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
if IDDSurface<>nil then
begin
DXResult := {$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}._Restore;
DXResult := ISurface.Restore;
Result := DXResult = DD_OK;
end else
Result := False;
4472,29 → 2607,29
 
procedure TDirectDrawSurface.SetClipper(Value: TDirectDrawClipper);
begin
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
DXResult := {$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.SetClipper(Value.IDDClipper);
if IDDSurface<>nil then
DXResult := ISurface.SetClipper(Value.IDDClipper);
FHasClipper := (Value <> nil) and (DXResult = DD_OK);
end;
 
procedure TDirectDrawSurface.SetColorKey(Flags: DWORD; const Value: TDDColorKey);
begin
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
DXResult := {$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.SetColorKey(Flags, @Value);
if IDDSurface<>nil then
DXResult := ISurface.SetColorKey(Flags, Value);
end;
 
procedure TDirectDrawSurface.SetPalette(Value: TDirectDrawPalette);
begin
if {$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
DXResult := {$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.SetPalette(Value.IDDPalette);
if IDDSurface<>nil then
DXResult := ISurface.SetPalette(Value.IDDPalette);
end;
 
procedure TDirectDrawSurface.SetPixel(X, Y: Integer; Value: Longint);
var
ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
ddsd: TDDSurfaceDesc;
P: PByte;
begin
if ({$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil) and (X >= 0) and (X < Width) and (Y >= 0) and (Y < Height) then
if (IDDSurface<>nil) and (X>=0) and (X<Width) and (Y>=0) and (Y<Height) then
if Lock(PRect(nil)^, ddsd) then
begin
try
4531,15 → 2666,14
 
procedure TDirectDrawSurface.SetSize(AWidth, AHeight: Integer);
var
ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
ddsd: TDDSurfaceDesc;
begin
if (AWidth <= 0) or (AHeight <= 0) then
begin
{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := nil;
IDDSurface := nil;
Exit;
end;
 
FillChar(ddsd, SizeOf(ddsd), 0);
with ddsd do
begin
dwSize := SizeOf(ddsd);
4576,744 → 2710,6
ColorKey[DDCKEY_SRCBLT] := ddck;
end;
 
{additional pixel routines like turbopixels}
 
{
procedure TDirectDrawSurface.PutPixel8(x, y, color: Integer);
var
SurfacePtr: PByte;
PixelOffset: Integer;
begin
SurfacePtr := FLockSurfaceDesc.lpSurface;
PixelOffset := x + y * FLockSurfaceDesc.dwWidth;
SurfacePtr[PixelOffset] := color and $FF; // set pixel (lo byte of color)
end;}
 
procedure TDirectDrawSurface.PutPixel8(x, y, color: Integer); assembler;
{ on entry: self = eax, x = edx, y = ecx, color = ? }
asm
push esi // must maintain esi
mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface// set to surface
add esi,edx // add x
mov eax,[TDirectDrawSurface[eax].FLockSurfaceDesc.dwwidth] // eax = pitch
mul ecx // eax = pitch * y
add esi,eax // esi = pixel offset
mov ecx, color
mov ds:[esi],cl // set pixel (lo byte of ecx)
pop esi // restore esi
//ret // return
end;
 
{
procedure TDirectDrawSurface.PutPixel16(x, y, color: Integer);
var
pPixel: PWord;
begin
pPixel := PWord(Integer(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface) +
x * 2 + y * TDirectDrawSurface(Self).FLockSurfaceDesc.lPitch);
pPixel^ := color;
end;
}
 
procedure TDirectDrawSurface.PutPixel16(x, y, color: Integer); assembler;
{ on entry: self = eax, x = edx, y = ecx, color = ? }
asm
push esi
mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface
shl edx,1
add esi,edx
mov eax,[TDirectDrawSurface[eax].FLockSurfaceDesc.lpitch]
mul ecx
add esi,eax
mov ecx, color
mov ds:[esi],cx
pop esi
//ret
end;
 
{
procedure TDirectDrawSurface.PutPixel24(x, y, color: Integer);
var
pPixel: PByte;
dwPitch: DWORD;
dwColor: DWORD;
begin
pPixel := PByte(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface);
Inc(pPixel, x * 3);
dwPitch := TDirectDrawSurface(Self).FLockSurfaceDesc.lPitch;
Inc(pPixel, y * dwPitch);
dwColor := color and $FFFFFF;
pPixel[0] := Byte(dwColor);
pPixel[1] := Byte(dwColor shr 8);
pPixel[2] := Byte(dwColor shr 16);
end;
}
 
procedure TDirectDrawSurface.PutPixel24(x, y, color: Integer); assembler;
{ on entry: self = eax, x = edx, y = ecx, color = ? }
asm
push esi
mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface
imul edx,3
add esi,edx
mov eax,[TDirectDrawSurface[eax].FLockSurfaceDesc.lpitch]
mul ecx
add esi,eax
mov eax,ds:[esi]
and eax,$FF000000
mov ecx, color
or ecx,eax
mov ds:[esi+1],ecx
pop esi
//ret
end;
 
{
procedure TDirectDrawSurface.PutPixel24(x, y, color: Integer);
var
offset: Integer;
pixelColor: LongInt;
begin
offset := (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch) + (x * 3);
pixelColor := color and $FFFFFF;
Move(pixelColor, PByte(Integer(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface) + offset)^, 3);
end;
}
 
procedure TDirectDrawSurface.PutPixel32(x, y, color: Integer); assembler;
{ on entry: self = eax, x = edx, y = ecx, color = ? }
asm
push esi
mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface
shl edx,2
add esi,edx
mov eax,[TDirectDrawSurface[eax].FLockSurfaceDesc.lpitch]
mul ecx
add esi,eax
mov ecx, color
mov ds:[esi],ecx
pop esi
//ret
end;
 
procedure TDirectDrawSurface.Poke(X, Y: Integer; const Value: LongInt);
begin
if (X < 0) or (X > (Width - 1)) or
(Y < 0) or (Y > (Height - 1)) or not FIsLocked then Exit;
case Bitcount of
8: PutPixel8(x, y, value);
16: PutPixel16(x, y, value);
24: PutPixel24(x, y, value);
32: PutPixel32(x, y, value);
end;
end;
 
{
function TDirectDrawSurface.GetPixel8(x, y: Integer): Integer;
var
Pixel: Byte;
PixelPtr: PByte;
begin
PixelPtr := PByte(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface + x + (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch));
Pixel := PixelPtr^;
Result := Pixel;
end;
 
function TDirectDrawSurface.GetPixel16(x, y: Integer): Integer;
var
Pixel: Word;
PixelPtr: PWord;
begin
PixelPtr := PWord(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface + (x * 2) + (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch));
Pixel := PixelPtr^;
Result := Pixel;
end;
 
function TDirectDrawSurface.GetPixel24(x, y: Integer): Integer;
var
Pixel: array[0..2] of Byte;
PixelPtr: PByte;
begin
PixelPtr := PByte(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface + (x * 3) + (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch));
Pixel[0] := PixelPtr^;
Pixel[1] := (PixelPtr+1)^;
Pixel[2] := (PixelPtr+2)^;
Result := Pixel[0] or (Pixel[1] shl 8) or (Pixel[2] shl 16);
end;
 
function TDirectDrawSurface.GetPixel32(x, y: Integer): Integer;
var
Pixel: Integer;
PixelPtr: PInteger;
begin
PixelPtr := PInteger(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface + (x * 4) + (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch));
Pixel := PixelPtr^;
Result := Pixel;
end;
}
 
function TDirectDrawSurface.GetPixel8(x, y: Integer): Integer; assembler;
{ on entry: self = eax, x = edx, y = ecx, result = eax }
asm
push esi // myst maintain esi
mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface // set to surface
add esi,edx // add x
mov eax,[TDirectDrawSurface[eax].FLockSurfaceDesc.lpitch] // eax = pitch
mul ecx // eax = pitch * y
add esi,eax // esi = pixel offset
mov eax,ds:[esi] // eax = color
and eax,$FF // map into 8bit
pop esi // restore esi
//ret // return
end;
 
function TDirectDrawSurface.GetPixel16(x, y: Integer): Integer; assembler;
{ on entry: self = eax, x = edx, y = ecx, result = eax }
asm
push esi
mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface
shl edx,1
add esi,edx
mov eax,[TDirectDrawSurface[eax].FLockSurfaceDesc.lpitch]
mul ecx
add esi,eax
mov eax,ds:[esi]
and eax,$FFFF // map into 16bit
pop esi
//ret
end;
 
function TDirectDrawSurface.GetPixel24(x, y: Integer): Integer; assembler;
{ on entry: self = eax, x = edx, y = ecx, result = eax }
asm
push esi
mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface
imul edx,3
add esi,edx
mov eax,[TDirectDrawSurface[eax].FLockSurfaceDesc.lpitch]
mul ecx
add esi,eax
mov eax,ds:[esi]
and eax,$FFFFFF // map into 24bit
pop esi
//ret
end;
 
function TDirectDrawSurface.GetPixel32(x, y: Integer): Integer; assembler;
{ on entry: self = eax, x = edx, y = ecx, result = eax }
asm
push esi
mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface
shl edx,2
add esi,edx
mov eax,[TDirectDrawSurface[eax].FLockSurfaceDesc.lpitch]
mul ecx
add esi,eax
mov eax,ds:[esi]
pop esi
//ret
end;
 
function TDirectDrawSurface.Peek(X, Y: Integer): LongInt;
begin
Result := 0;
if (X < 0) or (X > (Width - 1)) or
(Y < 0) or (Y > (Height - 1)) or not FIsLocked then Exit;
case Bitcount of
8: Result := GetPixel8(x, y);
16: Result := GetPixel16(x, y);
24: Result := GetPixel24(x, y);
32: Result := GetPixel32(x, y);
end;
end;
 
procedure TDirectDrawSurface.PokeLine(X1, Y1, X2, Y2: Integer; Color: cardinal);
var
i, deltax, deltay, numpixels,
d, dinc1, dinc2,
x, xinc1, xinc2,
y, yinc1, yinc2: Integer;
begin
if not FIsLocked then {$IFDEF VER4UP}Lock{$ELSE}LockSurface{$ENDIF}; //force lock the surface
{ Calculate deltax and deltay for initialisation }
deltax := abs(x2 - x1);
deltay := abs(y2 - y1);
 
{ Initialise all vars based on which is the independent variable }
if deltax >= deltay then
begin
{ x is independent variable }
numpixels := deltax + 1;
d := (2 * deltay) - deltax;
 
dinc1 := deltay shl 1;
dinc2 := (deltay - deltax) shl 1;
xinc1 := 1;
xinc2 := 1;
yinc1 := 0;
yinc2 := 1;
end
else
begin
{ y is independent variable }
numpixels := deltay + 1;
d := (2 * deltax) - deltay;
dinc1 := deltax shl 1;
dinc2 := (deltax - deltay) shl 1;
xinc1 := 0;
xinc2 := 1;
yinc1 := 1;
yinc2 := 1;
end;
{ Make sure x and y move in the right directions }
if x1 > x2 then
begin
xinc1 := -xinc1;
xinc2 := -xinc2;
end;
if y1 > y2 then
begin
yinc1 := -yinc1;
yinc2 := -yinc2;
end;
x := x1;
y := y1;
{ Draw the pixels }
for i := 1 to numpixels do
begin
if (x > 0) and (x < (Width - 1)) and (y > 0) and (y < (Height - 1)) then
Pixel[x, y] := Color;
if d < 0 then
begin
Inc(d, dinc1);
Inc(x, xinc1);
Inc(y, yinc1);
end
else
begin
Inc(d, dinc2);
Inc(x, xinc2);
Inc(y, yinc2);
end;
end;
end;
 
procedure TDirectDrawSurface.PokeLinePolar(x, y: Integer; angle, length: extended; Color: cardinal);
var
xp, yp: Integer;
begin
xp := round(sin(angle * pi / 180) * length) + x;
yp := round(cos(angle * pi / 180) * length) + y;
PokeLine(x, y, xp, yp, Color);
end;
 
procedure TDirectDrawSurface.PokeBox(xs, ys, xd, yd: Integer; Color: cardinal);
begin
pokeline(xs, ys, xd, ys, color);
pokeline(xs, ys, xs, yd, color);
pokeline(xd, ys, xd, yd, color);
pokeline(xs, yd, xd, yd, color);
end;
 
procedure TDirectDrawSurface.PokeBlendPixel(const X, Y: Integer; aColor: cardinal; Alpha: byte);
var
cr, cg, cb: byte;
ar, ag, ab: byte;
begin
LoadRGB(aColor, ar, ag, ab);
LoadRGB(Pixel[x, y], cr, cg, cb);
Pixel[x, y] := SaveRGB((Alpha * (aR - cr) shr 8) + cr, // R alpha
(Alpha * (aG - cg) shr 8) + cg, // G alpha
(Alpha * (aB - cb) shr 8) + cb); // B alpha
end;
 
{
function Conv24to16(Color: Integer): Word;
var
r, g, b: Byte;
begin
r := (Color shr 16) and $FF;
g := (Color shr 8) and $FF;
b := Color and $FF;
Result := ((r shr 3) shl 11) or ((g shr 2) shl 5) or (b shr 3);
end;
}
 
function Conv24to16(Color: Integer): Word; register;
asm
mov ecx,eax
shl eax,24
shr eax,27
shl eax,11
mov edx,ecx
shl edx,16
shr edx,26
shl edx,5
or eax,edx
mov edx,ecx
shl edx,8
shr edx,27
or eax,edx
end;
 
procedure TDirectDrawSurface.PokeWuLine(X1, Y1, X2, Y2, aColor: Integer);
var DeltaX, DeltaY, Loop, Start, Finish: Integer;
Dx, Dy, DyDx: Single; // fractional parts
Color16: DWord;
begin
DeltaX := Abs(X2 - X1); // Calculate DeltaX and DeltaY for initialization
DeltaY := Abs(Y2 - Y1);
if (DeltaX = 0) or (DeltaY = 0) then
begin // straight lines
PokeLine(X1, Y1, X2, Y2, aColor);
Exit;
end;
if BitCount = 16 then
Color16 := Conv24to16(aColor)
else
Color16 := aColor;
if DeltaX > DeltaY then // horizontal or vertical
begin
{ determine rise and run }
if Y2 > Y1 then DyDx := -(DeltaY / DeltaX)
else DyDx := DeltaY / DeltaX;
if X2 < X1 then
begin
Start := X2; // right to left
Finish := X1;
Dy := Y2;
end else
begin
Start := X1; // left to right
Finish := X2;
Dy := Y1;
DyDx := -DyDx; // inverse slope
end;
for Loop := Start to Finish do
begin
PokeBlendPixel(Loop, Trunc(Dy), Color16, Trunc((1 - Frac(Dy)) * 255));
PokeBlendPixel(Loop, Trunc(Dy) + 1, Color16, Trunc(Frac(Dy) * 255));
Dy := Dy + DyDx; // next point
end;
end else
begin
{ determine rise and run }
if X2 > X1 then DyDx := -(DeltaX / DeltaY)
else DyDx := DeltaX / DeltaY;
if Y2 < Y1 then
begin
Start := Y2; // right to left
Finish := Y1;
Dx := X2;
end else
begin
Start := Y1; // left to right
Finish := Y2;
Dx := X1;
DyDx := -DyDx; // inverse slope
end;
for Loop := Start to Finish do
begin
PokeBlendPixel(Trunc(Dx), Loop, Color16, Trunc((1 - Frac(Dx)) * 255));
PokeBlendPixel(Trunc(Dx), Loop, Color16, Trunc(Frac(Dx) * 255));
Dx := Dx + DyDx; // next point
end;
end;
end;
 
procedure TDirectDrawSurface.Noise(Oblast: TRect; Density: Byte);
var
dx, dy: Integer;
Dens: byte;
begin
{noise}
case Density of
0..2: Dens := 3;
255: Dens := 254;
else
Dens := Density;
end;
if Dens >= Oblast.Right then
Dens := Oblast.Right div 3;
dy := Oblast.Top;
while dy <= Oblast.Bottom do begin
dx := Oblast.Left;
while dx <= Oblast.Right do begin
inc(dx, random(dens));
if dx <= Oblast.Right then
Pixel[dx, dy] := not Pixel[dx, dy];
end;
inc(dy);
end;
end;
 
{
function Conv16to24(Color: Word): Integer;
var
r, g, b: Byte;
begin
r := (Color shr 11) and $1F;
g := (Color shr 5) and $3F;
b := Color and $1F;
Result := (r shl 19) or (g shl 10) or (b shl 3);
end;
}
 
function Conv16to24(Color: Word): Integer; register;
asm
xor edx,edx
mov dx,ax
 
mov eax,edx
shl eax,27
shr eax,8
 
mov ecx,edx
shr ecx,5
shl ecx,26
shr ecx,16
or eax,ecx
 
mov ecx,edx
shr ecx,11
shl ecx,27
shr ecx,24
or eax,ecx
end;
 
procedure GetRGB(Color: cardinal; var R, G, B: Byte); {$IFDEF VER9UP}inline; {$ENDIF}
begin
R := Color;
G := Color shr 8;
B := Color shr 16;
end;
 
procedure TDirectDrawSurface.LoadRGB(Color: cardinal; var R, G, B: Byte);
var grB: Byte;
begin
grB := 1;
if FLockSurfaceDesc.ddpfPixelFormat.dwGBitMask = 2016 then grB := 0; // 565
case BitCount of
15, 16: begin
R := (color shr (11 - grB)) shl 3;
if grB = 0 then
G := ((color and 2016) shr 5) shl 2
else
G := ((color and 992) shr 5) shl 3;
B := (color and 31) shl 3;
end;
else
GetRGB(Color, R, G, B);
end;
end;
 
function TDirectDrawSurface.SaveRGB(const R, G, B: Byte): cardinal;
begin
case BitCount of
15, 16: begin
Result := Conv24to16(RGB(R, G, B));
end;
else
Result := RGB(R, G, B);
end;
end;
 
procedure TDirectDrawSurface.Blur;
var
x, y, tr, tg, tb: Integer;
r, g, b: byte;
begin
for y := 1 to GetHeight - 1 do
for x := 1 to GetWidth - 1 do begin
LoadRGB(peek(x, y), r, g, b);
tr := r;
tg := g;
tb := b;
LoadRGB(peek(x, y + 1), r, g, b);
Inc(tr, r);
Inc(tg, g);
Inc(tb, b);
LoadRGB(peek(x, y - 1), r, g, b);
Inc(tr, r);
Inc(tg, g);
Inc(tb, b);
LoadRGB(peek(x - 1, y), r, g, b);
Inc(tr, r);
Inc(tg, g);
Inc(tb, b);
LoadRGB(peek(x + 1, y), r, g, b);
Inc(tr, r);
Inc(tg, g);
Inc(tb, b);
tr := tr shr 2;
tg := tg shr 2;
tb := tb shr 2;
Poke(x, y, savergb(tr, tg, tb));
end;
end;
 
procedure TDirectDrawSurface.PokeCircle(X, Y, Radius, Color: Integer);
var
a, af, b, bf, c,
target, r2: Integer;
begin
Target := 0;
A := Radius;
B := 0;
R2 := Sqr(Radius);
 
while a >= B do
begin
b := Round(Sqrt(R2 - Sqr(A)));
c := target; target := b; b := c;
while B < Target do
begin
Af := (120 * a) div 100;
Bf := (120 * b) div 100;
pixel[x + af, y + b] := color;
pixel[x + bf, y + a] := color;
pixel[x - af, y + b] := color;
pixel[x - bf, y + a] := color;
pixel[x - af, y - b] := color;
pixel[x - bf, y - a] := color;
pixel[x + af, y - b] := color;
pixel[x + bf, y - a] := color;
B := B + 1;
end;
A := A - 1;
end;
end;
 
function RGBToBGR(Color: cardinal): cardinal;
begin
result := (LoByte(LoWord(Color)) shr 3 shl 11) or // Red
(HiByte((Color)) shr 2 shl 5) or // Green
(LoByte(HiWord(Color)) shr 3); // Blue
end;
 
procedure TDirectDrawSurface.PokeVLine(x, y1, y2: Integer; Color: cardinal);
var
y: Integer;
NColor: cardinal;
r, g, b: byte;
begin
if y1 < 0 then y1 := 0;
if y2 >= Height then y2 := Height - 1;
GetRGB(Color, r, g, b);
NColor := RGBToBGR(rgb(r, g, b));
for y := y1 to y2 do
begin
pixel[x, y] := NColor;
end;
end;
 
procedure TDirectDrawSurface.PokeFilledEllipse(exc, eyc, ea, eb, color: Integer);
var x, y: Integer; aa, aa2, bb, bb2, d, dx, dy: LongInt;
begin
x := 0;
y := eb;
aa := LongInt(ea) * ea;
aa2 := 2 * aa;
bb := LongInt(eb) * eb;
bb2 := 2 * bb;
d := bb - aa * eb + aa div 4;
dx := 0;
dy := aa2 * eb;
PokevLine(exc, eyc - y, eyc + y, color);
while (dx < dy) do begin
if (d > 0) then begin
dec(y); dec(dy, aa2); dec(d, dy);
end;
inc(x); inc(dx, bb2); inc(d, bb + dx);
PokevLine(exc - x, eyc - y, eyc + y, color);
PokevLine(exc + x, eyc - y, eyc + y, color);
end;
inc(d, (3 * (aa - bb) div 2 - (dx + dy)) div 2);
while (y >= 0) do begin
if (d < 0) then begin
inc(x); inc(dx, bb2); inc(d, bb + dx);
PokevLine(exc - x, eyc - y, eyc + y, color);
PokevLine(exc + x, eyc - y, eyc + y, color);
end;
dec(y); dec(dy, aa2); inc(d, aa - dy);
end;
end;
 
procedure TDirectDrawSurface.DoRotate(cent1, cent2, angle: Integer; coord1, coord2: Real; Color: word);
var coord1t, coord2t: Real;
c1, c2: Integer;
begin
coord1t := coord1 - cent1;
coord2t := coord2 - cent2;
coord1 := coord1t * cos(angle * pi / 180) - coord2t * sin(angle * pi / 180);
coord2 := coord1t * sin(angle * pi / 180) + coord2t * cos(angle * pi / 180);
coord1 := coord1 + cent1;
coord2 := coord2 + cent2;
c1 := round(coord1);
c2 := round(coord2);
pixel[c1, c2] := Color;
end;
 
procedure TDirectDrawSurface.PokeEllipse(exc, eyc, ea, eb, angle, Color: Integer);
var
elx, ely: Integer;
aa, aa2, bb, bb2, d, dx, dy: LongInt;
x, y: real;
begin
elx := 0;
ely := eb;
aa := LongInt(ea) * ea;
aa2 := 2 * aa;
bb := LongInt(eb) * eb;
bb2 := 2 * bb;
d := bb - aa * eb + aa div 4;
dx := 0;
dy := aa2 * eb;
x := exc;
y := eyc - ely;
dorotate(exc, eyc, angle, x, y, Color);
x := exc;
y := eyc + ely;
dorotate(exc, eyc, angle, x, y, Color);
x := exc - ea;
y := eyc;
dorotate(exc, eyc, angle, x, y, Color);
x := exc + ea;
y := eyc;
dorotate(exc, eyc, angle, x, y, Color);
while (dx < dy) do begin
if (d > 0) then begin Dec(ely); Dec(dy, aa2); Dec(d, dy); end;
Inc(elx); Inc(dx, bb2); Inc(d, bb + dx);
x := exc + elx; y := eyc + ely;
dorotate(exc, eyc, angle, x, y, Color);
x := exc - elx; y := eyc + ely;
dorotate(exc, eyc, angle, x, y, Color);
x := exc + elx; y := eyc - ely;
dorotate(exc, eyc, angle, x, y, Color);
x := exc - elx; y := eyc - ely;
dorotate(exc, eyc, angle, x, y, Color);
end;
Inc(d, (3 * (aa - bb) div 2 - (dx + dy)) div 2);
while (ely > 0) do begin
if (d < 0) then begin Inc(elx); Inc(dx, bb2); Inc(d, bb + dx); end;
Dec(ely); Dec(dy, aa2); Inc(d, aa - dy);
x := exc + elx; y := eyc + ely;
dorotate(exc, eyc, angle, x, y, Color);
x := exc - elx; y := eyc + ely;
dorotate(exc, eyc, angle, x, y, Color);
x := exc + elx; y := eyc - ely;
dorotate(exc, eyc, angle, x, y, Color);
x := exc - elx; y := eyc - ely;
dorotate(exc, eyc, angle, x, y, Color);
end;
end;
 
procedure TDirectDrawSurface.MirrorFlip(Value: TRenderMirrorFlipSet);
begin
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then
D2D.MirrorFlip := Value;
end;
 
{ TDXDrawDisplayMode }
 
function TDXDrawDisplayMode.GetBitCount: Integer;
5340,10 → 2736,10
FModes := TCollection.Create(TDXDrawDisplayMode);
FWidth := 640;
FHeight := 480;
FBitCount := 16;
FFixedBitCount := False; //True;
FBitCount := 8;
FFixedBitCount := True;
FFixedRatio := True;
FFixedSize := True; //False;
FFixedSize := False;
end;
 
destructor TDXDrawDisplay.Destroy;
5380,7 → 2776,7
function TDXDrawDisplay.GetMode: TDXDrawDisplayMode;
var
i: Integer;
ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
ddsd: TDDSurfaceDesc;
begin
Result := nil;
if FDXDraw.DDraw <> nil then
5444,16 → 2840,13
 
if FDXDraw.DDraw <> nil then
begin
FDXDraw.DDraw.DXResult := FDXDraw.DDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}
.EnumDisplayModes(0, {$IFDEF D3D_deprecated}PDDSurfaceDesc{$ELSE}PDDSurfaceDesc2{$ENDIF}(nil),
FDXDraw.DDraw.DXResult := FDXDraw.DDraw.IDraw.EnumDisplayModes(0, PDDSurfaceDesc(nil)^,
FModes, @EnumDisplayModesProc);
end else
begin
DDraw := TDirectDraw.Create(PGUID(FDXDraw.FDriver));
try
DDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}
.EnumDisplayModes(0, {$IFDEF D3D_deprecated}PDDSurfaceDesc{$ELSE}PDDSurfaceDesc2{$ENDIF}(nil),
FModes, @EnumDisplayModesProc);
DDraw.IDraw.EnumDisplayModes(0, PDDSurfaceDesc(nil)^, FModes, @EnumDisplayModesProc);
finally
DDraw.Free;
end;
5472,13 → 2865,12
end;
end;
 
function TDXDrawDisplay.SetSize(AWidth, AHeight, ABitCount{$IFNDEF D3D_deprecated}, ARefreshRate, AFlags{$ENDIF}: Integer): Boolean;
function TDXDrawDisplay.SetSize(AWidth, AHeight, ABitCount: Integer): Boolean;
begin
Result := False;
if FDXDraw.DDraw <> nil then
begin
FDXDraw.DDraw.DXResult := FDXDraw.DDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}
.SetDisplayMode(AWidth, AHeight, ABitCount{$IFNDEF D3D_deprecated}, ARefreshRate, AFlags{$ENDIF});
FDXDraw.DDraw.DXResult := FDXDraw.DDraw.IDraw.SetDisplayMode(AWidth, AHeight, ABitCount);
Result := FDXDraw.DDraw.DXResult = DD_OK;
 
if Result then
5492,13 → 2884,6
 
function TDXDrawDisplay.DynSetSize(AWidth, AHeight, ABitCount: Integer): Boolean;
 
{$IFNDEF D3D_deprecated}
function GetDefaultRefreshRate: Integer;
begin
Result := 60;
end;
{$ENDIF}
 
function TestBitCount(BitCount, ABitCount: Integer): Boolean;
begin
if (BitCount > 8) and (ABitCount > 8) then
5512,7 → 2897,7
 
function SetSize2(Ratio: Boolean): Boolean;
var
DWidth, DHeight, DBitCount{$IFNDEF D3D_deprecated}, DRRate, DFlags{$ENDIF}, i: Integer;
DWidth, DHeight, DBitCount, i: Integer;
Flag: Boolean;
begin
Result := False;
5520,10 → 2905,7
DWidth := Maxint;
DHeight := Maxint;
DBitCount := ABitCount;
{$IFNDEF D3D_deprecated}
DRRate := GetDefaultRefreshRate;
DFlags := 0;
{$ENDIF}
 
Flag := False;
for i := 0 to Count - 1 do
with Modes[i] do
5551,7 → 2933,7
DBitCount := ABitCount;
end;
 
Result := SetSize(DWidth, DHeight, DBitCount{$IFNDEF D3D_deprecated}, DRRate, DFlags{$ENDIF});
Result := SetSize(DWidth, DHeight, DBitCount);
end;
end;
 
5561,7 → 2943,7
if (AWidth <= 0) or (AHeight <= 0) or (not (ABitCount in [8, 16, 24, 32])) then Exit;
 
{ The change is attempted by the size of default. }
if SetSize(AWidth, AHeight, ABitCount{$IFNDEF D3D_deprecated}, GetDefaultRefreshRate, 0{$ENDIF}) then
if SetSize(AWidth, AHeight, ABitCount) then
begin
Result := True;
Exit;
5621,8 → 3003,8
begin
if ZBuffer <> nil then
begin
if (Surface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil) and (ZBuffer.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil) then
Surface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.DeleteAttachedSurface(0, ZBuffer.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF});
if (Surface.IDDSurface<>nil) and (ZBuffer.IDDSurface<>nil) then
Surface.ISurface.DeleteAttachedSurface(0, ZBuffer.IDDSurface);
ZBuffer.Free; ZBuffer := nil;
end;
end;
5629,12 → 3011,12
 
type
TInitializeDirect3DOption = (idoSelectDriver, idoOptimizeDisplayMode,
idoHardware, {$IFDEF D3DRM}idoRetainedMode,{$ENDIF} idoZBuffer);
idoHardware, idoRetainedMode, idoZBuffer);
 
TInitializeDirect3DOptions = set of TInitializeDirect3DOption;
 
procedure Direct3DInitializing(Options: TInitializeDirect3DOptions;
var BitCount: Integer; var Driver: PGUID; var DriverGUID: TGUID{$IFNDEF D3D_deprecated}; var D3DDeviceTypeSet: TD3DDeviceTypeSet{$ENDIF});
var BitCount: Integer; var Driver: PGUID; var DriverGUID: TGUID);
type
PDirect3DInitializingRecord = ^TDirect3DInitializingRecord;
TDirect3DInitializingRecord = record
5646,29 → 3028,19
Flag: Boolean;
DriverCaps: TDDCaps;
HELCaps: TDDCaps;
{$IFDEF D3D_deprecated}
HWDeviceDesc: TD3DDeviceDesc;
HELDeviceDesc: TD3DDeviceDesc;
DeviceDesc: TD3DDeviceDesc;
{$ELSE}
DeviceDesc: TD3DDeviceDesc7;
{$ENDIF}
 
D3DFlag: Boolean;
{$IFDEF D3D_deprecated}
HWDeviceDesc2: TD3DDeviceDesc;
HELDeviceDesc2: TD3DDeviceDesc;
DeviceDesc2: TD3DDeviceDesc;
{$ELSE}
DeviceDesc2: TD3DDeviceDesc7;
{$ENDIF}
end;
 
{$IFDEF D3D_deprecated}
function EnumDeviceCallBack(lpGuid: PGUID; // nil for the default device
lpDeviceDescription: PAnsiChar; lpDeviceName: PAnsiChar;
var lpD3DHWDeviceDesc: TD3DDeviceDesc;
var lpD3DHELDeviceDesc: TD3DDeviceDesc;
rec: PDirect3DInitializingRecord) : HResult; stdcall;
function EnumDeviceCallBack(const lpGuid: TGUID; lpDeviceDescription, lpDeviceName: PChar;
const lpD3DHWDeviceDesc, lpD3DHELDeviceDesc: TD3DDeviceDesc;
rec: PDirect3DInitializingRecord): HRESULT; stdcall;
 
procedure UseThisDevice;
begin
5686,8 → 3058,7
if idoOptimizeDisplayMode in rec.Options then
begin
if (lpD3DHWDeviceDesc.dwDeviceRenderBitDepth and (DDBD_16 or DDBD_24 or DDBD_32)) = 0 then Exit;
end
else
end else
begin
if (lpD3DHWDeviceDesc.dwDeviceRenderBitDepth and BPPToDDBD(rec.BitCount)) = 0 then Exit;
end;
5694,38 → 3065,12
 
UseThisDevice;
end;
{$ELSE}
function EnumDeviceCallBack(lpDeviceDescription: PAnsiChar; lpDeviceName: PAnsiChar;
const lpD3DDeviceDesc: TD3DDeviceDesc7; rec: PDirect3DInitializingRecord) : HResult; stdcall;
begin
Result := D3DENUMRET_OK;
 
maxVideoBlockSize := Min(lpD3DDeviceDesc.dwMaxTextureWidth, lpD3DDeviceDesc.dwMaxTextureHeight);
SurfaceDivWidth := lpD3DDeviceDesc.dwMaxTextureWidth;
SurfaceDivHeight := lpD3DDeviceDesc.dwMaxTextureHeight;
 
//if lpD3DHWDeviceDesc.dcmColorModel = 0 then Exit;
if idoOptimizeDisplayMode in rec.Options then
begin
if (lpD3DDeviceDesc.dwDeviceRenderBitDepth and (DDBD_16 or DDBD_24 or DDBD_32)) = 0 then Exit;
end
else
begin
if (lpD3DDeviceDesc.dwDeviceRenderBitDepth and BPPToDDBD(rec.BitCount)) = 0 then Exit;
end;
 
rec.D3DFlag := True;
rec.DeviceDesc2 := lpD3DDeviceDesc;
end;
{$ENDIF}
 
function EnumDirectDrawDriverCallback(lpGUID: PGUID; lpDriverDescription: {$IFDEF UNICODE}LPCTSTR{$ELSE}LPCSTR{$ENDIF};
lpDriverName: {$IFDEF UNICODE}LPCTSTR{$ELSE}LPCSTR{$ENDIF}; rec: PDirect3DInitializingRecord): HRESULT; stdcall;
function EnumDirectDrawDriverCallback(lpGUID: PGUID; lpDriverDescription: LPSTR;
lpDriverName: LPSTR; rec: PDirect3DInitializingRecord): HRESULT; stdcall;
var
DDraw: TDirectDraw;
{$IFDEF D3D_deprecated}
Direct3D: IDirect3D;
{$ENDIF}
Direct3D7: IDirect3D7;
 
function CountBitMask(i: DWORD; const Bits: array of DWORD): DWORD;
5778,19 → 3123,7
begin
{ The Direct3D driver is examined. }
rec.D3DFlag := False;
try
{$IFDEF D3D_deprecated}Direct3D{$ELSE}Direct3D7{$ENDIF}.EnumDevices(@EnumDeviceCallBack, rec) {= DD_OK}
except
on E: Exception do
begin
rec.D3DFlag := False;
// eventually catch exception to automatic log
Log(E.Message {$IFNDEF VER4UP}, ChangefileExt(ParamStr(0), '.log'){$ENDIF});
//and cannot continue !!!
Result := False;
Exit;
end;
end;
Direct3D.EnumDevices(@EnumDeviceCallBack, rec);
Result := rec.D3DFlag;
 
if not Result then Exit;
5798,20 → 3131,17
{ Comparison of DirectDraw driver. }
if not rec.Flag then
begin
{$IFDEF D3D_deprecated}
rec.HWDeviceDesc := rec.HWDeviceDesc2;
rec.HELDeviceDesc := rec.HELDeviceDesc2;
rec.DeviceDesc := rec.DeviceDesc2;
{$ENDIF}
rec.Flag := True;
end
else
end else
begin
{ Comparison of hardware. (One with large number of functions to support is chosen. }
Result := False;
 
if DDraw.DriverCaps.dwVidMemTotal < rec.DriverCaps.dwVidMemTotal then Exit;
{$IFDEF D3D_deprecated}
 
if CompareCountBitMask(DDraw.DriverCaps.ddscaps.dwCaps, rec.DriverCaps.ddscaps.dwCaps, [DDSCAPS_TEXTURE, DDSCAPS_ZBUFFER, DDSCAPS_MIPMAP]) +
CompareCountBit(rec.HWDeviceDesc.dpcLineCaps.dwMiscCaps, rec.HWDeviceDesc2.dpcLineCaps.dwMiscCaps) +
CompareCountBit(rec.HWDeviceDesc.dpcLineCaps.dwRasterCaps, rec.HWDeviceDesc2.dpcLineCaps.dwRasterCaps) +
5823,7 → 3153,7
CompareCountBit(rec.HWDeviceDesc.dpcLineCaps.dwTextureFilterCaps, rec.HWDeviceDesc2.dpcLineCaps.dwTextureFilterCaps) +
CompareCountBit(rec.HWDeviceDesc.dpcLineCaps.dwTextureBlendCaps, rec.HWDeviceDesc2.dpcLineCaps.dwTextureBlendCaps) +
CompareCountBit(rec.HWDeviceDesc.dpcLineCaps.dwTextureAddressCaps, rec.HWDeviceDesc2.dpcLineCaps.dwTextureAddressCaps) < 0 then Exit;
{$ENDIF}
 
Result := True;
end;
end;
5836,17 → 3166,10
if (DDraw.DriverCaps.dwCaps and DDCAPS_3D <> 0) and
(DDraw.DriverCaps.ddsCaps.dwCaps and DDSCAPS_TEXTURE <> 0) then
begin
try
if DDraw.IDDraw7 <> nil then
Direct3D7 := DDraw.IDraw7 as IDirect3D7
{$IFDEF D3D_deprecated}
else
Direct3D := DDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF} as IDirect3D
{$ENDIF};
except
on E: Exception do
log(E.Message {$IFNDEF VER4UP}, ChangefileExt(ParamStr(0), '.log'){$ENDIF});
end;
Direct3D := DDraw.IDraw as IDirect3D;
try
if FindDevice then
begin
5855,16 → 3178,13
 
if lpGUID = nil then
rec.Driver := nil
else
begin
else begin
rec.DriverGUID^ := lpGUID^;
rec.Driver^ := @rec.DriverGUID;
end;
end;
finally
{$IFDEF D3D_deprecated}
Direct3D := nil;
{$ENDIF}
Direct3D7 := nil;
end;
end;
5876,9 → 3196,6
var
rec: TDirect3DInitializingRecord;
DDraw: TDirectDraw;
{$IFNDEF D3D_deprecated}
devGUID: Tguid;
{$ENDIF}
begin
FillChar(rec, SizeOf(rec), 0);
rec.BitCount := BitCount;
5891,9 → 3208,8
rec.Options := Options;
rec.Driver := @Driver;
rec.DriverGUID := @DriverGUID;
DXDirectDrawEnumerate(@EnumDirectDrawDriverCallback, @rec);
end
else
DXDirectDrawEnumerate(@EnumDirectDrawDriverCallback, @rec)
end else
begin
DDraw := TDirectDraw.Create(Driver);
try
5901,13 → 3217,10
rec.HELCaps := DDraw.HELCaps;
 
rec.D3DFlag := False;
(DDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF} as IDirect3D).EnumDevices(@EnumDeviceCallBack, @rec);
(DDraw.IDraw as IDirect3D).EnumDevices(@EnumDeviceCallBack, @rec);
 
if rec.D3DFlag then
{$IFDEF D3D_deprecated}
rec.DeviceDesc := rec.DeviceDesc2;
{$ELSE}
rec.DeviceDesc := rec.DeviceDesc2;
{$ENDIF}
finally
DDraw.Free;
end;
5921,8 → 3234,7
begin
if rec.DeviceDesc.dwDeviceRenderBitDepth and DDBD_16 <> 0 then
rec.BitCount := 16
else
if rec.DeviceDesc.dwDeviceRenderBitDepth and DDBD_24 <> 0 then
else if rec.DeviceDesc.dwDeviceRenderBitDepth and DDBD_24<>0 then
rec.BitCount := 24
else if rec.DeviceDesc.dwDeviceRenderBitDepth and DDBD_32 <> 0 then
rec.BitCount := 32;
5929,30 → 3241,6
end;
end;
 
{test type of device}
{$IFNDEF D3D_deprecated}
D3DDeviceTypeSet := [];
 
Move(rec.DeviceDesc2.deviceGUID, devGUID, Sizeof(TGUID) );
 
if CompareMem(@devGUID, @IID_IDirect3DTnLHalDevice, Sizeof(TGUID)) then
D3DDeviceTypeSet := D3DDeviceTypeSet + [dtTnLHAL];
 
if CompareMem(@devGUID, @IID_IDirect3DHALDEVICE, Sizeof(TGUID)) then
D3DDeviceTypeSet := D3DDeviceTypeSet + [dtHAL];
 
if CompareMem(@devGUID, @IID_IDirect3DMMXDevice, Sizeof(TGUID)) then
D3DDeviceTypeSet := D3DDeviceTypeSet + [dtMMX];
 
if CompareMem(@devGUID, @IID_IDirect3DRGBDevice, Sizeof(TGUID)) then
D3DDeviceTypeSet := D3DDeviceTypeSet + [dtRGB];
 
if CompareMem(@devGUID, @IID_IDirect3DRampDevice, Sizeof(TGUID)) then
D3DDeviceTypeSet := D3DDeviceTypeSet + [dtRamp];
 
if CompareMem(@devGUID, @IID_IDirect3DRefDevice, Sizeof(TGUID)) then
D3DDeviceTypeSet := D3DDeviceTypeSet + [dtRef];
{$ENDIF}
BitCount := rec.BitCount;
end;
 
5962,21 → 3250,14
BitCount: Integer;
Driver: PGUID;
DriverGUID: TGUID;
{$IFNDEF D3D_deprecated}
D3DDeviceTypeSet: TD3DDeviceTypeSet;
{$ENDIF}
begin
BitCount := DXDraw.Display.BitCount;
Driver := DXDraw.Driver;
Direct3DInitializing(Options, BitCount, Driver, DriverGUID{$IFNDEF D3D_deprecated}, D3DDeviceTypeSet{$ENDIF});
Direct3DInitializing(Options, BitCount, Driver, DriverGUID);
DXDraw.Driver := Driver;
DXDraw.Display.BitCount := BitCount;
{$IFNDEF D3D_deprecated}
DXDraw.FDeviceTypeSet := D3DDeviceTypeSet;
{$ENDIF}
end;
 
{$IFDEF D3D_deprecated}
procedure InitializeDirect3D(Surface: TDirectDrawSurface;
var ZBuffer: TDirectDrawSurface;
out D3D: IDirect3D;
5985,7 → 3266,6
out D3DDevice: IDirect3DDevice;
out D3DDevice2: IDirect3DDevice2;
out D3DDevice3: IDirect3DDevice3;
{$IFDEF D3DRM}
var D3DRM: IDirect3DRM;
var D3DRM2: IDirect3DRM2;
var D3DRM3: IDirect3DRM3;
5995,7 → 3275,6
out Viewport: IDirect3DRMViewport;
var Scene: IDirect3DRMFrame;
var Camera: IDirect3DRMFrame;
{$ENDIF}
var NowOptions: TInitializeDirect3DOptions);
type
TInitializeDirect3DRecord = record
6023,11 → 3302,9
 
if DeviceDesc.dwDeviceZBufferBitDepth and DDBD_16 <> 0 then
ZBufferBitDepth := 16
else
if DeviceDesc.dwDeviceZBufferBitDepth and DDBD_24 <> 0 then
else if DeviceDesc.dwDeviceZBufferBitDepth and DDBD_24<>0 then
ZBufferBitDepth := 24
else
if DeviceDesc.dwDeviceZBufferBitDepth and DDBD_32 <> 0 then
else if DeviceDesc.dwDeviceZBufferBitDepth and DDBD_32<>0 then
ZBufferBitDepth := 32
else
ZBufferBitDepth := 0;
6062,6 → 3339,7
end;
end;
 
 
function EnumDeviceCallBack(const lpGuid: TGUID; lpDeviceDescription, lpDeviceName: PChar;
const lpD3DHWDeviceDesc, lpD3DHELDeviceDesc: TD3DDeviceDesc;
lpUserArg: Pointer): HRESULT; stdcall;
6144,10 → 3422,9
NowOptions := NowOptions + [idoZBuffer];
end;
end;
{$IFDEF D3DRM}
 
type
TDirect3DRMCreate = function(out lplpDirect3DRM: IDirect3DRM): HRESULT; stdcall;
{$ENDIF}
begin
try
Options := NowOptions;
6186,11 → 3463,12
SetRenderState(TD3DRenderStateType(D3DRENDERSTATE_ZENABLE), Ord(ZBuffer <> nil));
SetRenderState(TD3DRenderStateType(D3DRENDERSTATE_ZWRITEENABLE), Ord(ZBuffer <> nil));
end;
{$IFDEF D3DRM}
 
{ Direct3D Retained Mode}
if idoRetainedMode in Options then
begin
NowOptions := NowOptions + [idoRetainedMode];
 
if D3DRM = nil then
begin
if TDirect3DRMCreate(DXLoadLibrary('D3DRM.dll', 'Direct3DRMCreate'))(D3DRM) <> D3DRM_OK then
6235,7 → 3513,6
Surface.Width, Surface.Height, Viewport);
Viewport.SetBack(5000.0);
end;
{$ENDIF}
except
FreeZBufferSurface(Surface, ZBuffer);
D3D := nil;
6244,7 → 3521,6
D3DDevice := nil;
D3DDevice2 := nil;
D3DDevice3 := nil;
{$IFDEF D3DRM}
D3DRM := nil;
D3DRM2 := nil;
D3DRMDevice := nil;
6252,11 → 3528,9
Viewport := nil;
Scene := nil;
Camera := nil;
{$ENDIF}
raise;
end;
end;
{$ENDIF}
 
procedure InitializeDirect3D7(Surface: TDirectDrawSurface;
var ZBuffer: TDirectDrawSurface;
6279,7 → 3553,7
MemPosition: array[Boolean] of Integer = (DDSCAPS_SYSTEMMEMORY, DDSCAPS_VIDEOMEMORY);
var
ZBufferBitDepth: Integer;
ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
ddsd: TDDSurfaceDesc;
begin
Result := False;
FreeZBufferSurface(Surface, ZBuffer);
6298,27 → 3572,18
with ddsd do
begin
dwSize := SizeOf(ddsd);
Surface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetSurfaceDesc(ddsd);
Surface.ISurface.GetSurfaceDesc(ddsd);
dwFlags := DDSD_CAPS or DDSD_WIDTH or DDSD_HEIGHT or DDSD_ZBUFFERBITDEPTH;
ddsCaps.dwCaps := DDSCAPS_ZBUFFER or MemPosition[Hardware];
dwHeight := Surface.Height;
dwWidth := Surface.Width;
{$IFDEF D3D_deprecated}
dwZBufferBitDepth := ZBufferBitDepth;
{$ELSE}
ddpfPixelFormat.dwFlags := DDPF_ZBUFFER;
ddpfPixelFormat.dwZBufferBitDepth := ZBufferBitDepth;
ddpfPixelFormat.dwStencilBitDepth := 0;
ddpfPixelFormat.dwZBitMask := (1 shl ZBufferBitDepth) - 1;
ddpfPixelFormat.dwStencilBitMask := 0;
ddpfPixelFormat.dwLuminanceAlphaBitMask := 0;
{$ENDIF}
end;
 
ZBuffer := TDirectDrawSurface.Create(Surface.DDraw);
if ZBuffer.CreateSurface(ddsd) then
begin
if Surface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.AddAttachedSurface(ZBuffer.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}) <> DD_OK then
if Surface.ISurface.AddAttachedSurface(ZBuffer.ISurface)<>DD_OK then
begin
ZBuffer.Free; ZBuffer := nil;
Exit;
6406,9 → 3671,8
end;
 
begin
 
try
Options := NowOptions {$IFDEF D3DRM}- [idoRetainedMode]{$ENDIF};
Options := NowOptions - [idoRetainedMode];
NowOptions := [];
 
D3D7 := Surface.DDraw.IDraw7 as IDirect3D7;
6415,9 → 3679,11
 
{ Whether hardware can be used is tested. }
SupportHardware := (Surface.SurfaceDesc.ddsCaps.dwCaps and DDSCAPS_VIDEOMEMORY <> 0) and
(idoHardware in Options) and (Surface.DDraw.DriverCaps.dwCaps and DDCAPS_3D <> 0) and
(Surface.DDraw.DriverCaps.ddsCaps.dwCaps and DDSCAPS_TEXTURE <> 0);
(idoHardware in Options) and (Surface.DDraw.DriverCaps.dwCaps and DDCAPS_3D<>0);
 
if Surface.DDraw.DriverCaps.ddsCaps.dwCaps and DDSCAPS_TEXTURE=0 then
SupportHardware := False;
 
{ Direct3D }
InitDevice;
 
6437,8 → 3703,8
raise;
end;
end;
 
type
 
{ TDXDrawDriver }
 
TDXDrawDriver = class
6468,17 → 3734,6
procedure Initialize; override;
end;
 
procedure TCustomDXDraw.MirrorFlip(Value: TRenderMirrorFlipSet);
begin
if CheckD3 then
FD2D.MirrorFlip := Value;
end;
 
procedure TCustomDXDraw.SaveTextures(path: string);
begin
if CheckD3 then
FD2D.SaveTextures(path)
end;
{ TDXDrawDriver }
 
constructor TDXDrawDriver.Create(ADXDraw: TCustomDXDraw);
6489,8 → 3744,8
FDXDraw := ADXDraw;
 
{ Driver selection and Display mode optimizationn }
if FDXDraw.FOptions * [doFullScreen, doSystemMemory, {$IFDEF D3D_deprecated}do3D,{$ENDIF} doHardware] =
[doFullScreen, {$IFDEF D3D_deprecated}do3D,{$ENDIF} doHardware] then
if FDXDraw.FOptions*[doFullScreen, doSystemMemory, do3D, doHardware]=
[doFullScreen, do3D, doHardware] then
begin
AOptions := [];
with FDXDraw do
6499,7 → 3754,7
if not FDXDraw.Display.FixedBitCount then AOptions := AOptions + [idoOptimizeDisplayMode];
 
if doHardware in Options then AOptions := AOptions + [idoHardware];
{$IFDEF D3DRM}if doRetainedMode in Options then AOptions := AOptions + [idoRetainedMode];{$ENDIF}
if doRetainedMode in Options then AOptions := AOptions + [idoRetainedMode];
if doZBuffer in Options then AOptions := AOptions + [idoZBuffer];
end;
 
6507,14 → 3762,14
end;
 
if FDXDraw.Options * [doFullScreen, doHardware, doSystemMemory] = [doFullScreen, doHardware] then
FDXDraw.FDDraw := TDirectDraw.CreateEx(PGUID(FDXDraw.FDriver), {$IFDEF D3D_deprecated}doDirectX7Mode in FDXDraw.Options{$ELSE}True{$ENDIF})
FDXDraw.FDDraw := TDirectDraw.CreateEx(PGUID(FDXDraw.FDriver), doDirectX7Mode in FDXDraw.Options)
else
FDXDraw.FDDraw := TDirectDraw.CreateEx(nil, {$IFDEF D3D_deprecated}doDirectX7Mode in FDXDraw.Options{$ELSE}True{$ENDIF});
FDXDraw.FDDraw := TDirectDraw.CreateEx(nil, doDirectX7Mode in FDXDraw.Options);
end;
 
procedure TDXDrawDriver.Initialize3D;
const
DXDrawOptions3D = [doHardware, {$IFDEF D3DRM}doRetainedMode,{$ENDIF} doSelectDriver, doZBuffer];
DXDrawOptions3D = [doHardware, doRetainedMode, doSelectDriver, doZBuffer];
var
AOptions: TInitializeDirect3DOptions;
begin
6522,10 → 3777,10
with FDXDraw do
begin
if doHardware in FOptions then AOptions := AOptions + [idoHardware];
{$IFDEF D3DRM}if doRetainedMode in FNowOptions then AOptions := AOptions + [idoRetainedMode];{$ENDIF}
if doRetainedMode in FNowOptions then AOptions := AOptions + [idoRetainedMode];
if doSelectDriver in FOptions then AOptions := AOptions + [idoSelectDriver];
if doZBuffer in FOptions then AOptions := AOptions + [idoZBuffer];
{$IFDEF D3D_deprecated}
 
if doDirectX7Mode in FOptions then
begin
InitializeDirect3D7(FSurface, FZBuffer, FD3D7, FD3DDevice7, AOptions);
6532,17 → 3787,12
end else
begin
InitializeDirect3D(FSurface, FZBuffer, FD3D, FD3D2, FD3D3, FD3DDevice, FD3DDevice2, FD3DDevice3,
{$IFDEF D3DRM}
FD3DRM, FD3DRM2, FD3DRM3, FD3DRMDevice, FD3DRMDevice2, FD3DRMDevice3, FViewport, FScene, FCamera,
{$ENDIF}
AOptions);
FD3DRM, FD3DRM2, FD3DRM3, FD3DRMDevice, FD3DRMDevice2, FD3DRMDevice3, FViewport, FScene, FCamera, AOptions);
end;
{$ELSE}
InitializeDirect3D7(FSurface, FZBuffer, FD3D7, FD3DDevice7, AOptions);
{$ENDIF}
 
FNowOptions := FNowOptions - DXDrawOptions3D;
if idoHardware in AOptions then FNowOptions := FNowOptions + [doHardware];
{$IFDEF D3DRM}if idoRetainedMode in AOptions then FNowOptions := FNowOptions + [doRetainedMode];{$ENDIF}
if idoRetainedMode in AOptions then FNowOptions := FNowOptions + [doRetainedMode];
if idoSelectDriver in AOptions then FNowOptions := FNowOptions + [doSelectDriver];
if idoZBuffer in AOptions then FNowOptions := FNowOptions + [doZBuffer];
end;
6559,7 → 3809,6
begin
with FDXDraw do
begin
{$IFDEF D3DRM}
FViewport := nil;
FCamera := nil;
FScene := nil;
6567,21 → 3816,13
FD3DRMDevice := nil;
FD3DRMDevice2 := nil;
FD3DRMDevice3 := nil;
FD3DRM3 := nil;
FD3DRM2 := nil;
FD3DRM := nil;
{$ENDIF}
{$IFDEF D3D_deprecated}
FD3DDevice := nil;
FD3DDevice2 := nil;
FD3DDevice3 := nil;
{$ENDIF}
FD3DDevice7 := nil;
{$IFDEF D3D_deprecated}
FD3D := nil;
FD3D2 := nil;
FD3D3 := nil;
{$ENDIF}
FD3D7 := nil;
 
FreeZBufferSurface(FSurface, FZBuffer);
6591,6 → 3832,9
FSurface.Free; FSurface := nil;
FPrimary.Free; FPrimary := nil;
 
FD3DRM3 := nil;
FD3DRM2 := nil;
FD3DRM := nil;
end;
end;
 
6623,11 → 3867,8
if not AllowPalette256 then
begin
dc := GetDC(0);
try
GetSystemPaletteEntries(dc, 0, 256, Entries);
finally
ReleaseDC(0, dc);
end;
 
for i := 0 to 9 do
Result[i] := Entries[i];
6663,9 → 3904,8
end;
 
if doWaitVBlank in FDXDraw.NowOptions then
FDXDraw.FDDraw.DXResult := FDXDraw.FDDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);
FDXDraw.FDDraw.DXResult := FDXDraw.FDDraw.IDraw.WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);
 
FillChar(DF, SizeOf(DF), 0);
DF.dwsize := SizeOf(DF);
DF.dwDDFX := 0;
 
6673,7 → 3913,6
end;
 
procedure TDXDrawDriverBlt.Initialize;
{$IFDEF D3D_deprecated}
const
PrimaryDesc: TDDSurfaceDesc = (
dwSize: SizeOf(PrimaryDesc);
6680,20 → 3919,10
dwFlags: DDSD_CAPS;
ddsCaps: (dwCaps: DDSCAPS_PRIMARYSURFACE)
);
{$ENDIF}
var
Entries: TPaletteEntries;
PaletteCaps: Integer;
{$IFNDEF D3D_deprecated}
PrimaryDesc: TDDSurfaceDesc2;
{$ENDIF}
begin
{$IFNDEF D3D_deprecated}
FillChar(PrimaryDesc, SizeOf(PrimaryDesc), 0);
PrimaryDesc.dwSize := SizeOf(PrimaryDesc);
PrimaryDesc.dwFlags := DDSD_CAPS;
PrimaryDesc.ddsCaps.dwCaps := DDSCAPS_PRIMARYSURFACE;
{$ENDIF}
{ Surface making }
FDXDraw.FPrimary := TDirectDrawSurface.Create(FDXDraw.FDDraw);
if not FDXDraw.FPrimary.CreateSurface(PrimaryDesc) then
6723,9 → 3952,9
 
procedure TDXDrawDriverBlt.InitializeSurface;
var
ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
ddsd: TDDSurfaceDesc;
begin
FDXDraw.FSurface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := nil;
FDXDraw.FSurface.IDDSurface := nil;
 
{ Surface making }
FDXDraw.FNowOptions := FDXDraw.FNowOptions - [doSystemMemory];
6740,7 → 3969,7
ddsCaps.dwCaps := DDSCAPS_OFFSCREENPLAIN;
if doSystemMemory in FDXDraw.Options then
ddsCaps.dwCaps := ddsCaps.dwCaps or DDSCAPS_SYSTEMMEMORY;
{$IFDEF D3D_deprecated}if do3D in FDXDraw.FNowOptions then{$ENDIF}
if do3D in FDXDraw.FNowOptions then
ddsCaps.dwCaps := ddsCaps.dwCaps or DDSCAPS_3DDEVICE;
end;
 
6757,7 → 3986,7
FDXDraw.FSurface.Palette := FDXDraw.Palette;
FDXDraw.FSurface.Fill(0);
 
{$IFDEF D3D_deprecated}if do3D in FDXDraw.FNowOptions then{$ENDIF}
if do3D in FDXDraw.FNowOptions then
Initialize3D;
end;
 
6792,13 → 4021,12
procedure TDXDrawDriverFlip.Flip;
begin
if (FDXDraw.FForm <> nil) and (FDXDraw.FForm.Active) then
FDXDraw.FPrimary.DXResult := FDXDraw.FPrimary.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.Flip(nil, DDFLIP_WAIT)
FDXDraw.FPrimary.DXResult := FDXDraw.FPrimary.ISurface.Flip(nil, DDFLIP_WAIT)
else
FDXDraw.FPrimary.DXResult := 0;
end;
 
procedure TDXDrawDriverFlip.Initialize;
{$IFDEF D3D_deprecated}
const
DefPrimaryDesc: TDDSurfaceDesc = (
dwSize: SizeOf(DefPrimaryDesc);
6807,29 → 4035,16
ddsCaps: (dwCaps: DDSCAPS_PRIMARYSURFACE or DDSCAPS_FLIP or DDSCAPS_COMPLEX)
);
BackBufferCaps: TDDSCaps = (dwCaps: DDSCAPS_BACKBUFFER);
{$ENDIF}
var
PrimaryDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
PrimaryDesc: TDDSurfaceDesc;
PaletteCaps: Integer;
Entries: TPaletteEntries;
DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF};
{$IFNDEF D3D_deprecated}
BackBufferCaps: TDDSCaps2;
{$ENDIF}
DDSurface: IDirectDrawSurface;
begin
{ Surface making }
{$IFDEF D3D_deprecated}
PrimaryDesc := DefPrimaryDesc;
{$ELSE}
FillChar(PrimaryDesc, SizeOf(PrimaryDesc), 0);
PrimaryDesc.dwSize := SizeOf(PrimaryDesc);
PrimaryDesc.dwFlags := DDSD_CAPS or DDSD_BACKBUFFERCOUNT;
PrimaryDesc.dwBackBufferCount := 1;
PrimaryDesc.ddsCaps.dwCaps := DDSCAPS_PRIMARYSURFACE or DDSCAPS_FLIP or DDSCAPS_COMPLEX;
FillChar(BackBufferCaps, SizeOf(BackBufferCaps), 0);
BackBufferCaps.dwCaps := DDSCAPS_BACKBUFFER;
{$ENDIF}
{$IFDEF D3D_deprecated}if do3D in FDXDraw.FNowOptions then{$ENDIF}
 
if do3D in FDXDraw.FNowOptions then
PrimaryDesc.ddsCaps.dwCaps := PrimaryDesc.ddsCaps.dwCaps or DDSCAPS_3DDEVICE;
 
FDXDraw.FPrimary := TDirectDrawSurface.Create(FDXDraw.FDDraw);
6837,8 → 4052,8
raise EDXDrawError.CreateFmt(SCannotMade, [SDirectDrawPrimarySurface]);
 
FDXDraw.FSurface := TDirectDrawSurface.Create(FDXDraw.FDDraw);
if FDXDraw.FPrimary.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetAttachedSurface(BackBufferCaps, DDSurface) = DD_OK then
FDXDraw.FSurface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := DDSurface;
if FDXDraw.FPrimary.ISurface.GetAttachedSurface(BackBufferCaps, DDSurface)=DD_OK then
FDXDraw.FSurface.IDDSurface := DDSurface;
 
FDXDraw.FNowOptions := FDXDraw.FNowOptions - [doSystemMemory];
if FDXDraw.FSurface.SurfaceDesc.ddscaps.dwCaps and DDSCAPS_SYSTEMMEMORY <> 0 then
6860,9 → 4075,8
FDXDraw.FPrimary.Palette := FDXDraw.Palette;
FDXDraw.FSurface.Palette := FDXDraw.Palette;
 
{$IFDEF D3D_deprecated}if do3D in FDXDraw.FNowOptions then{$ENDIF}
if do3D in FDXDraw.FNowOptions then
Initialize3D;
 
end;
 
constructor TCustomDXDraw.Create(AOwner: TComponent);
6874,18 → 4088,14
inherited Create(AOwner);
FAutoInitialize := True;
FDisplay := TDXDrawDisplay.Create(Self);
{$IFDEF _DMO_}FAdapters := EnumDirectDrawDriversEx;{$ENDIF}
Options := [doAllowReboot, doWaitVBlank, doCenter, {$IFDEF D3D_deprecated}doDirectX7Mode, do3D,{$ENDIF}
doHardware, doSelectDriver];
 
Options := [doAllowReboot, doWaitVBlank, doCenter, doDirectX7Mode, doHardware, doSelectDriver];
 
FAutoSize := True;
 
dc := GetDC(0);
try
GetSystemPaletteEntries(dc, 0, 256, Entries);
finally
ReleaseDC(0, dc);
end;
 
ColorTable := PaletteEntriesToRGBQuads(Entries);
DefColorTable := ColorTable;
6893,11 → 4103,7
Width := 100;
Height := 100;
ParentColor := False;
Color := clBlack; //clBtnFace; // FIX
 
FD2D := TD2D.Create(Self);
D2D := FD2D; {as loopback}
FTraces := TTraces.Create(Self);
Color := clBtnFace;
end;
 
destructor TCustomDXDraw.Destroy;
6905,13 → 4111,8
Finalize;
NotifyEventList(dxntDestroying);
FDisplay.Free;
{$IFDEF _DMO_}FAdapters := nil;{$ENDIF}
FSubClass.Free; FSubClass := nil;
FNotifyEventList.Free;
FD2D.Free;
FD2D := nil;
D2D := nil;
FTraces.Free;
inherited Destroy;
end;
 
6920,13 → 4121,6
Result := EnumDirectDrawDrivers;
end;
 
{$IFDEF _DMO_}
class function TCustomDXDraw.DriversEx: TDirectXDriversEx;
begin
Result := EnumDirectDrawDriversEx;
end;
{$ENDIF}
 
type
PDXDrawNotifyEvent = ^TDXDrawNotifyEvent;
 
6989,7 → 4183,7
procedure FlipToGDISurface;
begin
if Initialized and (FNowOptions * [doFullScreen, doFlip] = [doFullScreen, doFlip]) then
DDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.FlipToGDISurface;
DDraw.IDraw.FlipToGDISurface;
end;
 
begin
7011,23 → 4205,6
Exit;
end;
end;
(*
WM_ACTIVATEAPP:
begin
if TWMActivateApp(Message).Active then
begin
FActive := True;
DoActivate;
// PostMessage(FHandle, CM_ACTIVATE, 0, 0)
end
else
begin
FActive := False;
DoDeactivate;
// PostMessage(FHandle, CM_DEACTIVATE, 0, 0);
end;
end;
*)
WM_ACTIVATE:
begin
if TWMActivate(Message).Active = WA_INACTIVE then
7041,25 → 4218,7
begin
Finalize;
end;
WM_ENTERSIZEMOVE:
begin
if not (csLoading in ComponentState) then
Finalize;
end;
WM_EXITSIZEMOVE:
begin
if not (csLoading in ComponentState) then
Initialize;
end;
// SW_RESTORE, SW_MAXIMIZE:
// begin
// {force finalize/initialize loop}
// if not AutoInitialize or not (csLoading in ComponentState) then begin
// Finalize;
// Initialize;
// end;
// end;
end;
DefWindowProc(Message);
end;
 
7075,26 → 4234,11
 
procedure TCustomDXDraw.DoInitialize;
begin
{$IFDEF _DMO_}
{erase items for following refresh}
if Assigned(FAdapters) then FAdapters.Clear;
EnumDirectDrawDriversEx;
{$ENDIF}
if Assigned(FOnInitialize) then FOnInitialize(Self);
{$IFNDEF DXR_deprecated}
{$IFDEF D3D_deprecated}
if not (do3D in Options) then
Options := Options + [do3D];
{$ENDIF}
{$ENDIF}
end;
 
procedure TCustomDXDraw.DoInitializeSurface;
begin
{.06 added for better initialization}
if Assigned(FD2D) then
RenderError := FD2D.D2DInitializeSurface;
 
if Assigned(FOnInitializeSurface) then FOnInitializeSurface(Self);
end;
 
7150,10 → 4294,6
FUpdating := False;
end;
end;
if AsSigned(FD2D) then
FD2D.Free;
FD2D := nil;
D2D := nil
end;
 
procedure TCustomDXDraw.Flip;
7160,21 → 4300,14
begin
if Initialized and (not FUpdating) then
begin
if TryRestore and (not RenderError) then
if TryRestore then
TDXDrawDriver(FDXDrawDriver).Flip;
end;
RenderError := false;
end;
 
function TCustomDXDraw.GetCanDraw: Boolean;
begin
{$IFNDEF DXR_deprecated}
{$IFDEF D3D_deprecated}
if not (do3D in Options) then
Options := Options + [do3D];
{$ENDIF}
{$ENDIF}
Result := Initialized and (not FUpdating) and (Surface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil) and
Result := Initialized and (not FUpdating) and (Surface.IDDSurface<>nil) and
TryRestore;
end;
 
7186,7 → 4319,7
 
function TCustomDXDraw.GetSurfaceHeight: Integer;
begin
if Surface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
if Surface.IDDSurface<>nil then
Result := Surface.Height
else
Result := FSurfaceHeight;
7194,7 → 4327,7
 
function TCustomDXDraw.GetSurfaceWidth: Integer;
begin
if Surface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
if Surface.IDDSurface<>nil then
Result := Surface.Width
else
Result := FSurfaceWidth;
7284,11 → 4417,6
Dec(FOffNotifyRestore);
end;
 
if not Assigned(FD2D) then begin
FD2D := TD2D.Create(Self);
D2D := FD2D; {as loopback}
end;
 
Restore;
end;
 
7346,11 → 4474,9
Result := False;
end;
 
procedure TCustomDXDraw.Render(LagCount: Integer{$IFDEF VER4UP} = 0{$ENDIF});
var I: Integer;
procedure TCustomDXDraw.Render;
begin
{$IFDEF D3DRM}
if FInitialized and {$IFDEF D3D_deprecated}(do3D in FNowOptions) and{$ENDIF} (doRetainedMode in FNowOptions) then
if FInitialized and (do3D in FNowOptions) and (doRetainedMode in FNowOptions) then
begin
asm FInit end;
FViewport.Clear;
7358,15 → 4484,6
FD3DRMDevice.Update;
asm FInit end;
end;
{$ENDIF}
{traces}
if FTraces.Count > 0 then
for I := 0 to FTraces.Count - 1 do
if FTraces.Items[I].Active then
FTraces.Items[I].Render(LagCount);
{own rendering event}
if Assigned(FOnRender) then
FOnRender(Self);
end;
 
procedure TCustomDXDraw.Restore;
7408,255 → 4525,6
SetSize(AWidth, AHeight);
end;
 
procedure TCustomDXDraw.BeginScene;
begin
if CheckD3 then
FD2D.BeginScene
end;
 
procedure TCustomDXDraw.EndScene;
begin
if CheckD3 then
FD2D.EndScene
end;
 
function TCustomDXDraw.CheckD3: Boolean;
begin
Result := {$IFDEF D3D_deprecated}(do3D in Options) and{$ENDIF} (doHardware in Options) and AsSigned(FD2D);
end;
 
function TCustomDXDraw.CheckD3D(Dest: TDirectDrawSurface): Boolean;
begin
Result := CheckD3 and (FD2D.FDDraw.FSurface = Dest)
end;
 
procedure TCustomDXDraw.ClearStack;
begin
if CheckD3 then
FD2D.D2DTextures.D2DPruneAllTextures;
end;
 
procedure TCustomDXDraw.UpdateTextures;
var Changed: Boolean;
begin
if CheckD3 then begin
if Assigned(FOnUpdateTextures) then begin
Changed := False;
FOnUpdateTextures(FD2D.FD2DTexture, Changed);
if Changed then FD2D.D2DUpdateTextures;
end
end;
end;
 
procedure TCustomDXDraw.TextureFilter(Grade: TD2DTextureFilter);
begin
if CheckD3 then
FD2D.TextureFilter := Grade;
end;
 
procedure TCustomDXDraw.AntialiasFilter(Grade: TD3DAntialiasMode);
begin
if CheckD3 then
FD2D.AntialiasFilter := Grade;
end;
 
// ***** fade effects
// do not use in dxtimer cycle
 
function TCustomDXDraw.Fade2Color(colorfrom, colorto: LongInt): LongInt;
var i, r1, r2, g1, g2, b1, b2: Integer;
begin
r1 := GetRValue(colorfrom);
r2 := GetRValue(colorto);
g1 := GetGValue(colorfrom);
g2 := GetGValue(colorto);
b1 := GetBValue(colorfrom);
b2 := GetBValue(colorto);
if r1 < r2 then
begin
for i := r1 to r2 do
begin
Surface.Fill(RGB(i, g1, b1));
Flip;
end;
end
else
begin
for i := r1 downto r2 do
begin
Surface.Fill(RGB(i, g1, b1));
Flip;
end;
end;
 
if g1 < g2 then
begin
for i := g1 to g2 do
begin
Surface.Fill(RGB(r2, i, b1));
Flip;
end;
end
else
begin
for i := g1 downto g2 do
begin
Surface.Fill(RGB(r2, i, b1));
Flip;
end;
end;
if b1 < b2 then
begin
for i := b1 to b2 do
begin
Surface.Fill(RGB(r2, g2, i));
Flip;
end;
end
else
begin
for i := b1 downto b2 do
begin
Surface.Fill(RGB(r2, g2, i));
Flip;
end;
end;
Result := colorto;
end;
 
function TCustomDXDraw.Fade2Black(colorfrom: LongInt): LongInt;
var i, r, g, b: Integer;
begin
r := GetRValue(colorfrom);
g := GetGValue(colorfrom);
b := GetBValue(colorfrom);
for i := r downto 0 do
begin
Surface.Fill(RGB(i, g, b));
Flip;
end;
for i := g downto 0 do
begin
Surface.Fill(RGB(0, i, b));
Flip;
end;
for i := g downto 0 do
begin
Surface.Fill(RGB(0, 0, i));
Flip;
end;
Result := 0;
end;
 
function TCustomDXDraw.Fade2White(colorfrom: LongInt): LongInt;
var i, r, g, b: Integer;
begin
r := GetRValue(colorfrom);
g := GetGValue(colorfrom);
b := GetBValue(colorfrom);
for i := r to 255 do
begin
Surface.Fill(RGB(i, g, b));
Flip;
end;
for i := g to 255 do
begin
Surface.Fill(RGB(255, i, b));
Flip;
end;
for i := b to 255 do
begin
Surface.Fill(RGB(255, 255, i));
Flip;
end;
Result := RGB(255, 255, 255);
end;
 
function TCustomDXDraw.Grey2Fade(shadefrom, shadeto: Integer): Integer;
var i: Integer;
begin
if shadefrom < shadeto then
begin
for i := shadefrom to shadeto do
begin
Surface.Fill(RGB(i, i, i));
Flip;
end;
end
else
begin
for i := shadefrom downto shadeto do
begin
Surface.Fill(RGB(i, i, i));
Flip;
end;
end;
Result := shadeto;
end;
 
function TCustomDXDraw.FadeGrey2Screen(oldcolor, newcolour: LongInt): LongInt;
begin
result := Grey2Fade(oldcolor, newcolour);
end;
 
function TCustomDXDraw.Fade2Screen(oldcolor, newcolour: LongInt): LongInt;
begin
result := Fade2Color(oldcolor, newcolour);
end;
 
function TCustomDXDraw.White2Screen(oldcolor: Integer): LongInt;
begin
result := Fade2Color(oldcolor, RGB(255, 255, 255));
end;
 
function TCustomDXDraw.Black2Screen(oldcolor: Integer): LongInt;
begin
result := Fade2Color(oldcolor, RGB(0, 0, 0));
end;
 
procedure TCustomDXDraw.GrabImage(iX, iY, iWidth, iHeight: Integer; ddib: TDIB);
var ts, td: trect;
begin
ddib.SetSize(iWidth, iHeight, 24);
ts.left := iX;
ts.top := iY;
ts.right := iX + iWidth - 1;
ts.bottom := iY + iHeight - 1;
td.left := 0;
td.top := 0;
td.right := iWidth;
td.bottom := iHeight;
with Surface.Canvas do
begin
ddib.Canvas.CopyRect(td, Surface.Canvas, ts);
Release;
end;
end;
 
procedure TCustomDXDraw.PasteImage(sdib: TDIB; x, y: Integer);
var
ts, td: trect;
w, h: Integer;
begin
w := sdib.width - 1;
h := sdib.height - 1;
ts.left := 0;
ts.top := 0;
ts.right := w;
ts.bottom := h;
td.left := x;
td.top := y;
td.right := x + w;
td.bottom := y + h;
with Surface.Canvas do
begin
CopyRect(td, sdib.Canvas, ts);
release;
end;
end;
 
// *****
 
procedure TCustomDXDraw.SetColorTable(const ColorTable: TRGBQuads);
var
Entries: TPaletteEntries;
7680,15 → 4548,15
 
if doFullScreen in FNowOptions then
begin
Flags := DDSCL_FULLSCREEN or DDSCL_EXCLUSIVE or DDSCL_ALLOWMODEX{$IFDEF DXDOUBLEPRECISION} or DDSCL_FPUPRESERVE{$ENDIF};
Flags := DDSCL_FULLSCREEN or DDSCL_EXCLUSIVE or DDSCL_ALLOWMODEX;
if doNoWindowChange in FNowOptions then
Flags := Flags or DDSCL_NOWINDOWCHANGES;
if doAllowReboot in FNowOptions then
Flags := Flags or DDSCL_ALLOWREBOOT;
end else
Flags := DDSCL_NORMAL{$IFDEF DXDOUBLEPRECISION} or DDSCL_FPUPRESERVE{$ENDIF};
Flags := DDSCL_NORMAL;
 
DDraw.DXResult := DDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.SetCooperativeLevel(Control.Handle, Flags);
DDraw.DXResult := DDraw.IDraw.SetCooperativeLevel(Control.Handle, Flags);
end;
 
procedure TCustomDXDraw.SetDisplay(Value: TDXDrawDisplay);
7708,10 → 4576,9
 
procedure TCustomDXDraw.SetOptions(Value: TDXDrawOptions);
const
InitOptions = [doFullScreen, doNoWindowChange, doAllowReboot,
doAllowPalette256, doSystemMemory, doFlip,
{$IFDEF D3D_deprecated}doDirectX7Mode, do3D,{$ENDIF}{$IFDEF D3DRM} doRetainedMode, {$ENDIF}
doHardware, doSelectDriver, doZBuffer];
InitOptions = [doDirectX7Mode, doFullScreen, doNoWindowChange, doAllowReboot,
doAllowPalette256, doSystemMemory, doFlip, do3D,
doRetainedMode, doHardware, doSelectDriver, doZBuffer];
var
OldOptions: TDXDrawOptions;
begin
7721,10 → 4588,9
begin
OldOptions := FNowOptions;
FNowOptions := FNowOptions * InitOptions + (FOptions - InitOptions);
{$IFDEF D3D_deprecated}
 
if not (do3D in FNowOptions) then
FNowOptions := FNowOptions - [doHardware, {$IFDEF D3DRM}doRetainedMode,{$ENDIF} doSelectDriver, doZBuffer];
{$ENDIF}
FNowOptions := FNowOptions - [doHardware, doRetainedMode, doSelectDriver, doZBuffer];
end else
begin
FNowOptions := FOptions;
7731,16 → 4597,16
 
if not (doFullScreen in FNowOptions) then
FNowOptions := FNowOptions - [doNoWindowChange, doAllowReBoot, doAllowPalette256, doFlip];
{$IFDEF D3D_deprecated}
 
if not (do3D in FNowOptions) then
FNowOptions := FNowOptions - [doDirectX7Mode, {$IFDEF D3DRM}doRetainedMode,{$ENDIF} doHardware, doSelectDriver, doZBuffer];
{$ENDIF}
FNowOptions := FNowOptions - [doDirectX7Mode, doRetainedMode, doHardware, doSelectDriver, doZBuffer];
 
if doSystemMemory in FNowOptions then
FNowOptions := FNowOptions - [doFlip];
{$IFDEF D3DRM}
 
if doDirectX7Mode in FNowOptions then
FNowOptions := FNowOptions - [doRetainedMode];
{$ENDIF}
 
FNowOptions := FNowOptions - [doHardware];
end;
end;
7811,30 → 4677,24
begin
Result := False;
 
if Initialized and (not FUpdating) and (Primary.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil) then
if Initialized and (not FUpdating) and (Primary.IDDSurface<>nil) then
begin
if (Primary.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.IsLost = DDERR_SURFACELOST) or
(Surface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.IsLost = DDERR_SURFACELOST) then
if (Primary.ISurface.IsLost=DDERR_SURFACELOST) or
(Surface.ISurface.IsLost=DDERR_SURFACELOST) then
begin
if Assigned(FD2D) and Assigned(FD2D.FD2DTexture) then FD2D.FD2DTexture.D2DPruneAllTextures;//<-Add Mr.Kawasaki
Restore;
Result := (Primary.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.IsLost = DD_OK) and (Surface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.IsLost = DD_OK);
Result := (Primary.ISurface.IsLost=DD_OK) and (Surface.ISurface.IsLost=DD_OK);
end else
Result := True;
end;
end;
 
procedure TCustomDXDraw.SetTraces(const Value: TTraces);
begin
FTraces.Assign(Value);
end;
 
procedure TCustomDXDraw.UpdatePalette;
begin
if Initialized and (doWaitVBlank in FNowOptions) then
begin
if FDDraw.FDriverCaps.dwPalCaps and DDPCAPS_VSYNC = 0 then
FDDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);
FDDraw.IDraw.WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);
end;
 
SetColorTable(ColorTable);
7851,8 → 4711,6
end;
end;
 
{$IFDEF DX3D_deprecated}
 
{ TCustomDX3D }
 
constructor TCustomDX3D.Create(AOwner: TComponent);
7893,7 → 4751,7
FInitialized := False;
 
SetOptions(FOptions);
{$IFDEF D3DRM}
 
FViewport := nil;
FCamera := nil;
FScene := nil;
7901,28 → 4759,22
FD3DRMDevice := nil;
FD3DRMDevice2 := nil;
FD3DRMDevice3 := nil;
{$ENDIF}
{$IFDEF D3D_deprecated}
FD3DDevice := nil;
FD3DDevice2 := nil;
FD3DDevice3 := nil;
{$ENDIF}
FD3DDevice7 := nil;
{$IFDEF D3D_deprecated}
FD3D := nil;
FD3D2 := nil;
FD3D3 := nil;
{$ENDIF}
FD3D7 := nil;
 
FreeZBufferSurface(FSurface, FZBuffer);
 
FSurface.Free; FSurface := nil;
{$IFDEF D3DRM}
 
FD3DRM3 := nil;
FD3DRM2 := nil;
FD3DRM := nil;
{$ENDIF}
end;
end;
end;
7969,8 → 4821,7
end else
begin
InitializeDirect3D(FSurface, FZBuffer, FD3D, FD3D2, FD3D3, FD3DDevice, FD3DDevice2, FD3DDevice3,
{$IFDEF D3DRM}FD3DRM, FD3DRM2, FD3DRM3, FD3DRMDevice, FD3DRMDevice2, FD3DRMDevice3, FViewport, FScene, FCamera, {$ENDIF}
AOptions);
FD3DRM, FD3DRM2, FD3DRM3, FD3DRMDevice, FD3DRMDevice2, FD3DRMDevice3, FViewport, FScene, FCamera, AOptions);
end;
 
FNowOptions := [];
7989,7 → 4840,6
 
procedure TCustomDX3D.Render;
begin
{$IFDEF D3DRM}
if FInitialized and (toRetainedMode in FNowOptions) then
begin
asm FInit end;
7998,7 → 4848,6
FD3DRMDevice.Update;
asm FInit end;
end;
{$ENDIF}
end;
 
function TCustomDX3D.GetCanDraw: Boolean;
8155,8 → 5004,6
end;
end;
 
{$ENDIF}
 
{ TDirect3DTexture }
 
constructor TDirect3DTexture.Create(Graphic: TGraphic; DXDraw: TComponent);
8181,15 → 5028,12
begin
with (FDXDraw as TCustomDXDraw) do
begin
if (not Initialized) {$IFDEF D3D_deprecated}or (not (do3D in NowOptions)){$ENDIF} then
if (not Initialized) or (not (do3D in NowOptions)) then
raise EDirect3DTextureError.CreateFmt(SNotMade, [FDXDraw.ClassName]);
end;
FSurface := TDirectDrawSurface.Create((FDXDraw as TCustomDXDraw).Surface.DDraw);
(FDXDraw as TCustomDXDraw).RegisterNotifyEvent(DXDrawNotifyEvent);
end
else
{$IFDEF DX3D_deprecated}
if FDXDraw is TCustomDX3D then
end else if FDXDraw is TCustomDX3D then
begin
with (FDXDraw as TDX3D) do
begin
8200,7 → 5044,6
FSurface := TDirectDrawSurface.Create((FDXDraw as TCustomDX3D).Surface.DDraw);
(FDXDraw as TCustomDX3D).FDXDraw.RegisterNotifyEvent(DXDrawNotifyEvent);
end else
{$ENDIF}
raise EDirect3DTextureError.CreateFmt(SNotSupported, [FDXDraw.ClassName]);
end;
 
8209,13 → 5052,11
if FDXDraw is TCustomDXDraw then
begin
(FDXDraw as TCustomDXDraw).UnRegisterNotifyEvent(DXDrawNotifyEvent);
end
{$IFDEF DX3D_deprecated}
else if FDXDraw is TCustomDX3D then
end else if FDXDraw is TCustomDX3D then
begin
(FDXDraw as TCustomDX3D).FDXDraw.UnRegisterNotifyEvent(DXDrawNotifyEvent);
end
{$ENDIF};
end;
 
Clear;
FSurface.Free;
inherited Destroy;
8225,7 → 5066,7
begin
FHandle := 0;
FTexture := nil;
FSurface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := nil;
FSurface.IDDSurface := nil;
end;
 
function TDirect3DTexture.GetHandle: TD3DTextureHandle;
8242,7 → 5083,7
Result := FSurface;
end;
 
function TDirect3DTexture.GetTexture: {$IFDEF D3D_deprecated}IDirect3DTexture{$ELSE}IDirect3DTexture2{$ENDIF};
function TDirect3DTexture.GetTexture: IDirect3DTexture;
begin
if FTexture = nil then
Restore;
8332,12 → 5173,12
end;
 
var
ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
ddsd: TDDSurfaceDesc;
Palette: TDirectDrawPalette;
PaletteCaps: Integer;
TempSurface: TDirectDrawSurface;
Width2, Height2: Integer;
D3DDevice: {$IFDEF D3D_deprecated}IDirect3DDevice{$ELSE}IDirect3DDevice7{$ENDIF};
D3DDevice: IDirect3DDevice;
Hardware: Boolean;
DDraw: TDirectDraw;
begin
8348,17 → 5189,14
if FDXDraw is TCustomDXDraw then
begin
DDraw := (FDXDraw as TCustomDXDraw).DDraw;
D3DDevice := (FDXDraw as TCustomDXDraw).{$IFDEF D3D_deprecated}D3DDevice{$ELSE}D3DDevice7{$ENDIF};
D3DDevice := (FDXDraw as TCustomDXDraw).D3DDevice;
Hardware := doHardware in (FDXDraw as TCustomDXDraw).NowOptions;
end
{$IFDEF DX3D_deprecated}
else if FDXDraw is TCustomDX3D then
end else if FDXDraw is TCustomDX3D then
begin
DDraw := (FDXDraw as TCustomDX3D).Surface.DDraw;
D3DDevice := (FDXDraw as TCustomDX3D).D3DDevice;
Hardware := toHardware in (FDXDraw as TCustomDX3D).NowOptions;
end
{$ENDIF};
end;
 
if (DDraw = nil) or (D3DDevice = nil) then Exit;
 
8446,13 → 5284,13
end;
 
{ Source surface is loaded into surface. }
FTexture := FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF} as {$IFDEF D3D_deprecated}IDirect3DTexture{$ELSE}IDirect3DTexture2{$ENDIF};
FTexture.Load(TempSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF} as {$IFDEF D3D_deprecated}IDirect3DTexture{$ELSE}IDirect3DTexture2{$ENDIF});
FTexture := FSurface.ISurface as IDirect3DTexture;
FTexture.Load(TempSurface.ISurface as IDirect3DTexture);
finally
TempSurface.Free;
end;
 
if FTexture.GetHandle(D3DDevice as {$IFDEF D3D_deprecated}IDirect3DDevice{$ELSE}IDirect3DDevice2{$ENDIF}, FHandle) <> D3D_OK then
if FTexture.GetHandle(D3DDevice, FHandle)<>D3D_OK then
raise EDirect3DTextureError.CreateFmt(SCannotMade, [STexture]);
 
FSurface.TransparentColor := FSurface.ColorMatch(FTransparentColor);
8489,11 → 5327,9
 
if FSrcImage is TDXTextureImage then
FImage := TDXTextureImage(FSrcImage)
else
if FSrcImage is TDIB then
else if FSrcImage is TDIB then
SetDIB(TDIB(FSrcImage))
else
if FSrcImage is TGraphic then
else if FSrcImage is TGraphic then
begin
FSrcImage := TDIB.Create;
try
8504,8 → 5340,7
Graphic.Free;
FAutoFreeGraphic := True;
end;
end
else
end else
if FSrcImage is TPicture then
begin
FSrcImage := TDIB.Create;
8517,8 → 5352,7
Graphic.Free;
FAutoFreeGraphic := True;
end;
end
else
end else
raise Exception.CreateFmt(SCannotLoadGraphic, [Graphic.ClassName]);
 
FMipmap := FImage.SubGroupImageCount[DXTextureImageGroupType_Mipmap] > 0;
8680,17 → 5514,6
FImage := FImage2;
end;
 
function TDirect3DTexture2.GetHeight: Integer;
begin
if Assigned(FImage) then
Result := FImage.Height
else
if Assigned(FImage2) then
Result := FImage2.Height
else
Result := 0;
end;
 
function TDirect3DTexture2.GetIsMipmap: Boolean;
begin
if FSurface <> nil then
8714,17 → 5537,6
Result := FTransparent;
end;
 
function TDirect3DTexture2.GetWidth: Integer;
begin
if Assigned(FImage) then
Result := FImage.Width
else
if Assigned(FImage2) then
Result := FImage2.Width
else
Result := 0;
end;
 
procedure TDirect3DTexture2.SetTransparent(Value: Boolean);
begin
if FTransparent <> Value then
8910,9 → 5722,9
Width, Height: Integer;
PaletteCaps: DWORD;
Palette: IDirectDrawPalette;
{$IFDEF D3D_deprecated}TempD3DDevDesc: TD3DDeviceDesc;{$ENDIF}
TempD3DDevDesc: TD3DDeviceDesc;
D3DDevDesc7: TD3DDeviceDesc7;
TempSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface4{$ELSE}IDirectDrawSurface7{$ENDIF};
TempSurface: IDirectDrawSurface4;
begin
Finalize;
try
8923,14 → 5735,12
FD3DDevDesc.dpcTriCaps.dwTextureCaps := D3DDevDesc7.dpcTriCaps.dwTextureCaps;
FD3DDevDesc.dwMinTextureWidth := D3DDevDesc7.dwMinTextureWidth;
FD3DDevDesc.dwMaxTextureWidth := D3DDevDesc7.dwMaxTextureWidth;
end
{$IFDEF D3D_deprecated}
else
end else
begin
FD3DDevDesc.dwSize := SizeOf(FD3DDevDesc);
TempD3DDevDesc.dwSize := SizeOf(TempD3DDevDesc);
FDXDraw.D3DDevice3.GetCaps(FD3DDevDesc, TempD3DDevDesc);
end{$ENDIF};
end;
 
if FImage <> nil then
begin
8940,8 → 5750,7
{ The size of the texture is only Sqr(n). }
Width := Max(1 shl GetBitCount(FImage.Width), 1);
Height := Max(1 shl GetBitCount(FImage.Height), 1);
end
else
end else
begin
Width := FImage.Width;
Height := FImage.Height;
8970,8 → 5779,8
FEnumTextureFormatFlag := False;
if FDXDraw.D3DDevice7 <> nil then
FDXDraw.D3DDevice7.EnumTextureFormats(@EnumTextureFormatCallback, Self)
{$IFDEF D3D_deprecated}else
FDXDraw.D3DDevice3.EnumTextureFormats(@EnumTextureFormatCallback, Self){$ENDIF};
else
FDXDraw.D3DDevice3.EnumTextureFormats(@EnumTextureFormatCallback, Self);
 
if not FEnumTextureFormatFlag then
raise EDirect3DTextureError.CreateFmt(SCannotInitialized, [STexture]);
9005,10 → 5814,10
end;
 
FSurface := TDirectDrawSurface.Create(FDXDraw.DDraw);
FSurface.DDraw.DXResult := FSurface.DDraw.{$IFDEF D3D_deprecated}IDraw4{$ELSE}IDraw7{$ENDIF}.CreateSurface(FTextureFormat, TempSurface, nil);
FSurface.DDraw.DXResult := FSurface.DDraw.IDraw4.CreateSurface(FTextureFormat, TempSurface, nil);
if FSurface.DDraw.DXResult <> DD_OK then
raise EDirect3DTextureError.CreateFmt(SCannotInitialized, [STexture]);
FSurface.{$IFDEF D3D_deprecated}IDDSurface4{$ELSE}IDDSurface7{$ENDIF} := TempSurface;
FSurface.IDDSurface4 := TempSurface;
 
{ Palette making }
if (FImage <> nil) and (FTextureFormat.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED <> 0) then
9015,14 → 5824,11
begin
if FTextureFormat.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED8 <> 0 then
PaletteCaps := DDPCAPS_8BIT or DDPCAPS_ALLOW256
else
if FTextureFormat.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED4 <> 0 then
else if FTextureFormat.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED4<>0 then
PaletteCaps := DDPCAPS_4BIT
else
if FTextureFormat.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED2 <> 0 then
else if FTextureFormat.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED2<>0 then
PaletteCaps := DDPCAPS_2BIT
else
if FTextureFormat.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED1 <> 0 then
else if FTextureFormat.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED1<>0 then
PaletteCaps := DDPCAPS_1BIT
else
PaletteCaps := 0;
9029,10 → 5835,10
 
if PaletteCaps <> 0 then
begin
if FDXDraw.DDraw.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.CreatePalette(PaletteCaps, @FImage.idx_palette, Palette, nil) <> 0 then
if FDXDraw.DDraw.IDraw.CreatePalette(PaletteCaps, @FImage.idx_palette, Palette, nil)<>0 then
Exit;
 
FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.SetPalette(Palette);
FSurface.ISurface.SetPalette(Palette);
end;
end;
 
9047,7 → 5853,7
const
MipmapCaps: TDDSCaps2 = (dwCaps: DDSCAPS_TEXTURE or DDSCAPS_MIPMAP);
var
CurSurface, NextSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface4{$ELSE}IDirectDrawSurface7{$ENDIF};
CurSurface, NextSurface: IDirectDrawSurface4;
Index: Integer;
SrcImage: TDXTextureImage;
begin
9055,7 → 5861,7
Initialize;
 
FNeedLoadTexture := False;
if FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.IsLost = DDERR_SURFACELOST then
if FSurface.ISurface.IsLost=DDERR_SURFACELOST then
FSurface.Restore;
 
{ Color key setting. }
9067,7 → 5873,7
if FSrcImage is TDIB then
SetDIB(TDIB(FSrcImage));
 
CurSurface := FSurface.{$IFDEF D3D_deprecated}ISurface4{$ELSE}ISurface7{$ENDIF};
CurSurface := FSurface.ISurface4;
Index := 0;
while CurSurface <> nil do
begin
9088,8 → 5894,7
 
Inc(Index);
end;
end
else
end else
DoRestoreSurface;
end;
 
9108,8 → 5913,7
begin
{ Palette index }
ck.dwColorSpaceLowValue := FTransparentColor and $FF;
end
else
end else
if FImage <> nil then
begin
{ RGB value }
9116,8 → 5920,7
ck.dwColorSpaceLowValue := FImage.PaletteIndex(GetRValue(FTransparentColor), GetGValue(FTransparentColor), GetBValue(FTransparentColor));
end else
Exit;
end
else
end else
begin
if (FImage <> nil) and (FImage.ImageType = DXTextureImageType_PaletteIndexedColor) and (FTransparentColor shr 24 = $01) then
begin
9126,8 → 5929,7
dxtEncodeChannel(dxtMakeChannel(FSurface.SurfaceDesc.ddpfPixelFormat.dwRBitMask, False), FImage.idx_palette[FTransparentColor and $FF].peRed) or
dxtEncodeChannel(dxtMakeChannel(FSurface.SurfaceDesc.ddpfPixelFormat.dwGBitMask, False), FImage.idx_palette[FTransparentColor and $FF].peGreen) or
dxtEncodeChannel(dxtMakeChannel(FSurface.SurfaceDesc.ddpfPixelFormat.dwBBitMask, False), FImage.idx_palette[FTransparentColor and $FF].peBlue);
end
else
end else
if FTransparentColor shr 24 = $00 then
begin
{ RGB value }
9135,19 → 5937,18
dxtEncodeChannel(dxtMakeChannel(FSurface.SurfaceDesc.ddpfPixelFormat.dwRBitMask, False), GetRValue(FTransparentColor)) or
dxtEncodeChannel(dxtMakeChannel(FSurface.SurfaceDesc.ddpfPixelFormat.dwGBitMask, False), GetGValue(FTransparentColor)) or
dxtEncodeChannel(dxtMakeChannel(FSurface.SurfaceDesc.ddpfPixelFormat.dwBBitMask, False), GetBValue(FTransparentColor));
end
else
end else
Exit;
end;
 
ck.dwColorSpaceHighValue := ck.dwColorSpaceLowValue;
FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.SetColorKey(DDCKEY_SRCBLT, @ck);
FSurface.ISurface.SetColorKey(DDCKEY_SRCBLT, ck);
 
FUseColorKey := True;
end;
end;
 
procedure TDirect3DTexture2.LoadSubTexture(Dest: {$IFDEF D3D_deprecated}IDirectDrawSurface4{$ELSE}IDirectDrawSurface7{$ENDIF}; SrcImage: TDXTextureImage);
procedure TDirect3DTexture2.LoadSubTexture(Dest: IDirectDrawSurface4; SrcImage: TDXTextureImage);
const
Mask1: array[0..7] of DWORD = (1, 2, 4, 8, 16, 32, 64, 128);
Mask2: array[0..3] of DWORD = (3, 12, 48, 192);
9185,16 → 5986,12
if Dest.Lock(nil, ddsd, DDLOCK_WAIT, 0) = 0 then
begin
try
if (SrcImage.idx_index.Mask = DWORD(1 shl ddsd.ddpfPixelFormat.dwRGBBitCount) - 1) and
(SrcImage.idx_alpha.Mask = 0) and
(SrcImage.BitCount = Integer(ddsd.ddpfPixelFormat.dwRGBBitCount)) and
(not SrcImage.PackedPixelOrder)
then
if (SrcImage.idx_index.Mask=DWORD(1 shl ddsd.ddpfPixelFormat.dwRGBBitCount)-1) and (SrcImage.idx_alpha.Mask=0) and
(SrcImage.BitCount=Integer(ddsd.ddpfPixelFormat.dwRGBBitCount)) and (not SrcImage.PackedPixelOrder) then
begin
for y := 0 to ddsd.dwHeight - 1 do
Move(SrcImage.ScanLine[y]^, Pointer(Integer(ddsd.lpSurface) + ddsd.lPitch * y)^, (Integer(ddsd.dwWidth) * SrcImage.BitCount + 7) div 8);
end
else
end else
begin
for y := 0 to ddsd.dwHeight - 1 do
begin
9239,8 → 6036,7
 
SetPixel(ddsd, x, y, c);
end;
end
else
end else
begin
cA := dxtEncodeChannel(dest_alpha_fmt, 255);
 
9281,13 → 6077,11
 
if (dest_red_fmt.Mask = SrcImage.rgb_red.Mask) and (dest_green_fmt.Mask = SrcImage.rgb_green.Mask) and
(dest_blue_fmt.Mask = SrcImage.rgb_blue.Mask) and (dest_alpha_fmt.Mask = SrcImage.rgb_alpha.Mask) and
(Integer(ddsd.ddpfPixelFormat.dwRGBBitCount) = SrcImage.BitCount) and (not SrcImage.PackedPixelOrder)
then
(Integer(ddsd.ddpfPixelFormat.dwRGBBitCount)=SrcImage.BitCount) and (not SrcImage.PackedPixelOrder) then
begin
for y := 0 to ddsd.dwHeight - 1 do
Move(SrcImage.ScanLine[y]^, Pointer(Integer(ddsd.lpSurface) + ddsd.lPitch * y)^, (Integer(ddsd.dwWidth) * SrcImage.BitCount + 7) div 8);
end
else
end else
if SrcImage.rgb_alpha.mask <> 0 then
begin
for y := 0 to ddsd.dwHeight - 1 do
9302,8 → 6096,7
 
SetPixel(ddsd, x, y, c);
end;
end
else
end else
begin
cA := dxtEncodeChannel(dest_alpha_fmt, 255);
 
9346,2147 → 6139,10
end;
end;
 
{ Support function }
 
function GetWidthBytes(Width, BitCount: Integer): Integer;
begin
Result := (((Width * BitCount) + 31) div 32) * 4;
end;
 
function dxtEncodeChannel(const Channel: TDXTextureImageChannel; c: DWORD): DWORD;
begin
Result := ((c shl Channel._rshift) shr Channel._lshift) and Channel.Mask;
end;
 
function dxtDecodeChannel(const Channel: TDXTextureImageChannel; c: DWORD): DWORD;
begin
Result := ((c and Channel.Mask) shr Channel._rshift) shl Channel._lshift;
Result := Result or (Result shr Channel._BitCount2);
end;
 
function dxtMakeChannel(Mask: DWORD; indexed: Boolean): TDXTextureImageChannel;
 
function GetMaskBitCount(b: Integer): Integer;
var
i: Integer;
begin
i := 0;
while (i < 31) and (((1 shl i) and b) = 0) do Inc(i);
 
Result := 0;
while ((1 shl i) and b) <> 0 do
begin
Inc(i);
Inc(Result);
end;
end;
 
function GetBitCount2(b: Integer): Integer;
begin
Result := 0;
while (Result < 31) and (((1 shl Result) and b) = 0) do Inc(Result);
end;
 
begin
Result.BitCount := GetMaskBitCount(Mask);
Result.Mask := Mask;
 
if indexed then
begin
Result._rshift := GetBitCount2(Mask);
Result._lshift := 0;
Result._Mask2 := 1 shl Result.BitCount - 1;
Result._BitCount2 := 0;
end
else
begin
Result._rshift := GetBitCount2(Mask) - (8 - Result.BitCount);
if Result._rshift < 0 then
begin
Result._lshift := -Result._rshift;
Result._rshift := 0;
end
else
Result._lshift := 0;
Result._Mask2 := (1 shl Result.BitCount - 1) shl (8 - Result.BitCount);
Result._BitCount2 := 8 - Result.BitCount;
end;
end;
 
{ TDXTextureImage }
 
var
_DXTextureImageLoadFuncList: TList;
 
procedure DXTextureImage_LoadDXTextureImageFunc(Stream: TStream; Image: TDXTextureImage); forward;
procedure DXTextureImage_LoadBitmapFunc(Stream: TStream; Image: TDXTextureImage); forward;
 
function DXTextureImageLoadFuncList: TList;
begin
if _DXTextureImageLoadFuncList = nil then
begin
_DXTextureImageLoadFuncList := TList.Create;
_DXTextureImageLoadFuncList.Add(@DXTextureImage_LoadDXTextureImageFunc);
_DXTextureImageLoadFuncList.Add(@DXTextureImage_LoadBitmapFunc);
end;
Result := _DXTextureImageLoadFuncList;
end;
 
class procedure TDXTextureImage.RegisterLoadFunc(LoadFunc: TDXTextureImageLoadFunc);
begin
if DXTextureImageLoadFuncList.IndexOf(@LoadFunc) = -1 then
DXTextureImageLoadFuncList.Add(@LoadFunc);
end;
 
class procedure TDXTextureImage.UnRegisterLoadFunc(LoadFunc: TDXTextureImageLoadFunc);
begin
DXTextureImageLoadFuncList.Remove(@LoadFunc);
end;
 
constructor TDXTextureImage.Create;
begin
inherited Create;
FSubImage := TList.Create;
end;
 
constructor TDXTextureImage.CreateSub(AOwner: TDXTextureImage);
begin
Create;
 
FOwner := AOwner;
try
FOwner.FSubImage.Add(Self);
except
FOwner := nil;
raise;
end;
end;
 
destructor TDXTextureImage.Destroy;
begin
Clear;
FSubImage.Free;
if FOwner <> nil then
FOwner.FSubImage.Remove(Self);
inherited Destroy;
end;
 
procedure TDXTextureImage.DoSaveProgress(Progress, ProgressCount: Integer);
begin
if Assigned(FOnSaveProgress) then
FOnSaveProgress(Self, Progress, ProgressCount);
end;
 
procedure TDXTextureImage.Assign(Source: TDXTextureImage);
var
y: Integer;
begin
SetSize(Source.ImageType, Source.Width, Source.Height, Source.BitCount, Source.WidthBytes);
 
idx_index := Source.idx_index;
idx_alpha := Source.idx_alpha;
idx_palette := Source.idx_palette;
 
rgb_red := Source.rgb_red;
rgb_green := Source.rgb_green;
rgb_blue := Source.rgb_blue;
rgb_alpha := Source.rgb_alpha;
 
for y := 0 to Height - 1 do
Move(Source.ScanLine[y]^, ScanLine[y]^, WidthBytes);
 
Transparent := Source.Transparent;
TransparentColor := Source.TransparentColor;
ImageGroupType := Source.ImageGroupType;
ImageID := Source.ImageID;
ImageName := Source.ImageName;
end;
 
procedure TDXTextureImage.ClearImage;
begin
if FAutoFreeImage then
FreeMem(FPBits);
 
FImageType := DXTextureImageType_PaletteIndexedColor;
FWidth := 0;
FHeight := 0;
FBitCount := 0;
FWidthBytes := 0;
FNextLine := 0;
FSize := 0;
FPBits := nil;
FTopPBits := nil;
FAutoFreeImage := False;
end;
 
procedure TDXTextureImage.Clear;
begin
ClearImage;
 
while SubImageCount > 0 do
SubImages[SubImageCount - 1].Free;
 
FImageGroupType := 0;
FImageID := 0;
FImageName := '';
 
FTransparent := False;
FTransparentColor := 0;
 
FillChar(idx_index, SizeOf(idx_index), 0);
FillChar(idx_alpha, SizeOf(idx_alpha), 0);
FillChar(idx_palette, SizeOf(idx_palette), 0);
FillChar(rgb_red, SizeOf(rgb_red), 0);
FillChar(rgb_green, SizeOf(rgb_green), 0);
FillChar(rgb_blue, SizeOf(rgb_blue), 0);
FillChar(rgb_alpha, SizeOf(rgb_alpha), 0);
end;
 
procedure TDXTextureImage.SetImage(ImageType: TDXTextureImageType; Width, Height, BitCount, WidthBytes, NextLine: Integer;
PBits, TopPBits: Pointer; Size: Integer; AutoFree: Boolean);
begin
ClearImage;
 
FAutoFreeImage := AutoFree;
FImageType := ImageType;
FWidth := Width;
FHeight := Height;
FBitCount := BitCount;
FWidthBytes := WidthBytes;
FNextLine := NextLine;
FSize := Size;
FPBits := PBits;
FTopPBits := TopPBits;
end;
 
procedure TDXTextureImage.SetSize(ImageType: TDXTextureImageType; Width, Height, BitCount, WidthBytes: Integer);
var
APBits: Pointer;
begin
ClearImage;
 
if WidthBytes = 0 then
WidthBytes := GetWidthBytes(Width, BitCount);
 
GetMem(APBits, WidthBytes * Height);
SetImage(ImageType, Width, Height, BitCount, WidthBytes,
WidthBytes, APBits, APBits, WidthBytes * Height, True);
end;
 
function TDXTextureImage.GetScanLine(y: Integer): Pointer;
begin
Result := Pointer(Integer(FTopPBits) + FNextLine * y);
end;
 
function TDXTextureImage.GetSubGroupImageCount(GroupTypeID: DWORD): Integer;
var
i: Integer;
begin
Result := 0;
for i := 0 to SubImageCount - 1 do
if SubImages[i].ImageGroupType = GroupTypeID then
Inc(Result);
end;
 
function TDXTextureImage.GetSubGroupImage(GroupTypeID: DWORD; Index: Integer): TDXTextureImage;
var
i, j: Integer;
begin
j := 0;
for i := 0 to SubImageCount - 1 do
if SubImages[i].ImageGroupType = GroupTypeID then
begin
if j = Index then
begin
Result := SubImages[i];
Exit;
end;
 
Inc(j);
end;
 
Result := nil;
SubImages[-1];
end;
 
function TDXTextureImage.GetSubImageCount: Integer;
begin
Result := 0;
if Assigned(FSubImage) then
Result := FSubImage.Count;
end;
 
function TDXTextureImage.GetSubImage(Index: Integer): TDXTextureImage;
begin
Result := FSubImage[Index];
end;
 
function TDXTextureImage.EncodeColor(R, G, B, A: Byte): DWORD;
begin
if ImageType = DXTextureImageType_PaletteIndexedColor then
begin
Result := dxtEncodeChannel(idx_index, PaletteIndex(R, G, B)) or
dxtEncodeChannel(idx_alpha, A);
end
else
begin
Result := dxtEncodeChannel(rgb_red, R) or
dxtEncodeChannel(rgb_green, G) or
dxtEncodeChannel(rgb_blue, B) or
dxtEncodeChannel(rgb_alpha, A);
end;
end;
 
function TDXTextureImage.PaletteIndex(R, G, B: Byte): DWORD;
var
i, d, d2: Integer;
begin
Result := 0;
if ImageType = DXTextureImageType_PaletteIndexedColor then
begin
d := MaxInt;
for i := 0 to (1 shl idx_index.BitCount) - 1 do
with idx_palette[i] do
begin
d2 := Abs((peRed - R)) * Abs((peRed - R)) + Abs((peGreen - G)) * Abs((peGreen - G)) + Abs((peBlue - B)) * Abs((peBlue - B));
if d > d2 then
begin
d := d2;
Result := i;
end;
end;
end;
end;
 
const
Mask1: array[0..7] of DWORD = (1, 2, 4, 8, 16, 32, 64, 128);
Mask2: array[0..3] of DWORD = (3, 12, 48, 192);
Mask4: array[0..1] of DWORD = ($0F, $F0);
 
Shift1: array[0..7] of DWORD = (0, 1, 2, 3, 4, 5, 6, 7);
Shift2: array[0..3] of DWORD = (0, 2, 4, 6);
Shift4: array[0..1] of DWORD = (0, 4);
 
type
PByte3 = ^TByte3;
TByte3 = array[0..2] of Byte;
 
function TDXTextureImage.GetPixel(x, y: Integer): DWORD;
begin
Result := 0;
if (x >= 0) and (x < FWidth) and (y >= 0) and (y < FHeight) then
begin
case FBitCount of
1: begin
if FPackedPixelOrder then
Result := (PByte(Integer(FTopPBits) + FNextLine * y + x shr 3)^ and Mask1[7 - x and 7]) shr Shift1[7 - x and 7]
else
Result := (PByte(Integer(FTopPBits) + FNextLine * y + x shr 3)^ and Mask1[x and 7]) shr Shift1[x and 7];
end;
2: begin
if FPackedPixelOrder then
Result := (PByte(Integer(FTopPBits) + FNextLine * y + x shr 2)^ and Mask2[3 - x and 3]) shr Shift2[3 - x and 3]
else
Result := (PByte(Integer(FTopPBits) + FNextLine * y + x shr 2)^ and Mask2[x and 3]) shr Shift2[x and 3];
end;
4: begin
if FPackedPixelOrder then
Result := (PByte(Integer(FTopPBits) + FNextLine * y + x shr 1)^ and Mask4[1 - x and 1]) shr Shift4[1 - x and 1]
else
Result := (PByte(Integer(FTopPBits) + FNextLine * y + x shr 1)^ and Mask4[x and 1]) shr Shift4[x and 1];
end;
8: Result := PByte(Integer(FTopPBits) + FNextLine * y + x)^;
16: Result := PWord(Integer(FTopPBits) + FNextLine * y + x * 2)^;
24: PByte3(@Result)^ := PByte3(Integer(FTopPBits) + FNextLine * y + x * 3)^;
32: Result := PDWORD(Integer(FTopPBits) + FNextLine * y + x * 4)^;
end;
end;
end;
 
procedure TDXTextureImage.SetPixel(x, y: Integer; c: DWORD);
var
P: PByte;
begin
if (x >= 0) and (x < FWidth) and (y >= 0) and (y < FHeight) then
begin
case FBitCount of
1: begin
P := Pointer(Integer(FTopPBits) + FNextLine * y + x shr 3);
if FPackedPixelOrder then
P^ := (P^ and (not Mask1[7 - x and 7])) or ((c and 1) shl Shift1[7 - x and 7])
else
P^ := (P^ and (not Mask1[x and 7])) or ((c and 1) shl Shift1[x and 7]);
end;
2: begin
P := Pointer(Integer(FTopPBits) + FNextLine * y + x shr 2);
if FPackedPixelOrder then
P^ := (P^ and (not Mask2[3 - x and 3])) or ((c and 3) shl Shift2[3 - x and 3])
else
P^ := (P^ and (not Mask2[x and 3])) or ((c and 3) shl Shift2[x and 3]);
end;
4: begin
P := Pointer(Integer(FTopPBits) + FNextLine * y + x shr 1);
if FPackedPixelOrder then
P^ := (P^ and (not Mask4[1 - x and 1])) or ((c and 7) shl Shift4[1 - x and 1])
else
P^ := (P^ and (not Mask4[x and 1])) or ((c and 7) shl Shift4[x and 1]);
end;
8: PByte(Integer(FTopPBits) + FNextLine * y + x)^ := c;
16: PWord(Integer(FTopPBits) + FNextLine * y + x * 2)^ := c;
24: PByte3(Integer(FTopPBits) + FNextLine * y + x * 3)^ := PByte3(@c)^;
32: PDWORD(Integer(FTopPBits) + FNextLine * y + x * 4)^ := c;
end;
end;
end;
 
procedure TDXTextureImage.LoadFromFile(const FileName: string);
var
Stream: TFileStream;
begin
Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
 
procedure TDXTextureImage.LoadFromStream(Stream: TStream);
var
i, p: Integer;
begin
Clear;
 
p := Stream.Position;
for i := 0 to DXTextureImageLoadFuncList.Count - 1 do
begin
Stream.Position := p;
try
TDXTextureImageLoadFunc(DXTextureImageLoadFuncList[i])(Stream, Self);
Exit;
except
Clear;
end;
end;
 
raise EDXTextureImageError.Create(SNotSupportGraphicFile);
end;
 
procedure TDXTextureImage.SaveToFile(const FileName: string);
var
Stream: TFileStream;
begin
Stream := TFileStream.Create(FileName, fmCreate);
try
SaveToStream(Stream);
finally
Stream.Free;
end;
end;
 
procedure DXTextureImage_SaveDXTextureImageFunc(Stream: TStream; Image: TDXTextureImage); forward;
 
procedure TDXTextureImage.SaveToStream(Stream: TStream);
begin
DXTextureImage_SaveDXTextureImageFunc(Stream, Self);
end;
 
{ DXTextureImage_LoadDXTextureImageFunc }
 
const
DXTextureImageFile_Type = 'dxt:';
DXTextureImageFile_Version = $100;
 
DXTextureImageCompress_None = 0;
DXTextureImageCompress_ZLIB = 1; // ZLIB enabled
 
DXTextureImageFileCategoryType_Image = $100;
 
DXTextureImageFileBlockID_EndFile = 0;
DXTextureImageFileBlockID_EndGroup = 1;
DXTextureImageFileBlockID_StartGroup = 2;
DXTextureImageFileBlockID_Image_Format = DXTextureImageFileCategoryType_Image + 1;
DXTextureImageFileBlockID_Image_PixelData = DXTextureImageFileCategoryType_Image + 2;
DXTextureImageFileBlockID_Image_GroupInfo = DXTextureImageFileCategoryType_Image + 3;
DXTextureImageFileBlockID_Image_Name = DXTextureImageFileCategoryType_Image + 4;
DXTextureImageFileBlockID_Image_TransparentColor = DXTextureImageFileCategoryType_Image + 5;
 
type
TDXTextureImageFileHeader = packed record
FileType: array[0..4] of Char;
ver: DWORD;
end;
 
TDXTextureImageFileBlockHeader = packed record
ID: DWORD;
Size: Integer;
end;
 
TDXTextureImageFileBlockHeader_StartGroup = packed record
CategoryType: DWORD;
end;
 
TDXTextureImageHeader_Image_Format = packed record
ImageType: TDXTextureImageType;
Width: DWORD;
Height: DWORD;
BitCount: DWORD;
WidthBytes: DWORD;
end;
 
TDXTextureImageHeader_Image_Format_Index = packed record
idx_index_Mask: DWORD;
idx_alpha_Mask: DWORD;
idx_palette: array[0..255] of TPaletteEntry;
end;
 
TDXTextureImageHeader_Image_Format_RGB = packed record
rgb_red_Mask: DWORD;
rgb_green_Mask: DWORD;
rgb_blue_Mask: DWORD;
rgb_alpha_Mask: DWORD;
end;
 
TDXTextureImageHeader_Image_GroupInfo = packed record
ImageGroupType: DWORD;
ImageID: DWORD;
end;
 
TDXTextureImageHeader_Image_PixelData = packed record
Compress: DWORD;
end;
 
TDXTextureImageHeader_Image_TransparentColor = packed record
Transparent: Boolean;
TransparentColor: DWORD;
end;
 
procedure DXTextureImage_LoadDXTextureImageFunc(Stream: TStream; Image: TDXTextureImage);
 
procedure ReadGroup_Image(Image: TDXTextureImage);
var
i: Integer;
BlockHeader: TDXTextureImageFileBlockHeader;
NextPos: Integer;
SubImage: TDXTextureImage;
Header_StartGroup: TDXTextureImageFileBlockHeader_StartGroup;
Header_Image_Format: TDXTextureImageHeader_Image_Format;
Header_Image_Format_Index: TDXTextureImageHeader_Image_Format_Index;
Header_Image_Format_RGB: TDXTextureImageHeader_Image_Format_RGB;
Header_Image_GroupInfo: TDXTextureImageHeader_Image_GroupInfo;
Header_Image_TransparentColor: TDXTextureImageHeader_Image_TransparentColor;
Header_Image_PixelData: TDXTextureImageHeader_Image_PixelData;
ImageName: string;
{$IFDEF DXTextureImage_UseZLIB}
Decompression: TDecompressionStream;
{$ENDIF}
begin
while True do
begin
Stream.ReadBuffer(BlockHeader, SizeOf(BlockHeader));
NextPos := Stream.Position + BlockHeader.Size;
 
case BlockHeader.ID of
DXTextureImageFileBlockID_EndGroup:
begin
{ End of group }
Break;
end;
DXTextureImageFileBlockID_StartGroup:
begin
{ Beginning of group }
Stream.ReadBuffer(Header_StartGroup, SizeOf(Header_StartGroup));
case Header_StartGroup.CategoryType of
DXTextureImageFileCategoryType_Image:
begin
{ Image group }
SubImage := TDXTextureImage.CreateSub(Image);
try
ReadGroup_Image(SubImage);
except
SubImage.Free;
raise;
end;
end;
end;
end;
DXTextureImageFileBlockID_Image_Format:
begin
{ Image information reading (size etc.) }
Stream.ReadBuffer(Header_Image_Format, SizeOf(Header_Image_Format));
 
if (Header_Image_Format.ImageType <> DXTextureImageType_PaletteIndexedColor) and
(Header_Image_Format.ImageType <> DXTextureImageType_RGBColor)
then
raise EDXTextureImageError.Create(SInvalidDXTFile);
 
Image.SetSize(Header_Image_Format.ImageType, Header_Image_Format.Width, Header_Image_Format.Height,
Header_Image_Format.BitCount, Header_Image_Format.Widthbytes);
 
if Header_Image_Format.ImageType = DXTextureImageType_PaletteIndexedColor then
begin
{ INDEX IMAGE }
Stream.ReadBuffer(Header_Image_Format_Index, SizeOf(Header_Image_Format_Index));
 
Image.idx_index := dxtMakeChannel(Header_Image_Format_Index.idx_index_Mask, True);
Image.idx_alpha := dxtMakeChannel(Header_Image_Format_Index.idx_alpha_Mask, False);
 
for i := 0 to 255 do
Image.idx_palette[i] := Header_Image_Format_Index.idx_palette[i];
end
else
if Header_Image_Format.ImageType = DXTextureImageType_RGBColor then
begin
{ RGB IMAGE }
Stream.ReadBuffer(Header_Image_Format_RGB, SizeOf(Header_Image_Format_RGB));
 
Image.rgb_red := dxtMakeChannel(Header_Image_Format_RGB.rgb_red_Mask, False);
Image.rgb_green := dxtMakeChannel(Header_Image_Format_RGB.rgb_green_Mask, False);
Image.rgb_blue := dxtMakeChannel(Header_Image_Format_RGB.rgb_blue_Mask, False);
Image.rgb_alpha := dxtMakeChannel(Header_Image_Format_RGB.rgb_alpha_Mask, False);
end;
end;
DXTextureImageFileBlockID_Image_Name:
begin
{ Name reading }
SetLength(ImageName, BlockHeader.Size);
Stream.ReadBuffer(ImageName[1], BlockHeader.Size);
 
Image.ImageName := ImageName;
end;
DXTextureImageFileBlockID_Image_GroupInfo:
begin
{ Image group information reading }
Stream.ReadBuffer(Header_Image_GroupInfo, SizeOf(Header_Image_GroupInfo));
 
Image.ImageGroupType := Header_Image_GroupInfo.ImageGroupType;
Image.ImageID := Header_Image_GroupInfo.ImageID;
end;
DXTextureImageFileBlockID_Image_TransparentColor:
begin
{ Transparent color information reading }
Stream.ReadBuffer(Header_Image_TransparentColor, SizeOf(Header_Image_TransparentColor));
 
Image.Transparent := Header_Image_TransparentColor.Transparent;
Image.TransparentColor := Header_Image_TransparentColor.TransparentColor;
end;
DXTextureImageFileBlockID_Image_PixelData:
begin
{ Pixel data reading }
Stream.ReadBuffer(Header_Image_PixelData, SizeOf(Header_Image_PixelData));
 
case Header_Image_PixelData.Compress of
DXTextureImageCompress_None:
begin
{ NO compress }
for i := 0 to Image.Height - 1 do
Stream.ReadBuffer(Image.ScanLine[i]^, Header_Image_Format.Widthbytes);
end;
{$IFDEF DXTextureImage_UseZLIB}
DXTextureImageCompress_ZLIB:
begin
{ ZLIB compress enabled }
Decompression := TDecompressionStream.Create(Stream);
try
for i := 0 to Image.Height - 1 do
Decompression.ReadBuffer(Image.ScanLine[i]^, Header_Image_Format.Widthbytes);
finally
Decompression.Free;
end;
end;
{$ENDIF}
else
raise EDXTextureImageError.CreateFmt('Decompression error (%d)', [Header_Image_PixelData.Compress]);
end;
end;
 
end;
 
Stream.Seek(NextPos, soFromBeginning);
end;
end;
 
var
FileHeader: TDXTextureImageFileHeader;
BlockHeader: TDXTextureImageFileBlockHeader;
Header_StartGroup: TDXTextureImageFileBlockHeader_StartGroup;
NextPos: Integer;
begin
{ File header reading }
Stream.ReadBuffer(FileHeader, SizeOf(FileHeader));
 
if FileHeader.FileType <> DXTextureImageFile_Type then
raise EDXTextureImageError.Create(SInvalidDXTFile);
if FileHeader.ver <> DXTextureImageFile_Version then
raise EDXTextureImageError.Create(SInvalidDXTFile);
 
while True do
begin
Stream.ReadBuffer(BlockHeader, SizeOf(BlockHeader));
NextPos := Stream.Position + BlockHeader.Size;
 
case BlockHeader.ID of
DXTextureImageFileBlockID_EndFile:
begin
{ End of file }
Break;
end;
DXTextureImageFileBlockID_StartGroup:
begin
{ Beginning of group }
Stream.ReadBuffer(Header_StartGroup, SizeOf(Header_StartGroup));
case Header_StartGroup.CategoryType of
DXTextureImageFileCategoryType_Image: ReadGroup_Image(Image);
end;
end;
end;
 
Stream.Seek(NextPos, soFromBeginning);
end;
end;
 
type
PDXTextureImageFileBlockHeaderWriter_BlockInfo = ^TDXTextureImageFileBlockHeaderWriter_BlockInfo;
TDXTextureImageFileBlockHeaderWriter_BlockInfo = record
BlockID: DWORD;
StreamPos: Integer;
end;
 
TDXTextureImageFileBlockHeaderWriter = class
private
FStream: TStream;
FList: TList;
public
constructor Create(Stream: TStream);
destructor Destroy; override;
procedure StartBlock(BlockID: DWORD);
procedure EndBlock;
procedure WriteBlock(BlockID: DWORD);
procedure StartGroup(CategoryType: DWORD);
procedure EndGroup;
end;
 
constructor TDXTextureImageFileBlockHeaderWriter.Create(Stream: TStream);
begin
inherited Create;
FStream := Stream;
FList := TList.Create;
end;
 
destructor TDXTextureImageFileBlockHeaderWriter.Destroy;
var
i: Integer;
begin
for i := 0 to FList.Count - 1 do
Dispose(PDXTextureImageFileBlockHeaderWriter_BlockInfo(FList[i]));
FList.Free;
inherited Destroy;
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.StartBlock(BlockID: DWORD);
var
BlockInfo: PDXTextureImageFileBlockHeaderWriter_BlockInfo;
BlockHeader: TDXTextureImageFileBlockHeader;
begin
New(BlockInfo);
BlockInfo.BlockID := BlockID;
BlockInfo.StreamPos := FStream.Position;
FList.Add(BlockInfo);
 
BlockHeader.ID := BlockID;
BlockHeader.Size := 0;
FStream.WriteBuffer(BlockHeader, SizeOf(BlockHeader));
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.EndBlock;
var
BlockHeader: TDXTextureImageFileBlockHeader;
BlockInfo: PDXTextureImageFileBlockHeaderWriter_BlockInfo;
CurStreamPos: Integer;
begin
CurStreamPos := FStream.Position;
try
BlockInfo := FList[FList.Count - 1];
 
FStream.Position := BlockInfo.StreamPos;
BlockHeader.ID := BlockInfo.BlockID;
BlockHeader.Size := CurStreamPos - (BlockInfo.StreamPos + SizeOf(TDXTextureImageFileBlockHeader));
FStream.WriteBuffer(BlockHeader, SizeOf(BlockHeader));
finally
FStream.Position := CurStreamPos;
 
Dispose(FList[FList.Count - 1]);
FList.Count := FList.Count - 1;
end;
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.WriteBlock(BlockID: DWORD);
var
BlockHeader: TDXTextureImageFileBlockHeader;
begin
BlockHeader.ID := BlockID;
BlockHeader.Size := 0;
FStream.WriteBuffer(BlockHeader, SizeOf(BlockHeader));
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.StartGroup(CategoryType: DWORD);
var
Header_StartGroup: TDXTextureImageFileBlockHeader_StartGroup;
begin
StartBlock(DXTextureImageFileBlockID_StartGroup);
 
Header_StartGroup.CategoryType := CategoryType;
FStream.WriteBuffer(Header_StartGroup, SizeOf(Header_StartGroup));
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.EndGroup;
begin
WriteBlock(DXTextureImageFileBlockID_EndGroup);
EndBlock;
end;
 
procedure DXTextureImage_SaveDXTextureImageFunc(Stream: TStream; Image: TDXTextureImage);
var
Progress: Integer;
ProgressCount: Integer;
BlockHeaderWriter: TDXTextureImageFileBlockHeaderWriter;
 
function CalcProgressCount(Image: TDXTextureImage): Integer;
var
i: Integer;
begin
Result := Image.WidthBytes * Image.Height;
for i := 0 to Image.SubImageCount - 1 do
Inc(Result, CalcProgressCount(Image.SubImages[i]));
end;
 
procedure AddProgress(Count: Integer);
begin
Inc(Progress, Count);
Image.DoSaveProgress(Progress, ProgressCount);
end;
 
procedure WriteGroup_Image(Image: TDXTextureImage);
var
i: Integer;
Header_Image_Format: TDXTextureImageHeader_Image_Format;
Header_Image_Format_Index: TDXTextureImageHeader_Image_Format_Index;
Header_Image_Format_RGB: TDXTextureImageHeader_Image_Format_RGB;
Header_Image_GroupInfo: TDXTextureImageHeader_Image_GroupInfo;
Header_Image_TransparentColor: TDXTextureImageHeader_Image_TransparentColor;
Header_Image_PixelData: TDXTextureImageHeader_Image_PixelData;
{$IFDEF DXTextureImage_UseZLIB}
Compression: TCompressionStream;
{$ENDIF}
begin
BlockHeaderWriter.StartGroup(DXTextureImageFileCategoryType_Image);
try
{ Image format writing }
if Image.Size > 0 then
begin
Header_Image_Format.ImageType := Image.ImageType;
Header_Image_Format.Width := Image.Width;
Header_Image_Format.Height := Image.Height;
Header_Image_Format.BitCount := Image.BitCount;
Header_Image_Format.WidthBytes := Image.WidthBytes;
 
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_Format);
try
Stream.WriteBuffer(Header_Image_Format, SizeOf(Header_Image_Format));
 
case Image.ImageType of
DXTextureImageType_PaletteIndexedColor:
begin
{ INDEX IMAGE }
Header_Image_Format_Index.idx_index_Mask := Image.idx_index.Mask;
Header_Image_Format_Index.idx_alpha_Mask := Image.idx_alpha.Mask;
for i := 0 to 255 do
Header_Image_Format_Index.idx_palette[i] := Image.idx_palette[i];
 
Stream.WriteBuffer(Header_Image_Format_Index, SizeOf(Header_Image_Format_Index));
end;
DXTextureImageType_RGBColor:
begin
{ RGB IMAGE }
Header_Image_Format_RGB.rgb_red_Mask := Image.rgb_red.Mask;
Header_Image_Format_RGB.rgb_green_Mask := Image.rgb_green.Mask;
Header_Image_Format_RGB.rgb_blue_Mask := Image.rgb_blue.Mask;
Header_Image_Format_RGB.rgb_alpha_Mask := Image.rgb_alpha.Mask;
 
Stream.WriteBuffer(Header_Image_Format_RGB, SizeOf(Header_Image_Format_RGB));
end;
end;
finally
BlockHeaderWriter.EndBlock;
end;
end;
 
{ Image group information writing }
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_GroupInfo);
try
Header_Image_GroupInfo.ImageGroupType := Image.ImageGroupType;
Header_Image_GroupInfo.ImageID := Image.ImageID;
 
Stream.WriteBuffer(Header_Image_GroupInfo, SizeOf(Header_Image_GroupInfo));
finally
BlockHeaderWriter.EndBlock;
end;
 
{ Name writing }
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_Name);
try
Stream.WriteBuffer(Image.ImageName[1], Length(Image.ImageName));
finally
BlockHeaderWriter.EndBlock;
end;
 
{ Transparent color writing }
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_TransparentColor);
try
Header_Image_TransparentColor.Transparent := Image.Transparent;
Header_Image_TransparentColor.TransparentColor := Image.TransparentColor;
 
Stream.WriteBuffer(Header_Image_TransparentColor, SizeOf(Header_Image_TransparentColor));
finally
BlockHeaderWriter.EndBlock;
end;
 
{ Pixel data writing }
if Image.Size > 0 then
begin
{ Writing start }
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_PixelData);
try
{ Scan compress type }
case Image.FileCompressType of
DXTextureImageFileCompressType_None:
begin
Header_Image_PixelData.Compress := DXTextureImageCompress_None;
end;
{$IFDEF DXTextureImage_UseZLIB}
DXTextureImageFileCompressType_ZLIB:
begin
Header_Image_PixelData.Compress := DXTextureImageCompress_ZLIB;
end;
{$ENDIF}
else
Header_Image_PixelData.Compress := DXTextureImageCompress_None;
end;
 
Stream.WriteBuffer(Header_Image_PixelData, SizeOf(Header_Image_PixelData));
 
case Header_Image_PixelData.Compress of
DXTextureImageCompress_None:
begin
for i := 0 to Image.Height - 1 do
begin
Stream.WriteBuffer(Image.ScanLine[i]^, Image.Widthbytes);
AddProgress(Image.Widthbytes);
end;
end;
{$IFDEF DXTextureImage_UseZLIB}
DXTextureImageCompress_ZLIB:
begin
Compression := TCompressionStream.Create(clMax, Stream);
try
for i := 0 to Image.Height - 1 do
begin
Compression.WriteBuffer(Image.ScanLine[i]^, Image.WidthBytes);
AddProgress(Image.Widthbytes);
end;
finally
Compression.Free;
end;
end;
{$ENDIF}
end;
finally
BlockHeaderWriter.EndBlock;
end;
end;
 
{ Sub-image writing }
for i := 0 to Image.SubImageCount - 1 do
WriteGroup_Image(Image.SubImages[i]);
finally
BlockHeaderWriter.EndGroup;
end;
end;
 
var
FileHeader: TDXTextureImageFileHeader;
begin
Progress := 0;
ProgressCount := CalcProgressCount(Image);
 
{ File header writing }
FileHeader.FileType := DXTextureImageFile_Type;
FileHeader.ver := DXTextureImageFile_Version;
Stream.WriteBuffer(FileHeader, SizeOf(FileHeader));
 
{ Image writing }
BlockHeaderWriter := TDXTextureImageFileBlockHeaderWriter.Create(Stream);
try
{ Image writing }
WriteGroup_Image(Image);
 
{ End of file }
BlockHeaderWriter.WriteBlock(DXTextureImageFileBlockID_EndFile);
finally
BlockHeaderWriter.Free;
end;
end;
 
{ DXTextureImage_LoadBitmapFunc }
 
procedure DXTextureImage_LoadBitmapFunc(Stream: TStream; Image: TDXTextureImage);
type
TDIBPixelFormat = packed record
RBitMask, GBitMask, BBitMask: DWORD;
end;
var
TopDown: Boolean;
BF: TBitmapFileHeader;
BI: TBitmapInfoHeader;
 
procedure DecodeRGB;
var
y: Integer;
begin
for y := 0 to Image.Height - 1 do
begin
if TopDown then
Stream.ReadBuffer(Image.ScanLine[y]^, Image.WidthBytes)
else
Stream.ReadBuffer(Image.ScanLine[Image.Height - y - 1]^, Image.WidthBytes);
end;
end;
 
procedure DecodeRLE4;
var
SrcDataP: Pointer;
B1, B2, C: Byte;
Dest, Src, P: PByte;
X, Y, i: Integer;
begin
GetMem(SrcDataP, BI.biSizeImage);
try
Stream.ReadBuffer(SrcDataP^, BI.biSizeImage);
 
Dest := Image.TopPBits;
Src := SrcDataP;
X := 0;
Y := 0;
 
while True do
begin
B1 := Src^; Inc(Src);
B2 := Src^; Inc(Src);
 
if B1 = 0 then
begin
case B2 of
0: begin { End of line }
X := 0; Inc(Y);
Dest := Image.ScanLine[Y];
end;
1: Break; { End of bitmap }
2: begin { Difference of coordinates }
Inc(X, B1); Inc(Y, B2); Inc(Src, 2);
Dest := Image.ScanLine[Y];
end;
else
{ Absolute mode }
C := 0;
for i := 0 to B2 - 1 do
begin
if i and 1 = 0 then
begin
C := Src^; Inc(Src);
end
else
begin
C := C shl 4;
end;
 
P := Pointer(Integer(Dest) + X shr 1);
if X and 1 = 0 then
P^ := (P^ and $0F) or (C and $F0)
else
P^ := (P^ and $F0) or ((C and $F0) shr 4);
 
Inc(X);
end;
end;
end
else
begin
{ Encoding mode }
for i := 0 to B1 - 1 do
begin
P := Pointer(Integer(Dest) + X shr 1);
if X and 1 = 0 then
P^ := (P^ and $0F) or (B2 and $F0)
else
P^ := (P^ and $F0) or ((B2 and $F0) shr 4);
 
Inc(X);
 
// Swap nibble
B2 := (B2 shr 4) or (B2 shl 4);
end;
end;
 
{ Word arrangement }
Inc(Src, Longint(Src) and 1);
end;
finally
FreeMem(SrcDataP);
end;
end;
 
procedure DecodeRLE8;
var
SrcDataP: Pointer;
B1, B2: Byte;
Dest, Src: PByte;
X, Y: Integer;
begin
GetMem(SrcDataP, BI.biSizeImage);
try
Stream.ReadBuffer(SrcDataP^, BI.biSizeImage);
 
Dest := Image.TopPBits;
Src := SrcDataP;
X := 0;
Y := 0;
 
while True do
begin
B1 := Src^; Inc(Src);
B2 := Src^; Inc(Src);
 
if B1 = 0 then
begin
case B2 of
0: begin { End of line }
X := 0; Inc(Y);
Dest := Pointer(Longint(Image.TopPBits) + Y * Image.NextLine + X);
end;
1: Break; { End of bitmap }
2: begin { Difference of coordinates }
Inc(X, B1); Inc(Y, B2); Inc(Src, 2);
Dest := Pointer(Longint(Image.TopPBits) + Y * Image.NextLine + X);
end;
else
{ Absolute mode }
Move(Src^, Dest^, B2); Inc(Dest, B2); Inc(Src, B2);
end;
end
else
begin
{ Encoding mode }
FillChar(Dest^, B1, B2); Inc(Dest, B1);
end;
 
{ Word arrangement }
Inc(Src, Longint(Src) and 1);
end;
finally
FreeMem(SrcDataP);
end;
end;
 
var
BC: TBitmapCoreHeader;
RGBTriples: array[0..255] of TRGBTriple;
RGBQuads: array[0..255] of TRGBQuad;
i, PalCount, j: Integer;
OS2: Boolean;
PixelFormat: TDIBPixelFormat;
begin
{ File header reading }
i := Stream.Read(BF, SizeOf(TBitmapFileHeader));
if i = 0 then Exit;
if i <> SizeOf(TBitmapFileHeader) then
raise EDXTextureImageError.Create(SInvalidDIB);
 
{ Is the head 'BM'? }
if BF.bfType <> Ord('B') + Ord('M') * $100 then
raise EDXTextureImageError.Create(SInvalidDIB);
 
{ Reading of size of header }
i := Stream.Read(BI.biSize, 4);
if i <> 4 then
raise EDXTextureImageError.Create(SInvalidDIB);
 
{ Kind check of DIB }
OS2 := False;
 
case BI.biSize of
SizeOf(TBitmapCoreHeader):
begin
{ OS/2 type }
Stream.ReadBuffer(Pointer(Integer(@BC) + 4)^, SizeOf(TBitmapCoreHeader) - 4);
 
FilLChar(BI, SizeOf(BI), 0);
with BI do
begin
biClrUsed := 0;
biCompression := BI_RGB;
biBitCount := BC.bcBitCount;
biHeight := BC.bcHeight;
biWidth := BC.bcWidth;
end;
 
OS2 := True;
end;
SizeOf(TBitmapInfoHeader):
begin
{ Windows type }
Stream.ReadBuffer(Pointer(Integer(@BI) + 4)^, SizeOf(TBitmapInfoHeader) - 4);
end;
else
raise EDXTextureImageError.Create(SInvalidDIB);
end;
 
{ Bit mask reading }
if BI.biCompression = BI_BITFIELDS then
begin
Stream.ReadBuffer(PixelFormat, SizeOf(PixelFormat));
end
else
begin
if BI.biBitCount = 16 then
begin
PixelFormat.RBitMask := $7C00;
PixelFormat.GBitMask := $03E0;
PixelFormat.BBitMask := $001F;
end else if (BI.biBitCount = 24) or (BI.biBitCount = 32) then
begin
PixelFormat.RBitMask := $00FF0000;
PixelFormat.GBitMask := $0300FF00;
PixelFormat.BBitMask := $000000FF;
end;
end;
 
{ DIB making }
if BI.biHeight < 0 then
begin
BI.biHeight := -BI.biHeight;
TopDown := True;
end
else
TopDown := False;
 
if BI.biBitCount in [1, 4, 8] then
begin
Image.SetSize(DXTextureImageType_PaletteIndexedColor, BI.biWidth, BI.biHeight, BI.biBitCount,
(((BI.biWidth * BI.biBitCount) + 31) div 32) * 4);
 
Image.idx_index := dxtMakeChannel(1 shl BI.biBitCount - 1, True);
Image.PackedPixelOrder := True;
end
else
begin
Image.SetSize(DXTextureImageType_RGBColor, BI.biWidth, BI.biHeight, BI.biBitCount,
(((BI.biWidth * BI.biBitCount) + 31) div 32) * 4);
 
Image.rgb_red := dxtMakeChannel(PixelFormat.RBitMask, False);
Image.rgb_green := dxtMakeChannel(PixelFormat.GBitMask, False);
Image.rgb_blue := dxtMakeChannel(PixelFormat.BBitMask, False);
 
j := Image.rgb_red.BitCount + Image.rgb_green.BitCount + Image.rgb_blue.BitCount;
if j < BI.biBitCount then
Image.rgb_alpha := dxtMakeChannel((1 shl (BI.biBitCount - j) - 1) shl j, False);
 
Image.PackedPixelOrder := False;
end;
 
{ palette reading }
PalCount := BI.biClrUsed;
if (PalCount = 0) and (BI.biBitCount <= 8) then
PalCount := 1 shl BI.biBitCount;
if PalCount > 256 then PalCount := 256;
 
if OS2 then
begin
{ OS/2 type }
Stream.ReadBuffer(RGBTriples, SizeOf(TRGBTriple) * PalCount);
for i := 0 to PalCount - 1 do
begin
Image.idx_palette[i].peRed := RGBTriples[i].rgbtRed;
Image.idx_palette[i].peGreen := RGBTriples[i].rgbtGreen;
Image.idx_palette[i].peBlue := RGBTriples[i].rgbtBlue;
end;
end
else
begin
{ Windows type }
Stream.ReadBuffer(RGBQuads, SizeOf(TRGBQuad) * PalCount);
for i := 0 to PalCount - 1 do
begin
Image.idx_palette[i].peRed := RGBQuads[i].rgbRed;
Image.idx_palette[i].peGreen := RGBQuads[i].rgbGreen;
Image.idx_palette[i].peBlue := RGBQuads[i].rgbBlue;
end;
end;
 
{ Pixel data reading }
case BI.biCompression of
BI_RGB: DecodeRGB;
BI_BITFIELDS: DecodeRGB;
BI_RLE4: DecodeRLE4;
BI_RLE8: DecodeRLE8;
else
raise EDXTextureImageError.Create(SInvalidDIB);
end;
end;
 
{ TDXTBase }
 
//Note by JB.
//This class is supplement of original Hori's code.
//For use alphablend you can have a bitmap 32 bit RGBA
//when isn't alphachannel present, it works like RGB 24bit
 
//functions required actualized DIB source for works with alphachannel
 
function TDXTBase.GetCompression: TDXTextureImageFileCompressType;
begin
Result := FParamsFormat.Compress;
end;
 
procedure TDXTBase.SetCompression(const Value: TDXTextureImageFileCompressType);
begin
FParamsFormat.Compress := Value;
end;
 
function TDXTBase.GetWidth: Integer;
begin
Result := FParamsFormat.Width;
end;
 
procedure TDXTBase.SetWidth(const Value: Integer);
begin
FParamsFormat.Width := Value;
end;
 
function TDXTBase.GetMipmap: Integer;
begin
Result := FParamsFormat.MipmapCount;
end;
 
procedure TDXTBase.SetMipmap(const Value: Integer);
begin
if Value = -1 then
FParamsFormat.MipmapCount := MaxInt
else
FParamsFormat.MipmapCount := Value;
end;
 
function TDXTBase.GetTransparentColor: TColorRef;
begin
Result := FParamsFormat.TransparentColor;
end;
 
procedure TDXTBase.SetTransparentColor(const Value: TColorRef);
begin
FParamsFormat.Transparent := True;
FParamsFormat.TransparentColor := RGB(Value shr 16, Value shr 8, Value);
end;
 
procedure TDXTBase.SetTransparentColorIndexed(const Value: TColorRef);
begin
FParamsFormat.TransparentColor := PaletteIndex(Value);
end;
 
function TDXTBase.GetHeight: Integer;
begin
Result := FParamsFormat.Height;
end;
 
procedure TDXTBase.SetHeight(const Value: Integer);
begin
FParamsFormat.Height := Value;
end;
 
procedure TDXTBase.SetChannelY(T: TDIB);
begin
 
end;
 
procedure TDXTBase.LoadChannelRGBFromFile(const FileName: string);
begin
FStrImageFileName := FileName;
try
EvaluateChannels([rgbRed, rgbGreen, rgbBlue], '', '');
finally
FStrImageFileName := '';
end;
end;
 
function TDXTBase.LoadFromFile(iFilename: string): Boolean;
begin
Result := FileExists(iFilename);
if Result then
try
Texture.LoadFromFile(iFileName);
except
Result := False;
end;
end;
 
procedure TDXTBase.LoadChannelAFromFile(const FileName: string);
begin
FStrImageFileName := FileName;
try
EvaluateChannels([rgbAlpha], '', '');
finally
FStrImageFileName := '';
end;
end;
 
constructor TDXTBase.Create;
var
Channel: TDXTImageChannel;
begin
FillChar(Channel, SizeOf(Channel), 0);
FilLChar(FParamsFormat, SizeOf(FParamsFormat), 0);
FParamsFormat.Compress := DXTextureImageFileCompressType_None;
FHasImageList := TList.Create;
for Channel := Low(Channel) to High(Channel) do
FChannelChangeTable[Channel] := Channel;
FChannelChangeTable[rgbAlpha] := yuvY;
FDIB := nil;
FStrImageFileName := '';
end;
 
procedure TDXTBase.SetChannelRGBA(T: TDIB);
begin
FDIB := T;
try
EvaluateChannels([rgbRed, rgbGreen, rgbBlue, rgbAlpha], '', '');
finally
FDIB := nil;
end;
end;
 
procedure TDXTBase.BuildImage(Image: TDXTextureImage);
type
TOutputImageChannelInfo2 = record
Image: TDXTextureImage;
Channels: TDXTImageChannels;
end;
var
cR, cG, cB: Byte;
 
function GetChannelVal(const Channel: TDXTextureImageChannel; SrcChannel: TDXTImageChannel): DWORD;
begin
case SrcChannel of
rgbRed: Result := dxtEncodeChannel(Channel, cR);
rgbGreen: Result := dxtEncodeChannel(Channel, cG);
rgbBlue: Result := dxtEncodeChannel(Channel, cB);
yuvY: Result := dxtEncodeChannel(Channel, (cR * 306 + cG * 602 + cB * 116) div 1024);
else Result := 0;
end;
end;
 
var
HasImageChannelList: array[0..Ord(High(TDXTImageChannel)) + 1] of TOutputImageChannelInfo2;
HasImageChannelListCount: Integer;
x, y, i: Integer;
c, c2, c3: DWORD;
Channel: TDXTImageChannel;
Flag: Boolean;
 
SrcImage: TDXTextureImage;
UseChannels: TDXTImageChannels;
begin
HasImageChannelListCount := 0;
for Channel := Low(Channel) to High(Channel) do
if Channel in FHasChannels then
begin
Flag := False;
for i := 0 to HasImageChannelListCount - 1 do
if HasImageChannelList[i].Image = FHasChannelImages[Channel].Image then
begin
HasImageChannelList[i].Channels := HasImageChannelList[i].Channels + [Channel];
Flag := True;
Break;
end;
if not Flag then
begin
HasImageChannelList[HasImageChannelListCount].Image := FHasChannelImages[Channel].Image;
HasImageChannelList[HasImageChannelListCount].Channels := [Channel];
Inc(HasImageChannelListCount);
end;
end;
 
cR := 0;
cG := 0;
cB := 0;
 
if Image.ImageType = DXTextureImageType_PaletteIndexedColor then
begin
{ Index color }
for y := 0 to Image.Height - 1 do
for x := 0 to Image.Width - 1 do
begin
c := 0;
 
for i := 0 to HasImageChannelListCount - 1 do
begin
SrcImage := HasImageChannelList[i].Image;
UseChannels := HasImageChannelList[i].Channels;
 
case SrcImage.ImageType of
DXTextureImageType_PaletteIndexedColor:
begin
c2 := SrcImage.Pixels[x, y];
c3 := dxtDecodeChannel(SrcImage.idx_index, c2);
 
if rgbRed in UseChannels then
c := c or dxtEncodeChannel(Image.idx_index, c3);
 
cR := SrcImage.idx_palette[c3].peRed;
cG := SrcImage.idx_palette[c3].peGreen;
cB := SrcImage.idx_palette[c3].peBlue;
end;
DXTextureImageType_RGBColor:
begin
c2 := SrcImage.Pixels[x, y];
 
cR := dxtDecodeChannel(SrcImage.rgb_red, c2);
cG := dxtDecodeChannel(SrcImage.rgb_green, c2);
cB := dxtDecodeChannel(SrcImage.rgb_blue, c2);
end;
end;
 
if rgbAlpha in UseChannels then
c := c or GetChannelVal(Image.idx_alpha, FChannelChangeTable[rgbAlpha]);
end;
 
Image.Pixels[x, y] := c;
end;
end
else
if Image.ImageType = DXTextureImageType_RGBColor then
begin
{ RGB color }
for y := 0 to Image.Height - 1 do
for x := 0 to Image.Width - 1 do
begin
c := 0;
 
for i := 0 to HasImageChannelListCount - 1 do
begin
SrcImage := HasImageChannelList[i].Image;
UseChannels := HasImageChannelList[i].Channels;
 
case SrcImage.ImageType of
DXTextureImageType_PaletteIndexedColor:
begin
c2 := SrcImage.Pixels[x, y];
c3 := dxtDecodeChannel(SrcImage.idx_index, c2);
 
cR := SrcImage.idx_palette[c3].peRed;
cG := SrcImage.idx_palette[c3].peGreen;
cB := SrcImage.idx_palette[c3].peBlue;
end;
DXTextureImageType_RGBColor:
begin
c2 := SrcImage.Pixels[x, y];
 
cR := dxtDecodeChannel(SrcImage.rgb_red, c2);
cG := dxtDecodeChannel(SrcImage.rgb_green, c2);
cB := dxtDecodeChannel(SrcImage.rgb_blue, c2);
end;
end;
 
if rgbRed in UseChannels then
c := c or GetChannelVal(Image.rgb_red, FChannelChangeTable[rgbRed]);
if rgbGreen in UseChannels then
c := c or GetChannelVal(Image.rgb_green, FChannelChangeTable[rgbGreen]);
if rgbBlue in UseChannels then
c := c or GetChannelVal(Image.rgb_Blue, FChannelChangeTable[rgbBlue]);
if rgbAlpha in UseChannels then
c := c or GetChannelVal(Image.rgb_alpha, FChannelChangeTable[rgbAlpha]);
end;
 
Image.Pixels[x, y] := c;
end;
end;
end;
 
procedure TDXTBase.SetChannelR(T: TDIB);
begin
FDIB := T;
try
EvaluateChannels([rgbRed], '', '');
finally
FDIB := nil;
end;
end;
 
function GetBitCount(b: Integer): Integer;
begin
Result := 32;
while (Result > 0) and (((1 shl (Result - 1)) and b) = 0) do Dec(Result);
end;
 
procedure TDXTBase.CalcOutputBitFormat;
var
BitCount: DWORD;
NewWidth, NewHeight, i, j: Integer;
Channel: TDXTImageChannel;
begin
{ Size calculation }
NewWidth := 1 shl GetBitCount(TDXTextureImage(FHasImageList[0]).Width);
NewHeight := 1 shl GetBitCount(TDXTextureImage(FHasImageList[0]).Height);
NewWidth := Max(NewWidth, NewHeight);
NewHeight := NewWidth;
if Abs(FParamsFormat.Width - NewWidth) > Abs(FParamsFormat.Width - NewWidth div 2) then
NewWidth := NewWidth div 2;
if Abs(FParamsFormat.Height - NewHeight) > Abs(FParamsFormat.Height - NewHeight div 2) then
NewHeight := NewHeight div 2;
 
if FParamsFormat.Width = 0 then FParamsFormat.Width := NewWidth;
if FParamsFormat.Height = 0 then FParamsFormat.Height := NewHeight;
 
{ Other several calculation }
i := Min(FParamsFormat.Width, FParamsFormat.Height);
j := 0;
while i > 1 do
begin
i := i div 2;
Inc(j);
end;
 
FParamsFormat.MipmapCount := Min(j, FParamsFormat.MipmapCount);
 
{ Output type calculation }
if (FHasChannelImages[rgbRed].Image = FHasChannelImages[rgbGreen].Image) and
(FHasChannelImages[rgbRed].Image = FHasChannelImages[rgbBlue].Image) and
(FHasChannelImages[rgbRed].Image <> nil) and
(FHasChannelImages[rgbRed].Image.ImageType = DXTextureImageType_PaletteIndexedColor) and
 
(FHasChannelImages[rgbRed].BitCount = 8) and
(FHasChannelImages[rgbGreen].BitCount = 8) and
(FHasChannelImages[rgbBlue].BitCount = 8) and
 
(FChannelChangeTable[rgbRed] = rgbRed) and
(FChannelChangeTable[rgbGreen] = rgbGreen) and
(FChannelChangeTable[rgbBlue] = rgbBlue) and
 
(FParamsFormat.Width = FHasChannelImages[rgbRed].Image.Width) and
(FParamsFormat.Height = FHasChannelImages[rgbRed].Image.Height) and
 
(FParamsFormat.MipmapCount = 0)
then
begin
FParamsFormat.ImageType := DXTextureImageType_PaletteIndexedColor;
end
else
FParamsFormat.ImageType := DXTextureImageType_RGBColor;
 
{ Bit several calculations }
FParamsFormat.BitCount := 0;
 
for Channel := Low(TDXTImageChannel) to High(TDXTImageChannel) do
if (FHasChannelImages[Channel].Image <> nil) and (FHasChannelImages[Channel].Image.ImageType = DXTextureImageType_PaletteIndexedColor) then
begin
FParamsFormat.idx_palette := FHasChannelImages[Channel].Image.idx_palette;
Break;
end;
 
if FParamsFormat.ImageType = DXTextureImageType_PaletteIndexedColor then
begin
{ Index channel }
if rgbRed in FHasChannels then
begin
BitCount := FHasChannelImages[rgbRed].BitCount;
FParamsFormat.idx_index := dxtMakeChannel(((1 shl BitCount) - 1) shl FParamsFormat.BitCount, True);
Inc(FParamsFormat.BitCount, BitCount);
end;
 
{ Alpha channel }
if rgbAlpha in FHasChannels then
begin
BitCount := FHasChannelImages[rgbAlpha].BitCount;
FParamsFormat.idx_alpha := dxtMakeChannel(((1 shl BitCount) - 1) shl FParamsFormat.BitCount, False);
Inc(FParamsFormat.BitCount, BitCount);
end;
end
else
begin
{ B channel }
if rgbBlue in FHasChannels then
begin
BitCount := FHasChannelImages[rgbBlue].BitCount;
FParamsFormat.rgb_blue := dxtMakeChannel(((1 shl BitCount) - 1) shl FParamsFormat.BitCount, False);
Inc(FParamsFormat.BitCount, BitCount);
end;
 
{ G channel }
if rgbGreen in FHasChannels then
begin
BitCount := FHasChannelImages[rgbGreen].BitCount;
FParamsFormat.rgb_green := dxtMakeChannel(((1 shl BitCount) - 1) shl FParamsFormat.BitCount, False);
Inc(FParamsFormat.BitCount, BitCount);
end;
 
{ R channel }
if rgbRed in FHasChannels then
begin
BitCount := FHasChannelImages[rgbRed].BitCount;
FParamsFormat.rgb_red := dxtMakeChannel(((1 shl BitCount) - 1) shl FParamsFormat.BitCount, False);
Inc(FParamsFormat.BitCount, BitCount);
end;
 
{ Alpha channel }
if rgbAlpha in FHasChannels then
begin
BitCount := FHasChannelImages[rgbAlpha].BitCount;
FParamsFormat.rgb_alpha := dxtMakeChannel(((1 shl BitCount) - 1) shl FParamsFormat.BitCount, False);
Inc(FParamsFormat.BitCount, BitCount);
end;
end;
 
{ As for the number of bits only either of 1, 2, 4, 8, 16, 24, 32 }
if FParamsFormat.BitCount in [3] then
FParamsFormat.BitCount := 4
else
if FParamsFormat.BitCount in [5..7] then
FParamsFormat.BitCount := 8
else
if FParamsFormat.BitCount in [9..15] then
FParamsFormat.BitCount := 16
else
if FParamsFormat.BitCount in [17..23] then
FParamsFormat.BitCount := 24
else
if FParamsFormat.BitCount in [25..31] then
FParamsFormat.BitCount := 32;
 
{ Transparent color }
if (FParamsFormat.ImageType = DXTextureImageType_RGBColor) and (FParamsFormat.TransparentColor shr 24 = $01) then
begin
FParamsFormat.TransparentColor := RGB(FParamsFormat.idx_palette[Byte(FParamsFormat.TransparentColor)].peRed,
FParamsFormat.idx_palette[Byte(FParamsFormat.TransparentColor)].peGreen,
FParamsFormat.idx_palette[Byte(FParamsFormat.TransparentColor)].peBlue);
end;
end;
 
procedure TDXTBase.LoadChannelRGBAFromFile(const FileName: string);
begin
FStrImageFileName := FileName;
try
EvaluateChannels([rgbRed, rgbGreen, rgbBlue, rgbAlpha], '', '');
finally
FStrImageFileName := '';
end;
end;
 
procedure TDXTBase.SetChannelB(T: TDIB);
begin
FDIB := T;
try
EvaluateChannels([rgbBlue], '', '');
finally
FDIB := nil;
end;
end;
 
procedure TDXTBase.SetChannelRGB(T: TDIB);
begin
FDIB := T;
try
EvaluateChannels([rgbRed, rgbGreen, rgbBlue], '', '');
finally
FDIB := nil;
end;
end;
 
procedure TDXTBase.SaveToFile(iFilename: string {$IFDEF VER4UP} = ''{$ENDIF});
var
Image: TDXTextureImage;
begin
{ Create output stream }
Image := Self.Texture;
if (FHasImageList.Count > 0) and Assigned(Image) then
begin
if iFilename <> '' then
Image.SaveToFile(iFilename)
else
Image.SaveToFile(FParamsFormat.Name + '.dxt');
end;
end;
 
procedure TDXTBase.SetChannelA(T: TDIB);
begin
FDIB := T;
try
EvaluateChannels([rgbAlpha], '', '');
finally
FDIB := nil;
end;
end;
 
procedure TDXTBase.SetChannelG(T: TDIB);
begin
FDIB := T;
try
EvaluateChannels([rgbGreen], '', '');
finally
FDIB := nil;
end;
end;
 
destructor TDXTBase.Destroy;
var I: Integer;
begin
for I := 0 to FHasImageList.Count - 1 do
TDXTextureImage(FHasImageList[I]).Free;
FHasImageList.Free;
inherited Destroy;
end;
 
function TDXTBase.GetPicture: TDXTextureImage;
var
MemoryStream: TMemoryStream;
begin
Result := TDXTextureImage.Create;
try
if (FStrImageFileName <> '') and FileExists(FStrImageFileName) then
begin
Result.LoadFromFile(FStrImageFileName);
Result.FImageName := ExtractFilename(FStrImageFileName);
end
else
if Assigned(FDIB) then
begin
MemoryStream := TMemoryStream.Create;
try
FDIB.SaveToStream(MemoryStream);
MemoryStream.Position := 0; //reading from 0
Result.LoadFromStream(MemoryStream);
finally
MemoryStream.Free;
end;
Result.FImageName := Format('DIB%x', [Integer(Result)]); //supplement name
end;
except
on E: Exception do
begin
EDXTBaseError.Create(E.Message);
end;
end
end;
 
procedure TDXTBase.Resize(Image: TDXTextureImage; NewWidth, NewHeight: Integer;
FilterTypeResample: TFilterTypeResample);
//resize used for Mipmap
var
DIB: TDIB;
x, y: Integer;
c: DWORD;
MemoryStream: TMemoryStream;
begin
{ Exit when no resize }
if (Image.Width = NewWidth) and (Image.Height = NewHeight) then Exit;
{ Supplement for image resizing }
//raise EDXTBaseError.Create('Invalid image size for texture.');
{ No image at start }
DIB := TDIB.Create; //DIB accept
try
DIB.SetSize(Image.Width, Image.Height, Image.BitCount);
{ of type }
for y := 0 to Image.Height - 1 do
for x := 0 to Image.Width - 1 do
begin
if Image.ImageType = DXTextureImageType_PaletteIndexedColor then
begin
c := dxtDecodeChannel(Image.idx_index, Image.Pixels[x, y]);
DIB.Pixels[x, y] := (Image.idx_palette[c].peRed shl 16) or
(Image.idx_palette[c].peGreen shl 8) or
Image.idx_palette[c].peBlue;
end
else begin
c := Image.Pixels[x, y];
DIB.Pixels[x, y] := (dxtDecodeChannel(Image.rgb_red, c) shl 16) or
(dxtDecodeChannel(Image.rgb_green, c) shl 8) or
dxtDecodeChannel(Image.rgb_blue, c);
end;
end;
 
{ Resize for 24 bitcount deep }
Image.SetSize(DXTextureImageType_RGBColor, Width, Height, Image.BitCount, 0);
 
Image.rgb_red := dxtMakeChannel($FF0000, False);
Image.rgb_green := dxtMakeChannel($00FF00, False);
Image.rgb_blue := dxtMakeChannel($0000FF, False);
Image.rgb_alpha := dxtMakeChannel(0, False);
 
{ Resample routine DIB based there }
DIB.DoResample(Width, Height, FilterTypeResample);
 
{Image returned through stream}
Image.ClearImage;
MemoryStream := TMemoryStream.Create;
try
DIB.SaveToStream(MemoryStream);
MemoryStream.Position := 0; //from first byte
Image.LoadFromStream(MemoryStream);
finally
MemoryStream.Free;
end;
finally
DIB.Free;
end;
end;
 
procedure TDXTBase.EvaluateChannels
(const CheckChannelUsed: TDXTImageChannels;
const CheckChannelChanged, CheckBitCountForChannel: string);
var J: Integer;
Channel: TDXTImageChannel;
ChannelBitCount: array[TDXTImageChannel] of Integer;
ChannelParamName: TDXTImageChannels;
Image: TDXTextureImage;
Q: TDXTImageChannel;
begin
Fillchar(ChannelBitCount, SizeOf(ChannelBitCount), 0);
ChannelParamName := [];
{ The channel which you use acquisition }
J := 0;
for Q := rgbRed to rgbAlpha do
begin
if Q in CheckChannelUsed then
begin
Inc(J);
Channel := Q;
if not (Channel in FHasChannels) then
begin
if CheckBitCountForChannel <> '' then
ChannelBitCount[Channel] := StrToInt(Copy(CheckBitCountForChannel, j, 1))
else
ChannelBitCount[Channel] := 8; {poke default value}
if ChannelBitCount[Channel] <> 0 then
ChannelParamName := ChannelParamName + [Channel];
 
if CheckChannelChanged <> '' then
begin
case UpCase(CheckChannelChanged[j]) of
'R': FChannelChangeTable[Channel] := rgbRed;
'G': FChannelChangeTable[Channel] := rgbGreen;
'B': FChannelChangeTable[Channel] := rgbBlue;
'Y': FChannelChangeTable[Channel] := yuvY;
'N': FChannelChangeTable[Channel] := rgbNone;
else
raise EDXTBaseError.CreateFmt('Invalid channel type(%s)', [CheckChannelChanged[j]]);
end;
end;
end;
end;
end;
{ Processing of each }
if ChannelParamName <> [] then
begin
{ Picture load }
Image := nil;
{pokud je image uz nahrany tj. stejneho jmena, pokracuj dale}
for j := 0 to FHasImageList.Count - 1 do
if AnsiCompareFileName(TDXTextureImage(FHasImageList[j]).ImageName, FStrImageFileName) = 0 then
begin
Image := FHasImageList[j];
Break;
end;
{obrazek neexistuje, musi se dotahnout bud z proudu, souboru nebo odjinut}
if Image = nil then
begin
try
Image := GetPicture;
except
if Assigned(Image) then
begin
{$IFNDEF VER5UP}
Image.Free; Image := nil;
{$ELSE}
FreeAndNil(Image);
{$ENDIF}
end;
raise;
end;
FHasImageList.Add(Image);
end;
 
{ Each channel processing }
for Channel := Low(Channel) to High(Channel) do
if Channel in ChannelParamName then
begin
if ChannelBitCount[Channel] >= 0 then
FHasChannelImages[Channel].BitCount := ChannelBitCount[Channel]
else
begin
case Image.ImageType of
DXTextureImageType_PaletteIndexedColor:
begin
case Channel of
rgbRed: FHasChannelImages[Channel].BitCount := 8;
rgbGreen: FHasChannelImages[Channel].BitCount := 8;
rgbBlue: FHasChannelImages[Channel].BitCount := 8;
rgbAlpha: FHasChannelImages[Channel].BitCount := 8;
end;
end;
DXTextureImageType_RGBColor:
begin
case Channel of
rgbRed: FHasChannelImages[Channel].BitCount := Image.rgb_red.BitCount;
rgbGreen: FHasChannelImages[Channel].BitCount := Image.rgb_green.BitCount;
rgbBlue: FHasChannelImages[Channel].BitCount := Image.rgb_blue.BitCount;
rgbAlpha: FHasChannelImages[Channel].BitCount := 8;
end;
end;
end;
end;
if FHasChannelImages[Channel].BitCount = 0 then Continue;
FHasChannels := FHasChannels + [Channel];
FHasChannelImages[Channel].Image := Image;
end;
end;
end;
 
function TDXTBase.GetTexture: TDXTextureImage;
var
i, j: Integer;
SubImage: TDXTextureImage;
CurWidth, CurHeight: Integer;
begin
Result := nil;
if FHasImageList.Count = 0 then
raise EDXTBaseError.Create('No image found');
 
{ Output format calculation }
CalcOutputBitFormat;
Result := TDXTextureImage.Create;
try
Result.SetSize(FParamsFormat.ImageType, FParamsFormat.Width, FParamsFormat.Height, FParamsFormat.BitCount, 0);
 
Result.idx_index := FParamsFormat.idx_index;
Result.idx_alpha := FParamsFormat.idx_alpha;
Result.idx_palette := FParamsFormat.idx_palette;
 
Result.rgb_red := FParamsFormat.rgb_red;
Result.rgb_green := FParamsFormat.rgb_green;
Result.rgb_blue := FParamsFormat.rgb_blue;
Result.rgb_alpha := FParamsFormat.rgb_alpha;
 
Result.ImageName := FParamsFormat.Name;
 
Result.Transparent := FParamsFormat.Transparent;
if FParamsFormat.TransparentColor shr 24 = $01 then
Result.TransparentColor := dxtEncodeChannel(Result.idx_index, PaletteIndex(Byte(FParamsFormat.TransparentColor)))
else
Result.TransparentColor := Result.EncodeColor(GetRValue(FParamsFormat.TransparentColor), GetGValue(FParamsFormat.TransparentColor), GetBValue(FParamsFormat.TransparentColor), 0);
 
BuildImage(Result);
 
if FParamsFormat.ImageType = DXTextureImageType_RGBColor then
begin
BuildImage(Result);
{ Picture information store here }
CurWidth := FParamsFormat.Width;
CurHeight := FParamsFormat.Height;
for i := 0 to FParamsFormat.MipmapCount - 1 do
begin
CurWidth := CurWidth div 2;
CurHeight := CurHeight div 2;
if (CurWidth <= 0) or (CurHeight <= 0) then Break;
{ Resize calc here }
for j := 0 to FHasImageList.Count - 1 do
Resize(FHasImageList[j], CurWidth, CurHeight, ftrTriangle);
 
SubImage := TDXTextureImage.CreateSub(Result);
SubImage.SetSize(FParamsFormat.ImageType, CurWidth, CurHeight, FParamsFormat.BitCount, 0);
 
SubImage.idx_index := FParamsFormat.idx_index;
SubImage.idx_alpha := FParamsFormat.idx_alpha;
SubImage.idx_palette := FParamsFormat.idx_palette;
 
SubImage.rgb_red := FParamsFormat.rgb_red;
SubImage.rgb_green := FParamsFormat.rgb_green;
SubImage.rgb_blue := FParamsFormat.rgb_blue;
SubImage.rgb_alpha := FParamsFormat.rgb_alpha;
 
SubImage.ImageGroupType := DXTextureImageGroupType_Normal;
SubImage.ImageID := i;
SubImage.ImageName := Format('%s - mimap #%d', [Result.ImageName, i + 1]);
 
BuildImage(SubImage);
end;
end;
Result.FileCompressType := FParamsFormat.Compress;
except
on E: Exception do
begin
{$IFNDEF VER5UP}
Result.Free;
Result := nil;
{$ELSE}
FreeAndNil(Result);
{$ENDIF}
raise EDXTBaseError.Create(E.Message);
end;
end;
end;
 
{ DIB2DTX }
 
procedure dib2dxt(DIBImage: TDIB; out DXTImage: TDXTextureImage{$IFDEF DXTextureImage_UseZLIB}; const Shrink: Boolean = True{$ENDIF});
var
TexImage: TDXTBase;
DIB: TDIB;
begin
TexImage := TDXTBase.Create;
try
{$IFDEF DXTextureImage_UseZLIB}
if Shrink then
begin
TexImage.Compression := DXTextureImageFileCompressType_ZLIB;
TexImage.Mipmap := 4;
end;
{$ENDIF}
try
if DIBImage.HasAlphaChannel then
begin
DIB := DIBImage.RGBChannel;
TexImage.SetChannelRGB(DIB);
DIB.Free;
DIB := DIBImage.AlphaChannel;
TexImage.SetChannelA(DIB);
DIB.Free;
end
else
TexImage.SetChannelRGB(DIBImage);
 
DXTImage := TexImage.Texture;
except
if Assigned(DXTImage) then
DXTImage.Free;
DXTImage := nil;
end;
finally
TexImage.Free;
end
end;
 
{$IFDEF D3DRM}
 
{ TDirect3DRMUserVisual }
 
procedure TDirect3DRMUserVisual_D3DRMOBJECTCALLBACK(lpD3DRMobj: IDirect3DRMObject;
lpArg: Pointer); cdecl;
lpArg: Pointer); CDECL;
begin
TDirect3DRMUserVisual(lpArg).Free;
end;
11493,7 → 6149,7
 
function TDirect3DRMUserVisual_D3DRMUSERVISUALCALLBACK(lpD3DRMUV: IDirect3DRMUserVisual;
lpArg: Pointer; lpD3DRMUVreason: TD3DRMUserVisualReason;
lpD3DRMDev: IDirect3DRMDevice; lpD3DRMview: IDirect3DRMViewport): Integer; cdecl;
lpD3DRMDev: IDirect3DRMDevice; lpD3DRMview: IDirect3DRMViewport): Integer; CDECL;
begin
Result := TDirect3DRMUserVisual(lpArg).DoRender(lpD3DRMUVreason, lpD3DRMDev, lpD3DRMview);
end;
11503,8 → 6159,7
inherited Create;
 
if D3DRM.CreateUserVisual(@TDirect3DRMUserVisual_D3DRMUSERVISUALCALLBACK,
Self, FUserVisual) <> D3DRM_OK
then
Self, FUserVisual)<>D3DRM_OK then
raise EDirect3DRMUserVisualError.CreateFmt(SCannotMade, ['IDirect3DRMUserVisual']);
 
FUserVisual.AddDestroyCallback(@TDirect3DRMUserVisual_D3DRMOBJECTCALLBACK, Self);
11523,10 → 6178,13
begin
Result := 0;
end;
{$ENDIF}
 
{ TPictureCollectionItem }
 
const
SurfaceDivWidth = 512;
SurfaceDivHeight = 512;
 
type
TPictureCollectionItemPattern = class(TCollectionItem)
private
11602,7 → 6260,6
function TPictureCollectionItem.GetPatternRect(Index: Integer): TRect;
begin
if (Index >= 0) and (index < FPatterns.Count) then
//Result := (FPatterns.Items[Index] as TPictureCollectionItemPattern).FRect
Result := TPictureCollectionItemPattern(FPatterns.Items[Index]).FRect
else
Result := Rect(0, 0, 0, 0);
11622,14 → 6279,14
begin
if FSurfaceList.Count = 0 then
begin
if PatternWidth = 0 then PatternWidth := FPicture.Width; //prevent division by zero
XCount := FPicture.Width div (PatternWidth + SkipWidth);
if FPicture.Width - XCount * (PatternWidth + SkipWidth) = PatternWidth then
Inc(XCount);
if PatternHeight = 0 then PatternHeight := FPicture.Height; //prevent division by zero
 
YCount := FPicture.Height div (PatternHeight + SkipHeight);
if FPicture.Height - YCount * (PatternHeight + SkipHeight) = PatternHeight then
Inc(YCount);
 
Result := XCount * YCount;
end else
Result := FPatterns.Count;
11647,92 → 6304,15
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
{$IFDEF DrawHWAcc}
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.{$IFNDEF VER4UP}D2DRender2{$ELSE}D2DRender{$ENDIF}(Self, Bounds(X, Y, Width, Height), PatternIndex, rtDraw{$IFNDEF VER4UP}, $FF{$ENDIF});
end
else
{$ENDIF DrawHWAcc}
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.Draw(X, Y, FRect, FSurface, Transparent);
end;
end;
 
procedure TPictureCollectionItem.DrawFlipHV(Dest: TDirectDrawSurface; X, Y,
PatternIndex: Integer);
var
flrc: trect;
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
begin
flrc.Left := frect.right; flrc.Right := frect.left;
flrc.Top := fpicture.height - frect.top;
flrc.Bottom := fpicture.height - frect.bottom;
Dest.Draw(X, Y, Flrc, FSurface, Transparent);
end;
end;
 
procedure TPictureCollectionItem.DrawFlipH(Dest: TDirectDrawSurface; X, Y,
PatternIndex: Integer);
var
flrc: TRect;
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
begin
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Dest) then
begin
flrc := frect;
Dest.MirrorFlip([rmfMirror]);
end
else
begin
flrc.Left := fpicture.width - frect.left;
flrc.Right := fpicture.width - frect.right;
flrc.Top := frect.Top; flrc.Bottom := frect.Bottom;
end;
Dest.Draw(X, Y, Flrc, FSurface, Transparent);
end;
end;
 
procedure TPictureCollectionItem.DrawFlipV(Dest: TDirectDrawSurface; X, Y,
PatternIndex: Integer);
var
flrc: TRect;
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
begin
if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Dest) then
begin
flrc := frect;
Dest.MirrorFlip([rmfFlip]);
end
else
begin
flrc.Left := frect.left; flrc.Right := frect.right;
flrc.Top := fpicture.height - frect.top;
flrc.Bottom := fpicture.height - frect.bottom;
end;
Dest.Draw(X, Y, Flrc, FSurface, Transparent);
end;
end;
 
procedure TPictureCollectionItem.StretchDraw(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
{$IFDEF DrawHWAcc}
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.{$IFNDEF VER4UP}D2DRender2{$ELSE}D2DRender{$ENDIF}(Self, DestRect, PatternIndex, rtDraw{$IFNDEF VER4UP}, $FF{$ENDIF})
end
else
{$ENDIF DrawHWAcc}
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.StretchDraw(DestRect, FRect, FSurface, Transparent);
end;
11743,44 → 6323,16
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.{$IFNDEF VER4UP}D2DRender2{$ELSE}D2DRender{$ENDIF}(Self, DestRect, PatternIndex, rtAdd, Alpha)
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawAdd(DestRect, FRect, FSurface, Transparent, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawAddCol(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Color: Integer; Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderCol(Self, DestRect, PatternIndex, Color, rtAdd, Alpha)
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawAdd(DestRect, FRect, FSurface, Transparent, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawAlpha(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.{$IFNDEF VER4UP}D2DRender2{$ELSE}D2DRender{$ENDIF}(Self, DestRect, PatternIndex, rtBlend, Alpha)
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawAlpha(DestRect, FRect, FSurface, Transparent, Alpha);
end;
11791,49 → 6343,16
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.{$IFNDEF VER4UP}D2DRender2{$ELSE}D2DRender{$ENDIF}(Self, DestRect, PatternIndex, rtSub, Alpha)
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawSub(DestRect, FRect, FSurface, Transparent, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawSubCol(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Color: Integer; Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderCol(Self, DestRect, PatternIndex, Color, rtSub, Alpha)
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawSub(DestRect, FRect, FSurface, Transparent, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawRotate(Dest: TDirectDrawSurface; X, Y, Width, Height, PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single);
CenterX, CenterY: Double; Angle: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
//X,Y................ Center of rotation
//Width,Height....... Picture
//PatternIndex....... Piece of picture
//CenterX,CenterY ... Center of rotation on picture
//Angle.............. Angle of rotation
FDXDraw.FD2D.D2DRenderRotate(Self, X, Y, Width, Height, PatternIndex, rtDraw, CenterX, CenterY, Angle{$IFNDEF VER4UP}, $FF{$ENDIF});
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawRotate(X, Y, Width, Height, FRect, FSurface, CenterX, CenterY, Transparent, Angle);
end;
11840,16 → 6359,10
end;
 
procedure TPictureCollectionItem.DrawRotateAdd(Dest: TDirectDrawSurface; X, Y, Width, Height, PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single; Alpha: Integer);
CenterX, CenterY: Double; Angle, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderRotate(Self, X, Y, Width, Height, PatternIndex, rtAdd, CenterX, CenterY, Angle, Alpha);
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawRotateAdd(X, Y, Width, Height, FRect, FSurface, CenterX, CenterY, Transparent, Angle, Alpha);
end;
11856,16 → 6369,10
end;
 
procedure TPictureCollectionItem.DrawRotateAlpha(Dest: TDirectDrawSurface; X, Y, Width, Height, PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single; Alpha: Integer);
CenterX, CenterY: Double; Angle, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderRotate(Self, X, Y, Width, Height, PatternIndex, rtBlend, CenterX, CenterY, Angle, Alpha);
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawRotateAlpha(X, Y, Width, Height, FRect, FSurface, CenterX, CenterY, Transparent, Angle, Alpha);
end;
11872,16 → 6379,10
end;
 
procedure TPictureCollectionItem.DrawRotateSub(Dest: TDirectDrawSurface; X, Y, Width, Height, PatternIndex: Integer;
CenterX, CenterY: Double; Angle: single; Alpha: Integer);
CenterX, CenterY: Double; Angle, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderRotate(Self, X, Y, Width, Height, PatternIndex, rtSub, CenterX, CenterY, Angle, Alpha);
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawRotateSub(X, Y, Width, Height, FRect, FSurface, CenterX, CenterY, Transparent, Angle, Alpha);
end;
11892,13 → 6393,6
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderWaveX(Self, X, Y, Width, Height, PatternIndex, rtDraw,
Transparent, amp, Len, ph{$IFNDEF VER4UP}, $FF{$ENDIF});
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawWaveX(X, Y, Width, Height, FRect, FSurface, Transparent, amp, Len, ph);
end;
11909,13 → 6403,6
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderWaveX(Self, X, Y, Width, Height, PatternIndex, rtAdd,
Transparent, amp, Len, ph, Alpha);
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawWaveXAdd(X, Y, Width, Height, FRect, FSurface, Transparent, amp, Len, ph, Alpha);
end;
11926,13 → 6413,6
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderWaveX(Self, X, Y, Width, Height, PatternIndex, rtBlend,
Transparent, amp, Len, ph, Alpha);
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawWaveXAlpha(X, Y, Width, Height, FRect, FSurface, Transparent, amp, Len, ph, Alpha);
end;
11943,75 → 6423,11
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderWaveX(Self, X, Y, Width, Height, PatternIndex, rtSub,
Transparent, amp, Len, ph, Alpha);
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawWaveXSub(X, Y, Width, Height, FRect, FSurface, Transparent, amp, Len, ph, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawWaveYSub(Dest: TDirectDrawSurface; X, Y,
Width, Height, PatternIndex, amp, Len, ph, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderWaveY(Self, X, Y, Width, Height, PatternIndex, rtSub,
Transparent, amp, Len, ph, Alpha);
end
{there is not software version}
end;
end;
 
procedure TPictureCollectionItem.DrawWaveY(Dest: TDirectDrawSurface; X, Y,
Width, Height, PatternIndex, amp, Len, ph: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderWaveY(Self, X, Y, Width, Height, PatternIndex, rtDraw,
Transparent, amp, Len, ph{$IFNDEF VER4UP}, $FF{$ENDIF});
end
end;
end;
 
procedure TPictureCollectionItem.DrawWaveYAdd(Dest: TDirectDrawSurface; X, Y,
Width, Height, PatternIndex, amp, Len, ph, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderWaveY(Self, X, Y, Width, Height, PatternIndex, rtAdd,
Transparent, amp, Len, ph, Alpha);
end
end;
end;
 
procedure TPictureCollectionItem.DrawWaveYAlpha(Dest: TDirectDrawSurface; X, Y,
Width, Height, PatternIndex, amp, Len, ph, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderWaveY(Self, X, Y, Width, Height, PatternIndex, rtBlend,
Transparent, amp, Len, ph, Alpha);
end
end;
end;
 
procedure TPictureCollectionItem.Finalize;
begin
if FInitialized then
12021,98 → 6437,10
end;
end;
 
procedure TPictureCollectionItem.UpdateTag;
 
function AddSurface(const SrcRect: TRect): TDirectDrawSurface;
begin
Result := TDirectDrawSurface.Create(PictureCollection.DXDraw.DDraw);
FSurfaceList.Add(Result);
 
Result.SystemMemory := FSystemMemory;
Result.LoadFromGraphicRect(FPicture.Graphic, 0, 0, SrcRect);
Result.TransparentColor := Result.ColorMatch(FTransparentColor);
end;
 
var
x, y, x2, y2: Integer;
BlockWidth, BlockHeight, BlockXCount, BlockYCount: Integer;
Width2, Height2: Integer;
TempSurface : TDirectDrawSurface;
begin
if FPicture.Graphic = nil then Exit;
// ClearSurface;
Width2 := Width + SkipWidth;
Height2 := Height + SkipHeight;
 
if (Width = FPicture.Width) and (Height = FPicture.Height) then
begin
with TPictureCollectionItemPattern.Create(FPatterns) do
begin
TempSurface := TDirectDrawSurface.Create(PictureCollection.DXDraw.DDraw);
FSurface := TempSurface;
FRect := Bounds(0, 0, FPicture.Width, FPicture.Height);
TempSurface.LoadFromGraphicRect(FPicture.Graphic, 0, 0, FRect);
TempSurface.SystemMemory := FSystemMemory;
TempSurface.TransparentColor := TempSurface.ColorMatch(FTransparentColor);
FSurfaceList.Add(TempSurface);
end;
end
else
if FSystemMemory then
begin
AddSurface(Bounds(0, 0, FPicture.Width, FPicture.Height));
for y := 0 to (FPicture.Height + SkipHeight) div Height2 - 1 do
for x := 0 to (FPicture.Width + SkipWidth) div Width2 - 1 do
with TPictureCollectionItemPattern.Create(FPatterns) do
begin
FRect := Bounds(x * Width2, y * Height2, Width, Height);
FSurface := TDirectDrawSurface(FSurfaceList[0]);
end;
end
else
begin
{ Load to a video memory with dividing the image. }
BlockWidth := Min(((SurfaceDivWidth + Width2 - 1) div Width2) * Width2,
(FPicture.Width + SkipWidth) div Width2 * Width2);
BlockHeight := Min(((SurfaceDivHeight + Height2 - 1) div Height2) * Height2,
(FPicture.Height + SkipHeight) div Height2 * Height2);
 
if (BlockWidth = 0) or (BlockHeight = 0) then Exit;
 
BlockXCount := (FPicture.Width + BlockWidth - 1) div BlockWidth;
BlockYCount := (FPicture.Height + BlockHeight - 1) div BlockHeight;
 
for y := 0 to BlockYCount - 1 do
for x := 0 to BlockXCount - 1 do
begin
x2 := Min(BlockWidth, Max(FPicture.Width - x * BlockWidth, 0));
if x2 = 0 then x2 := BlockWidth;
 
y2 := Min(BlockHeight, Max(FPicture.Height - y * BlockHeight, 0));
if y2 = 0 then y2 := BlockHeight;
 
AddSurface(Bounds(x * BlockWidth, y * BlockHeight, x2, y2));
end;
 
for y := 0 to (FPicture.Height + SkipHeight) div Height2 - 1 do
for x := 0 to (FPicture.Width + SkipWidth) div Width2 - 1 do
begin
x2 := x * Width2;
y2 := y * Height2;
with TPictureCollectionItemPattern.Create(FPatterns) do
begin
FRect := Bounds(x2 - (x2 div BlockWidth * BlockWidth), y2 - (y2 div BlockHeight * BlockHeight), Width, Height);
FSurface := TDirectDrawSurface(FSurfaceList[(x2 div BlockWidth) + ((y2 div BlockHeight) * BlockXCount)]);
end;
end;
end;
end;
 
procedure TPictureCollectionItem.Initialize;
begin
Finalize;
FInitialized := PictureCollection.Initialized;
UpdateTag;
end;
 
procedure TPictureCollectionItem.Restore;
12154,9 → 6482,7
FRect := Bounds(0, 0, FPicture.Width, FPicture.Height);
FSurface := AddSurface(Bounds(0, 0, FPicture.Width, FPicture.Height));
end;
end
else
if FSystemMemory then
end else if FSystemMemory then
begin
{ Load to a system memory. }
AddSurface(Bounds(0, 0, FPicture.Width, FPicture.Height));
12168,8 → 6494,7
FRect := Bounds(x * Width2, y * Height2, Width, Height);
FSurface := TDirectDrawSurface(FSurfaceList[0]);
end;
end
else
end else
begin
{ Load to a video memory with dividing the image. }
BlockWidth := Min(((SurfaceDivWidth + Width2 - 1) div Width2) * Width2,
12206,13 → 6531,6
end;
end;
end;
{Code added for better compatibility}
{When is any picture changed, then all textures cleared and list have to reloaded}
with PictureCollection do
{$IFDEF D3D_deprecated}if (do3D in FDXDraw.Options) then{$ENDIF}
if AsSigned(FDXDraw.FD2D) then
if Assigned(FDXDraw.FD2D.D2DTextures) then
FDXDraw.FD2D.D2DTextures.D2DPruneAllTextures;
end;
 
procedure TPictureCollectionItem.SetPicture(Value: TPicture);
12239,121 → 6557,6
end;
end;
 
procedure TPictureCollectionItem.DrawAlphaCol(Dest: TDirectDrawSurface;
const DestRect: TRect; PatternIndex, Color, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderCol(Self, DestRect, PatternIndex, color, rtBlend, Alpha)
end else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawAlpha(DestRect, FRect, FSurface, Transparent, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawRotateAddCol(Dest: TDirectDrawSurface;
X, Y, Width, Height, PatternIndex: Integer; CenterX, CenterY: Double;
Angle: single; Color, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderRotateModeCol(Self, rtAdd, X, Y, Width,
Height, PatternIndex, CenterX, CenterY, Angle, Color, Alpha);
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawRotateAdd(X, Y, Width, Height, FRect, FSurface, CenterX, CenterY, Transparent, Angle, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawRotateAlphaCol(Dest: TDirectDrawSurface;
X, Y, Width, Height, PatternIndex: Integer; CenterX, CenterY: Double;
Angle: single; Color, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderRotateModeCol(Self, rtBlend, X, Y, Width,
Height, PatternIndex, CenterX, CenterY, Angle, Color, Alpha);
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawRotateAlpha(X, Y, Width, Height, FRect, FSurface, CenterX, CenterY, Transparent, Angle, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawRotateSubCol(Dest: TDirectDrawSurface;
X, Y, Width, Height, PatternIndex: Integer; CenterX, CenterY: Double;
Angle: single; Color, Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderRotateModeCol(Self, rtSub, X, Y, Width,
Height, PatternIndex, CenterX, CenterY, Angle, Color, Alpha);
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawRotateSub(X, Y, Width, Height, FRect, FSurface, CenterX, CenterY, Transparent, Angle, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawCol(Dest: TDirectDrawSurface;
const DestRect, SourceRect: TRect; PatternIndex: Integer; Faded: Boolean;
RenderType: TRenderType; Color, Specular: Integer; Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRenderColoredPartition(Self, DestRect, PatternIndex,
Color, Specular, Faded, SourceRect, RenderType,
Alpha)
end
else
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
Dest.DrawAlpha(DestRect, FRect, FSurface, Transparent, Alpha);
end;
end;
 
procedure TPictureCollectionItem.DrawRect(Dest: TDirectDrawSurface;
const DestRect, SourceRect: TRect; PatternIndex: Integer;
RenderType: TRenderType; Transparent: Boolean; Alpha: Integer);
begin
if FInitialized and (PatternIndex >= 0) and (PatternIndex < FPatterns.Count) then
begin
{$IFDEF DrawHWAcc}
with TPictureCollection(Self.GetPictureCollection) do
if FDXDraw.CheckD3D(Dest) then
begin
FDXDraw.FD2D.D2DRender(Self, DestRect, PatternIndex, SourceRect, RenderType, Alpha);
end
else
{$ENDIF DrawHWAcc}
with TPictureCollectionItemPattern(FPatterns.Items[PatternIndex]) do
begin
case RenderType of
rtDraw: Dest.StretchDraw(DestRect, SourceRect, FSurface, Transparent);
//Dest.Draw(DestRect.Left, DestRect.Top, SourceRect, FSurface, Transparent);
rtBlend: Dest.DrawAlpha(DestRect, SourceRect, FSurface, Transparent, Alpha);
rtAdd: Dest.DrawAdd(DestRect, SourceRect, FSurface, Transparent, Alpha);
rtSub: Dest.DrawSub(DestRect, SourceRect, FSurface, Transparent, Alpha);
end;
end;
end;
end;
 
{ TPictureCollection }
 
constructor TPictureCollection.Create(AOwner: TPersistent);
12400,22 → 6603,6
end;
end;
 
procedure TPictureCollection.InitializeImages(DXDraw: TCustomDXDraw; Id : Integer);
var
i: Integer;
begin
If id = -1 Then
Finalize;
FDXDraw := DXDraw;
 
if not Initialized then
raise EPictureCollectionError.CreateFmt(SCannotInitialized, [ClassName]);
 
for i := 0 to Count - 1 do
If (id = -1) or (id = i) Then
Items[i].Initialize;
end;
 
procedure TPictureCollection.Initialize(DXDraw: TCustomDXDraw);
var
i: Integer;
12674,7 → 6861,6
end;
 
constructor TDirectDrawOverlay.CreateWindowed(WindowHandle: HWND);
{$IFDEF D3D_deprecated}
const
PrimaryDesc: TDDSurfaceDesc = (
dwSize: SizeOf(PrimaryDesc);
12681,22 → 6867,12
dwFlags: DDSD_CAPS;
ddsCaps: (dwCaps: DDSCAPS_PRIMARYSURFACE)
);
{$ELSE}
var
PrimaryDesc: TDDSurfaceDesc2;
{$ENDIF}
begin
FDDraw2 := TDirectDraw.CreateEx(nil, False);
if FDDraw2.{$IFDEF D3D_deprecated}IDraw{$ELSE}IDraw7{$ENDIF}.SetCooperativeLevel(WindowHandle, DDSCL_NORMAL) <> DD_OK then
if FDDraw2.IDraw.SetCooperativeLevel(WindowHandle, DDSCL_NORMAL)<>DD_OK then
raise EDirectDrawOverlayError.CreateFmt(SCannotInitialized, [SOverlay]);
 
FTargetSurface2 := TDirectDrawSurface.Create(FDDraw2);
{$IFNDEF D3D_deprecated}
FillChar(PrimaryDesc, SizeOf(PrimaryDesc), 0);
PrimaryDesc.dwSize := SizeOf(PrimaryDesc);
PrimaryDesc.dwFlags := DDSD_CAPS;
PrimaryDesc.ddsCaps.dwCaps := DDSCAPS_PRIMARYSURFACE;
{$ENDIF}
if not FTargetSurface2.CreateSurface(PrimaryDesc) then
raise EDirectDrawOverlayError.CreateFmt(SCannotInitialized, [SOverlay]);
 
12717,17 → 6893,11
FSurface.Free; FSurface := nil;
end;
 
procedure TDirectDrawOverlay.Initialize(const SurfaceDesc: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF});
{$IFDEF D3D_deprecated}
procedure TDirectDrawOverlay.Initialize(const SurfaceDesc: TDDSurfaceDesc);
const
BackBufferCaps: TDDSCaps = (dwCaps: DDSCAPS_BACKBUFFER);
var
DDSurface: IDirectDrawSurface;
{$ELSE}
var
DDSurface: IDirectDrawSurface7;
BackBufferCaps: TDDSCaps2;
{$ENDIF}
begin
Finalize;
try
12736,21 → 6906,18
raise EDirectDrawOverlayError.CreateFmt(SCannotInitialized, [SOverlay]);
 
FBackSurface := TDirectDrawSurface.Create(FDDraw);
{$IFNDEF D3D_deprecated}
BackBufferCaps.dwCaps := DDSCAPS_BACKBUFFER;
{$ENDIF}
if SurfaceDesc.ddsCaps.dwCaps and DDSCAPS_FLIP <> 0 then
begin
if FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetAttachedSurface(BackBufferCaps, DDSurface) = DD_OK then
FBackSurface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := DDSurface;
end
else
FBackSurface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} := FSurface.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF};
if FSurface.ISurface.GetAttachedSurface(BackBufferCaps, DDSurface)=DD_OK then
FBackSurface.IDDSurface := DDSurface;
end else
FBackSurface.IDDSurface := FSurface.IDDSurface;
 
if FVisible then
SetOverlayRect(FOverlayRect)
else
FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.UpdateOverlay(PRect(nil), FTargetSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, PRect(nil), DDOVER_HIDE, PDDOverlayFX(nil));
FSurface.ISurface.UpdateOverlay(PRect(nil)^, FTargetSurface.ISurface, PRect(nil)^, DDOVER_HIDE, PDDOverlayFX(nil)^);
except
Finalize;
raise;
12762,7 → 6929,7
if FSurface = nil then Exit;
 
if FSurface.SurfaceDesc.ddsCaps.dwCaps and DDSCAPS_FLIP <> 0 then
FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.Flip(nil, DDFLIP_WAIT);
FSurface.ISurface.Flip(nil, DDFLIP_WAIT);
end;
 
procedure TDirectDrawOverlay.SetOverlayColorKey(Value: TColor);
12797,34 → 6964,26
XScaleRatio := (DestRect.right - DestRect.left) * 1000 div (SrcRect.right - SrcRect.left);
YScaleRatio := (DestRect.bottom - DestRect.top) * 1000 div (SrcRect.bottom - SrcRect.top);
 
if (FDDraw.DriverCaps.dwCaps and DDCAPS_OVERLAYSTRETCH <> 0)
and (FDDraw.DriverCaps.dwMinOverlayStretch <> 0)
and (XScaleRatio < Integer(FDDraw.DriverCaps.dwMinOverlayStretch))
then
if (FDDraw.DriverCaps.dwCaps and DDCAPS_OVERLAYSTRETCH<>0) and
(FDDraw.DriverCaps.dwMinOverlayStretch<>0) and (XScaleRatio<Integer(FDDraw.DriverCaps.dwMinOverlayStretch)) then
begin
DestRect.Right := DestRect.Left + (Integer(FSurface.SurfaceDesc.dwWidth) * (Integer(FDDraw.DriverCaps.dwMinOverlayStretch) + 1)) div 1000;
end;
 
if (FDDraw.DriverCaps.dwCaps and DDCAPS_OVERLAYSTRETCH <> 0)
and (FDDraw.DriverCaps.dwMaxOverlayStretch <> 0)
and (XScaleRatio > Integer(FDDraw.DriverCaps.dwMaxOverlayStretch))
then
if (FDDraw.DriverCaps.dwCaps and DDCAPS_OVERLAYSTRETCH<>0) and
(FDDraw.DriverCaps.dwMaxOverlayStretch<>0) and (XScaleRatio>Integer(FDDraw.DriverCaps.dwMaxOverlayStretch)) then
begin
DestRect.Right := DestRect.Left + (Integer(FSurface.SurfaceDesc.dwWidth) * (Integer(FDDraw.DriverCaps.dwMaxOverlayStretch) + 999)) div 1000;
end;
 
if (FDDraw.DriverCaps.dwCaps and DDCAPS_OVERLAYSTRETCH <> 0)
and (FDDraw.DriverCaps.dwMinOverlayStretch <> 0)
and (YScaleRatio < Integer(FDDraw.DriverCaps.dwMinOverlayStretch))
then
if (FDDraw.DriverCaps.dwCaps and DDCAPS_OVERLAYSTRETCH<>0) and
(FDDraw.DriverCaps.dwMinOverlayStretch<>0) and (YScaleRatio<Integer(FDDraw.DriverCaps.dwMinOverlayStretch)) then
begin
DestRect.Bottom := DestRect.Top + (Integer(FSurface.SurfaceDesc.dwHeight) * (Integer(FDDraw.DriverCaps.dwMinOverlayStretch) + 1)) div 1000;
end;
 
if (FDDraw.DriverCaps.dwCaps and DDCAPS_OVERLAYSTRETCH <> 0)
and (FDDraw.DriverCaps.dwMaxOverlayStretch <> 0)
and (YScaleRatio > Integer(FDDraw.DriverCaps.dwMaxOverlayStretch))
then
if (FDDraw.DriverCaps.dwCaps and DDCAPS_OVERLAYSTRETCH<>0) and
(FDDraw.DriverCaps.dwMaxOverlayStretch<>0) and (YScaleRatio>Integer(FDDraw.DriverCaps.dwMaxOverlayStretch)) then
begin
DestRect.Bottom := DestRect.Top + (Integer(FSurface.SurfaceDesc.dwHeight) * (Integer(FDDraw.DriverCaps.dwMaxOverlayStretch) + 999)) div 1000;
end;
12892,7 → 7051,7
OverlayFlags := OverlayFlags or (DDOVER_KEYDESTOVERRIDE or DDOVER_DDFX);
end;
 
FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.UpdateOverlay(@SrcRect, FTargetSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, @DestRect, OverlayFlags, @OverlayFX);
FSurface.ISurface.UpdateOverlay(SrcRect, FTargetSurface.ISurface, DestRect, OverlayFlags, OverlayFX);
end;
end;
 
12904,3614 → 7063,13
if FVisible then
SetOverlayRect(FOverlayRect)
else
FSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.UpdateOverlay(PRect(nil), FTargetSurface.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}, PRect(nil), DDOVER_HIDE, PDDOverlayFX(nil));
FSurface.ISurface.UpdateOverlay(PRect(nil)^, FTargetSurface.ISurface, PRect(nil)^, DDOVER_HIDE, PDDOverlayFX(nil)^);
end;
end;
 
{ TDXFont }
 
constructor TDXFont.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
 
destructor TDXFont.Destroy;
begin
inherited Destroy;
end;
 
procedure TDXFont.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FDXImageList) then
begin
FDXImageList := nil;
end;
end; {Notification}
 
procedure TDXFont.SetFont(const Value: string);
begin
FFont := Value;
if assigned(FDXImageList) then
begin
FFontIndex := FDXImageList.items.IndexOf(FFont); { find font once }
fOffset := FDXImageList.Items[FFontIndex].PatternWidth;
end;
end;
 
procedure TDXFont.SetFontIndex(const Value: Integer);
begin
FFontIndex := Value;
if assigned(FDXImageList) then
begin
FFont := FDXImageList.Items[FFontIndex].Name;
fOffset := FDXImageList.Items[FFontIndex].PatternWidth;
end;
end;
 
procedure TDXFont.TextOut(DirectDrawSurface: TDirectDrawSurface; X, Y: Integer; const Text: string);
var
loop, letter: Integer;
UpperText: string;
begin
if not assigned(FDXImageList) then
exit;
Offset := FDXImageList.Items[FFontIndex].PatternWidth;
UpperText := AnsiUppercase(text);
for loop := 1 to Length(UpperText) do
begin
letter := AnsiPos(UpperText[loop], Alphabet) - 1;
if letter < 0 then letter := 30;
FDXImageList.items[FFontIndex].Draw(DirectDrawSurface, x + Offset * loop, y, letter);
end; { loop }
end;
 
{ TDXPowerFontEffectsParameters }
 
procedure TDXPowerFontEffectsParameters.SetAlphaValue(
const Value: Integer);
begin
FAlphaValue := Value;
end;
 
procedure TDXPowerFontEffectsParameters.SetAngle(const Value: Integer);
begin
FAngle := Value;
end;
 
procedure TDXPowerFontEffectsParameters.SetCenterX(const Value: Integer);
begin
FCenterX := Value;
end;
 
procedure TDXPowerFontEffectsParameters.SetCenterY(const Value: Integer);
begin
FCenterY := Value;
end;
 
procedure TDXPowerFontEffectsParameters.SetHeight(const Value: Integer);
begin
FHeight := Value;
end;
 
procedure TDXPowerFontEffectsParameters.SetWAmplitude(
const Value: Integer);
begin
FWAmplitude := Value;
end;
 
procedure TDXPowerFontEffectsParameters.SetWidth(const Value: Integer);
begin
FWidth := Value;
end;
 
procedure TDXPowerFontEffectsParameters.SetWLenght(const Value: Integer);
begin
FWLenght := Value;
end;
 
procedure TDXPowerFontEffectsParameters.SetWPhase(const Value: Integer);
begin
FWPhase := Value;
end;
 
{ TDXPowerFont }
 
constructor TDXPowerFont.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FUseEnterChar := True;
FEnterCharacter := '|<';
FAlphabets := PowerAlphaBet;
FTextOutType := ttNormal;
FTextOutEffect := teNormal;
FEffectsParameters := TDXPowerFontEffectsParameters.Create;
end;
 
destructor TDXPowerFont.Destroy;
begin
inherited Destroy;
end;
 
procedure TDXPowerFont.SetAlphabets(const Value: string);
begin
if FDXImageList <> nil then
if Length(Value) > FDXImageList.Items[FFontIndex].PatternCount - 1 then Exit;
FAlphabets := Value;
end;
 
procedure TDXPowerFont.SetEnterCharacter(const Value: string);
begin
if Length(Value) >= 2 then Exit;
FEnterCharacter := Value;
end;
 
procedure TDXPowerFont.SetFont(const Value: string);
begin
FFont := Value;
if FDXImageList <> nil then
begin
FFontIndex := FDXImageList.Items.IndexOf(FFont); // Find font once...
Offset := FDXImageList.Items[FFontIndex].PatternWidth;
 
FEffectsParameters.Width := FDXImageList.Items[FFontIndex].PatternWidth;
FEffectsParameters.Height := FDXImageList.Items[FFontIndex].PatternHeight;
end;
end;
 
procedure TDXPowerFont.SetFontIndex(const Value: Integer);
begin
FFontIndex := Value;
if FDXImageList <> nil then
begin
FFont := FDXImageList.Items[FFontIndex].Name;
Offset := FDXImageList.Items[FFontIndex].PatternWidth;
 
FEffectsParameters.Width := FDXImageList.Items[FFontIndex].PatternWidth;
FEffectsParameters.Height := FDXImageList.Items[FFontIndex].PatternHeight;
end;
end;
 
procedure TDXPowerFont.SetEffectsParameters(const Value: TDXPowerFontEffectsParameters);
begin
FEffectsParameters := Value;
end;
 
procedure TDXPowerFont.SetTextOutEffect(const Value: TDXPowerFontTextOutEffect);
begin
FTextOutEffect := Value;
end;
 
procedure TDXPowerFont.SetTextOutType(const Value: TDXPowerFontTextOutType);
begin
FTextOutType := Value;
end;
 
procedure TDXPowerFont.SetUseEnterChar(const Value: Boolean);
begin
FUseEnterChar := Value;
end;
 
function TDXPowerFont.TextOutFast(DirectDrawSurface: TDirectDrawSurface; X, Y: Integer; const Text: string): Boolean;
var
Loop, Letter: Integer;
txt: string;
begin
Result := False;
if FDXImageList = nil then Exit;
// modified
case FTextOutType of
ttNormal: Txt := Text;
ttUpperCase: Txt := AnsiUpperCase(Text);
ttLowerCase: Txt := AnsiLowerCase(Text);
end;
Offset := FDXImageList.Items[FFontIndex].PatternWidth;
Loop := 1;
while (Loop <= Length(Text)) do
begin
Letter := AnsiPos(txt[Loop], FAlphabets); // modified
if (Letter > 0) and (Letter < FDXImageList.Items[FFontIndex].PatternCount - 1) then
FDXImageList.Items[FFontIndex].Draw(DirectDrawSurface, X + (Offset * Loop), Y, Letter - 1);
Inc(Loop);
end;
Result := True;
end;
 
function TDXPowerFont.TextOut(DirectDrawSurface: TDirectDrawSurface; X, Y: Integer; const Text: string): Boolean;
var
Loop, Letter: Integer;
FCalculatedEnters, EnterHeghit, XLoop: Integer;
DoTextOut: Boolean;
Txt: string;
Rect: TRect;
begin
Result := False;
if FDXImageList = nil then Exit;
Txt := Text;
DoTextOut := True;
if Assigned(FBeforeTextOut) then FBeforeTextOut(Self, Txt, DoTextOut);
if not DoTextOut then Exit;
// modified
case FTextOutType of
ttNormal: Txt := Text;
ttUpperCase: Txt := AnsiUpperCase(Text);
ttLowerCase: Txt := AnsiLowerCase(Text);
end;
Offset := FDXImageList.Items[FFontIndex].PatternWidth;
FCalculatedEnters := 0;
EnterHeghit := FDXImageList.Items[FFontIndex].PatternHeight;
XLoop := 0;
Loop := 1;
while (Loop <= Length(Txt)) do
begin
if FUseEnterChar then
begin
if Txt[Loop] = FEnterCharacter[1] then begin Inc(FCalculatedEnters); Inc(Loop); end;
if Txt[Loop] = FEnterCharacter[2] then begin Inc(FCalculatedEnters); XLoop := 0; {-FCalculatedEnters;} Inc(Loop); end;
end;
Letter := AnsiPos(Txt[Loop], FAlphabets); // modified
 
if (Letter > 0) and (Letter < FDXImageList.Items[FFontIndex].PatternCount - 1) then
case FTextOutEffect of
teNormal: FDXImageList.Items[FFontIndex].Draw(DirectDrawSurface, X + (Offset * XLoop), Y + (FCalculatedEnters * EnterHeghit), Letter - 1);
teRotat: FDXImageList.Items[FFontIndex].DrawRotate(DirectDrawSurface, X + (Offset * XLoop), Y + (FCalculatedEnters * EnterHeghit), FEffectsParameters.Width, FEffectsParameters.Height, Letter - 1, FEffectsParameters.CenterX, FEffectsParameters.CenterY, FEffectsParameters.Angle);
teAlphaBlend:
begin
Rect.Left := X + (Offset * XLoop);
Rect.Top := Y + (FCalculatedEnters * EnterHeghit);
Rect.Right := Rect.Left + FEffectsParameters.Width;
Rect.Bottom := Rect.Top + FEffectsParameters.Height;
 
FDXImageList.Items[FFontIndex].DrawAlpha(DirectDrawSurface, Rect, Letter - 1, FEffectsParameters.AlphaValue);
end;
teWaveX: FDXImageList.Items[FFontIndex].DrawWaveX(DirectDrawSurface, X + (Offset * XLoop), Y + (FCalculatedEnters * EnterHeghit), FEffectsParameters.Width, FEffectsParameters.Height, Letter - 1, FEffectsParameters.WAmplitude, FEffectsParameters.WLenght, FEffectsParameters.WPhase);
end;
Inc(Loop);
Inc(XLoop);
end;
if Assigned(FAfterTextOut) then FAfterTextOut(Self, Txt);
Result := True;
end;
 
//---------------------------------------------------------------------------
{
Main code supported hardware acceleration by videoadapteur
* Copyright (c) 2004-2010 Jaro Benes
* All Rights Reserved
* Version 1.09
* D2D Hardware module - main implementation part
* web site: www.micrel.cz/Dx
* e-mail: delphix_d2d@micrel.cz
}
 
constructor TD2DTextures.Create(DDraw: TCustomDXDraw);
begin
//inherited;
FDDraw := DDraw; //reload DDraw
{$IFNDEF VER4UP}
TexLen := 0;
Texture := nil;
{$ELSE}
SetLength(Texture, 0);
{$ENDIF}
end;
 
destructor TD2DTextures.Destroy;
var
I: Integer;
begin
if Assigned(Texture) then
{$IFDEF VER4UP}
for I := Low(Texture) to High(Texture) do
begin
Texture[I].D2DTexture.Free;
{$IFDEF VIDEOTEX}
if Assigned(Texture[I].VDIB) then
Texture[I].VDIB.Free;
{$ENDIF}
end;
{$ELSE}
for I := 0 to TexLen - 1 do
begin
Texture[I].D2DTexture.Free;
{$IFDEF VIDEOTEX}
if Assigned(Texture[I].VDIB) then
Texture[I].VDIB.Free;
{$ENDIF}
end;
{$ENDIF}
inherited;
end;
 
function TD2DTextures.GetD2DMaxTextures: Integer;
begin
Result := {$IFDEF VER4UP}Length(Texture){$ELSE}TexLen{$ENDIF};
end;
 
procedure TD2DTextures.SaveTextures(path: string);
var I: Integer;
begin
if Texture <> nil then
{$IFDEF VER4UP}
if Length(Texture) > 0 then
for I := Low(Texture) to High(Texture) do
{$ELSE}
if TexLen > 0 then
for I := 0 to TexLen - 1 do
{$ENDIF}
Texture[I].D2DTexture.FImage.SaveToFile(path + Texture[I].Name + '.dxt');
end;
 
procedure TD2DTextures.SetD2DMaxTextures(const Value: Integer);
begin
if Value > 0 then
{$IFDEF VER4UP}
SetLength(Texture, Value)
{$ELSE}
Inc(TexLen);
if Texture = nil then
Texture := AllocMem(SizeOf(TTextureRec))
else begin
{alokuj pamet}
ReallocMem(Texture, TexLen * SizeOf(TTextureRec));
end;
{$ENDIF}
end;
 
function TD2DTextures.Find(byName: string): Integer;
var I: Integer;
begin
Result := -1;
if Texture <> nil then
{$IFDEF VER4UP}
if Length(Texture) > 0 then
for I := Low(Texture) to High(Texture) do
if AnsiUpperCase(Texture[I].Name) = AnsiUpperCase(byName) then
begin
Result := I;
Exit;
end;
{$ELSE}
if TexLen > 0 then
for I := 0 to TexLen - 1 do
if AnsiUpperCase(Texture[I].Name) = AnsiUpperCase(byName) then
begin
Result := I;
Exit;
end;
{$ENDIF}
end;
 
function TD2DTextures.GetTextureByName(const byName: string): TDirect3DTexture2;
begin
Result := nil;
if Assigned(Texture) then
Result := Texture[Find(byName)].D2DTexture;
end;
 
function TD2DTextures.GetTextureByIndex(const byIndex: Integer): TDirect3DTexture2;
begin
Result := nil;
{$IFNDEF VER4UP}
if Assigned(Texture) and (byIndex >= 0) and (byIndex <= (TexLen - 1)) then
Result := Texture[byIndex].D2DTexture;
{$ELSE}
if Assigned(Texture) and (byIndex in [0..High(Texture)]) then
Result := Texture[byIndex].D2DTexture;
{$ENDIF}
end;
 
function TD2DTextures.GetTextureNameByIndex(const byIndex: Integer): string;
begin
Result := '';
{$IFNDEF VER4UP}
if Assigned(Texture) and (byIndex >= 0) and (byIndex <= (TexLen - 1)) then
Result := Texture[byIndex].Name;
{$ELSE}
if Assigned(Texture) and (byIndex in [0..High(Texture)]) then
Result := Texture[byIndex].Name;
{$ENDIF}
end;
 
function TD2DTextures.Count: Integer;
begin
Result := 0;
if Assigned(Texture) then
{$IFNDEF VER4UP}
Result := TexLen;
{$ELSE}
Result := High(Texture) + 1;
{$ENDIF}
end;
 
procedure TD2DTextures.D2DPruneAllTextures;
var I: Integer;
begin
if not Assigned(Texture) then Exit;
{$IFDEF VER4UP}
for I := Low(Texture) to High(Texture) do
{$ELSE}
for I := 0 to TexLen - 1 do
{$ENDIF}
begin
Texture[I].D2DTexture.Free;
{$IFDEF VIDEOTEX}
if Assigned(Texture[I].VDIB) then
Texture[I].VDIB.Free;
{$ENDIF}
end;
{$IFDEF VER4UP}
SetLength(Texture, 0);
{$ELSE}
TexLen := 0;
{$ENDIF}
end;
 
procedure TD2DTextures.D2DFreeTextures;
var I: Integer;
begin
if not Assigned(Texture) then Exit;
{$IFDEF VER4UP}
for I := Low(Texture) to High(Texture) do
{$ELSE}
for I := 0 to TexLen - 1 do
{$ENDIF}
begin
Texture[I].D2DTexture.Free;
{$IFDEF VIDEOTEX}
if Assigned(Texture[I].VDIB) then
Texture[I].VDIB.Free;
{$ENDIF}
end;
{$IFNDEF VER4UP}
FreeMem(Texture, TexLen * SizeOf(TTextureRec));
Texture := nil;
{$ENDIF}
end;
 
procedure TD2DTextures.D2DPruneTextures;
begin
if {$IFDEF VER4UP}Length(Texture){$ELSE}TexLen{$ENDIF} > maxTexBlock then
begin
D2DPruneAllTextures
end;
end;
 
procedure TD2DTextures.SizeAdjust(var DIB: TDIB; var FloatX1, FloatY1, FloatX2, FloatY2: Double);
var
X, Y: Integer;
tempDIB: TDIB;
begin {auto-adjust size n^2 for accelerator compatibility}
X := 1;
repeat
X := X * 2;
until DIB.Width <= X;
Y := 1;
repeat
Y := Y * 2
until DIB.Height <= Y;
{$IFDEF FORCE_SQUARE}
X := Max(X, Y);
Y := X;
{$ENDIF}
if (X = DIB.Width) and (Y = DIB.Height) then
begin
if DIB.BitCount = 32 then Exit; {do not touch}
{code for correction a DIB.BitCount to 24 bit only}
tempDIB := TDIB.Create;
try
tempDIB.SetSize(X, Y, 24);
FillChar(tempDIB.PBits^, tempDIB.Size, 0);
tempDIB.Canvas.Draw(0, 0, DIB);
DIB.Assign(tempDIB);
finally
tempDIB.Free;
end;
Exit;
end;
tempDIB := TDIB.Create;
try
if DIB.BitCount = 32 then
begin
tempDIB.SetSize(X, Y, 32);
FillChar(tempDIB.PBits^, tempDIB.Size, 0);
//tempDIB.Canvas.Brush.Color := clBlack;
//tempDIB.Canvas.FillRect(Bounds(0, 0, X, Y));
tempDIB.Canvas.Draw(0, 0, DIB);
// if DIB.HasAlphaChannel then
// tempDIB.AssignAlphaChannel(DIB);
end
else
begin
tempDIB.SetSize(X, Y, 24 {DIB.BitCount}); {bad value for some 16}
FillChar(tempDIB.PBits^, tempDIB.Size, 0);
//tempDIB.Canvas.Brush.Color := clBlack;
//tempDIB.Canvas.FillRect(Bounds(0, 0, X, Y));
tempDIB.Canvas.Draw(0, 0, DIB);
end;
FloatX2 := (1 / tempDIB.Width) * DIB.Width;
FloatY2 := (1 / tempDIB.Height) * DIB.Height;
DIB.Assign(tempDIB);
finally
tempDIB.Free;
end
end;
 
function TD2DTextures.CanFindTexture(aImage: TPictureCollectionItem): Boolean;
var I: Integer;
begin
Result := True;
{$IFDEF VER4UP}
if Length(Texture) > 0 then
{$ELSE}
if TexLen > 0 then
{$ENDIF}
for I := 0 to D2DMaxTextures - 1 do
if Texture[I].Name = aImage.Name then Exit;
Result := False;
end;
 
function TD2DTextures.LoadTextures(aImage: TPictureCollectionItem): Boolean;
var
{$IFNDEF VIDEOTEX}
VDIB: TDIB;
{$ENDIF}
T: TDXTextureImage;
begin
Result := True;
try
D2DPruneTextures; {up to maxTexBlock textures only}
D2DMaxTextures := D2DMaxTextures + 1;
if aImage.Name = '' then // FIX: OPTIMIZED
aImage.Name := aImage.GetNamePath; {this name is supplement name, when wasn't aImage.Name fill}
{$IFDEF VIDEOTEX}Texture[D2DMaxTextures - 1].{$ENDIF}VDIB := TDIB.Create;
try
with Texture[D2DMaxTextures - 1] do
begin
VDIB.Assign(aImage.Picture.Graphic);
VDIB.Transparent := aImage.Transparent;
FloatX1 := 0; FloatY1 := 0; FloatX2 := 1; FloatY2 := 1;
SizeAdjust(VDIB, FloatX1, FloatY1, FloatX2, FloatY2);
Name := aImage.Name;
Width := VDIB.Width;
Height := VDIB.Height;
if VDIB.HasAlphaChannel then
begin
DIB2DXT(VDIB, T);
T.ImageName := aImage.Name;
T.Transparent := aImage.Transparent;
D2DTexture := TDirect3DTexture2.Create(FDDraw, T, False);
D2DTexture.Transparent := aImage.Transparent;
AlphaChannel := True;
//**T.Free; DO NOT FREE - surface is lost ** FIX by JB.
end
else
begin
D2DTexture := TDirect3DTexture2.Create(FDDraw, VDIB, False);
D2DTexture.TransparentColor := DWORD(aImage.TransparentColor);
D2DTexture.Surface.TransparentColor := DWORD(aImage.TransparentColor);
D2DTexture.Transparent := aImage.Transparent;
AlphaChannel := False;
end;
end;
finally
{$IFNDEF VIDEOTEX}
VDIB.Free;
{$ENDIF}
end;
except
D2DMaxTextures := D2DMaxTextures - 1;
Result := False;
end;
end;
 
{$IFDEF VER4UP}
function TD2DTextures.CanFindTexture(const TexName: string): Boolean;
{$ELSE}
function TD2DTextures.CanFindTexture2(const TexName: string): Boolean;
{$ENDIF}
var I: Integer;
begin
Result := True;
{$IFDEF VER4UP}
if Length(Texture) > 0 then
{$ELSE}
if TexLen > 0 then
{$ENDIF}
for I := 0 to D2DMaxTextures - 1 do
if Texture[I].Name = TexName then Exit;
Result := False;
end;
 
function TD2DTextures.SetTransparentColor(dds: TDirectDrawSurface; PixelColor: Integer; Transparent: Boolean): Integer;
{Give a speculative transparent color value from DDS}
var
ddck: TDDColorKey;
CLL: Integer;
begin
Result := 0;
if dds.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
if dds.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetColorKey(DDCKEY_SRCBLT, ddck) = DD_OK then
Result := ddck.dwColorSpaceLowValue;
CLL := PixelColor; {have to pick up color from 0,0 pix of DIB}
if Transparent then {and must be transparent}
if (CLL <> Result) then {when different}
Result := CLL; {use our TransparentColor}
end;
 
{$IFDEF VER4UP}
function TD2DTextures.LoadTextures(dds: TDirectDrawSurface; Transparent: Boolean; asTexName: string): Boolean;
{$ELSE}
function TD2DTextures.LoadTextures2(dds: TDirectDrawSurface; Transparent: Boolean; asTexName: string): Boolean;
{$ENDIF}
var
{$IFNDEF VIDEOTEX}
VDIB: TDIB;
{$ENDIF}
Col: Integer;
T: PTextureRec;
begin
Result := True;
T := nil;
try
if dds.Modified then
begin
{search existing texture and return the pointer}
T := Addr(Texture[Find(asTexName)]);
{$IFNDEF VIDEOTEX}VDIB := TDIB.Create;{$ENDIF}
end
else
begin
D2DPruneTextures; {up to maxTexBlock textures only}
D2DMaxTextures := D2DMaxTextures + 1; {next to new space}
T := Addr(Texture[D2DMaxTextures - 1]); {is new place}
{set name}
T.Name := asTexName;
{and create video-dib object for store the picture periodically changed}
{$IFDEF VIDEOTEX}T.{$ENDIF}VDIB := TDIB.Create;
//T.VDIB.PixelFormat := MakeDIBPixelFormat(8, 8, 8);
end;
try
{the dds assigned here}
{$IFDEF VIDEOTEX}T.{$ENDIF}VDIB.Assign(dds);
{with full adjustation}
T.FloatX1 := 0; T.FloatY1 := 0; T.FloatX2 := 1; T.FloatY2 := 1;
SizeAdjust({$IFDEF VIDEOTEX}T.{$ENDIF}VDIB, T.FloatX1, T.FloatY1, T.FloatX2, T.FloatY2);
{and store 'changed' values of size here}
T.Width := {$IFDEF VIDEOTEX}T.{$ENDIF}VDIB.Width;
T.Height := {$IFDEF VIDEOTEX}T.{$ENDIF}VDIB.Height;
{and it have to set by dds as transparent, when it set up}
{$IFDEF VIDEOTEX}T.{$ENDIF}VDIB.Transparent := Transparent;
{get up transparent color}
Col := SetTransparentColor(dds, {$IFDEF VIDEOTEX}T.{$ENDIF}VDIB.Pixels[0, 0], Transparent);
if dds.Modified then
T.D2DTexture.Load {for minimize time only load as videotexture}
else
T.D2DTexture := TDirect3DTexture2.Create(FDDraw, {$IFDEF VIDEOTEX}T.{$ENDIF}VDIB, False); {create it}
{don't forget set transparent values on texture!}
T.D2DTexture.TransparentColor := DWORD(COL);
T.D2DTexture.Surface.TransparentColor := DWORD(COL);
T.D2DTexture.Transparent := Transparent;
finally
{$IFNDEF VIDEOTEX}
if Assigned(VDIB) then VDIB.Free;
{$ENDIF}
end;
except
{eh, sorry, when is not the dds modified, roll back and release last the VDIB}
if not dds.Modified then
if T <> nil then
begin
if Assigned({$IFDEF VIDEOTEX}T.{$ENDIF}VDIB) then
{$IFNDEF D5UP}
begin {$IFDEF VIDEOTEX}T.{$ENDIF}VDIB.Free; {$IFDEF VIDEOTEX}T.{$ENDIF}VDIB := nil; end;
{$ELSE}
FreeAndNil({$IFDEF VIDEOTEX}T.{$ENDIF}VDIB);
{$ENDIF}
if Assigned(T.D2DTexture) then
{$IFNDEF D5UP}
begin T.D2DTexture.Free; T.D2DTexture := nil; end;
{$ELSE}
FreeAndNil(T.D2DTexture);
{$ENDIF}
 
D2DMaxTextures := D2DMaxTextures - 1; //go back
end;
Result := False;
end;
dds.Modified := False; {this flag turn off always}
end;
 
{$IFDEF VER4UP}
function TD2DTextures.LoadTextures(dds: TDirectDrawSurface; Transparent: Boolean;
TransparentColor: Integer; asTexName: string): Boolean;
{$ELSE}
function TD2DTextures.LoadTextures3(dds: TDirectDrawSurface; Transparent: Boolean;
TransparentColor: Integer; asTexName: string): Boolean;
{$ENDIF}
function getDDSTransparentColor(DIB: TDIB; dds: TDirectDrawSurface): Integer;
var CLL: Integer; ddck: TDDColorKey;
begin
Result := 0;
if dds.{$IFDEF D3D_deprecated}IDDSurface{$ELSE}IDDSurface7{$ENDIF} <> nil then
if dds.{$IFDEF D3D_deprecated}ISurface{$ELSE}ISurface7{$ENDIF}.GetColorKey(DDCKEY_SRCBLT, ddck) = DD_OK then
Result := ddck.dwColorSpaceLowValue;
CLL := TransparentColor;
if (CLL = -1) or (cardinal(CLL) <> DIB.Pixels[0, 0]) then //when is DDS
CLL := DIB.Pixels[0, 0]; //have to pick up color from 0,0 pix of DIB
if Transparent then //and must be transparent
if CLL <> Result then //when different
Result := CLL; //use TransparentColor
end;
var
{$IFNDEF VIDEOTEX}
VDIB: TDIB;
{$ENDIF}
COL: Integer;
T: TDXTextureImage;
begin
Result := True;
try
D2DPruneTextures; {up to maxTexBlock textures only}
D2DMaxTextures := D2DMaxTextures + 1;
Texture[D2DMaxTextures - 1].Name := asTexName;
{$IFDEF VIDEOTEX}Texture[D2DMaxTextures - 1].{$ENDIF}VDIB := TDIB.Create;
try
with Texture[D2DMaxTextures - 1] do
begin
VDIB.AsSign(dds);
VDIB.Transparent := Transparent;
FloatX1 := 0; FloatY1 := 0; FloatX2 := 1; FloatY2 := 1;
SizeAdjust(VDIB, FloatX1, FloatY1, FloatX2, FloatY2);
Width := VDIB.Width;
Height := VDIB.Height;
if VDIB.HasAlphaChannel then
begin
DIB2DXT(VDIB, T);
T.ImageName := asTexName;
T.Transparent := Transparent;
D2DTexture := TDirect3DTexture2.Create(FDDraw, T, False);
D2DTexture.Transparent := Transparent;
AlphaChannel := True;
//**T.Free; DO NOT FREE - surface is lost ** FIX by JB.
end
else
begin
D2DTexture := TDirect3DTexture2.Create(FDDraw, VDIB, False);
if transparentcolor = -1 then
COL := getDDSTransparentColor(VDIB, DDS)
else
COL := D2DTexture.Surface.ColorMatch(transparentcolor);
D2DTexture.TransparentColor := DWORD(COL); //**
D2DTexture.Surface.TransparentColor := DWORD(COL); //**
D2DTexture.Transparent := Transparent;
AlphaChannel := False;
end;
end
finally
{$IFNDEF VIDEOTEX}
VDIB.Free;
{$ENDIF}
end;
except
D2DMaxTextures := D2DMaxTextures - 1;
Result := False;
end;
end;
 
{$IFDEF VER4UP}
function TD2DTextures.CanFindTexture(const Color: LongInt): Boolean;
{$ELSE}
function TD2DTextures.CanFindTexture3(const Color: LongInt): Boolean;
{$ENDIF}
var I: Integer;
begin
Result := True;
{$IFDEF VER4UP}
if Length(Texture) > 0 then
{$ELSE}
if TexLen > 0 then
{$ENDIF}
for I := 0 to D2DMaxTextures - 1 do
if Texture[I].Name = '$' + IntToStr(Color) then Exit;
Result := False;
end;
 
{$IFDEF VER4UP}
function TD2DTextures.LoadTextures(Color: LongInt): Boolean;
{$ELSE}
function TD2DTextures.LoadTextures4(Color: LongInt): Boolean;
{$ENDIF}
var
S: string;
{$IFNDEF VIDEOTEX}
VDIB: TDIB;
{$ENDIF}
begin
Result := True;
try
D2DPruneTextures; {up to maxTexBlock textures only}
D2DMaxTextures := D2DMaxTextures + 1;
S := '$' + IntToStr(Color); {this name is supplement name}
{$IFDEF VIDEOTEX}Texture[D2DMaxTextures - 1].{$ENDIF}VDIB := TDIB.Create;
try
with Texture[D2DMaxTextures - 1] do
begin
VDIB.SetSize(16, 16, 24); {16x16 good size}
VDIB.Canvas.Brush.Color := Color;
VDIB.Canvas.FillRect(Bounds(0, 0, 16, 16));
 
FloatX1 := 0;
FloatY1 := 0;
FloatX2 := 1;
FloatY2 := 1;
Name := S;
D2DTexture := TDirect3DTexture2.Create(FDDraw, VDIB, False);
D2DTexture.Transparent := False; //cannot be transparent
end;
finally
{$IFNDEF VIDEOTEX}
VDIB.Free;
{$ENDIF}
end;
except
D2DMaxTextures := D2DMaxTextures - 1;
Result := False;
end;
end;
 
{$IFDEF VIDEOTEX}
function TD2DTextures.GetTexLayoutByName(name: string): TDIB;
var
I: Integer;
begin
Result := nil;
I := Find(name);
{$IFDEF VER4UP}
if (I >= Low(Texture)) and (I <= High(Texture)) then
{$ELSE}
if I <> -1 then
{$ENDIF}
Result := Texture[I].VDIB
end;
{$ENDIF}
 
//---------------------------------------------------------------------------
 
constructor TD2D.Create(DDraw: TCustomDXDraw);
begin
inherited Create;
//after inheritance
FDDraw := DDraw;
FD2DTextureFilter := D2D_POINT {D2D_LINEAR};
{$IFNDEF D3D_deprecated}
FD2DTexture := TD2DTextures.Create(FDDraw);
{$ENDIF}
InitVertex;
{internal allocation of texture}
CanUseD2D := {$IFDEF D3D_deprecated}(do3D in FDDraw.Options) and
(doDirectX7Mode in FDDraw.Options) and
(doHardware in FDDraw.Options){$ELSE}True{$ENDIF};
FDIB := TDIB.Create;
FInitialized := False;
end;
 
destructor TD2D.Destroy;
begin
{freeing texture and stop using it}
CanUseD2D := False;
if AsSigned(FD2DTexture) then
begin
FD2DTexture.Free; {add 29.5.2005 Takanori Kawasaki}
FD2DTexture := nil;
end;
FDIB.Free;
inherited Destroy;
end;
 
procedure TD2D.InitVertex;
var i: Integer;
begin
Fillchar(FVertex, SizeOf(FVertex), 0);
for i := 0 to 3 do
begin
FVertex[i].Specular := D3DRGB(1.0, 1.0, 1.0);
FVertex[i].rhw := 1.0;
end;
end;
 
//---------------------------------------------------------------------------
 
procedure TD2D.BeginScene();
begin
asm
FINIT
end;
FDDraw.D3DDevice7.BeginScene();
asm
FINIT
end;
FDDraw.D3DDevice7.Clear(0, nil, D3DCLEAR_TARGET, 0, 0, 0);
end;
 
//---------------------------------------------------------------------------
 
procedure TD2D.EndScene();
begin
asm
FINIT
end;
FDDraw.D3DDevice7.EndScene();
asm
FINIT
end;
end;
 
function TD2D.D2DTexturedOn(Image: TPictureCollectionItem; Pattern: Integer; SubPatternRect: TRect; RenderType: TRenderType; Alpha: Byte): Boolean;
var I: Integer;
SrcX, SrcY, diffX: Double;
R: TRect;
Q: TTextureRec;
begin
Result := False;
FDDraw.D3DDevice7.SetTexture(0, nil);
if not FD2DTexture.CanFindTexture(Image) then {when no texture in list try load it}
if not FD2DTexture.LoadTextures(Image) then {loading is here}
Exit; {on error occurr out}
I := FD2DTexture.Find(Image.Name);
if I = -1 then Exit;
{set pattern as texture}
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MAGFILTER, DWord(Ord(FD2DTextureFilter)+1));
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MINFILTER, DWord(Ord(FD2DTextureFilter)+1));
try
RenderError := FDDraw.D3DDevice7.SetTexture(0, FD2DTexture.Texture[I].D2DTexture.Surface.IDDSurface7) <> DD_OK;
case RenderType of
rtDraw: begin D2DEffectSolid; D2DWhite; end;
rtBlend: begin D2DEffectBlend; D2DAlphaVertex(Alpha); end;
rtAdd: begin D2DEffectAdd; D2DFade(Alpha); end;
rtSub: begin D2DEffectSub; D2DFade(Alpha); end;
end;
except
RenderError := True;
FD2DTexture.D2DPruneAllTextures;
Image.Restore;
SetD2DTextureFilter(D2D_LINEAR);
Exit;
end;
{set transparent area}
RenderError := FDDraw.D3DDevice7.SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, Ord(FD2DTexture.Texture[I].D2DTexture.Transparent)) <> DD_OK;
{except for Draw when alphachannel exists}
{change for blend drawing but save transparent area still}
if FD2DTexture.Texture[I].AlphaChannel then
{when is Draw selected then}
if RenderType = rtDraw then
begin
D2DEffectBlend;
D2DAlphaVertex($FF);
end;
{pokud je obrazek rozdeleny, nastav oka site}
if (Image.PatternHeight <> 0) or (Image.PatternWidth <> 0) then
begin
{vezmi rect jenom dilku}
R := Image.PatternRects[Pattern];
SrcX := 1 / FD2DTexture.Texture[I].Width;
SrcY := 1 / FD2DTexture.Texture[I].Height;
//namapovani vertexu na texturu
FD2DTexture.Texture[I].FloatX1 := SrcX * R.Left;
FD2DTexture.Texture[I].FloatY1 := SrcY * R.Top;
{for meshed subimage contain one image only can be problem there}
diffX := 0.5; if Image.PatternCount = 1 then diffX := 0;
FD2DTexture.Texture[I].FloatX2 := SrcX * (R.Right - diffX);
FD2DTexture.Texture[I].FloatY2 := SrcY * (R.Bottom - diffX);
if not (
(SubPatternRect.Left = Image.PatternRects[Pattern].Left) and
(SubPatternRect.Top = Image.PatternRects[Pattern].Top) and
(SubPatternRect.Right = Image.PatternRects[Pattern].Right) and
(SubPatternRect.Bottom = Image.PatternRects[Pattern].Bottom))
then
begin
{remaping subtexture via subpattern}
Q.FloatX1 := SrcX * SubPatternRect.Left;
Q.FloatY1 := SrcY * SubPatternRect.Top;
Q.FloatX2 := SrcX * (SubPatternRect.Right - diffX);
Q.FloatY2 := SrcY * (SubPatternRect.Bottom - diffX);
D2DTU(Q); {with mirroring/flipping}
Result := not RenderError;
Exit;
end;
end; {jinak celeho obrazku}
 
{ X1,Y1 X2,Y1
0 +-----------------+ 1
| |
| |
| |
| |
2 +-----------------+ 3
X1,Y2 X2,Y2 }
D2DTU(FD2DTexture.Texture[I]);
Result := not RenderError;
end;
 
function TD2D.D2DTexturedOnDDSTex(dds: TDirectDrawSurface; SubPatternRect: TRect; Transparent: Boolean): Integer;
{special version of map for TDirectDrawSurface only}
{set up transparent color from this surface}
var
TexName: string;
begin
Result := -1;
{pokud je seznam prazdny, nahrej texturu}
if dds.Caption <> '' then TexName := dds.Caption
else TexName := IntToStr(Integer(dds)); {simple but stupid}
if not FD2DTexture.{$IFDEF VER4UP}CanFindTexture{$ELSE}CanFindTexture2{$ENDIF}(TexName) then
begin
{when texture doesn't exists, has to the Modified flag turn off}
if dds.Modified then
dds.Modified := not dds.Modified;
if not FD2DTexture.{$IFDEF VER4UP}LoadTextures{$ELSE}LoadTextures2{$ENDIF}(dds, Transparent, TexName) then
Exit; {nepovede-li se to, pak ven}
end
else
if dds.Modified then
begin {when modifying, load texture allways}
if not FD2DTexture.{$IFDEF VER4UP}LoadTextures{$ELSE}LoadTextures2{$ENDIF}(dds, Transparent, TexName) then
Exit; {nepovede-li se to, pak ven}
end;
Result := FD2DTexture.Find(TexName);
end;
 
function IsNotZero(Z: TRect): Boolean;
begin
Result := ((Z.Right - Z.Left) > 0) and ((Z.Bottom - Z.Top) > 0)
end;
 
function TD2D.D2DTexturedOnDDS(dds: TDirectDrawSurface; SubPatternRect: TRect; Transparent: Boolean; RenderType: TRenderType; Alpha: Byte): Boolean;
var I: Integer;
SrcX, SrcY: Double;
begin
Result := False;
FDDraw.D3DDevice7.SetTexture(0, nil);
{call a low level routine for load DDS texture}
I := D2DTexturedOnDDSTex(dds, SubPatternRect, Transparent);
if I = -1 then Exit;
{set pattern as texture}
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MAGFILTER, DWord(Ord(FD2DTextureFilter)+1));
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MINFILTER, DWord(Ord(FD2DTextureFilter)+1));
try
RenderError := FDDraw.D3DDevice7.SetTexture(0, FD2DTexture.Texture[I].D2DTexture.Surface.IDDSurface7) <> DD_OK;
case RenderType of
rtDraw: begin D2DEffectSolid; D2DWhite; end;
rtBlend: begin D2DEffectBlend; D2DAlphaVertex(Alpha); end;
rtAdd: begin D2DEffectAdd; D2DFade(Alpha); end;
rtSub: begin D2DEffectSub; D2DFade(Alpha); end;
end;
except
RenderError := True;
FD2DTexture.D2DPruneAllTextures;
SetD2DTextureFilter(D2D_LINEAR); //default
Exit;
end;
{set transparent area}
RenderError := FDDraw.D3DDevice7.SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, Ord(FD2DTexture.Texture[I].D2DTexture.Transparent)) <> DD_OK;
if IsNotZero(SubPatternRect) then
begin
{Set Texture Coordinates}
SrcX := 1 / FD2DTexture.Texture[I].D2DTexture.FImage.Width;
SrcY := 1 / FD2DTexture.Texture[I].D2DTexture.FImage.Height;
//namapovani vertexu na texturu
FD2DTexture.Texture[I].FloatX1 := SrcX * SubPatternRect.Left;
FD2DTexture.Texture[I].FloatY1 := SrcY * SubPatternRect.Top;
FD2DTexture.Texture[I].FloatX2 := SrcX * (SubPatternRect.Right - 0.5 { - 1}); //by Speeeder
FD2DTexture.Texture[I].FloatY2 := SrcY * (SubPatternRect.Bottom - 0.5 { - 1}); //by Speeeder
end;
D2DTU(FD2DTexture.Texture[I]);
Result := not RenderError;
end;
 
//---------------------------------------------------------------------------
 
procedure TD2D.SaveTextures(path: string);
begin
FD2DTexture.SaveTextures(path);
end;
 
procedure TD2D.SetCanUseD2D(const Value: Boolean);
begin
case Value of
False: {prestava se uzivat}
if AsSigned(FD2DTexture) and (Value <> FCanUseD2D) then
begin
FInitialized := False;
end;
True:
if Value <> FCanUseD2D then
begin
{$IFDEF D3D_deprecated}
FD2DTexture := TD2DTextures.Create(FDDraw);
TextureFilter := D2D_LINEAR;
{$ENDIF}
end
end;
FCanUseD2D := Value;
end;
 
function TD2D.GetCanUseD2D: Boolean;
begin
{$IFDEF D3D_deprecated}
{Mode has to do3D, doDirectX7Mode and doHardware}
if (do3D in FDDraw.Options) and
(doDirectX7Mode in FDDraw.Options) and
(doHardware in FDDraw.Options)
then
begin
if not FCanUseD2D then CanUseD2D := True;
end
else
if not (do3D in FDDraw.Options) or
not (doDirectX7Mode in FDDraw.Options) or
not (doHardware in FDDraw.Options)
then
if FCanUseD2D then FCanUseD2D := False; // CanUseD2D -> FCanUseD2D
{$ELSE}
FCanUseD2D := (doHardware in FDDraw.Options);
{$ENDIF}
FBitCount := FDDraw.Surface.SurfaceDesc.ddpfPixelFormat.dwRGBBitCount;
{supported 16 or 32 bitcount deepth only}
{$IFDEF D3D_deprecated}
if not (FBitCount in [16, 32]) then FCanUseD2D := False;
{$ENDIF}
if not FInitialized then
if FCanUseD2D and Assigned(FDDraw.D3DDevice7) then
begin
FDDraw.D3DDevice7.GetCaps(FD3DDevDesc7);
FInitialized := True;
end;
 
Result := FCanUseD2D;
end;
 
procedure TD2D.SetD2DTextureFilter(const Value: TD2DTextureFilter);
begin
FD2DTextureFilter := Value;
if {$IFDEF D3D_deprecated}(do3D in FDDraw.Options) and{$ENDIF} AsSigned(FDDraw.D3DDevice7) then
begin
FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MAGFILTER, DWord(Ord(FD2DTextureFilter) + 1));
FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MINFILTER, DWord(Ord(FD2DTextureFilter) + 1));
end;
end;
 
procedure TD2D.SetD2DAntialiasFilter(const Value: TD3DAntialiasMode);
begin
FD2DAntialiasFilter := Value;
if {$IFDEF D3D_deprecated}(do3D in FDDraw.Options) and{$ENDIF} AsSigned(FDDraw.D3DDevice7) then
begin
FDDraw.D3DDevice7.SetRenderState(D3DRENDERSTATE_ANTIALIAS, Ord(Value));
end;
end;
 
procedure TD2D.D2DRect(R: TRect);
begin
FVertex[0].sx := R.Left - 0.5;
FVertex[0].sy := R.Top - 0.5;
FVertex[1].sx := R.Right - 0.5;
FVertex[1].sy := R.Top - 0.5;
FVertex[2].sx := R.Left - 0.5;
FVertex[2].sy := R.Bottom - 0.5;
FVertex[3].sx := R.Right - 0.5;
FVertex[3].sy := R.Bottom - 0.5;
end;
 
procedure TD2D.D2DTU(T: TTextureRec);
begin
if FMirrorFlipSet = [rmfMirror] then
begin
{ X1,Y1 X2,Y1
0 +-----------------+ 1
| |
| |
| |
| |
2 +-----------------+ 3
X1,Y2 X2,Y2 }
FVertex[1].tu := T.FloatX1;
FVertex[1].tv := T.FloatY1;
FVertex[0].tu := T.FloatX2;
FVertex[0].tv := T.FloatY1;
FVertex[3].tu := T.FloatX1;
FVertex[3].tv := T.FloatY2;
FVertex[2].tu := T.FloatX2;
FVertex[2].tv := T.FloatY2;
end
else
if FMirrorFlipSet = [rmfFlip] then
begin
{ X1,Y1 X2,Y1
0 +-----------------+ 1
| |
| |
| |
| |
2 +-----------------+ 3
X1,Y2 X2,Y2 }
FVertex[2].tu := T.FloatX1;
FVertex[2].tv := T.FloatY1;
FVertex[3].tu := T.FloatX2;
FVertex[3].tv := T.FloatY1;
FVertex[0].tu := T.FloatX1;
FVertex[0].tv := T.FloatY2;
FVertex[1].tu := T.FloatX2;
FVertex[1].tv := T.FloatY2;
end
else
if FMirrorFlipSet = [rmfMirror, rmfFlip] then
begin
{ X1,Y1 X2,Y1
0 +-----------------+ 1
| |
| |
| |
| |
2 +-----------------+ 3
X1,Y2 X2,Y2 }
FVertex[3].tu := T.FloatX1;
FVertex[3].tv := T.FloatY1;
FVertex[2].tu := T.FloatX2;
FVertex[2].tv := T.FloatY1;
FVertex[1].tu := T.FloatX1;
FVertex[1].tv := T.FloatY2;
FVertex[0].tu := T.FloatX2;
FVertex[0].tv := T.FloatY2;
end
else
begin
{ X1,Y1 X2,Y1
0 +-----------------+ 1
| |
| |
| |
| |
2 +-----------------+ 3
X1,Y2 X2,Y2 }
FVertex[0].tu := T.FloatX1;
FVertex[0].tv := T.FloatY1;
FVertex[1].tu := T.FloatX2;
FVertex[1].tv := T.FloatY1;
FVertex[2].tu := T.FloatX1;
FVertex[2].tv := T.FloatY2;
FVertex[3].tu := T.FloatX2;
FVertex[3].tv := T.FloatY2;
end;
end;
 
{Final public routines}
 
function TD2D.D2DRender(Image: TPictureCollectionItem; DestRect: TRect;
Pattern: Integer; SourceRect: TRect; RenderType: TRenderType; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
if D2DTexturedOnSubRect(Image, Pattern, Image.PatternRects[Pattern], SourceRect, RenderType, Alpha) then
begin
D2DRect(DestRect);
Result := RenderQuad;
end;
end;
 
function TD2D.{$IFNDEF VER4UP}D2DRender2{$ELSE}D2DRender{$ENDIF}(Image: TPictureCollectionItem; R: TRect;
Pattern: Integer; RenderType: TRenderType; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
if D2DTexturedOn(Image, Pattern, Image.PatternRects[Pattern], RenderType, Alpha) then
begin
D2DRect(R);
Result := RenderQuad;
end;
end;
 
function TD2D.D2DRenderDDS(Source: TDirectDrawSurface; SourceRect, DestRect: TRect;
Transparent: Boolean; Pattern: Integer; RenderType: TRenderType; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
if D2DTexturedOnDDS(Source, SourceRect, Transparent, RenderType, Alpha) then
begin
D2DRect(DestRect);
Result := RenderQuad;
end;
end;
 
function TD2D.D2DRenderCol(Image: TPictureCollectionItem; R: TRect;
Pattern, Color: Integer; RenderType: TRenderType; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
if D2DTexturedOn(Image, Pattern, Image.PatternRects[Pattern], RenderType, Alpha) then
begin
D2DRect(R);
Result := RenderQuad;
end;
end;
 
function TD2D.D2DRenderColDDS(Source: TDirectDrawSurface; SourceRect, DestRect: TRect;
Transparent: Boolean; Pattern, Color: Integer; RenderType: TRenderType; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{Add}
if D2DTexturedOnDDS(Source, SourceRect, Transparent, RenderType, Alpha) then
begin
D2DRect(DestRect);
Result := RenderQuad;
end;
end;
 
function TD2D.D2DRenderDrawXY(Image: TPictureCollectionItem; X, Y: Integer;
Pattern: Integer; RenderType: TRenderType; Alpha: Byte): Boolean;
var PWidth, PHeight: Integer;
begin
Result := False; if not CanUseD2D then Exit;
{Draw}
if D2DTexturedOn(Image, Pattern, Image.PatternRects[Pattern], RenderType, Alpha) then
begin
PWidth := Image.PatternWidth; if PWidth = 0 then PWidth := Image.Width;
PHeight := Image.PatternHeight; if PHeight = 0 then PHeight := Image.Height;
D2DRect(Bounds(X, Y, PWidth, PHeight));
Result := RenderQuad;
end;
end;
 
function TD2D.D2DRenderDrawDDSXY(Source: TDirectDrawSurface; X, Y: Integer;
Transparent: Boolean; Pattern: Integer; RenderType: TRenderType; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{Draw}
if D2DTexturedOnDDS(Source, ZeroRect, Transparent, RenderType, Alpha) then
begin
D2DRect(Bounds(X, Y, Source.Width, Source.Height));
Result := RenderQuad;
end;
end;
 
{$IFDEF VER4UP}
function TD2D.D2DRenderDrawDDSXY(Source: TDirectDrawSurface; X, Y: Integer;
SrcRect: TRect; Transparent: Boolean; Pattern: Integer; RenderType: TRenderType; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{Draw}
if D2DTexturedOnDDS(Source, SrcRect, Transparent, RenderType, Alpha) then
begin
D2DRect(Bounds(X, Y, SrcRect.Right - SrcRect.Left, SrcRect.Bottom - SrcRect.Top));
Result := RenderQuad;
end;
end;
{$ENDIF}
 
{Rotate functions}
 
procedure TD2D.D2DRotate(X, Y, W, H: Integer; Px, Py: Double; Angle: Single);
procedure SinCosS(const Theta: Single; var Sin, Cos: Single); register;
{ EAX contains address of Sin}
{ EDX contains address of Cos}
{ Theta is passed over the stack}
asm
FLD Theta
FSINCOS
FSTP DWORD PTR [EDX] // cosine
FSTP DWORD PTR [EAX] // sine
end;
const PI256 = 2 * PI / 256;
var x1, y1, up, s_angle, c_angle, s_up, c_up: Single;
begin
angle := angle * PI256; up := angle + PI / 2;
x1 := w * px; y1 := h * py;
SinCosS(angle, s_angle, c_angle);
SinCosS(up, s_up, c_up);
FVertex[0].sx := X - x1 * c_angle - y1 * c_up;
FVertex[0].sy := Y - x1 * s_angle - y1 * s_up;
FVertex[1].sx := FVertex[0].sx + W * c_angle;
FVertex[1].sy := FVertex[0].sy + W * s_angle;
FVertex[2].sx := FVertex[0].sx + H * c_up;
FVertex[2].sy := FVertex[0].sy + H * s_up;
FVertex[3].sx := FVertex[2].sx + W * c_angle;
FVertex[3].sy := FVertex[2].sy + W * s_angle;
end;
 
function TD2D.D2DRenderRotate(Image: TPictureCollectionItem; RotX, RotY,
PictWidth, PictHeight, PatternIndex: Integer; RenderType: TRenderType;
CenterX, CenterY: Double;
Angle: single; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{load textures and map it, set of effect}
if D2DTexturedOn(Image, PatternIndex, Image.PatternRects[PatternIndex], RenderType, Alpha) then
begin
{do rotate mesh}
D2DRotate(RotX, RotY, PictWidth, PictHeight, CenterX, CenterY, Angle);
{render it}
Result := RenderQuad;
end;
end;
 
function TD2D.D2DRenderRotateDDS(Image: TDirectDrawSurface; SourceRect: TRect; RotX, RotY,
PictWidth, PictHeight: Integer; RenderType: TRenderType;
CenterX, CenterY: Double; Angle: single; Alpha: Byte;
Transparent: Boolean): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{load textures and map it, set of effect}
if D2DTexturedOnDDS(Image, SourceRect, Transparent, RenderType, Alpha) then
begin
{do rotate mesh}
D2DRotate(RotX, RotY, PictWidth, PictHeight, CenterX, CenterY, Angle);
{render it}
Result := RenderQuad;
end;
end;
 
{------------------------------------------------------------------------------}
{created 31.1.2005 JB.}
{replacement original Hori's functionality}
{24.4.2006 create WaveY as supplement like WaveX functions}
{14.5.2006 added functionality for tile drawing through PatternIndex}
 
function TD2D.D2DMeshMapToWave(dds: TDirectDrawSurface; Transparent: Boolean;
TransparentColor: Integer; X, Y, iWidth, iHeight, PatternIndex: Integer;
PatternRect: TRect;
Amp, Len, Ph, Alpha: Integer; effect: TRenderType; DoY: Boolean): Boolean;
function D2DTexturedOn(dds: TDirectDrawSurface; Transparent: Boolean; var TexNo: Integer): Boolean;
{special version of mapping for TDirectDrawSurface only}
{set up transparent color from this surface}
var I: Integer;
TexName: string;
begin
Result := False;
TexNo := -1;
RenderError := FDDraw.D3DDevice7.SetTexture(0, nil) <> DD_OK;
{pokud je seznam prazdny, nahrej texturu}
if dds.Caption <> '' then TexName := dds.Caption
else TexName := IntToStr(Integer(dds));
if not FD2DTexture.{$IFDEF VER4UP}CanFindTexture{$ELSE}CanFindTexture2{$ENDIF}(TexName) then
{nepovede-li se to, pak ven}
if not FD2DTexture.{$IFDEF VER4UP}LoadTextures{$ELSE}LoadTextures3{$ENDIF}(dds, Transparent, TransparentColor, TexName) then Exit;
I := FD2DTexture.Find(TexName);
if I = -1 then Exit;
TexNo := I;
{set pattern as texture}
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MAGFILTER, DWord(Ord(FD2DTextureFilter)+1));
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MINFILTER, DWord(Ord(FD2DTextureFilter)+1));
try
RenderError := FDDraw.D3DDevice7.SetTexture(0, FD2DTexture.Texture[I].D2DTexture.Surface.IDDSurface7) <> DD_OK;
//Result := True; {not RetderError}
except
RenderError := True;
Result := False;
FD2DTexture.D2DPruneAllTextures;
Exit;
end;
{set transparent area}
RenderError := FDDraw.D3DDevice7.SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, Ord(FD2DTexture.Texture[I].D2DTexture.Transparent)) <> DD_OK;
Result := not RenderError;
end;
type
TVertexArray = array{$IFNDEF VER4UP} [0..0]{$ENDIF} of TD3DTLVERTEX;
{$IFNDEF VER4UP}
PVertexArray = ^TVertexArray;
{$ENDIF}
var
SVertex: {$IFDEF VER4UP}TVertexArray{$ELSE}PVertexArray{$ENDIF};
I, maxVertex, maxPix, VStepVx, TexNo, Width, Height: Integer;
VStep, VStepTo, D, Z, FX1, FX2, FY1, FY2, SX, SY, X1, Y1, X2, Y2: Extended;
R: TRect;
clr: DWORD;
begin
Result := False;
{zde uschovano maximum [0..1] po adjustaci textury, ktera nemela nektery rozmer 2^n}
{FD2DTexture.Texture[I].FloatX2;}
{FD2DTexture.Texture[I].FloatY2;}
{napr. pokud byl rozmer 0.7 pak je nutno prepocitat tento interval [0..0.7] na height}
if not D2DTexturedOn(dds, Transparent, TexNo) then Exit;
{musi se prenastavit velikost pokud je PatternIndex <> -1}
Width := iWidth;
Height := iHeight;
{remove into local variabled for multi-picture adjustation}
FX1 := FD2DTexture.Texture[TexNo].FloatX1;
FX2 := FD2DTexture.Texture[TexNo].FloatX2;
FY1 := FD2DTexture.Texture[TexNo].FloatY1;
FY2 := FD2DTexture.Texture[TexNo].FloatY2;
{when pattertindex selected, get real value of subtexture}
if (PatternIndex <> -1) {and (PatternRect <> ZeroRect)} then
begin
R := PatternRect;
Width := R.Right - R.Left;
Height := R.Bottom - R.Top;
{scale unit of full new width and height}
SX := 1 / FD2DTexture.Texture[TexNo].Width;
SY := 1 / FD2DTexture.Texture[TexNo].Height;
{remap there}
FX1 := R.Left * SX;
FX2 := R.Right * SX;
FY1 := R.Top * SY;
FY2 := R.Bottom * SY;
end;
{nastavuje se tolik vertexu, kolik je potreba}
{speculative set up of rows for better look how needed}
if not DoY then
begin
maxVertex := 2 * Trunc(Height / Len * 8);
if (maxVertex mod 2) > 0 then {top to limits}
Inc(maxVertex, 2);
if (maxVertex div 2) > Height then {correct to Height}
maxVertex := 2 * Height;
end
else
begin
maxVertex := 2 * Trunc(Width / Len * 8);
if (maxVertex mod 2) > 0 then {top to limits}
Inc(maxVertex, 2);
if (maxVertex div 2) > Width then {correct to Width}
maxVertex := 2 * Width;
end;
 
{pocet pixlu mezi ploskami}
if not DoY then
begin
repeat
if (Height mod (maxVertex div 2)) <> 0 then
Inc(maxVertex, 2);
maxPix := Height div (maxVertex div 2);
until (Height mod (maxVertex div 2)) = 0;
{krok k nastaveni vertexu}
VStep := (FY2 - FY1) / (maxVertex div 2);
end
else
begin
repeat
if (Width mod (maxVertex div 2)) <> 0 then
Inc(maxVertex, 2);
maxPix := Width div (maxVertex div 2);
until (Width mod (maxVertex div 2)) = 0;
{krok k nastaveni vertexu}
VStep := (FX2 - FX1) / (maxVertex div 2);
end;
//prostor
{$IFDEF VER4UP}
SetLength(SVertex, maxVertex);
{$ELSE}
SVertex := AllocMem(maxVertex * SizeOf(TD3DTLVERTEX));
try
{$ENDIF}
//inicializace
VStepVx := 0;
VStepTo := 0;
D := ph / (128 / PI); {shift wave}
Z := (Len / 2) / PI; {wave length to radians}
clr := D2DVertColor(Effect, Alpha); //effect cumulate to one param and one line of code
{vlastni nastaveni vertexu v pasu vertexu}
for I := 0 to maxVertex - 1 do
begin
SVertex[I].Specular := D3DRGB(1.0, 1.0, 1.0);
SVertex[I].rhw := 1.0;
SVertex[I].color := clr;
if not DoY then
case (I + 1) mod 2 of //triangle driver
1: begin
if I <> 0 then Inc(VStepVx, maxPix);
SVertex[I].sx := X + Trunc(amp * Sin((Y + VStepVx) / Z + D)) - 0.5; //levy
SVertex[I].sy := Y + VStepVx - 0.5;
if FMirrorFlipSet = [rmfMirror] then
begin
X1 := FX2; if I <> 0 then VStepTo := VStepTo + VStep;
Y1 := FY1 + VStepTo;
end
else
if FMirrorFlipSet = [rmfFlip] then
begin
X1 := FX1;
Y1 := FY2 - VStepTo;
end
else
if FMirrorFlipSet = [rmfMirror, rmfFlip] then
begin
X1 := FX2;
Y1 := FY2 - VStepTo;
end
else
begin
X1 := FX1; if I <> 0 then VStepTo := VStepTo + VStep;
Y1 := FY1 + VStepTo;
end;
SVertex[I].tu := X1;
SVertex[I].tv := Y1;
end;
0: begin
SVertex[I].sx := X + Width + Trunc(amp * Sin((Y + VStepVx) / Z + D)) - 1; //pravy
SVertex[I].sy := Y + VStepVx;
if FMirrorFlipSet = [rmfMirror] then
begin
X2 := FX1;
Y2 := FY1 + VStepTo;
end
else
if FMirrorFlipSet = [rmfFlip] then
begin
X2 := FX2;
Y2 := FY2 - VStepTo; if I <> 0 then VStepTo := VStepTo + VStep;
end
else
if FMirrorFlipSet = [rmfMirror, rmfFlip] then
begin
X2 := FX1;
Y2 := FY2 - VStepTo; if I <> 0 then VStepTo := VStepTo + VStep;
end
else
begin
X2 := FX2;
Y2 := FY1 + VStepTo;
end;
SVertex[I].tu := X2;
SVertex[I].tv := Y2;
end;
end {case}
else
case (I + 1) mod 2 of //triangle driver
0: begin
if I <> 0 then Inc(VStepVx, maxPix);
SVertex[I].sy := Y + Trunc(amp * Sin((X + VStepVx) / Z + D)) - 0.5; //hore
SVertex[I].sx := X + VStepVx - 0.5;
if FMirrorFlipSet = [rmfMirror] then
begin
Y1 := FY1; if I <> 0 then VStepTo := VStepTo + VStep;
X1 := FX2 - VStepTo;
end
else
if FMirrorFlipSet = [rmfFlip] then
begin
Y1 := FY2; if I <> 0 then VStepTo := VStepTo + VStep;
X1 := FX1 + VStepTo;
end
else
if FMirrorFlipSet = [rmfMirror, rmfFlip] then
begin
Y1 := FY2; if I <> 0 then VStepTo := VStepTo + VStep;
X1 := FX2 - VStepTo;
end
else
begin
Y1 := FY1; if I <> 0 then VStepTo := VStepTo + VStep;
X1 := FX1 + VStepTo;
end;
SVertex[I].tu := X1;
SVertex[I].tv := Y1;
end;
1: begin
SVertex[I].sy := Y + Height + Trunc(amp * Sin((X + VStepVx) / Z + D)) - 1; //dole
SVertex[I].sx := X + VStepVx;
if FMirrorFlipSet = [rmfMirror] then
begin
Y2 := FY2;
X2 := FX2 - VStepTo;
end
else
if FMirrorFlipSet = [rmfFlip] then
begin
Y2 := FY1;
X2 := FX1 + VStepTo;
end
else
if FMirrorFlipSet = [rmfMirror, rmfFlip] then
begin
Y2 := FY1;
X2 := FX2 - VStepTo;
end
else
begin
Y2 := FY2;
X2 := FX1 + VStepTo;
end;
SVertex[I].tu := X2;
SVertex[I].tv := Y2;
end;
end;
end;
{set of effect}
case Effect of
rtDraw: D2DEffectSolid;
rtBlend: D2DEffectBlend;
rtAdd: D2DEffectAdd;
rtSub: D2DEffectSub;
end;
with FDDraw.D3DDevice7 do
begin
{kreslime hned zde}//render now and here
Result := DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, SVertex[0], maxVertex, D3DDP_WAIT) = DD_OK;
//zpet hodnoty
//FIX InitVertex;
FMirrorFlipSet := []; {only for one operation, back to normal position}
{restore device status}
RenderError := SetTextureStageState(1, D3DTSS_COLOROP, Ord(D3DTOP_DISABLE)) <> DD_OK;
RenderError := SetTextureStageState(1, D3DTSS_ALPHAOP, Ord(D3DTOP_DISABLE)) <> DD_OK;
RenderError := SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0) <> DD_OK;
end;
{$IFNDEF VER4UP}
finally
FreeMem(SVertex, maxVertex * SizeOf(TD3DTLVERTEX));
end;
{$ENDIF}
end;
 
function TD2D.D2DRenderWaveX(Image: TPictureCollectionItem; X, Y, Width,
Height, PatternIndex: Integer; RenderType: TRenderType; transparent: Boolean;
amp, Len, ph, Alpha: Integer): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{load textures and map, do make wave mesh and render it}
Result := D2DMeshMapToWave(Image.PatternSurfaces[PatternIndex], transparent,
Image.FTransparentColor, X, Y, Width, Height, PatternIndex,
Image.PatternRects[PatternIndex],
amp, Len, ph, Alpha, RenderType{$IFNDEF VER4UP}, False{$ENDIF});
end;
 
function TD2D.D2DRenderWaveXDDS(Source: TDirectDrawSurface; X, Y, Width,
Height: Integer; RenderType: TRenderType; Transparent: Boolean; Amp, Len, Ph, Alpha: Integer): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{load textures and map, do make wave mesh and render it}
Result := D2DMeshMapToWave(Source, transparent, -1, X, Y, Width, Height, -1,
ZeroRect,
amp, Len, ph, Alpha, RenderType{$IFNDEF VER4UP}, False{$ENDIF});
end;
 
function TD2D.D2DRenderWaveY(Image: TPictureCollectionItem; X, Y, Width,
Height, PatternIndex: Integer; RenderType: TRenderType; Transparent: Boolean;
Amp, Len, Ph, Alpha: Integer): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{load textures and map, do make wave mesh and render it}
Result := D2DMeshMapToWave(Image.PatternSurfaces[PatternIndex], transparent,
Image.FTransparentColor, X, Y, Width, Height, PatternIndex,
Image.PatternRects[PatternIndex],
amp, Len, ph, Alpha, RenderType, True);
end;
 
function TD2D.D2DRenderWaveYDDS(Source: TDirectDrawSurface; X, Y, Width,
Height: Integer; RenderType: TRenderType; Transparent: Boolean;
Amp, Len, Ph, Alpha: Integer): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{load textures and map, do make wave mesh and render it}
Result := D2DMeshMapToWave(Source, transparent, -1, X, Y, Width, Height, -1,
ZeroRect,
amp, Len, ph, Alpha, RenderType, True);
end;
 
function TD2D.D2DTexturedOnRect(Rect: TRect; Color: LongInt): Boolean;
var I: Integer;
begin
Result := False;
FDDraw.D3DDevice7.SetTexture(0, nil);
if not FD2DTexture.{$IFDEF VER4UP}CanFindTexture{$ELSE}CanFindTexture3{$ENDIF}(Color) then {when no texture in list try load it}
if not FD2DTexture.{$IFDEF VER4UP}LoadTextures{$ELSE}LoadTextures4{$ENDIF}(Color) then Exit; {on error occurr go out}
I := FD2DTexture.Find('$' + IntToStr(Color)); //simply .. but stupid
if I = -1 then Exit;
{set pattern as texture}
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MAGFILTER, DWord(Ord(FD2DTextureFilter)+1));
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MINFILTER, DWord(Ord(FD2DTextureFilter)+1));
try
RenderError := FDDraw.D3DDevice7.SetTexture(0, FD2DTexture.Texture[I].D2DTexture.Surface.IDDSurface7) <> DD_OK;
except
RenderError := True;
FD2DTexture.D2DPruneAllTextures;
exit;
end;
{set transparent part}
FDDraw.D3DDevice7.SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0); //no transparency
 
D2DTU(FD2DTexture.Texture[I]);
Result := not RenderError;
end;
 
function TD2D.D2DTexturedOnSubRect(Image: TPictureCollectionItem;
Pattern: Integer; SubPatternRect, SubRect: TRect; RenderType: TRenderType;
Alpha: Byte): Boolean;
label
lblHop;
var
I, W, H: Integer;
SrcX, SrcY, diffX: Double;
R, tmpSubRect: TRect;
Q: TTextureRec;
qFloatX1, qFloatX2, qFloatY1, qFloatY2: Double;
begin
Result := False;
FDDraw.D3DDevice7.SetTexture(0, nil);
if not FD2DTexture.CanFindTexture(Image) then {when no texture in list try load it}
if not FD2DTexture.LoadTextures(Image) then {loading is here}
Exit; {on error occurr out}
I := FD2DTexture.Find(Image.Name);
if I = -1 then Exit;
{set pattern as texture}
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MAGFILTER, DWord(Ord(FD2DTextureFilter)+1));
// FDDraw.D3DDevice7.SetTextureStageState(0, D3DTSS_MINFILTER, DWord(Ord(FD2DTextureFilter)+1));
try
FDDraw.D3DDevice7.SetTexture(0, FD2DTexture.Texture[I].D2DTexture.Surface.IDDSurface7);
case RenderType of
rtDraw: begin D2DEffectSolid; D2DWhite; end;
rtBlend: begin D2DEffectBlend; D2DAlphaVertex(Alpha); end;
rtAdd: begin D2DEffectAdd; D2DFade(Alpha); end;
rtSub: begin D2DEffectSub; D2DFade(Alpha); end;
end;
except
RenderError := true;
FD2DTexture.D2DPruneAllTextures;
Image.Restore;
SetD2DTextureFilter(D2D_LINEAR);
Exit;
end;
{set transparent part}
FDDraw.D3DDevice7.SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, Ord(FD2DTexture.Texture[I].D2DTexture.Transparent));
{except for Draw when alphachannel exists}
{change for blend drawing but save transparent area still}
if FD2DTexture.Texture[I].AlphaChannel then
{when is Draw selected then}
if RenderType = rtDraw then
begin
D2DEffectBlend; D2DAlphaVertex($FF);
end;
{pokud je obrazek rozdeleny, nastav oka site}
if (Image.PatternHeight <> 0) or (Image.PatternWidth <> 0) then
begin
{vezmi rect jenom dilku}
R := Image.PatternRects[Pattern];
 
if not CompareMem(@SubRect, @ZeroRect, SizeOf(SubRect)) then
begin
{ktere oko site to je?}
W := SubRect.Right - SubRect.Left; {takhle je siroky}
H := SubRect.Bottom - SubRect.Top; {takhle je vysoky}
tmpSubRect := Bounds(R.Left + SubRect.Left, R.Top + SubRect.Top, W, H);
if RectInRect(tmpSubRect, R) then
begin
{pokud je subrect jeste v ramci patternu, musi se posouvat podle patternindex}
Inc(R.Left, SubRect.Left);
Inc(R.Top, SubRect.Top);
if (R.Left + W) < R.Right then R.Right := R.Left + W;
if (R.Top + H) < R.Bottom then R.Bottom := R.Top + H;
goto lblHop;
end;
end;
SrcX := 1 / FD2DTexture.Texture[I].Width;
SrcY := 1 / FD2DTexture.Texture[I].Height;
//namapovani vertexu na texturu
FD2DTexture.Texture[I].FloatX1 := SrcX * R.Left;
FD2DTexture.Texture[I].FloatY1 := SrcY * R.Top;
{for meshed subimage contain one image only can be problem there}
diffX := 0.5; if Image.PatternCount = 1 then diffX := 0;
FD2DTexture.Texture[I].FloatX2 := SrcX * (R.Right - diffX);
FD2DTexture.Texture[I].FloatY2 := SrcY * (R.Bottom - diffX);
if not (
(SubPatternRect.Left = Image.PatternRects[Pattern].Left) and
(SubPatternRect.Top = Image.PatternRects[Pattern].Top) and
(SubPatternRect.Right = Image.PatternRects[Pattern].Right) and
(SubPatternRect.Bottom = Image.PatternRects[Pattern].Bottom))
then
begin
{remaping subtexture via subpattern}
Q.FloatX1 := SrcX * SubPatternRect.Left;
Q.FloatY1 := SrcY * SubPatternRect.Top;
Q.FloatX2 := SrcX * (SubPatternRect.Right - diffX);
Q.FloatY2 := SrcY * (SubPatternRect.Bottom - diffX);
D2DTU(Q); {with mirroring/flipping}
Result := True;
Exit;
end;
end; {jinak celeho obrazku}
 
if not CompareMem(@SubRect, @ZeroRect, SizeOf(SubRect)) then
if RectInRect(SubRect, Bounds(0,0, FD2DTexture.Texture[I].Width, FD2DTexture.Texture[I].Height)) then
begin
R := SubRect;
lblHop:
SrcX := 1 / FD2DTexture.Texture[I].Width;
SrcY := 1 / FD2DTexture.Texture[I].Height;
//namapovani vertexu na texturu
qFloatX1 := FD2DTexture.Texture[I].FloatX1;
qFloatY1 := FD2DTexture.Texture[I].FloatY1;
qFloatX2 := FD2DTexture.Texture[I].FloatX2;
qFloatY2 := FD2DTexture.Texture[I].FloatY2;
try
FD2DTexture.Texture[I].FloatX1 := SrcX * R.Left;
FD2DTexture.Texture[I].FloatY1 := SrcY * R.Top;
{for meshed subimage contain one image only can be problem there}
diffX := 0.5; if Image.PatternCount = 1 then diffX := 0;
FD2DTexture.Texture[I].FloatX2 := SrcX * (R.Right - diffX);
FD2DTexture.Texture[I].FloatY2 := SrcY * (R.Bottom - diffX);
{remaping subtexture via subpattern}
D2DTU(FD2DTexture.Texture[I]); {with mirroring/flipping}
Result := True;
Exit;
finally
FD2DTexture.Texture[I].FloatX1 := qFloatX1;
FD2DTexture.Texture[I].FloatY1 := qFloatY1;
FD2DTexture.Texture[I].FloatX2 := qFloatX2;
FD2DTexture.Texture[I].FloatY2 := qFloatY2;
end;
end;
 
{ X1,Y1 X2,Y1
0 +-----------------+ 1
| |
| |
| |
| |
2 +-----------------+ 3
X1,Y2 X2,Y2 }
D2DTU(FD2DTexture.Texture[I]);
Result := True;
end;
 
function TD2D.D2DRenderColoredPartition(Image: TPictureCollectionItem;
DestRect: TRect;
PatternIndex, Color, Specular: Integer;
Faded: Boolean;
SourceRect: TRect;
RenderType: TRenderType;
Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{set of effect before fade}
case RenderType of
rtDraw: D2DEffectSolid;
rtBlend: D2DEffectBlend;
rtAdd: D2DEffectAdd;
rtSub: D2DEffectSub;
end;
if Faded then D2DFade(Alpha);
 
D2DColoredVertex(Color);
if Specular <> Round(D3DRGB(1.0, 1.0, 1.0)) then
D2DSpecularVertex(Specular);
{load textures and map it}
if D2DTexturedOn(Image, PatternIndex, SourceRect, RenderType, Alpha) then
begin
D2DRect(DestRect);
{render it}
Result := RenderQuad;
end;
end;
 
function TD2D.D2DRenderFillRect(Rect: TRect; RGBColor: LongInt;
RenderType: TRenderType; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
case RenderType of
rtDraw: begin D2DEffectSolid; D2DColoredVertex(RGBColor); end;
rtBlend: begin D2DEffectBlend; D2DAlphaVertex(Alpha); end;
rtAdd: begin D2DEffectAdd; D2DFade(Alpha); end;
rtSub: begin D2DEffectSub; D2DFade(Alpha); end;
end;
if D2DTexturedOnRect(Rect, RGBColor) then
begin
D2DRect(Rect);
Result := RenderQuad;
end;
end;
 
function TD2D.D2DRenderRotateModeCol(Image: TPictureCollectionItem;
RenderType: TRenderType;
RotX, RotY, PictWidth, PictHeight, PatternIndex: Integer; CenterX,
CenterY: Double; Angle: single; Color: Integer; Alpha: Byte): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{set of effect before colored}
case RenderType of
rtDraw: D2DEffectSolid;
rtAdd: D2DEffectAdd;
rtSub: D2DEffectSub;
rtBlend: D2DEffectBlend;
end;
D2DFadeColored(Color, Alpha);
{load textures and map it}
if D2DTexturedOn(Image, PatternIndex, Image.PatternRects[PatternIndex], RenderType, Alpha) then
begin
{do rotate mesh}
D2DRotate(RotX, RotY, PictWidth, PictHeight, CenterX, CenterY, Angle);
{render it}
Result := RenderQuad;
end;
end;
 
function TD2D.D2DRenderRotateModeColDDS(Image: TDirectDrawSurface;
RotX, RotY, PictWidth, PictHeight: Integer; RenderType: TRenderType;
CenterX, CenterY: Double; Angle: Single; Color: Integer; Alpha: Byte;
Transparent: Boolean): Boolean;
begin
Result := False; if not CanUseD2D then Exit;
{set of effect}
D2DFadeColored(Color, Alpha);
{load textures and map it}
if D2DTexturedOnDDS(Image, ZeroRect, Transparent, RenderType, Alpha) then
begin
{do rotate mesh}
D2DRotate(RotX, RotY, PictWidth, PictHeight, CenterX, CenterY, Angle);
{render it}
Result := RenderQuad;
end;
end;
 
procedure TD2D.D2DEffectSolid;
begin
with FDDraw.D3DDevice7 do
begin
SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0);
//SetRenderState(D3DRENDERSTATE_FILLMODE, Integer(D3DFILL_SOLID));
SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, Integer(True));
SetRenderState(D3DRENDERSTATE_SRCBLEND, Integer(D3DBLEND_ONE));
end;
end;
 
procedure TD2D.D2DEffectBlend;
begin
with FDDraw.D3DDevice7 do
begin
SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1);
SetRenderState(D3DRENDERSTATE_SRCBLEND, Integer(D3DBLEND_SRCALPHA));
SetRenderState(D3DRENDERSTATE_DESTBLEND, Integer(D3DBLEND_INVSRCALPHA));
 
SetTextureStageState(0, D3DTSS_COLOROP, Integer(D3DTOP_MODULATE));
SetTextureStageState(0, D3DTSS_COLORARG1, Integer(D3DTA_TEXTURE));
SetTextureStageState(0, D3DTSS_COLORARG2, Integer(D3DTA_CURRENT));
 
SetTextureStageState(0, D3DTSS_ALPHAOP, Integer(D3DTOP_BLENDDIFFUSEALPHA));
SetTextureStageState(0, D3DTSS_ALPHAARG1, Integer(D3DTA_TEXTURE));
SetTextureStageState(0, D3DTSS_ALPHAARG2, Integer(D3DTA_CURRENT));
 
SetTextureStageState(0, D3DTSS_ALPHAOP, Integer(D3DTOP_MODULATE));
end;
end;
 
procedure TD2D.D2DEffectAdd;
begin
with FDDraw.D3DDevice7 do
begin
SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1);
SetRenderState(D3DRENDERSTATE_SRCBLEND, Integer(D3DBLEND_ONE));
SetRenderState(D3DRENDERSTATE_DESTBLEND, Integer(D3DBLEND_ONE));
SetTextureStageState(0, D3DTSS_ALPHAOP, Ord(D3DTOP_SELECTARG1));
SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
SetTextureStageState(0, D3DTSS_ALPHAOP, Integer(D3DTOP_MODULATE));
end;
end;
 
procedure TD2D.D2DEffectSub;
begin
with FDDraw.D3DDevice7 do
begin
SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1);
SetRenderState(D3DRENDERSTATE_SRCBLEND, Integer(D3DBLEND_ZERO));
SetRenderState(D3DRENDERSTATE_DESTBLEND, Integer(D3DBLEND_INVSRCCOLOR));
SetTextureStageState(0, D3DTSS_ALPHAOP, Ord(D3DTOP_SELECTARG1));
SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
SetTextureStageState(0, D3DTSS_ALPHAOP, Integer(D3DTOP_MODULATE));
end;
end;
 
function TD2D.D2DAlphaVertex(Alpha: Integer): Integer;
begin
Result := RGBA_MAKE($FF, $FF, $FF, Alpha);
FVertex[0].Color := Result;
FVertex[1].Color := Result;
FVertex[2].Color := Result;
FVertex[3].Color := Result;
end;
 
procedure TD2D.D2DColoredVertex(C: Integer);
begin
C := D3DRGB(C and $FF / 255, (C shr 8) and $FF / 255, (C shr 16) and $FF / 255);
FVertex[0].Color := C;
FVertex[1].Color := C;
FVertex[2].Color := C;
FVertex[3].Color := C;
end;
 
procedure TD2D.D2DColAlpha(C, Alpha: Integer);
begin
C := D3DRGBA(C and $FF / 255, (C shr 8) and $FF / 255, (C shr 16) and $FF / 255, Alpha / 255);
FVertex[0].Color := C;
FVertex[1].Color := C;
FVertex[2].Color := C;
FVertex[3].Color := C;
end;
 
procedure TD2D.D2DSpecularVertex(C: Integer);
begin
C := D3DRGB(C and $FF / 255, (C shr 8) and $FF / 255, (C shr 16) and $FF / 255);
FVertex[0].Specular := C;
FVertex[1].Specular := C;
FVertex[2].Specular := C;
FVertex[3].Specular := C;
end;
 
procedure TD2D.D2DCol4Alpha(C1, C2, C3, C4, Alpha: Integer);
begin
FVertex[0].Color := D3DRGBA(C1 and $FF / 255, (C1 shr 8) and $FF / 255,
(C1 shr 16) and $FF / 255, Alpha / 255);
FVertex[1].Color := D3DRGBA(C2 and $FF / 255, (C2 shr 8) and $FF / 255,
(C2 shr 16) and $FF / 255, Alpha / 255);
FVertex[2].Color := D3DRGBA(C3 and $FF / 255, (C3 shr 8) and $FF / 255,
(C3 shr 16) and $FF / 255, Alpha / 255);
FVertex[3].Color := D3DRGBA(C4 and $FF / 255, (C4 shr 8) and $FF / 255,
(C4 shr 16) and $FF / 255, Alpha / 255);
end;
 
function TD2D.D2DVertColor(RenderType: TRenderType; Alpha: Byte): DWORD;
begin
case RenderType of //effect cumulate to one param and four line of code
rtDraw: Result := RGB_MAKE($FF, $FF, $FF);
rtBlend: Result := RGBA_MAKE($FF, $FF, $FF, Alpha);
rtAdd: Result := RGB_MAKE(Alpha, Alpha, Alpha);
rtSub: Result := RGB_MAKE(Alpha, Alpha, Alpha);
else
Result := RGB_MAKE($FF, $FF, $FF);
end;
end;
 
function TD2D.D2DWhite: Integer;
begin
Result := RGB_MAKE($FF, $FF, $FF);
FVertex[0].Color := Result;
FVertex[1].Color := Result;
FVertex[2].Color := Result;
FVertex[3].Color := Result;
end;
 
function TD2D.D2DFade(Alpha: Integer): Integer;
begin
Result := RGB_MAKE(Alpha, Alpha, Alpha);
FVertex[0].Color := Result;
FVertex[1].Color := Result;
FVertex[2].Color := Result;
FVertex[3].Color := Result;
end;
 
procedure TD2D.D2DFadeColored(C, Alpha: Integer);
var mult: single;
begin
mult := Alpha / 65025; //Alpha/255/255;
C := D3DRGB((C and $FF) * mult, ((C shr 8) and $FF) * mult, ((C shr 16) and $FF) * mult);
FVertex[0].Color := C;
FVertex[1].Color := C;
FVertex[2].Color := C;
FVertex[3].Color := C;
end;
 
procedure TD2D.D2DFade4Colored(C1, C2, C3, C4, Alpha: Integer);
var mult: single;
begin
mult := Alpha / 65025; //Alpha/255/255;
FVertex[0].Color := D3DRGB((C1 and $FF) * mult, ((C1 shr 8) and $FF) * mult,
((C1 shr 16) and $FF) * mult);
FVertex[1].Color := D3DRGB((C2 and $FF) * mult, ((C2 shr 8) and $FF) * mult,
((C2 shr 16) and $FF) * mult);
FVertex[2].Color := D3DRGB((C3 and $FF) * mult, ((C3 shr 8) and $FF) * mult,
((C3 shr 16) and $FF) * mult);
FVertex[3].Color := D3DRGB((C4 and $FF) * mult, ((C4 shr 8) and $FF) * mult,
((C4 shr 16) and $FF) * mult);
end;
 
function TD2D.RenderQuad: Boolean;
begin
Result := FDDraw.D3DDevice7.DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, FVertex, 4, D3DDP_WAIT) <> DD_OK;
InitVertex;
FMirrorFlipSet := []; {only for one operation, back to normal position}
{restore device status}
with FDDraw.D3DDevice7 do
begin
SetTextureStageState(1, D3DTSS_COLOROP, Ord(D3DTOP_DISABLE));
SetTextureStageState(1, D3DTSS_ALPHAOP, Ord(D3DTOP_DISABLE));
SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0);
end;
end;
 
function TD2D.RenderTri: Boolean;
begin
Result := FDDraw.D3DDevice7.DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, FVertex, 3, D3DDP_WAIT) <> DD_OK;
InitVertex;
FMirrorFlipSet := []; {only for one operation, back to normal position}
{restore device status}
with FDDraw.D3DDevice7 do
begin
SetTextureStageState(1, D3DTSS_COLOROP, Ord(D3DTOP_DISABLE));
SetTextureStageState(1, D3DTSS_ALPHAOP, Ord(D3DTOP_DISABLE));
SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0);
end;
end;
 
procedure TD2D.D2DMeshMapToRect(R: TRect);
begin
FVertex[0].sx := R.Left - 0.5;
FVertex[0].sy := R.Top - 0.5;
FVertex[1].sx := R.Right - 0.5;
FVertex[1].sy := R.Top - 0.5;
FVertex[2].sx := R.Left - 0.5;
FVertex[2].sy := R.Bottom - 0.5;
FVertex[3].sx := R.Right - 0.5;
FVertex[3].sy := R.Bottom - 0.5;
end;
 
function TD2D.D2DInitializeSurface: Boolean;
begin
Result := False;
if Assigned(FDDraw.D3DDevice7) then
Result := FDDraw.D3DDevice7.SetRenderTarget(FDDraw.Surface.IDDSurface7, 0) = DD_OK;
end;
 
procedure TD2D.D2DUpdateTextures;
var I: Integer;
begin
{$IFDEF VER4UP}
for I := Low(FD2DTexture.Texture) to High(FD2DTexture.Texture) do
{$ELSE}
for I := 0 to FD2DTexture.TexLen - 1 do
{$ENDIF}
begin
FD2DTexture.Texture[I].Width := FD2DTexture.Texture[I].D2DTexture.Surface.Width;
FD2DTexture.Texture[I].Height := FD2DTexture.Texture[I].D2DTexture.Surface.Height;
// FD2DTexture.Texture[I].AlphaChannel := ?
end;
end;
 
{ TTrace }
 
constructor TTrace.Create(Collection: TCollection);
begin
inherited Create(Collection);
FBlit := TBlit.Create(Self);
FBlit.FEngine := TCustomDXDraw(Traces.FOwner);
end;
 
destructor TTrace.Destroy;
begin
FBlit.Free;
inherited Destroy;
end;
 
function TTrace.GetDisplayName: string;
begin
Result := inherited GetDisplayName
end;
 
procedure TTrace.SetDisplayName(const Value: string);
begin
if (Value <> '') and (AnsiCompareText(Value, GetDisplayName) <> 0) and
(Collection is TTraces) and (TTraces(Collection).IndexOf(Value) >= 0) then
raise Exception.Create(Format('Item duplicate name "%s" error', [Value]));
inherited SetDisplayName(Value);
end;
 
function TTrace.GetTraces: TTraces;
begin
if Collection is TTraces then
Result := TTraces(Collection)
else
Result := nil;
end;
 
procedure TTrace.Render(const LagCount: Integer);
begin
FBlit.DoMove(LagCount);
FBlit.DoCollision;
FBlit.DoDraw;
if Assigned(FBlit.FOnRender) then
FBlit.FOnRender(FBlit);
end;
 
function TTrace.IsActualized: Boolean;
begin
Result := FActualized;
end;
 
procedure TTrace.Assign(Source: TPersistent);
begin
if Source is TTrace then begin
//FTracePoints.Assign(TTrace(Source).FTracePoints);
FBlit.Assign(TTrace(Source).FBlit);
FTag := TTrace(Source).FTag;
end
else
inherited Assign(Source);
end;
 
function TTrace.GetActive: Boolean;
begin
Result := FBlit.FActive;
end;
 
procedure TTrace.SetActive(const Value: Boolean);
begin
FBlit.FActive := Value;
end;
 
function TTrace.GetOnCollision: TNotifyEvent;
begin
Result := FBlit.FOnCollision;
end;
 
procedure TTrace.SetOnCollision(const Value: TNotifyEvent);
begin
FBlit.FOnCollision := Value;
end;
 
function TTrace.GetOnGetImage: TNotifyEvent;
begin
Result := FBlit.FOnGetImage;
end;
 
procedure TTrace.SetOnGetImage(const Value: TNotifyEvent);
begin
FBlit.FOnGetImage := Value;
end;
 
function TTrace.GetOnDraw: TNotifyEvent;
begin
Result := FBlit.FOnDraw;
end;
 
procedure TTrace.SetOnDraw(const Value: TNotifyEvent);
begin
FBlit.FOnDraw := Value;
end;
 
function TTrace.GetOnMove: TBlitMoveEvent;
begin
Result := FBlit.FOnMove;
end;
 
procedure TTrace.SetOnMove(const Value: TBlitMoveEvent);
begin
FBlit.FOnMove := Value;
end;
 
function TTrace.Clone(NewName: string; OffsetX, OffsetY: Integer;
Angle: Single): TTrace;
var
NewItem: TTrace;
I: Integer;
begin
NewItem := GetTraces.Add;
NewItem.Assign(Self);
NewItem.Name := NewName;
for I := 0 to NewItem.Blit.GetPathCount - 1 do begin
NewItem.Blit.FPathArr[I].X := NewItem.Blit.FPathArr[I].X + OffsetX;
NewItem.Blit.FPathArr[I].Y := NewItem.Blit.FPathArr[I].Y + OffsetY;
end;
Result := NewItem
end;
 
function TTrace.GetOnRender: TOnRender;
begin
Result := FBlit.FOnRender;
end;
 
procedure TTrace.SetOnRender(const Value: TOnRender);
begin
FBlit.FOnRender := Value;
end;
 
{ TTraces }
 
constructor TTraces.Create(AOwner: TComponent);
begin
inherited Create(TTrace);
FOwner := AOwner;
end;
 
destructor TTraces.Destroy;
begin
inherited Destroy;
end;
 
function TTraces.Add: TTrace;
begin
Result := TTrace(inherited Add);
end;
 
function TTraces.Find(const Name: string): TTrace;
var
i: Integer;
begin
i := IndexOf(Name);
if i = -1 then
raise EDXTracerError.CreateFmt('Tracer item named %s not found', [Name]);
Result := Items[i];
end;
 
function TTraces.GetItem(Index: Integer): TTrace;
begin
Result := TTrace(inherited GetItem(Index));
end;
 
procedure TTraces.SetItem(Index: Integer;
Value: TTrace);
begin
inherited SetItem(Index, Value);
end;
 
procedure TTraces.Update(Item: TCollectionItem);
begin
inherited Update(Item);
end;
 
{$IFDEF VER4UP}
function TTraces.Insert(Index: Integer): TTrace;
begin
Result := TTrace(inherited Insert(Index));
end;
{$ENDIF}
 
function TTraces.GetOwner: TPersistent;
begin
Result := FOwner;
end;
 
{ TBlit }
 
function TBlit.GetWorldX: Double;
begin
if Parent <> nil then
Result := Parent.WorldX + FBlitRec.FX
else
Result := FBlitRec.FX;
end;
 
function TBlit.GetWorldY: Double;
begin
if Parent <> nil then
Result := Parent.WorldY + FBlitRec.FY
else
Result := FBlitRec.FY;
end;
 
procedure TBlit.DoMove(LagCount: Integer);
var
MoveIt: Boolean;
begin
if not FBlitRec.FMoved then Exit;
if AsSigned(FOnMove) then begin
MoveIt := True; {if nothing then reanimate will force}
FOnMove(Self, LagCount, MoveIt); {when returned MoveIt = true still that do not move}
if MoveIt then
ReAnimate(LagCount); //for reanimation
end
else begin
ReAnimate(LagCount);
end;
{there is moving to next foot of the path}
if Active then
if GetPathCount > 0 then begin
Dec(FCurrentTime, LagCount);
if FCurrentTime < 0 then begin
if FBustrofedon then begin
case FCurrentDirection of
True: begin
Inc(FCurrentPosition); //go forward
if FCurrentPosition = (GetPathCount - 1) then
FCurrentDirection := not FCurrentDirection //change direction
end;
False: begin
Dec(FCurrentPosition); //go backward
if FCurrentPosition = 0 then
FCurrentDirection := not FCurrentDirection //change direction
end;
end;
end
else
if FCurrentPosition < (GetPathCount - 1) then begin
Inc(FCurrentPosition) //go forward only
end
else
if FMovingRepeatly then
FCurrentPosition := 0; {return to start}
{get actual new value for showing time}
{must be pick-up there, after change of the current position}
FCurrentTime := Path[FCurrentPosition].StayOn; {cas mezi pohyby}
end;
X := Path[FCurrentPosition].X;
Y := Path[FCurrentPosition].Y;
end;
{}
end;
 
function TBlit.GetDrawImageIndex: Integer;
begin
Result := FBlitRec.FAnimStart + Trunc(FBlitRec.FAnimPos);
end;
 
procedure TBlit.DoDraw;
var
f: TRenderMirrorFlipSet;
r: TRect;
begin
with FBlitRec do begin
if not FVisible then Exit;
if FImage = nil then DoGetImage;
if FImage = nil then Exit;
{owner draw called here}
if AsSigned(FOnDraw) then
FOnDraw(Self)
else
{when is not owner draw then go here}
begin
f := [];
if FMirror then f := f + [rmfMirror];
if FFlip then f := f + [rmfFlip];
r := Bounds(Round(FX), Round(FY), FImage.Width, FImage.Height);
DXDraw_Render(FEngine, FImage, r,
GetDrawImageIndex, FBlurImageArr, FBlurImage, FTextureFilter, f, FBlendMode, FAngle,
FAlpha, FCenterX, FCenterY, FScale, FWaveType, FAmplitude, FAmpLength, FPhase);
end;
end
end;
 
function Mod2f(i: Double; i2: Integer): Double;
begin
if i2 = 0 then
Result := i
else
begin
Result := i - Round(i / i2) * i2;
if Result < 0 then
Result := i2 + Result;
end;
end;
 
procedure TBlit.ReAnimate(MoveCount: Integer);
var I: Integer;
begin
with FBlitRec do begin
FAnimPos := FAnimPos + FAnimSpeed * MoveCount;
 
if FAnimLooped then
begin
if FAnimCount > 0 then
FAnimPos := Mod2f(FAnimPos, FAnimCount)
else
FAnimPos := 0;
end
else
begin
if Round(FAnimPos) >= FAnimCount then
begin
FAnimPos := FAnimCount - 1;
FAnimSpeed := 0;
end;
if FAnimPos < 0 then
begin
FAnimPos := 0;
FAnimSpeed := 0;
end;
end;
{incerease or decrease speed}
if (FEnergy <> 0) then begin
FSpeedX := FSpeedX + FSpeedX * FEnergy;
FSpeedY := FSpeedY + FSpeedY * FEnergy;
end;
{adjust with speed}
if (FSpeedX > 0) or (FSpeedY > 0) then begin
FX := FX + FSpeedX * MoveCount;
FY := FY + FSpeedY * MoveCount;
end;
{and gravity aplicable}
if (FGravityX > 0) or (FGravityY > 0) then begin
FX := FX + FGravityX * MoveCount;
FY := FY + FGravityY * MoveCount;
end;
if FBlurImage then begin
{ale jen jsou-li jine souradnice}
if (FBlurImageArr[High(FBlurImageArr)].eX <> Round(WorldX)) or
(FBlurImageArr[High(FBlurImageArr)].eY <> Round(WorldY)) then begin
for i := Low(FBlurImageArr) + 1 to High(FBlurImageArr) do begin
FBlurImageArr[i - 1] := FBlurImageArr[i];
{adjust the blur intensity}
FBlurImageArr[i - 1].eIntensity := Round(FAlpha / (High(FBlurImageArr) + 1)) * (i - 1);
end;
with FBlurImageArr[High(FBlurImageArr)] do begin
eX := Round(WorldX);
eY := Round(WorldY);
ePatternIndex := GetDrawImageIndex;
eIntensity := Round(FAlpha / (High(FBlurImageArr) + 1)) * High(FBlurImageArr);
eBlendMode := FBlendMode;
eActive := True;
end;
end;
end;
end;
end;
 
function TBlit.DoCollision: TBlit;
var
i, maxzaxis: Integer;
begin
Result := nil;
if not FBlitRec.FCollisioned then Exit;
if AsSigned(FOnCollision) then
FOnCollision(Self)
else begin
{over z axis}
maxzaxis := 0;
for i := 0 to FEngine.Traces.Count - 1 do
maxzaxis := Max(maxzaxis, FEngine.Traces.Items[i].FBlit.Z);
{for all items}
for i := 0 to FEngine.Traces.Count - 1 do
{no self item}
if FEngine.Traces.Items[i].FBlit <> Self then
{through engine}
with FEngine.Traces.Items[i] do
{test overlap}
if OverlapRect(Bounds(Round(FBlit.WorldX), Round(FBlit.WorldY),
FBlit.Width, FBlit.Height), Bounds(Round(WorldX), Round(WorldY), Width, Height)) then
begin
{if any, then return first blit}
Result := FBlit;
{and go out}
Break;
end;
end;
end;
 
procedure TBlit.DoGetImage;
begin
{init image when object come from form}
if FImage = nil then
if AsSigned(FOnGetImage) then begin
FOnGetImage(Self);
if FImage = nil then
raise EDXBlitError.Create('Undefined image file!');
FBlitRec.FWidth := FImage.Width;
FBlitRec.FHeight := FImage.Height;
end;
end;
 
constructor TBlit.Create(AParent: TObject);
begin
inherited Create;
FParent := nil;
if AParent is TBlit then
FParent := TBlit(AParent);
FillChar(FBlitRec, SizeOf(FBlitRec), 0);
with FBlitRec do begin
FCollisioned := True; {can be collisioned}
FMoved := True; {can be moved}
FVisible := True; {can be rendered}
FAnimCount := 0;
FAnimLooped := False;
FAnimPos := 0;
FAnimSpeed := 0;
FAnimStart := 0;
FAngle := 0;
FAlpha := $FF;
FCenterX := 0.5;
FCenterY := 0.5;
FScale := 1;
FBlendMode := rtDraw;
FAmplitude := 0;
FAmpLength := 0;
FPhase := 0;
FWaveType := wtWaveNone;
FSpeedX := 0;
FSpeedY := 0;
FGravityX := 0;
FGravityY := 0;
FEnergy := 0;
FBlurImage := False;
FMirror := False;
FFlip := False;
end;
FillChar(FBlurImageArr, SizeOf(FBlitRec), 0);
FActive := True; {active on}
FMovingRepeatly := True;
{super private}
FCurrentTime := 0;
FCurrentPosition := 0;
FCurrentDirection := True;
end;
 
destructor TBlit.Destroy;
begin
{$IFDEF VER4UP}
SetLength(FPathArr, 0);
{$ELSE}
SetPathLen(0);
{$ENDIF}
inherited;
end;
 
function TBlit.GetMoved: Boolean;
begin
Result := FBlitRec.FMoved;
end;
 
procedure TBlit.SetMoved(const Value: Boolean);
begin
FBlitRec.FMoved := Value;
end;
 
function TBlit.GetWaveType: TWaveType;
begin
Result := FBlitRec.FWaveType;
end;
 
procedure TBlit.SetWaveType(const Value: TWaveType);
begin
FBlitRec.FWaveType := Value;
end;
 
function TBlit.GetAmplitude: Integer;
begin
Result := FBlitRec.FAmplitude;
end;
 
procedure TBlit.SetAmplitude(const Value: Integer);
begin
FBlitRec.FAmplitude := Value;
end;
 
function TBlit.GetAnimStart: Integer;
begin
Result := FBlitRec.FAnimStart;
end;
 
procedure TBlit.SetAnimStart(const Value: Integer);
begin
FBlitRec.FAnimStart := Value;
end;
 
function TBlit.GetAmpLength: Integer;
begin
Result := FBlitRec.FAmpLength;
end;
 
procedure TBlit.SetAmpLength(const Value: Integer);
begin
FBlitRec.FAmpLength := Value;
end;
 
function TBlit.GetWidth: Integer;
begin
Result := FBlitRec.FWidth;
end;
 
procedure TBlit.SetWidth(const Value: Integer);
begin
FBlitRec.FWidth := Value;
end;
 
function TBlit.GetGravityX: Single;
begin
Result := FBlitRec.FGravityX;
end;
 
procedure TBlit.SetGravityX(const Value: Single);
begin
FBlitRec.FGravityX := Value;
end;
 
function TBlit.StoreGravityX: Boolean;
begin
Result := FBlitRec.FGravityX <> 1.0;
end;
 
function TBlit.GetPhase: Integer;
begin
Result := FBlitRec.FPhase;
end;
 
procedure TBlit.SetPhase(const Value: Integer);
begin
FBlitRec.FPhase := Value;
end;
 
function TBlit.GetAnimPos: Double;
begin
Result := FBlitRec.FAnimPos;
end;
 
procedure TBlit.SetAnimPos(const Value: Double);
begin
FBlitRec.FAnimPos := Value;
end;
 
function TBlit.StoreAnimPos: Boolean;
begin
Result := FBlitRec.FAnimPos <> 0;
end;
 
function TBlit.GetFlip: Boolean;
begin
Result := FBlitRec.FFlip;
end;
 
procedure TBlit.SetFlip(const Value: Boolean);
begin
FBlitRec.FFlip := Value;
end;
 
function TBlit.GetGravityY: Single;
begin
Result := FBlitRec.FGravityY;
end;
 
procedure TBlit.SetGravityY(const Value: Single);
begin
FBlitRec.FGravityY := Value;
end;
 
function TBlit.StoreGravityY: Boolean;
begin
Result := FBlitRec.FGravityY <> 1.0;
end;
 
function TBlit.GetSpeedX: Single;
begin
Result := FBlitRec.FSpeedX;
end;
 
procedure TBlit.SetSpeedX(const Value: Single);
begin
FBlitRec.FSpeedX := Value;
end;
 
function TBlit.StoreSpeedX: Boolean;
begin
Result := FBlitRec.FSpeedX <> 0;
end;
 
function TBlit.GetSpeedY: Single;
begin
Result := FBlitRec.FSpeedY;
end;
 
procedure TBlit.SetSpeedY(const Value: Single);
begin
FBlitRec.FSpeedY := Value;
end;
 
function TBlit.StoreSpeedY: Boolean;
begin
Result := FBlitRec.FSpeedY <> 0;
end;
 
function TBlit.GetCenterX: Double;
begin
Result := FBlitRec.FCenterX;
end;
 
procedure TBlit.SetCenterX(const Value: Double);
begin
FBlitRec.FCenterX := Value;
end;
 
function TBlit.StoreCenterX: Boolean;
begin
Result := FBlitRec.FCenterX <> 0.5;
end;
 
function TBlit.GetAngle: Single;
begin
Result := FBlitRec.FAngle;
end;
 
procedure TBlit.SetAngle(const Value: Single);
begin
FBlitRec.FAngle := Value;
end;
 
function TBlit.StoreAngle: Boolean;
begin
Result := FBlitRec.FAngle <> 0;
end;
 
function TBlit.GetBlurImage: Boolean;
begin
Result := FBlitRec.FBlurImage;
end;
 
procedure TBlit.SetBlurImage(const Value: Boolean);
begin
FBlitRec.FBlurImage := Value;
end;
 
function TBlit.GetCenterY: Double;
begin
Result := FBlitRec.FCenterY;
end;
 
procedure TBlit.SetCenterY(const Value: Double);
begin
FBlitRec.FCenterY := Value;
end;
 
function TBlit.StoreCenterY: Boolean;
begin
Result := FBlitRec.FCenterY <> 0.5;
end;
 
function TBlit.GetBlendMode: TRenderType;
begin
Result := FBlitRec.FBlendMode;
end;
 
procedure TBlit.SetBlendMode(const Value: TRenderType);
begin
FBlitRec.FBlendMode := Value;
end;
 
function TBlit.GetAnimSpeed: Double;
begin
Result := FBlitRec.FAnimSpeed;
end;
 
procedure TBlit.SetAnimSpeed(const Value: Double);
begin
FBlitRec.FAnimSpeed := Value;
end;
 
function TBlit.StoreAnimSpeed: Boolean;
begin
Result := FBlitRec.FAnimSpeed <> 0;
end;
 
function TBlit.GetZ: Integer;
begin
Result := FBlitRec.FZ;
end;
 
procedure TBlit.SetZ(const Value: Integer);
begin
FBlitRec.FZ := Value;
end;
 
function TBlit.GetMirror: Boolean;
begin
Result := FBlitRec.FMirror;
end;
 
procedure TBlit.SetMirror(const Value: Boolean);
begin
FBlitRec.FMirror := Value;
end;
 
function TBlit.GetX: Double;
begin
Result := FBlitRec.FX;
end;
 
procedure TBlit.SetX(const Value: Double);
begin
FBlitRec.FX := Value;
end;
 
function TBlit.GetVisible: Boolean;
begin
Result := FBlitRec.FVisible;
end;
 
procedure TBlit.SetVisible(const Value: Boolean);
begin
FBlitRec.FVisible := Value;
end;
 
function TBlit.GetY: Double;
begin
Result := FBlitRec.FY;
end;
 
procedure TBlit.SetY(const Value: Double);
begin
FBlitRec.FY := Value;
end;
 
function TBlit.GetAlpha: Byte;
begin
Result := FBlitRec.FAlpha;
end;
 
procedure TBlit.SetAlpha(const Value: Byte);
begin
FBlitRec.FAlpha := Value;
end;
 
function TBlit.GetEnergy: Single;
begin
Result := FBlitRec.FEnergy;
end;
 
procedure TBlit.SetEnergy(const Value: Single);
begin
FBlitRec.FEnergy := Value;
end;
 
function TBlit.StoreEnergy: Boolean;
begin
Result := FBlitRec.FEnergy <> 0;
end;
 
function TBlit.GetCollisioned: Boolean;
begin
Result := FBlitRec.FCollisioned;
end;
 
procedure TBlit.SetCollisioned(const Value: Boolean);
begin
FBlitRec.FCollisioned := Value;
end;
 
function TBlit.GetAnimLooped: Boolean;
begin
Result := FBlitRec.FAnimLooped;
end;
 
procedure TBlit.SetAnimLooped(const Value: Boolean);
begin
FBlitRec.FAnimLooped := Value;
end;
 
function TBlit.GetHeight: Integer;
begin
Result := FBlitRec.FHeight;
end;
 
procedure TBlit.SetHeight(const Value: Integer);
begin
FBlitRec.FHeight := Value;
end;
 
function TBlit.GetScale: Double;
begin
Result := FBlitRec.FScale;
end;
 
procedure TBlit.SetScale(const Value: Double);
begin
FBlitRec.FScale := Value;
end;
 
function TBlit.StoreScale: Boolean;
begin
Result := FBlitRec.FScale <> 1.0;
end;
 
function TBlit.GetAnimCount: Integer;
begin
Result := FBlitRec.FAnimCount;
end;
 
procedure TBlit.SetAnimCount(const Value: Integer);
begin
FBlitRec.FAnimCount := Value;
end;
 
function TBlit.GetTextureFilter: TD2DTextureFilter;
begin
Result := FBlitRec.FTextureFilter;
end;
 
procedure TBlit.SetTextureFilter(const Value: TD2DTextureFilter);
begin
FBlitRec.FTextureFilter := Value;
end;
 
function TBlit.GetBoundsRect: TRect;
begin
Result := Bounds(Round(WorldX), Round(WorldY), Width, Height);
end;
 
function TBlit.GetClientRect: TRect;
begin
Result := Bounds(0, 0, Width, Height);
end;
 
function TBlit.GetBlitAt(X, Y: Integer): TBlit;
 
procedure BlitAt(X, Y: Double; Blit: TBlit);
var
i: Integer;
X2, Y2: Double;
begin
if Blit.Visible and PointInRect(Point(Round(X), Round(Y)),
Bounds(Round(Blit.X), Round(Blit.Y), Blit.Width, Blit.Width)) then
begin
if (Result = nil) or (Blit.Z > Result.Z) then
Result := Blit; {uniquelly - where will be store last blit}
end;
 
X2 := X - Blit.X;
Y2 := Y - Blit.Y;
for i := 0 to Blit.Engine.FTraces.Count - 1 do
BlitAt(X2, Y2, Blit.Engine.FTraces.Items[i].FBlit);
end;
 
var
i: Integer;
X2, Y2: Double;
begin
Result := nil;
 
X2 := X - Self.X;
Y2 := Y - Self.Y;
for i := 0 to Engine.FTraces.Count - 1 do
BlitAt(X2, Y2, Engine.FTraces.Items[i].FBlit);
end;
 
procedure TBlit.SetPathLen(Len: Integer);
var I, L: Integer;
begin
{$IFDEF VER4UP}
if Length(FPathArr) <> Len then
{$ELSE}
if FPathLen <> Len then
{$ENDIF}
begin
L := Len;
if Len <= 0 then L := 0;
{$IFDEF VER4UP}
SetLength(FPathArr, L);
for I := Low(FPathArr) to High(FPathArr) do begin
FillChar(FPathArr[i], SizeOf(FPathArr), 0);
FPathArr[i].StayOn := 25;
end;
{$ELSE}
FPathLen := L;
if FPathArr = nil then
FPAthArr := AllocMem(FPathLen * SizeOf(TPath))
else
{alokuj pamet}
ReallocMem(FPathArr, FPathLen * SizeOf(TPath));
if Assigned(FPathArr) then begin
FillChar(FPathArr^, FPathLen * SizeOf(TPath), 0);
for I := 0 to FPathLen do
FPathArr[i].StayOn := 25;
end
{$ENDIF}
end;
end;
 
function TBlit.IsPathEmpty: Boolean;
begin
{$IFNDEF VER4UP}
Result := FPathLen = 0;
{$ELSE}
Result := Length(FPathArr) = 0;
{$ENDIF}
end;
 
function TBlit.GetPathCount: Integer;
begin
{$IFNDEF VER4UP}
Result := FPathLen;
{$ELSE}
Result := Length(FPathArr);
{$ENDIF}
end;
 
function TBlit.GetPath(index: Integer): TPath;
begin
{$IFDEF VER4UP}
if (index >= Low(FPathArr)) and (index <= High(FPathArr)) then
{$ELSE}
if (index >= 0) and (index < FPathLen) then
{$ENDIF}
Result := FPathArr[index]
else
raise Exception.Create('Bad path index!');
end;
 
procedure TBlit.SetPath(index: Integer; const Value: TPath);
begin
{$IFDEF VER4UP}
if (index >= Low(FPathArr)) and (index <= High(FPathArr)) then
{$ELSE}
if (index >= 0) and (index < FPathLen) then
{$ENDIF}
FPathArr[index] := Value
else
raise Exception.Create('Bad path index!');
end;
 
procedure TBlit.ReadPaths(Stream: TStream);
var
PathLen: Integer;
begin
{nacti delku}
Stream.ReadBuffer(PathLen, SizeOf(PathLen));
SetPathLen(PathLen);
Stream.ReadBuffer(FPathArr[0], PathLen * SizeOf(TPath));
end;
 
procedure TBlit.WritePaths(Stream: TStream);
var
PathLen: Integer;
begin
PathLen := GetPathCount;
Stream.WriteBuffer(PathLen, SizeOf(PathLen));
Stream.WriteBuffer(FPathArr[0], PathLen * SizeOf(TPath));
end;
 
procedure TBlit.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineBinaryProperty('Paths', ReadPaths, WritePaths, not IsPathEmpty);
end;
 
procedure TBlit.Assign(Source: TPersistent);
var I: Integer;
begin
if Source is TBlit then
begin
{$IFDEF VER4UP}
I := Length(TBlit(Source).FPathArr);
{$ELSE}
I := FPathLen;
{$ENDIF}
SetPathLen(I);
if I > 0 then
Move(TBlit(Source).FPathArr[0], FPathArr[0], I * SizeOf(TPath));
FBlitRec := TBlit(Source).FBlitRec;
FillChar(FBlurImageArr, SizeOf(FBlurImageArr), 0);
FActive := TBlit(Source).FActive;
FMovingRepeatly := TBlit(Source).FMovingRepeatly;
FImage := nil;
FOnMove := TBlit(Source).FOnMove;
FOnDraw := TBlit(Source).FOnDraw;
FOnCollision := TBlit(Source).FOnCollision;
FOnGetImage := TBlit(Source).FOnGetImage;
FEngine := TBlit(Source).FEngine;
end
else
inherited Assign(Source);
end;
 
function TBlit.GetMovingRepeatly: Boolean;
begin
Result := FMovingRepeatly;
end;
 
procedure TBlit.SetMovingRepeatly(const Value: Boolean);
begin
FMovingRepeatly := Value;
end;
 
function TBlit.GetBustrofedon: Boolean;
begin
Result := FBustrofedon;
end;
 
procedure TBlit.SetBustrofedon(const Value: Boolean);
begin
FBustrofedon := Value;
end;
 
{ utility draw }
 
procedure DXDraw_Draw(DXDraw: TCustomDXDraw; Image: TPictureCollectionItem;
Rect: TRect; Pattern: Integer; TextureFilter: TD2DTextureFilter;
MirrorFlip: TRenderMirrorFlipSet;
BlendMode: TRenderType; Angle: Single; Alpha: Byte;
CenterX: Double; CenterY: Double;
Scale: Single); {$IFDEF VER9UP}inline;{$ENDIF}
var
// r: TRect;
width, height: Integer;
begin
if not Assigned(DXDraw.Surface) then Exit;
if not Assigned(Image) then Exit;
if Scale <> 1.0 then begin
width := Round(Scale * Image.Width);
height := Round(Scale * Image.Height);
end
else begin
width := Image.Width;
height := Image.Height;
end;
//r := Bounds(X, Y, width, height);
DXDraw.TextureFilter(TextureFilter);
DXDraw.MirrorFlip(MirrorFlip);
case BlendMode of
rtDraw: begin
if Angle = 0 then
Image.StretchDraw(DXDraw.Surface, Rect, Pattern)
else
Image.DrawRotate(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle);
end;
rtBlend: begin
if Angle = 0 then
Image.DrawAlpha(DXDraw.Surface, Rect, Pattern, Alpha)
else
Image.DrawRotateAlpha(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle, Alpha);
end;
rtAdd: begin
if Angle = 0 then
Image.DrawAdd(DXDraw.Surface, Rect, Pattern, Alpha)
else
Image.DrawRotateAdd(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle, Alpha);
end;
rtSub: begin
if Angle = 0 then
Image.DrawSub(DXDraw.Surface, Rect, Pattern, Alpha)
else
Image.DrawRotateSub(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle, Alpha);
end;
end; {case}
end;
 
procedure DXDraw_Paint(DXDraw: TCustomDXDraw; Image: TPictureCollectionItem;
Rect: TRect; Pattern: Integer; var BlurImageArr: TBlurImageArr; BlurImage: Boolean;
TextureFilter: TD2DTextureFilter;
MirrorFlip: TRenderMirrorFlipSet;
BlendMode: TRenderType;
Angle: Single;
Alpha: Byte;
CenterX: Double; CenterY: Double); {$IFDEF VER9UP}inline;{$ENDIF}
var
rr: TRect;
i, width, height: Integer;
begin
if not Assigned(DXDraw.Surface) then Exit;
if not Assigned(Image) then Exit;
width := Image.Width;
height := Image.Height;
//rr := Bounds(X, Y, width, height);
//DXDraw.MirrorFlip(MirrorFlip);
DXDraw.TextureFilter(TextureFilter);
case BlendMode of
rtDraw: begin
if BlurImage then begin
for i := Low(BlurImageArr) to High(BlurImageArr) do if BlurImageArr[i].eActive then begin
DXDraw.MirrorFlip(MirrorFlip);
rr := Bounds(BlurImageArr[i].eX, BlurImageArr[i].eY, Width, Height);
if Angle = 0 then
Image.DrawAlpha(DXDraw.Surface, rr, BlurImageArr[i].ePatternIndex, BlurImageArr[i].eIntensity)
else
Image.DrawRotateAlpha(DXDraw.Surface, (rr.Left + rr.Right) div 2,
(rr.Top + rr.Bottom) div 2,
Width, Height, BlurImageArr[i].ePatternIndex, CenterX, CenterY, BlurImageArr[i].eAngle, BlurImageArr[i].eIntensity);
if BlurImageArr[i].eIntensity > 0 then Dec(BlurImageArr[i].eIntensity) else FillChar(BlurImageArr[i], SizeOf(BlurImageArr[i]), 0);
end;
end;
DXDraw.MirrorFlip(MirrorFlip);
if Angle = 0 then
Image.StretchDraw(DXDraw.Surface, Rect, Pattern)
else
Image.DrawRotate(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle);
end;
rtBlend: begin
if BlurImage then begin
for i := Low(BlurImageArr) to High(BlurImageArr) do if BlurImageArr[i].eActive then begin
DXDraw.MirrorFlip(MirrorFlip);
rr := Bounds(BlurImageArr[i].eX, BlurImageArr[i].eY, Width, Height);
if Angle = 0 then
Image.DrawAlpha(DXDraw.Surface, rr, Pattern, BlurImageArr[i].eIntensity)
else
Image.DrawRotateAlpha(DXDraw.Surface, (rr.Left + rr.Right) div 2,
(rr.Top + rr.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, BlurImageArr[i].eAngle, BlurImageArr[i].eIntensity);
if BlurImageArr[i].eIntensity > 0 then Dec(BlurImageArr[i].eIntensity) else FillChar(BlurImageArr[i], SizeOf(BlurImageArr[i]), 0);
end;
end;
DXDraw.MirrorFlip(MirrorFlip);
if Angle = 0 then
Image.DrawAlpha(DXDraw.Surface, Rect, Pattern, Alpha)
else
Image.DrawRotateAlpha(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle, Alpha);
end;
rtAdd: begin
if BlurImage then begin
for i := Low(BlurImageArr) to High(BlurImageArr) do if BlurImageArr[i].eActive then begin
DXDraw.MirrorFlip(MirrorFlip);
rr := Bounds(BlurImageArr[i].eX, BlurImageArr[i].eY, Width, Height);
if Angle = 0 then
Image.DrawAdd(DXDraw.Surface, rr, Pattern, BlurImageArr[i].eIntensity)
else
Image.DrawRotateAdd(DXDraw.Surface, (rr.Left + rr.Right) div 2,
(rr.Top + rr.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, BlurImageArr[i].eAngle, BlurImageArr[i].eIntensity);
if BlurImageArr[i].eIntensity > 0 then Dec(BlurImageArr[i].eIntensity) else FillChar(BlurImageArr[i], SizeOf(BlurImageArr[i]), 0);
end;
end;
DXDraw.MirrorFlip(MirrorFlip);
if Angle = 0 then
Image.DrawAdd(DXDraw.Surface, Rect, Pattern, Alpha)
else
Image.DrawRotateAdd(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle, Alpha);
end;
rtSub: begin
if BlurImage then begin
for i := Low(BlurImageArr) to High(BlurImageArr) do if BlurImageArr[i].eActive then begin
DXDraw.MirrorFlip(MirrorFlip);
rr := Bounds(BlurImageArr[i].eX, BlurImageArr[i].eY, Width, Height);
if Angle = 0 then
Image.DrawSub(DXDraw.Surface, rr, Pattern, BlurImageArr[i].eIntensity)
else
Image.DrawRotateSub(DXDraw.Surface, (rr.Left + rr.Right) div 2,
(rr.Top + rr.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, BlurImageArr[i].eAngle, BlurImageArr[i].eIntensity);
if BlurImageArr[i].eIntensity > 0 then Dec(BlurImageArr[i].eIntensity) else FillChar(BlurImageArr[i], SizeOf(BlurImageArr[i]), 0);
end;
end;
DXDraw.MirrorFlip(MirrorFlip);
if Angle = 0 then
Image.DrawSub(DXDraw.Surface, Rect, Pattern, Alpha)
else
Image.DrawRotateSub(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle, Alpha);
end;
end; {case}
end;
 
procedure DXDraw_Render(DXDraw: TCustomDXDraw; Image: TPictureCollectionItem;
Rect: TRect; Pattern: Integer; var BlurImageArr: TBlurImageArr; BlurImage: Boolean;
TextureFilter: TD2DTextureFilter; MirrorFlip: TRenderMirrorFlipSet;
BlendMode: TRenderType;
Angle: Single;
Alpha: Byte;
CenterX: Double; CenterY: Double;
Scale: Single;
WaveType: TWaveType;
Amplitude: Integer; AmpLength: Integer; Phase: Integer); {$IFDEF VER9UP}inline;{$ENDIF}
var
rr: TRect;
i, width, height: Integer;
begin
if not Assigned(DXDraw.Surface) then Exit;
if not Assigned(Image) then Exit;
if Scale <> 1.0 then begin
width := Round(Scale * Image.Width);
height := Round(Scale * Image.Height);
end
else begin
width := Image.Width;
height := Image.Height;
end;
//r := Bounds(X, Y, width, height);
DXDraw.TextureFilter(TextureFilter);
DXDraw.MirrorFlip(MirrorFlip);
case BlendMode of
rtDraw:
begin
case WaveType of
wtWaveNone:
begin
if BlurImage then begin
for i := Low(BlurImageArr) to High(BlurImageArr) do if BlurImageArr[i].eActive then begin
DXDraw.MirrorFlip(MirrorFlip);
rr := Bounds(BlurImageArr[i].eX, BlurImageArr[i].eY, Round(Scale * Width), Round(Scale * Height));
if Angle = 0 then
Image.DrawAlpha(DXDraw.Surface, rr, BlurImageArr[i].ePatternIndex, BlurImageArr[i].eIntensity)
else
Image.DrawRotateAlpha(DXDraw.Surface, (rr.Left + rr.Right) div 2,
(rr.Top + rr.Bottom) div 2,
Width, Height, BlurImageArr[i].ePatternIndex, CenterX, CenterY, BlurImageArr[i].eAngle, BlurImageArr[i].eIntensity);
if BlurImageArr[i].eIntensity > 0 then Dec(BlurImageArr[i].eIntensity) else FillChar(BlurImageArr[i], SizeOf(BlurImageArr[i]), 0);
end;
end;
DXDraw.MirrorFlip(MirrorFlip);
if Angle = 0 then
Image.StretchDraw(DXDraw.Surface, Rect, Pattern)
else
Image.DrawRotate(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle);
end;
wtWaveX: Image.DrawWaveX(DXDraw.Surface, Round(Rect.Left), Round(Rect.Top), Width, Height, Pattern, Amplitude, AmpLength, Phase);
wtWaveY: Image.DrawWaveY(DXDraw.Surface, Round(Rect.Left), Round(Rect.Top), Width, Height, Pattern, Amplitude, AmpLength, Phase);
end;
end;
rtBlend: begin
case WaveType of
wtWaveNone: begin
if BlurImage then begin
for i := Low(BlurImageArr) to High(BlurImageArr) do if BlurImageArr[i].eActive then begin
DXDraw.MirrorFlip(MirrorFlip);
rr := Bounds(BlurImageArr[i].eX, BlurImageArr[i].eY, Round(Scale * Width), Round(Scale * Height));
if Angle = 0 then
Image.DrawAlpha(DXDraw.Surface, rr, Pattern, BlurImageArr[i].eIntensity)
else
Image.DrawRotateAlpha(DXDraw.Surface, (rr.Left + rr.Right) div 2,
(rr.Top + rr.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, BlurImageArr[i].eAngle, BlurImageArr[i].eIntensity);
if BlurImageArr[i].eIntensity > 0 then Dec(BlurImageArr[i].eIntensity) else FillChar(BlurImageArr[i], SizeOf(BlurImageArr[i]), 0);
end;
end;
DXDraw.MirrorFlip(MirrorFlip);
if Angle = 0 then
Image.DrawAlpha(DXDraw.Surface, Rect, Pattern, Alpha)
else
Image.DrawRotateAlpha(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle, Alpha);
end;
wtWaveX: Image.DrawWaveXAlpha(DXDraw.Surface, Round(Rect.Left), Round(Rect.Top), Width, Height, Pattern, Amplitude, AmpLength, Phase, Alpha);
wtWaveY: Image.DrawWaveYAlpha(DXDraw.Surface, Round(Rect.Top), Round(Rect.Top), Width, Height, Pattern, Amplitude, AmpLength, Phase, Alpha);
end;
end;
rtAdd: begin
case WaveType of
wtWaveNone: begin
if BlurImage then begin
for i := Low(BlurImageArr) to High(BlurImageArr) do if BlurImageArr[i].eActive then begin
DXDraw.MirrorFlip(MirrorFlip);
rr := Bounds(BlurImageArr[i].eX, BlurImageArr[i].eY, Round(Scale * Width), Round(Scale * Height));
if Angle = 0 then
Image.DrawAdd(DXDraw.Surface, rr, Pattern, BlurImageArr[i].eIntensity)
else
Image.DrawRotateAdd(DXDraw.Surface, (rr.Left + rr.Right) div 2,
(rr.Top + rr.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, BlurImageArr[i].eAngle, BlurImageArr[i].eIntensity);
if BlurImageArr[i].eIntensity > 0 then Dec(BlurImageArr[i].eIntensity) else FillChar(BlurImageArr[i], SizeOf(BlurImageArr[i]), 0);
end;
end;
DXDraw.MirrorFlip(MirrorFlip);
if Angle = 0 then
Image.DrawAdd(DXDraw.Surface, Rect, Pattern, Alpha)
else
Image.DrawRotateAdd(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle, Alpha);
end;
wtWaveX: Image.DrawWaveXAdd(DXDraw.Surface, Round(Rect.Left), Round(Rect.Top), Width, Height, Pattern, Amplitude, AmpLength, Phase, Alpha);
wtWaveY: Image.DrawWaveYAdd(DXDraw.Surface, Round(Rect.Top), Round(Rect.Top), Width, Height, Pattern, Amplitude, AmpLength, Phase, Alpha);
end;
end;
rtSub: begin
case WaveType of
wtWaveNone: begin
if BlurImage then begin
for i := Low(BlurImageArr) to High(BlurImageArr) do if BlurImageArr[i].eActive then begin
DXDraw.MirrorFlip(MirrorFlip);
rr := Bounds(BlurImageArr[i].eX, BlurImageArr[i].eY, Round(Scale * Width), Round(Scale * Height));
if Angle = 0 then
Image.DrawSub(DXDraw.Surface, rr, Pattern, BlurImageArr[i].eIntensity)
else
Image.DrawRotateSub(DXDraw.Surface, (rr.Left + rr.Right) div 2,
(rr.Top + rr.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, BlurImageArr[i].eAngle, BlurImageArr[i].eIntensity);
if BlurImageArr[i].eIntensity > 0 then Dec(BlurImageArr[i].eIntensity) else FillChar(BlurImageArr[i], SizeOf(BlurImageArr[i]), 0);
end;
end;
DXDraw.MirrorFlip(MirrorFlip);
if Angle = 0 then
Image.DrawSub(DXDraw.Surface, Rect, Pattern, Alpha)
else
Image.DrawRotateSub(DXDraw.Surface, (Rect.Left + Rect.Right) div 2,
(Rect.Top + Rect.Bottom) div 2,
Width, Height, Pattern, CenterX, CenterY, Angle, Alpha);
end;
wtWaveX: Image.DrawWaveXSub(DXDraw.Surface, Round(Rect.Left), Round(Rect.Top), Width, Height, Pattern, Amplitude, AmpLength, Phase, Alpha);
wtWaveY: Image.DrawWaveYSub(DXDraw.Surface, Round(Rect.Top), Round(Rect.Top), Width, Height, Pattern, Amplitude, AmpLength, Phase, Alpha);
end;
end;
end; {case}
end;
 
initialization
_DXTextureImageLoadFuncList := TList.Create;
TDXTextureImage.RegisterLoadFunc(DXTextureImage_LoadDXTextureImageFunc); //delete Mr.Kawasaki
TDXTextureImage.RegisterLoadFunc(DXTextureImage_LoadBitmapFunc);
finalization
TDXTextureImage.UnRegisterLoadFunc(DXTextureImage_LoadDXTextureImageFunc); //delete Mr.Kawasaki
TDXTextureImage.UnRegisterLoadFunc(DXTextureImage_LoadBitmapFunc);
_DXTextureImageLoadFuncList.Free;
{ driver free }
DirectDrawDrivers.Free;
{$IFDEF _DMO_}DirectDrawDriversEx.Free;{$ENDIF}
end.
end.
 
 
/VCL_DELPHIX_D6/DXPlayFm.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DAnim.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXETable.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXTexImg.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DelphiX_for6.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXFFBEdit.dfm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/VCL_DELPHIX_D6/DXGUIDEdit.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXInput.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXPlayFm.pas
1,23 → 1,10
unit DXPlayFm;
 
{$INCLUDE DelphiXcfg.inc}
 
{$IFNDEF UseDirectPlay}
// If you want to use DXPlayFm.pas, please enable the IFDEF UseDirectPlay in DelphiXcfg.inc
interface
implementation
{$ELSE} // !UseDirectPlay
 
interface
 
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, DXPlay, ActiveX, DXETable, DIB,
{$IfDef StandardDX}
DirectDraw, DirectPlay;
{$Else}
DirectX;
{$EndIf}
StdCtrls, ExtCtrls, DirectX, DXPlay, ActiveX, DXETable, DIB;
 
type
TDelphiXDXPlayForm = class(TForm)
67,9 → 54,7
private
FProviderGUID: TGUID;
public
DPlay: //{$IfDef DX7}
IDirectPlay4A;
//{$Else}IDirectPlay8Address{$EndIf};
DPlay: IDirectPlay4A;
DXPlay: TCustomDXPlay;
PlayerName: string;
ProviderName: string;
119,15 → 104,12
 
procedure InitDirectPlay;
var
DPlay1: //{$IfDef DX7}
IDirectPlay;
//{$Else}IDirectPlay8Server{$EndIf};
DPlay1: IDirectPlay;
begin
if DXDirectPlayCreate(FProviderGUID, DPlay1, nil)<>0 then
raise EDXPlayError.CreateFmt(SCannotInitialized, [SDirectPlay]);
 
DPlay := DPlay1 as //{$IfDef DX7}
IDirectPlay4A//{$Else}IDirectPlay8Address{$EndIf}
DPlay := DPlay1 as IDirectPlay4A;
end;
 
function EnumSessionsCallback(const lpThisSD: TDPSessionDesc2;
143,11 → 125,8
 
Guid := New(PGUID);
Move(lpThisSD.guidInstance, Guid^, SizeOf(TGUID));
{$IFDEF UNICODE}
TDelphiXDXPlayForm(lpContext).JoinGameSessionList.Items.AddObject(lpThisSD.lpszSessionNameW, Pointer(Guid));
{$ELSE}
TDelphiXDXPlayForm(lpContext).JoinGameSessionList.Items.AddObject(lpThisSD.lpszSessionNameA, Pointer(Guid));
{$ENDIF}
 
Result := True;
end;
 
253,11 → 232,7
with lpName do
begin
if lpszShortNameA<>nil then
{$IFDEF UNICODE}
TDelphiXDXPlayForm(lpContext).JoinGamePlayerList.Items.Add(lpszShortNameW);
{$ELSE}
TDelphiXDXPlayForm(lpContext).JoinGamePlayerList.Items.Add(lpszShortNameA);
{$ENDIF}
end;
 
Result := True;
289,7 → 264,7
hr := TempDPlay.Open(dpDesc, DPOPEN_JOIN);
if hr<>0 then Exit;
try
TempDPlay.EnumPlayers(PGUID(nil), @EnumPlayersCallback2, Self, DPENUMPLAYERS_REMOTE);
TempDPlay.EnumPlayers(PGUID(nil)^, @EnumPlayersCallback2, Self, DPENUMPLAYERS_REMOTE);
finally
TempDPlay.Close;
end;
436,7 → 411,5
end;
end;
 
{$ENDIF} // UseDirectPlay
 
end.
 
/VCL_DELPHIX_D6/DXETable.pas
5,36 → 5,15
{$INCLUDE DelphiXcfg.inc}
 
uses
Windows, SysUtils,
{$IfDef StandardDX}
{$ifdef DX7}
DirectDraw, Direct3D,DirectInput,DirectPlay,DirectSound;
{$else}
{$IfDef DX9}
DirectDraw, Direct3D9, Direct3D, D3DX9, {Direct3D8,} DX7toDX8, DirectInput, DirectPlay8, DirectSound;
// {$Else}
// {$IfDef DX81}
// D3DX8, Direct3D8, DirectInput8, DirectXGraphics, DX7toDX8, DirectPlay8;
// {$Else}
// DirectInput, Direct3D, Direct3DRM, DirectPlay;
{$EndIf}
{$EndIf}
{$Else}
DirectX;
{$EndIf}
Windows, SysUtils, DirectX;
 
 
function WindowsErrorMsg(ErrorCode: HRESULT): string;
function DDrawErrorMsg(ErrorCode: HRESULT): string;
function D3DErrorMsg(ErrorCode: HRESULT): string;
{$IFDEF D3DRM}
function D3DRMErrorMsg(ErrorCode: HRESULT): string;
{$ENDIF}
function DSoundErrorMsg(ErrorCode: HRESULT): string;
function DInputErrorMsg(ErrorCode: HRESULT): string;
{$IFDEF UseDirectPlay}
function DPlayErrorMsg(ErrorCode: HRESULT): string;
{$EndIf} // UseDirectPlay
 
implementation
 
225,7 → 204,7
Result := WindowsErrorMsg(ErrorCode);
end;
end;
{$IFDEF D3DRM}
 
function D3DRMErrorMsg(ErrorCode: HRESULT): string;
begin
case ErrorCode of
247,7 → 226,7
Result := WindowsErrorMsg(ErrorCode);
end;
end;
{$ENDIF}
 
function DSoundErrorMsg(ErrorCode: HRESULT): string;
begin
case ErrorCode of
292,82 → 271,15
DIERR_INPUTLOST : Result := 'DIERR_INPUTLOST';
DIERR_ACQUIRED : Result := 'DIERR_ACQUIRED';
DIERR_NOTACQUIRED : Result := 'DIERR_NOTACQUIRED';
HRESULT(E_PENDING) : Result := 'E_PENDING';
E_PENDING : Result := 'E_PENDING';
else
Result := WindowsErrorMsg(ErrorCode);
end;
end;
{$IFDEF UseDirectPlay}
{$IfDef DX9}
 
function DPlayErrorMsg(ErrorCode: HRESULT): string;
begin
case ErrorCode of
DPN_OK : Result := 'DPN_OK';
DPNERR_ALREADYINITIALIZED : Result := 'DPNERR_ALREADYINITIALIZED';
//DPNERR_ACCESSDENIED : Result := 'DPNERR_ACCESSDENIED';
//DPNERR_ACTIVEPLAYERS : Result := 'DPNERR_ACTIVEPLAYERS';
DPNERR_BUFFERTOOSMALL : Result := 'DPNERR_BUFFERTOOSMALL';
//DPNERR_CANTADDPLAYER : Result := 'DPNERR_CANTADDPLAYER';
DPNERR_CANTCREATEGROUP : Result := 'DPNERR_CANTCREATEGROUP';
DPNERR_CANTCREATEPLAYER : Result := 'DPNERR_CANTCREATEPLAYER';
//DPNERR_CANTCREATESESSION : Result := 'DPNERR_CANTCREATESESSION';
//DPNERR_CAPSNOTAVAILABLEYET : Result := 'DPNERR_CAPSNOTAVAILABLEYET';
DPNERR_EXCEPTION : Result := 'DPNERR_EXCEPTION';
DPNERR_GENERIC : Result := 'DPNERR_GENERIC';
DPNERR_INVALIDFLAGS : Result := 'DPNERR_INVALIDFLAGS';
DPNERR_INVALIDOBJECT : Result := 'DPNERR_INVALIDOBJECT';
DPNERR_INVALIDPARAM : Result := 'DPNERR_INVALIDPARAM, DPNERR_INVALIDPARAMS';
DPNERR_INVALIDPLAYER : Result := 'DPNERR_INVALIDPLAYER';
DPNERR_INVALIDGROUP : Result := 'DPNERR_INVALIDGROUP';
DPNERR_NOCAPS : Result := 'DPNERR_NOCAPS';
DPNERR_NOCONNECTION : Result := 'DPNERR_NOCONNECTION';
//DPNERR_NOMEMORY : Result := 'DPNERR_NOMEMORY, DPNERR_OUTOFMEMORY';
//DPNERR_NOMESSAGES : Result := 'DPNERR_NOMESSAGES';
//DPNERR_NONAMESERVERFOUND : Result := 'DPNERR_NONAMESERVERFOUND';
//DPNERR_NOPLAYERS : Result := 'DPNERR_NOPLAYERS';
//DPNERR_NOSESSIONS : Result := 'DPNERR_NOSESSIONS';
DPNERR_PENDING : Result := 'DPNERR_PENDING';
//DPNERR_SENDTOOBIG : Result := 'DPNERR_SENDTOOBIG';
//DPNERR_TIMEOUT : Result := 'DPNERR_TIMEOUT';
//DPNERR_UNAVAILABLE : Result := 'DPNERR_UNAVAILABLE';
DPNERR_UNSUPPORTED : Result := 'DPNERR_UNSUPPORTED';
//DPNERR_BUSY : Result := 'DPNERR_BUSY';
DPNERR_USERCANCEL : Result := 'DPNERR_USERCANCEL';
DPNERR_NOINTERFACE : Result := 'DPNERR_NOINTERFACE';
//DPNERR_CANNOTCREATESERVER : Result := 'DPNERR_CANNOTCREATESERVER';
DPNERR_PLAYERLOST : Result := 'DPNERR_PLAYERLOST';
//DPNERR_SESSIONLOST : Result := 'DPNERR_SESSIONLOST';
DPNERR_UNINITIALIZED : Result := 'DPNERR_UNINITIALIZED';
//DPNERR_NONEWPLAYERS : Result := 'DPNERR_NONEWPLAYERS';
DPNERR_INVALIDPASSWORD : Result := 'DPNERR_INVALIDPASSWORD';
DPNERR_CONNECTING : Result := 'DPNERR_CONNECTING';
//DPNERR_BUFFERTOOLARGE : Result := 'DPNERR_BUFFERTOOLARGE';
//DPNERR_CANTCREATEPROCESS : Result := 'DPNERR_CANTCREATEPROCESS';
//DPNERR_APPNOTSTARTED : Result := 'DPNERR_APPNOTSTARTED';
DPNERR_INVALIDINTERFACE : Result := 'DPNERR_INVALIDINTERFACE';
//DPNERR_NOSERVICEPROVIDER : Result := 'DPNERR_NOSERVICEPROVIDER';
//DPNERR_UNKNOWNAPPLICATION : Result := 'DPNERR_UNKNOWNAPPLICATION';
//DPNERR_NOTLOBBIED : Result := 'DPNERR_NOTLOBBIED';
//DPNERR_SERVICEPROVIDERLOADED : Result := 'DPNERR_SERVICEPROVIDERLOADED';
DPNERR_NOTREGISTERED : Result := 'DPNERR_NOTREGISTERED';
// Security related errors
//DPNERR_AUTHENTICATIONFAILED : Result := 'DPNERR_AUTHENTICATIONFAILED';
//DPNERR_CANTLOADSSPI : Result := 'DPNERR_CANTLOADSSPI';
//DPNERR_ENCRYPTIONFAILED : Result := 'DPNERR_ENCRYPTIONFAILED';
//DPNERR_SIGNFAILED : Result := 'DPNERR_SIGNFAILED';
//DPNERR_CANTLOADSECURITYPACKAGE : Result := 'DPNERR_CANTLOADSECURITYPACKAGE';
//DPNERR_ENCRYPTIONNOTSUPPORTED : Result := 'DPNERR_ENCRYPTIONNOTSUPPORTED';
//DPNERR_CANTLOADCAPI : Result := 'DPNERR_CANTLOADCAPI';
//DPNERR_NOTLOGGEDIN : Result := 'DPNERR_NOTLOGGEDIN';
//DPNERR_LOGONDENIED : Result := 'DPNERR_LOGONDENIED';
else
Result := WindowsErrorMsg(ErrorCode);
end;
end;
{$Else}
function DPlayErrorMsg(ErrorCode: HRESULT): string;
begin
case ErrorCode of
DP_OK : Result := 'DP_OK';
DPERR_ALREADYINITIALIZED : Result := 'DPERR_ALREADYINITIALIZED';
DPERR_ACCESSDENIED : Result := 'DPERR_ACCESSDENIED';
430,6 → 342,5
Result := WindowsErrorMsg(ErrorCode);
end;
end;
{$EndIf}
{$EndIf} // UseDirectPlay
 
end.
/VCL_DELPHIX_D6/DAnim.pas
22,9 → 22,7
 
{$Z4}
{$A+}
{$IfNDef D7UP}
{$WEAKPACKAGEUNIT}
{$EndIf}
 
uses Windows, ActiveX, DirectX, DShow;
 
1111,18 → 1109,18
out lplpDDClipper: IDirectDrawClipper; pUnkOuter: IUnknown): HResult; stdcall;
function CreatePalette(dwFlags: DWORD; lpColorTable: PPaletteEntry;
out lplpDDPalette: IDirectDrawPalette; pUnkOuter: IUnknown): HResult;stdcall;
function CreateSurface(const lpDDSurfaceDesc: TDDSURFACEDESC;
function CreateSurface(const lpDDSurfaceDesc: DDSURFACEDESC;
out lplpDDSurface: IDirectDrawSurface; pUnkOuter: IUnknown): HResult; stdcall;
function DuplicateSurface(lpDDSurface: IDirectDrawSurface;
out lplpDupDDSurface: IDirectDrawSurface): HResult; stdcall;
function EnumDisplayModes(dwFlags: DWORD;
const lpDDSurfaceDesc: TDDSURFACEDESC; lpContext: Pointer;
lpEnumModesCallback: {LPDDENUMMODESCALLBACK}TDDEnumModesCallback): HResult; stdcall;
function EnumSurfaces(dwFlags: DWORD; const lpDDSD: TDDSURFACEDESC;
lpContext: Pointer; lpEnumCallback: {LPDDENUMSURFACESCALLBACK}TDDEnumSurfacesCallback): HResult; stdcall;
const lpDDSurfaceDesc: DDSURFACEDESC; lpContext: Pointer;
lpEnumModesCallback: LPDDENUMMODESCALLBACK): HResult; stdcall;
function EnumSurfaces(dwFlags: DWORD; const lpDDSD: DDSURFACEDESC;
lpContext: Pointer; lpEnumCallback: LPDDENUMSURFACESCALLBACK): HResult; stdcall;
function FlipToGDISurface: HResult; stdcall;
function GetCaps(var lpDDDriverCaps: TDDCAPS; var lpDDHELCaps: TDDCAPS): HResult; stdcall;
function GetDisplayMode(var lpDDSurfaceDesc: TDDSURFACEDESC): HResult; stdcall;
function GetCaps(var lpDDDriverCaps: DDCAPS; var lpDDHELCaps: DDCAPS): HResult; stdcall;
function GetDisplayMode(var lpDDSurfaceDesc: DDSURFACEDESC): HResult; stdcall;
function GetFourCCCodes(var lpNumCodes, lpCodes: DWORD): HResult; stdcall;
function GetGDISurface(out lplpGDIDDSSurface: IDirectDrawSurface): HResult; stdcall;
function GetMonitorFrequency(var lpdwFrequency: DWORD): HResult; stdcall;
1135,7 → 1133,7
dwFlags: DWORD): HResult; stdcall;
function WaitForVerticalBlank(dwFlags: DWORD; hEvent: THandle): HResult; stdcall;
// IDirectDraw2 methods
function GetAvailableVidMem(var lpDDSCaps: TDDSCAPS;
function GetAvailableVidMem(var lpDDSCaps: DDSCAPS;
var lpdwTotal, lpdwFree: DWORD): HResult; stdcall;
// IDirectDraw3 methods
function GetSurfaceFromDC(hdc: HDC; out ppSurface: IDirectDrawSurface): HResult; stdcall;
/VCL_DELPHIX_D6/DXTexImg.pas
0,0 → 1,1304
unit DXTexImg;
 
interface
 
uses
Windows, SysUtils, Classes, DXConsts;
 
const
DXTextureImageGroupType_Normal = 0; // Normal group
DXTextureImageGroupType_Mipmap = 1; // Mipmap group
 
type
EDXTextureImageError = class(Exception);
 
TDXTextureImageChannel = record
Mask: DWORD;
BitCount: Integer;
 
{ Internal use }
_Mask2: DWORD;
_rshift: Integer;
_lshift: Integer;
_BitCount2: Integer;
end;
 
TDXTextureImage_PaletteEntries = array[0..255] of TPaletteEntry;
 
TDXTextureImageType = (
DXTextureImageType_PaletteIndexedColor,
DXTextureImageType_RGBColor
);
 
TDXTextureImage = class;
 
TDXTextureImageLoadFunc = procedure(Stream: TStream; Image: TDXTextureImage);
 
TDXTextureImage = class
private
FOwner: TDXTextureImage;
FSubImage: TList;
FImageType: TDXTextureImageType;
FWidth: Integer;
FHeight: Integer;
FPBits: Pointer;
FBitCount: Integer;
FPackedPixelOrder: Boolean;
FWidthBytes: Integer;
FNextLine: Integer;
FSize: Integer;
FTopPBits: Pointer;
FTransparent: Boolean;
FTransparentColor: DWORD;
FImageGroupType: DWORD;
FImageID: DWORD;
FImageName: string;
FAutoFreeImage: Boolean;
procedure ClearImage;
function GetPixel(x, y: Integer): DWORD;
procedure SetPixel(x, y: Integer; c: DWORD);
function GetScanLine(y: Integer): Pointer;
function GetSubGroupImageCount(GroupTypeID: DWORD): Integer;
function GetSubGroupImage(GroupTypeID: DWORD; Index: Integer): TDXTextureImage;
function GetSubImageCount: Integer;
function GetSubImage(Index: Integer): TDXTextureImage;
public
idx_index: TDXTextureImageChannel;
idx_alpha: TDXTextureImageChannel;
idx_palette: TDXTextureImage_PaletteEntries;
rgb_red: TDXTextureImageChannel;
rgb_green: TDXTextureImageChannel;
rgb_blue: TDXTextureImageChannel;
rgb_alpha: TDXTextureImageChannel;
constructor Create;
constructor CreateSub(AOwner: TDXTextureImage);
destructor Destroy; override;
procedure Assign(Source: TDXTextureImage);
procedure Clear;
procedure SetImage(ImageType: TDXTextureImageType; Width, Height, BitCount, WidthBytes, NextLine: Integer;
PBits, TopPBits: Pointer; Size: Integer; AutoFree: Boolean);
procedure SetSize(ImageType: TDXTextureImageType; Width, Height, BitCount, WidthBytes: Integer);
procedure LoadFromFile(const FileName: string);
procedure LoadFromStream(Stream: TStream);
procedure SaveToFile(const FileName: string);
procedure SaveToStream(Stream: TStream);
function EncodeColor(R, G, B, A: Byte): DWORD;
function PaletteIndex(R, G, B: Byte): DWORD;
class procedure RegisterLoadFunc(LoadFunc: TDXTextureImageLoadFunc);
class procedure UnRegisterLoadFunc(LoadFunc: TDXTextureImageLoadFunc);
property BitCount: Integer read FBitCount;
property PackedPixelOrder: Boolean read FPackedPixelOrder write FPackedPixelOrder;
property Height: Integer read FHeight;
property ImageType: TDXTextureImageType read FImageType;
property ImageGroupType: DWORD read FImageGroupType write FImageGroupType;
property ImageID: DWORD read FImageID write FImageID;
property ImageName: string read FImageName write FImageName;
property NextLine: Integer read FNextLine;
property PBits: Pointer read FPBits;
property Pixels[x, y: Integer]: DWORD read GetPixel write SetPixel;
property ScanLine[y: Integer]: Pointer read GetScanLine;
property Size: Integer read FSize;
property SubGroupImageCount[GroupTypeID: DWORD]: Integer read GetSubGroupImageCount;
property SubGroupImages[GroupTypeID: DWORD; Index: Integer]: TDXTextureImage read GetSubGroupImage;
property SubImageCount: Integer read GetSubImageCount;
property SubImages[Index: Integer]: TDXTextureImage read GetSubImage;
property TopPBits: Pointer read FTopPBits;
property Transparent: Boolean read FTransparent write FTransparent;
property TransparentColor: DWORD read FTransparentColor write FTransparentColor;
property Width: Integer read FWidth;
property WidthBytes: Integer read FWidthBytes;
end;
 
function dxtMakeChannel(Mask: DWORD; indexed: Boolean): TDXTextureImageChannel;
function dxtEncodeChannel(const Channel: TDXTextureImageChannel; c: DWORD): DWORD;
function dxtDecodeChannel(const Channel: TDXTextureImageChannel; c: DWORD): DWORD;
 
implementation
 
function GetWidthBytes(Width, BitCount: Integer): Integer;
begin
Result := (((Width*BitCount)+31) div 32)*4;
end;
 
function dxtEncodeChannel(const Channel: TDXTextureImageChannel; c: DWORD): DWORD;
begin
Result := ((c shl Channel._rshift) shr Channel._lshift) and Channel.Mask;
end;
 
function dxtDecodeChannel(const Channel: TDXTextureImageChannel; c: DWORD): DWORD;
begin
Result := ((c and Channel.Mask) shr Channel._rshift) shl Channel._lshift;
Result := Result or (Result shr Channel._BitCount2);
end;
 
function dxtMakeChannel(Mask: DWORD; indexed: Boolean): TDXTextureImageChannel;
 
function GetMaskBitCount(b: Integer): Integer;
var
i: Integer;
begin
i := 0;
while (i<31) and (((1 shl i) and b)=0) do Inc(i);
 
Result := 0;
while ((1 shl i) and b)<>0 do
begin
Inc(i);
Inc(Result);
end;
end;
 
function GetBitCount2(b: Integer): Integer;
begin
Result := 0;
while (Result<31) and (((1 shl Result) and b)=0) do Inc(Result);
end;
 
begin
Result.BitCount := GetMaskBitCount(Mask);
Result.Mask := Mask;
 
if indexed then
begin
Result._rshift := GetBitCount2(Mask);
Result._lshift := 0;
Result._Mask2 := 1 shl Result.BitCount-1;
Result._BitCount2 := 0;
end else
begin
Result._rshift := GetBitCount2(Mask)-(8-Result.BitCount);
if Result._rshift<0 then
begin
Result._lshift := -Result._rshift;
Result._rshift := 0;
end else
Result._lshift := 0;
Result._Mask2 := (1 shl Result.BitCount-1) shl (8-Result.BitCount);
Result._BitCount2 := 8-Result.BitCount;
end;
end;
 
{ TDXTextureImage }
 
var
_DXTextureImageLoadFuncList: TList;
 
procedure DXTextureImage_LoadDXTextureImageFunc(Stream: TStream; Image: TDXTextureImage); forward;
procedure DXTextureImage_LoadBitmapFunc(Stream: TStream; Image: TDXTextureImage); forward;
 
function DXTextureImageLoadFuncList: TList;
begin
if _DXTextureImageLoadFuncList=nil then
begin
_DXTextureImageLoadFuncList := TList.Create;
_DXTextureImageLoadFuncList.Add(@DXTextureImage_LoadDXTextureImageFunc);
_DXTextureImageLoadFuncList.Add(@DXTextureImage_LoadBitmapFunc);
end;
Result := _DXTextureImageLoadFuncList;
end;
 
class procedure TDXTextureImage.RegisterLoadFunc(LoadFunc: TDXTextureImageLoadFunc);
begin
if DXTextureImageLoadFuncList.IndexOf(@LoadFunc)=-1 then
DXTextureImageLoadFuncList.Add(@LoadFunc);
end;
 
class procedure TDXTextureImage.UnRegisterLoadFunc(LoadFunc: TDXTextureImageLoadFunc);
begin
DXTextureImageLoadFuncList.Remove(@LoadFunc);
end;
 
constructor TDXTextureImage.Create;
begin
inherited Create;
FSubImage := TList.Create;
end;
 
constructor TDXTextureImage.CreateSub(AOwner: TDXTextureImage);
begin
Create;
 
FOwner := AOwner;
try
FOwner.FSubImage.Add(Self);
except
FOwner := nil;
raise;
end;
end;
 
destructor TDXTextureImage.Destroy;
begin
Clear;
FSubImage.Free;
if FOwner<>nil then
FOwner.FSubImage.Remove(Self);
inherited Destroy;
end;
 
procedure TDXTextureImage.Assign(Source: TDXTextureImage);
var
y: Integer;
begin
SetSize(Source.ImageType, Source.Width, Source.Height, Source.BitCount, Source.WidthBytes);
 
idx_index := Source.idx_index;
idx_alpha := Source.idx_alpha;
idx_palette := Source.idx_palette;
 
rgb_red := Source.rgb_red;
rgb_green := Source.rgb_green;
rgb_blue := Source.rgb_blue;
rgb_alpha := Source.rgb_alpha;
 
for y:=0 to Height-1 do
Move(Source.ScanLine[y]^, ScanLine[y]^, WidthBytes);
 
Transparent := Source.Transparent;
TransparentColor := Source.TransparentColor;
ImageGroupType := Source.ImageGroupType;
ImageID := Source.ImageID;
ImageName := Source.ImageName;
end;
 
procedure TDXTextureImage.ClearImage;
begin
if FAutoFreeImage then
FreeMem(FPBits);
 
FImageType := DXTextureImageType_PaletteIndexedColor;
FWidth := 0;
FHeight := 0;
FBitCount := 0;
FWidthBytes := 0;
FNextLine := 0;
FSize := 0;
FPBits := nil;
FTopPBits := nil;
FAutoFreeImage := False;
end;
 
procedure TDXTextureImage.Clear;
begin
ClearImage;
 
while SubImageCount>0 do
SubImages[SubImageCount-1].Free;
 
FImageGroupType := 0;
FImageID := 0;
FImageName := '';
 
FTransparent := False;
FTransparentColor := 0;
 
FillChar(idx_index, SizeOf(idx_index), 0);
FillChar(idx_alpha, SizeOf(idx_alpha), 0);
FillChar(idx_palette, SizeOf(idx_palette), 0);
FillChar(rgb_red, SizeOf(rgb_red), 0);
FillChar(rgb_green, SizeOf(rgb_green), 0);
FillChar(rgb_blue, SizeOf(rgb_blue), 0);
FillChar(rgb_alpha, SizeOf(rgb_alpha), 0);
end;
 
procedure TDXTextureImage.SetImage(ImageType: TDXTextureImageType; Width, Height, BitCount, WidthBytes, NextLine: Integer;
PBits, TopPBits: Pointer; Size: Integer; AutoFree: Boolean);
begin
ClearImage;
 
FAutoFreeImage := AutoFree;
FImageType := ImageType;
FWidth := Width;
FHeight := Height;
FBitCount := BitCount;
FWidthBytes := WidthBytes;
FNextLine := NextLine;
FSize := Size;
FPBits := PBits;
FTopPBits := TopPBits;
end;
 
procedure TDXTextureImage.SetSize(ImageType: TDXTextureImageType; Width, Height, BitCount, WidthBytes: Integer);
var
APBits: Pointer;
begin
ClearImage;
 
if WidthBytes=0 then
WidthBytes := GetWidthBytes(Width, BitCount);
 
GetMem(APBits, WidthBytes*Height);
SetImage(ImageType, Width, Height, BitCount, WidthBytes, WidthBytes, APBits, APBits, WidthBytes*Height, True);
end;
 
function TDXTextureImage.GetScanLine(y: Integer): Pointer;
begin
Result := Pointer(Integer(FTopPBits)+FNextLine*y);
end;
 
function TDXTextureImage.GetSubGroupImageCount(GroupTypeID: DWORD): Integer;
var
i: Integer;
begin
Result := 0;
for i:=0 to SubImageCount-1 do
if SubImages[i].ImageGroupType=GroupTypeID then
Inc(Result);
end;
 
function TDXTextureImage.GetSubGroupImage(GroupTypeID: DWORD; Index: Integer): TDXTextureImage;
var
i, j: Integer;
begin
j := 0;
for i:=0 to SubImageCount-1 do
if SubImages[i].ImageGroupType=GroupTypeID then
begin
if j=Index then
begin
Result := SubImages[i];
Exit;
end;
 
Inc(j);
end;
 
Result := nil;
SubImages[-1];
end;
 
function TDXTextureImage.GetSubImageCount: Integer;
begin
Result := FSubImage.Count;
end;
 
function TDXTextureImage.GetSubImage(Index: Integer): TDXTextureImage;
begin
Result := FSubImage[Index];
end;
 
function TDXTextureImage.EncodeColor(R, G, B, A: Byte): DWORD;
begin
if ImageType=DXTextureImageType_PaletteIndexedColor then
begin
Result := dxtEncodeChannel(idx_index, PaletteIndex(R, G, B)) or
dxtEncodeChannel(idx_alpha, A);
end else
begin
Result := dxtEncodeChannel(rgb_red, R) or
dxtEncodeChannel(rgb_green, G) or
dxtEncodeChannel(rgb_blue, B) or
dxtEncodeChannel(rgb_alpha, A);
end;
end;
 
function TDXTextureImage.PaletteIndex(R, G, B: Byte): DWORD;
var
i, d, d2: Integer;
begin
Result := 0;
if ImageType=DXTextureImageType_PaletteIndexedColor then
begin
d := MaxInt;
for i:=0 to (1 shl idx_index.BitCount)-1 do
with idx_palette[i] do
begin
d2 := Abs((peRed-R))*Abs((peRed-R)) + Abs((peGreen-G))*Abs((peGreen-G)) + Abs((peBlue-B))*Abs((peBlue-B));
if d>d2 then
begin
d := d2;
Result := i;
end;
end;
end;
end;
 
const
Mask1: array[0..7] of DWORD= (1, 2, 4, 8, 16, 32, 64, 128);
Mask2: array[0..3] of DWORD= (3, 12, 48, 192);
Mask4: array[0..1] of DWORD= ($0F, $F0);
 
Shift1: array[0..7] of DWORD= (0, 1, 2, 3, 4, 5, 6, 7);
Shift2: array[0..3] of DWORD= (0, 2, 4, 6);
Shift4: array[0..1] of DWORD= (0, 4);
 
type
PByte3 = ^TByte3;
TByte3 = array[0..2] of Byte;
 
function TDXTextureImage.GetPixel(x, y: Integer): DWORD;
begin
Result := 0;
if (x>=0) and (x<FWidth) and (y>=0) and (y<FHeight) then
begin
case FBitCount of
1 : begin
if FPackedPixelOrder then
Result := (PByte(Integer(FTopPBits)+FNextLine*y+x shr 3)^ and Mask1[7-x and 7]) shr Shift1[7-x and 7]
else
Result := (PByte(Integer(FTopPBits)+FNextLine*y+x shr 3)^ and Mask1[x and 7]) shr Shift1[x and 7];
end;
2 : begin
if FPackedPixelOrder then
Result := (PByte(Integer(FTopPBits)+FNextLine*y+x shr 2)^ and Mask2[3-x and 3]) shr Shift2[3-x and 3]
else
Result := (PByte(Integer(FTopPBits)+FNextLine*y+x shr 2)^ and Mask2[x and 3]) shr Shift2[x and 3];
end;
4 : begin
if FPackedPixelOrder then
Result := (PByte(Integer(FTopPBits)+FNextLine*y+x shr 1)^ and Mask4[1-x and 1]) shr Shift4[1-x and 1]
else
Result := (PByte(Integer(FTopPBits)+FNextLine*y+x shr 1)^ and Mask4[x and 1]) shr Shift4[x and 1];
end;
8 : Result := PByte(Integer(FTopPBits)+FNextLine*y+x)^;
16: Result := PWord(Integer(FTopPBits)+FNextLine*y+x*2)^;
24: PByte3(@Result)^ := PByte3(Integer(FTopPBits)+FNextLine*y+x*3)^;
32: Result := PDWORD(Integer(FTopPBits)+FNextLine*y+x*4)^;
end;
end;
end;
 
procedure TDXTextureImage.SetPixel(x, y: Integer; c: DWORD);
var
P: PByte;
begin
if (x>=0) and (x<FWidth) and (y>=0) and (y<FHeight) then
begin
case FBitCount of
1 : begin
P := Pointer(Integer(FTopPBits)+FNextLine*y+x shr 3);
if FPackedPixelOrder then
P^ := (P^ and (not Mask1[7-x and 7])) or ((c and 1) shl Shift1[7-x and 7])
else
P^ := (P^ and (not Mask1[x and 7])) or ((c and 1) shl Shift1[x and 7]);
end;
2 : begin
P := Pointer(Integer(FTopPBits)+FNextLine*y+x shr 2);
if FPackedPixelOrder then
P^ := (P^ and (not Mask2[3-x and 3])) or ((c and 3) shl Shift2[3-x and 3])
else
P^ := (P^ and (not Mask2[x and 3])) or ((c and 3) shl Shift2[x and 3]);
end;
4 : begin
P := Pointer(Integer(FTopPBits)+FNextLine*y+x shr 1);
if FPackedPixelOrder then
P^ := (P^ and (not Mask4[1-x and 1])) or ((c and 7) shl Shift4[1-x and 1])
else
P^ := (P^ and (not Mask4[x and 1])) or ((c and 7) shl Shift4[x and 1]);
end;
8 : PByte(Integer(FTopPBits)+FNextLine*y+x)^ := c;
16: PWord(Integer(FTopPBits)+FNextLine*y+x*2)^ := c;
24: PByte3(Integer(FTopPBits)+FNextLine*y+x*3)^ := PByte3(@c)^;
32: PDWORD(Integer(FTopPBits)+FNextLine*y+x*4)^ := c;
end;
end;
end;
 
procedure TDXTextureImage.LoadFromFile(const FileName: string);
var
Stream: TFileStream;
begin
Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
 
procedure TDXTextureImage.LoadFromStream(Stream: TStream);
var
i, p: Integer;
begin
Clear;
 
p := Stream.Position;
for i:=0 to DXTextureImageLoadFuncList.Count-1 do
begin
Stream.Position := p;
try
TDXTextureImageLoadFunc(DXTextureImageLoadFuncList[i])(Stream, Self);
Exit;
except
Clear;
end;
end;
 
raise EDXTextureImageError.Create(SNotSupportGraphicFile);
end;
 
procedure TDXTextureImage.SaveToFile(const FileName: string);
var
Stream: TFileStream;
begin
Stream := TFileStream.Create(FileName, fmCreate);
try
SaveToStream(Stream);
finally
Stream.Free;
end;
end;
 
procedure DXTextureImage_SaveDXTextureImageFunc(Stream: TStream; Image: TDXTextureImage); forward;
 
procedure TDXTextureImage.SaveToStream(Stream: TStream);
begin
DXTextureImage_SaveDXTextureImageFunc(Stream, Self);
end;
 
{ DXTextureImage_LoadDXTextureImageFunc }
 
const
DXTextureImageFile_Type = 'dxt:';
DXTextureImageFile_Version = $100;
 
DXTextureImageCompress_None = 0;
 
DXTextureImageFileCategoryType_Image = $100;
 
DXTextureImageFileBlockID_EndFile = 0;
DXTextureImageFileBlockID_EndGroup = 1;
DXTextureImageFileBlockID_StartGroup = 2;
DXTextureImageFileBlockID_Image_Format = DXTextureImageFileCategoryType_Image + 1;
DXTextureImageFileBlockID_Image_PixelData = DXTextureImageFileCategoryType_Image + 2;
DXTextureImageFileBlockID_Image_GroupInfo = DXTextureImageFileCategoryType_Image + 3;
DXTextureImageFileBlockID_Image_Name = DXTextureImageFileCategoryType_Image + 4;
DXTextureImageFileBlockID_Image_TransparentColor = DXTextureImageFileCategoryType_Image + 5;
 
type
TDXTextureImageFileHeader = packed record
FileType: array[0..4] of Char;
ver: DWORD;
end;
 
TDXTextureImageFileBlockHeader = packed record
ID: DWORD;
Size: Integer;
end;
 
TDXTextureImageFileBlockHeader_StartGroup = packed record
CategoryType: DWORD;
end;
 
TDXTextureImageHeader_Image_Format = packed record
ImageType: TDXTextureImageType;
Width: DWORD;
Height: DWORD;
BitCount: DWORD;
WidthBytes: DWORD;
end;
 
TDXTextureImageHeader_Image_Format_Index = packed record
idx_index_Mask: DWORD;
idx_alpha_Mask: DWORD;
idx_palette: array[0..255] of TPaletteEntry;
end;
 
TDXTextureImageHeader_Image_Format_RGB = packed record
rgb_red_Mask: DWORD;
rgb_green_Mask: DWORD;
rgb_blue_Mask: DWORD;
rgb_alpha_Mask: DWORD;
end;
 
TDXTextureImageHeader_Image_GroupInfo = packed record
ImageGroupType: DWORD;
ImageID: DWORD;
end;
 
TDXTextureImageHeader_Image_TransparentColor = packed record
Transparent: Boolean;
TransparentColor: DWORD;
end;
 
procedure DXTextureImage_LoadDXTextureImageFunc(Stream: TStream; Image: TDXTextureImage);
 
procedure ReadGroup_Image(Image: TDXTextureImage);
var
i: Integer;
BlockHeader: TDXTextureImageFileBlockHeader;
NextPos: Integer;
SubImage: TDXTextureImage;
Header_StartGroup: TDXTextureImageFileBlockHeader_StartGroup;
Header_Image_Format: TDXTextureImageHeader_Image_Format;
Header_Image_Format_Index: TDXTextureImageHeader_Image_Format_Index;
Header_Image_Format_RGB: TDXTextureImageHeader_Image_Format_RGB;
Header_Image_GroupInfo: TDXTextureImageHeader_Image_GroupInfo;
Header_Image_TransparentColor: TDXTextureImageHeader_Image_TransparentColor;
ImageName: string;
begin
while True do
begin
Stream.ReadBuffer(BlockHeader, SizeOf(BlockHeader));
NextPos := Stream.Position + BlockHeader.Size;
 
case BlockHeader.ID of
DXTextureImageFileBlockID_EndGroup:
begin
{ End of group }
Break;
end;
DXTextureImageFileBlockID_StartGroup:
begin
{ Beginning of group }
Stream.ReadBuffer(Header_StartGroup, SizeOf(Header_StartGroup));
case Header_StartGroup.CategoryType of
DXTextureImageFileCategoryType_Image:
begin
{ Image group }
SubImage := TDXTextureImage.CreateSub(Image);
try
ReadGroup_Image(SubImage);
except
SubImage.Free;
raise;
end;
end;
end;
end;
DXTextureImageFileBlockID_Image_Format:
begin
{ Image information reading (size etc.) }
Stream.ReadBuffer(Header_Image_Format, SizeOf(Header_Image_Format));
 
if (Header_Image_Format.ImageType<>DXTextureImageType_PaletteIndexedColor) and
(Header_Image_Format.ImageType<>DXTextureImageType_RGBColor) then
raise EDXTextureImageError.Create(SInvalidDXTFile);
 
Image.SetSize(Header_Image_Format.ImageType, Header_Image_Format.Width, Header_Image_Format.Height,
Header_Image_Format.BitCount, Header_Image_Format.Widthbytes);
 
if Header_Image_Format.ImageType=DXTextureImageType_PaletteIndexedColor then
begin
{ INDEX IMAGE }
Stream.ReadBuffer(Header_Image_Format_Index, SizeOf(Header_Image_Format_Index));
 
Image.idx_index := dxtMakeChannel(Header_Image_Format_Index.idx_index_Mask, True);
Image.idx_alpha := dxtMakeChannel(Header_Image_Format_Index.idx_alpha_Mask, False);
 
for i:=0 to 255 do
Image.idx_palette[i] := Header_Image_Format_Index.idx_palette[i];
end else if Header_Image_Format.ImageType=DXTextureImageType_RGBColor then
begin
{ RGB IMAGE }
Stream.ReadBuffer(Header_Image_Format_RGB, SizeOf(Header_Image_Format_RGB));
 
Image.rgb_red := dxtMakeChannel(Header_Image_Format_RGB.rgb_red_Mask, False);
Image.rgb_green := dxtMakeChannel(Header_Image_Format_RGB.rgb_green_Mask, False);
Image.rgb_blue := dxtMakeChannel(Header_Image_Format_RGB.rgb_blue_Mask, False);
Image.rgb_alpha := dxtMakeChannel(Header_Image_Format_RGB.rgb_alpha_Mask, False);
end;
end;
DXTextureImageFileBlockID_Image_Name:
begin
{ Name reading }
SetLength(ImageName, BlockHeader.Size);
Stream.ReadBuffer(ImageName[1], BlockHeader.Size);
 
Image.ImageName := ImageName;
end;
DXTextureImageFileBlockID_Image_GroupInfo:
begin
{ Image group information reading }
Stream.ReadBuffer(Header_Image_GroupInfo, SizeOf(Header_Image_GroupInfo));
 
Image.ImageGroupType := Header_Image_GroupInfo.ImageGroupType;
Image.ImageID := Header_Image_GroupInfo.ImageID;
end;
DXTextureImageFileBlockID_Image_TransparentColor:
begin
{ Transparent color information reading }
Stream.ReadBuffer(Header_Image_TransparentColor, SizeOf(Header_Image_TransparentColor));
 
Image.Transparent := Header_Image_TransparentColor.Transparent;
Image.TransparentColor := Header_Image_TransparentColor.TransparentColor;
end;
DXTextureImageFileBlockID_Image_PixelData:
begin
{ Pixel data reading }
for i:=0 to Image.Height-1 do
Stream.ReadBuffer(Image.ScanLine[i]^, Header_Image_Format.Widthbytes);
end;
end;
 
Stream.Seek(NextPos, soFromBeginning);
end;
end;
 
var
FileHeader: TDXTextureImageFileHeader;
BlockHeader: TDXTextureImageFileBlockHeader;
Header_StartGroup: TDXTextureImageFileBlockHeader_StartGroup;
NextPos: Integer;
begin
{ File header reading }
Stream.ReadBuffer(FileHeader, SizeOf(FileHeader));
 
if FileHeader.FileType<>DXTextureImageFile_Type then
raise EDXTextureImageError.Create(SInvalidDXTFile);
if FileHeader.ver<>DXTextureImageFile_Version then
raise EDXTextureImageError.Create(SInvalidDXTFile);
 
while True do
begin
Stream.ReadBuffer(BlockHeader, SizeOf(BlockHeader));
NextPos := Stream.Position + BlockHeader.Size;
 
case BlockHeader.ID of
DXTextureImageFileBlockID_EndFile:
begin
{ End of file }
Break;
end;
DXTextureImageFileBlockID_StartGroup:
begin
{ Beginning of group }
Stream.ReadBuffer(Header_StartGroup, SizeOf(Header_StartGroup));
case Header_StartGroup.CategoryType of
DXTextureImageFileCategoryType_Image: ReadGroup_Image(Image);
end;
end;
end;
Stream.Seek(NextPos, soFromBeginning);
end;
end;
 
type
PDXTextureImageFileBlockHeaderWriter_BlockInfo = ^TDXTextureImageFileBlockHeaderWriter_BlockInfo;
TDXTextureImageFileBlockHeaderWriter_BlockInfo = record
BlockID: DWORD;
StreamPos: Integer;
end;
 
TDXTextureImageFileBlockHeaderWriter = class
private
FStream: TStream;
FList: TList;
public
constructor Create(Stream: TStream);
destructor Destroy; override;
procedure StartBlock(BlockID: DWORD);
procedure EndBlock;
procedure WriteBlock(BlockID: DWORD);
procedure StartGroup(CategoryType: DWORD);
procedure EndGroup;
end;
 
constructor TDXTextureImageFileBlockHeaderWriter.Create(Stream: TStream);
begin
inherited Create;
FStream := Stream;
FList := TList.Create;
end;
 
destructor TDXTextureImageFileBlockHeaderWriter.Destroy;
var
i: Integer;
begin
for i:=0 to FList.Count-1 do
Dispose(PDXTextureImageFileBlockHeaderWriter_BlockInfo(FList[i]));
FList.Free;
inherited Destroy;
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.StartBlock(BlockID: DWORD);
var
BlockInfo: PDXTextureImageFileBlockHeaderWriter_BlockInfo;
BlockHeader: TDXTextureImageFileBlockHeader;
begin
New(BlockInfo);
BlockInfo.BlockID := BlockID;
BlockInfo.StreamPos := FStream.Position;
FList.Add(BlockInfo);
 
BlockHeader.ID := BlockID;
BlockHeader.Size := 0;
FStream.WriteBuffer(BlockHeader, SizeOf(BlockHeader));
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.EndBlock;
var
BlockHeader: TDXTextureImageFileBlockHeader;
BlockInfo: PDXTextureImageFileBlockHeaderWriter_BlockInfo;
CurStreamPos: Integer;
begin
CurStreamPos := FStream.Position;
try
BlockInfo := FList[FList.Count-1];
 
FStream.Position := BlockInfo.StreamPos;
BlockHeader.ID := BlockInfo.BlockID;
BlockHeader.Size := CurStreamPos-(BlockInfo.StreamPos+SizeOf(TDXTextureImageFileBlockHeader));
FStream.WriteBuffer(BlockHeader, SizeOf(BlockHeader));
finally
FStream.Position := CurStreamPos;
 
Dispose(FList[FList.Count-1]);
FList.Count := FList.Count-1;
end;
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.WriteBlock(BlockID: DWORD);
var
BlockHeader: TDXTextureImageFileBlockHeader;
begin
BlockHeader.ID := BlockID;
BlockHeader.Size := 0;
FStream.WriteBuffer(BlockHeader, SizeOf(BlockHeader));
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.StartGroup(CategoryType: DWORD);
var
Header_StartGroup: TDXTextureImageFileBlockHeader_StartGroup;
begin
StartBlock(DXTextureImageFileBlockID_StartGroup);
 
Header_StartGroup.CategoryType := CategoryType;
FStream.WriteBuffer(Header_StartGroup, SizeOf(Header_StartGroup));
end;
 
procedure TDXTextureImageFileBlockHeaderWriter.EndGroup;
begin
WriteBlock(DXTextureImageFileBlockID_EndGroup);
EndBlock;
end;
 
procedure DXTextureImage_SaveDXTextureImageFunc(Stream: TStream; Image: TDXTextureImage);
var
BlockHeaderWriter: TDXTextureImageFileBlockHeaderWriter;
 
function CalcProgressCount(Image: TDXTextureImage): Integer;
var
i: Integer;
begin
Result := Image.WidthBytes*Image.Height;
for i:=0 to Image.SubImageCount-1 do
Inc(Result, CalcProgressCount(Image.SubImages[i]));
end;
 
procedure WriteGroup_Image(Image: TDXTextureImage);
var
i: Integer;
Header_Image_Format: TDXTextureImageHeader_Image_Format;
Header_Image_Format_Index: TDXTextureImageHeader_Image_Format_Index;
Header_Image_Format_RGB: TDXTextureImageHeader_Image_Format_RGB;
Header_Image_GroupInfo: TDXTextureImageHeader_Image_GroupInfo;
Header_Image_TransparentColor: TDXTextureImageHeader_Image_TransparentColor;
begin
BlockHeaderWriter.StartGroup(DXTextureImageFileCategoryType_Image);
try
{ Image format writing }
if Image.Size>0 then
begin
Header_Image_Format.ImageType := Image.ImageType;
Header_Image_Format.Width := Image.Width;
Header_Image_Format.Height := Image.Height;
Header_Image_Format.BitCount := Image.BitCount;
Header_Image_Format.WidthBytes := Image.WidthBytes;
 
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_Format);
try
Stream.WriteBuffer(Header_Image_Format, SizeOf(Header_Image_Format));
 
case Image.ImageType of
DXTextureImageType_PaletteIndexedColor:
begin
{ INDEX IMAGE }
Header_Image_Format_Index.idx_index_Mask := Image.idx_index.Mask;
Header_Image_Format_Index.idx_alpha_Mask := Image.idx_alpha.Mask;
for i:=0 to 255 do
Header_Image_Format_Index.idx_palette[i] := Image.idx_palette[i];
 
Stream.WriteBuffer(Header_Image_Format_Index, SizeOf(Header_Image_Format_Index));
end;
DXTextureImageType_RGBColor:
begin
{ RGB IMAGE }
Header_Image_Format_RGB.rgb_red_Mask := Image.rgb_red.Mask;
Header_Image_Format_RGB.rgb_green_Mask := Image.rgb_green.Mask;
Header_Image_Format_RGB.rgb_blue_Mask := Image.rgb_blue.Mask;
Header_Image_Format_RGB.rgb_alpha_Mask := Image.rgb_alpha.Mask;
 
Stream.WriteBuffer(Header_Image_Format_RGB, SizeOf(Header_Image_Format_RGB));
end;
end;
finally
BlockHeaderWriter.EndBlock;
end;
end;
 
{ Image group information writing }
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_GroupInfo);
try
Header_Image_GroupInfo.ImageGroupType := Image.ImageGroupType;
Header_Image_GroupInfo.ImageID := Image.ImageID;
 
Stream.WriteBuffer(Header_Image_GroupInfo, SizeOf(Header_Image_GroupInfo));
finally
BlockHeaderWriter.EndBlock;
end;
 
{ Name writing }
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_Name);
try
Stream.WriteBuffer(Image.ImageName[1], Length(Image.ImageName));
finally
BlockHeaderWriter.EndBlock;
end;
 
{ Transparent color writing }
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_TransparentColor);
try
Header_Image_TransparentColor.Transparent := Image.Transparent;
Header_Image_TransparentColor.TransparentColor := Image.TransparentColor;
 
Stream.WriteBuffer(Header_Image_TransparentColor, SizeOf(Header_Image_TransparentColor));
finally
BlockHeaderWriter.EndBlock;
end;
 
{ Pixel data writing }
if Image.Size>0 then
begin
BlockHeaderWriter.StartBlock(DXTextureImageFileBlockID_Image_PixelData);
try
for i:=0 to Image.Height-1 do
Stream.WriteBuffer(Image.ScanLine[i]^, Image.Widthbytes);
finally
BlockHeaderWriter.EndBlock;
end;
end;
 
{ Sub-image writing }
for i:=0 to Image.SubImageCount-1 do
WriteGroup_Image(Image.SubImages[i]);
finally
BlockHeaderWriter.EndGroup;
end;
end;
 
var
FileHeader: TDXTextureImageFileHeader;
begin
{ File header writing }
FileHeader.FileType := DXTextureImageFile_Type;
FileHeader.ver := DXTextureImageFile_Version;
Stream.WriteBuffer(FileHeader, SizeOf(FileHeader));
 
{ Image writing }
BlockHeaderWriter := TDXTextureImageFileBlockHeaderWriter.Create(Stream);
try
{ Image writing }
WriteGroup_Image(Image);
 
{ End of file }
BlockHeaderWriter.WriteBlock(DXTextureImageFileBlockID_EndFile);
finally
BlockHeaderWriter.Free;
end;
end;
 
{ DXTextureImage_LoadBitmapFunc }
 
procedure DXTextureImage_LoadBitmapFunc(Stream: TStream; Image: TDXTextureImage);
type
TDIBPixelFormat = packed record
RBitMask, GBitMask, BBitMask: DWORD;
end;
var
TopDown: Boolean;
BF: TBitmapFileHeader;
BI: TBitmapInfoHeader;
 
procedure DecodeRGB;
var
y: Integer;
begin
for y:=0 to Image.Height-1 do
begin
if TopDown then
Stream.ReadBuffer(Image.ScanLine[y]^, Image.WidthBytes)
else
Stream.ReadBuffer(Image.ScanLine[Image.Height-y-1]^, Image.WidthBytes);
end;
end;
 
procedure DecodeRLE4;
var
SrcDataP: Pointer;
B1, B2, C: Byte;
Dest, Src, P: PByte;
X, Y, i: Integer;
begin
GetMem(SrcDataP, BI.biSizeImage);
try
Stream.ReadBuffer(SrcDataP^, BI.biSizeImage);
 
Dest := Image.TopPBits;
Src := SrcDataP;
X := 0;
Y := 0;
 
while True do
begin
B1 := Src^; Inc(Src);
B2 := Src^; Inc(Src);
 
if B1=0 then
begin
case B2 of
0: begin { End of line }
X := 0; Inc(Y);
Dest := Image.ScanLine[Y];
end;
1: Break; { End of bitmap }
2: begin { Difference of coordinates }
Inc(X, B1); Inc(Y, B2); Inc(Src, 2);
Dest := Image.ScanLine[Y];
end;
else
{ Absolute mode }
C := 0;
for i:=0 to B2-1 do
begin
if i and 1=0 then
begin
C := Src^; Inc(Src);
end else
begin
C := C shl 4;
end;
 
P := Pointer(Integer(Dest)+X shr 1);
if X and 1=0 then
P^ := (P^ and $0F) or (C and $F0)
else
P^ := (P^ and $F0) or ((C and $F0) shr 4);
 
Inc(X);
end;
end;
end else
begin
{ Encoding mode }
for i:=0 to B1-1 do
begin
P := Pointer(Integer(Dest)+X shr 1);
if X and 1=0 then
P^ := (P^ and $0F) or (B2 and $F0)
else
P^ := (P^ and $F0) or ((B2 and $F0) shr 4);
 
Inc(X);
 
// Swap nibble
B2 := (B2 shr 4) or (B2 shl 4);
end;
end;
 
{ Word arrangement }
Inc(Src, Longint(Src) and 1);
end;
finally
FreeMem(SrcDataP);
end;
end;
 
procedure DecodeRLE8;
var
SrcDataP: Pointer;
B1, B2: Byte;
Dest, Src: PByte;
X, Y: Integer;
begin
GetMem(SrcDataP, BI.biSizeImage);
try
Stream.ReadBuffer(SrcDataP^, BI.biSizeImage);
 
Dest := Image.TopPBits;
Src := SrcDataP;
X := 0;
Y := 0;
 
while True do
begin
B1 := Src^; Inc(Src);
B2 := Src^; Inc(Src);
 
if B1=0 then
begin
case B2 of
0: begin { End of line }
X := 0; Inc(Y);
Dest := Pointer(Longint(Image.TopPBits)+Y*Image.NextLine+X);
end;
1: Break; { End of bitmap }
2: begin { Difference of coordinates }
Inc(X, B1); Inc(Y, B2); Inc(Src, 2);
Dest := Pointer(Longint(Image.TopPBits)+Y*Image.NextLine+X);
end;
else
{ Absolute mode }
Move(Src^, Dest^, B2); Inc(Dest, B2); Inc(Src, B2);
end;
end else
begin
{ Encoding mode }
FillChar(Dest^, B1, B2); Inc(Dest, B1);
end;
 
{ Word arrangement }
Inc(Src, Longint(Src) and 1);
end;
finally
FreeMem(SrcDataP);
end;
end;
 
var
BC: TBitmapCoreHeader;
RGBTriples: array[0..255] of TRGBTriple;
RGBQuads: array[0..255] of TRGBQuad;
i, PalCount, j: Integer;
OS2: Boolean;
PixelFormat: TDIBPixelFormat;
begin
{ File header reading }
i := Stream.Read(BF, SizeOf(TBitmapFileHeader));
if i=0 then Exit;
if i<>SizeOf(TBitmapFileHeader) then
raise EDXTextureImageError.Create(SInvalidDIB);
 
{ Is the head 'BM'? }
if BF.bfType<>Ord('B') + Ord('M')*$100 then
raise EDXTextureImageError.Create(SInvalidDIB);
 
{ Reading of size of header }
i := Stream.Read(BI.biSize, 4);
if i<>4 then
raise EDXTextureImageError.Create(SInvalidDIB);
 
{ Kind check of DIB }
OS2 := False;
 
case BI.biSize of
SizeOf(TBitmapCoreHeader):
begin
{ OS/2 type }
Stream.ReadBuffer(Pointer(Integer(@BC)+4)^, SizeOf(TBitmapCoreHeader)-4);
 
FilLChar(BI, SizeOf(BI), 0);
with BI do
begin
biClrUsed := 0;
biCompression := BI_RGB;
biBitCount := BC.bcBitCount;
biHeight := BC.bcHeight;
biWidth := BC.bcWidth;
end;
 
OS2 := True;
end;
SizeOf(TBitmapInfoHeader):
begin
{ Windows type }
Stream.ReadBuffer(Pointer(Integer(@BI)+4)^, SizeOf(TBitmapInfoHeader)-4);
end;
else
raise EDXTextureImageError.Create(SInvalidDIB);
end;
 
{ Bit mask reading }
if BI.biCompression = BI_BITFIELDS then
begin
Stream.ReadBuffer(PixelFormat, SizeOf(PixelFormat));
end else
begin
if BI.biBitCount=16 then
begin
PixelFormat.RBitMask := $7C00;
PixelFormat.GBitMask := $03E0;
PixelFormat.BBitMask := $001F;
end else if (BI.biBitCount=24) or (BI.biBitCount=32) then
begin
PixelFormat.RBitMask := $00FF0000;
PixelFormat.GBitMask := $0300FF00;
PixelFormat.BBitMask := $000000FF;
end;
end;
 
{ DIB making }
if BI.biHeight<0 then
begin
BI.biHeight := -BI.biHeight;
TopDown := True;
end else
TopDown := False;
 
if BI.biBitCount in [1, 4, 8] then
begin
Image.SetSize(DXTextureImageType_PaletteIndexedColor, BI.biWidth, BI.biHeight, BI.biBitCount,
(((BI.biWidth*BI.biBitCount)+31) div 32)*4);
 
Image.idx_index := dxtMakeChannel(1 shl BI.biBitCount-1, True);
Image.PackedPixelOrder := True;
end else
begin
Image.SetSize(DXTextureImageType_RGBColor, BI.biWidth, BI.biHeight, BI.biBitCount,
(((BI.biWidth*BI.biBitCount)+31) div 32)*4);
 
Image.rgb_red := dxtMakeChannel(PixelFormat.RBitMask, False);
Image.rgb_green := dxtMakeChannel(PixelFormat.GBitMask, False);
Image.rgb_blue := dxtMakeChannel(PixelFormat.BBitMask, False);
 
j := Image.rgb_red.BitCount+Image.rgb_green.BitCount+Image.rgb_blue.BitCount;
if j<BI.biBitCount then
Image.rgb_alpha := dxtMakeChannel((1 shl (BI.biBitCount-j)-1) shl j, False);
 
Image.PackedPixelOrder := False;
end;
 
{ palette reading }
PalCount := BI.biClrUsed;
if (PalCount=0) and (BI.biBitCount<=8) then
PalCount := 1 shl BI.biBitCount;
if PalCount>256 then PalCount := 256;
 
if OS2 then
begin
{ OS/2 type }
Stream.ReadBuffer(RGBTriples, SizeOf(TRGBTriple)*PalCount);
for i:=0 to PalCount-1 do
begin
Image.idx_palette[i].peRed := RGBTriples[i].rgbtRed;
Image.idx_palette[i].peGreen := RGBTriples[i].rgbtGreen;
Image.idx_palette[i].peBlue := RGBTriples[i].rgbtBlue;
end;
end else
begin
{ Windows type }
Stream.ReadBuffer(RGBQuads, SizeOf(TRGBQuad)*PalCount);
for i:=0 to PalCount-1 do
begin
Image.idx_palette[i].peRed := RGBQuads[i].rgbRed;
Image.idx_palette[i].peGreen := RGBQuads[i].rgbGreen;
Image.idx_palette[i].peBlue := RGBQuads[i].rgbBlue;
end;
end;
 
{ Pixel data reading }
case BI.biCompression of
BI_RGB : DecodeRGB;
BI_BITFIELDS: DecodeRGB;
BI_RLE4 : DecodeRLE4;
BI_RLE8 : DecodeRLE8;
else
raise EDXTextureImageError.Create(SInvalidDIB);
end;
end;
 
initialization
finalization
_DXTextureImageLoadFuncList.Free;
end.
/VCL_DELPHIX_D6/DXPictEdit.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXPlay.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXInput.pas
6,20 → 6,7
 
uses
Windows, Messages, SysUtils, Classes, Controls, Forms, MMSystem,
DXClass, {$IFDEF VER17UP} Types, {$ENDIF}
{$IfDef StandardDX}
{$IfDef DX9}
DirectInput;
{$Else}
{$IfDef DX81}
DirectInput8;
{$Else}
DirectInput;
{$EndIf}
{$EndIf}
{$Else}
DirectX;
{$EndIf}
DirectX, DXClass;
 
type
 
778,7 → 765,7
FFindEffectGUID := pdei.guid;
end;
 
Result := Integer(DIENUM_STOP);
Result := DIENUM_STOP;
end;
 
procedure CreateIEffectGuid(const GUID: TGUID;
787,7 → 774,7
if EffectObject.Feff.dwSize=0 then Exit;
 
if FRoot.FInput.FDevice2<>nil then
FRoot.FInput.FDevice2.CreateEffect(GUID, @EffectObject.Feff, EffectObject.FEffect, nil);
FRoot.FInput.FDevice2.CreateEffect(GUID, EffectObject.Feff, EffectObject.FEffect, nil);
end;
 
procedure CreateIEffect(dwFlags: DWORD;
1418,11 → 1405,11
 
if FDevice<>nil then
begin
hr := FDevice.GetDeviceState(dwSize, @Data);
hr := FDevice.GetDeviceState(dwSize, Data);
if (hr=DIERR_INPUTLOST) or (hr=DIERR_NOTACQUIRED) then
begin
FDevice.Acquire;
hr := FDevice.GetDeviceState(dwSize, @Data);
hr := FDevice.GetDeviceState(dwSize, Data);
end;
Result := hr=DI_OK;
end else
1434,7 → 1421,7
function DIEnumDeviceObjectsProc(const peff: TDIDeviceObjectInstanceA;
pvRef: Pointer): HRESULT; stdcall;
begin
Result := Integer(DIENUM_CONTINUE);
Result := DIENUM_CONTINUE;
 
if CompareMem(@peff.guidType, @GUID_Unknown, SizeOf(TGUID)) then Exit;
 
1659,10 → 1646,7
DIK_APPS : Result := VK_APPS;
end;
end;
{$IFDEF StandardDX}
type
TDIKeyboardState = array[0..255] of Byte;
{$ENDIF}
 
var
j: Integer;
i: TDXInputState;
1864,7 → 1848,7
function TJoystick_EnumJoysticksCallback(const lpddi: TDIDeviceInstanceA;
pvRef: Pointer): HRESULT; stdcall;
begin
Result := Integer(DIENUM_CONTINUE);
Result := DIENUM_CONTINUE;
 
with TJoystick(pvRef) do
begin
1872,7 → 1856,7
begin
FDeviceGUID := lpddi.guidInstance;
FEnumFlag := True;
Result := Integer(DIENUM_STOP);
Result := DIENUM_STOP;
Exit;
end;
Inc(FEnumIndex);
1896,7 → 1880,7
FEnumFlag := False;
FEnumIndex := 0;
 
FDXInput.FDInput.EnumDevices({DIDEVTYPE_JOYSTICK}4, @TJoystick_EnumJoysticksCallback,
FDXInput.FDInput.EnumDevices(DIDEVTYPE_JOYSTICK, @TJoystick_EnumJoysticksCallback,
Self, DIEDFL_ATTACHEDONLY);
 
if not FEnumFlag then Exit;
1912,7 → 1896,7
FForceFeedbackDevice := True;
end;
 
//if FDXInput.FDInput.CreateDevice(GUID_Joystick, FDevice, nil)<>DI_OK then Exit; get out by Paul van Dinther
if FDXInput.FDInput.CreateDevice(GUID_Joystick, FDevice, nil)<>DI_OK then Exit;
 
{ Device data format (TDIDataFormat) making. }
 
2138,12 → 2122,12
procedure InitDirectInput(out DI: IDirectInput);
type
TDirectInputCreate = function(hinst: THandle; dwVersion: DWORD;
out ppDI: {$IFDEF UNICODE}IDirectInputW{$ELSE}IDirectInputA{$ENDIF}; punkOuter: IUnknown): HRESULT; stdcall;
out ppDI: IDirectInputA; punkOuter: IUnknown): HRESULT; stdcall;
begin
if FDirectInput=nil then
begin
try
TDirectInputCreate(DXLoadLibrary('DInput.dll', {$IFDEF UNICODE}'DirectInputCreateW'{$ELSE}'DirectInputCreateA'{$ENDIF}))
TDirectInputCreate(DXLoadLibrary('DInput.dll', 'DirectInputCreateA'))
(HInstance, DIRECTINPUT_VERSION, FDirectInput, nil);
except
FDirectInput := nil;
/VCL_DELPHIX_D6/DXWaveEdit.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXReg_original.pas
0,0 → 1,685
unit DXReg_original;
 
interface
 
uses
Windows, SysUtils, Classes, DsgnIntf, Forms, Dialogs, Graphics, TypInfo,
DXDraws, DXSounds, DIB, Wave, DXInput, DXPlay, DXSprite, DXClass;
 
type
 
{ TDXDrawDisplayProperty }
 
TDXDrawDisplayProperty = class(TClassProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
end;
 
{ TDIBProperty }
 
TDIBProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TDXDIBEditor }
 
TDXDIBEditor = class(TComponentEditor)
public
procedure Edit; override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TPictureCollectionItem_PictureProperty }
 
TPictureCollectionItem_PictureProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TDXImageListEditor }
 
TDXImageListEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TWaveProperty }
 
TWaveProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TDXWaveEditor }
 
TDXWaveEditor = class(TComponentEditor)
public
procedure Edit; override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TDXWaveListEditor }
 
TDXWaveListEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TForceFeedbackEffectsProperty }
 
TForceFeedbackEffectsProperty = class(TClassProperty)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TDXInputEditor }
 
TDXInputEditor = class(TComponentEditor)
public
procedure Edit; override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TGUIDProperty }
 
TGUIDProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
procedure Register;
 
implementation
 
uses DXPictEdit, DXWaveEdit, DXFFBEdit, DXInptEdit, DXGUIDEdit;
 
const
SNone = '(None)';
 
SSettingImage = '&Image...';
SSettingWave = '&Wave...';
SDXGFileFilter = 'DXG file(*.dxg)|*.dxg|All files(*.*)|*.*';
SDXGOpenFileFilter = 'DXG file(*.dxg)|*.dxg|Bitmap file(*.bmp)|*.bmp|All files(*.*)|*.*';
SDXWFileFilter = 'DXW file(*.dxw)|*.dxg|All files(*.*)|*.*';
SDXWOpenFileFilter = 'DXW file(*.dxw)|*.dxw|Wave file(*.wav)|*.wav|All files(*.*)|*.*';
SSinglePlayer = '&Single player';
SMultiPlayer1 = 'Multi player &1';
SMultiPlayer2 = 'Multi player &2';
 
SOpen = '&Open...';
SSave = '&Save..';
 
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(TDXDrawDisplay), nil, '',
TDXDrawDisplayProperty);
 
RegisterPropertyEditor(TypeInfo(TDIB), nil, '', TDIBProperty);
RegisterComponentEditor(TCustomDXDIB, TDXDIBEditor);
 
RegisterPropertyEditor(TypeInfo(TPicture), TPictureCollectionItem, 'Picture', TPictureCollectionItem_PictureProperty);
RegisterComponentEditor(TCustomDXImageList, TDXImageListEditor);
 
RegisterPropertyEditor(TypeInfo(TWave), nil, '', TWaveProperty);
RegisterComponentEditor(TCustomDXWave, TDXWaveEditor);
 
RegisterComponentEditor(TCustomDXWaveList, TDXWaveListEditor);
 
RegisterPropertyEditor(TypeInfo(TForceFeedbackEffects), nil, '', TForceFeedbackEffectsProperty);
 
RegisterComponentEditor(TCustomDXInput, TDXInputEditor);
 
RegisterPropertyEditor(TypeInfo(string), TCustomDXPlay, 'GUID', TGUIDProperty);
 
RegisterComponents('DelphiX',
[TDXDraw,
TDXDIB,
TDXImageList,
TDX3D,
TDXSound,
TDXWave,
TDXWaveList,
TDXInput,
TDXPlay,
TDXSpriteEngine,
TDXTimer,
TDXPaintBox]);
end;
 
{ TDXDrawDisplayProperty }
 
function TDXDrawDisplayProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paValueList] - [paReadOnly];
end;
 
const
SDisplayMode = '%dx%dx%d';
 
function TDXDrawDisplayProperty.GetValue: string;
begin
with TDXDrawDisplay(GetOrdValue) do
Result := Format(SDisplayMode, [Width, Height, BitCount]);
end;
 
procedure TDXDrawDisplayProperty.GetValues(Proc: TGetStrProc);
const
List: array[0..2] of TPoint = (
(X: 640; Y: 480),
(X: 800; Y: 600),
(X: 1024; Y: 768));
var
BitCount, i: Integer;
begin
for i:=Low(List) to High(List) do
for BitCount:=1 to 3 do
Proc(Format(SDisplayMode, [List[i].x, List[i].y, BitCount*8]));
end;
 
procedure TDXDrawDisplayProperty.SetValue(const Value: string);
var
s: string;
i, AWidth, AHeight, ABitCount: Integer;
begin
s := Value;
 
i := Pos('x', s);
AWidth := StrToInt(Copy(s, 1, i-1));
s := Copy(s, i+1, Length(s));
 
i := Pos('x', s);
AHeight := StrToInt(Copy(s, 1, i-1));
s := Copy(s, i+1, Length(s));
 
ABitCount := StrToInt(s);
 
with TDXDrawDisplay(GetOrdValue) do
begin
Width := AWidth;
Height := AHeight;
BitCount := ABitCount;
end;
 
SetOrdValue(GetOrdValue);
end;
 
{ TDIBProperty }
 
procedure TDIBProperty.Edit;
var
Form: TDelphiXPictureEditForm;
begin
Form := TDelphiXPictureEditForm.Create(nil);
try
Form.ViewBox.Picture.Assign(TDIB(GetOrdValue));
Form.DIBClassOnly := True;
Form.ShowModal;
if Form.Tag<>0 then
begin
SetOrdValue(Integer(Form.ViewBox.Picture.Graphic));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TDIBProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
 
function TDIBProperty.GetValue: string;
begin
if TDIB(GetOrdValue).Size=0 then
Result := SNone
else
Result := Format('(%s)', [TObject(GetOrdValue).ClassName]);
end;
 
{ TDXDIBEditor }
 
procedure TDXDIBEditor.Edit;
var
Form: TDelphiXPictureEditForm;
begin
Form := TDelphiXPictureEditForm.Create(nil);
try
Form.ViewBox.Picture.Assign(TCustomDXDIB(Component).DIB);
Form.DIBClassOnly := True;
Form.ShowModal;
if Form.Tag<>0 then
begin
TCustomDXDIB(Component).DIB.Assign(TGraphic(Form.ViewBox.Picture.Graphic));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
procedure TDXDIBEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: Edit;
end;
end;
 
function TDXDIBEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SSettingImage;
end;
end;
 
function TDXDIBEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
 
{ TPictureCollectionItem_PictureProperty }
 
procedure TPictureCollectionItem_PictureProperty.Edit;
var
Form: TDelphiXPictureEditForm;
Item: TPictureCollectionItem;
TempDIB: TDIB;
begin
Form := TDelphiXPictureEditForm.Create(nil);
try
Form.ViewBox.Picture := TPicture(GetOrdValue);
Form.ShowModal;
if Form.Tag<>0 then
begin
SetOrdValue(Integer(Form.ViewBox.Picture));
 
Item := GetComponent(0) as TPictureCollectionItem;
if Item.Picture.Graphic<>nil then
begin
TempDIB := TDIB.Create;
try
TempDIB.SetSize(1, 1, 24);
TempDIB.Canvas.Draw(0, 0, Item.Picture.Graphic);
Item.TransparentColor := TempDIB.Pixels[0, 0];
finally
TempDIB.Free;
end;
end;
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TPictureCollectionItem_PictureProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
 
function TPictureCollectionItem_PictureProperty.GetValue: string;
begin
if (TPicture(GetOrdValue).Graphic=nil) or (TPicture(GetOrdValue).Graphic.Empty) then
Result := SNone
else
Result := Format('(%s)', [TPicture(GetOrdValue).Graphic.ClassName]);
end;
 
{ TDXImageListEditor }
 
procedure TDXImageListEditor.ExecuteVerb(Index: Integer);
var
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
i: Integer;
begin
case Index of
0: begin
OpenDialog := TOpenDialog.Create(nil);
try
OpenDialog.DefaultExt := 'dxg';
OpenDialog.Filter := SDXGOpenFileFilter;
OpenDialog.Options := [ofPathMustExist, ofFileMustExist, ofAllowMultiSelect];
if OpenDialog.Execute then
begin
if OpenDialog.FilterIndex=2 then
begin
for i:=0 to OpenDialog.Files.Count-1 do
with TPictureCollectionItem.Create(TCustomDXImageList(Component).Items) do
begin
try
Picture.LoadFromFile(OpenDialog.Files[i]);
Name := ExtractFileName(OpenDialog.Files[i]);
except
Free;
raise;
end;
end;
end else
TCustomDXImageList(Component).Items.LoadFromFile(OpenDialog.FileName);
Designer.Modified;
end;
finally
OpenDialog.Free;
end;
end;
1: begin
SaveDialog := TSaveDialog.Create(nil);
try
SaveDialog.DefaultExt := 'dxg';
SaveDialog.Filter := SDXGFileFilter;
SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist];
if SaveDialog.Execute then
TCustomDXImageList(Component).Items.SaveToFile(SaveDialog.FileName);
finally
SaveDialog.Free;
end;
end;
end;
end;
 
function TDXImageListEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SOpen;
1: Result := SSave;
end;
end;
 
function TDXImageListEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
 
{ TWaveProperty }
 
procedure TWaveProperty.Edit;
var
Form: TDelphiXWaveEditForm;
begin
Form := TDelphiXWaveEditForm.Create(nil);
try
Form.Wave := TWave(GetOrdValue);
Form.ShowModal;
if Form.Tag<>0 then
begin
SetOrdValue(Integer(Form.Wave));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TWaveProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
 
function TWaveProperty.GetValue: string;
begin
if TWave(GetOrdValue).Size=0 then
Result := SNone
else
Result := Format('(%s)', [TObject(GetOrdValue).ClassName]);
end;
 
{ TDXWaveEditor }
 
procedure TDXWaveEditor.Edit;
var
Form: TDelphiXWaveEditForm;
begin
Form := TDelphiXWaveEditForm.Create(nil);
try
Form.Wave := TCustomDXWave(Component).Wave;
Form.ShowModal;
if Form.Tag<>0 then
begin
TCustomDXWave(Component).Wave := Form.Wave;
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
procedure TDXWaveEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: Edit;
end;
end;
 
function TDXWaveEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SSettingWave;
end;
end;
 
function TDXWaveEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
 
{ TDXWaveListEditor }
 
procedure TDXWaveListEditor.ExecuteVerb(Index: Integer);
var
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
i: Integer;
begin
case Index of
0: begin
OpenDialog := TOpenDialog.Create(nil);
try
OpenDialog.DefaultExt := 'dxw';
OpenDialog.Filter := SDXWOpenFileFilter;
OpenDialog.Options := [ofPathMustExist, ofFileMustExist, ofAllowMultiSelect];
if OpenDialog.Execute then
begin
if OpenDialog.FilterIndex=2 then
begin
for i:=0 to OpenDialog.Files.Count-1 do
with TWaveCollectionItem.Create(TCustomDXWaveList(Component).Items) do
begin
try
Wave.LoadFromFile(OpenDialog.Files[i]);
Name := ExtractFileName(OpenDialog.Files[i]);
except
Free;
raise;
end;
end;
end else
TCustomDXWaveList(Component).Items.LoadFromFile(OpenDialog.FileName);
Designer.Modified;
end;
finally
OpenDialog.Free;
end;
end;
1: begin
SaveDialog := TSaveDialog.Create(nil);
try
SaveDialog.DefaultExt := 'dxw';
SaveDialog.Filter := SDXWFileFilter;
SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist];
if SaveDialog.Execute then
TCustomDXWaveList(Component).Items.SaveToFile(SaveDialog.FileName);
finally
SaveDialog.Free;
end;
end;
end;
end;
 
function TDXWaveListEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SOpen;
1: Result := SSave;
end;
end;
 
function TDXWaveListEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
 
{ TForceFeedbackEffectsProperty }
 
procedure TForceFeedbackEffectsProperty.Edit;
var
Form: TDelphiXFFEditForm;
Effects: TForceFeedbackEffects;
begin
Effects := TForceFeedbackEffects(GetOrdValue);
 
Form := TDelphiXFFEditForm.Create(nil);
try
if Effects.Input is TJoystick then
Form.Effects := Form.DXInput.Joystick.Effects
else if Effects.Input is TKeyboard then
Form.Effects := Form.DXInput.Keyboard.Effects
else if Effects.Input is TMouse then
Form.Effects := Form.DXInput.Mouse.Effects
else Exit;
 
Form.Effects.Assign(TForceFeedbackEffects(GetOrdValue));
Form.ShowModal;
if Form.Tag<>0 then
begin
SetOrdValue(Integer(Form.Effects));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TForceFeedbackEffectsProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
 
function TForceFeedbackEffectsProperty.GetValue: string;
begin
if TForceFeedbackEffects(GetOrdValue).Count=0 then
Result := SNone
else
Result := Format('(%s)', [TObject(GetOrdValue).ClassName]);
end;
 
{ TDXInputEditor }
 
procedure TDXInputEditor.Edit;
var
Form: TDelphiXInputEditForm;
begin
Form := TDelphiXInputEditForm.Create(nil);
try
Form.DXInput := TCustomDXInput(Component);
Form.ShowModal;
if Form.Tag<>0 then
Designer.Modified;
finally
Form.Free;
end;
end;
 
procedure TDXInputEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: begin
with TCustomDXInput(Component) do
begin
Joystick.ID := 0;
Keyboard.KeyAssigns := DefKeyAssign;
end;
Designer.Modified;
end;
1: begin
with TCustomDXInput(Component) do
begin
Joystick.ID := 0;
Keyboard.KeyAssigns := DefKeyAssign2_1;
end;
Designer.Modified;
end;
2: begin
with TCustomDXInput(Component) do
begin
Joystick.ID := 1;
Keyboard.KeyAssigns := DefKeyAssign2_2;
end;
Designer.Modified;
end;
end;
end;
 
function TDXInputEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SSinglePlayer;
1: Result := SMultiPlayer1;
2: Result := SMultiPlayer2;
end;
end;
 
function TDXInputEditor.GetVerbCount: Integer;
begin
Result := 3;
end;
 
{ TGUIDProperty }
 
procedure TGUIDProperty.Edit;
var
Form: TDelphiXGUIDEditForm;
begin
Form := TDelphiXGUIDEditForm.Create(nil);
try
Form.GUID := GetStrValue;
Form.ShowModal;
if Form.Tag<>0 then
begin
SetStrValue(Form.GUID);
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TGUIDProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
 
end.
/VCL_DELPHIX_D6/DXSounds.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXPictEdit.pas
1,10 → 1,10
unit DXPictEdit;
{$INCLUDE DelphiXcfg.inc}
 
interface
 
uses
Windows, SysUtils, Classes, Forms, Dialogs, Controls, StdCtrls, ExtCtrls,
ExtDlgs, DIB, Menus, Graphics, Clipbrd {$IFDEF VER28UP}, PNGImage{$ENDIF};
ExtDlgs, DIB, Menus, Graphics, Clipbrd;
 
type
 
/VCL_DELPHIX_D6/DXPlay.pas
1,33 → 1,13
unit DXPlay;
 
{$INCLUDE DelphiXcfg.inc}
 
{$IFNDEF UseDirectPlay}
// If you want to use DXPlay.pas, please enable the IFDEF UseDirectPlay in DelphiXcfg.inc
interface
implementation
{$ELSE} // !UseDirectPlay
 
interface
{$INCLUDE DelphiXcfg.inc}
 
uses
Windows, SysUtils, Classes, Forms, DXClass, ActiveX, DXETable,
{$IfDef StandardDX}
DirectDraw,
// Delphi 2010 cannot be use DirectPlay8 because structure was not rewriten
// {$IfDef DX9}
// DirectPlay8, DX7toDX8;
// {$Else}
DirectPlay; //old wersion, current in directory
// {$EndIf}
{$Else}
DirectX;
{$EndIf}
Windows, SysUtils, Classes, Forms, DXClass, ActiveX, DirectX, DXETable;
 
type
{$IfDef DX9}
TDPID = DWORD;
{$EndIf}
 
{ TDXPlayPlayer }
 
108,8 → 88,7
 
TCustomDXPlay = class(TComponent)
private
FDPlay: //{$IfDef DX7}
IDirectPlay4A;//{$Else}IDirectPlay8Address{$EndIf};
FDPlay: IDirectPlay4A;
FGUID: string;
FIsHost: Boolean;
FLocalPlayer: TDXPlayPlayer;
137,11 → 116,7
FAsync: Boolean;
FAsyncSupported: Boolean;
procedure ChangeDPlay;
procedure CreateDPlayWithoutDialog(out DPlay:
//{$IfDef DX7}
IDirectPlay4A;
//{$Else}IDirectPlay8Address{$EndIf};
const ProviderName: string);
procedure CreateDPlayWithoutDialog(out DPlay: IDirectPlay4A; const ProviderName: string);
function OpenDPlayWithLobby(out Name: string): Boolean;
function OpenDPlayWithoutLobby(out Name: string): Boolean;
function OpenDPlayWithoutLobby2(const NewSession: Boolean; const ProviderName, SessionName, PlayerName: string): Boolean;
216,10 → 191,7
function DXPlayMessageType(P: Pointer): DWORD;
 
function DXPlayStringToGUID(const S: string): TGUID;
function DXDirectPlayCreate(const lpGUID: TGUID; out lplpDP:
//{$IfDef DX7}
IDirectPlay;
//{$Else}IDirectPlay8Server{$EndIf};
function DXDirectPlayCreate(const lpGUID: TGUID; out lplpDP: IDirectPlay;
pUnk: IUnknown): HRESULT;
 
implementation
252,10 → 224,7
CoTaskMemFree(P);
end;
 
function DXDirectPlayCreate(const lpGUID: TGUID; out lplpDP:
//{$IfDef DX7}
IDirectPlay;
//{$Else}IDirectPlay8Server{$EndIf};
function DXDirectPlayCreate(const lpGUID: TGUID; out lplpDP: IDirectPlay;
pUnk: IUnknown): HRESULT;
type
TDirectPlayCreate= function(const lpGUID: TGUID; out lplpDP: IDirectPlay; pUnk: IUnknown): HRESULT; stdcall;
263,27 → 232,9
Result := TDirectPlayCreate(DXLoadLibrary('DPlayX.dll', 'DirectPlayCreate'))
(lpGUID, lplpDP, pUnk);
end;
{$IFDEF UNICODE}
function DXDirectPlayEnumerate(lpEnumDPCallback: TDPEnumDPCallbackW; lpContext: Pointer): HRESULT;
type
TDirectPlayEnumerateW= function(lpEnumDPCallback: TDPEnumDPCallbackW; lpContext: Pointer): HRESULT; stdcall;
begin
Result := TDirectPlayEnumerateW(DXLoadLibrary('DPlayX.dll', 'DirectPlayEnumerateW'))
(lpEnumDPCallback, lpContext);
end;
 
function DXDirectPlayLobbyCreate(const lpguidSP: TGUID; out lplpDPL: IDirectPlayLobbyW;
lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD): HRESULT;
function DXDirectPlayEnumerateA(lpEnumDPCallback: TDPEnumDPCallbackA; lpContext: Pointer): HRESULT;
type
TDirectPlayLobbyCreateW = function(const lpguidSP: TGUID; out lplpDPL: IDirectPlayLobbyW;
lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD): HRESULT; stdcall;
begin
Result := TDirectPlayLobbyCreateW(DXLoadLibrary('DPlayX.dll', 'DirectPlayLobbyCreateW'))
(lpguidSP, lplpDPL, lpUnk, lpData, dwDataSize);
end;
{$ELSE}
function DXDirectPlayEnumerate(lpEnumDPCallback: TDPEnumDPCallbackA; lpContext: Pointer): HRESULT;
type
TDirectPlayEnumerateA= function(lpEnumDPCallback: TDPEnumDPCallbackA; lpContext: Pointer): HRESULT; stdcall;
begin
Result := TDirectPlayEnumerateA(DXLoadLibrary('DPlayX.dll', 'DirectPlayEnumerateA'))
290,7 → 241,7
(lpEnumDPCallback, lpContext);
end;
 
function DXDirectPlayLobbyCreate(const lpguidSP: TGUID; out lplpDPL: IDirectPlayLobbyA;
function DXDirectPlayLobbyCreateA(const lpguidSP: TGUID; out lplpDPL: IDirectPlayLobbyA;
lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD): HRESULT;
type
TDirectPlayLobbyCreateA = function(const lpguidSP: TGUID; out lplpDPL: IDirectPlayLobbyA;
299,7 → 250,7
Result := TDirectPlayLobbyCreateA(DXLoadLibrary('DPlayX.dll', 'DirectPlayLobbyCreateA'))
(lpguidSP, lplpDPL, lpUnk, lpData, dwDataSize);
end;
{$ENDIF}
 
{ TDXPlayPlayers }
 
constructor TDXPlayPlayers.Create;
365,16 → 316,10
end;
 
var
{$IFDEF UNICODE}
Lobby1: IDirectPlayLobbyW;
Lobby: IDirectPlayLobby2W;
DPlay: IDirectPlay4W;
{$ELSE}
Lobby1: IDirectPlayLobbyA;
Lobby: IDirectPlayLobby2A;
DPlay1: IDirectPlay;
DPlay: IDirectPlay4A;
{$ENDIF}
DPlay1: IDirectPlay;
lpAddress: Pointer;
dwAddressSize: DWORD;
begin
382,16 → 327,16
begin
FModemNames := TStringList.Create;
try
if DXDirectPlayLobbyCreate(PGUID(nil)^, Lobby1, nil, nil, 0)<>0 then
if DXDirectPlayLobbyCreateA(PGUID(nil)^, Lobby1, nil, nil, 0)<>0 then
raise EDXPlayError.CreateFmt(SCannotInitialized, [SDirectPlay]);
Lobby := Lobby1 as {$IFDEF UNICODE}IDirectPlayLobby2W{$ELSE}IDirectPlayLobby2A{$ENDIF};
Lobby := Lobby1 as IDirectPlayLobby2A;
 
if DXDirectPlayCreate(DPSPGUID_MODEM, DPlay1, nil)<>0 then
raise EDXPlayError.CreateFmt(SCannotInitialized, [SDirectPlay]);
DPlay := DPlay1 as {$IFDEF UNICODE}IDirectPlay4W{$ELSE}IDirectPlay4A{$ENDIF};
DPlay := DPlay1 as IDirectPlay4A;
 
{ get size of player address for all players }
if DPlay.GetPlayerAddress(DPID_ALLPLAYERS, nil, dwAddressSize)<>DPERR_BUFFERTOOSMALL then
if DPlay.GetPlayerAddress(DPID_ALLPLAYERS, nil^, dwAddressSize)<>DPERR_BUFFERTOOSMALL then
raise EDXPlayError.Create(SDXPlayModemListCannotBeAcquired);
 
GetMem(lpAddress, dwAddressSize);
399,7 → 344,7
FillChar(lpAddress^, dwAddressSize, 0);
 
{ get the address }
if DPlay.GetPlayerAddress(DPID_ALLPLAYERS, lpAddress, dwAddressSize)<>0 then
if DPlay.GetPlayerAddress(DPID_ALLPLAYERS, lpAddress^, dwAddressSize)<>0 then
raise EDXPlayError.Create(SDXPlayModemListCannotBeAcquired);
 
{ get modem strings from address and put them in the combo box }
525,12 → 470,12
 
try
repeat
hr := FDPlay.Receive(idFrom, idTo, DPRECEIVE_ALL, lpvMsgBuffer, dwMsgBufferSize);
hr := FDPlay.Receive(idFrom, idTo, DPRECEIVE_ALL, lpvMsgBuffer^, dwMsgBufferSize);
 
if hr=DPERR_BUFFERTOOSMALL then
begin
ReAllocMem(lpvMsgBuffer, dwMsgBufferSize);
hr := FDPlay.Receive(idFrom, idTo, DPRECEIVE_ALL, lpvMsgBuffer, dwMsgBufferSize);
hr := FDPlay.Receive(idFrom, idTo, DPRECEIVE_ALL, lpvMsgBuffer^, dwMsgBufferSize);
end;
 
if (hr=0) and (dwMsgBufferSize>=SizeOf(TDPMSG_GENERIC)) then
552,13 → 497,8
 
with Msg_CreatePlayerOrGroup.dpnName do
begin
{$IFDEF UNICODE}
if lpszShortNameW<>nil then
Player.FName := lpszShortNameW;
{$ELSE}
if lpszShortNameA<>nil then
Player.FName := lpszShortNameA;
{$ENDIF}
end;
 
DoAddPlayer(Player);
664,7 → 604,7
 
function TCustomDXPlay.GetProviders: TStrings;
 
function EnumProviderCallback(const lpguidSP: TGUID; lpSPName: {$IFDEF UNICODE}LPCTSTR{$ELSE}LPSTR{$ENDIF};
function EnumProviderCallback(const lpguidSP: TGUID; lpSPName: LPSTR;
dwMajorVersion: DWORD; dwMinorVersion: DWORD; lpContext: Pointer):
BOOL; stdcall;
var
681,7 → 621,7
begin
FProviders := TStringList.Create;
try
DXDirectPlayEnumerate(@EnumProviderCallback, FProviders);
DXDirectPlayEnumerateA(@EnumProviderCallback, FProviders);
except
FProviders.Free; FProviders := nil;
raise;
706,11 → 646,8
 
Guid := New(PGUID);
Move(lpThisSD.guidInstance, Guid^, SizeOf(TGUID));
{$IFDEF UNICODE}
TStrings(lpContext).AddObject(lpThisSD.lpszSessionNameW, TObject(Guid));
{$ELSE}
TStrings(lpContext).AddObject(lpThisSD.lpszSessionNameA, TObject(Guid));
{$ENDIF}
 
Result := True;
end;
 
761,13 → 698,8
ProviderGUID: TGUID;
addressElements: array[0..15] of TDPCompoundAddressElement;
dwElementCount: Integer;
{$IFDEF UNICODE}
Lobby1: IDirectPlayLobbyW;
Lobby: IDirectPlayLobby2W;
{$ELSE}
Lobby1: IDirectPlayLobbyA;
Lobby: IDirectPlayLobby2A;
{$ENDIF}
lpAddress: Pointer;
dwAddressSize: DWORD;
begin
777,9 → 709,9
ProviderGUID := PGUID(Providers.Objects[i])^;
 
{ DirectPlay address making }
if DXDirectPlayLobbyCreate(PGUID(nil)^, Lobby1, nil, nil, 0)<>0 then
if DXDirectPlayLobbyCreateA(PGUID(nil)^, Lobby1, nil, nil, 0)<>0 then
raise EDXPlayError.CreateFmt(SCannotInitialized, [SDirectPlay]);
Lobby := Lobby1 as {$IFDEF UNICODE}IDirectPlayLobby2W{$ELSE}IDirectPlayLobby2A{$ENDIF};
Lobby := Lobby1 as IDirectPlayLobby2A;
 
FillChar(addressElements, SizeOf(addressElements), 0);
dwElementCount := 0;
828,7 → 760,7
end;
end;
 
if Lobby.CreateCompoundAddress(addressElements[0], dwElementCount, nil, dwAddressSize)<>DPERR_BUFFERTOOSMALL then
if Lobby.CreateCompoundAddress(addressElements[0], dwElementCount, nil^, dwAddressSize)<>DPERR_BUFFERTOOSMALL then
raise EDXPlayError.CreateFmt(SCannotInitialized, [SDirectPlay]);
 
GetMem(lpAddress, dwAddressSize);
835,7 → 767,7
try
FillChar(lpAddress^, dwAddressSize, 0);
 
if Lobby.CreateCompoundAddress(addressElements[0], dwElementCount, lpAddress, dwAddressSize)<>0 then
if Lobby.CreateCompoundAddress(addressElements[0], dwElementCount, lpAddress^, dwAddressSize)<>0 then
raise EDXPlayError.CreateFmt(SCannotInitialized, [SDirectPlay]);
 
{ DirectPlay initialization }
905,13 → 837,8
 
with lpName do
begin
{$IFDEF UNICODE}
if lpszShortNameW<>nil then
Player.FName := lpszShortNameW;
{$ELSE}
if lpszShortNameA<>nil then
Player.FName := lpszShortNameA;
{$ENDIF}
end;
 
Result := True;
935,11 → 862,11
FLocalPlayer := TDXPlayPlayer.Create(FPlayers);
FLocalPlayer.FName := NameS;
 
if FDPlay.CreatePlayer(FLocalPlayer.FID, @Name, FRecvEvent[0], nil, 0, 0)<>DP_OK then
if FDPlay.CreatePlayer(FLocalPlayer.FID, Name, FRecvEvent[0], nil^, 0, 0)<>DP_OK then
raise EDXPlayError.CreateFmt(SCannotOpened, [FSessionName]);
 
{ Player enumeration }
FDPlay.EnumPlayers(PGUID(nil), @EnumPlayersCallback2, Self, DPENUMPLAYERS_REMOTE);
FDPlay.EnumPlayers(PGUID(nil)^, @EnumPlayersCallback2, Self, DPENUMPLAYERS_REMOTE);
 
FIsHost := FPlayers.Count=1;
 
948,7 → 875,7
 
{ Thread start }
FRecvThread := TDXPlayRecvThread.Create(Self);
FRecvThread.{$IFDEF VER14UP}Start{$ELSE}Resume{$ENDIF};
FRecvThread.Resume;
except
Close;
raise;
973,25 → 900,21
function TCustomDXPlay.OpenDPlayWithLobby(out Name: string): Boolean;
var
DPlay1: IDirectPlay2;
{$IFDEF UNICODE}
Lobby: IDirectPlayLobbyW;
{$ELSE}
Lobby: IDirectPlayLobbyA;
{$ENDIF}
dwSize: DWORD;
ConnectionSettings: PDPLConnection;
begin
Result := False;
 
if DXDirectPlayLobbyCreate(PGUID(nil)^, Lobby, nil, nil, 0)<>0 then
if DXDirectPlayLobbyCreateA(PGUID(nil)^, Lobby, nil, nil, 0)<>0 then
Exit;
 
if Lobby.GetConnectionSettings(0, PDPLConnection(nil), dwSize)<>DPERR_BUFFERTOOSMALL then
if Lobby.GetConnectionSettings(0, PDPLConnection(nil)^, dwSize)<>DPERR_BUFFERTOOSMALL then
Exit;
 
GetMem(ConnectionSettings, dwSize);
try
if Lobby.GetConnectionSettings(0, ConnectionSettings, dwSize)<>0 then
if Lobby.GetConnectionSettings(0, ConnectionSettings^, dwSize)<>0 then
Exit;
 
with ConnectionSettings^.lpSessionDesc^ do
1010,24 → 933,14
 
with ConnectionSettings.lpSessionDesc^ do
begin
{$IFDEF UNICODE}
if lpszSessionNameW<>nil then
FSessionName := lpszSessionNameW;
{$ELSE}
if lpszSessionNameA<>nil then
FSessionName := lpszSessionNameA;
{$ENDIF}
end;
 
with ConnectionSettings.lpPlayerName^ do
begin
{$IFDEF UNICODE}
if lpszShortNameW<>nil then
Name := lpszShortNameW;
{$ELSE}
if lpszShortNameA<>nil then
Name := lpszShortNameA;
{$ENDIF}
end;
finally
FreeMem(ConnectionSettings);
1082,11 → 995,7
FillChar(dpDesc, SizeOf(dpDesc), 0);
dpDesc.dwSize := SizeOf(dpDesc);
dpDesc.dwFlags := DPSESSION_MIGRATEHOST or DPSESSION_KEEPALIVE;
{$IFDEF UNICODE}
dpDesc.lpszSessionNameW := {$IFDEF VER12UP}PChar{$ELSE}PWideChar{$ENDIF}(SessionName);
{$ELSE}
dpDesc.lpszSessionNameA := PAnsiChar(SessionName);
{$ENDIF}
dpDesc.lpszSessionNameA := PChar(SessionName);
dpDesc.guidApplication := DXPlayStringToGUID(GUID);
dpDesc.dwMaxPlayers := MaxPlayers;
 
1170,7 → 1079,7
DoMessage(FLocalPlayer, Data, DataSize);
end else
if FAsync and FAsyncSupported then
FDPlay.SendEx(FLocalPlayer.ID, ToID, DPSEND_GUARANTEED or DPSEND_ASYNC, Data, DataSize, 0, 0, nil, nil)
FDPlay.SendEx(FLocalPlayer.ID, ToID, DPSEND_GUARANTEED or DPSEND_ASYNC, Data^, DataSize, 0, 0, nil, nil)
else
FDPlay.Send(FLocalPlayer.ID, ToID, DPSEND_GUARANTEED, Data^, DataSize);
end;
1189,7 → 1098,7
{ Ž©•ªˆ¶‚̃ƒbƒZ[ƒW }
DoMessage(FLocalPlayer, Data, DataSize);
end else
FDPlay.SendEx(FLocalPlayer.ID, ToID, dwFlags, Data, DataSize,
FDPlay.SendEx(FLocalPlayer.ID, ToID, dwFlags, Data^, DataSize,
0, 0, nil, @Result); // 0 ˆÈŠO‚̓Tƒ|[ƒg‚µ‚È‚¢ƒfƒoƒCƒX‚ ‚é‚Ì‚ÅŽg‚í‚È‚¢
end;
 
1234,6 → 1143,4
CoInitialize(nil);
finalization
CoUninitialize;
{$ENDIF} // UseDirectPlay
 
end.
end.
/VCL_DELPHIX_D6/DXReg.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXRender.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXWaveEdit.pas
4,7 → 4,7
 
uses
Windows, SysUtils, Classes, Forms, Dialogs, Controls, StdCtrls, ExtCtrls,
Buttons, ComCtrls, DXSounds, DXWave, Graphics;
Buttons, ComCtrls, DXSounds, Wave, Graphics;
 
type
 
/VCL_DELPHIX_D6/DXInptEdit.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXPlayFm.dfm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/VCL_DELPHIX_D6/DXSounds.pas
5,13 → 5,8
{$INCLUDE DelphiXcfg.inc}
 
uses
Windows, Messages, SysUtils, Classes, Controls, Forms, ExtCtrls, MMSystem, ActiveX,
DXClass, DXWave, D3DUtils, {$IFDEF VER17UP} Types, {$ENDIF}
{$IFDEF StandardDX}
DirectSound, DirectMusic;
{$ELSE}
DirectX;
{$ENDIF}
Windows, Messages, SysUtils, Classes, Controls, Forms, ExtCtrls, MMSystem,
DirectX, DXClass, Wave;
 
type
 
48,50 → 43,6
property ISound: IDirectSound read GetISound;
end;
 
{ TD3DSParams }
 
TConeAngle = record
Inside,Outside:DWord;
end;
TD3DSParams = class
private
FOwner: TDirectSoundBuffer;
 
FDsb: TDS3DBUFFER;
 
function GetPosition: TD3DVector;
function GetVelocity: TD3DVector;
function GetConeOrientation: TD3DVector;
function GetConeAngle: TConeAngle;
function GetConeOutsideVolume: Integer;
function GetMinDistance: TD3DValue;
function GetMaxDistance: TD3DValue;
function GetRaw: TDS3DBuffer;
 
procedure SetPosition(const v: TD3DVector);
procedure SetVelocity(const v: TD3DVector);
procedure SetConeOrientation(const v: TD3DVector);
procedure SetConeAngle(const v: TConeAngle);
procedure SetConeOutsideVolume(const v: Integer);
procedure SetMinDistance(const v: TD3DValue);
procedure SetMaxDistance(const v: TD3DValue);
procedure SetRaw(const v: TDS3DBuffer);
 
function CheckValidity: Boolean;
public
constructor Create(Owner: TDirectSoundBuffer);
destructor Destroy; override;
property Position: TD3DVector read getPosition write setPosition;
property Velocity: TD3DVector read getVelocity write setVelocity;
property ConeOrientation: TD3DVector read getConeOrientation write setConeOrientation;
property ConeAngle: TConeAngle read getConeAngle write setConeAngle;
property ConeOutsideVolume: Integer read getConeOutsideVolume write setConeOutsideVolume;
property MinDistance: TD3DValue read getMinDistance write setMinDistance;
property MaxDistance: TD3DValue read getMaxDistance write setMaxDistance;
property RawParams: TDS3DBuffer read getRaw write setRaw;
procedure Assign(Prms: TD3DSParams);
end;
 
{ TDirectSoundBuffer }
 
TDirectSoundBuffer = class(TDirectX)
98,8 → 49,6
private
FDSound: TDirectSound;
FIDSBuffer: IDirectSoundBuffer;
FIDS3DBuffer:IDirectSound3DBuffer;
FD3DSParams: TD3DSParams;
FCaps: TDSBCaps;
FFormat: PWaveFormatEx;
FFormatSize: Integer;
106,7 → 55,6
FLockAudioPtr1, FLockAudioPtr2: array[0..0] of Pointer;
FLockAudioSize1, FLockAudioSize2: array[0..0] of DWORD;
FLockCount: Integer;
FIsD3D: Boolean;
function GetBitCount: Longint;
function GetFormat: PWaveFormatEx;
function GetFrequency: Integer;
123,9 → 71,6
procedure SetPan(Value: Integer);
procedure SetPosition(Value: Longint);
procedure SetVolume(Value: Integer);
function GetIDS3DBuffer: IDirectSound3DBuffer;
procedure SetIDS3DBuffer(const Value: IDirectSound3DBuffer);
procedure SetD3DSParams(const Value: TD3DSParams);
protected
procedure Check; override;
public
144,7 → 89,7
function Play(Loop: Boolean{$IFNDEF VER100} = False{$ENDIF}): Boolean;
function Restore: Boolean;
function SetFormat(const Format: TWaveFormatEx): Boolean;
procedure SetSize(const Format: TWaveFormatEx; Size: Integer; D3D: Boolean {$IFNDEF VER100}= False{$ENDIF});
procedure SetSize(const Format: TWaveFormatEx; Size: Integer);
procedure Stop;
procedure UnLock;
property BitCount: Longint read GetBitCount;
154,11 → 99,8
property Frequency: Integer read GetFrequency write SetFrequency;
property IBuffer: IDirectSoundBuffer read GetIBuffer;
property IDSBuffer: IDirectSoundBuffer read GetIDSBuffer write SetIDSBuffer;
property IDS3DBuffer: IDirectSound3DBuffer read GetIDS3DBuffer write SetIDS3DBuffer;
property Playing: Boolean read GetPlaying;
property Pan: Integer read GetPan write SetPan;
property D3DSParams: TD3DSParams read FD3DSParams write SetD3DSParams;
property IsD3D: Boolean read FIsD3D write FIsD3D default False;
property Position: Longint read GetPosition write SetPosition;
property Size: Integer read GetSize;
property Volume: Integer read GetVolume write SetVolume;
435,8 → 377,6
procedure SetPan(Value: Integer);
procedure SetVolume(Value: Integer);
procedure SetWave(Value: TWave);
protected
function GetPlaying: boolean;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
449,8 → 389,6
property Pan: Integer read FPan write SetPan;
property Volume: Integer read FVolume write SetVolume;
property WaveCollection: TWaveCollection read GetWaveCollection;
 
property Playing: boolean read GetPlaying;
published
property Looped: Boolean read FLooped write SetLooped;
property MaxPlayingCount: Integer read FMaxPlayingCount write SetMaxPlayingCount;
507,125 → 445,10
property Items;
end;
 
{ EDXMusicError }
 
EDXMusicError = class(Exception);
 
TMusicListCollection = class;
 
{ TMusicListCollectionItem }
 
TMusicDataProp = class(TPersistent)
private
FMusicData: string;
FMidiname: string;
function GetMusicData: string;
procedure SetMusicData(const Value: string);
protected
procedure DefineProperties(Filer: TFiler); override;
procedure ReadMidiData(Stream: TStream);
procedure WriteMidiData(Stream: TStream);
public
property MusicData: string read GetMusicData write SetMusicData;
published
property MidiName: string read FMidiname write FMidiname;
end;
 
TMusicListCollectionItem = class(THashCollectionItem)
private
{ Private declarations }
FDirectMusicPerformance: IDirectMusicPerformance;
FDirectSound: IDirectSound;
FDirectMusic: IDirectMusic;
FDirectMusicLoader: IDirectMusicLoader;
FDirectMusicSegment: IDirectMusicSegment;
FMusicObjDesc: TDMus_ObjectDesc;
FDirectMusicSegmentState: IDirectMusicSegmentState;
FRepeats: Cardinal;
FStartpoint: Integer;
FDuration: Integer;
// startpoint props in seconds these used to hold millisecond value
FActualDuration: Integer;
FActualStartPoint: Integer;
FIsInitialized: Boolean;
FMusicDataProp: TMusicDataProp;
procedure SetDuration(const Value: integer);
procedure SetRepeats(const Value: Cardinal);
procedure SetStartPoint(const Value: integer);
function GetMusicListCollection: TMusicListCollection;
protected
function GetDisplayName: string; override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
function Size: Integer;
procedure Play;
function IsPlaying: Boolean;
procedure Stop;
procedure Load;
procedure Init;
procedure LoadFromFile(const MidiFileName: string);
procedure SaveToFile(const MidiFileName: string);
property MusicCollection: TMusicListCollection read GetMusicListCollection;
property IsInitialized: Boolean read FIsInitialized write FIsInitialized;
published
property Name;
property Repeats: Cardinal read Frepeats write SetRepeats;
property Duration: integer read FDuration write SetDuration;
property StartPoint: integer read FStartPoint write SetStartPoint;
property Midi: TMusicDataProp read FMusicDataProp write FMusicDataProp;
end;
 
{ TMusicListCollection }
 
TMusicListCollection = class(THashCollection)
private
FOwner: TPersistent;
FDirectSound: IDirectSound;
protected
function GetItem(Index: Integer): TMusicListCollectionItem;
procedure SetItem(Index: Integer; Value: TMusicListCollectionItem);
procedure Update(Item: TCollectionItem); override;
function GetOwner: TPersistent; override;
public
constructor Create(AOwner: TComponent);
function Add: TMusicListCollectionItem;
function Find(const Name: string): TMusicListCollectionItem;
procedure Restore;
procedure LoadFromFile(const FileName: string);
procedure LoadFromStream(Stream: TStream);
procedure SaveToFile(const FileName: string);
procedure SaveToStream(Stream: TStream);
{$IFDEF VER4UP}
function Insert(Index: Integer): TMusicListCollectionItem;
{$ENDIF}
property Items[Index: Integer]: TMusicListCollectionItem read GetItem write SetItem;
published
end;
 
{ TDXMusic }
 
TDXMusic = class(TComponent)
private
FDXSound: TDXSound;
FMidis: TMusicListCollection;
procedure SetMidis(const value: TMusicListCollection);
procedure SetDXSound(const Value: TDXSound);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property DXSound: TDXSound read FDXSound write SetDXSound;
property Midis: TMusicListCollection read FMidis write SetMidis;
end;
 
implementation
 
uses DXConsts;
 
const
dm_OK = 0;
 
function DXDirectSoundCreate(lpGUID: PGUID; out lpDS: IDirectSound;
pUnkOuter: IUnknown): HRESULT;
type
636,13 → 459,13
(lpGUID, lpDS, pUnkOuter);
end;
 
function DXDirectSoundEnumerate(lpCallback: {$IFDEF UNICODE}TDSEnumCallbackW{$ELSE}TDSEnumCallbackA{$ENDIF};
function DXDirectSoundEnumerate(lpCallback: TDSEnumCallbackA;
lpContext: Pointer): HRESULT;
type
TDirectSoundEnumerate = function(lpCallback: {$IFDEF UNICODE}TDSEnumCallbackW{$ELSE}TDSEnumCallbackA{$ENDIF};
TDirectSoundEnumerate = function(lpCallback: TDSEnumCallbackA;
lpContext: Pointer): HRESULT; stdcall;
begin
Result := TDirectSoundEnumerate(DXLoadLibrary('DSound.dll', {$IFDEF UNICODE}'DirectSoundEnumerateW'{$ELSE}'DirectSoundEnumerateA'{$ENDIF}))
Result := TDirectSoundEnumerate(DXLoadLibrary('DSound.dll', 'DirectSoundEnumerateA'))
(lpCallback, lpContext);
end;
 
667,7 → 490,7
lpContext: Pointer): HRESULT; stdcall;
begin
try
Result := TDirectSoundCaptureEnumerate(DXLoadLibrary('DSound.dll', {$IFDEF UNICODE}'DirectSoundCaptureEnumerateW'{$ELSE}'DirectSoundCaptureEnumerateA'{$ENDIF}))
Result := TDirectSoundCaptureEnumerate(DXLoadLibrary('DSound.dll', 'DirectSoundCaptureEnumerateA'))
(lpCallback, lpContext);
except
raise EDirectXError.Create(SSinceDirectX5);
678,8 → 501,8
DirectSoundDrivers: TDirectXDrivers;
DirectSoundCaptureDrivers: TDirectXDrivers;
 
function EnumDirectSoundDrivers_DSENUMCALLBACK(lpGuid: PGUID; lpstrDescription: {$IFDEF UNICODE}LPCTSTR{$ELSE}LPCSTR{$ENDIF};
lpstrModule: {$IFDEF UNICODE}LPCTSTR{$ELSE}LPCSTR{$ENDIF}; lpContext: Pointer): BOOL; stdcall;
function EnumDirectSoundDrivers_DSENUMCALLBACK(lpGuid: PGUID; lpstrDescription: LPCSTR;
lpstrModule: LPCSTR; lpContext: Pointer): BOOL; stdcall;
begin
Result := True;
with TDirectXDriver.Create(TDirectXDrivers(lpContext)) do
800,9 → 623,7
constructor TDirectSoundBuffer.Create(ADirectSound: TDirectSound);
begin
inherited Create;
FIsD3D := False;
FDSound := ADirectSound;
FIDS3DBuffer := nil;
FDSound.FBufferList.Add(Self);
end;
 
809,7 → 630,6
destructor TDirectSoundBuffer.Destroy;
begin
IDSBuffer := nil;
IDS3DBuffer := nil;
FDSound.FBufferList.Remove(Self);
inherited Destroy;
end;
820,35 → 640,21
begin
if Source = nil then
IDSBuffer := nil
else
if Source is TWave then
else if Source is TWave then
LoadFromWave(TWave(Source))
else
if Source is TDirectSoundBuffer then
else if Source is TDirectSoundBuffer then
begin
if TDirectSoundBuffer(Source).IDSBuffer = nil then
IDSBuffer := nil
else
else begin
FDSound.DXResult := FDSound.ISound.DuplicateSoundBuffer(TDirectSoundBuffer(Source).IDSBuffer,
TempBuffer);
if FDSound.DXResult=0 then
begin
FDSound.DXResult := FDSound.ISound.DuplicateSoundBuffer(TDirectSoundBuffer(Source).IDSBuffer, TempBuffer);
if FDSound.DXResult = DS_OK then
begin
IDSBuffer := TempBuffer;
end;
end;
 
if FIsD3D then
if TDirectSoundBuffer(Source).IDS3DBuffer = nil then
IDS3DBuffer := nil
else
begin
FDSound.DXResult := FDSound.ISound.QueryInterface(IID_IDirectSound3DBuffer, FIDS3DBuffer);
if FDSound.DXResult = DS_OK then
FD3DSParams := TDirectSoundBuffer(Source).FD3DSParams;
end;
 
end
else
end else
inherited Assign(Source);
end;
 
886,14 → 692,6
DXResult := IBuffer.GetFrequency(DWORD(Result));
end;
 
function TDirectSoundBuffer.GetIDS3DBuffer: IDirectSound3DBuffer;
begin
if Self <> nil then
Result := FIDS3DBuffer
else
Result := nil;
end;
 
function TDirectSoundBuffer.GetIDSBuffer: IDirectSoundBuffer;
begin
if Self <> nil then
923,7 → 721,7
var
dwCurrentWriteCursor: Longint;
begin
IBuffer.GetCurrentPosition(@DWORD(Result), @DWORD(dwCurrentWriteCursor));
IBuffer.GetCurrentPosition(DWORD(Result), DWORD(dwCurrentWriteCursor));
end;
 
function TDirectSoundBuffer.GetSize: Integer;
959,7 → 757,7
Data1, Data2: Pointer;
Data1Size, Data2Size: Longint;
begin
SetSize(Format, Size, FIsD3D);
SetSize(Format, Size);
 
if Data <> nil then
begin
972,11 → 770,9
finally
UnLock;
end;
end
else
end else
begin
FIDSBuffer := nil;
FIDS3DBuffer := nil;
raise EDirectSoundBufferError.CreateFmt(SCannotLock, [SDirectSoundBuffer]);
end;
end;
1008,9 → 804,10
if IDSBuffer = nil then Exit;
 
if FLockCount > High(FLockAudioPtr1) then Exit;
 
DXResult := IBuffer.Lock(LockPosition, LockSize,
{$IFNDEF DX7}@{$ENDIF}FLockAudioPtr1[FLockCount], {$IFNDEF DX7}@{$ENDIF}FLockAudioSize1[FLockCount],
{$IFNDEF DX7}@{$ENDIF}FLockAudioPtr2[FLockCount], {$IFNDEF DX7}@{$ENDIF}FLockAudioSize2[FLockCount], 0);
FLockAudioPtr1[FLockCount], FLockAudioSize1[FLockCount],
FLockAudioPtr2[FLockCount], FLockAudioSize2[FLockCount], 0);
Result := DXResult = DS_OK;
 
if Result then
1038,14 → 835,9
Result := DXResult = DS_OK;
end;
 
procedure TDirectSoundBuffer.SetD3DSParams(const Value: TD3DSParams);
begin
FD3DSParams.Assign(Value);
end;
 
function TDirectSoundBuffer.SetFormat(const Format: TWaveFormatEx): Boolean;
begin
DXResult := IBuffer.SetFormat(FFormat{$IFDEF DX7}^{$ENDIF});
DXResult := IBuffer.SetFormat(Format);
Result := DXResult = DS_OK;
 
if Result then
1053,10 → 845,10
FreeMem(FFormat);
FFormat := nil;
FFormatSize := 0;
if IBuffer.GetFormat(PWaveFormatEx(nil), 0, @DWORD(FFormatSize)) = DS_OK then
if IBuffer.GetFormat(PWaveFormatEx(nil)^, 0, DWORD(FFormatSize))=DS_OK then
begin
GetMem(FFormat, FFormatSize);
IBuffer.GetFormat(FFormat, FFormatSize, nil);
IBuffer.GetFormat(FFormat^, FFormatSize, PDWORD(nil)^);
end;
end;
end;
1066,30 → 858,6
DXResult := IBuffer.SetFrequency(Value);
end;
 
procedure TDirectSoundBuffer.SetIDS3DBuffer(const Value: IDirectSound3DBuffer);
begin
if FIDS3DBuffer = Value then Exit;
 
FIDS3DBuffer := Value;
FillChar(FCaps, SizeOf(FCaps), 0);
FreeMem(FFormat);
FFormat := nil;
FFormatSize := 0;
FLockCount := 0;
 
if FIDS3DBuffer <> nil then
begin
FCaps.dwSize := SizeOf(FCaps);
IBuffer.GetCaps(FCaps);
 
if IBuffer.GetFormat(PWaveFormatEx(nil), 0, @DWORD(FFormatSize)) = DS_OK then
begin
GetMem(FFormat, FFormatSize);
IBuffer.GetFormat(FFormat, FFormatSize, nil);
end;
end;
end;
 
procedure TDirectSoundBuffer.SetIDSBuffer(Value: IDirectSoundBuffer);
begin
if FIDSBuffer = Value then Exit;
1106,10 → 874,10
FCaps.dwSize := SizeOf(FCaps);
IBuffer.GetCaps(FCaps);
 
if IBuffer.GetFormat(PWaveFormatEx(nil), 0, @DWORD(FFormatSize)) = DS_OK then
if IBuffer.GetFormat(PWaveFormatEx(nil)^, 0, DWORD(FFormatSize))=DS_OK then
begin
GetMem(FFormat, FFormatSize);
IBuffer.GetFormat(FFormat, FFormatSize, nil);
IBuffer.GetFormat(FFormat^, FFormatSize, PDWORD(nil)^);
end;
end;
end;
1123,12 → 891,8
begin
DXResult := IBuffer.SetCurrentPosition(Value);
end;
{$IFNDEF DX7}
const
DSBCAPS_CTRLDEFAULT = DSBCAPS_CTRLFREQUENCY or DSBCAPS_CTRLPAN or DSBCAPS_CTRLVOLUME;
{$ENDIF}
 
procedure TDirectSoundBuffer.SetSize(const Format: TWaveFormatEx; Size: Integer; D3D: Boolean {$IFNDEF VER100}= False{$ENDIF});
procedure TDirectSoundBuffer.SetSize(const Format: TWaveFormatEx; Size: Integer);
var
BufferDesc: TDSBufferDesc;
begin
1143,8 → 907,6
dwFlags := dwFlags or DSBCAPS_STICKYFOCUS
else if DSound.FGlobalFocus then
dwFlags := dwFlags or DSBCAPS_GLOBALFOCUS;
if D3D then
dwFlags := DSBCAPS_STATIC + DSBCAPS_CTRLDEFAULT + DSBCAPS_CTRL3D - DSBCAPS_CTRLPAN;
dwBufferBytes := Size;
lpwfxFormat := @Format;
end;
1173,207 → 935,6
FLockAudioPtr2[FLockCount], FLockAudioSize2[FLockCount]);
end;
 
{ TD3DSParams }
 
function TD3DSParams.CheckValidity: Boolean;
begin
Result := (FOwner <> nil) and (TDirectSoundBuffer(FOwner).IDS3DBuffer <> nil)
end;
 
constructor TD3DSParams.Create(Owner: TDirectSoundBuffer);
{$IFDEF VER14UP}
function MakeD3DVector(x, y, z: TD3DValue): TD3DVector; {$IFDEF VER9UP}inline; {$ENDIF}
begin
Result.x := x;
Result.y := y;
Result.z := z;
end;
{$ENDIF}
begin
inherited Create;
FOwner := Owner;
with FDsb do
begin
dwSize := SizeOf(TDS3DBuffer);
vPosition := MakeD3DVector(0, 0, 0);
vVelocity := MakeD3DVector(0, 0, 0);
dwInsideConeAngle := DS3D_DEFAULTCONEANGLE;
dwOutsideConeAngle := DS3D_DEFAULTCONEANGLE;
vConeOrientation := MakeD3DVector(0, 0, 0);
lConeoutsideVolume := DS3D_DEFAULTCONEOUTSIDEVOLUME;
flMinDistance := 5;
flMaxDistance := 100.0;
dwMode := DS3DMODE_NORMAL;
end;
end;
 
destructor TD3DSParams.destroy;
begin
inherited destroy;
end;
 
function TD3DSParams.getPosition: TD3DVector;
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.GetPosition(FDsb.vPosition);
end;
result := FDsb.vPosition;
end;
 
function TD3DSParams.getVelocity: TD3DVector;
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.GetVelocity(FDsb.vVelocity);
end;
result := FDsb.vVelocity;
end;
 
function TD3DSParams.getConeOrientation: TD3DVector;
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.GetConeOrientation(FDsb.vConeOrientation);
end;
result := FDsb.vConeOrientation;
end;
 
function TD3DSParams.getConeAngle: TConeAngle;
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.GetConeAngles(FDsb.dwInsideConeAngle, FDsb.dwOutsideConeAngle);
end;
with result do
begin
Inside := FDsb.dwInsideConeAngle;
OutSide := FDsb.dwOutsideConeAngle;
end;
end;
 
function TD3DSParams.getConeOutsideVolume: Integer;
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.GetConeOutsideVolume(FDsb.lConeOutsideVolume);
end;
result := FDsb.lConeOutsideVolume;
end;
 
function TD3DSParams.getMinDistance: TD3DValue;
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.GetMinDistance(FDsb.flMinDistance);
end;
result := FDsb.flMinDistance;
end;
 
function TD3DSParams.getMaxDistance: TD3DValue;
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.GetMaxDistance(FDsb.flMaxDistance);
end;
result := FDsb.flMaxDistance;
end;
 
function TD3DSParams.getRaw: TDS3DBuffer;
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.GetAllParameters(FDsb);
end;
result := FDsb;
end;
 
 
procedure TD3DSParams.setPosition(const v: TD3DVector);
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.SetPosition(v.x, v.y, v.z, DS3D_IMMEDIATE);
end;
FDsb.vPosition := v;
end;
 
procedure TD3DSParams.setVelocity(const v: TD3DVector);
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.SetVelocity(v.x, v.y, v.z, DS3D_IMMEDIATE);
end;
FDsb.vVelocity := v;
end;
 
procedure TD3DSParams.setConeOrientation(const v: TD3DVector);
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.SetConeOrientation(v.x, v.y, v.z, DS3D_IMMEDIATE);
end;
FDsb.vConeOrientation := v;
end;
 
procedure TD3DSParams.setConeAngle(const v: TConeAngle);
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.SetConeAngles(v.Inside, v.Outside, DS3D_IMMEDIATE);
end;
FDsb.dwInsideConeAngle := v.Inside;
FDsb.dwInsideConeAngle := v.Outside;
end;
 
procedure TD3DSParams.setConeOutsideVolume(const v: Integer);
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.SetConeOutsideVolume(v, DS3D_IMMEDIATE);
end;
FDsb.lConeOutsideVolume := v;
end;
 
procedure TD3DSParams.setMinDistance(const v: TD3DValue);
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.SetMinDistance(v, DS3D_IMMEDIATE);
end;
FDsb.flMinDistance := v;
end;
 
procedure TD3DSParams.setMaxDistance(const v: TD3DValue);
begin
if CheckValidity then
begin
FOwner.IDS3DBuffer.SetMaxDistance(v, DS3D_IMMEDIATE);
end;
FDsb.flMaxDistance := v;
end;
 
procedure TD3DSParams.setRaw(const v: TDS3DBuffer);
begin
if CheckValidity then
begin
if FOwner.IDS3DBuffer.SetAllParameters(v, DS3D_IMMEDIATE) <> DS_OK then
{'Parameter is invalid for Params3D'};
end;
FDsb := v;
end;
 
procedure TD3DSParams.Assign(Prms: TD3DSParams);
begin
FDsb := Prms.RawParams;
 
if CheckValidity then
begin
if FOwner.IDS3DBuffer.SetAllParameters(FDsb, DS3D_IMMEDIATE) <> DS_OK then
{'Parameter is invalid for Params3D'};
end;
end;
 
{ TAudioStream }
 
type
2101,7 → 1662,7
var
CapturePosition, ReadPosition: DWORD;
begin
if FBuffer.GetCurrentPosition(@DWORD(CapturePosition), @DWORD(ReadPosition)) = DS_OK then
if FBuffer.GetCurrentPosition(CapturePosition, ReadPosition)=DS_OK then
begin
if FBufferPos <= ReadPosition then
Result := ReadPosition - FBufferPos
2120,8 → 1681,7
begin
if not FCapturing then
Start;
Data1 := nil;
Data2 := nil;
 
Result := 0;
while Result < Count do
begin
2128,8 → 1688,7
Size := Min(Count - Result, GetReadSize);
if Size > 0 then
begin
if FBuffer.Lock(FBufferPos, Size, Data1, {$IFNDEF DX7}@{$ENDIF}Data1Size,
Data2, {$IFNDEF DX7}@{$ENDIF}Data2Size, 0) = DS_OK then
if FBuffer.Lock(FBufferPos, Size, Data1, Data1Size, Data2, Data2Size, 0)=DS_OK then
begin
Move(Data1^, Pointer(Integer(@Buffer) + Result)^, Data1Size);
Result := Result + Integer(Data1Size);
2178,7 → 1737,7
if Assigned(FOnFilledBuffer) then
begin
FNotifyThread := TSoundCaptureStreamNotify.Create(Self);
FNotifyThread.{$IFDEF VER14UP}Start{$ELSE}Resume{$ENDIF};
FNotifyThread.Resume;
end;
end else
FOnFilledBuffer := Value;
2213,7 → 1772,7
if Assigned(FOnFilledBuffer) then
begin
FNotifyThread := TSoundCaptureStreamNotify.Create(Self);
FNotifyThread.{$IFDEF VER14UP}Start{$ELSE}Resume{$ENDIF};
FNotifyThread.Resume;
end;
except
Stop;
2241,6 → 1800,7
FDSound := ADSound;
FEnabled := True;
 
 
FEffectList := TList.Create;
FTimer := TTimer.Create(nil);
FTimer.Interval := 500;
2663,37 → 2223,10
 
if PrevInitialized then
Restore;
end
else
end else
inherited Assign(Source);
end;
 
function TWaveCollectionItem.GetPlaying: boolean;
var
Buffer: TDirectSoundBuffer;
index: integer;
begin
Result := False;
if not FInitialized then Exit;
Assert(GetBuffer <> nil);
Assert(FBufferList <> nil);
if FLooped then
begin
Buffer := GetBuffer;
Assert(Buffer <> nil);
Result := Buffer.Playing;
end
else
begin
for index := 0 to FBufferList.Count - 1 do
begin
Result := TDirectSoundBuffer(FBufferList[index]).Playing;
if Result then
Break;
end;
end;
end; {GetPlaying}
 
function TWaveCollectionItem.GetBuffer: TDirectSoundBuffer;
begin
if FInitialized and (FBuffer = nil) then
2751,8 → 2284,7
GetBuffer.Stop;
GetBuffer.Position := 0;
GetBuffer.Play(True);
end
else
end else
begin
NewBuffer := nil;
for i := 0 to FBufferList.Count - 1 do
2770,8 → 2302,7
if NewBuffer = nil then Exit;
 
FBufferList.Add(NewBuffer);
end
else
end else
begin
if FBufferList.Count < FMaxPlayingCount then
begin
2779,8 → 2310,7
if NewBuffer = nil then Exit;
 
FBufferList.Add(NewBuffer);
end
else
end else
begin
NewBuffer := FBufferList[0];
FBufferList.Move(0, FBufferList.Count - 1);
3062,379 → 2592,6
FItems.Assign(Value);
end;
 
{(c) 2006 Jaro Benes, Play midi from memory module}
 
{ TMusicDataProp }
 
type
TMidiDataHeader = packed record
Size: Integer;
end;
 
procedure TMusicDataProp.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineBinaryProperty('Midi', ReadMidiData, WriteMidiData, Length(Self.FMusicData) <> 0);
end;
 
function TMusicDataProp.GetMusicData: string;
begin
SetLength(Result, Length(FMusicData));
if Length(FMusicData) <> 0 then
Move(FMusicData[1], Result[1], Length(FMusicData));
end;
 
procedure TMusicDataProp.ReadMidiData(Stream: TStream);
var
Header: TMidiDataHeader;
begin
Stream.ReadBuffer(Header, SizeOf(Header));
SetLength(FMusicData, Header.Size);
Stream.ReadBuffer(FMusicData[1], Header.Size);
end;
 
procedure TMusicDataProp.SetMusicData(const Value: string);
begin
SetLength(FMusicData, Length(Value));
if Length(Value) <> 0 then
Move(Value[1], FMusicData[1], Length(Value));
end;
 
procedure TMusicDataProp.WriteMidiData(Stream: TStream);
var
Header: TMidiDataHeader;
begin
Header.Size := Length(FMusicData);
Stream.WriteBuffer(Header, SizeOf(Header));
Stream.WriteBuffer(FMusicData[1], Header.Size);
end;
 
{ TMusicListCollectionItem }
 
procedure TMusicListCollectionItem.Load;
var
MidiFilelength: Integer;
begin
// kdyby nahodou uz nejaky existoval tak ho znic
if FDirectMusicSegment <> nil then
FDirectMusicSegment := nil;
ZeroMemory(@FMusicObjDesc, SizeOf(TDMUS_OBJECTDESC));
// tohle je popisek parametru - chceme hrat z pameti
with FMusicObjDesc do
begin
dwsize := SizeOf(TDMUS_OBJECTDESC);
guidclass := CLSID_DirectMusicSegment;
//tohle jen pokud je to ze souboru
//dwvaliddata := DMUS_OBJ_CLASS or DMUS_OBJ_FULLPATH or DMUS_OBJ_FILENAME;
dwvaliddata := DMUS_OBJ_CLASS or DMUS_OBJ_MEMORY or DMUS_OBJ_LOADED;
pbMemData := @FMusicDataProp.FMusicData[1];
llMemLength := Length(FMusicDataProp.FMusicData);
end;
if FDirectMusicLoader.GetObject(FMusicObjDesc, IID_IDirectMusicSegment, FDirectMusicSegment) <> dm_ok then
raise EDXMusicError.Create('Failed to Get object for Direct music'); ;
if FDirectMusicSegment.setParam(GUID_StandardMidiFile, $FFFFFFFF, 0, 0, Pointer(FDirectMusicPerformance)) <> dm_ok then
raise EDXMusicError.Create('Failed to Set param for Direct music'); ;
if FDirectMusicSegment.setParam(GUID_Download, $FFFFFFFF, 0, 0, Pointer(FDirectMusicPerformance)) <> dm_ok then
raise EDXMusicError.Create('Failed to Set param for Direct music'); ;
FDirectMusicSegment.GetLength(MidiFilelength);
if (FActualDuration < MidiFilelength) and (FActualDuration > 0) then
FDirectMusicSegment.SetLength(FActualDuration);
if FActualStartPoint < MidiFilelength - FActualDuration then
FDirectMusicSegment.SetStartpoint(FActualStartPoint);
// jak opakovat
FDirectMusicSegment.Setrepeats(repeats - 1);
end;
 
constructor TMusicListCollectionItem.Create(Collection: TCollection);
begin
inherited Create(Collection);
CoInitialize(nil);
FMusicDataProp := TMusicDataProp.Create;
SetLength(FMusicDataProp.FMusicData, 0);
FDirectMusicPerformance := nil;
FDirectMusic := nil;
FDirectSound := nil;
FDirectMusicSegment := nil;
FDirectMusicLoader := nil;
FIsInitialized := False;
end;
 
procedure TMusicListCollectionItem.Stop;
begin
if FDirectMusicPerformance <> nil then
FDirectMusicPerformance.Stop(nil, nil, 0, 0);
end;
 
function TMusicListCollectionItem.GetDisplayName: string;
begin
Result := inherited GetDisplayName
end;
 
procedure TMusicListCollectionItem.Play;
begin
if not FIsInitialized then
Init;
Load;
if FDirectMusicPerformance <> nil then
FDirectMusicPerformance.PlaySegment(FDirectMusicSegment, 0, 0, @FDirectMusicSegmentState);
end;
 
function TMusicListCollectionItem.IsPlaying: Boolean;
begin
Result := False;
if FDirectMusicPerformance <> nil then
Result := FDirectMusicPerformance.IsPlaying(FDirectMusicSegment, FDirectMusicSegmentState) = DM_OK;
end;
 
destructor TMusicListCollectionItem.Destroy;
begin
FDirectMusicPerformance := nil;
FDirectMusic := nil;
FDirectSound := nil;
FDirectMusicSegment := nil;
FDirectMusicLoader := nil;
FMusicDataProp.Free;
CoUninitialize;
inherited Destroy;
end;
 
procedure TMusicListCollectionItem.SetRepeats(const Value: Cardinal);
begin
Frepeats := Value;
end;
 
procedure TMusicListCollectionItem.SetStartPoint(const Value: integer);
begin
FStartPoint := Value;
end;
 
procedure TMusicListCollectionItem.SetDuration(const Value: integer);
begin
FDuration := Value;
end;
 
procedure TMusicListCollectionItem.Init;
var OK: Boolean;
begin
FIsInitialized := False;
OK := False;
// vytvor FDirectMusicPerformance pokud uz neni vytvoreno
if FDirectMusicPerformance = nil then
OK := CoCreateInstance(CLSID_DirectMusicPerformance, nil, CLSCTX_INPROC,
IID_IDirectMusicperformance, FDirectMusicPerformance) = DM_OK;
if not OK then Exit;
if FDirectSound <> nil then
OK := FDirectMusicPerformance.Init({$IFDEF DX7}@{$ENDIF}FDirectMusic, FDirectSound, 0) = DM_OK
else
OK := FDirectMusicPerformance.Init({$IFDEF DX7}@{$ENDIF}FDirectMusic, nil, 0) = dm_OK;
if not OK then Exit;
// vychozi midi port
// pridej pokud neni nastaven
if FDirectMusicPerformance.Addport(nil) <> DM_OK then Exit;
// zkus vytvorit loader
OK := CoCreateInstance(CLSID_DirectMusicLoader, nil, CLSCTX_Inproc,
IID_IDirectMusicLoader, FDirectMusicLoader) = DM_OK;
FIsInitialized := OK;
end;
 
function TMusicListCollectionItem.GetMusicListCollection: TMusicListCollection;
begin
Result := Collection as TMusicListCollection;
end;
 
procedure TMusicListCollectionItem.SaveToFile(const MidiFileName: string);
var F: file; BakFileMode: integer;
begin
BakFileMode := FileMode;
FileMode := 1; // Read/Write
try
AssignFile(F, MidiFileName);
Rewrite(F, 1);
try
BlockWrite(F, FMusicDataProp.FMusicData[1], Length(FMusicDataProp.FMusicData));
finally
CloseFile(F);
end;
finally
FileMode := BakFileMode;
end;
end;
 
procedure TMusicListCollectionItem.LoadFromFile(const MidiFileName: string);
var F: file; S: string; I: Integer; BakFileMode: integer;
begin
BakFileMode := FileMode;
FileMode := 0; // Read only
try
AssignFile(F, MidiFileName);
Reset(F, 1);
try
SetLength(FMusicDataProp.FMusicData, FileSize(F));
BlockRead(F, FMusicDataProp.FMusicData[1], FileSize(F));
S := ExtractFileName(MidiFileName);
I := Pos(ExtractFileExt(S), S);
if I > 0 then S := Copy(S, 1, I - 1);
FMusicDataProp.Midiname := S;
finally
CloseFile(F);
end;
Name := ExtractFileName(MidiFileName);
finally
FileMode := BakFileMode;
end;
end;
 
function TMusicListCollectionItem.Size: Integer;
begin
Result := Length(FMusicDataProp.FMusicData);
end;
 
{ TMusicListCollection }
 
constructor TMusicListCollection.Create(AOwner: TComponent);
begin
inherited Create(TMusicListCollectionItem);
FOwner := AOwner;
end;
 
function TMusicListCollection.Add: TMusicListCollectionItem;
begin
Result := TMusicListCollectionItem(inherited Add);
Result.FDirectSound := Self.FDirectSound;
end;
 
function TMusicListCollection.GetItem(Index: Integer): TMusicListCollectionItem;
begin
Result := TMusicListCollectionItem(inherited GetItem(Index));
end;
 
procedure TMusicListCollection.SetItem(Index: Integer;
Value: TMusicListCollectionItem);
begin
inherited SetItem(Index, Value);
end;
 
procedure TMusicListCollection.Update(Item: TCollectionItem);
begin
inherited Update(Item);
end;
 
function TMusicListCollection.Find(
const Name: string): TMusicListCollectionItem;
var
i: Integer;
begin
i := IndexOf(Name);
if i = -1 then
raise EDXMusicError.CreateFmt('The midi document does not exist: %s.', [Name]);
Result := Items[i];
end;
 
{$IFDEF VER4UP}
function TMusicListCollection.Insert(Index: Integer): TMusicListCollectionItem;
begin
Result := TMusicListCollectionItem(inherited Insert(Index));
end;
{$ENDIF}
 
function TMusicListCollection.GetOwner: TPersistent;
begin
Result := FOwner;
end;
 
procedure TMusicListCollection.Restore;
begin
 
end;
 
procedure TMusicListCollection.SaveToFile(const FileName: string);
var
Stream: TFileStream;
begin
Stream := TFileStream.Create(FileName, fmCreate);
try
SaveToStream(Stream);
finally
Stream.Free;
end;
end;
 
procedure TMusicListCollection.LoadFromFile(const FileName: string);
var
Stream: TFileStream;
begin
Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
 
type
TMidiCollectionComponent = class(TComponent)
private
FList: TMusicListCollection;
published
property List: TMusicListCollection read FList write FList;
end;
 
procedure TMusicListCollection.SaveToStream(Stream: TStream);
var
Component: TMidiCollectionComponent;
begin
Component := TMidiCollectionComponent.Create(nil);
try
Component.FList := Self;
Stream.WriteComponentRes('DelphiXMidiCollection', Component);
finally
Component.Free;
end;
end;
 
procedure TMusicListCollection.LoadFromStream(Stream: TStream);
var
Component: TMidiCollectionComponent;
begin
Clear;
Component := TMidiCollectionComponent.Create(nil);
try
Component.FList := Self;
Stream.ReadComponentRes(Component);
Restore;
finally
Component.Free;
end;
end;
 
{ TDXMusic }
 
constructor TDXMusic.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FMidis := TMusicListCollection.Create(Self);
if Assigned(FDXSound) then
FMidis.FDirectSound := FDXSound.DSound.IDSound;
end;
 
procedure TDXMusic.SetMidis(const value: TMusicListCollection);
begin
FMidis.Assign(Value);
end;
 
destructor TDXMusic.Destroy;
begin
FMidis.Free;
inherited Destroy;
end;
 
procedure TDXMusic.SetDXSound(const Value: TDXSound);
begin
FDXSound := Value;
if Assigned(FDXSound) then
FMidis.FDirectSound := FDXSound.DSound.IDSound;
end;
 
initialization
finalization
DirectSoundDrivers.Free;
/VCL_DELPHIX_D6/DXReg.pas
1,1302 → 1,53
unit DXReg;
 
 
interface
 
{$I DelphiXcfg.inc}
{$WARNINGS OFF}
 
uses
Windows, SysUtils, Classes, Forms, Dialogs, Graphics, TypInfo,
Controls, StdCtrls, ExtCtrls, Buttons,
{$IFDEF D3DRM}Colli3DX, {$ENDIF}
{$IFNDEF VER6UP}DsgnIntf,
{$ELSE}Designintf, DesignEditors, VCLEditors, PropertyCategories,
{$ENDIF}
DXDraws, DXSounds, DIB, DXWave, DXInput, DXPlay, DXSprite, DXClass;
DXDraws, DXSounds, DIB, Wave, DXInput, DXPlay, DXSprite,
DXClass;
 
type
 
{ TDXDrawDisplayProperty }
procedure Register;
 
TDXDrawDisplayProperty = class(TClassProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
end;
 
{ TDIBProperty }
 
TDIBProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TDXDIBEditor }
 
TDXDIBEditor = class(TComponentEditor)
public
procedure Edit; override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TPictureCollectionItem_PictureProperty }
 
TPictureCollectionItem_PictureProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TDXImageListEditor }
 
TDXImageListEditor = class(TComponentEditor)
private
procedure ListBox1DblClick(Sender: TObject);
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TDXSpriteEngineEditor}
 
TDXSpriteEngineEditor = class(TComponentEditor)
private
procedure ListBox1DblClick(Sender: TObject);
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TWaveProperty }
 
TWaveProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TDXWaveEditor }
 
TDXWaveEditor = class(TComponentEditor)
public
procedure Edit; override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TDXWaveListEditor }
 
TDXWaveListEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TForceFeedbackEffectsProperty }
 
TForceFeedbackEffectsProperty = class(TClassProperty)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TDXInputEditor }
 
TDXInputEditor = class(TComponentEditor)
public
procedure Edit; override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ TGUIDProperty }
 
TGUIDProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TSpriteProperty }
 
TSpriteProperty = class(TClassProperty)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
{ TMidiProperty }
 
TMidiProperty = class(TClassProperty)
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
end;
 
TMidiEditor = class(TDefaultEditor)
public
{$IFDEF VER6UP}
procedure EditProperty(const Prop: IProperty; var Continue: Boolean); override;
{$ELSE}
procedure EditProperty(PropertyEditor: TPropertyEditor;
var continue, FreeEditor: Boolean); override;
{$ENDIF}
end;
 
{ TDXMidiListEditor }
 
TDXMidiListEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
{ Trace editor}
 
TDXDrawEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
 
procedure Register;
 
implementation
 
uses DXPictEdit, DXWaveEdit, DXFFBEdit, DXInptEdit, DXGUIDEdit, DXSpriteEdit,
DXMidiEdit, DXDIBEffectEdit, {$IFDEF VER4UP}DXGlueItEdit,{$ENDIF} DXPathEdit;
 
const
SNone = '(None)';
 
SSettingImage = '&Image...';
SSettingWave = '&Wave...';
SDXGFileFilter = 'DXG file(*.dxg)|*.dxg|All files(*.*)|*.*';
SDXGOpenFileFilter = 'DXG file(*.dxg)|*.dxg|Bitmap file(*.bmp)|*.bmp|All files(*.*)|*.*';
SDXWFileFilter = 'DXW file(*.dxw)|*.dxg|All files(*.*)|*.*';
SDXWFileFilter = 'DXW file(*.dxw)|*.dxw|All files(*.*)|*.*';
SDXWOpenFileFilter = 'DXW file(*.dxw)|*.dxw|Wave file(*.wav)|*.wav|All files(*.*)|*.*';
SDXMFileFilter = 'DXM file(*.dxm)|*.dxm|All files(*.*)|*.*';
SDXMOpenFileFilter = 'DXM file(*.dxm)|*.dxm|Midi file(*.mid)|*.mid|All files(*.*)|*.*';
 
SSinglePlayer = '&Single player';
SMultiPlayer1 = 'Multi player &1';
SMultiPlayer2 = 'Multi player &2';
 
SOpen = '&Open...';
SSave = '&Save...';
SSave = '&Save..';
 
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(TDXDrawDisplay), nil, '',
TDXDrawDisplayProperty);
 
RegisterPropertyEditor(TypeInfo(TDIB), nil, '', TDIBProperty);
RegisterComponentEditor(TCustomDXDIB, TDXDIBEditor);
 
RegisterPropertyEditor(TypeInfo(TPicture), TPictureCollectionItem, 'Picture', TPictureCollectionItem_PictureProperty);
RegisterComponentEditor(TCustomDXImageList, TDXImageListEditor);
 
RegisterPropertyEditor(TypeInfo(TWave), nil, '', TWaveProperty);
RegisterComponentEditor(TCustomDXWave, TDXWaveEditor);
 
RegisterComponentEditor(TCustomDXWaveList, TDXWaveListEditor);
 
RegisterPropertyEditor(TypeInfo(TForceFeedbackEffects), nil, '', TForceFeedbackEffectsProperty);
 
RegisterComponentEditor(TCustomDXInput, TDXInputEditor);
 
{$IFDEF UseDirectPlay}
RegisterPropertyEditor(TypeInfo(string), TCustomDXPlay, 'GUID', TGUIDProperty);
{$ENDIF} // UseDirectPlay
 
RegisterPropertyEditor(TypeInfo(TImageSprite), NIL, '', TSpriteProperty);
RegisterPropertyEditor(TypeInfo(TImageSpriteEx), NIL, '', TSpriteProperty);
RegisterPropertyEditor(TypeInfo(TSprite), NIL, '', TSpriteProperty);
RegisterPropertyEditor(TypeInfo(TBackgroundSprite), NIL, '', TSpriteProperty);
 
RegisterPropertyEditor(TypeInfo(TMusicDataProp), nil, 'MIDI', TMidiProperty);
RegisterComponentEditor(TDXMusic, TDXMidiListEditor);
RegisterComponentEditor(TDXSpriteEngine, TDXSpriteEngineEditor);
 
RegisterComponents('DelphiX',
[TDXDraw,
TDXDIB,
TDXImageList,
{$IFDEF DX3D_deprecated}
TDX3D,
{$ENDIF}
TDXSound,
TDXWave,
TDXWaveList,
TDXInput,
{$IFDEF UseDirectPlay}
TDXPlay,
{$ENDIF} // UseDirectPlay
TDXSpriteEngine,
TDXTimer,
TDXPaintBox,
TDXFont,
TDXPowerFont,
TDXMusic
]);
RegisterComponentEditor(TCustomDXDraw, TDXDrawEditor);
TDXPaintBox]);
end;
 
{ TDXDrawDisplayProperty }
end.
 
function TDXDrawDisplayProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paValueList] - [paReadOnly];
end;
 
const
SDisplayMode = '%dx%dx%d';
 
function TDXDrawDisplayProperty.GetValue: string;
begin
with TDXDrawDisplay(GetOrdValue) do
Result := Format(SDisplayMode, [Width, Height, BitCount]);
end;
 
procedure TDXDrawDisplayProperty.GetValues(Proc: TGetStrProc);
const
List: array[0..2] of TPoint = (
(X: 640; Y: 480),
(X: 800; Y: 600),
(X: 1024; Y: 768));
var
BitCount, i: Integer;
begin
for i := Low(List) to High(List) do
for BitCount := 1 to 3 do
Proc(Format(SDisplayMode, [List[i].x, List[i].y, BitCount * 8]));
end;
 
procedure TDXDrawDisplayProperty.SetValue(const Value: string);
var
s: string;
i, AWidth, AHeight, ABitCount: Integer;
begin
s := Value;
 
i := Pos('x', s);
AWidth := StrToInt(Copy(s, 1, i - 1));
s := Copy(s, i + 1, Length(s));
 
i := Pos('x', s);
AHeight := StrToInt(Copy(s, 1, i - 1));
s := Copy(s, i + 1, Length(s));
 
ABitCount := StrToInt(s);
 
with TDXDrawDisplay(GetOrdValue) do
begin
Width := AWidth;
Height := AHeight;
BitCount := ABitCount;
end;
 
SetOrdValue(GetOrdValue);
end;
 
{ TDIBProperty }
 
procedure TDIBProperty.Edit;
var
Form: TDelphiXPictureEditForm;
begin
Form := TDelphiXPictureEditForm.Create(nil);
try
Form.ViewBox.Picture.Assign(TDIB(GetOrdValue));
Form.DIBClassOnly := True;
Form.ShowModal;
if Form.Tag <> 0 then
begin
SetOrdValue(Integer(Form.ViewBox.Picture.Graphic));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TDIBProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
 
function TDIBProperty.GetValue: string;
begin
if TDIB(GetOrdValue).Size = 0 then
Result := SNone
else
Result := Format('(%s)', [TObject(GetOrdValue).ClassName]);
end;
 
{ TDXDIBEditor }
 
procedure TDXDIBEditor.Edit;
var
Form: TDelphiXPictureEditForm;
begin
Form := TDelphiXPictureEditForm.Create(nil);
try
Form.ViewBox.Picture.Assign(TCustomDXDIB(Component).DIB);
Form.DIBClassOnly := True;
Form.ShowModal;
if Form.Tag <> 0 then
begin
TCustomDXDIB(Component).DIB.Assign(TGraphic(Form.ViewBox.Picture.Graphic));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
procedure TDXDIBEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: Edit;
end;
end;
 
function TDXDIBEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SSettingImage;
end;
end;
 
function TDXDIBEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
 
{ TPictureCollectionItem_PictureProperty }
 
procedure TPictureCollectionItem_PictureProperty.Edit;
var
Form: TDelphiXPictureEditForm;
Item: TPictureCollectionItem;
TempDIB: TDIB;
begin
Form := TDelphiXPictureEditForm.Create(nil);
try
Form.ViewBox.Picture := TPicture(GetOrdValue);
Form.ShowModal;
if Form.Tag <> 0 then
begin
SetOrdValue(Integer(Form.ViewBox.Picture));
 
Item := GetComponent(0) as TPictureCollectionItem;
if Item.Picture.Graphic <> nil then
begin
TempDIB := TDIB.Create;
try
TempDIB.SetSize(1, 1, 24);
TempDIB.Canvas.Draw(0, 0, Item.Picture.Graphic);
Item.TransparentColor := TempDIB.Pixels[0, 0];
finally
TempDIB.Free;
end;
end;
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TPictureCollectionItem_PictureProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
 
function TPictureCollectionItem_PictureProperty.GetValue: string;
begin
if (TPicture(GetOrdValue).Graphic = nil) or (TPicture(GetOrdValue).Graphic.Empty) then
Result := SNone
else
Result := Format('(%s)', [TPicture(GetOrdValue).Graphic.ClassName]);
end;
 
{ dialog }
function CreateListBox(DblClck: TNotifyEvent; out lstbx: TListBox): TForm;
var
Panel1: TPanel;
Panel2: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
begin
Result := TForm.Create(nil);
Panel1 := TPanel.Create(Result);
lstbx := TListBox.Create(Result);
Panel2 := TPanel.Create(Result);
BitBtn1 := TBitBtn.Create(Result);
BitBtn2 := TBitBtn.Create(Result);
with Result do
begin
Name := 'Form12';
Left := 0;
Top := 0;
BorderStyle := bsDialog;
Caption := 'Select Item';
ClientHeight := 206;
ClientWidth := 228;
Color := clBtnFace;
Font.Charset := DEFAULT_CHARSET;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [];
Position := poScreenCenter;
PixelsPerInch := 96;
end;
with Panel1 do
begin
Name := 'Panel1';
Parent := Result;
Left := 0;
Top := 0;
Width := 228;
Height := 165;
Align := alClient;
BevelOuter := bvNone;
BorderWidth := 4;
Caption := '';
TabOrder := 0;
end;
with lstbx do
begin
Name := 'ListBox1';
Parent := Panel1;
Left := 4;
Top := 4;
Width := 220;
Height := 157;
Align := alClient;
ItemHeight := 13;
TabOrder := 0;
OnDblClick := DblClck;
end;
with Panel2 do
begin
Name := 'Panel2';
Parent := Result;
Left := 0;
Top := 165;
Width := 228;
Height := 41;
Align := alBottom;
BevelOuter := bvNone;
Caption := '';
TabOrder := 1;
end;
with BitBtn1 do
begin
Name := 'BitBtn1';
Parent := Panel2;
Left := 24;
Top := 8;
Width := 75;
Height := 25;
TabOrder := 0;
Kind := bkOK;
end;
with BitBtn2 do
begin
Name := 'BitBtn2';
Parent := Panel2;
Left := 128;
Top := 8;
Width := 75;
Height := 25;
TabOrder := 1;
Kind := bkCancel;
end;
end;
function Alter(const str, altstr: string): string;
begin
if str = '' then Result := altstr
else Result := str;
end;
 
{ TDXImageListEditor }
 
procedure TDXImageListEditor.ExecuteVerb(Index: Integer);
var
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
DelphiXDIBEffectEditForm: TTDelphiXDIBEffectEditForm;
{$IFDEF VER4UP}
DXGlueItEditForm: TDXGlueItEditor;
{$ENDIF}
Q: TPictureCollectionItem;
I, N: Integer;
S, Z: string;
{$IFDEF VER4UP}
QQ: TCustomDXImageList;
FrmListBox: TForm;
ListBox1: TListBox;
{$ENDIF}
begin
case Index of
0: begin
OpenDialog := TOpenDialog.Create(nil);
try
OpenDialog.DefaultExt := 'dxg';
OpenDialog.Filter := SDXGOpenFileFilter;
OpenDialog.Options := [ofPathMustExist, ofFileMustExist, ofAllowMultiSelect];
if OpenDialog.Execute then
begin
if OpenDialog.FilterIndex = 2 then
begin
for i := 0 to OpenDialog.Files.Count - 1 do
with TPictureCollectionItem.Create(TCustomDXImageList(Component).Items) do
begin
try
Picture.LoadFromFile(OpenDialog.Files[i]);
Name := ExtractFileName(OpenDialog.Files[i]);
except
Free;
raise;
end;
end;
end else
TCustomDXImageList(Component).Items.LoadFromFile(OpenDialog.FileName);
Designer.Modified;
end;
finally
OpenDialog.Free;
end;
end;
1: begin
SaveDialog := TSaveDialog.Create(nil);
try
SaveDialog.DefaultExt := 'dxg';
SaveDialog.Filter := SDXGFileFilter;
SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist];
if SaveDialog.Execute then
TCustomDXImageList(Component).Items.SaveToFile(SaveDialog.FileName);
finally
SaveDialog.Free;
end;
end;
2:
begin {Create shine effect...}
{special effect}
DelphiXDIBEffectEditForm := TTDelphiXDIBEffectEditForm.Create(nil);
try
DelphiXDIBEffectEditForm.ShowModal;
if DelphiXDIBEffectEditForm.Tag = 1 then begin
{check all names in list of images}
N := 0;
Z := DelphiXDIBEffectEditForm.eName.Text; S := Z;
I := TCustomDXImageList(Component).Items.IndexOf(Z);
{hleda jmeno}
while I <> -1 do begin
S := Format('%s_%d', [Z, N]); {new name}
I := TCustomDXImageList(Component).Items.IndexOf(S);
Inc(N);
end;
{add item}
Q := TPictureCollectionItem(TCustomDXImageList(Component).Items.Add);
Q.Picture.Assign(DelphiXDIBEffectEditForm.ResultDIB);
Q.Name := S; {it has to name!}
Q.Transparent := False; {transparend will be set in future}
Designer.Modified;
end;
finally
DelphiXDIBEffectEditForm.Free;
end;
end;
{$IFDEF VER4UP}
3: {Glue-it editor}
begin
DXGlueItEditForm := TDXGlueItEditor.Create(nil);
try
QQ := TCustomDXImageList(Component); Q := nil;
 
if QQ.Items.Count > 0 then begin
FrmListBox := CreateListBox(ListBox1DblClick, ListBox1);
try
for I := 0 to QQ.Items.Count - 1 do begin
S := QQ.Items[I].Name;
ListBox1.Items.Add(Alter(S, '(unnamed).' + IntToStr(I)));
end;
 
case FrmListBox.ShowModal of
mrOk: //when select one
begin
//when image selected
if ListBox1.ItemIndex <> -1 then begin
Q := QQ.Items[ListBox1.ItemIndex];
//load one image into editor
DXGlueItEditForm.LoadImageFromList(Q.Name, Q.Picture, Q.Width,
Q.Height, Q.Transparent, Q.TransparentColor);
//image loadet, noe se up edit mode
DXGlueItEditForm.Operation := ogiEdit;
end;
end;
mrCancel: DXGlueItEditForm.Operation := ogiNew;
else
Exit
end {case};
finally
FrmListBox.Free;
end;
end
else
DXGlueItEditForm.Operation := ogiNew;
DXGlueItEditForm.ShowModal;
if DXGlueItEditForm.Tag = 1 then begin
//when image as new. it has to create new item
if DXGlueItEditForm.Operation = ogiNew then
Q := TPictureCollectionItem(TCustomDXImageList(Component).Items.Add);
//and store edited image into
if Assigned(Q) then
DXGlueItEditForm.SaveImageIntoList(Q);
//signal to designer that anything was changed;
Designer.Modified;
end;
finally
DXGlueItEditForm.Free;
end;
end;
{$ENDIF}
end;
end;
 
function TDXImageListEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SOpen;
1: Result := SSave;
2: Result := 'Shine effect...';
{$IFDEF VER4UP}
//fix bug by Pásztor Károly [fenistil@hu.hu]
3: Result := 'Glue it...';
{$ENDIF}
end;
end;
 
function TDXImageListEditor.GetVerbCount: Integer;
begin
Result := {$IFDEF VER4UP}4{$ELSE}3{$ENDIF};
end;
 
procedure TDXImageListEditor.ListBox1DblClick(Sender: TObject);
begin
if Sender is TListBox then with (Sender as TListBox) do
if ItemIndex <> -1 then
(Owner as TForm).ModalResult := mrOk;
end;
 
{ TWaveProperty }
 
procedure TWaveProperty.Edit;
var
Form: TDelphiXWaveEditForm;
begin
Form := TDelphiXWaveEditForm.Create(nil);
try
Form.Wave := TWave(GetOrdValue);
Form.ShowModal;
if Form.Tag <> 0 then
begin
SetOrdValue(Integer(Form.Wave));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TWaveProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
 
function TWaveProperty.GetValue: string;
begin
if TWave(GetOrdValue).Size = 0 then
Result := SNone
else
Result := Format('(%s)', [TObject(GetOrdValue).ClassName]);
end;
 
{ TDXWaveEditor }
 
procedure TDXWaveEditor.Edit;
var
Form: TDelphiXWaveEditForm;
begin
Form := TDelphiXWaveEditForm.Create(nil);
try
Form.Wave := TCustomDXWave(Component).Wave;
Form.ShowModal;
if Form.Tag <> 0 then
begin
TCustomDXWave(Component).Wave := Form.Wave;
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
procedure TDXWaveEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: Edit;
end;
end;
 
function TDXWaveEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SSettingWave;
end;
end;
 
function TDXWaveEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
 
{ TDXWaveListEditor }
 
procedure TDXWaveListEditor.ExecuteVerb(Index: Integer);
var
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
i: Integer;
begin
case Index of
0: begin
OpenDialog := TOpenDialog.Create(nil);
try
OpenDialog.DefaultExt := 'dxw';
OpenDialog.Filter := SDXWOpenFileFilter;
OpenDialog.Options := [ofPathMustExist, ofFileMustExist, ofAllowMultiSelect];
if OpenDialog.Execute then
begin
if OpenDialog.FilterIndex = 2 then
begin
for i := 0 to OpenDialog.Files.Count - 1 do
with TWaveCollectionItem.Create(TCustomDXWaveList(Component).Items) do
begin
try
Wave.LoadFromFile(OpenDialog.Files[i]);
Name := ExtractFileName(OpenDialog.Files[i]);
except
Free;
raise;
end;
end;
end else
TCustomDXWaveList(Component).Items.LoadFromFile(OpenDialog.FileName);
Designer.Modified;
end;
finally
OpenDialog.Free;
end;
end;
1: begin
SaveDialog := TSaveDialog.Create(nil);
try
SaveDialog.DefaultExt := 'dxw';
SaveDialog.Filter := SDXWFileFilter;
SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist];
if SaveDialog.Execute then
TCustomDXWaveList(Component).Items.SaveToFile(SaveDialog.FileName);
finally
SaveDialog.Free;
end;
end;
end;
end;
 
function TDXWaveListEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SOpen;
1: Result := SSave;
end;
end;
 
function TDXWaveListEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
 
{ TForceFeedbackEffectsProperty }
 
procedure TForceFeedbackEffectsProperty.Edit;
var
Form: TDelphiXFFEditForm;
Effects: TForceFeedbackEffects;
begin
Effects := TForceFeedbackEffects(GetOrdValue);
 
Form := TDelphiXFFEditForm.Create(nil);
try
if Effects.Input is TJoystick then
Form.Effects := Form.DXInput.Joystick.Effects
else if Effects.Input is TKeyboard then
Form.Effects := Form.DXInput.Keyboard.Effects
else if Effects.Input is TMouse then
Form.Effects := Form.DXInput.Mouse.Effects
else Exit;
 
Form.Effects.Assign(TForceFeedbackEffects(GetOrdValue));
Form.ShowModal;
if Form.Tag <> 0 then
begin
SetOrdValue(Integer(Form.Effects));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TForceFeedbackEffectsProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
 
function TForceFeedbackEffectsProperty.GetValue: string;
begin
if TForceFeedbackEffects(GetOrdValue).Count = 0 then
Result := SNone
else
Result := Format('(%s)', [TObject(GetOrdValue).ClassName]);
end;
 
{ TDXInputEditor }
 
procedure TDXInputEditor.Edit;
var
Form: TDelphiXInputEditForm;
begin
Form := TDelphiXInputEditForm.Create(nil);
try
Form.DXInput := TCustomDXInput(Component);
Form.ShowModal;
if Form.Tag <> 0 then
Designer.Modified;
finally
Form.Free;
end;
end;
 
procedure TDXInputEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: begin
with TCustomDXInput(Component) do
begin
Joystick.ID := 0;
Keyboard.KeyAssigns := DefKeyAssign;
end;
Designer.Modified;
end;
1: begin
with TCustomDXInput(Component) do
begin
Joystick.ID := 0;
Keyboard.KeyAssigns := DefKeyAssign2_1;
end;
Designer.Modified;
end;
2: begin
with TCustomDXInput(Component) do
begin
Joystick.ID := 1;
Keyboard.KeyAssigns := DefKeyAssign2_2;
end;
Designer.Modified;
end;
end;
end;
 
function TDXInputEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SSinglePlayer;
1: Result := SMultiPlayer1;
2: Result := SMultiPlayer2;
end;
end;
 
function TDXInputEditor.GetVerbCount: Integer;
begin
Result := 3;
end;
 
{ TGUIDProperty }
 
procedure TGUIDProperty.Edit;
var
Form: TDelphiXGUIDEditForm;
begin
Form := TDelphiXGUIDEditForm.Create(nil);
try
Form.GUID := GetStrValue;
Form.ShowModal;
if Form.Tag <> 0 then
begin
SetStrValue(Form.GUID);
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TGUIDProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
 
{ TSpriteProperty }
 
procedure TSpriteProperty.Edit;
var
DirectAccessToSprite: TSprite;
Form: TDelphiXSpriteEditForm;
//FormDesigner: IDesigner;
begin
DirectAccessToSprite := TSprite(GetOrdValue);
//FormDesigner := Designer;
Form := TDelphiXSpriteEditForm.Create(nil);
{FormDesigner.GetComponentNames(GetTypeData(GetPropType), Proc);}
try
Form.LoadDataToForm(DirectAccessToSprite);
//Form.Sprite.AsSign(TPersistent(GetOrdValue));
Form.ShowModal;
if Form.Tag <> 0 then
begin
DirectAccessToSprite := TSprite(Form.SaveDataFromForm);
SetOrdValue(Integer(DirectAccessToSprite));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
 
function TSpriteProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
 
function TSpriteProperty.GetValue: string;
begin
Result := Format('(%s)', [TObject(GetOrdValue).ClassName]);
end;
 
{ TMidiProperty }
 
procedure TMidiProperty.Edit;
var
DelphiXMidiEditForm: TDelphiXMidiEditForm;
DirectAccessToMidiData: TMusicDataProp;
S: string; I: Integer;
begin
DirectAccessToMidiData := TMusicDataProp(GetOrdValue);
DelphiXMidiEditForm := TDelphiXMidiEditForm.Create(nil);
try
DelphiXMidiEditForm.MidiData := DirectAccessToMidiData.MusicData;
DelphiXMidiEditForm.MidiFileName := DirectAccessToMidiData.MidiName;
DelphiXMidiEditForm.Showmodal;
if DelphiXMidiEditForm.Tag = 1 then begin
DirectAccessToMidiData.MusicData := DelphiXMidiEditForm.MidiData;
S := '';
if DelphiXMidiEditForm.MidiFileName <> '' then begin
S := ExtractFileName(DelphiXMidiEditForm.MidiFileName);
I := Pos(ExtractFileExt(S), S);
if I > 0 then S := Copy(S, 1, I - 1);
end;
DirectAccessToMidiData.MidiName := S;
Designer.Modified;
end;
finally
DelphiXMidiEditForm.Free;
end;
end;
 
function TMidiProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
 
function TMidiProperty.GetValue: string;
var
S: string;
begin
S := TMusicDataProp(GetOrdValue).MusicData;
if Length(S) = 0 then
Result := SNone
else
Result := '(Midi)';
end;
 
{$IFDEF VER6UP}
procedure TMidiEditor.EditProperty(const Prop: IProperty; var Continue: Boolean);
{$ELSE}
procedure TMidiEditor.EditProperty(PropertyEditor: TPropertyEditor;
var continue, FreeEditor: Boolean);
{$ENDIF}
var
PropName: string;
begin
PropName := {$IFDEF VER6UP}Prop{$ELSE}PropertyEditor{$ENDIF}.GetName;
if (CompareText(PropName, 'Midi') = 0) then
begin
{$IFDEF VER6UP}Prop{$ELSE}PropertyEditor{$ENDIF}.edit;
continue := false;
end;
end;
 
{ TDXMidiListEditor }
 
procedure TDXMidiListEditor.ExecuteVerb(Index: Integer);
var
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
i: Integer;
begin
case Index of
0: begin
OpenDialog := TOpenDialog.Create(nil);
try
OpenDialog.DefaultExt := 'dxm';
OpenDialog.Filter := SDXMOpenFileFilter;
OpenDialog.Options := [ofPathMustExist, ofFileMustExist, ofAllowMultiSelect];
if OpenDialog.Execute then
begin
if OpenDialog.FilterIndex = 2 then
begin
for i := 0 to OpenDialog.Files.Count - 1 do
with TMusicListCollectionItem.Create(TDXMusic(Component).Midis) do
begin
try
LoadFromFile(OpenDialog.Files[i]);
Name := ExtractFileName(OpenDialog.Files[i]);
except
Free;
raise;
end;
end;
end
else
TDXMusic(Component).Midis.LoadFromFile(OpenDialog.FileName);
Designer.Modified;
end;
finally
OpenDialog.Free;
end;
end;
1: begin
SaveDialog := TSaveDialog.Create(nil);
try
SaveDialog.DefaultExt := 'dxm';
SaveDialog.Filter := SDXMFileFilter;
SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist];
if SaveDialog.Execute then
TCustomDXWaveList(Component).Items.SaveToFile(SaveDialog.FileName);
finally
SaveDialog.Free;
end;
end;
end;
end;
 
function TDXMidiListEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
 
function TDXMidiListEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SOpen;
1: Result := SSave;
end;
end;
 
{ TDXSpriteEngineEditor }
 
procedure TDXSpriteEngineEditor.ListBox1DblClick(Sender: TObject);
begin
if Sender is TListBox then with (Sender as TListBox) do
if ItemIndex <> -1 then
(Owner as TForm).ModalResult := mrOk;
end;
 
procedure TDXSpriteEngineEditor.ExecuteVerb(Index: Integer);
var
FrmListBox: TForm;
ListBox1: TListBox;
DelphiXSpriteEditForm: TDelphiXSpriteEditForm;
ASprite: TSprite;
I, Z: Integer;
S: string;
Q: TCustomDXSpriteEngine;
begin
case Index of
0: begin
FrmListBox := nil;
Z := 0; //default value
DelphiXSpriteEditForm := TDelphiXSpriteEditForm.Create(nil);
try
Q := TCustomDXSpriteEngine(Component);
case Q.Items.Count of
0: begin
ShowMessage('You must create any item of sprite first!');
Exit;
end;
1: ASprite := Q.Items[Z].Sprite;
else
FrmListBox := CreateListBox(ListBox1DblClick, ListBox1);
for I := 0 to Q.Items.Count - 1 do begin
S := Q.Items[I].Name;
ListBox1.Items.Add(Alter(S, '(unnamed).' + IntToStr(I)));
end;
if FrmListBox.ShowModal <> mrOk then Exit;
Z := ListBox1.ItemIndex;
if Z = -1 then Exit;
ASprite := Q.Items[Z].Sprite;
{synchronize of names}
if ASprite.Caption = '' then
if Q.Items[ListBox1.ItemIndex].Name <> '' then
ASprite.Caption := Q.Items[Z].Name;
end {case};
DelphiXSpriteEditForm.LoadDataToForm(ASprite);
DelphiXSpriteEditForm.ShowModal;
if DelphiXSpriteEditForm.Tag <> 0 then begin
ASprite := TSprite(DelphiXSpriteEditForm.SaveDataFromForm);
if Q.Items[Z].Name = '' then
if ASprite.Caption <> '' then
Q.Items[Z].Name := ASprite.Caption;
Designer.Modified;
end;
finally
if Assigned(FrmListBox) then FrmListBox.Free;
DelphiXSpriteEditForm.Free;
end;
end;
end;
end;
 
function TDXSpriteEngineEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
 
function TDXSpriteEngineEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := 'Sprite Editor';
end;
end;
 
{ TDXDrawEditor }
 
procedure TDXDrawEditor.ExecuteVerb(Index: Integer);
var
ediform: TDelphiXPathsEditForm;
Q: TCustomDXDraw;
I: Integer;
S: string;
T: TTrace;
{$IFNDEF VER4UP}
H: TTrace;
J: Integer;
{$ENDIF}
begin
case Index of
0: begin
Q := TCustomDXDraw(Component);
{paths editor}
ediform := TDelphiXPathsEditForm.Create(nil);
try
ediform.Pane.Width := Q.Display.Width;
ediform.Pane.Height := Q.Display.Width;
for I := 0 to Q.Traces.Count - 1 do begin
S := Q.Traces.Items[I].Name;
T := ediform.PrivateTraces.Add;
T.Name := S;
{$IFDEF VER4UP}
T.Assign(Q.Traces.Items[I]);
{$ELSE}
T.Blit := Q.Traces.Items[I].Blit;
{$ENDIF}
if Trim(S) = '' then S := Format('(unnamed[%d])', [I]);
ediform.cbListOfTraces.Items.Add(S);
end;
ediform.ShowTracesOnPane;
 
ediform.ShowModal;
 
if ediform.Tag = 1 then begin
{clear traces}
Q.Traces.Clear;
{rewrite backward}
for i := 0 to ediform.PrivateTraces.Count -1 do begin
T := Q.Traces.Add;
T.Name := ediform.PrivateTraces.Items[I].Name;
{$IFDEF VER4UP}
T.Assign(ediform.PrivateTraces.Items[i]);
{$ELSE}
H := ediform.PrivateTraces.Items[i];
T.Blit := H.Blit;
T.Blit.SetPathLen(H.Blit.GetPathCount);
for J := 0 to H.Blit.GetPathCount - 1 do begin
T.Blit.Path[J] := H.Blit.Path[J]
end
{$ENDIF}
end;
{prepis zmeny}
Designer.Modified;
end;
finally
ediform.Free;
end;
end;
end;
end;
 
function TDXDrawEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
 
function TDXDrawEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := 'Traces Editor';
end;
end;
 
end.
/VCL_DELPHIX_D6/DXRender.pas
5,18 → 5,7
{$INCLUDE DelphiXcfg.inc}
 
uses
Windows,
{$IfDef StandardDX}
DirectDraw,
{$ifdef DX7}
Direct3D;
{$endif}
{$IfDef DX9}
Direct3D9, Direct3D, D3DX9, {Direct3D8,} DX7toDX8;
{$EndIf}
{$Else}
DirectX;
{$EndIf}
Windows, DirectX;
 
const
DXR_MAXTEXTURE = 4;
27,15 → 16,6
TDXR_Color = DWORD;
TDXR_SurfaceColor = DWORD;
 
{ TDXR_Option }
 
PDXR_Option = ^TDXR_Option;
TDXR_Option = (
DXR_OPTION_VERSION,
DXR_OPTION_MMXENABLE,
DXR_OPTION_RENDERPRIMITIVES
);
 
{ TDXR_ShadeMode }
 
TDXR_ShadeMode = (
54,6 → 34,7
DXR_BLEND_ONE1_SUB_ONE2, // r=c1-c2
DXR_BLEND_ONE2_SUB_ONE1, // r=c2-c1
DXR_BLEND_ONE1_MUL_ONE2, // r=c1*c2
 
DXR_BLEND_SRCALPHA1, // r=c1*a1
DXR_BLEND_SRCALPHA1_ADD_ONE2, // r=c1*a1+c2
DXR_BLEND_ONE2_SUB_SRCALPHA1, // r=c2-c1*a1
60,10 → 41,8
DXR_BLEND_SRCALPHA1_ADD_INVSRCALPHA2, // r=c1*a1+c2*(1-a2)
DXR_BLEND_INVSRCALPHA1_ADD_SRCALPHA2, // r=c1*(1-a1)+c2*a2
// for lighting
DXR_BLEND_DECAL, // r=c1
DXR_BLEND_DECALALPHA, // r=c1 ra=a2
DXR_BLEND_MODULATE, // r=c1*c2 ra=a2
DXR_BLEND_MODULATEALPHA, // r=c1*c2
DXR_BLEND_ADD // r=c1+c2 ra=a2
);
 
71,9 → 50,7
 
TDXR_TextureFilter = (
DXR_TEXTUREFILTER_NEAREST,
DXR_TEXTUREFILTER_LINEAR,
DXR_TEXTUREFILTER_MIPMAP_NEAREST,
DXR_TEXTUREFILTER_MIPMAP_LINEAR
DXR_TEXTUREFILTER_LINEAR
);
 
{ TDXR_TextureAddress }
83,19 → 60,6
DXR_TEXTUREADDRESS_DONOTCLIP // tx=tx ty=ty
);
 
{ TDXR_CmpFunc }
 
TDXR_CmpFunc = (
DXR_CMPFUNC_NEVER,
DXR_CMPFUNC_LESS,
DXR_CMPFUNC_EQUAL,
DXR_CMPFUNC_LESSEQUAL,
DXR_CMPFUNC_GREATER,
DXR_CMPFUNC_NOTEQUAL,
DXR_CMPFUNC_GREATEREQUAL,
DXR_CMPFUNC_ALWAYS
);
 
{ TDXR_ColorType }
 
TDXR_ColorType = (
125,7 → 89,6
Bits: Pointer; // Pointer to pixeldata(x:0 y:0)
Pitch: Integer; // Offset of next scanline
PitchBit: Integer; // Offset of next scanline (Number of bit)
MipmapChain: PDXR_Surface;
case Integer of
0: (
{ Indexed color }
150,7 → 113,6
sx: TDXR_Value; // Screen coordinates
sy: TDXR_Value;
sz: TDXR_Value;
rhw: TDXR_Value; // 1/sz
color: TDXR_Color;
specular: TDXR_Color;
tu, tv: array[0..DXR_MAXTEXTURE-1] of TDXR_Value;
183,7 → 145,6
ColorKeyEnable: Boolean;
ColorKey: TDXR_SurfaceColor;
TextureAddress: TDXR_TextureAddress;
BumpTexture: Integer;
end;
 
{ TDXR_Cull }
206,26 → 167,19
TextureEnable: Boolean;
TextureList: array[0..DXR_MAXTEXTURE-1] of TDXR_TextureLayer;
TextureFilter: TDXR_TextureFilter;
ZBuffer: PDXR_Surface;
ZFunc: TDXR_CmpFunc;
ZWriteEnable: Boolean;
EnableDrawLine: Integer;
EnableDrawLine: DWORD;
end;
 
function dxrGetOption(Option: TDXR_Option): DWORD;
procedure dxrSetOption(Option: TDXR_Option; Value: DWORD);
 
procedure dxrMakeIndexedSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
Bits: Pointer; pitch: Integer; idx_index, idx_alpha: DWORD);
procedure dxrMakeRGBSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
Bits: Pointer; pitch: Integer; rgb_red, rgb_green, rgb_blue, rgb_alpha: DWORD);
function dxrScanLine(const Surface: TDXR_Surface; y: DWORD): Pointer;
procedure dxrZBufferClear(const Surface: TDXR_Surface);
 
function dxrDDSurfaceLock(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; var Surface: TDXR_Surface): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
function dxrDDSurfaceLock2(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; var ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
var Surface: TDXR_Surface): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
procedure dxrDDSurfaceUnLock(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; const Surface: TDXR_Surface); {$IFDEF VER9UP}inline;{$ENDIF}
function dxrDDSurfaceLock(DDSurface: IDirectDrawSurface; var Surface: TDXR_Surface): Boolean;
function dxrDDSurfaceLock2(DDSurface: IDirectDrawSurface; var ddsd: TDDSurfaceDesc;
var Surface: TDXR_Surface): Boolean;
procedure dxrDDSurfaceUnLock(DDSurface: IDirectDrawSurface; const Surface: TDXR_Surface);
 
procedure dxrDefRenderStates(var States: TDXR_RenderStates);
 
266,6 → 220,19
 
PInteger = ^Integer;
 
{ TDXR_CmpFunc }
 
TDXR_CmpFunc = (
DXR_CMPFUNC_NEVER,
DXR_CMPFUNC_LESS,
DXR_CMPFUNC_EQUAL,
DXR_CMPFUNC_LESSEQUAL,
DXR_CMPFUNC_GREATER,
DXR_CMPFUNC_NOTEQUAL,
DXR_CMPFUNC_GREATEREQUAL,
DXR_CMPFUNC_ALWAYS
);
 
{ TDXRMachine }
 
TDXRMachine_TreeType = (
273,9 → 240,6
DXR_TREETYPE_LOADCOLOR, // Load vertex color
DXR_TREETYPE_LOADCONSTCOLOR, // Load constant color
DXR_TREETYPE_LOADTEXTURE, // Load texel
DXR_TREETYPE_LOADBUMPTEXTURE,// Load texel with Bump mapping
// dx := nx + (BumpTexture[nx-1, ny]-BumpTexture[nx+1, ny]);
// dy := ny + (BumpTexture[nx, ny-1]-BumpTexture[nx, ny+1]);
DXR_TREETYPE_LOADDESTPIXEL, // Load dest pixel
DXR_TREETYPE_BLEND // Blend color
);
320,23 → 284,10
DefaultColor: TDXRMachine_Color;
end;
 
TDXRMachine_Reg_RHW = record
Enable: Boolean;
nRHW: TDXRMachine_Int64;
iRHW: TDXRMachine_Int64;
end;
 
TDXRMachine_Reg_Dither = record
Enable: Boolean;
end;
 
TDXRMachine_Reg_ZBuffer = record
Enable: Boolean;
Surface: PDXR_Surface;
CmpFunc: TDXR_CmpFunc;
WriteEnable: Boolean;
end;
 
TDXRMachine_Reg_Axis = record
Axis: TDXRMachine_Axis;
IncEnable: Boolean;
358,10 → 309,6
DXR_TREETYPE_LOADTEXTURE: (
Texture: Integer
);
DXR_TREETYPE_LOADBUMPTEXTURE: (
_Texture: Integer;
BumpTexture: Integer;
);
DXR_TREETYPE_LOADDESTPIXEL: (
);
DXR_TREETYPE_BLEND: (
379,15 → 326,11
FTreeCount: Integer;
FTreeList: array[0..127] of TDXRMachine_Tree;
FMMXUsed: Boolean;
F_ZBuf: Pointer;
F_BiLinearAxis: TDXRMachine_Axis;
F_BiLinearCol1: TDXRMachine_Color;
F_BiLinearCol2: TDXRMachine_Color;
F_BiLinearCol3: TDXRMachine_Color;
F_BiLinearCol4: TDXRMachine_Color;
F_BumpAxis: TDXRMachine_Axis;
F_BumpAxis2: TDXRMachine_Axis;
F_BumpTempCol: DWORD;
FStack: array[0..255] of TDXRMachine_Color;
procedure GenerateCode(var Code: Pointer; Tree: PDXRMachine_Tree);
public
399,19 → 342,16
TextureIndex: array[0..7] of Integer;
TextureIndexCount: Integer;
Dither: TDXRMachine_Reg_Dither;
ZBuffer: TDXRMachine_Reg_ZBuffer;
Axis: TDXRMachine_Reg_Axis;
RHW: TDXRMachine_Reg_RHW;
constructor Create;
destructor Destroy; override;
function CreateTree: PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
function CreateTree2(Typ: TDXRMachine_TreeType): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
function CreateTree_LoadColor(Color: DWORD): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
function CreateTree_LoadConstColor(R, G, B, A: Byte): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
function CreateTree_LoadTexture(Texture: DWORD): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
function CreateTree_LoadBumpTexture(Texture, BumpTexture: DWORD): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
function CreateTree_Blend(Blend: TDXR_Blend; BlendTree1, BlendTree2: PDXRMachine_Tree): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
procedure Initialize; {$IFDEF VER9UP}inline;{$ENDIF}
function CreateTree: PDXRMachine_Tree;
function CreateTree2(Typ: TDXRMachine_TreeType): PDXRMachine_Tree;
function CreateTree_LoadColor(Color: DWORD): PDXRMachine_Tree;
function CreateTree_LoadConstColor(R, G, B, A: Byte): PDXRMachine_Tree;
function CreateTree_LoadTexture(Texture: DWORD): PDXRMachine_Tree;
function CreateTree_Blend(Blend: TDXR_Blend; BlendTree1, BlendTree2: PDXRMachine_Tree): PDXRMachine_Tree;
procedure Initialize;
procedure Compile(Tree: PDXRMachine_Tree);
procedure Run(Count: Integer);
property Compiled: Boolean read FCompiled write FCompiled;
478,42 → 418,10
@@exit:
pop ebx
end;
 
UseMMX := CPUIDFeatures and CPUIDF_MMX<>0;
end;
 
function dxrGetOption(Option: TDXR_Option): DWORD;
begin
Result := 0;
case Option of
DXR_OPTION_VERSION:
begin
Result := 1*100 + 0;
end;
DXR_OPTION_MMXENABLE:
begin
Result := DWORD(LongBool(UseMMX));
end;
DXR_OPTION_RENDERPRIMITIVES:
begin
Result := RenderPrimitiveCount;
end;
end;
end;
 
procedure dxrSetOption(Option: TDXR_Option; Value: DWORD);
begin
case Option of
DXR_OPTION_MMXENABLE:
begin
UseMMX := LongBool(Value) and (CPUIDFeatures and CPUIDF_MMX<>0);
end;
DXR_OPTION_RENDERPRIMITIVES:
begin
RenderPrimitiveCount := Value;
end;
end;
end;
 
function GetBitCount(B: Integer): DWORD;
begin
Result := 31;
630,14 → 538,14
Result := False;
end;
 
function dxrDDSurfaceLock(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; var Surface: TDXR_Surface): Boolean;
function dxrDDSurfaceLock(DDSurface: IDirectDrawSurface; var Surface: TDXR_Surface): Boolean;
var
ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
ddsd: TDDSurfaceDesc;
begin
Result := dxrDDSurfaceLock2(DDSurface, ddsd, Surface);
end;
function dxrDDSurfaceLock2(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; var ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
function dxrDDSurfaceLock2(DDSurface: IDirectDrawSurface; var ddsd: TDDSurfaceDesc;
var Surface: TDXR_Surface): Boolean;
const
DDPF_PALETTEINDEXED = DDPF_PALETTEINDEXED1 or DDPF_PALETTEINDEXED2 or
654,12 → 562,12
ddsd.lpSurface, ddsd.lPitch, (1 shl ddsd.ddpfPixelFormat.dwRGBBitCount)-1, 0);
end else
begin
if ddsd.ddpfPixelFormat.dwFlags and DDPF_ALPHAPIXELS<>0 then
{if ddsd.ddpfPixelFormat.dwFlags and DDPF_ALPHAPIXELS<>0 then
begin
dxrMakeRGBSurface(Surface, ddsd.dwWidth, ddsd.dwHeight, ddsd.ddpfPixelFormat.dwRGBBitCount,
ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRBitMask, ddsd.ddpfPixelFormat.dwGBitMask,
ddsd.ddpfPixelFormat.dwBBitMask, ddsd.ddpfPixelFormat.dwRGBAlphaBitMask);
end else
end else}
begin
dxrMakeRGBSurface(Surface, ddsd.dwWidth, ddsd.dwHeight, ddsd.ddpfPixelFormat.dwRGBBitCount,
ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRBitMask, ddsd.ddpfPixelFormat.dwGBitMask,
669,7 → 577,7
end;
end;
 
procedure dxrDDSurfaceUnLock(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; const Surface: TDXR_Surface);
procedure dxrDDSurfaceUnLock(DDSurface: IDirectDrawSurface; const Surface: TDXR_Surface);
begin
DDSurface.Unlock(Surface.Bits);
end;
679,14 → 587,6
Result := Pointer(Integer(Surface.Bits)+Surface.Pitch*Integer(y));
end;
 
procedure dxrZBufferClear(const Surface: TDXR_Surface);
var
i: Integer;
begin
for i:=0 to Surface.Height-1 do
FillChar(dxrScanLine(Surface, i)^, Abs(Surface.Pitch), $FF);
end;
 
{ TDXRMachine }
 
constructor TDXRMachine.Create;
716,9 → 616,7
FillChar(ColorList, SizeOf(ColorList), 0);
FillChar(TextureList, SizeOf(TextureList), 0);
FillChar(Dither, SizeOf(Dither), 0);
FillChar(ZBuffer, SizeOf(ZBuffer), 0);
FillChar(Axis, SizeOf(Axis), 0);
FillChar(RHW, SizeOf(RHW), 0);
end;
 
function TDXRMachine.CreateTree: PDXRMachine_Tree;
758,14 → 656,6
Result.Texture := Texture;
end;
 
function TDXRMachine.CreateTree_LoadBumpTexture(Texture, BumpTexture: DWORD): PDXRMachine_Tree;
begin
Result := CreateTree;
Result.Typ := DXR_TREETYPE_LOADBUMPTEXTURE;
Result.Texture := Texture;
Result.BumpTexture := BumpTexture;
end;
 
function TDXRMachine.CreateTree_Blend(Blend: TDXR_Blend; BlendTree1, BlendTree2: PDXRMachine_Tree): PDXRMachine_Tree;
begin
Result := CreateTree;
820,7 → 710,10
Col2_1 := [chRed, chGreen, chBlue, chAlpha];
Col2_2 := [];
end;
DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE1_SUB_ONE2:
DXR_BLEND_ONE1_ADD_ONE2,
DXR_BLEND_ONE1_SUB_ONE2,
DXR_BLEND_ONE2_SUB_ONE1,
DXR_BLEND_ONE1_MUL_ONE2:
begin
Col1_1 := [chRed, chGreen, chBlue, chAlpha];
Col1_2 := [];
827,13 → 720,6
Col2_1 := [chRed, chGreen, chBlue, chAlpha];
Col2_2 := [];
end;
DXR_BLEND_ONE2_SUB_ONE1, DXR_BLEND_ONE1_MUL_ONE2:
begin
Col1_1 := [chRed, chGreen, chBlue, chAlpha];
Col1_2 := [];
Col2_1 := [chRed, chGreen, chBlue, chAlpha];
Col2_2 := [];
end;
DXR_BLEND_SRCALPHA1:
begin
Col1_1 := [chRed, chGreen, chBlue];
870,13 → 756,6
Col2_2 := [];
end;
 
DXR_BLEND_DECAL:
begin
Col1_1 := [chRed, chGreen, chBlue, chAlpha];
Col1_2 := [];
Col2_1 := [];
Col2_2 := [];
end;
DXR_BLEND_DECALALPHA:
begin
Col1_1 := [chRed, chGreen, chBlue];
886,13 → 765,6
end;
DXR_BLEND_MODULATE:
begin
Col1_1 := [chRed, chGreen, chBlue, chAlpha];
Col1_2 := [];
Col2_1 := [chRed, chGreen, chBlue, chAlpha];
Col2_2 := [];
end;
DXR_BLEND_MODULATEALPHA:
begin
Col1_1 := [chRed, chGreen, chBlue];
Col1_2 := [chAlpha];
Col2_1 := [chRed, chGreen, chBlue];
925,10 → 797,6
begin
// Load texel
end;
DXR_TREETYPE_LOADBUMPTEXTURE:
begin
// Load texel with Bump mapping
end;
DXR_TREETYPE_LOADDESTPIXEL:
begin
// Load dest pixel
948,7 → 816,7
begin
c := Tree.Channels; Tree^.Typ := DXR_TREETYPE_LOADBLACK; Tree.Channels := c;
end else
if (Tree.Blend in [DXR_BLEND_ONE1, DXR_BLEND_DECAL]) then
if (Tree.Blend in [DXR_BLEND_ONE1]) then
begin
c := Tree.Channels; Tree := Tree.BlendTree1; Tree.Channels := c;
end else
956,12 → 824,12
begin
c := Tree.Channels; Tree := Tree.BlendTree2; Tree.Channels := c;
end else
if (Tree.Blend in [DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE2_SUB_ONE1]) and
if (Tree.Blend in [DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE1_SUB_ONE2]) and
(Tree.BlendTree2.Typ=DXR_TREETYPE_LOADBLACK) then
begin
c := Tree.Channels; Tree := Tree.BlendTree1; Tree.Channels := c;
end else
if (Tree.Blend in [DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE2_SUB_ONE1]) and
if (Tree.Blend in [DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE1_SUB_ONE2]) and
(Tree.BlendTree1.Typ=DXR_TREETYPE_LOADBLACK) then
begin
c := Tree.Channels; Tree := Tree.BlendTree2; Tree.Channels := c;
994,14 → 862,6
Tree.Channels*GetSurfaceChannels(TextureList[Tree.Texture].Surface^);
TextureList[Tree.Texture].Enable := TextureList[Tree.Texture].EnableChannels<>[];
end;
DXR_TREETYPE_LOADBUMPTEXTURE:
begin
// Load texel with Bump mapping
TextureList[Tree.Texture].EnableChannels := TextureList[Tree.Texture].EnableChannels +
Tree.Channels*GetSurfaceChannels(TextureList[Tree.Texture].Surface^);
TextureList[Tree.Texture].Enable := TextureList[Tree.Texture].EnableChannels<>[];
TextureList[Tree.BumpTexture].Enable := True;
end;
DXR_TREETYPE_LOADDESTPIXEL:
begin
// Load dest pixel
1040,9 → 900,6
Inc(TextureIndexCount);
end;
 
ZBuffer.Enable := ZBuffer.Surface<>nil;
 
RHW.Enable := ZBuffer.Enable;
Axis.IncEnable := Dither.Enable;
 
{ Generate X86 code }
1279,230 → 1136,6
end;
end;
 
procedure genInitZBuffer(var Code: Pointer);
var
_Axis: Pointer;
ByteCount, Pitch: DWORD;
Bits, _ZBuf: Pointer;
begin
if not ZBuffer.Enable then Exit;
 
_Axis := @Axis.Axis;
 
ByteCount := ZBuffer.Surface.BitCount div 8;
Pitch := ZBuffer.Surface.Pitch;
Bits := ZBuffer.Surface.Bits;
 
_ZBuf := @F_ZBuf;
 
asm
jmp @@EndCode
@@StartCode:
mov edx,dword ptr [offset _null]{}@@AxisX:
imul edx,$11{} @@ByteCount: // States.ZBuffer.BitCount div 8
mov eax,dword ptr [offset _null]{}@@AxisY:
imul eax,$11111111{} @@Pitch: // States.ZBuffer.pitch
add eax,$11111111{} @@Bits: // States.ZBuffer.Bits
add eax,edx
mov dword ptr [offset _null],eax{}@@_ZBuf:
@@EndCode:
{$I DXRender.inc}
{ @@AxisX }
mov eax,_Axis; add eax,TDXRMachine_Axis.X
mov edx,offset @@AxisX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@AxisY }
mov eax,_Axis; add eax,TDXRMachine_Axis.Y
mov edx,offset @@AxisY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@ByteCount }
mov eax,ByteCount
mov edx,offset @@ByteCount-1
sub edx,offset @@StartCode
mov byte ptr [ecx+edx],al
 
{ @@Pitch }
mov eax,Pitch
mov edx,offset @@Pitch-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Bits }
mov eax,Bits
mov edx,offset @@Bits-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_ZBuf }
mov eax,_ZBuf
mov edx,offset @@_ZBuf-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end;
 
procedure genZBufferTest(var Code: Pointer);
var
_ZBuf, _RHW: Pointer;
begin
if not ZBuffer.Enable then Exit;
 
_ZBuf := @F_ZBuf;
_RHW := @RHW.nRHW;
 
asm
jmp @@EndCode
@@StartCode:
mov edx,dword ptr [offset _null]{}@@_ZBuf:
mov ebx,dword ptr [offset _null]{}@@_RHW:
@@EndCode:
{$I DXRender.inc}
{ @@_ZBuf }
mov eax,_ZBuf
mov edx,offset @@_ZBuf-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_RHW }
mov eax,_RHW; add eax,4
mov edx,offset @@_RHW-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
 
if ZBuffer.CmpFunc<>DXR_CMPFUNC_ALWAYS then
begin
case ZBuffer.Surface.BitCount of
8: begin
asm
jmp @@EndCode
@@StartCode:
movzx eax,byte ptr [edx]
@@EndCode:
{$I DXRender.inc}
end;
end;
16: begin
asm
jmp @@EndCode
@@StartCode:
movzx eax,word ptr [edx]
@@EndCode:
{$I DXRender.inc}
end;
end;
24: begin
asm
jmp @@EndCode
@@StartCode:
movzx ax,byte ptr [edx+2]
shl eax,16
mov ax,word ptr [edx]
@@EndCode:
{$I DXRender.inc}
end;
end;
32: begin
asm
jmp @@EndCode
@@StartCode:
mov eax,dword ptr [edx]
@@EndCode:
{$I DXRender.inc}
end;
end;
end;
 
asm
jmp @@EndCode
@@StartCode:
cmp eax,ebx
@@EndCode:
{$I DXRender.inc}
end;
genCmpFunc(Code, ZBuffer.CmpFunc, SkipAddress);
end;
 
if ZBuffer.WriteEnable then
begin
case ZBuffer.Surface.BitCount of
8: begin
asm
jmp @@EndCode
@@StartCode:
mov byte ptr [edx],bl
@@EndCode:
{$I DXRender.inc}
end;
end;
16: begin
asm
jmp @@EndCode
@@StartCode:
mov word ptr [edx],bx
@@EndCode:
{$I DXRender.inc}
end;
end;
24: begin
asm
jmp @@EndCode
@@StartCode:
mov word ptr [edx],bx
bswap ebx
mov byte ptr [edx+2],bh
@@EndCode:
{$I DXRender.inc}
end;
end;
32: begin
asm
jmp @@EndCode
@@StartCode:
mov dword ptr [edx],ebx
@@EndCode:
{$I DXRender.inc}
end;
end;
end;
end;
end;
 
procedure genUpdateZBufferAddress(var Code: Pointer);
var
ByteCount: DWORD;
_ZBuf: Pointer;
begin
if not ZBuffer.Enable then Exit;
 
ByteCount := ZBuffer.Surface.BitCount shr 3;
 
_ZBuf := @F_ZBuf;
 
asm
jmp @@EndCode
@@StartCode:
add dword ptr [offset _null],$11{}@@_ZBuf:
@@EndCode:
{$I DXRender.inc}
{ @@_ZBuf }
mov eax,ByteCount
mov edx,offset @@_ZBuf-1
sub edx,offset @@StartCode
mov byte ptr [ecx+edx],al
 
{ @@_ZBuf }
mov eax,_ZBuf
mov edx,offset @@_ZBuf-5
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end;
 
procedure genReadDestPixel(var Code: Pointer);
begin
case Dest.BitCount of
2990,19 → 2623,19
mov dword ptr [ecx+edx],eax
 
{ @@DestR }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@DestR-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@DestG }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@DestG-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@DestB }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@DestB-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3045,19 → 2678,19
mov dword ptr [ecx+edx],eax
 
{ @@DestR }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@DestR-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@DestG }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@DestG-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@DestB }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@DestB-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3099,19 → 2732,19
mov dword ptr [ecx+edx],eax
 
{ @@DestR }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@DestR-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@DestG }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@DestG-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@DestB }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@DestB-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3128,7 → 2761,7
@@EndCode:
{$I DXRender.inc}
{ @@DestR }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R)
mov edx,offset @@DestR-6
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3139,7 → 2772,7
mov word ptr [ecx+edx],ax
 
{ @@DestG }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G)
mov edx,offset @@DestG-6
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3150,7 → 2783,7
mov word ptr [ecx+edx],ax
 
{ @@DestB }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B)
mov edx,offset @@DestB-6
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3192,7 → 2825,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3221,7 → 2854,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3236,7 → 2869,7
@@EndCode:
{$I DXRender.inc}
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A)
mov edx,offset @@Dest-6
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3279,7 → 2912,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3308,7 → 2941,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3323,7 → 2956,7
@@EndCode:
{$I DXRender.inc}
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R)
mov edx,offset @@Dest-6
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3365,7 → 2998,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3394,7 → 3027,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3409,7 → 3042,7
@@EndCode:
{$I DXRender.inc}
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G)
mov edx,offset @@Dest-6
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3451,7 → 3084,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3480,7 → 3113,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3495,7 → 3128,7
@@EndCode:
{$I DXRender.inc}
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B)
mov edx,offset @@Dest-6
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3537,7 → 3170,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3566,7 → 3199,7
mov byte ptr [ecx+edx],al
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3581,7 → 3214,7
@@EndCode:
{$I DXRender.inc}
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A)
mov edx,offset @@Dest-6
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3621,7 → 3254,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3650,7 → 3283,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3685,7 → 3318,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3714,7 → 3347,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3749,7 → 3382,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3778,7 → 3411,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3813,7 → 3446,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3842,7 → 3475,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3902,7 → 3535,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
3992,7 → 3625,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4082,7 → 3715,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4172,7 → 3805,7
@@EndCode:
{$I DXRender.inc}
{ @@Src }
mov eax,Src; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Src; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Src-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4256,13 → 3889,10
procedure genEncodeColor2(var Code: Pointer; const Surface: TDXR_Surface; Src: PDXRMachine_Color; EnableChannels: TDXRColorChannels);
begin
if Dither.Enable then
begin
genEncodeColor_with_Dither(Code, Surface, Src, @Axis.Axis, EnableChannels)
end else
begin
else
genEncodeColor(Code, Surface, Src, EnableChannels);
end;
end;
 
procedure genColorKey(var Code: Pointer; const Texture: TDXRMachine_Reg_Texture);
var
4608,25 → 4238,25
@@EndCode:
{$I DXRender.inc}
{ @@_BiLinearCol1 }
mov eax,_BiLinearCol1; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,_BiLinearCol1; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@_BiLinearCol1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol2 }
mov eax,_BiLinearCol2; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,_BiLinearCol2; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@_BiLinearCol2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol3 }
mov eax,_BiLinearCol3; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,_BiLinearCol3; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@_BiLinearCol3-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol4 }
mov eax,_BiLinearCol4; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,_BiLinearCol4; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@_BiLinearCol4-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4644,7 → 4274,7
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4684,25 → 4314,25
@@EndCode:
{$I DXRender.inc}
{ @@_BiLinearCol1 }
mov eax,_BiLinearCol1; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,_BiLinearCol1; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@_BiLinearCol1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol2 }
mov eax,_BiLinearCol2; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,_BiLinearCol2; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@_BiLinearCol2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol3 }
mov eax,_BiLinearCol3; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,_BiLinearCol3; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@_BiLinearCol3-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol4 }
mov eax,_BiLinearCol4; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,_BiLinearCol4; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@_BiLinearCol4-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4720,7 → 4350,7
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4760,25 → 4390,25
@@EndCode:
{$I DXRender.inc}
{ @@_BiLinearCol1 }
mov eax,_BiLinearCol1; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,_BiLinearCol1; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@_BiLinearCol1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol2 }
mov eax,_BiLinearCol2; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,_BiLinearCol2; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@_BiLinearCol2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol3 }
mov eax,_BiLinearCol3; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,_BiLinearCol3; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@_BiLinearCol3-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol4 }
mov eax,_BiLinearCol4; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,_BiLinearCol4; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@_BiLinearCol4-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4796,7 → 4426,7
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4836,25 → 4466,25
@@EndCode:
{$I DXRender.inc}
{ @@_BiLinearCol1 }
mov eax,_BiLinearCol1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,_BiLinearCol1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@_BiLinearCol1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol2 }
mov eax,_BiLinearCol2; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,_BiLinearCol2; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@_BiLinearCol2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol3 }
mov eax,_BiLinearCol3; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,_BiLinearCol3; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@_BiLinearCol3-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@_BiLinearCol4 }
mov eax,_BiLinearCol4; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,_BiLinearCol4; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@_BiLinearCol4-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4872,7 → 4502,7
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
4884,252 → 4514,12
procedure genReadTexture(var Code: Pointer; Dest: PDXRMachine_Color;
const Texture: TDXRMachine_Reg_Texture; EnableChannels: TDXRColorChannels);
begin
if Texture.Filter in [DXR_TEXTUREFILTER_LINEAR, DXR_TEXTUREFILTER_MIPMAP_LINEAR] then
if Texture.Filter in [DXR_TEXTUREFILTER_LINEAR] then
genReadTexture_BiLinear(Code, Dest, Texture, Texture.nAxis, EnableChannels)
else
genReadTexture_Nearest(Code, Dest, Texture, Texture.nAxis, EnableChannels);
end;
 
procedure genReadBumpTexture_Nearest(var Code: Pointer; Dest: PDXRMachine_Color;
const Texture, BumpTexture: TDXRMachine_Reg_Texture; EnableChannels: TDXRColorChannels);
var
_Axis, _Axis2, _iAxis, _BumpAxis, _BumpAxis2: PDXRMachine_Axis;
_BumpTempCol: Pointer;
begin
if EnableChannels=[] then Exit;
 
_Axis := @BumpTexture.nAxis;
_Axis2 := @Texture.nAxis;
_iAxis := @BumpTexture.iAxis;
_BumpAxis := @F_BumpAxis;
_BumpAxis2 := @F_BumpAxis2;
_BumpTempCol := @F_BumpTempCol;
 
{ X }
asm
jmp @@EndCode
@@StartCode:
mov eax,dword ptr [offset _null]{}@@TexX:
mov edx,dword ptr [offset _null]{}@@TexY:
sub eax,dword ptr [offset _null]{}@@iTexX:
mov dword ptr [offset _null],edx{}@@AxisY:
mov dword ptr [offset _null],eax{}@@AxisX:
@@EndCode:
{$I DXRender.inc}
{ @@TexX }
mov eax,_Axis; add eax,TDXRMachine_Axis.X
mov edx,offset @@TexX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@TexY }
mov eax,_Axis; add eax,TDXRMachine_Axis.Y
mov edx,offset @@TexY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@iTexX }
mov eax,_iAxis; add eax,TDXRMachine_Axis.X
mov edx,offset @@iTexX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@AxisX }
mov eax,_BumpAxis; add eax,TDXRMachine_Axis.X
mov edx,offset @@AxisX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@AxisY }
mov eax,_BumpAxis; add eax,TDXRMachine_Axis.Y
mov edx,offset @@AxisY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
genReadSurfacePixel(Code, BumpTexture, _BumpAxis);
 
asm
jmp @@EndCode
@@StartCode:
mov dword ptr [offset _null],eax{}@@BumpTempCol:
@@EndCode:
{$I DXRender.inc}
{ @@BumpTempCol }
mov eax,_BumpTempCol
mov edx,offset @@BumpTempCol-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
 
asm
jmp @@EndCode
@@StartCode:
mov edx,dword ptr [offset _null]{}@@iAxisX:
add dword ptr [offset _null],edx{}@@AxisX:
@@EndCode:
{$I DXRender.inc}
{ @@iAxisX }
mov eax,_iAxis; add eax,TDXRMachine_Axis.X
mov edx,offset @@iAxisX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@AxisX }
mov eax,_BumpAxis; add eax,TDXRMachine_Axis.X
mov edx,offset @@AxisX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
 
genReadSurfacePixel(Code, BumpTexture, _BumpAxis);
 
asm
jmp @@EndCode
@@StartCode:
sub eax,dword ptr [offset _null]{}@@BumpTempCol:
sal eax,16
add eax,dword ptr [offset _null]{}@@TexX:
mov dword ptr [offset _null],eax{}@@AxisX:
@@EndCode:
{$I DXRender.inc}
{ @@BumpTempCol }
mov eax,_BumpTempCol
mov edx,offset @@BumpTempCol-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@TexX }
mov eax,_Axis2; add eax,TDXRMachine_Axis.X
mov edx,offset @@TexX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@AxisX }
mov eax,_BumpAxis2; add eax,TDXRMachine_Axis.X
mov edx,offset @@AxisX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
 
{ Y }
asm
jmp @@EndCode
@@StartCode:
mov eax,dword ptr [offset _null]{}@@TexX:
mov edx,dword ptr [offset _null]{}@@TexY:
sub edx,dword ptr [offset _null]{}@@iTexY:
mov dword ptr [offset _null],eax{}@@AxisX:
mov dword ptr [offset _null],edx{}@@AxisY:
@@EndCode:
{$I DXRender.inc}
{ @@TexX }
mov eax,_Axis; add eax,TDXRMachine_Axis.X
mov edx,offset @@TexX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@TexY }
mov eax,_Axis; add eax,TDXRMachine_Axis.Y
mov edx,offset @@TexY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@iTexY }
mov eax,_iAxis; add eax,TDXRMachine_Axis.Y
mov edx,offset @@iTexY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@AxisX }
mov eax,_BumpAxis; add eax,TDXRMachine_Axis.X
mov edx,offset @@AxisX-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@AxisY }
mov eax,_BumpAxis; add eax,TDXRMachine_Axis.Y
mov edx,offset @@AxisY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
genReadSurfacePixel(Code, BumpTexture, _BumpTempCol);
 
asm
jmp @@EndCode
@@StartCode:
mov dword ptr [offset _null],eax{}@@BumpTempCol:
@@EndCode:
{$I DXRender.inc}
{ @@BumpTempCol }
mov eax,_BumpTempCol
mov edx,offset @@BumpTempCol-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
 
asm
jmp @@EndCode
@@StartCode:
mov edx,dword ptr [offset _null]{}@@iAxisY:
sal edx,1
sub dword ptr [offset _null],edx{}@@AxisY:
@@EndCode:
{$I DXRender.inc}
{ @@iAxisY }
mov eax,_iAxis; add eax,TDXRMachine_Axis.Y
mov edx,offset @@iAxisY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@AxisY }
mov eax,_BumpAxis; add eax,TDXRMachine_Axis.Y
mov edx,offset @@AxisY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
 
genReadSurfacePixel(Code, BumpTexture, _BumpAxis);
 
asm
jmp @@EndCode
@@StartCode:
sub eax,dword ptr [offset _null]{}@@BumpTempCol:
sal eax,16
add eax,dword ptr [offset _null]{}@@TexY:
mov dword ptr [offset _null],eax{}@@AxisY:
@@EndCode:
{$I DXRender.inc}
{ @@BumpTempCol }
mov eax,_BumpTempCol
mov edx,offset @@BumpTempCol-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@TexX }
mov eax,_Axis2; add eax,TDXRMachine_Axis.Y
mov edx,offset @@TexY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@AxisX }
mov eax,_BumpAxis2; add eax,TDXRMachine_Axis.Y
mov edx,offset @@AxisY-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
 
genReadTexture_Nearest(Code, Dest, Texture, _BumpAxis2^, EnableChannels);
end;
 
procedure genReadBumpTexture(var Code: Pointer; Dest: PDXRMachine_Color;
const Texture, BumpTexture: TDXRMachine_Reg_Texture; EnableChannels: TDXRColorChannels);
begin
{if Texture.Filter in [DXR_TEXTUREFILTER_LINEAR, DXR_TEXTUREFILTER_MIPMAP_LINEAR] then
genReadBumpTexture_BiLinear(Code, Dest, Texture, BumpTexture, EnableChannels)
else }
genReadBumpTexture_Nearest(Code, Dest, Texture, BumpTexture, EnableChannels);
end;
 
procedure genUpdateAxis(var Code: Pointer);
var
_Axis: Pointer;
5137,7 → 4527,6
if not Axis.IncEnable then Exit;
 
_Axis := @Axis.Axis;
 
asm
jmp @@EndCode
@@StartCode:
5266,40 → 4655,6
nTex := @Texture.nAxis;
iTex := @Texture.iAxis;
 
if UseMMX then
begin
FMMXUsed := True;
asm
jmp @@EndCode
@@StartCode:
db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
@@nTex:
db $0F,$FE,$05,$11,$11,$11,$11///paddd mm0,qword ptr [$11111111]
@@iTex:
db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
@@nTex2:
@@EndCode:
{$I DXRender.inc}
{ @@nTex }
mov eax,nTex
mov edx,offset @@nTex-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@nTex2 }
mov eax,nTex
mov edx,offset @@nTex2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@iTex }
mov eax,iTex
mov edx,offset @@iTex-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end else
begin
if Texture.iAxisConstant then
begin
if Texture.iAxis.X<>0 then
5344,7 → 4699,7
end;
end;
end else
//begin
begin
if UseMMX then
begin
FMMXUsed := True;
5379,7 → 4734,6
end;
end else
begin
 
asm
jmp @@EndCode
@@StartCode:
5418,51 → 4772,6
end;
end;
 
procedure genUpdateRHW(var Code: Pointer);
var
nRHW, iRHW: Pointer;
begin
if not RHW.Enable then Exit;
 
nRHW := @RHW.nRHW;
iRHW := @RHW.iRHW;
 
asm
jmp @@EndCode
@@StartCode:
// 64 bit addition
mov eax,dword ptr [offset _null]{}@@iRHW:
mov edx,dword ptr [offset _null]{}@@iRHW2:
add dword ptr [offset _null],eax{}@@nRHW:
adc dword ptr [offset _null],edx{}@@nRHW2:
@@EndCode:
{$I DXRender.inc}
{ @@nRHW }
mov eax,nRHW
mov edx,offset @@nRHW-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@nRHW2 }
mov eax,nRHW; add eax,4
mov edx,offset @@nRHW2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@iRHW }
mov eax,iRHW
mov edx,offset @@iRHW-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@iRHW }
mov eax,iRHW; add eax,4
mov edx,offset @@iRHW2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end;
 
procedure genBlend(var Code: Pointer; Blend: TDXR_Blend;
Dest, Col1, Col2: PDXRMachine_Color; EnableChannels: TDXRColorChannels;
ConstChannels1, ConstChannels2: TDXRColorChannels);
5619,7 → 4928,7
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
5654,7 → 4963,7
begin
if Dest=Col1 then Exit;
 
if UseMMX then //False then//UseMMX then
if UseMMX then
begin
FMMXUsed := True;
asm
5763,9 → 5072,8
@@StartCode:
db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
@@Col1:
db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
db $0F,$DD,$05,$11,$11,$11,$11/// paddusw mm0,qword ptr [$11111111]
@@Col2:
db $0F,$DD,$C1 ///paddusw mm0,mm1
db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
@@Dest:
@@EndCode:
5848,102 → 5156,6
end;
end;
 
procedure genBlend_ONE2_SUB_ONE1(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
ConstChannels1, ConstChannels12: TDXRColorChannels);
begin
if UseMMX then
begin
FMMXUsed := True;
asm
jmp @@EndCode
@@StartCode:
db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
@@Col1:
db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
@@Col2:
db $0F,$D9,$C8 ///psubusw mm1,mm0
db $0F,$7F,$0D,$11,$11,$11,$11///movq qword ptr [$11111111],mm1
@@Dest:
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end else
begin
{ Red Channel }
if chRed in EnableChannels then
begin
if chRed in ConstChannels1 then
begin
Func_col1_Sub_const2(Code, @Dest.R, @Col2.R, @Col1.R);
end else
if chRed in ConstChannels2 then
begin
Func_const1_Sub_col2(Code, @Dest.R, @Col1.R, @Col2.R);
end else
Func_col1_Sub_col2(Code, @Dest.R, @Col2.R, @Col1.R);
end;
 
{ Green Channel }
if chRed in EnableChannels then
begin
if chRed in ConstChannels1 then
begin
Func_col1_Sub_const2(Code, @Dest.G, @Col2.G, @Col1.G);
end else
if chRed in ConstChannels2 then
begin
Func_const1_Sub_col2(Code, @Dest.G, @Col1.G, @Col2.G);
end else
Func_col1_Sub_col2(Code, @Dest.G, @Col2.G, @Col1.G);
end;
 
{ Blue Channel }
if chRed in EnableChannels then
begin
if chRed in ConstChannels1 then
begin
Func_col1_Sub_const2(Code, @Dest.B, @Col2.B, @Col1.B);
end else
if chRed in ConstChannels2 then
begin
Func_const1_Sub_col2(Code, @Dest.B, @Col1.B, @Col2.B);
end else
Func_col1_Sub_col2(Code, @Dest.B, @Col2.B, @Col1.B);
end;
 
{ Alpha Channel }
if chRed in EnableChannels then
begin
if chRed in ConstChannels1 then
begin
Func_col1_Sub_const2(Code, @Dest.A, @Col2.A, @Col1.A);
end else
if chRed in ConstChannels2 then
begin
Func_const1_Sub_col2(Code, @Dest.A, @Col1.A, @Col2.A);
end else
Func_col1_Sub_col2(Code, @Dest.A, @Col2.A, @Col1.A);
end;
end;
end;
 
procedure genBlend_ONE1_SUB_ONE2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
ConstChannels1, ConstChannels12: TDXRColorChannels);
begin
6091,19 → 5303,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6121,19 → 5333,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6151,19 → 5363,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6181,19 → 5393,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6212,7 → 5424,7
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6255,13 → 5467,13
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6279,13 → 5491,13
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6330,13 → 5542,13
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6354,13 → 5566,13
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6379,7 → 5591,7
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6399,19 → 5611,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6432,19 → 5644,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6465,19 → 5677,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6498,19 → 5710,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6528,7 → 5740,7
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6549,19 → 5761,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6583,19 → 5795,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6617,19 → 5829,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6651,19 → 5863,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6683,7 → 5895,7
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6741,19 → 5953,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6775,19 → 5987,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6847,19 → 6059,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6881,19 → 6093,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6914,7 → 6126,7
@@EndCode:
{$I DXRender.inc}
{ @@Col1A }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1A-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
6972,19 → 6184,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7006,19 → 6218,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7078,19 → 6290,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7112,19 → 6324,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7210,13 → 6422,13
@@EndCode:
{$I DXRender.inc}
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7224,7 → 6436,7
end;
end;
 
procedure genBlend_MODULATE(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
procedure genBlend_MODULATE_RGBONLY(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
ConstChannels1, ConstChannels12: TDXRColorChannels);
begin
if chRed in EnableChannels then
7238,19 → 6450,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7268,19 → 6480,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7298,19 → 6510,19
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7327,13 → 6539,13
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7341,166 → 6553,6
end;
end;
 
procedure genBlend_MODULATEALPHA(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
ConstChannels1, ConstChannels12: TDXRColorChannels);
begin
if UseMMX then
begin
FMMXUsed := True;
asm
jmp @@EndCode
@@StartCode:
db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
@@Col1:
db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
@@Col2:
db $0F,$E5,$C1 ///pmulhw mm0,mm1
db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
@@Dest:
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,offset Dest
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end else
begin
if chRed in EnableChannels then
begin
asm
jmp @@EndCode
@@StartCode:
mov al,byte ptr [offset offset _null]{}@@Col1:
mul byte ptr [offset offset _null] {}@@Col2:
mov byte ptr [offset offset _null],ah{}@@Dest:
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end;
 
if chGreen in EnableChannels then
begin
asm
jmp @@EndCode
@@StartCode:
mov al,byte ptr [offset offset _null]{}@@Col1:
mul byte ptr [offset offset _null] {}@@Col2:
mov byte ptr [offset offset _null],ah{}@@Dest:
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end;
 
if chBlue in EnableChannels then
begin
asm
jmp @@EndCode
@@StartCode:
mov al,byte ptr [offset offset _null]{}@@Col1:
mul byte ptr [offset offset _null] {}@@Col2:
mov byte ptr [offset offset _null],ah{}@@Dest:
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end;
 
if chAlpha in EnableChannels then
begin
asm
jmp @@EndCode
@@StartCode:
mov al,byte ptr [offset offset _null]{}@@Col1:
mul byte ptr [offset offset _null] {}@@Col2:
mov byte ptr [offset offset _null],ah{}@@Dest:
@@EndCode:
{$I DXRender.inc}
{ @@Col1 }
mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
mov edx,offset @@Col1-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
end;
end;
end;
end;
 
procedure genBlend_ADD(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
ConstChannels1, ConstChannels12: TDXRColorChannels);
begin
7549,13 → 6601,13
@@EndCode:
{$I DXRender.inc}
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7616,13 → 6668,13
@@EndCode:
{$I DXRender.inc}
{ @@Col2 }
mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Col2-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
 
{ @@Dest }
mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
mov edx,offset @@Dest-4
sub edx,offset @@StartCode
mov dword ptr [ecx+edx],eax
7640,7 → 6692,7
DXR_BLEND_ONE2 : genBlend_ONE1(Code, Dest, Col2, ConstChannels2);
DXR_BLEND_ONE1_ADD_ONE2 : genBlend_ONE1_ADD_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_ONE1_SUB_ONE2 : genBlend_ONE1_SUB_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_ONE2_SUB_ONE1 : genBlend_ONE2_SUB_ONE1(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_ONE2_SUB_ONE1 : genBlend_ONE1_SUB_ONE2(Code, Dest, Col2, Col1, ConstChannels2, ConstChannels1);
DXR_BLEND_ONE1_MUL_ONE2 : genBlend_ONE1_MUL_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_SRCALPHA1 : genBlend_SRCALPHA1(Code, Dest, Col1, ConstChannels1);
DXR_BLEND_SRCALPHA1_ADD_ONE2 : genBlend_SRCALPHA1_ADD_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7647,10 → 6699,8
DXR_BLEND_ONE2_SUB_SRCALPHA1 : genBlend_ONE2_SUB_SRCALPHA1(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_SRCALPHA1_ADD_INVSRCALPHA2: genBlend_SRCALPHA1_ADD_INVSRCALPHA2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_INVSRCALPHA1_ADD_SRCALPHA2: genBlend_INVSRCALPHA1_ADD_SRCALPHA2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_DECAL : genBlend_ONE1(Code, Dest, Col1, ConstChannels1);
DXR_BLEND_DECALALPHA : genBlend_DECALALPHA(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_MODULATE : genBlend_MODULATE(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_MODULATEALPHA : genBlend_MODULATEALPHA(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_MODULATE : genBlend_MODULATE_RGBONLY(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
DXR_BLEND_ADD : genBlend_ADD(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
end;
end;
7688,10 → 6738,6
begin
genReadTexture(Code, Result, TextureList[Tree.Texture], Tree.Channels);
end;
DXR_TREETYPE_LOADBUMPTEXTURE:
begin
genReadBumpTexture(Code, Result, TextureList[Tree.Texture], TextureList[Tree.BumpTexture], Tree.Channels);
end;
DXR_TREETYPE_LOADDESTPIXEL:
begin
genReadDestPixel(Code);
7837,7 → 6883,7
Col: PDXRMachine_Color;
begin
if (Tree.Typ=DXR_TREETYPE_LOADCOLOR) and (not ColorList[Tree.Color].Gouraud) and
(not ZBuffer.Enable) and (not Dither.Enable) and (Dest.BitCount in [16, 32]) then
(not Dither.Enable) and (Dest.BitCount in [16, 32]) then
begin
FCall := Code;
genInitDestAddress(Code);
7926,9 → 6972,7
genUpdateAxis(Code);
genUpdateColor(Code);
genUpdateTextureAxis(Code);
genUpdateRHW(Code);
genUpdateDestAddress(Code);
genUpdateZBufferAddress(Code);
 
asm
jmp @@EndCode
7942,8 → 6986,6
{ ----------- Main ----------- }
MainCode := Code;
 
genZBufferTest(Code);
 
if Tree.Typ=DXR_TREETYPE_LOADCOLOR then
begin
genEncodeColor2(Code, Dest^, @ColorList[Tree.Color].nColor, Tree.Channels);
7950,7 → 6992,7
genWriteDestPixel(Code);
end else
if (Tree.Typ=DXR_TREETYPE_LOADTEXTURE) and (not Dither.Enable) and
(TextureList[Tree.Texture].Filter in [DXR_TEXTUREFILTER_NEAREST, DXR_TEXTUREFILTER_MIPMAP_NEAREST]) and
(TextureList[Tree.Texture].Filter in [DXR_TEXTUREFILTER_NEAREST]) and
(dxrCompareSurface(Dest^, TextureList[Tree.Texture].Surface^)) then
begin
genReadSurfacePixel(Code, TextureList[Tree.Texture], @TextureList[Tree.Texture].nAxis);
7969,7 → 7011,6
FCall := Code;
 
genInitDestAddress(Code);
genInitZBuffer(Code);
 
genCmpFunc(Code, DXR_CMPFUNC_ALWAYS, MainCode);
end;
8034,10 → 7075,7
TexBlend := DXR_BLEND_MODULATE;
Blend := DXR_BLEND_ONE1;
TextureFilter := DXR_TEXTUREFILTER_NEAREST;
ZBuffer := nil;
ZFunc := DXR_CMPFUNC_LESSEQUAL;
ZWriteEnable := True;
EnableDrawLine := 0;
EnableDrawLine := $FFFFFFFF;
end;
 
for i:=0 to DXR_MAXTEXTURE-1 do
8049,7 → 7087,6
ColorKeyEnable := False;
ColorKey := 0;
TextureAddress := DXR_TEXTUREADDRESS_TILE;
BumpTexture := -1;
end;
end;
 
8071,9 → 7108,6
 
function InitGenerator_MakeTree_LoadTexture(Texture: Integer): PDXRMachine_Tree;
begin
if States.TextureList[Texture].BumpTexture>=0 then
Result := DXRMachine.CreateTree_LoadBumpTexture(Texture, States.TextureList[Texture].BumpTexture)
else
Result := DXRMachine.CreateTree_LoadTexture(Texture);
end;
 
8134,17 → 7168,11
var
i: Integer;
Layer: PDXR_TextureLayer;
Mipmap1, Mipmap2, Mipmap3: Integer;
TmpSurface2: PDXR_Surface;
begin
DXRMachine.Initialize;
 
{ Parameter setting }
DXRMachine.Dest := @Dest;
DXRMachine.ZBuffer.Enable := States.ZBuffer<>nil;
DXRMachine.ZBuffer.Surface := States.ZBuffer;
DXRMachine.ZBuffer.CmpFunc := States.ZFunc;
DXRMachine.ZBuffer.WriteEnable := States.ZWriteEnable;
DXRMachine.Dither.Enable := States.DitherEnable;
 
DXRMachine.ColorList[0].Gouraud := States.Shade=DXR_SHADEMODE_GOURAUD;
8164,34 → 7192,9
Surface := Layer.Surface;
Filter := States.TextureFilter;
TextureAddress := Layer.TextureAddress;
 
if (Filter in [DXR_TEXTUREFILTER_MIPMAP_NEAREST, DXR_TEXTUREFILTER_MIPMAP_LINEAR]) and
(Surface.MipmapChain<>nil) then
begin
{ Mipmap }
Mipmap1 := MaxInt;
Mipmap3 := Trunc(Abs(Hypot(Tri[2].sx-Tri[1].sx, Tri[2].sy-Tri[1].sy))*
Abs(Hypot(Tri[1].sx-Tri[0].sx, Tri[1].sy-Tri[0].sy))*
Abs(Hypot(Tri[2].sx-Tri[0].sx, Tri[2].sy-Tri[0].sy))/9);
 
TmpSurface2 := Surface;
 
while TmpSurface2<>nil do
begin
Mipmap2 := TmpSurface2.Width2*TmpSurface2.Height2;
 
if (Abs(Mipmap3-Mipmap2)<Abs(Mipmap3-Mipmap1)) then
begin
Surface := TmpSurface2;
Mipmap1 := Mipmap2;
end;
 
TmpSurface2 := TmpSurface2.MipmapChain;
end;
end;
end;
end;
end;
 
{ Tree making }
DXRMachine.Compile(InitGenerator_MakeTree);
8232,15 → 7235,9
Result := Comp2DWORD(d*TexYFloat[i]);
end;
 
function FloatToRHWFloat(d: Extended): Comp;
begin
Result := d*Int32Value;
end;
 
procedure drawline(x1, x2, y: Integer;
const x_ntex1, x_ntex2: T2DAxis64Array;
const x_nc1, x_nc2: TCol64Array;
const x_nRHW1, x_nRHW2: Comp);
const x_nc1, x_nc2: TCol64Array);
var
i, xcount, xcount2, ofs: Integer;
begin
8314,17 → 7311,6
end;
end;
 
with DXRMachine.RHW do
begin
if Enable then
begin
nRHW := x_nRHW1;
iRHW := (x_nRHW2-x_nRHW1) / xcount;
if ofs<>0 then
nRHW := nRHW + iRHW*ofs;
end;
end;
 
DXRMachine.Run(xcount2);
end;
 
8335,7 → 7321,6
y_nx1, y_nx2, y_ix1, y_ix2: Comp;
y_ntex1, y_ntex2, y_itex1, y_itex2: T2DAxis64Array;
y_nc1, y_nc2, y_ic1, y_ic2: TCol64Array;
y_nRHW1, y_nRHW2, y_iRHW1, y_iRHW2: Comp;
begin
if ycount<=0 then Exit;
if y1=0 then Exit;
8451,40 → 7436,15
end;
end;
 
if DXRMachine.RHW.Enable then
begin
y_nRHW1 := FloatToRHWFloat(p1.rhw);
y_nRHW2 := FloatToRHWFloat(p2.rhw);
y_iRHW1 := FloatToRHWFloat((pt1.rhw-p1.rhw)/y1);
y_iRHW2 := FloatToRHWFloat((pt2.rhw-p2.rhw)/y2);
 
if ofs1<>0 then
begin
y_nRHW1 := y_nRHW1 + y_iRHW1*ofs1;
end;
 
if ofs2<>0 then
begin
y_nRHW2 := y_nRHW2 + y_iRHW2*ofs2;
end;
end else
begin
y_nRHW1 := 0;
y_nRHW2 := 0;
y_iRHW1 := 0;
y_iRHW2 := 0;
end;
 
for y:=starty to starty+ycount-1 do
begin
if (States.EnableDrawLine=0) or ((States.EnableDrawLine-1)=y mod 2) then
if States.EnableDrawLine and (1 shl (y and 31))<>0 then
if PInteger(Integer(@y_nx1)+4)^<PInteger(Integer(@y_nx2)+4)^ then
begin
drawline(
PInteger(Integer(@y_nx1)+4)^, PInteger(Integer(@y_nx2)+4)^, y,
y_ntex1, y_ntex2,
y_nc1, y_nc2,
y_nRHW1, y_nRHW2
y_nc1, y_nc2
);
end else if PInteger(Integer(@y_nx1)+4)^>PInteger(Integer(@y_nx2)+4)^ then
begin
8491,8 → 7451,7
drawline(
PInteger(Integer(@y_nx2)+4)^, PInteger(Integer(@y_nx1)+4)^, y,
y_ntex2, y_ntex1,
y_nc2, y_nc1,
y_nRHW2, y_nRHW1
y_nc2, y_nc1
);
end;
 
8523,14 → 7482,8
y_nc2[i].A := y_nc2[i].A + y_ic2[i].A;
end;
end;
 
if DXRMachine.RHW.Enable then
begin
y_nRHW1 := y_nRHW1 + y_iRHW1;
y_nRHW2 := y_nRHW2 + y_iRHW2;
end;
end;
end;
 
var
p: array[0..2] of PDXR_Vertex;
8568,9 → 7521,6
if (p[0].sx>=Dest.Width) and (p[1].sx>=Dest.Width) and (p[2].sx>=Dest.Width) then Exit;
 
{ Generate code }
if States.TextureFilter in [DXR_TEXTUREFILTER_MIPMAP_NEAREST, DXR_TEXTUREFILTER_MIPMAP_LINEAR] then
DXRMachine.Compiled := False;
 
if not DXRMachine.Compiled then
InitGenerator;
 
8722,30 → 7672,25
end;
end;
 
//function MulDiv64(a, b, c: Integer): Integer; assembler;
//asm
// mov eax, a
// imul b
// idiv c
//end;
 
function MulDiv64(a, b, c: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
begin
Result := a * b div c;
function MulDiv64(a, b, c: Integer): Integer; assembler;
asm
mov eax, a
imul b
idiv c
end;
 
function Max(B1, B2: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
function Max(B1, B2: Integer): Integer;
begin
if B1>=B2 then Result := B1 else Result := B2;
end;
 
function Min(B1, B2: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
function Min(B1, B2: Integer): Integer;
begin
if B1<=B2 then Result := B1 else Result := B2;
end;
 
function BltClipX(const Dest, Src: TDXR_Surface;
var StartX, EndX, StartSrcX: Integer): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
var StartX, EndX, StartSrcX: Integer): Boolean;
begin
if StartX<0 then
begin
8759,7 → 7704,7
end;
 
function BltClipY(const Dest, Src: TDXR_Surface;
var StartY, EndY, StartSrcY: Integer): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
var StartY, EndY, StartSrcY: Integer): Boolean;
begin
if StartY<0 then
begin
8773,7 → 7718,7
end;
 
function BltClip(const Dest, Src: TDXR_Surface;
var StartX, StartY, EndX, EndY, StartSrcX, StartSrcY: Integer): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
var StartX, StartY, EndX, EndY, StartSrcX, StartSrcY: Integer): Boolean;
begin
Result := BltClipX(Dest, Src, StartX, EndX, StartSrcX) and
BltClipY(Dest, Src, StartY, EndY, StartSrcY);
8780,7 → 7725,7
end;
 
function FillClip(const Dest: TDXR_Surface;
var StartX, StartY, EndX, EndY: Integer): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
var StartX, StartY, EndX, EndY: Integer): Boolean;
begin
StartX := Max(StartX, 0);
StartY := Max(StartY, 0);
8793,7 → 7738,7
var
CosinTable: array[0..255] of Double;
 
procedure InitCosinTable; {$IFDEF VER9UP}inline;{$ENDIF}
procedure InitCosinTable;
var
i: Integer;
begin
8801,12 → 7746,12
CosinTable[i] := Cos((i/256)*2*PI);
end;
 
function Cos256(i: Integer): Double; {$IFDEF VER9UP}inline;{$ENDIF}
function Cos256(i: Integer): Double;
begin
Result := CosinTable[i and 255];
end;
 
function Sin256(i: Integer): Double; {$IFDEF VER9UP}inline;{$ENDIF}
function Sin256(i: Integer): Double;
begin
Result := CosinTable[(i+192) and 255];
end;
9127,23 → 8072,10
end;
end;
 
//var TextureSurface, DestSurface: TDXR_Surface; RenderStates: TDXR_RenderStates;
//
//dxrDefRenderStates(RenderStates);
//if dxrDDSurfaceLock(Surf.ISurface, DestSurface then begin
// dxrDDSurfaceLock(TextureSurface as IDirectDrawSurface, TextureSurface);
// RenderStates.TextureList<0>.Surface:=@TextureSurface;
// dxrDrawPrimitive(DestSurface, RenderStates, DXR_PRIMITIVETYPE_TRIANGLELIST, @VertexList, 36);
// dxrDDSurfaceUnlock(SurfaceTexture as IDirectDrawSurface, TextureSurface);
// dxrDDSurfaceUnlock(Surf.ISurface, DestSurface);
//end;
 
initialization
ReadCPUID;
Init;
InitCosinTable;
 
dxrSetOption(DXR_OPTION_MMXENABLE, 1);
finalization
FDXRMachine.Free;
end.
end.
/VCL_DELPHIX_D6/DShow.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXGUIDEdit.dfm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/VCL_DELPHIX_D6/DelphiX.dcr
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/VCL_DELPHIX_D6/DShow.pas
22,9 → 22,7
 
{$Z4}
{$A+}
{$IfNDef D7UP}
{$WEAKPACKAGEUNIT}
{$EndIf}
 
uses Windows, ActiveX, DirectX, MMSystem;
 
1889,10 → 1887,10
 
IDirectDrawMediaStream = interface(IMediaStream)
['{F4104FCE-9A70-11d0-8FDE-00C04FD9189D}']
function GetFormat(var pDDSDCurrent: TDDSURFACEDESC;
function GetFormat(var pDDSDCurrent: DDSURFACEDESC;
out ppDirectDrawPalette: IDirectDrawPalette;
var pDDSDDesired: TDDSURFACEDESC; var pdwFlags: DWORD): HResult; stdcall;
function SetFormat(const pDDSurfaceDesc: TDDSURFACEDESC;
var pDDSDDesired: DDSURFACEDESC; var pdwFlags: DWORD): HResult; stdcall;
function SetFormat(const pDDSurfaceDesc: DDSURFACEDESC;
pDirectDrawPalette: IDirectDrawPalette): HResult; stdcall;
function GetDirectDraw(out ppDirectDraw: IDirectDraw): HResult; stdcall;
function SetDirectDraw(pDirectDraw: IDirectDraw): HResult; stdcall;
2622,9 → 2620,9
// IDirectDrawVideo methods
function GetSwitches(var pSwitches: DWORD): HResult; stdcall;
function SetSwitches(pSwitches: DWORD): HResult; stdcall;
function GetCaps(var pCaps: TDDCAPS): HResult; stdcall;
function GetEmulatedCaps(var pCaps: TDDCAPS): HResult; stdcall;
function GetSurfaceDesc(var pSurfaceDesc: TDDSURFACEDESC): HResult; stdcall;
function GetCaps(var pCaps: DDCAPS): HResult; stdcall;
function GetEmulatedCaps(var pCaps: DDCAPS): HResult; stdcall;
function GetSurfaceDesc(var pSurfaceDesc: DDSURFACEDESC): HResult; stdcall;
function GetFourCCCodes(var pCount, pCodes: DWORD): HResult; stdcall;
function SetDirectDraw(pDirectDraw: IDirectDraw): HResult; stdcall;
function GetDirectDraw(out ppDirectDraw: IDirectDraw): HResult; stdcall;
3003,23 → 3001,23
// of structures. If the pointer to the array is NULL, first parameter
// returns the total number of formats supported.
function GetVideoFormats(var lpNumFormats: DWORD;
const lpddpfFormats: TDDPIXELFORMAT): HResult; stdcall;
const lpddpfFormats: DDPIXELFORMAT): HResult; stdcall;
 
// retrives maximum pixels per second rate expected for a given
// format and a given scaling factor. If decoder does not support
// those scaling factors, then it gives the rate and the nearest
// scaling factors.
function GetMaxPixelRate(const ddpfFormat: TDDPIXELFORMAT;
function GetMaxPixelRate(const ddpfFormat: DDPIXELFORMAT;
lpdwZoomHeight, lpdwZoomWidth: DWORD;
var lpdwMaxPixelsPerSecond: DWORD): HResult; stdcall;
 
// retrives various properties of the decoder for a given format
function GetVideoSignalInfo(const ddpfFormat: TDDPIXELFORMAT;
function GetVideoSignalInfo(const ddpfFormat: DDPIXELFORMAT;
var lpAMVideoSignalInfo: TAMVideoSignalInfo): HResult; stdcall;
 
// asks the decoder to ouput in this format. Return value should give
// appropriate error code
function SetVideoFormat(const ddpfFormat: TDDPIXELFORMAT): HResult; stdcall;
function SetVideoFormat(const ddpfFormat: DDPIXELFORMAT): HResult; stdcall;
 
// asks the decoder to treat even fields like odd fields and visa versa
function SetInvertPolarity: HResult; stdcall;
3187,13 → 3185,13
 
// informs the callee of the videoformats supported by the videoport
function InformVPInputFormats(dwNumFormats: DWORD;
const pDDPixelFormats: TDDPIXELFORMAT): HResult; stdcall;
const pDDPixelFormats: DDPIXELFORMAT): HResult; stdcall;
 
// gets the various formats supported by the decoder in an array
// of structures. If the pointer to the array is NULL, first parameter
// returns the total number of formats supported.
function GetVideoFormats(var pdwNumFormats: DWORD;
var pddPixelFormats: TDDPIXELFORMAT): HResult; stdcall;
var pddPixelFormats: DDPIXELFORMAT): HResult; stdcall;
 
// sets the format entry chosen (0, 1, .. ,(dwNumProposedEntries-1))
function SetVideoFormat(dwChosenEntry: DWORD): HResult; stdcall;
3271,10 → 3269,10
// this function gets the overlay surface that the mixer is using
function GetOverlaySurface(out ppOverlaySurface: IDirectDrawSurface): HResult; stdcall;
// this functions sets the color-controls, if the chip supports it.
function SetColorControls(const pColorControl: TDDCOLORCONTROL): HResult; stdcall;
function SetColorControls(const pColorControl: DDCOLORCONTROL): HResult; stdcall;
// this functions also returns the capability of the hardware in the dwFlags
// value of the struct.
function GetColorControls(var pColorControl: TDDCOLORCONTROL): HResult; stdcall;
function GetColorControls(var pColorControl: DDCOLORCONTROL): HResult; stdcall;
end;
 
// interface IVPVBINotify
/VCL_DELPHIX_D6/DXPictEdit.dfm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/VCL_DELPHIX_D6/DIB.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXFFBEdit.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXWaveEdit.dfm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/VCL_DELPHIX_D6/DXClass.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DXSprite.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/DirectX.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/Wave.dcu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/VCL_DELPHIX_D6/.
Property changes:
Deleted: svn:ignore
-*.local
-*.dcu
-*.~*
-*.identcache
-*.tvsconfig
-__history
-*.exe