Very new to BMax: I need help here with DLL's

BlitzMax Forums/BlitzMax Programming/Very new to BMax: I need help here with DLL's

hi!

i need some help here using the kernel32 dll!

this is a bb program
;;the DECLS part:
;.lib "kernel32.dll"
;apiRtlMoveMemory(Destination*,Source,Length):"RtlMoveMemory"
;apiRtlMoveMemory2(Destination,Source*,Length):"RtlMoveMemory"

Const gw = 1280
Const gh = 1024
Const gw1 = gw - 1
Const gh1 = gh - 1
Graphics gw, gh, 32, 2
SetBuffer BackBuffer()

bnkVideo = CreateBank(gw * gh * 4)

w4 = gw * 4
While Not KeyHit(1)
	x = 0
	mx = gw * gh * 4
	col = Rand($000000, $FFFFFF)
	While x < mx
		PokeInt bnkVideo, x, col
		x = x + 4
	Wend
	LockBuffer()
	bnkInfo = CreateBank(32)
	vgliApiRtlMoveMemory bnkInfo, GraphicsBuffer() + 72, 32
	size = PeekInt(bnkInfo, 20) * PeekInt(bnkInfo, 24) * PeekInt(bnkInfo, 28) / 8
	If BankSize(bnkVideo) < size Or PeekInt(bnkInfo, 0) = 0 Then
		FreeBank bnkInfo
		RuntimeError "Failed to draw on buffer."
	Else
		vgliApiRtlMoveMemory2 PeekInt(bnkInfo, 0), bnkVideo, size
		FreeBank bnkInfo
	EndIf
	UnlockBuffer()
	Text 10, 10, "Poke method!"
	Text 10, 25, "FPS: " + GetFPS()
	Flip 0
Wend

Global FPS, FPSFrame, FPSTime
Function GetFPS(ms = 1000)
ctime = MilliSecs()
FPSFrame = FPSFrame + 1
If ctime - FPSTime > ms Then
	FPS = FPSFrame * 1000 / ms
	FPSFrame = 0
	FPSTime = ctime
EndIf
Return FPS
End Function


it contains a library in which you can easily set up pixels. i tried to port it to bmax, but first i needed to import the kernel DLL, but i just didn't figure out how :(

can somebody help me here, please?
thanks a lot :)

Something like
Extern "Win32"
	Function apiRtlMoveMemory(Destination:Byte Ptr,Source:Byte Ptr,Length)="RtlMoveMemory@12"
EndExtern

or
Extern "Win32"
	Function RtlMoveMemory(Destination:Byte Ptr,Source:Byte Ptr,Length)
EndExtern


and what exactly do i do with this?
you know i'm a pro in BB and a beginner in bmax

BlitzMax has a MemCopy command which can be used instead. It takes two pointers and a length, just as yours do.

EDIT: Not that there's anything wrong with Azathoth's response. I just cross-posted.

wow quick answer :)

so, how do i USE this command instead of that one?

It defines the function RtlMoveMemory, you put it at the top of your program.

Edit: If you're uncertain whether the memory blocks over lap you could use MemMove, instead of MemCopy.

Extern "Win32"
	Function RtlMoveMemory(Destination:Byte Ptr,Source:Byte Ptr,Length)
EndExtern


so i only put in this piece of code, and i can use RtlMoveMemory as default?

and how do i access the BackBuffer ?

so i only put in this piece of code, and i can use RtlMoveMemory as default?
Yep.

and how do i access the BackBuffer ?
i need the pointer of the backbuffer

well thats just whats missing. i need the pointer to the backbuffer. in BB you usualy get this with BackBuffer()

There's not the same easy way in Bmax as far as I know.
You can try the following :
graphics800,600
Local renderSurf:IDirectDrawSurface7
D3D7GraphicsDriver().Direct3DDevice7().GetRenderTarget Varptr renderSurf

to get one from DX.