Jump to content

Compiling BoE source code for Windows


Ormus

Recommended Posts

Hi all! I've tried to compile BoE Windows code release and a lot of errors showed up. I think that the problem is that some files are missing: "townspec.h", "town.h", "text.h", "specials.h" and maybe others. Jeff, can you check for these files in your archives?

Link to comment
Share on other sites

  • 2 weeks later...

I've tried to port BoE to Win32 API and I encountered some problems I cannot bypass. You can see them HERE . Also see the SOURCE CODE . I've used Dev-cpp IDE which is based on GCC compiler. I'd be happy to get some help from someone experienced in Windows API.

 

For those who try to solve some basic problems with code published by Jeff while messing with original code:

1) Some Win16 functions and macros are completely removed from Win32 and some are replaced with their extended versions. MoveTo() is to be replaced by MoveToEx(). Members of POINT structure changed their type, so you have to change some things. You can start with MAKEPOINT macro - write your own. Also replace GetWindowWord() with GetWindowLong() and delete MakeProcInstance() as it is obsolote now.

2) You should check whether DeleteDC() and ReleaseDC() are used to destroy right objects. In Jeff's code there are some places where HDCs are deleted by using DeleteObject() which resulted in unexpected behavior of my WinXP. And you have to change fry_dc() function because it calls ReleaseDC and DeleteDC on the same object.

3) You have to add "#include <windows.h>" on the beginning of GAMEDLOG.RC, if you get compilation error

Link to comment
Share on other sites

Hi:)

If You want to make code more compatible with Win32, You should rewrite all file I/O functions. You should use CreateFile instead of OpenFile functions, SetFilePointer instead of _llseek, etc.

 

BTW there is no TINYOBJ.BMP file in Windows release of EoB source code. You can get it from shareware version of EoB.

Link to comment
Share on other sites

Quote:
Originally written by r.Q:
Hi:)
If You want to make code more compatible with Win32, You should rewrite all file I/O functions. You should use CreateFile instead of OpenFile functions, SetFilePointer instead of _llseek, etc.
Thanks for advice! I've just rewritten them! Unfortunately, it didn't help with the "no room for graphics" problem. I don't know how to fix it. I'll try to figure it out today. Are there any other people working on Win32 BoE?

EDIT: I've just realised that savegames aren't loading properly.
Link to comment
Share on other sites

I have a problem of the most basic kind: I have no idea how to actually compile this game! My logic tells me there is a step-by-step guide somewhere... but so far my attempts to find one have been fruitless.

 

So could someone give me a hint about what I need to compile the source, how do I do it and where should I look for further info?

Link to comment
Share on other sites

Quote:
Originally written by Frozen Feet:
I have a problem of the most basic kind: I have no idea how to actually compile this game! My logic tells me there is a step-by-step guide somewhere... but so far my attempts to find one have been fruitless.

So could someone give me a hint about what I need to compile the source, how do I do it and where should I look for further info?
I've given it a shot myself, and here's what I can tell you so far.

The first thing is to set up a Windows development environment. You can use these free tools:

Visual C++ 2005 Express
http://msdn.microsoft.com/vstudio/express/visualc/

Microsoft Platform SDK
http://www.microsoft.com/downloads/detai...;displaylang=en

How to Use the Platform SDK in Express
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/

Then you can make a Blades project with the code (.h, .cpp) and resource files (.rc) in it. If adding files to the project crashes Visual Studio, you need to patch it with the latest Service Pack.

Now, the data does not need to be added to your project, but it does need to be in the right places. If you created the solution and project with the default directory structure, then the BladScen folder goes in your project directory because this is also the default working directory.

The sounds folder should be named "blades" and placed in your solution directory (that is, one directory up from your project directory) -- the blades.rc resource file assumes the sounds path to be "..\blades", but you can change that to anything you like.

That's all the steps I know to get working with Blades in Windows. Getting a successful build is another matter, which I leave to more talented Windows coders than I.
Link to comment
Share on other sites

Hi guys! I've managed to find source of my problems with loading BoE save-games. It took me a lot of time but I've found it. Compiler used by Jeff didn't align data in structures to memory addresses divided by 2 or 4 because it wasn't important years ago to do it. But my compiler does align data in structures and this changes values of all the sizeof's used to measure length of data blocks to read or write. I suppose that other modern compilers may do that. Unfortunately, I couldn't find how to turn off this thing, so I had to rewrite some portions of FILEIO.CPP in a very ugly way. Now it is loading save-games correctly. Still I haven't rewritten any other input-output functions at this time because there is another problem to deal with - something connected with placing PCs in scenario just after loading it. You can see it on screen capture . My source code is here .

 

Frozen Feet, you want to compile BoE as 16 or 32-bit application? I suppose that as 16-bit application it should compile without any problems. But if you want to make it 32-bit then you should look at this PDF . It's about porting old Windows apps to 32-bit world and I've found it VERY useful. And there is one thing that isn't mentioned anywhere: on Win32 members of structure named RECT has changed its size.

Link to comment
Share on other sites

I haven't taken a good look at the source yet, but how hard would it be to implement sizeof everywhere you need to change from 16-bit to 32-bit? I realize that, depending on JV's code, it could be a big overhaul, but if it isn't done the source will have to be changed again if and when everyone moves to 64-bit.

 

EDIT: Grammar are nice.

 

--------------------

I stayed up all night playing poker with Tarot cards. I got a full house and seven people died.

- Steven Wright

Link to comment
Share on other sites

I don't see how using sizeofs could help. Could you explain it more, please? I've had a lot of problems because of their usage in BoE code, not because of lack of it.

 

EDIT: I think that what could really help is good documentation of file formats, data structures and algorithms. Porting is always difficult but it could be less time consuming.

Link to comment
Share on other sites

Ormus: What that looks like to me is that you're properly loading the scenario record and the text but not the town records, which are loaded separately.

 

You should try spitting out the starting co-ordinates when placing the party. where_start for ASR is (14, 56) -- which it obviously isn't for you -- and which_town_start is 1. That's what I'd check for.

 

UPDATE: Are you using the copy of ASR packaged with the source release? Because it appears that it's corrupt.

 

It and the packaged ZKR are garbled when I load them with my scenario dumper. Meanwhile, VoDT and all three of the Mac versions of the scenarios load fine, as well as a half dozen scenarios I just downloaded. Finally, I found some old copies of them lying around on my hard drive -- the Windows versions, natch -- and they worked.

 

So the copies of STEALTH.EXS and ZAKHAZI.EXS packaged with the Windows source release version 2 are corrupt. Don't use them for testing.

 

UPDATE 2: Running stock BoE in an old version of Wine, I tried to run the apparently corrupt STEALTH.EXS. I was partially able to duplicate your issue. It placed me 'correctly' -- that is, on the dock -- but moving in any direction resulted in a special-out-of-range error and I was teleported into the middle of nowhere. Hope that helps.

Link to comment
Share on other sites

You're right, Andrea, Windows versions of scenarios are corrupt. Unfortunately, I was disconnected from the internet so I couldn't read your post and I spend 8 hours looking for errors in code. frown Then I discovered that scenario editor couldn't open these scenarios and realized that something is not right with them. Great thanks anyway - it's nice to know that someone wants to help!

 

After changing scenarios to the Mac ones I've fixed all code responsible for loading and saving save-games. Now it works correctly. At this time I have to test all the game mechanisms, check for bugs etc. Currently I can compile and run BoE, make nice group of adventurers, load scenario, talk with some NPCs, fight with someone. It all works.

 

Links: source code , main executable

 

Now I want to find out why the game runs so slow and I think it's necessary to tidy up the code.

Link to comment
Share on other sites

