Rename windows directories to remove spaces. This backslash business is getting old.

This commit is contained in:
Sylae Jiendra Corell
2014-06-17 14:45:17 -06:00
parent 29906153cf
commit a8872eb199
276 changed files with 0 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
#ifndef _DLOGTOOL_H
#define _DLOGTOOL_H
#include "../globvar.h"
//#include "boe.graphutil.h"
void cd_set_flag(short dlog_num,short item_num,short flag);
short cd_get_led(short dlog_num,short item_num);
short cd_create_custom_dialog(HWND parent,char *strs,short pic_num,short buttons[3]);
void frame_di(HWND hDlg, short item_num, short val);
HDC cd_get_dlog_dc(short which_slot);
short cd_get_active(short dlog_num, short item_num);
short cd_create_dialog_parent_num(short dlog_num,short parent);
void cd_init_dialogs();
short cd_create_dialog(short dlog_num,HWND parent) ;
short cd_kill_dialog(short dlog_num,short parent_message);
short cd_process_click(HWND window,POINT the_point, WPARAM wparam, LPARAM lparam,short *item);
short cd_process_syskeystroke(HWND window,WPARAM wparam, LPARAM lparam,short *item);
short cd_process_keystroke(HWND window,WPARAM wparam, LPARAM lparam,short *item);
void cd_attach_key(short dlog_num,short item_num,char key);
void cd_set_pict(short dlog_num, short item_num, short pict_num);
void cd_activate_item(short dlog_num, short item_num, short status);
void cd_set_item_text(short dlog_num, short item_num, char *str);
void cd_set_item_num(short dlog_num, short item_num, short num);
void cd_set_led(short dlog_num,short item_num,short state);
void cd_text_frame(short dlog_num,short item_num,short frame);
void cd_add_label(short dlog_num, short item_num, char *label, short label_flag);
void cd_key_label(short dlog_num, short item_num,short loc);
void cd_draw_item(short dlog_num,short item_num);
void cd_initial_draw(short dlog_num);
void cd_draw(short dlog_num);
void cd_redraw(HWND window);
void cd_frame_item(short dlog_num, short item_num, short width);
void cd_erase_item(short dlog_num, short item_num);
void cd_press_button(short dlog_num, short item_num);
short cd_get_indices(short dlg_num, short item_num, short *dlg_index, short *item_index);
short cd_get_dlg_index(short dlog_num);
short cd_find_dlog(HWND window, short *dlg_num, short *dlg_key);
short cd_get_item_id(short dlg_num, short item_num);
void center_window(HWND window);
RECT get_item_rect(HWND hDlg, short item_num);
void frame_dlog_rect(HWND hDlg, RECT rect, short val);
void draw_dialog_graphic(HWND hDlg, RECT rect, short which_g, Boolean do_frame,short win_or_gworld) ;
void showcursor(Boolean a);
short cd_create_custom_pic_dialog(HWND parent, HBITMAP picture);
void cd_get_text_edit_str(short dlog_num, char *str);
// NOTE!!! Expects a c string
inline void cd_set_text_edit_str(short, char *str)
{ if (edit_box != NULL) SetWindowText(edit_box,str); }
inline void cdsin(short dlog_num, short item_num, short num)
{ cd_set_item_num(dlog_num, item_num, num); }
inline void csit(short dlog_num, short item_num, char *str)
{ cd_set_item_text( dlog_num, item_num, str); }
inline void csp(short dlog_num, short item_num, short pict_num)
{ cd_set_pict( dlog_num, item_num, pict_num); }
inline void cd_set_edit_focus() { if (edit_box) SetFocus(edit_box); }
void ModalDialog();
extern HWND dlgs[ND];
RECT calc_rect(short i, short j);
#endif

View File

@@ -0,0 +1,56 @@
/*
* mathutil.cpp
* BoE
*
* Created by Celtic Minstrel on 16/04/09.
*
*/
#include <cstdlib>
#include "mathutil.h"
//minmax, move_to_zero and ex_abs (return absolute value) are templates in the header file
short get_ran (short times,short min,short max){
long int store;
short i, to_ret = 0;
if(max < min) max = min;
for (i = 1; i < times + 1; i++) {
store = rand();
to_ret += min + (store % (max - min + 1));//min + (((store + 32767) * (max - min + 1)) / 65536);
}
return to_ret;
}
short s_pow(short x,short y){
return (short) pow((double) x, (double) y);
}
short s_sqrt(short val)
{
return (short) sqrt((double)(val));
}
short max(short a,short b){
if (a > b)
return a;
else return b;
}
short min(short a,short b){
if (a < b)
return a;
else return b;
}
short gcd(short a, short b){ // Grabbed from Wikipedia and translated to C code
short t;
while(b != 0){
t = b;
b = a % b;
a = t;
}
return a;
}

View File

@@ -0,0 +1,44 @@
/*
* mathutil.h
* BoE
*
* Created by Celtic Minstrel on 16/04/09.
*
*/
#include <cmath>
using std::abs;
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
extern short get_ran (short times,short min,short max);
extern short s_pow(short x,short y);
short s_sqrt(short val);
short max(short a,short b);
short min(short a,short b);
short gcd(short a, short b);
template <class T>
void move_to_zero(T & value)
{
if (value > 0) --value;
else if (value < 0) ++value;
};
template <class T>
T minmax(T min, T max, T k)
{
return (k < min)? min : (k > max)? max : k;
};
template <class T>
T ex_abs(T value)
{
return (value < 0)? (-value) : value;
};

View File

@@ -0,0 +1,399 @@
/*
* soundtool.cpp
* BoE
*
* Created by Celtic Minstrel on 16/04/09.
*
*/
#include <cmath>
#if defined(__APPLE__)
#include <Carbon/Carbon.h>
#elif defined(WIN32)
#include <windows.h>
#include <mmsystem.h>
#endif
#include <cstdio>
#include "soundtool.h"
#include "../classes/consts.h"
#include "../globvar.h"
#include "../boe.text.h"
char* snds[NUM_SOUNDS];
#if defined(WIN32)
HGLOBAL sound_handles[NUM_SOUNDS];
#endif
bool sound_going(short which_s) {
short i;
for (i = 0; i < 4; i++)
if (snd_played[i] == which_s)
return true;
return false;
}
#ifdef __APPLE__
pascal void snd_channel_callback(SndChannelPtr theChannel,SndCommand* theCommand) {
long theA5;
short channel = -1,i,which_sound;
#ifndef EXILE_BIG_GUNS
theA5 = SetA5(theCommand->param2);
#endif
for (i = 0; i < 4; i++)
if (chan[i] == theChannel)
channel = i;
which_sound = snd_played[channel];
snd_played[channel] = -1;
//if (in_startup_mode == false)
// print_num(0,snd_played[channel],channel);
if ((sound_going(which_sound) == false) && (load_when_play[which_sound] == true)) {
HUnlock(sound_handles[which_sound]);
//if (in_startup_mode == false)
// print_num(99,snd_played[channel],channel);
}
#ifndef EXILE_BIG_GUNS
theA5 = SetA5(theA5);
#endif
}
#endif
void init_snd_tool(){
#ifdef __APPLE__
short i,t;
SndCallBackUPP callback;
for (i = 0; i < NUM_SOUNDS; i++) {
if (!load_when_play[i]) {
sound_handles[i] = GetResource('snd ', 20000 + i);
}
}
callback = NewSndCallBackUPP(snd_channel_callback);
for(t=0;t<4;t++){ // set up 4 sound channels
SndNewChannel(&chan[t], sampledSynth, initMono + initNoDrop, callback);
chan[t]->qLength = 128;
}
#endif
}
void play_sound(short which, short how_many_times) { // if < 0, play asynch
#if defined(__APPLE__)
Handle sndhandle;
unsigned long dummy;
OSErr err;
SndCommand theCommand;
if (!play_sounds || how_many_times == 0) return;
if (abs(which) > NUM_SOUNDS) {
//char msg[50];
/*s*/printf(/*msg,*/"Error: Sound #%i does not exist.\n",abs(which));
//give_error(msg,"",0);
return;
}
channel++;
if (channel > numchannel) channel = 0;
if (!sound_going(abs(which)) && load_when_play[abs(which)])
sndhandle = GetResource('snd ',20000 + abs(which));
else sndhandle = sound_handles[abs(which)];
if (which > 0)
if (always_asynch[which])
which *= -1;
if (sndhandle != NULL)
{
HLock(sndhandle);
if (which < 0) err = SndPlay(chan[channel],(SndListHandle) sndhandle,true); // Normal SndPlay
else {
err = SndPlay(chan[channel],(SndListHandle) sndhandle,false);
}
if (err != 0) {
printf("Sound error.\n");
//add_string_to_buf("Sound Error. Error codes:");
//print_nums(channel,which,err);
//add_string_to_buf("Your system could not play a sound.");
//add_string_to_buf("Make sure editor isn't running.");
//add_string_to_buf("Turn off sounds if necessary.");
}
HUnlock(sndhandle);
snd_played[channel] = abs(which);
theCommand.cmd = callBackCmd;
theCommand.param1 = 0;
#ifndef EXILE_BIG_GUNS
theCommand.param2 = SetCurrentA5();
#endif
#ifdef EXILE_BIG_GUNS
theCommand.param2 = 0;
#endif
SndDoCommand(chan[channel],&theCommand,true);
}
else SysBeep(20);
if (which < 0)
Delay(sound_delay[-1 * which],&dummy);
if(how_many_times > 1)
play_sound(which, how_many_times - 1);
#elif defined(WIN32)
short i,num_fails = 0;
char snd_name[30];
bool asyn = false,a_sound_did_get_played = false;
bool not_asyn = false,check_sound;
HRSRC h;
if ((sounds_missing) || (!play_sounds) || (how_many_times == 0))
return;
if (which < 0) {
asyn = true;
which = which * -1;
}
if (which >= 1000) {
which -= 1000;
not_asyn = true;
}
if (which >= 100)
return;
if ((always_asynch[which] == true) &&
((can_ignore[which] == 1) || (can_ignore[which] >= 3)))
asyn = true;
if ((can_ignore[which] > 0) && (can_ignore[which] < 5) && (party.stuff_done[SDF_LESS_SOUND] == 1))
return;
if ((can_ignore[which] != 1) && (can_ignore[which] < 3))
asyn = false;
if ((party.stuff_done[SDF_LESS_SOUND] == 1) && (can_ignore[which] < 5))
asyn = false;
if (not_asyn == true)
asyn = false;
if ((load_when_play[which] == true) && (sound_handles[which] == NULL)) {
asyn = false;
sprintf((char *)snd_name,"#%d",which + 1);
h = FindResource(hModule,snd_name,"#100");
sound_handles[which] = LoadResource(hModule,h);
snds[which] = (char *) LockResource(sound_handles[which]);
}
if (store_last_sound_played == 6)
sndPlaySound(NULL,0);
if (asyn == true) {
if (can_ignore[which] >= 4)
check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY | SND_NOSTOP);
else check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY);
while (check_sound == false) {
if (can_ignore[store_last_sound_played] == 4) {// then sound goes away
return;
}
num_fails++;
if (num_fails < 40)
sound_pause(25);
else {
MessageBox(mainPtr,"Cannot play sounds - Sounds stuck error a. Game can still be played, but quietly. Check to make sure your sound drivers are up to date and not corrupted.",
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
print_nums(111,which,num_fails);
sounds_missing = true;
return;
}
sndPlaySound(NULL,0);
if (can_ignore[which] >= 4)
check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY | SND_NOSTOP);
else check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY);
}
a_sound_did_get_played = true;
}
else {
if (can_ignore[which] >= 4)
check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY | SND_NOSTOP);
else check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY);
while (check_sound == false) {
if (can_ignore[store_last_sound_played] == 4) {// then sound goes away
return;
}
num_fails++;
if (num_fails < 40)
sound_pause(25);
else {
MessageBox(mainPtr,"Cannot play sounds - Sounds stuck error b. Game can still be played, but quietly. Check to make sure your sound drivers are up to date and not corrupted.",
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
print_nums(222,which,num_fails);
sounds_missing = true;
return;
}
sndPlaySound(NULL,0);
if (can_ignore[which] >= 4)
check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY | SND_NOSTOP);
else check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY);
}
a_sound_did_get_played = true;
}
store_last_sound_played = which;
if ((load_when_play[which] == true) && (asyn == false))
sound_handles[which] = NULL;
for (i = 0; i < NUM_SOUNDS; i++)
if ((load_when_play[which] == true) && (sound_handles[which] != NULL)
&& (a_sound_did_get_played == true) && (i != which))
{
sound_handles[i] = NULL;
}
#endif
}
#ifdef WIN32
void kill_sound()
{
sndPlaySound(NULL,0);
}
#endif
void one_sound(short which)
{
if (which == last_played)
return;
play_sound(which);
last_played = which;
}
void clear_sound_memory(){
last_played = 100;
}
void flip_sound()
{
play_sounds = (play_sounds == true) ? false : true;
}
#ifdef WIN32
void sound_pause(long len) {
long t1,t2;
t1 = (long) GetCurrentTime();
t2 = t1;
while (t2 - t1 < len) {
t2 = (long)GetCurrentTime();
}
}
void load_sounds(HMODULE handle)
{
short i,t,err;
HRSRC h;
char snd_name[20];
WAVEOUTCAPS wavecaps;
hModule = handle;
t = waveOutGetNumDevs();
if (t == 0) {
sounds_missing = true;
return;
}
err = waveOutGetDevCaps(0,&wavecaps,sizeof(WAVEOUTCAPS));
if (err != 0) {
sounds_missing = true;
switch (err) {
case MMSYSERR_BADDEVICEID:
MessageBox(mainPtr,"Cannot initialize sounds - No sound device detected. Game can still be played, but quietly.",
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
return;
case MMSYSERR_NODRIVER:
MessageBox(mainPtr,"Cannot initialize sounds - No driver installed. Game can still be played, but quietly.",
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
return;
case MMSYSERR_NOMEM :
MessageBox(mainPtr,"Cannot initialize sounds - can't find enough memory. Game can still be played, but quietly.",
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
return;
case MMSYSERR_ALLOCATED:
MessageBox(mainPtr,"Cannot initialize sounds - sound card already allocated. Game can still be played, but quietly.",
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
return;
case MMSYSERR_ERROR:
MessageBox(mainPtr,"Cannot initialize sounds - internal error. Game can still be played, but quietly.",
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
return;
default:
MessageBox(mainPtr,"Cannot initialize sounds - unidentified error. Game can still be played, but quietly.",
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
return;
}
}
for (i = 0; i < NUM_SOUNDS; i++) {
sound_handles[i] = NULL;
if (load_when_play[i] == false) {
sprintf((char *)snd_name,"#%d",i + 1);
h = FindResource(handle,snd_name,"#100");
sound_handles[i] = LoadResource(handle,h);
snds[i] = (char*) LockResource(sound_handles[i]);
}
}
}
void move_sound(unsigned char ter,short step)
{
short spec;
spec = scenario.ter_types[ter].special;
if ((monsters_going == false) && (overall_mode < MODE_COMBAT) && (party.in_boat >= 0)) {
if (spec == TER_SPEC_TOWN_ENTRANCE)
return;
play_sound(48);
}
else if ((monsters_going == false) && (overall_mode < MODE_COMBAT) && (party.in_horse >= 0)) {////
play_sound(85);
}
else if(spec == TER_SPEC_POISON_LAND) //if poisoned land don't play squish sound : BoE legacy behavior, can be removed safely
return;
// else if(spec == TER_SPEC_DISEASED_LAND) //if diseased land do the same
// return;
else switch(scenario.ter_types[ter].step_sound){
case 0:
if (step % 2 == 0) //footsteps alternate sound
play_sound(49);
else play_sound(50);
break;
case 1:
play_sound(55); //squish
break;
case 2:
play_sound(47); //crunch
break;
case 3:
break; //silence : do nothing
default:
if (step % 2 == 0) //safety footsteps valve
play_sound(49);
else play_sound(50);
}
}
#endif

View File

@@ -0,0 +1,52 @@
/*
* soundtool.h
* BoE
*
* Created by Celtic Minstrel on 16/04/09.
*
*/
#ifndef _SOUNDTOOL_H
#define _SOUNDTOOL_H
#define NUM_SOUNDS 100
typedef unsigned short snd_num_t;
void init_snd_tool();
void play_sound(short which, short how_many_times = 1);
void one_sound(short which);
#if defined(__APPLE__)
void clear_sound_memory();
void flip_sound();
extern Handle sound_handles[NUM_SOUNDS];
extern SndChannelPtr chan[4];
extern char numchannel;
extern char channel;
#elif defined(WIN32)
#include <windows.h> // for HMODULE
void load_sounds (HMODULE handle);
void sound_pause(long len);
void kill_sound();
extern HMODULE hModule;
extern short can_ignore[100];
extern bool sounds_missing;
extern HGLOBAL sound_handles[NUM_SOUNDS];
extern char* snds[NUM_SOUNDS];
#else
#error Invalid platform
#endif
extern short snd_played[4];
extern bool play_sounds;
extern short last_played;
extern bool always_asynch[100];
extern bool load_when_play[100];
extern short sound_delay[100];
extern short store_last_sound_played;
void move_sound(unsigned char ter,short step);
#endif

View File

@@ -0,0 +1,130 @@
#ifdef __APPLE__
#include <Carbon/Carbon.h>
Handle sound_handles[NUM_SOUNDS];
#else
#include <windows.h>
#endif
bool play_sounds = true;
short last_played = 10000;
short store_last_sound_played = 0;
#ifdef __APPLE__ // TODO: should go over these to decide how to merge them
bool always_asynch[100] = {
false,false,false,false,false,
false,true,false,false,false,
false,false,false,false,false, // 10
false,false,false,false,false,
false,false,false,false,true, // 20
true,false,false,false,false,
false,false,false,false,true, // 30
false,false,true,false,true,
false,true,true,true,true, // 40
true,true,true,true,true,
true,false,false,false,false, // 50
true,false,false,false,false,
false,true,false,false,false, // 60
false,false,false,false,false,
false,false,false,false,false, // 70
false,true,true,true,true,
true,true,true,true,false, // 80
true,false,false,false,false,
false,true,false,false,false, // 90
false,false,false,false,false
};
bool load_when_play[100] = {
0,0,1,1,1,1,0,1,1,1,
0,0,0,1,0,1,1,1,1,1,
1,1,1,1,1,1,1,0,1,1,
1,1,1,1,0,1,1,0,1,1,
1,1,1,1,1,1,1,0,0,0,
0,1,1,1,1,0,1,1,1,1,
1,0,1,1,1,1,1,1,1,0,
0,0,0,0,0,0,1,1,1,1,
1,1,1,1,1,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,0
};
#else
bool always_asynch[100] = {
false,false,false,false,false,
true,true,false,false,false,
true,false,false,false,false, // 10
false,false,false,false,false,
false,false,true,false,true, // 20
true,false,false,false,false,
false,false,false,false,true, // 30
false,false,true,false,true,
false,true,true,true,true, // 40
true,true,true,true,true,
true,false,false,true,false, // 50
true,false,false,false,false,
false,true,false,false,false, // 60
false,false,false,false,false,
false,false,false,false,false, // 70
false,true,true,true,true,
true,true,true,true,false, // 80
true,false,false,false,false,
false,true,false,false,false, // 90
false,false,false,false,false};
bool load_when_play[100] = {
0,0,1,1,1,0,0,1,1,1,
0,0,0,1,0,1,1,1,1,1,
1,1,0,1,1,1,1,0,1,1,
1,1,1,1,0,1,1,0,1,1,
1,1,1,1,1,1,1,0,0,0,
0,1,1,0,1,0,1,1,1,1, // 50
1,0,1,1,1,1,1,1,1,0,
0,0,0,0,0,0,0,0,0,0, // 70
1,1,1,1,1,0,0,0,0,0,
1,0,1,1,1,1,1,1,1,0
};
#endif
short sound_delay[100] = {
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,25,25,0,0,0,0,
0,0,0,0,8,0,0,8,0,0,
0,0,0,10,20,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,13,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0
};
bool sounds_missing = false;
short can_ignore[100] = {
0,0,0,0,0,5,3,0,0,0,
5,5,5,0,5,0,0,0,0,0,
0,0,5,0,0,0,0,0,0,2,
2,2,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,1,1,1,
1,0,0,5,0,1,0,0,0,0, // 50
0,0,0,0,5,0,0,0,0,0,
0,0,0,0,0, 0,5,5,5,5, // 70
4,4,4,4,0,0,0,0,0,0,
0,5,5,0,0,0,0,0,0,0
}; // currently windows-only?
// 1 - polite asych, 1 or 2 or 3- lose easily when pref is set for fewer snds
// 3 can be async
// 4 - nostop asynch ... when 4, this sound is NOSTOP, i.e. when played, is played
// asynch, and refuses all other sounds. Sounds that come in are ignored, and
// disappear into the ether
// 5 - finally, bold asynch ... when 5, this sound is NOSTOP, i.e. when played, is played
// asynch, and refuses all other sounds. When a sound is played on top of this, game
// hangs on until sound is done, and then and only then plays later sound.
//Allocate SndChannelPtr chan[4] as a global variable.
//Allocate char numchannel = 3; (This gives 4 channels, = 2 gives 3 etc...
//Allocate char channel; This is just used as a counter so each sound is played by the next
//channel in line. You can have up to 4 sounds playing at once.
#ifdef __APPLE__
SndChannelPtr chan[4];
char numchannel = 3;
char channel;
#else
HMODULE hModule;
#endif
short snd_played[4] = {-1,-1,-1,-1};