I originally wrote a program DBOFastReader which reads in DBO and exports static/animated objects out to DirectX and OBJ formats using DBPro commands and IanM Matrix1Utils.
This program / tutorial is more nearer to a VS C version of DBOLoader but with DBPro workarounds due to restrictions/limitations DBPro has.
DBO Format documentation can be found in your DBPro install folder under "DBO". In there you should be able to see a file DBOFormat.doc. This spec document, gives you a basic overview of how the structure works and how it can be loaded in. Under the same folder, you have the original DBO VS source code.
For the tutorials you will need Matrix1Utils written by IanM which allows us to use ALLOC and various Array Pointer commands, plus loads more.
NOTE: I have not used #include as when compiling with DBPRO and hitting errors does not show true line number , so once the program is complete / tested and works like a charm, then we can start adding include files to organise or our code better.
Part I - Setting up some initial variables and loading the DBO file into memory (pointer).
Initial Code:
As I get a bit more time on my hands, more and more breakdown info on what the code is doing will be added below the code snippet.
[code removed temporarily]
How does DBO work?
DBO works by embedding special codes that are represented in DWORD (LONG) format i.e. 4 bytes e.g. 1,0,0,0 = 1, 101,0,0,0 = 101, anything over 255 will carry over into the next byte.
How does the code work?
This 1st part of the code works by setting up some initial global variables, i.e. pointers to the DBO data and embedded codes and size. This is because DBPro does not understand "&" symbol used in VS C.
In DBPro we can allocate memory using memblocks, banks and ALLOC ( the last 2 you need IanM Matrix1 utils plugin).
Constant variables are initialised including a complete list of embedded DBO code 1 - 406 and some WIN32 API constants needed for the CreateFileA function. This gives us more control on the way a file is read in and is very fast. Originally , I used MAKE BANK FROM FILE and then obtained pointer from there.
To use the "CreateFileA" and "ReadFile" functions, we have to load in the "kernel32.dll" dll. Then obtain a handle to the CreateFileA function. Pointer variables are parsed into the ReadFile function.
dppBlock is used to allocate memory with size of the file obtained from *dpdwSize (i.e. return the size value contained in pointer dpdwSize). Print dpdwSize and Print *dpdwSize are 2 different things. The 1st returns the memory address and the 2nd returns the actual value stored in that address.
ppBlock is used as a "floating" address pointer to obtain the next DBO address, but is not set up as a pointer. It's purely a copy of the base pointer pDBOBlock which is static meaning the value will never change.
Anything that was setup as allocated memory is deallocated using FREE command at the end of the program (CleanUp function). I've added a message statement (for those that have Robert Knights BLUEGUI plugin) just to ensure that the cleanup works correctly without prematurely "bombing" out the program. For the ppBlock variable, it simply gets "NULLED" or set to zero.
In the future tutorial sections, there will be references to LPSTR, LPVOID and other LPxxx etc type vars , these are simply windows structures that really can be translated as DWORDs as they are all pointers to a particular windows data type.
Don't forget that all strings in DBPro are essentially DWORDs containing the address that points to the actual text of a string.
So if you have a fear of pointers and pointer to pointer, turn away now

Pro Programmer / Data Scientist, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others