Quote:
Originally written by Ormus:
Compiler used by Jeff didn't align data in structures to memory addresses divided by 2 or 4 because it wasn't important years ago to do it. But my compiler does align data in structures and this changes values of all the sizeof's used to measure length of data blocks to read or write. I suppose that other modern compilers may do that. Unfortunately, I couldn't find how to turn off this thing, so I had to rewrite some portions of FILEIO.CPP in a very ugly way. Now it is loading save-games correctly.
There is a way to turn off structure data align on the GCC based compiler (e.g Dev-C++). To do it, You have to add "__attribute__" instruction to a structure definition. For example:
Code:
typedef struct#ifdef __GNUC__        __attribute__ ((packed)) #endif{       char a;       int b;} NOT_ALIGNED_STRUCTURE;
Anyway, this is not recommended but it's worth to know wink
Link to comment
Share on other sites

Ormus: I just downloaded, extracted, and ran the application. It skips the introduction with the Spidweb logo, the splash screen, and the music. I simply get a black screen with a black popup window which I assume is the Tip Of The Day. I moved it around which revealed the text on the main menu buttons but no images, closed the window with what I assume is the OK button, heard the click sound, and still couldn't see anything. I had to close the program with the Task Manager, I think due to the same problem I have with the old BoE (it insists on changing my Windows colors every time I switch to it from another program, and then the colors need to change back when I switch to another program from BoE, causing my computer to lag for a minute or two every time I switch to or from BoE).

 

Black screen aside, it would be nice if you could remove whatever code is switching the Windows colors to stop the lagging.I have very little programming knowledge, but I assume getting rid of that bit of code wouldn't harm compatibility or anything.

 

Hmm. Further investigation reveals the character and scenario editors change the colors too, but have considerably less lag. It must be something else.

Link to comment
Share on other sites

r.Q, thanks, I''ll check it. It would really help.

 

The Almighty Do-er of Stuff, probably you don't have image files in right subfolder. Download this , unpack and run. Then tell me if you still have problems with colors and lagging.

 

Now I'm porting Character Editor. I was planning to port Scenario Editor first, but it seems that some files are missing (again). I couldn't find "townout.h" and "tfileio.h". frown I hope that Jeff will find these ones too.

Link to comment
Share on other sites

"Now I'm porting Character Editor. I was planning to port Scenario Editor first, but it seems that some files are missing (again). I couldn't find "townout.h" and "tfileio.h". I hope that Jeff will find these ones too."

 

Meh. Just make them. Copy-paste the function/procedure headers over and you got it.

 

- Jeff Vogel

Link to comment
Share on other sites

Quote:
Originally written by Spidweb:
Meh. Just make them. Copy-paste the function/procedure headers over and you got it.
You're right! Sometimes the simpliest solutions are the hardest to imagine. laugh Unfortunately, TOWNOUT.CPP doesn't exist, so I can't create appropriate header file for it. frown

The Almighty Do-er of Stuff, I've changed the code responsible for color palette changes. Now the game should work without any problems. And now it works really fast (at least on my computer). Please, download the game from my makeshift website (link is in the signature).
Link to comment
Share on other sites

Yes, now it is SUPAR SPEEDY. Thanks! I still miss the splash screen and intro music though, but I suppose I can live without it.

 

Anyway, there's another bug that was in the Win16 version and was carried over to the Win32 version. On my 1280x960 monitor, BoE's main screen displays just fine, as it did on smaller monitors I had in the past. However, on my 1600x1200 monitor, it looks like this: http://ados.ermarian.net/garbage/boemain.gif (681.77 KB GIF image, dialup beware)

 

That black area is black when I first open the program, but when I go to different screens within BoE or put other windows in front of it, it gets filled in with whatever was there. This only seems to happen with the main screen and not other screens.

Link to comment
Share on other sites

"You're right! Sometimes the simpliest solutions are the hardest to imagine. Unfortunately, TOWNOUT.CPP doesn't exist, so I can't create appropriate header file for it. "

 

I just don't have time to dig that old machine out of storage again. Use the Mac version. You'll have to change the #includes at the top of the change the call to launch the dialog boxes (change it from the Mac ModalDialog to whatever it being used for the Windows version. Should be pretty quick.

 

- Jeff Vogel

Link to comment
Share on other sites

The Almighty Do-er of Stuff, I am going bring to back splash screen and intro music soon. I've turned them off because I was chasing some nasty bugs and it was distracting me. This problem with displaying background in high resolutions must wait until I find computer with suitable monitor and graphic card because now I am working on laptop computer which can't go beyond 1024x768.

 

