New Helper Userlib

Blitz3D Forums/Blitz3D Userlibs/New Helper Userlib

Apocalypse(Posted 2005) [#1]
I've started work on a helper DLL for Blitz3D and was wondering if anyone would be interested in trying it out and maybe making some suggestions as to added functions. I intend to release the DLL as freeware when I am done. All I would ask is that I am listed in the credits somewhere if you use it.

Download the DLL here...

http://www.imakegames.com/B3DHLP.dll


Here are the functions I've done so far...

FmtStr$ - allows you to format a number like "#,###.00"
(This function suffers from Blitz's lack of extended precision)

DiskSpaceFree - Returns free Space of HD in megabytes
DiskSpaceTotal - Returns total space of HD in megabytes

SetBit - Allows setting an individual bit of a variable
ResetBit - Allows resetting an individial bit of a variable
TestBit - Returns whether a bit is on or off in a variable

SaveBank - Allows you to save the entire contents of a Bank at once

LoadBank - Allows you to load an entire Bank's contents from a file.

Here are the .decls...

.lib "B3DHLP.dll"
SaveBank% (pBank%, Filename$):"SAVEBANK"
LoadBank% (pBank%, Filename$):"LOADBANK"
FmtStr$ (InVal$ , pFmt$):"FMTSTR"
DiskSpaceFree% (Drive$):"DISKSPACEFREE"
DiskSpaceTotal% (Drive$):"DISKSPACETOTAL"
SetBit% (dwVal%, BitPos%):"SETBIT"
ResetBit% (dwVal%, BitPos%):"RESETBIT"
TestBit% (dwVal%, BitPos%):"TESTBIT"


Apocalypse(Posted 2005) [#2]
I am still working on accessing image memory. That seems to be a tough nut for me to crack. When I finally get it I am going to make routines to swap Bank and Image memory. I am also going to make some functions for checking if files and directories already exist.


jfk EO-11110(Posted 2005) [#3]
Seems like some of it is very useful, although the Bit Commands could be realised in Blitz easily:

function Testbit(bit,value); for bit 1 to bit 32
 return ((2^(bit-1)) and value)/(2^(bit-1))
end function


However, if is is possible to start the LoadBank task as a parallel thread, this would give us a lot of new possibilities, like loading content without to stop execution of other things. Youcouldalso use an additional small bank to exchange information about the state of the Bank Loading (like, Bitz sets the state-bank to zero and the DLL sets it to 1 if loading is complete)

This way we could even do things like loading streaming Maps.

BTW. isn't there some way to set up a ramdisk by code? I know, in Windows this is much more complicated, but in the good old days of DOS, Atari and Amiga, it was pretty easy to write a ramdisk to extract data to it and then load it with Media commands.


Apocalypse(Posted 2005) [#4]
Seems like some of it is very useful, although the Bit Commands could be realised in Blitz easily:


These functions were included from a previous request, and there are ways to set these bits in code, but if speed is a concern, the DLL can modify the bits in 2 or 3 CPU cycles/per call, whereas your example would require many more by performing at least 6 math operations.

As far as threading, i'm not sure Blitz3d is thread-safe.


jfk EO-11110(Posted 2005) [#5]
I think Blitz is "thread-safe" in windowed mode as long as you are only accessing a bit flag in a bank. Reading/writing unsynced data from and to banks would be pretty risky, of course. but as long as it's only a bit that signals if Loading is complete, why not? When you play a Movie or Mod, it's multithreading too, at least on the system level.

In Fullscreen it's probably more difficult.


Apocalypse(Posted 2005) [#6]
I have moved updates on this project over to the Work Logs Section...

http://www.blitzbasic.com/logs/userlog.php?user=7138&log=440


Apocalypse(Posted 2005) [#7]
New AVI file functions have been added to directly access a frame of video and Blt the pixels to a BBImage.

Check it out here...

www.blitzbasic.com/logs/userlog.php?user=7138&log=440


Apocalypse(Posted 2005) [#8]
You can now Blit AVI frames to a texture. Play an AVI on a spinning cube! Check out the demo here...

www.blitzbasic.com/logs/userlog.php?user=7138&log=440


jfk EO-11110(Posted 2005) [#9]
I tried the Avi example, but the line OpenAvi(path$) gives me a MAV, both in debug mode on and off. I have no idea why, the file is there, I also tried full paths. I tried a cinepak and an Indeo 5.04 Codec, they are both installed. WinME,DX9a, Blitz3D 1.88, radeon 9200se. Note that Toms DLL didn't work neighter.


Apocalypse(Posted 2005) [#10]
What exactly is MAV?


jfk EO-11110(Posted 2005) [#11]
a "memory access violation" error message. when it happens with debugger on, it's not a standard error like a missing entity or so.


Apocalypse(Posted 2005) [#12]
Do you get the MAV when running my demo? (Changing the name of the AVI of course.)?

What OS are you running? and what SP?


jfk EO-11110(Posted 2005) [#13]
Yes, the demo code. Of course, I replaced the "baby.avi" to a path that should work here. As I said, WinME (Millienium - don't laugh, it isn't that bad :P) there ain't no SPs for WinME. and DX 9.0a, Radeon 9200se Card.


Apocalypse(Posted 2005) [#14]
Download the latest version of my DLL and tell me what is the value returned from AVIFileOpen. I will see if I can identify what the problem is.


jfk EO-11110(Posted 2005) [#15]
You mean AVIOpen - there is no return value since the execution creates the error before there is a return value. Also in the new version. AviOpenLib seems to work, at least no error with this call.
I tried some other commands of the DLL as well

FileExists like DirExists doesn't create an error, although it returns always zero, even when I use it with a full path of an existing file or folder.

DiskSpaceFree seems to return 2028 Meagbytes (in MB) tho there is more, but I guess it's a hardware limit.

TestBit seems to work too.

Since FIleExists doesn't find files, it probably has something to do with the way you are accessing files?


Apocalypse(Posted 2005) [#16]
The 3 functions you mention involved passing a string from Blitz to the DLL. Are you running the latest version of Blitz3D? (Not that I know this would be a problem but I want to eliminate it as a possibility).

I can't imagine that your machine passes strings in a different way than other machines.


jfk EO-11110(Posted 2005) [#17]
I have blitz3d 1.88, but in userlibs handling 1.90 is the same AFAIK. BTW other userlibs work, both ways, strings to dll, and dll to bank. I wonder if it's only me, only WinME, or maybe it requires XP anyway.

how would I have to use FileExists, i tried

print fileExists("test.txt")

and it printed zero.


Rook Zimbabwe(Posted 2005) [#18]
As I said, WinME (Millienium - don't laugh, it isn't that bad :P)
Yes it is. Sorry.
-RZ


Apocalypse(Posted 2005) [#19]
print fileExists("test.txt")

and it printed zero.


It Should return 1-exists /0-does not exist. I works on my machine (winXp Pro sp2) with the latest blitz3D. I'm at a loss as to what is up. Let me try getting at the string a different way. I will post when I have something you can try.


Apocalypse(Posted 2005) [#20]
@JFK:
I have changed the way I pass string data back and forth
in my Userlib. Give it another try and see if you still get the MAV's..


jfk EO-11110(Posted 2005) [#21]
Ok, asap, thanks.

Rook - I know them all, XP, 2000, NT, WinME, Win98, 95, 3.11, 3.10, msdos.... IMHO XP is probably the worst of all.


jfk EO-11110(Posted 2005) [#22]
Still didn't work. (the same as before, both, FileExists and AviOpen)

To make sure we are talking about the same versions:

I have tested 3 versions with the following file sizes:
1: 40448
2: 43520
3: 43008


Apocalypse(Posted 2005) [#23]
I think ME's lack of support for Unicode strings may be the problem...

http://www.microsoft.com/globaldev/handson/dev/mslu_announce.mspx


jfk EO-11110(Posted 2005) [#24]
Is your DLL using Unicode then? BTW - what Compiler did you use anyway, is this powerbasic? (I think I remember somebody mentioned Powerbasic)


Apocalypse(Posted 2005) [#25]
Here are some routines I added mainly because they are optimized for speed plus they've helped me in the past in making enemy AI...
Graphics 640,480,0,2

Print Distance (0,0,10,10)
Print OriginAngle(10,10)
Print Rad2Deg (OriginAngle(10,10))
Print Deg2Rad(315)



OriginAngle...
' This function will return the angle from origin 0,0 to X,Y
' Useful to figure out in which direction a set of coordinates
' is from another. By taking 2 sets of coordinates and normalizing them
' (ie: subtract X2-X1, Y2-Y1) will let you find the angle of any coordinate (X1,Y1)
' to any other coordinate. (X2,Y2)


Boiled Sweets(Posted 2006) [#26]
Hi,

it seems the GetTimeServer returned 10/10/2006 today (01/01/2006)

I think the NIST server is correct - could you please check your code as I use this excellent library...

Many thanks...


_PJ_(Posted 2013) [#27]
Sorry for the resurrection of this really old thread -
I was wondering if anybody has this dll at all that wouldn't mind hosting it?

The link Apocalypse gave is now dead, and it appears as though Apocalypse has long since departed these forums.


virtlands(Posted 2013) [#28]
Hi _pj_

There is some further talk on B3DHLP.dll located on this 2005 post:
http://www.blitzbasic.com/logs/userlog.php?user=7138&log=1254

But the DLL link remains missing. Apocalypse is apparently gone.


_PJ_(Posted 2013) [#29]
Thanks, Virtlands,- Yeah I checked out the worklogs and all.

I was hoping somebody still active may have the dll they may be willing to mail it or host it if possible.


mv333(Posted 2013) [#30]
B3DHLP.dll


_PJ_(Posted 2013) [#31]
Excellent! Thanks very much, mv333! Downloaded :)


virtlands(Posted 2013) [#32]
Thanks mv333, it's great to have B3DHlp.DLL

You can use DLL Export Viewer to confirm what's inside.
http://www.nirsoft.net/utils/dll_export_viewer.html

90 Functions are found: