BLADES OF EXILE SOURCE CODE INTRODUCTION
Release 3

	Welcome to the Blades of Exile source code. This is the complete source code for the game and editor for both the Windows and Macintosh versions of the 1997 RPG classic Blades of Exile.

	It is being released under the GNU General Public License, Version 2. To learn more about this free software license, go to 

http://en.wikipedia.org/wiki/Gpl

	Before you do too much with this code, be sure to check 

http://www.spiderwebsoftware.com/blades/opensource.html

to make sure that there haven't been any updates released. More importantly, be sure to go to the Blades of Exile forum:

http://www.ironycentral.com/cgi-bin/ubb/ubb/ultimatebb.php?ubb=forum;f=7

	Lots of improvements have been made to the code. Instead of wading through the raw stuff, see what work other people have done.

* IMPORTANT LEGAL STUFF

Blades of Exile Game/Scenario Editor/Character Editor
    Copyright (C) 1998-2007, Jeff Vogel
    http://www.spiderwebsoftware.com, spidweb@spiderwebsoftware.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

* SOME NOTES

	I normally hate giving things away for free. This is what I do for a living, after all. But I think I made enough money off of this game, and I do owe something to the community who worked so darn hard to create quality scenarios. Their work should have a chance at living on.

	Before you go too much farther, you should know a few things about the code. These are split up into sections for Macintosh, Windows, Both Platforms, the custom dialog engine, and expected questions.

* BOTH PLATFORMS NOTES

This is basically the same editor code, heavily modified, that I wrote 10 years ago. It is, in parts, clumsy, kludgy, and, in general, written to my own personal tastes and style. The inevitable E-mails explaning to me how my coding would be better if I did this or that will be read with interest and probably make no difference whatsoever. If I wrote this from scratch today, it would look much different.

If I wrote this today, it would be commented much better than it is. I would like to comment this heavily, but I just don't have the time.

Some files of great importance.

global.h - This is where all of the data structures are stored.
dlogool.c - This is the custom dialog engine. There are comments on this in that file.

You can use this code to either write your own game or make your own updated version of Blades of Exile. If you update Blades of Exile, you really, REALLY should make sure that it can handle existing Blades saved games. It should be able to read them and then write them in a format that will be understood by other versions of Blades of Exile. If you don't do this, people will be very angry at you, and rightly so.

* MACINTOSH NOTES

Important note! If you got the .zip version, it will have messed up resources files. To get the proper version, go to

http://www.spiderwebsoftware.com/blades/opensource.html

and get the Macintosh version.

To get Blades of Exile working in the modern world will take some doing. It is a Classic application. Three things need to be done.

One. It needs to be Carbonized. This shouldn't be too tough.

Two. It needs to be made Universal. This will be a bit of work. To make it Universal, it will need to deal with the fact that the order of the bytes in short ints changes between old and new applications.

Happily, the code is already in there to do the short int byte flipping when loading in Windows scenarios. This just needs to be adapted to be used when loading Mac scenarios on an Intel machine.

You will, however, also have to write the code to adapt saved games. When you load a saved game on an Intel machine, it should flip all the short ints. When you save the game on an Intel machine, it should FLIP THEM BACK. This is all part of maintaining the save saved game format. Mac saved games should always have the data set up like in the old Classic application.

Three. It needs to be modernized. Apple is getting rid of copybits and quickdraw, because it hates people dumb enough to develop for its machines. Someday, this should be ported to use OpenGL. If this sounds fun, look for a copy of Ultimate Game Programming Guide for Mac OS X.

Finally, for development, use XCode. It's free, and it works. Don't fight Apple on this one.

Oh, and just stick with Carbon C/C++. Don't port it to Cocoa. Wow, what a nightmare.

* WINDOWS NOTES

The situation here is much less of a mess than it is for the Mac. The game needs to be ported to the 32 bit world. It's a 16 bit application, which will make Vista very unhappy. But the port shouldn't be a nightmare.

Getting a development environment that can handle it, however, is a bit trickier. I would suggest obtaining a full copy of Microsoft Visual Studio 2005. Note that only a full copy will be able to do everything you need. This is the environment I use for all of my Windows development now.

You can get Borland Turbo C++ for free. It seems pretty lame to me, but, hey, free.

Also, the included .WAV files for the game had to be regenerated from the Mac sound files. If you have trouble with them, you might want to get a sound editing program and resample them at a more standard Windows sound frequency (like 22050 Mhz).

* THE CUSTOM DIALOG ENGINE

OK. The dialog box code seems weird. What on Earth is going on?

For various reasons (mainly customization and porting ease), we used a custom dialog box engine. This is it. 

Dialog boxes are created using the calls in this file. Basically, what happens, is that the editor loads in a dialog box resource. The text entries in that resource tell the editor what the dialog box should look like. An empty dialog box is created by the editor, and the editor draws the buttons on top of that.

Events for that dialog box are handled using the call cd_event_filter. If you make a new dialog box, it must have a line hooking it in in that procedure.

How to make a new dialog box.
1. Make the DLOG resource are usual.
2. Make item 1 a button. Move that button off of the window.
3. If you want text entry fields, make those items 2 - whatever. (i.e. 3 text entries their numbers are items 2-4).
4. All of the other items are text. Each is a number, then an underscore, then another number. (i.e. "0_1", "3_5").
The meanings of the numbers are:
First number = 0: Button. The second number is which button, the button types
	are described in arrays button_type and button_strs below
First number = 1: Default Button. Like button, but is the default.
First number = 2: Radio button. Next number should be 0.
First number = 5: Picture. I don't think this works anymore.
One exception: If you just want a chunk of text, you can have the text entry contain that text. If that text begins with ~, =, or *, formats text differently.

Of course, you can just ignore all this mess and write the code for regular dialog boxes.

* EXPECTED QUESTIONS

Q: What am I allowed to do with this code?

A: Just about anything you want. Read the Common Public License.

Q: I have questions about the code. Can you help me?

A: Probably not. We're very busy, and we really don't have much time to talk people through programming issues. You should check the Blades of Exile section of our forums or the Blades of Exile Scenario Workshop on our website. If people put together web pages on this stuff, we'll link to them.

Q: I found a problem or missing piece of data. Or I made a web page about Blades of Exile. Or I've improved the code and I have a new, better version available for download. Do you want to know about it? 

A: Yes!!! Tell us at spidweb@spiderwebsoftware.com. If a community comes up around this source code, we'll help people find you.

Q: Does this mean that you will be releasing the source code for other old games?

A: Not likely. For most of our games, when they get very old, we'll just rewrite and rerelease them. We're only doing this with Blades of Exile (and probably someday Blades of Avernum) because so many people have made scenarios for it.

Q: Why did it take so long to do this?

A: Partially because we were distracted by the thousands of things we have to do all the time. And partially because, up until very recently, we didn't know where the Windows Blades of Exile code was. (Please rest assured that this is very embarrassing to me.) A decent copy of it only turned up when we were searching through old computers for files for Nethergate: Resurrection.

- Jeff Vogel
Spiderweb Software
April, 2007


Description
The original source release of Blades of Exile, with line endings fixed
https://spiderwebsoftware.com/blades/opensource.html
Readme 5.9 MiB
Languages
Scenario 46.4%
C 28.9%
C++ 24.7%