Andrea, I've just uploaded cursors on my website. Go download them. Btw, I don't remember where I found "look.cur". It's not included in original package with BoE sources and I don't remember to extract it from original BoE executable (but it is the same one). Strange. smile And that's great news that ported code compiles under Winelib! I've checked yesterday how it compiles under diffrent compilers and I've fully succeded in doing so by using Borland C++ 5.02 and Digital Mars 8.49. However, both of these had problems with resource files.

 

For my next releases of the BoE for Win32 I've decided to separate sound resources from main executable and I've moved them to DLL file. It is so because I don't like big EXEs, especially when I have to upload them on the net, recompile, replace etc. (Do you know that BoE executable without sounds can be packed by UPX to ~300kB?). Also I've replaced BLADMISC.DAT with simple BLADES.INI configuration file, which can be easily edited with notepad.

 

EDIT: I would like to invite other people to work with the code. I'm a student and there comes slowly time of exams for me. Soon I'm going to disappear from the net and you won't see me here until I pass all exams.

Link to comment
Share on other sites

Quote:
Originally written by Ormus:
For my next releases of the BoE for Win32 I've decided to separate sound resources from main executable and I've moved them to DLL file.
Just wondering, why not put them into a directory as separate sound files? Then people can much more easily remove/replace individual sounds.

Quote:
Originally written by Ormus:
EDIT: I would like to invite other people to work with the code. I'm a student and there comes slowly time of exams for me. Soon I'm going to disappear from the net and you won't see me here until I pass all exams.
Why not put it somewhere like SourceForge? Unfortunately, Google Code's limited set of licenses does not include the CPL (which is a horrible [due to insane patent retaliation clauses] and not much used license).
Link to comment
Share on other sites

Quote:
Originally written by Reve:
Just wondering, why not put them into a directory as separate sound files? Then people can much more easily remove/replace individual sounds.
Because I don't know how to load sounds from files using Windows API only. smile In the future I am going to add support for external files, but now I have other priorities.

Quote:
Originally written by Reve:
Why not put it somewhere like SourceForge?
I don't have time to do this. If somebody could do this for me, I'd be happy.
Link to comment
Share on other sites

I really do advise avoiding SourceForge. It's slow, it's inferior, and their tech support is tremendously poor. If you need a ticket system, I'd be glad to set up Trac or something like it on my server. Just an offer.

 

Also, now that the Windows and Mac versions seem to be reasonably up to date, I'm going to be putting some hours in on merging both codebases.

Link to comment
Share on other sites

Hi;)

I would like to share some of my observations resulting from my work on BoE open source code. I use Dev-C++ compiler and at this moment code is compiling and running, but it wasn't easy. During my work, I have found some strange errors, like unexpected program collapsions, or terminations. To find out, what's going wrong I have spent a lot of time on debugging. I hope this post will save some time to people who have found similar problems.

First obstacle was an unexpected program collapsion while showing dialog box window. The reason of this situation is incorretly string formatting in "dummy_dialog_proc" (DLOGTOOL.CPP file) dialog window procedure. As we can see in line 616:

Code:
[...]else sscanf(item_str,"%d_%d",&type,&flag);[...]
'type' and 'flag' variables has 'short' type, while formatting string ("%d_%d") describes 'long' types. Properly, formating string should be "%hd_%hd".

 

Next thing is program terminiation, while closing dialog box windows. That was very frustrating, because everything seems to be OK. In this situation something is littering our application message queue with WM_QUIT message. Problem lies in implementation of "fry_dc" function (GRAPHUTL.CPP file, line 612). The solution is to rewrite this function to something like this:

Code:
void fry_dc(HWND hwnd,HDC dc) {     if(!ReleaseDC(hwnd, dc) && !DeleteDC(dc))                         PostQuitMessage(0);}
Ok, that's all what I have to say (now;)). Hope that anybody find it useful.

Bye;)

Link to comment
Share on other sites

Quote:
Originally written by Ormus:
Quote:
Originally written by Reve:
Just wondering, why not put them into a directory as separate sound files? Then people can much more easily remove/replace individual sounds.
Because I don't know how to load sounds from files using Windows API only. smile In the future I am going to add support for external files, but now I have other priorities.
Hey Ormus ! I have something for You;) I've rewritten all sound engine. Now it reads sound data from external *.WAV files, uses 32-bit Windows Multimedia function, and locks global handles only when playing sound (in order to avoid memory fragmentation). Following archive indludes two files: EXLSOUND.CPP and EXLSOUND.H. I have added "delete_all_sounds" function, to release all allocated memory, so You should call this function in course of processing "WM_DESTROY" message.

Archive: Download here

I hope You find it useful.
Regards wink
Link to comment
Share on other sites

  • 2 weeks later...

Ormus, I tried to download the scenario editor, but it appears the top two links on the page in your sig are the same as the two below them.

 

By the way, it turns out that the color changing thing gets annoying in the scenario editor and the character editor as well. I guess it depends on what program I switch to or something.

Link to comment
Share on other sites

  • 3 weeks later...

Hi all, I was busy with exams and was applying for a job so I wasn't working an BoE for a long time. First, I've fixed links at my site and you should be able to download and recompile game and scenario editor under Win32. Now I need a lot of time to familiarize myself with modifications made by people working on mac rewrite. I suppose they found a lot of bugs and fixed them and now I need to make approporiate changes in windows version of the code.

Link to comment
Share on other sites

They're already playable, they just aren't included in the download. You can download them separately from TrueSite for Blades . Click on Walkthroughs, select the first letter of the name of the scenario you want (including VoDT, ASR, and ZKR), ignoring the words "A", "An", and "The" if they are at the beginning of the name (for instance, look under S for "A Small Rebellion").

Link to comment
Share on other sites

Quote:
Originally written by The Almighty Do-er of Stuff:
They're already playable
They are? Man, then I know I'm dumb (can't vouch for Redstart, though). How do you install the scenarios? I've got a bunch of them in the "BLADSCEN" folder like the Valley of Dying Things and one in its own folder. Then I have one in the main game folder, one in the "BLSCENED" folder and OBoE still claims that there are no scenarios installed when I press the Custom Scenario button.
Link to comment
Share on other sites

Quote:
(can't vouch for Redstart, though)
Oi!

As a matter of fact I am both dumb and lazy. I hadn't event bothered with trying to install the scenarios since all other pre-packed scenarios said "must be registered" in their descriptions, and wouldn't launch.

EDIT:
Seems to work when you copy all the contents of the scenario into the bladscen folder. At least it worked for Falling Stars. Thank you ADoS.

EDIT 2:
Oh expletive. It seems I can't get Small Rebellion or Za-Khazi Run anywhere. Despite what ADoS said, they're not hosted on Gizmo's or Kelandon's sites. And Vista won't let me install the BoE demo since it's apparently 16-bit. Could someone host the two remaining pre-packed scenarios? Pretty please?
Link to comment
Share on other sites

  • 1 month later...

I simply rename the custom graphics sheet along with the scenario, it is the only solution. I am playing Shadow of the Stranger, or I was until I downloaded Nethergate: Resurrection, I renamed the scenario to "Stealth.exs" and the custom graphics to "Stealth.bmp".

 

I have only rarely been able to access the custom scenarios. Examining the source code might show the problem, but it can only be fixed by re - compiling the program.

Link to comment
Share on other sites

Ormus seems to have quit. Unfortunate.

 

Anyway, looking at the Windows source code, a few things--

 

-These sources are getting only slightly less Windows-centric. Good start, but far more is necessary. #ifdef hell may not even work with the mess on our hands.

 

-They're never going to compile under VS2005, which is a cast-iron shame. 800+ errors say "hello." Similarly, on gcc, I can only get it to compile by mickey-mousing the CFLAGS and ignoring things that should not be ignored.

 

-These sources still don't work on Vista. Now, like any half-sane person, I don't use Vista (tested it in VMware), but that's still a sticking point. I'm of the opinion that a reimplementation may be necessary, especially to expand the system limitations sanely. (In my spare time I'm messing around with one.)

 

-New file format. Very, very necessary in the long term. I propose that a group get together and formulate this, preferably one with a lot of both scenario and code experience.

Link to comment
Share on other sites

  • 3 weeks later...
Quote:
-They're never going to compile under VS2005, which is a cast-iron shame. 800+ errors say "hello." Similarly, on gcc, I can only get it to compile by mickey-mousing the CFLAGS and ignoring things that should not be ignored.
I love a good challenge wink

VS2005 project fiile that compiles (for me anyway anyone want to confirm it works?).

As far as I can tell it is working properly. Built off Ormus's (sources) link.

Ok bracing for reports about what I messed up lol

Quote:
-These sources still don't work on Vista. Now, like any half-sane person, I don't use Vista (tested it in VMware), but that's still a sticking point. I'm of the opinion that a reimplementation may be necessary, especially to expand the system limitations sanely. (In my spare time I'm messing around with one.)
What's broken on Vista (messes up)?

Quote:
I can not get custom scenarios working, I put them in the scenarios folder but it still says that there are none installed, I managed to get one working by renaming it to valleydy.exs but it wouldn't load it's custom graphics. any ideas?
Does anyone have a very basic example of this problem where renaming the files actually does make the scenarios load?

Quote:
I really do advise avoiding SourceForge. It's slow, it's inferior, and their tech support is tremendously poor. If you need a ticket system, I'd be glad to set up Trac or something like it on my server. Just an offer.
I think the advantge to SourceForge would be a commen place that everyone can go to get code and the folks working on the project can upload it.

It would be a shame if someone quit and people were getting old versions of the code to work on because that's what their sig pointed too. Or did I miss something that is already set up? Thanks for letting me know smile

Quote:
I still miss the splash screen and intro music though, but I suppose I can live without it.
I think I got it working correctly?
Link to comment
Share on other sites

  • 2 weeks later...

Ok it was pointed out to me (VIA PM) that I didn't mention what file I was linking against in the VS2005 file.

 

winmm.lib was the file that I finally figured out I needed to link against to get the project to compile.

 

It needs to be included under the project properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies.

 

I hope this clears up that question.

 

EDIT:

It's probably worth mentioning that there are several bugs due to VS2005 requiring variables to be defined before being passed to a function (and many aren't). I fixed the ones I saw just quickly playing through but if you find any more please report them smile

 

EDIT2:

*sigh* the overly confusing stuff do without realizing it frown . You need to install 7-Zip to extract the file.

 

http://www.7-zip.org/

 

After you install 7zip right click on the file -> choose the 7-Zip menu -> choose Extract files.

 

You should now see all the expected files. Sorry but I don't want to upload the extra 7mb for a zip file so I'm using 7-Zip to compress it.

Link to comment
Share on other sites

Quote:
Originally written by madcrow:
Hmm... this is a cool game, but I just realized something: the Win32 port isn't actually covered by the GPL!.
I'm confused. "Blades of Exile Game/Editor/Character Editor are released under the terms of the GNU General Public License, Version 2." seems clear that both versions are covered by the GPL. (This is from the SpiderWeb source download Blades of Exile License.txt). Both the Mac and Windows versions are present in the file below the license.
Link to comment
Share on other sites

Quote:
Originally written by Ingro:
Quote:
Originally written by madcrow:
Hmm... this is a cool game, but I just realized something: the Win32 port isn't actually covered by the GPL!.
I'm confused. "Blades of Exile Game/Editor/Character Editor are released under the terms of the GNU General Public License, Version 2." seems clear that both versions are covered by the GPL. (This is from the SpiderWeb source download Blades of Exile License.txt). Both the Mac and Windows versions are present in the file below the license.
The Win32 port/build happened pre-GPL, back when the code was still under the CPL (Common Public License)

Thus, as the changes were never merged back into the official code tree, the changes are still CPL. We should try to contact the author of the Win32 port (who hasn't been active in a long time) and see if he'll agree to release his changes as GPL and thus bring the Windows codebase back up from Win16.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...