Converted fprintf(stderr) to logging facility (most)
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2334 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+68
-55
@@ -28,6 +28,7 @@
|
|||||||
#include "libs/compiler.h"
|
#include "libs/compiler.h"
|
||||||
#include "libs/uio.h"
|
#include "libs/uio.h"
|
||||||
#include "libs/strlib.h"
|
#include "libs/strlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -93,8 +94,8 @@ findFileInDirs (const char *locs[], int numLocs, const char *file)
|
|||||||
if (locLen + (needSlash ? 1 : 0) + fileLen + 1 >= sizeof path)
|
if (locLen + (needSlash ? 1 : 0) + fileLen + 1 >= sizeof path)
|
||||||
{
|
{
|
||||||
// This dir plus the file name is too long.
|
// This dir plus the file name is too long.
|
||||||
fprintf (stderr, "Warning: path '%s' is ignored because it is "
|
log_add (log_Warning, "Warning: path '%s' is ignored"
|
||||||
"too long.\n", loc);
|
" because it is too long.", loc);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,20 +135,19 @@ prepareContentDir (const char *contentDirName, const char **addons)
|
|||||||
}
|
}
|
||||||
if (loc == NULL)
|
if (loc == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Fatal error: Could not find content.\n");
|
log_add (log_Always, "Fatal error: Could not find content.");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expandPath(path, sizeof path, loc, EP_ALL_SYSTEM) == -1)
|
if (expandPath (path, sizeof path, loc, EP_ALL_SYSTEM) == -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Fatal error: Could not expand path to content "
|
log_add (log_Always, "Fatal error: Could not expand path to content "
|
||||||
"directory: %s\n", strerror (errno));
|
"directory: %s", strerror (errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "Using '%s' as base content dir.", path);
|
||||||
fprintf (stderr, "Using '%s' as base content dir.\n", path);
|
|
||||||
#endif
|
|
||||||
mountContentDir (repository, path, addons);
|
mountContentDir (repository, path, addons);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,8 @@ prepareConfigDir (const char *configDirName) {
|
|||||||
static uio_AutoMount *autoMount[] = { NULL };
|
static uio_AutoMount *autoMount[] = { NULL };
|
||||||
uio_MountHandle *contentHandle;
|
uio_MountHandle *contentHandle;
|
||||||
|
|
||||||
if (configDirName == NULL) {
|
if (configDirName == NULL)
|
||||||
|
{
|
||||||
configDirName = getenv("UQM_CONFIG_DIR");
|
configDirName = getenv("UQM_CONFIG_DIR");
|
||||||
|
|
||||||
if (configDirName == NULL)
|
if (configDirName == NULL)
|
||||||
@@ -169,14 +170,12 @@ prepareConfigDir (const char *configDirName) {
|
|||||||
{
|
{
|
||||||
// Doesn't have to be fatal, but might mess up things when saving
|
// Doesn't have to be fatal, but might mess up things when saving
|
||||||
// config files.
|
// config files.
|
||||||
fprintf (stderr, "Fatal error: Invalid path to config files.\n");
|
log_add (log_Always, "Fatal error: Invalid path to config files.");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
configDirName = buf;
|
configDirName = buf;
|
||||||
|
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "Using config dir '%s'", configDirName);
|
||||||
fprintf (stderr, "Using config dir '%s'\n", configDirName);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set the environment variable UQM_CONFIG_DIR so UQM_MELEE_DIR
|
// Set the environment variable UQM_CONFIG_DIR so UQM_MELEE_DIR
|
||||||
// and UQM_SAVE_DIR can refer to it.
|
// and UQM_SAVE_DIR can refer to it.
|
||||||
@@ -189,15 +188,17 @@ prepareConfigDir (const char *configDirName) {
|
|||||||
contentHandle = uio_mountDir (repository, "/",
|
contentHandle = uio_mountDir (repository, "/",
|
||||||
uio_FSTYPE_STDIO, NULL, NULL, configDirName, autoMount,
|
uio_FSTYPE_STDIO, NULL, NULL, configDirName, autoMount,
|
||||||
uio_MOUNT_TOP, NULL);
|
uio_MOUNT_TOP, NULL);
|
||||||
if (contentHandle == NULL) {
|
if (contentHandle == NULL)
|
||||||
fprintf (stderr, "Fatal error: Could not mount config dir: %s\n",
|
{
|
||||||
|
log_add (log_Always, "Fatal error: Could not mount config dir: %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
configDir = uio_openDir (repository, "/", 0);
|
configDir = uio_openDir (repository, "/", 0);
|
||||||
if (configDir == NULL) {
|
if (configDir == NULL)
|
||||||
fprintf (stderr, "Fatal error: Could not open config dir: %s\n",
|
{
|
||||||
|
log_add (log_Always, "Fatal error: Could not open config dir: %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -216,7 +217,7 @@ prepareSaveDir (void) {
|
|||||||
{
|
{
|
||||||
// Doesn't have to be fatal, but might mess up things when saving
|
// Doesn't have to be fatal, but might mess up things when saving
|
||||||
// config files.
|
// config files.
|
||||||
fprintf (stderr, "Fatal error: Invalid path to config files.\n");
|
log_add (log_Always, "Fatal error: Invalid path to config files.");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,15 +227,15 @@ prepareSaveDir (void) {
|
|||||||
// Create the path upto the save dir, if not already existing.
|
// Create the path upto the save dir, if not already existing.
|
||||||
if (mkdirhier (saveDirName) == -1)
|
if (mkdirhier (saveDirName) == -1)
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "Saved games are kept in %s.\n", saveDirName);
|
log_add (log_Debug, "Saved games are kept in %s.", saveDirName);
|
||||||
#endif
|
|
||||||
|
|
||||||
saveDir = uio_openDirRelative (configDir, "save", 0);
|
saveDir = uio_openDirRelative (configDir, "save", 0);
|
||||||
// TODO: this doesn't work if the save dir is not
|
// TODO: this doesn't work if the save dir is not
|
||||||
// "save" in the config dir.
|
// "save" in the config dir.
|
||||||
if (saveDir == NULL) {
|
if (saveDir == NULL)
|
||||||
fprintf (stderr, "Fatal error: Could not open save dir: %s\n",
|
{
|
||||||
|
log_add (log_Always, "Fatal error: Could not open save dir: %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -253,7 +254,7 @@ prepareMeleeDir (void) {
|
|||||||
{
|
{
|
||||||
// Doesn't have to be fatal, but might mess up things when saving
|
// Doesn't have to be fatal, but might mess up things when saving
|
||||||
// config files.
|
// config files.
|
||||||
fprintf (stderr, "Fatal error: Invalid path to config files.\n");
|
log_add (log_Always, "Fatal error: Invalid path to config files.");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,8 +268,9 @@ prepareMeleeDir (void) {
|
|||||||
meleeDir = uio_openDirRelative (configDir, "teams", 0);
|
meleeDir = uio_openDirRelative (configDir, "teams", 0);
|
||||||
// TODO: this doesn't work if the save dir is not
|
// TODO: this doesn't work if the save dir is not
|
||||||
// "teams" in the config dir.
|
// "teams" in the config dir.
|
||||||
if (meleeDir == NULL) {
|
if (meleeDir == NULL)
|
||||||
fprintf (stderr, "Fatal error: Could not open melee teams dir: %s\n",
|
{
|
||||||
|
log_add (log_Always, "Fatal error: Could not open melee teams dir: %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -285,28 +287,30 @@ mountContentDir (uio_Repository *repository, const char *contentPath,
|
|||||||
contentHandle = uio_mountDir (repository, "/",
|
contentHandle = uio_mountDir (repository, "/",
|
||||||
uio_FSTYPE_STDIO, NULL, NULL, contentPath, autoMount,
|
uio_FSTYPE_STDIO, NULL, NULL, contentPath, autoMount,
|
||||||
uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
|
uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
|
||||||
if (contentHandle == NULL) {
|
if (contentHandle == NULL)
|
||||||
fprintf (stderr, "Fatal error: Could not mount content dir: %s\n",
|
{
|
||||||
|
log_add (log_Always, "Fatal error: Could not mount content dir: %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
contentDir = uio_openDir (repository, "/", 0);
|
contentDir = uio_openDir (repository, "/", 0);
|
||||||
if (contentDir == NULL) {
|
if (contentDir == NULL)
|
||||||
fprintf (stderr, "Fatal error: Could not open content dir: %s\n",
|
{
|
||||||
|
log_add (log_Always, "Fatal error: Could not open content dir: %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
packagesDir = uio_openDir (repository, "/packages", 0);
|
packagesDir = uio_openDir (repository, "/packages", 0);
|
||||||
if (packagesDir == NULL) {
|
if (packagesDir == NULL)
|
||||||
// No packages dir means no packages to load.
|
{ // No packages dir means no packages to load.
|
||||||
if (addons[0] != NULL) {
|
if (addons[0] != NULL)
|
||||||
// addons were specified, but there's no /packages dir,
|
{ // addons were specified, but there's no /packages dir,
|
||||||
// let alone a /packages/addons dir.
|
// let alone a /packages/addons dir.
|
||||||
fprintf (stderr, "Warning: There's no 'packages/addons' "
|
log_add (log_Always, "Warning: There's no 'packages/addons' "
|
||||||
"directory in the 'content' directory;\n\t'--addon' "
|
"directory in the 'content' directory;\n\t'--addon' "
|
||||||
"options are ignored.\n");
|
"options are ignored.");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -317,11 +321,11 @@ mountContentDir (uio_Repository *repository, const char *contentPath,
|
|||||||
// the former is the dir 'packages/addons', the latter a directory
|
// the former is the dir 'packages/addons', the latter a directory
|
||||||
// in that dir.
|
// in that dir.
|
||||||
addonsDir = uio_openDirRelative (packagesDir, "addons", 0);
|
addonsDir = uio_openDirRelative (packagesDir, "addons", 0);
|
||||||
if (addonsDir == NULL) {
|
if (addonsDir == NULL)
|
||||||
// No addon dir found.
|
{ // No addon dir found.
|
||||||
fprintf (stderr, "Warning: There's no 'packages/addons' "
|
log_add (log_Always, "Warning: There's no 'packages/addons' "
|
||||||
"directory in the 'content' directory;\n\t'--addon' "
|
"directory in the 'content' directory;\n\t'--addon' "
|
||||||
"options are ignored.\n");
|
"options are ignored.");
|
||||||
uio_closeDir (packagesDir);
|
uio_closeDir (packagesDir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -329,31 +333,37 @@ mountContentDir (uio_Repository *repository, const char *contentPath,
|
|||||||
uio_closeDir (packagesDir);
|
uio_closeDir (packagesDir);
|
||||||
|
|
||||||
availableAddons = uio_getDirList (addonsDir, "", "", match_MATCH_PREFIX);
|
availableAddons = uio_getDirList (addonsDir, "", "", match_MATCH_PREFIX);
|
||||||
if (availableAddons != NULL) {
|
if (availableAddons != NULL)
|
||||||
|
{
|
||||||
int i, count;
|
int i, count;
|
||||||
count = availableAddons->numNames;
|
count = availableAddons->numNames;
|
||||||
|
|
||||||
if (count != 1)
|
if (count != 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%d available addon packs.\n", count);
|
log_add (log_Always, "%d available addon packs.", count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "1 available addon pack.\n");
|
log_add (log_Always, "1 available addon pack.");
|
||||||
}
|
}
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++)
|
||||||
fprintf (stderr, " %d. %s\n", i+1, availableAddons->names[i]);
|
{
|
||||||
|
log_add (log_Always, " %d. %s", i+1,
|
||||||
|
availableAddons->names[i]);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
fprintf (stderr, "0 available addon packs.\n");
|
else
|
||||||
|
{
|
||||||
|
log_add (log_Always, "0 available addon packs.");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; *addons != NULL; addons++)
|
for (; *addons != NULL; addons++)
|
||||||
{
|
{
|
||||||
addonDir = uio_openDirRelative (addonsDir, *addons, 0);
|
addonDir = uio_openDirRelative (addonsDir, *addons, 0);
|
||||||
if (addonDir == NULL) {
|
if (addonDir == NULL)
|
||||||
fprintf (stderr, "Warning: directory 'packages/addons/%s' "
|
{
|
||||||
"not found; addon skipped.\n", *addons);
|
log_add (log_Always, "Warning: directory 'packages/addons/%s' "
|
||||||
|
"not found; addon skipped.", *addons);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,15 +383,18 @@ mountDirZips (uio_MountHandle *contentHandle, uio_DirHandle *dirHandle)
|
|||||||
|
|
||||||
dirList = uio_getDirList (dirHandle, "", ".(zip|uqm)$",
|
dirList = uio_getDirList (dirHandle, "", ".(zip|uqm)$",
|
||||||
match_MATCH_REGEX);
|
match_MATCH_REGEX);
|
||||||
if (dirList != NULL) {
|
if (dirList != NULL)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < dirList->numNames; i++) {
|
for (i = 0; i < dirList->numNames; i++)
|
||||||
|
{
|
||||||
if (uio_mountDir (repository, "/", uio_FSTYPE_ZIP,
|
if (uio_mountDir (repository, "/", uio_FSTYPE_ZIP,
|
||||||
dirHandle, dirList->names[i], "/", autoMount,
|
dirHandle, dirList->names[i], "/", autoMount,
|
||||||
uio_MOUNT_BELOW | uio_MOUNT_RDONLY,
|
uio_MOUNT_BELOW | uio_MOUNT_RDONLY,
|
||||||
contentHandle) == NULL) {
|
contentHandle) == NULL)
|
||||||
fprintf (stderr, "Warning: Could not mount '%s': %s.\n",
|
{
|
||||||
|
log_add (log_Always, "Warning: Could not mount '%s': %s.",
|
||||||
dirList->names[i], strerror (errno));
|
dirList->names[i], strerror (errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ typedef unsigned short mode_t;
|
|||||||
// Printf
|
// Printf
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
|
#define vsnprintf _vsnprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// setenv()
|
// setenv()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "libs/gfxlib.h"
|
#include "libs/gfxlib.h"
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
#include "libs/threadlib.h"
|
#include "libs/threadlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
// the running of the game-clock is based on game framerates
|
// the running of the game-clock is based on game framerates
|
||||||
// *not* on the system (or translated) timer
|
// *not* on the system (or translated) timer
|
||||||
@@ -225,7 +225,8 @@ SuspendGameClock (void)
|
|||||||
{
|
{
|
||||||
if (!clock_mutex)
|
if (!clock_mutex)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "BUG: Attempted to suspend non-existent game clock\n");
|
log_add (log_Always, "BUG: "
|
||||||
|
"Attempted to suspend non-existent game clock");
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
abort();
|
abort();
|
||||||
#endif
|
#endif
|
||||||
@@ -245,7 +246,8 @@ ResumeGameClock (void)
|
|||||||
{
|
{
|
||||||
if (!clock_mutex)
|
if (!clock_mutex)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "BUG: Attempted to resume non-existent game clock\n");
|
log_add (log_Always, "BUG: "
|
||||||
|
"Attempted to resume non-existent game clock\n");
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
abort();
|
abort();
|
||||||
#endif
|
#endif
|
||||||
@@ -271,7 +273,6 @@ SetGameClockRate (COUNT seconds_per_day)
|
|||||||
{
|
{
|
||||||
SIZE new_day_in_ticks, new_tick_count;
|
SIZE new_day_in_ticks, new_tick_count;
|
||||||
|
|
||||||
//if (GLOBAL (GameClock.clock_sem)) fprintf (stderr, "%u\n", GLOBAL (GameClock.clock_sem));
|
|
||||||
SetSemaphore (GLOBAL (GameClock.clock_sem));
|
SetSemaphore (GLOBAL (GameClock.clock_sem));
|
||||||
new_day_in_ticks = (SIZE)(seconds_per_day * CLOCK_BASE_FRAMERATE);
|
new_day_in_ticks = (SIZE)(seconds_per_day * CLOCK_BASE_FRAMERATE);
|
||||||
if (GLOBAL (GameClock.day_in_ticks) == 0)
|
if (GLOBAL (GameClock.day_in_ticks) == 0)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "races.h"
|
#include "races.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_COLLIDE
|
//#define DEBUG_COLLIDE
|
||||||
@@ -61,10 +62,10 @@ collide (ELEMENTPTR ElementPtr0, ELEMENTPTR ElementPtr1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_COLLIDE
|
#ifdef DEBUG_COLLIDE
|
||||||
fprintf (stderr, "Centers: <%d, %d> <%d, %d>\n",
|
log_add (log_Debug, "Centers: <%d, %d> <%d, %d>",
|
||||||
ElementPtr0->next.location.x, ElementPtr0->next.location.y,
|
ElementPtr0->next.location.x, ElementPtr0->next.location.y,
|
||||||
ElementPtr1->next.location.x, ElementPtr1->next.location.y);
|
ElementPtr1->next.location.x, ElementPtr1->next.location.y);
|
||||||
fprintf (stderr, "RelTravelAngle : %d, ImpactAngles <%d, %d>\n",
|
log_add (log_Debug, "RelTravelAngle : %d, ImpactAngles <%d, %d>",
|
||||||
RelTravelAngle, ImpactAngle0, ImpactAngle1);
|
RelTravelAngle, ImpactAngle0, ImpactAngle1);
|
||||||
#endif /* DEBUG_COLLIDE */
|
#endif /* DEBUG_COLLIDE */
|
||||||
|
|
||||||
@@ -83,8 +84,10 @@ collide (ELEMENTPTR ElementPtr0, ELEMENTPTR ElementPtr1)
|
|||||||
ElementPtr0->state_flags |= (DEFY_PHYSICS | COLLISION);
|
ElementPtr0->state_flags |= (DEFY_PHYSICS | COLLISION);
|
||||||
ElementPtr1->state_flags |= (DEFY_PHYSICS | COLLISION);
|
ElementPtr1->state_flags |= (DEFY_PHYSICS | COLLISION);
|
||||||
#ifdef DEBUG_COLLIDE
|
#ifdef DEBUG_COLLIDE
|
||||||
fprintf (stderr, "No movement before collision -- <(%d, %d) = %d, (%d, %d) = %d>\n",
|
log_add (log_Debug, "No movement before collision -- "
|
||||||
dx0, dy0, ImpactAngle0 - OCTANT, dx1, dy1, ImpactAngle1 - OCTANT);
|
"<(%d, %d) = %d, (%d, %d) = %d>",
|
||||||
|
dx0, dy0, ImpactAngle0 - OCTANT, dx1, dy1,
|
||||||
|
ImpactAngle1 - OCTANT);
|
||||||
#endif /* DEBUG_COLLIDE */
|
#endif /* DEBUG_COLLIDE */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +175,7 @@ collide (ELEMENTPTR ElementPtr0, ELEMENTPTR ElementPtr1)
|
|||||||
#ifdef DEBUG_COLLIDE
|
#ifdef DEBUG_COLLIDE
|
||||||
GetCurrentVelocityComponents (&ElementPtr0->velocity, &dx0, &dy0);
|
GetCurrentVelocityComponents (&ElementPtr0->velocity, &dx0, &dy0);
|
||||||
GetCurrentVelocityComponents (&ElementPtr1->velocity, &dx1, &dy1);
|
GetCurrentVelocityComponents (&ElementPtr1->velocity, &dx1, &dy1);
|
||||||
fprintf (stderr, "After: <%d, %d> <%d, %d>\n\n",
|
log_add (log_Debug, "After: <%d, %d> <%d, %d>\n",
|
||||||
dx0, dy0, dx1, dy1);
|
dx0, dy0, dx1, dy1);
|
||||||
#endif /* DEBUG_COLLIDE */
|
#endif /* DEBUG_COLLIDE */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "libs/sound/trackplayer.h"
|
#include "libs/sound/trackplayer.h"
|
||||||
#include "libs/sound/trackint.h"
|
#include "libs/sound/trackint.h"
|
||||||
#include "libs/strlib.h"
|
#include "libs/strlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -1579,10 +1580,10 @@ DoCommunication (PENCOUNTER_STATE pES)
|
|||||||
}
|
}
|
||||||
if ((unsigned)space_index >= sizeof (buffer))
|
if ((unsigned)space_index >= sizeof (buffer))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "DoCommunication() BUG: buffer[%u] "
|
log_add (log_Always, "DoCommunication() BUG: "
|
||||||
"too small to fit %d bytes\n",
|
"buffer[%u] too small to fit %d bytes\n",
|
||||||
sizeof (buffer), space_index);
|
sizeof (buffer), space_index);
|
||||||
abort ();
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
strncpy (buffer, temp, space_index);
|
strncpy (buffer, temp, space_index);
|
||||||
buffer[space_index] = '\0';
|
buffer[space_index] = '\0';
|
||||||
@@ -2251,7 +2252,6 @@ do_subtitles (UNICODE *pStr)
|
|||||||
}
|
}
|
||||||
subtitle_state = READ_SUBTITLE;
|
subtitle_state = READ_SUBTITLE;
|
||||||
ClearSubtitle = TRUE;
|
ClearSubtitle = TRUE;
|
||||||
// fprintf (stderr, "changed page to: %d\n", cur_page);
|
|
||||||
}
|
}
|
||||||
last_page = pStr;
|
last_page = pStr;
|
||||||
|
|
||||||
|
|||||||
@@ -337,9 +337,6 @@ ZoqFotIntro (RESPONSE_REF R)
|
|||||||
DISABLE_PHRASE (what_look_like);
|
DISABLE_PHRASE (what_look_like);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fprintf (stderr, "yr = 0x%x wf = 0x%x\n", alien_text[your_race][0], alien_text[where_from][0]);
|
|
||||||
// fprintf (stderr, "we = 0x%x tl = 0x%x\n", alien_text[what_emergency][0], alien_text[tough_luck][0]);
|
|
||||||
// fprintf (stderr, "wll = 0x%x\n", what_look_like);
|
|
||||||
if (PHRASE_ENABLED (your_race)
|
if (PHRASE_ENABLED (your_race)
|
||||||
|| PHRASE_ENABLED (where_from)
|
|| PHRASE_ENABLED (where_from)
|
||||||
|| PHRASE_ENABLED (what_emergency))
|
|| PHRASE_ENABLED (what_emergency))
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
int NPCNumberPhrase (int number, UNICODE **ptrack);
|
int NPCNumberPhrase (int number, UNICODE **ptrack);
|
||||||
|
|
||||||
@@ -285,9 +286,9 @@ construct_response (UNICODE *buf, int R /* promoted from RESPONSE_REF */, ...)
|
|||||||
if ((buf_start == shared_phrase_buf) &&
|
if ((buf_start == shared_phrase_buf) &&
|
||||||
(buf > shared_phrase_buf + sizeof (shared_phrase_buf)))
|
(buf > shared_phrase_buf + sizeof (shared_phrase_buf)))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: shared_phrase_buf size exceeded,"
|
log_add (log_Always, "Error: shared_phrase_buf size exceeded,"
|
||||||
" please increase!\n");
|
" please increase!\n");
|
||||||
abort ();
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "libs/graphics/widgets.h"
|
#include "libs/graphics/widgets.h"
|
||||||
#include "libs/inplib.h"
|
#include "libs/inplib.h"
|
||||||
#include "libs/sound/trackplayer.h"
|
#include "libs/sound/trackplayer.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@ DoConfirmExit (void)
|
|||||||
{
|
{
|
||||||
BOOLEAN result;
|
BOOLEAN result;
|
||||||
static BOOLEAN in_confirm = FALSE;
|
static BOOLEAN in_confirm = FALSE;
|
||||||
fprintf (stderr, "Confirming Exit!\n");
|
log_add (log_Info, "Confirming Exit!\n");
|
||||||
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
|
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE &&
|
||||||
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE &&
|
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE &&
|
||||||
!(LastActivity & CHECK_RESTART))
|
!(LastActivity & CHECK_RESTART))
|
||||||
@@ -189,7 +190,7 @@ DoConfirmExit (void)
|
|||||||
do_subtitles ((void *)~0);
|
do_subtitles ((void *)~0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "Exit was %sconfirmed.\n", result ? "" : "NOT ");
|
log_add (log_Info, "Exit was %sconfirmed.\n", result ? "" : "NOT ");
|
||||||
in_confirm = FALSE;
|
in_confirm = FALSE;
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "libs/inplib.h"
|
#include "libs/inplib.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
//#define DEBUG_CYBORG
|
//#define DEBUG_CYBORG
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ InitCyborg (STARSHIPPTR StarShipPtr)
|
|||||||
char buf[40];
|
char buf[40];
|
||||||
|
|
||||||
GetStringContents (StarShipPtr->RaceDescPtr->ship_data.race_strings, buf, FALSE);
|
GetStringContents (StarShipPtr->RaceDescPtr->ship_data.race_strings, buf, FALSE);
|
||||||
fprintf (stderr, "MI(%s) -- <%u:%u> = %u\n", buf,
|
log_add (log_Debug, "MI(%s) -- <%u:%u> = %u", buf,
|
||||||
StarShipPtr->RaceDescPtr->characteristics.max_thrust *
|
StarShipPtr->RaceDescPtr->characteristics.max_thrust *
|
||||||
StarShipPtr->RaceDescPtr->characteristics.thrust_increment,
|
StarShipPtr->RaceDescPtr->characteristics.thrust_increment,
|
||||||
Divisor, Index);
|
Divisor, Index);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "displist.h"
|
#include "displist.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file contains code for generic doubly linked lists.
|
* This file contains code for generic doubly linked lists.
|
||||||
@@ -35,7 +36,10 @@ InitQueue (PQUEUE pq, COUNT num_elements, OBJ_SIZE size)
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
#else /* QUEUE_TABLE */
|
#else /* QUEUE_TABLE */
|
||||||
SetFreeList (pq, NULL_HANDLE);
|
SetFreeList (pq, NULL_HANDLE);
|
||||||
// fprintf (stderr, "num_elements = %d (%d)\n", num_elements, (BYTE)num_elements);
|
#if 0
|
||||||
|
log_add (log_Debug, "InitQueue(): num_elements = %d (%d)",
|
||||||
|
num_elements, (BYTE)num_elements);
|
||||||
|
#endif
|
||||||
if (AllocQueueTab (pq, num_elements) && LockQueueTab (pq))
|
if (AllocQueueTab (pq, num_elements) && LockQueueTab (pq))
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
@@ -111,10 +115,9 @@ AllocLink (PQUEUE pq)
|
|||||||
SetFreeList (pq, _GetSuccLink (LinkPtr));
|
SetFreeList (pq, _GetSuccLink (LinkPtr));
|
||||||
UnlockLink (pq, hLink);
|
UnlockLink (pq, hLink);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
else
|
else
|
||||||
fprintf (stderr, "No more elements\n");
|
log_add (log_Debug, "AllocLink(): No more elements");
|
||||||
*/
|
|
||||||
return (hLink);
|
return (hLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "races.h"
|
#include "races.h"
|
||||||
|
|
||||||
#include "libs/compiler.h"
|
#include "libs/compiler.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -356,7 +357,7 @@ CaptureCodeRes (MEM_HANDLE hCode, PVOID pData, PVOID *ppLocData)
|
|||||||
|
|
||||||
if (hCode == 0)
|
if (hCode == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Ack! dummy.c::CaptureCodeRes() hCode==0! FATAL!\n");
|
log_add (log_Always, "dummy.c::CaptureCodeRes() hCode==0! FATAL!");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "libs/gfxlib.h"
|
#include "libs/gfxlib.h"
|
||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
extern COUNT zoom_out;
|
extern COUNT zoom_out;
|
||||||
extern PRIM_LINKS DisplayLinks;
|
extern PRIM_LINKS DisplayLinks;
|
||||||
@@ -238,7 +238,9 @@ InitGalaxy (void)
|
|||||||
PPOINT ppt;
|
PPOINT ppt;
|
||||||
PRIM_LINKS Links;
|
PRIM_LINKS Links;
|
||||||
|
|
||||||
// fprintf (stderr, "transition_width = %d transition_height = %d\n", TRANSITION_WIDTH, TRANSITION_HEIGHT);
|
log_add (log_Debug, "InitGalaxy(): transition_width = %d, "
|
||||||
|
"transition_height = %d",
|
||||||
|
TRANSITION_WIDTH, TRANSITION_HEIGHT);
|
||||||
|
|
||||||
Links = MakeLinks (END_OF_LIST, END_OF_LIST);
|
Links = MakeLinks (END_OF_LIST, END_OF_LIST);
|
||||||
factor = ONE_SHIFT + MAX_REDUCTION + (BACKGROUND_SHIFT - 3);
|
factor = ONE_SHIFT + MAX_REDUCTION + (BACKGROUND_SHIFT - 3);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "libs/inplib.h"
|
#include "libs/inplib.h"
|
||||||
#include "libs/misc.h"
|
#include "libs/misc.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "globdata.h"
|
#include "globdata.h"
|
||||||
#include "sounds.h"
|
#include "sounds.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@@ -163,8 +164,8 @@ DoTextEntry (PTEXTENTRY_STATE pTES)
|
|||||||
{
|
{
|
||||||
if (lwlen < pTES->JoyRegLength)
|
if (lwlen < pTES->JoyRegLength)
|
||||||
pTES->JoyRegLength = lwlen;
|
pTES->JoyRegLength = lwlen;
|
||||||
fprintf (stderr, "Warning: Joystick upper-lower registers size "
|
log_add (log_Warning, "Warning: Joystick upper-lower registers"
|
||||||
"mismatch; using the smallest subset (%d)\n",
|
" size mismatch; using the smallest subset (%d)",
|
||||||
pTES->JoyRegLength);
|
pTES->JoyRegLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef STATE_DEBUG
|
#ifdef STATE_DEBUG
|
||||||
# include <stdio.h>
|
# include "libs/log.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ setGameState (int startBit, int endBit, BYTE val
|
|||||||
| (BYTE)((val) >> (endBit - startBit - (endBit & 7)));
|
| (BYTE)((val) >> (endBit - startBit - (endBit & 7)));
|
||||||
}
|
}
|
||||||
#ifdef STATE_DEBUG
|
#ifdef STATE_DEBUG
|
||||||
fprintf (stderr, "State '%s' set to %d.\n", name, val);
|
log_add (log_Debug, "State '%s' set to %d.", name, val);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "collide.h"
|
#include "collide.h"
|
||||||
#include "races.h"
|
#include "races.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
//#define DEBUG_GRAVITY
|
//#define DEBUG_GRAVITY
|
||||||
|
|
||||||
@@ -64,15 +64,15 @@ CalculateGravity (PELEMENT ElementPtr)
|
|||||||
#ifdef DEBUG_GRAVITY
|
#ifdef DEBUG_GRAVITY
|
||||||
if (TestElementPtr->state_flags & PLAYER_SHIP)
|
if (TestElementPtr->state_flags & PLAYER_SHIP)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "CalculateGravity:\n");
|
log_add (log_Debug, "CalculateGravity:");
|
||||||
fprintf (stderr, "\tdx = %d, dy = %d\n", dx, dy);
|
log_add (log_Debug, "\tdx = %d, dy = %d", dx, dy);
|
||||||
}
|
}
|
||||||
#endif /* DEBUG_GRAVITY */
|
#endif /* DEBUG_GRAVITY */
|
||||||
dx = WRAP_DELTA_X (dx);
|
dx = WRAP_DELTA_X (dx);
|
||||||
dy = WRAP_DELTA_Y (dy);
|
dy = WRAP_DELTA_Y (dy);
|
||||||
#ifdef DEBUG_GRAVITY
|
#ifdef DEBUG_GRAVITY
|
||||||
if (TestElementPtr->state_flags & PLAYER_SHIP)
|
if (TestElementPtr->state_flags & PLAYER_SHIP)
|
||||||
fprintf (stderr, "\twrap_dx = %d, wrap_dy = %d\n", dx, dy);
|
log_add (log_Debug, "\twrap_dx = %d, wrap_dy = %d", dx, dy);
|
||||||
#endif /* DEBUG_GRAVITY */
|
#endif /* DEBUG_GRAVITY */
|
||||||
abs_dx = dx >= 0 ? dx : -dx;
|
abs_dx = dx >= 0 ? dx : -dx;
|
||||||
abs_dy = dy >= 0 ? dy : -dy;
|
abs_dy = dy >= 0 ? dy : -dy;
|
||||||
@@ -80,7 +80,8 @@ CalculateGravity (PELEMENT ElementPtr)
|
|||||||
abs_dy = WORLD_TO_DISPLAY (abs_dy);
|
abs_dy = WORLD_TO_DISPLAY (abs_dy);
|
||||||
#ifdef DEBUG_GRAVITY
|
#ifdef DEBUG_GRAVITY
|
||||||
if (TestElementPtr->state_flags & PLAYER_SHIP)
|
if (TestElementPtr->state_flags & PLAYER_SHIP)
|
||||||
fprintf (stderr, "\tdisplay_dx = %d, display_dy = %d\n", abs_dx, abs_dy);
|
log_add (log_Debug, "\tdisplay_dx = %d, display_dy = %d",
|
||||||
|
abs_dx, abs_dy);
|
||||||
#endif /* DEBUG_GRAVITY */
|
#endif /* DEBUG_GRAVITY */
|
||||||
if (abs_dx <= GRAVITY_THRESHOLD
|
if (abs_dx <= GRAVITY_THRESHOLD
|
||||||
&& abs_dy <= GRAVITY_THRESHOLD)
|
&& abs_dy <= GRAVITY_THRESHOLD)
|
||||||
@@ -106,12 +107,12 @@ CalculateGravity (PELEMENT ElementPtr)
|
|||||||
#define MAX_MAGNITUDE 6
|
#define MAX_MAGNITUDE 6
|
||||||
else if (magnitude > MAX_MAGNITUDE)
|
else if (magnitude > MAX_MAGNITUDE)
|
||||||
magnitude = MAX_MAGNITUDE;
|
magnitude = MAX_MAGNITUDE;
|
||||||
fprintf (stderr, "magnitude = %u ", magnitude);
|
log_add (log_Debug, "magnitude = %u", magnitude);
|
||||||
#endif /* NEVER */
|
#endif /* NEVER */
|
||||||
|
|
||||||
#ifdef DEBUG_GRAVITY
|
#ifdef DEBUG_GRAVITY
|
||||||
if (TestElementPtr->state_flags & PLAYER_SHIP)
|
if (TestElementPtr->state_flags & PLAYER_SHIP)
|
||||||
fprintf (stderr, "dist_squared = %lu\n", dist_squared);
|
log_add (log_Debug, "dist_squared = %lu", dist_squared);
|
||||||
#endif /* DEBUG_GRAVITY */
|
#endif /* DEBUG_GRAVITY */
|
||||||
if (TestHasGravity)
|
if (TestHasGravity)
|
||||||
{
|
{
|
||||||
|
|||||||
+15
-14
@@ -25,6 +25,7 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -302,8 +303,8 @@ FlushGroupInfo (GROUP_HEADER *pGH, DWORD offset, BYTE which_group, PVOID fp)
|
|||||||
SeekStateFile (fp, offset, SEEK_SET);
|
SeekStateFile (fp, offset, SEEK_SET);
|
||||||
WriteStateFile (pGH, sizeof (*pGH), 1, fp);
|
WriteStateFile (pGH, sizeof (*pGH), 1, fp);
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
fprintf (stderr, "1)FlushGroupInfo(%lu): WG = %u(%lu), NG = %u, "
|
log_add (log_Debug, "1)FlushGroupInfo(%lu): WG = %u(%lu), NG = %u, "
|
||||||
"SI = %u\n", offset, which_group, pGH->GroupOffset[which_group],
|
"SI = %u", offset, which_group, pGH->GroupOffset[which_group],
|
||||||
pGH->NumGroups, pGH->star_index);
|
pGH->NumGroups, pGH->star_index);
|
||||||
#endif /* DEBUG_GROUPS */
|
#endif /* DEBUG_GROUPS */
|
||||||
|
|
||||||
@@ -336,7 +337,7 @@ FlushGroupInfo (GROUP_HEADER *pGH, DWORD offset, BYTE which_group, PVOID fp)
|
|||||||
|
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
if (which_group == 0)
|
if (which_group == 0)
|
||||||
fprintf (stderr, "F) type %u, loc %u<%d, %d>, task 0x%02x:%u\n",
|
log_add (log_Debug, "F) type %u, loc %u<%d, %d>, task 0x%02x:%u",
|
||||||
RaceType,
|
RaceType,
|
||||||
GET_GROUP_LOC (FragPtr),
|
GET_GROUP_LOC (FragPtr),
|
||||||
FragPtr->ShipInfo.loc.x,
|
FragPtr->ShipInfo.loc.x,
|
||||||
@@ -370,7 +371,7 @@ GetGroupInfo (DWORD offset, BYTE which_group)
|
|||||||
SeekStateFile (fp, offset, SEEK_SET);
|
SeekStateFile (fp, offset, SEEK_SET);
|
||||||
ReadStateFile (&GH, sizeof (GH), 1, fp);
|
ReadStateFile (&GH, sizeof (GH), 1, fp);
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
fprintf (stderr, "GetGroupInfo(%lu): %u(%lu) out of %u\n", offset,
|
log_add (log_Debug, "GetGroupInfo(%lu): %u(%lu) out of %u", offset,
|
||||||
which_group, GH.GroupOffset[which_group], GH.NumGroups);
|
which_group, GH.GroupOffset[which_group], GH.NumGroups);
|
||||||
#endif /* DEBUG_GROUPS */
|
#endif /* DEBUG_GROUPS */
|
||||||
if (which_group == (BYTE)~0)
|
if (which_group == (BYTE)~0)
|
||||||
@@ -379,7 +380,7 @@ GetGroupInfo (DWORD offset, BYTE which_group)
|
|||||||
|
|
||||||
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
fprintf (stderr, "%u == %u\n", GH.star_index,
|
log_add (log_Debug, "%u == %u", GH.star_index,
|
||||||
(COUNT)(CurStarDescPtr - star_array));
|
(COUNT)(CurStarDescPtr - star_array));
|
||||||
#endif /* DEBUG_GROUPS */
|
#endif /* DEBUG_GROUPS */
|
||||||
day_index = GH.day_index;
|
day_index = GH.day_index;
|
||||||
@@ -394,8 +395,8 @@ GetGroupInfo (DWORD offset, BYTE which_group)
|
|||||||
|
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
if (GH.star_index == (COUNT)(CurStarDescPtr - star_array))
|
if (GH.star_index == (COUNT)(CurStarDescPtr - star_array))
|
||||||
fprintf (stderr, "GetGroupInfo: battle groups out of "
|
log_add (log_Debug, "GetGroupInfo: battle groups out of "
|
||||||
"date %u/%u/%u!\n", month_index, day_index,
|
"date %u/%u/%u!", month_index, day_index,
|
||||||
year_index);
|
year_index);
|
||||||
#endif /* DEBUG_GROUPS */
|
#endif /* DEBUG_GROUPS */
|
||||||
fp = OpenStateFile (RANDGRPINFO_FILE, "wb");
|
fp = OpenStateFile (RANDGRPINFO_FILE, "wb");
|
||||||
@@ -478,8 +479,8 @@ GetGroupInfo (DWORD offset, BYTE which_group)
|
|||||||
SET_GROUP_LOC (FragPtr, group_loc);
|
SET_GROUP_LOC (FragPtr, group_loc);
|
||||||
|
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
fprintf (stderr, "battle group %u(0x%04x) strength "
|
log_add (log_Debug, "battle group %u(0x%04x) strength "
|
||||||
"%u, type %u, loc %u<%d, %d>, task %u\n",
|
"%u, type %u, loc %u<%d, %d>, task %u",
|
||||||
which_group,
|
which_group,
|
||||||
hStarShip,
|
hStarShip,
|
||||||
NumShips,
|
NumShips,
|
||||||
@@ -558,8 +559,8 @@ GetGroupInfo (DWORD offset, BYTE which_group)
|
|||||||
|
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
if (which_group == 0)
|
if (which_group == 0)
|
||||||
fprintf (stderr, "G) type %u, loc %u<%d, %d>, "
|
log_add (log_Debug, "G) type %u, loc %u<%d, %d>, "
|
||||||
"task 0x%02x:%u\n",
|
"task 0x%02x:%u",
|
||||||
RaceType,
|
RaceType,
|
||||||
GET_GROUP_LOC (FragPtr),
|
GET_GROUP_LOC (FragPtr),
|
||||||
FragPtr->ShipInfo.loc.x,
|
FragPtr->ShipInfo.loc.x,
|
||||||
@@ -572,7 +573,7 @@ GetGroupInfo (DWORD offset, BYTE which_group)
|
|||||||
|| ShipsLeft)
|
|| ShipsLeft)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
fprintf (stderr, "\n");
|
log_add (log_Debug, "\n");
|
||||||
#endif /* DEBUG_GROUPS */
|
#endif /* DEBUG_GROUPS */
|
||||||
if (RaceType == SHOFIXTI_SHIP
|
if (RaceType == SHOFIXTI_SHIP
|
||||||
&& which_group
|
&& which_group
|
||||||
@@ -593,7 +594,7 @@ GetGroupInfo (DWORD offset, BYTE which_group)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
fprintf (stderr, " -- REMOVING\n");
|
log_add (log_Debug, " -- REMOVING");
|
||||||
#endif /* DEBUG_GROUPS */
|
#endif /* DEBUG_GROUPS */
|
||||||
UnlockStarShip (&GLOBAL (npc_built_ship_q), hStarShip);
|
UnlockStarShip (&GLOBAL (npc_built_ship_q), hStarShip);
|
||||||
RemoveQueue (&GLOBAL (npc_built_ship_q), hStarShip);
|
RemoveQueue (&GLOBAL (npc_built_ship_q), hStarShip);
|
||||||
@@ -660,7 +661,7 @@ PutGroupInfo (DWORD offset, BYTE which_group)
|
|||||||
}
|
}
|
||||||
GH.star_index = CurStarDescPtr - star_array;
|
GH.star_index = CurStarDescPtr - star_array;
|
||||||
#ifdef DEBUG_GROUPS
|
#ifdef DEBUG_GROUPS
|
||||||
fprintf (stderr, "PutGroupInfo(%lu): %u out of %u -- %u/%u/%u\n",
|
log_add (log_Debug, "PutGroupInfo(%lu): %u out of %u -- %u/%u/%u",
|
||||||
offset, which_group, GH.NumGroups,
|
offset, which_group, GH.NumGroups,
|
||||||
GH.month_index, GH.day_index, GH.year_index);
|
GH.month_index, GH.day_index, GH.year_index);
|
||||||
#endif /* DEBUG_GROUPS */
|
#endif /* DEBUG_GROUPS */
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "globdata.h"
|
#include "globdata.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ computer_intelligence (void)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// Should not happen. Satisfying compiler.
|
// Should not happen. Satisfying compiler.
|
||||||
fprintf (stderr, "Warning: Unexpected state in "
|
log_add (log_Warning, "Warning: Unexpected state in "
|
||||||
"computer_intelligence().");
|
"computer_intelligence().");
|
||||||
InputState = 0;
|
InputState = 0;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "libs/sound/sound.h"
|
#include "libs/sound/sound.h"
|
||||||
//#include "libs/vidlib.h"
|
//#include "libs/vidlib.h"
|
||||||
#include "libs/inplib.h"
|
#include "libs/inplib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -576,7 +577,7 @@ DoPresentation (PVOID pIS)
|
|||||||
|
|
||||||
if (cargs < 1)
|
if (cargs < 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Bad DRAW command '%s'\n", pStr);
|
log_add (log_Warning, "Bad DRAW command '%s'", pStr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cargs < 5)
|
if (cargs < 5)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "filintrn.h"
|
#include "filintrn.h"
|
||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
@@ -105,7 +106,7 @@ mkdirhier (const char *path)
|
|||||||
{
|
{
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Can't stat %s: %s\n", buf,
|
log_add (log_Always, "Can't stat %s: %s", buf,
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -131,7 +132,7 @@ mkdirhier (const char *path)
|
|||||||
{
|
{
|
||||||
if (createDirectory (buf, 0777) == -1)
|
if (createDirectory (buf, 0777) == -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Can't create %s: %s\n", buf,
|
log_add (log_Always, "Error: Can't create %s: %s", buf,
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -264,9 +265,9 @@ expandPath (char *dest, size_t len, const char *src, int what)
|
|||||||
// fallback for when the APPDATA env var is not set
|
// fallback for when the APPDATA env var is not set
|
||||||
// Using SHGetFolderPath or SHGetSpecialFolderPath
|
// Using SHGetFolderPath or SHGetSpecialFolderPath
|
||||||
// is problematic (not everywhere available).
|
// is problematic (not everywhere available).
|
||||||
fprintf(stderr, "Warning: %%APPDATA%% is not set. "
|
log_add (log_Warning, "Warning: %%APPDATA%% is not set. "
|
||||||
"Falling back to \"%%USERPROFILE%%\\Application "
|
"Falling back to \"%%USERPROFILE%%\\Application "
|
||||||
"Data\"\n");
|
"Data\"");
|
||||||
envVar = getenv ("USERPROFILE");
|
envVar = getenv ("USERPROFILE");
|
||||||
if (envVar != NULL)
|
if (envVar != NULL)
|
||||||
{
|
{
|
||||||
@@ -284,8 +285,9 @@ expandPath (char *dest, size_t len, const char *src, int what)
|
|||||||
|
|
||||||
// fallback to "./userdata"
|
// fallback to "./userdata"
|
||||||
#define APPDATA_FALLBACK_STRING ".\\userdata"
|
#define APPDATA_FALLBACK_STRING ".\\userdata"
|
||||||
fprintf(stderr, "Warning: %%USERPROFILE%% is not set. "
|
log_add (log_Warning,
|
||||||
"Falling back to \"%s\" for %%APPDATA%%\n",
|
"Warning: %%USERPROFILE%% is not set. "
|
||||||
|
"Falling back to \"%s\" for %%APPDATA%%",
|
||||||
APPDATA_FALLBACK_STRING);
|
APPDATA_FALLBACK_STRING);
|
||||||
CHECKLEN (buf, sizeof (APPDATA_FALLBACK_STRING) - 1);
|
CHECKLEN (buf, sizeof (APPDATA_FALLBACK_STRING) - 1);
|
||||||
strcpy (bufptr, APPDATA_FALLBACK_STRING);
|
strcpy (bufptr, APPDATA_FALLBACK_STRING);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "filintrn.h"
|
#include "filintrn.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
static int copyError(uio_Handle *srcHandle, uio_Handle *dstHandle,
|
static int copyError(uio_Handle *srcHandle, uio_Handle *dstHandle,
|
||||||
uio_DirHandle *unlinkHandle, const char *unlinkPath, uint8 *buf);
|
uio_DirHandle *unlinkHandle, const char *unlinkPath, uint8 *buf);
|
||||||
@@ -144,9 +145,7 @@ copyError(uio_Handle *srcHandle, uio_Handle *dstHandle,
|
|||||||
|
|
||||||
savedErrno = errno;
|
savedErrno = errno;
|
||||||
|
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "Error while copying: %s", strerror (errno));
|
||||||
fprintf (stderr, "Error while copying: %s\n", strerror (errno));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (srcHandle != NULL)
|
if (srcHandle != NULL)
|
||||||
uio_close (srcHandle);
|
uio_close (srcHandle);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "timelib.h"
|
#include "timelib.h"
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
#include "libs/compiler.h"
|
#include "libs/compiler.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
static char *tempDirName;
|
static char *tempDirName;
|
||||||
@@ -99,8 +100,8 @@ getTempDir (char *buf, size_t buflen) {
|
|||||||
tryTempDir (buf, buflen, "/tmp/") &&
|
tryTempDir (buf, buflen, "/tmp/") &&
|
||||||
tryTempDir (buf, buflen, getcwd (cwd, sizeof cwd)))
|
tryTempDir (buf, buflen, getcwd (cwd, sizeof cwd)))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Fatal Error: Cannot find a suitable location "
|
log_add (log_Always, "Fatal Error: Cannot find a suitable location "
|
||||||
"to store temporary files.\n");
|
"to store temporary files.");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,8 +118,8 @@ mountTempDir(const char *name) {
|
|||||||
uio_MOUNT_TOP, NULL);
|
uio_MOUNT_TOP, NULL);
|
||||||
if (tempHandle == NULL) {
|
if (tempHandle == NULL) {
|
||||||
int saveErrno = errno;
|
int saveErrno = errno;
|
||||||
fprintf (stderr, "Fatal error: Couldn't mount temp dir '%s': "
|
log_add (log_Always, "Fatal error: Couldn't mount temp dir '%s': "
|
||||||
"%s\n", name, strerror (errno));
|
"%s", name, strerror (errno));
|
||||||
errno = saveErrno;
|
errno = saveErrno;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -126,7 +127,7 @@ mountTempDir(const char *name) {
|
|||||||
tempDir = uio_openDir (repository, "/tmp", 0);
|
tempDir = uio_openDir (repository, "/tmp", 0);
|
||||||
if (tempDir == NULL) {
|
if (tempDir == NULL) {
|
||||||
int saveErrno = errno;
|
int saveErrno = errno;
|
||||||
fprintf (stderr, "Fatal error: Could not open temp dir: %s\n",
|
log_add (log_Always, "Fatal error: Could not open temp dir: %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
errno = saveErrno;
|
errno = saveErrno;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -168,9 +169,9 @@ initTempDir (void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Failure, could not make a temporary directory.
|
// Failure, could not make a temporary directory.
|
||||||
fprintf(stderr, "Fatal error: Cannot get a name for a temporary "
|
log_add (log_Always, "Fatal error: Cannot get a name for a temporary "
|
||||||
"directory.\n");
|
"directory.");
|
||||||
exit(EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -186,7 +187,7 @@ tempFilePath (const char *filename) {
|
|||||||
static char file[PATH_MAX];
|
static char file[PATH_MAX];
|
||||||
|
|
||||||
if (snprintf (file, PATH_MAX, "%s/%s", tempDirName, filename) == -1) {
|
if (snprintf (file, PATH_MAX, "%s/%s", tempDirName, filename) == -1) {
|
||||||
fprintf (stderr, "Path to temp file too long.\n");
|
log_add (log_Always, "Path to temp file too long.");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "gfx_common.h"
|
#include "gfx_common.h"
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -129,14 +130,15 @@ clone_colormap (TFB_ColorMap *from, int index)
|
|||||||
|
|
||||||
if (!from)
|
if (!from)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "FATAL: clone_colormap(): no maps available\n");
|
log_add (log_Warning, "FATAL: clone_colormap(): "
|
||||||
abort ();
|
"no maps available");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Now = GetTimeCounter ();
|
Now = GetTimeCounter ();
|
||||||
if (Now >= NextTime)
|
if (Now >= NextTime)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "clone_colormap(): static pool exhausted\n");
|
log_add (log_Warning, "clone_colormap(): static pool exhausted");
|
||||||
NextTime = Now + ONE_SECOND;
|
NextTime = Now + ONE_SECOND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +162,7 @@ free_colormap (TFB_ColorMap *map)
|
|||||||
{
|
{
|
||||||
if (!map)
|
if (!map)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "free_colormap(): tried to free a NULL map\n");
|
log_add (log_Warning, "free_colormap(): tried to free a NULL map");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,8 +178,8 @@ get_colormap (int index)
|
|||||||
map = colormaps[index];
|
map = colormaps[index];
|
||||||
if (!map)
|
if (!map)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "BUG: get_colormap(): map not present\n");
|
log_add (log_Always, "BUG: get_colormap(): map not present");
|
||||||
abort ();
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
map->refcount++;
|
map->refcount++;
|
||||||
@@ -192,7 +194,7 @@ release_colormap (TFB_ColorMap *map)
|
|||||||
|
|
||||||
if (map->refcount <= 0)
|
if (map->refcount <= 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "BUG: release_colormap(): refcount not >0\n");
|
log_add (log_Warning, "BUG: release_colormap(): refcount not >0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,8 +233,8 @@ TFB_ColorMapToRGB (TFB_Palette *pal, int index)
|
|||||||
|
|
||||||
if (!map)
|
if (!map)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_ColorMapToRGB(): "
|
log_add (log_Warning, "TFB_ColorMapToRGB(): "
|
||||||
"requested non-present colormap %d\n", index);
|
"requested non-present colormap %d", index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,21 +256,21 @@ SetColorMap (COLORMAPPTR map)
|
|||||||
end = *colors++;
|
end = *colors++;
|
||||||
if (start > end)
|
if (start > end)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ERROR: SetColorMap(): "
|
log_add (log_Warning, "ERROR: SetColorMap(): "
|
||||||
"starting map (%d) not less or eq ending (%d)\n",
|
"starting map (%d) not less or eq ending (%d)",
|
||||||
start, end);
|
start, end);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (start >= MAX_COLORMAPS)
|
if (start >= MAX_COLORMAPS)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ERROR: SetColorMap(): "
|
log_add (log_Warning, "ERROR: SetColorMap(): "
|
||||||
"starting map (%d) beyond range (0-%d)\n",
|
"starting map (%d) beyond range (0-%d)",
|
||||||
start, (int)MAX_COLORMAPS - 1);
|
start, (int)MAX_COLORMAPS - 1);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (end >= MAX_COLORMAPS)
|
if (end >= MAX_COLORMAPS)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SetColorMap(): "
|
log_add (log_Warning, "SetColorMap(): "
|
||||||
"ending map (%d) beyond range (0-%d)\n",
|
"ending map (%d) beyond range (0-%d)\n",
|
||||||
end, (int)MAX_COLORMAPS - 1);
|
end, (int)MAX_COLORMAPS - 1);
|
||||||
end = MAX_COLORMAPS - 1;
|
end = MAX_COLORMAPS - 1;
|
||||||
@@ -305,7 +307,6 @@ SetColorMap (COLORMAPPTR map)
|
|||||||
|
|
||||||
UnlockMutex (maplock);
|
UnlockMutex (maplock);
|
||||||
|
|
||||||
//fprintf (stderr, "SetColorMap(): vp %x map %x bytes %d, start %d end %d\n", vp, map, bytes, start, end);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +339,7 @@ fade_xform_task (void *data)
|
|||||||
TDelta = TTotal;
|
TDelta = TTotal;
|
||||||
|
|
||||||
FadeAmount += (FadeEnd - FadeAmount) * TDelta / TTotal;
|
FadeAmount += (FadeEnd - FadeAmount) * TDelta / TTotal;
|
||||||
//fprintf (stderr, "fade_xform_task FadeAmount %d\n", FadeAmount);
|
//log_add (log_Debug, "fade_xform_task FadeAmount %d\n", FadeAmount);
|
||||||
} while ((TTotal -= TDelta) && (!Task_ReadState (task, TASK_EXIT)));
|
} while ((TTotal -= TDelta) && (!Task_ReadState (task, TASK_EXIT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,7 +453,7 @@ XFormColorMap_step (void)
|
|||||||
if (!curmap)
|
if (!curmap)
|
||||||
{
|
{
|
||||||
UnlockMutex (maplock);
|
UnlockMutex (maplock);
|
||||||
fprintf (stderr, "BUG: XFormColorMap_step(): no current map\n");
|
log_add (log_Always, "BUG: XFormColorMap_step(): no current map");
|
||||||
finish_colormap_xform (x);
|
finish_colormap_xform (x);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -561,9 +562,7 @@ XFormPLUT (COLORMAPPTR ColorMapPtr, SIZE TimeInterval)
|
|||||||
}
|
}
|
||||||
else if (x >= MAX_XFORMS)
|
else if (x >= MAX_XFORMS)
|
||||||
{ // flush some xforms if the queue is full
|
{ // flush some xforms if the queue is full
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "WARNING: XFormPLUT(): no slots available");
|
||||||
fprintf (stderr, "WARNING: XFormPLUT(): no slots available\n");
|
|
||||||
#endif
|
|
||||||
x = XFormControl.Highest;
|
x = XFormControl.Highest;
|
||||||
finish_colormap_xform (x);
|
finish_colormap_xform (x);
|
||||||
}
|
}
|
||||||
@@ -579,7 +578,7 @@ XFormPLUT (COLORMAPPTR ColorMapPtr, SIZE TimeInterval)
|
|||||||
{
|
{
|
||||||
UnlockMutex (maplock);
|
UnlockMutex (maplock);
|
||||||
UnlockMutex (XFormControl.Lock);
|
UnlockMutex (XFormControl.Lock);
|
||||||
fprintf (stderr, "BUG: XFormPLUT(): no current map\n");
|
log_add (log_Warning, "BUG: XFormPLUT(): no current map");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
memcpy (control->OldCMap, map->colors, sizeof (map->colors));
|
memcpy (control->OldCMap, map->colors, sizeof (map->colors));
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "gfxintrn.h"
|
#include "gfxintrn.h"
|
||||||
#include "tfb_prim.h"
|
#include "tfb_prim.h"
|
||||||
#include "gfxother.h"
|
#include "gfxother.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
extern void FixContextFontEffect (void);
|
extern void FixContextFontEffect (void);
|
||||||
static inline TFB_Char *getCharFrame (FONT_DESC *fontPtr, wchar_t ch);
|
static inline TFB_Char *getCharFrame (FONT_DESC *fontPtr, wchar_t ch);
|
||||||
@@ -333,9 +333,7 @@ getCharFrame (FONT_DESC *fontPtr, wchar_t ch)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "Character %u not present", (unsigned int) ch);
|
||||||
fprintf (stderr, "Character %u not present\n", (unsigned int) ch);
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ int TFB_DEBUG_HALT = 0;
|
|||||||
void
|
void
|
||||||
SetGraphicUseOtherExtra (int other) //Could this possibly be more cryptic?!? :)
|
SetGraphicUseOtherExtra (int other) //Could this possibly be more cryptic?!? :)
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "SetGraphicUseOtherExtra %d\n", other);
|
//log_add (log_Debug, "SetGraphicUseOtherExtra %d", other);
|
||||||
(void)other; /* lint */
|
(void)other; /* lint */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ SetGraphicUseOtherExtra (int other) //Could this possibly be more cryptic?!? :)
|
|||||||
void
|
void
|
||||||
SetGraphicGrabOther (int grab_other)
|
SetGraphicGrabOther (int grab_other)
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "SetGraphicGrabOther %d\n", grab_other);
|
//log_add (log_Debug, "SetGraphicGrabOther %d", grab_other);
|
||||||
(void)grab_other; /* lint */
|
(void)grab_other; /* lint */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gfxintrn.h"
|
#include "gfxintrn.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
//#define DEBUG_INTERSEC
|
//#define DEBUG_INTERSEC
|
||||||
|
|
||||||
@@ -334,12 +335,14 @@ DrawablesIntersect (PINTERSECT_CONTROL pControl0,
|
|||||||
++time_x_1;
|
++time_x_1;
|
||||||
|
|
||||||
#ifdef DEBUG_INTERSEC
|
#ifdef DEBUG_INTERSEC
|
||||||
fprintf (stderr, "FramePtr0<%d, %d> --> <%d, %d>\nFramePtr1<%d, %d> --> <%d, %d>\n",
|
log_add (log_Debug, "FramePtr0<%d, %d> --> <%d, %d>",
|
||||||
GetFrameWidth (FramePtr0), GetFrameHeight (FramePtr0),
|
GetFrameWidth (FramePtr0), GetFrameHeight (FramePtr0),
|
||||||
r0.corner.x, r0.corner.y,
|
r0.corner.x, r0.corner.y);
|
||||||
|
log_add (log_Debug, "FramePtr1<%d, %d> --> <%d, %d>",
|
||||||
GetFrameWidth (FramePtr1), GetFrameHeight (FramePtr1),
|
GetFrameWidth (FramePtr1), GetFrameHeight (FramePtr1),
|
||||||
r1.corner.x, r1.corner.y);
|
r1.corner.x, r1.corner.y);
|
||||||
fprintf (stderr, "time_x(%d, %d)-%d, time_y(%d, %d)-%d\n", time_x_0, time_x_1, dx, time_y_0, time_y_1, dy);
|
log_add (log_Debug, "time_x(%d, %d)-%d, time_y(%d, %d)-%d",
|
||||||
|
time_x_0, time_x_1, dx, time_y_0, time_y_1, dy);
|
||||||
#endif /* DEBUG_INTERSEC */
|
#endif /* DEBUG_INTERSEC */
|
||||||
if (dx == 0)
|
if (dx == 0)
|
||||||
{
|
{
|
||||||
@@ -382,7 +385,8 @@ DrawablesIntersect (PINTERSECT_CONTROL pControl0,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_INTERSEC
|
#ifdef DEBUG_INTERSEC
|
||||||
fprintf (stderr, "start_time = %d, end_time = %d\n", time_y_0, time_y_1);
|
log_add (log_Debug, "start_time = %d, end_time = %d",
|
||||||
|
time_y_0, time_y_1);
|
||||||
#endif /* DEBUG_INTERSEC */
|
#endif /* DEBUG_INTERSEC */
|
||||||
if (time_y_0 <= time_y_1
|
if (time_y_0 <= time_y_1
|
||||||
&& (intersect_time = frame_intersect (
|
&& (intersect_time = frame_intersect (
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "sdl_common.h"
|
#include "sdl_common.h"
|
||||||
#include "graphics/tfb_draw.h"
|
#include "graphics/tfb_draw.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
static int gscale = GSCALE_IDENTITY;
|
static int gscale = GSCALE_IDENTITY;
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ read_screen (PRECT lpRect, FRAMEPTR DstFramePtr)
|
|||||||
->FlagsAndIndex)
|
->FlagsAndIndex)
|
||||||
& ((DWORD) MAPPED_TO_DISPLAY << FTYPE_SHIFT)))
|
& ((DWORD) MAPPED_TO_DISPLAY << FTYPE_SHIFT)))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Unimplemented function activated: read_screen()\n");
|
log_add (log_Warning, "Unimplemented function activated: read_screen()");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "sdluio.h"
|
#include "sdluio.h"
|
||||||
#include "libs/file.h"
|
#include "libs/file.h"
|
||||||
#include "libs/reslib.h"
|
#include "libs/reslib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "../font.h"
|
#include "../font.h"
|
||||||
#include "primitives.h"
|
#include "primitives.h"
|
||||||
|
|
||||||
@@ -415,15 +416,15 @@ _GetCelData (uio_Stream *fp, DWORD length)
|
|||||||
const char *err;
|
const char *err;
|
||||||
|
|
||||||
err = SDL_GetError();
|
err = SDL_GetError();
|
||||||
fprintf (stderr, "_GetCelData: Unable to load image!\n");
|
log_add (log_Warning, "_GetCelData: Unable to load image!");
|
||||||
if (err != NULL)
|
if (err != NULL)
|
||||||
fprintf (stderr, "SDL reports: %s\n", err);
|
log_add (log_Warning, "SDL reports: %s", err);
|
||||||
SDL_FreeSurface (img[cel_ct]);
|
SDL_FreeSurface (img[cel_ct]);
|
||||||
}
|
}
|
||||||
else if (img[cel_ct]->w < 0 || img[cel_ct]->h < 0 ||
|
else if (img[cel_ct]->w < 0 || img[cel_ct]->h < 0 ||
|
||||||
img[cel_ct]->format->BitsPerPixel < 8)
|
img[cel_ct]->format->BitsPerPixel < 8)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "_GetCelData: Bad file!\n");
|
log_add (log_Warning, "_GetCelData: Bad file!");
|
||||||
SDL_FreeSurface (img[cel_ct]);
|
SDL_FreeSurface (img[cel_ct]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -466,7 +467,7 @@ _GetCelData (uio_Stream *fp, DWORD length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Drawable == 0)
|
if (Drawable == 0)
|
||||||
fprintf (stderr, "Couldn't get cel data for '%s'\n",
|
log_add (log_Warning, "Couldn't get cel data for '%s'",
|
||||||
_cur_resfile_name);
|
_cur_resfile_name);
|
||||||
return (GetDrawableHandle (Drawable));
|
return (GetDrawableHandle (Drawable));
|
||||||
}
|
}
|
||||||
@@ -638,11 +639,9 @@ _GetFontData (uio_Stream *fp, DWORD length)
|
|||||||
if (destChar->data != NULL)
|
if (destChar->data != NULL)
|
||||||
{
|
{
|
||||||
// There's already an image for this character.
|
// There's already an image for this character.
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "Duplicate image for character %d "
|
||||||
fprintf (stderr, "Duplicate image for character %d "
|
"for font %s.", (int) bcd->index,
|
||||||
"for font %s.\n", (int) bcd->index,
|
|
||||||
_cur_resfile_name);
|
_cur_resfile_name);
|
||||||
#endif
|
|
||||||
SDL_FreeSurface (bcd->surface);
|
SDL_FreeSurface (bcd->surface);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/graphics/sdl/primitives.h"
|
#include "libs/graphics/sdl/primitives.h"
|
||||||
#include "libs/graphics/tfb_draw.h"
|
#include "libs/graphics/tfb_draw.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "rotozoom.h"
|
#include "rotozoom.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
@@ -70,7 +71,7 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale,
|
|||||||
|
|
||||||
if (img == 0)
|
if (img == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ERROR: TFB_DrawCanvas_Image passed null image ptr\n");
|
log_add (log_Warning, "ERROR: TFB_DrawCanvas_Image passed null image ptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,8 +155,8 @@ TFB_DrawCanvas_Fill (TFB_Canvas source, int width, int height,
|
|||||||
|
|
||||||
if (srcfmt->BytesPerPixel != 4 || dstfmt->BytesPerPixel != 4)
|
if (srcfmt->BytesPerPixel != 4 || dstfmt->BytesPerPixel != 4)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_DrawCanvas_Fill: Unsupported surface formats: "
|
log_add (log_Warning, "TFB_DrawCanvas_Fill: Unsupported surface "
|
||||||
"%d bytes/pixel source, %d bytes/pixel destination\n",
|
"formats: %d bytes/pixel source, %d bytes/pixel destination",
|
||||||
(int)srcfmt->BytesPerPixel, (int)dstfmt->BytesPerPixel);
|
(int)srcfmt->BytesPerPixel, (int)dstfmt->BytesPerPixel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -207,8 +208,8 @@ TFB_DrawCanvas_Fill (TFB_Canvas source, int width, int height,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_DrawCanvas_Fill: Unsupported source surface "
|
log_add (log_Warning, "TFB_DrawCanvas_Fill: Unsupported source"
|
||||||
"format\n");
|
"surface format\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockSurface(dst);
|
SDL_UnlockSurface(dst);
|
||||||
@@ -232,7 +233,7 @@ TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int
|
|||||||
|
|
||||||
if (img == 0)
|
if (img == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ERROR: TFB_DrawCanvas_FilledImage passed null image ptr\n");
|
log_add (log_Warning, "ERROR: TFB_DrawCanvas_FilledImage passed null image ptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,14 +328,14 @@ TFB_DrawCanvas_FontChar (TFB_Char *fontChar, TFB_Image *backing,
|
|||||||
|
|
||||||
if (fontChar == 0)
|
if (fontChar == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ERROR: "
|
log_add (log_Warning, "ERROR: "
|
||||||
"TFB_DrawCanvas_FontChar passed null char ptr\n");
|
"TFB_DrawCanvas_FontChar passed null char ptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (backing == 0)
|
if (backing == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ERROR: "
|
log_add (log_Warning, "ERROR: "
|
||||||
"TFB_DrawCanvas_FontChar passed null backing ptr\n");
|
"TFB_DrawCanvas_FontChar passed null backing ptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,9 +348,9 @@ TFB_DrawCanvas_FontChar (TFB_Char *fontChar, TFB_Image *backing,
|
|||||||
if (surf->format->BytesPerPixel != 4
|
if (surf->format->BytesPerPixel != 4
|
||||||
|| surf->w < w || surf->h < h)
|
|| surf->w < w || surf->h < h)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ERROR: "
|
log_add (log_Warning, "ERROR: "
|
||||||
"TFB_DrawCanvas_FontChar bad backing surface: %dx%dx%d; "
|
"TFB_DrawCanvas_FontChar bad backing surface: %dx%dx%d; "
|
||||||
"char: %dx%d\n",
|
"char: %dx%d",
|
||||||
surf->w, surf->h, (int)surf->format->BytesPerPixel, w, h);
|
surf->w, surf->h, (int)surf->format->BytesPerPixel, w, h);
|
||||||
UnlockMutex (backing->mutex);
|
UnlockMutex (backing->mutex);
|
||||||
return;
|
return;
|
||||||
@@ -397,9 +398,11 @@ TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha)
|
|||||||
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h,
|
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h,
|
||||||
fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask,
|
fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask,
|
||||||
hasalpha ? fmt->Amask : 0);
|
hasalpha ? fmt->Amask : 0);
|
||||||
if (!new_surf) {
|
if (!new_surf)
|
||||||
fprintf(stderr, "INTERNAL PANIC: Failed to create TFB_Canvas: %s", SDL_GetError());
|
{
|
||||||
exit(-1);
|
log_add (log_Always, "INTERNAL PANIC: Failed to create TFB_Canvas: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return new_surf;
|
return new_surf;
|
||||||
}
|
}
|
||||||
@@ -412,7 +415,7 @@ TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha)
|
|||||||
|
|
||||||
if (fmt->palette)
|
if (fmt->palette)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "TFB_DrawCanvas_New_ForScreen() WARNING:"
|
log_add (log_Warning, "TFB_DrawCanvas_New_ForScreen() WARNING:"
|
||||||
"Paletted display format will be slow");
|
"Paletted display format will be slow");
|
||||||
|
|
||||||
new_surf = TFB_DrawCanvas_New_TrueColor (w, h, withalpha);
|
new_surf = TFB_DrawCanvas_New_TrueColor (w, h, withalpha);
|
||||||
@@ -429,9 +432,9 @@ TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha)
|
|||||||
|
|
||||||
if (!new_surf)
|
if (!new_surf)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "TFB_DrawCanvas_New_ForScreen() INTERNAL PANIC:"
|
log_add (log_Always, "TFB_DrawCanvas_New_ForScreen() INTERNAL PANIC:"
|
||||||
"Failed to create TFB_Canvas: %s", SDL_GetError());
|
"Failed to create TFB_Canvas: %s", SDL_GetError());
|
||||||
exit (-1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return new_surf;
|
return new_surf;
|
||||||
}
|
}
|
||||||
@@ -441,9 +444,11 @@ TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent
|
|||||||
{
|
{
|
||||||
SDL_Surface *new_surf;
|
SDL_Surface *new_surf;
|
||||||
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 8, 0, 0, 0, 0);
|
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 8, 0, 0, 0, 0);
|
||||||
if (!new_surf) {
|
if (!new_surf)
|
||||||
fprintf(stderr, "INTERNAL PANIC: Failed to create TFB_Canvas: %s\n", SDL_GetError());
|
{
|
||||||
exit(-1);
|
log_add (log_Always, "INTERNAL PANIC: Failed to create TFB_Canvas: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (palette != NULL)
|
if (palette != NULL)
|
||||||
{
|
{
|
||||||
@@ -530,9 +535,10 @@ TFB_DrawCanvas_New_RotationTarget (TFB_Canvas src_canvas, int angle)
|
|||||||
src->format->Amask);
|
src->format->Amask);
|
||||||
if (!newsurf)
|
if (!newsurf)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "TFB_DrawCanvas_New_RotationTarget() INTERNAL PANIC:"
|
log_add (log_Always, "TFB_DrawCanvas_New_RotationTarget()"
|
||||||
"Failed to create TFB_Canvas: %s", SDL_GetError());
|
" INTERNAL PANIC: Failed to create TFB_Canvas: %s",
|
||||||
exit (-1);
|
SDL_GetError());
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (src->format->palette)
|
if (src->format->palette)
|
||||||
TFB_DrawCanvas_SetTransparentIndex (newsurf, TFB_DrawCanvas_GetTransparentIndex (src), FALSE);
|
TFB_DrawCanvas_SetTransparentIndex (newsurf, TFB_DrawCanvas_GetTransparentIndex (src), FALSE);
|
||||||
@@ -551,7 +557,8 @@ TFB_DrawCanvas_Delete (TFB_Canvas canvas)
|
|||||||
{
|
{
|
||||||
if (!canvas)
|
if (!canvas)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "INTERNAL PANIC: Attempted to delete a NULL canvas!\n");
|
log_add (log_Warning, "INTERNAL PANIC: Attempted"
|
||||||
|
" to delete a NULL canvas!");
|
||||||
/* Should we actually die here? */
|
/* Should we actually die here? */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -590,7 +597,8 @@ TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas)
|
|||||||
SDL_Surface *result = TFB_DisplayFormatAlpha ((SDL_Surface *)canvas);
|
SDL_Surface *result = TFB_DisplayFormatAlpha ((SDL_Surface *)canvas);
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "WARNING: Could not convert sprite-canvas to display format.\n");
|
log_add (log_Always, "WARNING: Could not convert"
|
||||||
|
" sprite-canvas to display format.");
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
else if (result == canvas)
|
else if (result == canvas)
|
||||||
@@ -743,12 +751,15 @@ TFB_DrawCanvas_Rescale_Nearest (TFB_Canvas src_canvas, TFB_Canvas dest_canvas, E
|
|||||||
|
|
||||||
if (size.width + size.height > NNS_MAX_DIMS)
|
if (size.width + size.height > NNS_MAX_DIMS)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_DrawCanvas_Scale: Tried to zoom an image to unreasonable size! Failing.\n");
|
log_add (log_Warning, "TFB_DrawCanvas_Scale: Tried to zoom"
|
||||||
|
" an image to unreasonable size! Failing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (size.width > dst->w || size.height > dst->h)
|
if (size.width > dst->w || size.height > dst->h)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_DrawCanvas_Scale: Tried to scale image to size %d %d when dest_canvas has only dimensions of %d %d! Failing.\n",
|
log_add (log_Warning, "TFB_DrawCanvas_Scale: Tried to scale"
|
||||||
|
" image to size %d %d when dest_canvas has only"
|
||||||
|
" dimensions of %d %d! Failing.",
|
||||||
size.width, size.height, dst->w, dst->h);
|
size.width, size.height, dst->w, dst->h);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -836,7 +847,8 @@ TFB_DrawCanvas_Rescale_Nearest (TFB_Canvas src_canvas, TFB_Canvas dest_canvas, E
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Tried to deal with unknown BPP: %d -> %d\n", src->format->BitsPerPixel, dst->format->BitsPerPixel);
|
log_add (log_Warning, "Tried to deal with unknown BPP: %d -> %d",
|
||||||
|
src->format->BitsPerPixel, dst->format->BitsPerPixel);
|
||||||
}
|
}
|
||||||
SDL_UnlockSurface (dst);
|
SDL_UnlockSurface (dst);
|
||||||
SDL_UnlockSurface (src);
|
SDL_UnlockSurface (src);
|
||||||
@@ -985,7 +997,9 @@ TFB_DrawCanvas_Rescale_Trilinear (TFB_Canvas src_canvas,
|
|||||||
|
|
||||||
if (size.width > dst->w || size.height > dst->h)
|
if (size.width > dst->w || size.height > dst->h)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_DrawCanvas_Rescale_Trilinear: Tried to scale image to size %d %d when dest_canvas has only dimensions of %d %d! Failing.\n",
|
log_add (log_Warning, "TFB_DrawCanvas_Rescale_Trilinear: "
|
||||||
|
"Tried to scale image to size %d %d when dest_canvas"
|
||||||
|
" has only dimensions of %d %d! Failing.",
|
||||||
size.width, size.height, dst->w, dst->h);
|
size.width, size.height, dst->w, dst->h);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -994,8 +1008,11 @@ TFB_DrawCanvas_Rescale_Trilinear (TFB_Canvas src_canvas,
|
|||||||
(mmfmt->BytesPerPixel != 1 && mmfmt->BytesPerPixel != 4) ||
|
(mmfmt->BytesPerPixel != 1 && mmfmt->BytesPerPixel != 4) ||
|
||||||
(dst->format->BytesPerPixel != 4))
|
(dst->format->BytesPerPixel != 4))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Tried to deal with unknown BPP: %d -> %d, mipmap %d\n",
|
log_add (log_Warning, "TFB_DrawCanvas_Rescale_Trilinear: "
|
||||||
srcfmt->BitsPerPixel, dst->format->BitsPerPixel, mmfmt->BitsPerPixel);
|
"Tried to deal with unknown BPP: %d -> %d, mipmap %d",
|
||||||
|
srcfmt->BitsPerPixel, dst->format->BitsPerPixel,
|
||||||
|
mmfmt->BitsPerPixel);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use colorkeys where appropriate
|
// use colorkeys where appropriate
|
||||||
@@ -1230,7 +1247,7 @@ TFB_DrawCanvas_GetScreenFormat (TFB_PixelFormat *fmt)
|
|||||||
|
|
||||||
if (sdl->palette)
|
if (sdl->palette)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "TFB_DrawCanvas_GetScreenFormat() WARNING:"
|
log_add (log_Warning, "TFB_DrawCanvas_GetScreenFormat() WARNING:"
|
||||||
"Paletted display format will be slow");
|
"Paletted display format will be slow");
|
||||||
|
|
||||||
fmt->BitsPerPixel = 32;
|
fmt->BitsPerPixel = 32;
|
||||||
@@ -1282,7 +1299,9 @@ TFB_DrawCanvas_Rotate (TFB_Canvas src_canvas, TFB_Canvas dst_canvas, int angle,
|
|||||||
|
|
||||||
if (size.width > dst->w || size.height > dst->h)
|
if (size.width > dst->w || size.height > dst->h)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_DrawCanvas_Rotate: Tried to rotate image to size %d %d when dst_canvas has only dimensions of %d %d! Failing.\n",
|
log_add (log_Warning, "TFB_DrawCanvas_Rotate: Tried to rotate"
|
||||||
|
" image to size %d %d when dst_canvas has only dimensions"
|
||||||
|
" of %d %d! Failing.",
|
||||||
size.width, size.height, dst->w, dst->h);
|
size.width, size.height, dst->w, dst->h);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1297,7 +1316,8 @@ TFB_DrawCanvas_Rotate (TFB_Canvas src_canvas, TFB_Canvas dst_canvas, int angle,
|
|||||||
ret = rotateSurface (src, dst, angle, 0);
|
ret = rotateSurface (src, dst, angle, 0);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_DrawCanvas_Rotate: WARNING: actual rotation func returned failure\n");
|
log_add (log_Warning, "TFB_DrawCanvas_Rotate: WARNING:"
|
||||||
|
" actual rotation func returned failure\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include SDL_INCLUDE(SDL_thread.h)
|
#include SDL_INCLUDE(SDL_thread.h)
|
||||||
#include "libs/graphics/drawcmd.h"
|
#include "libs/graphics/drawcmd.h"
|
||||||
#include "libs/graphics/sdl/dcqueue.h"
|
#include "libs/graphics/sdl/dcqueue.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
static RecursiveMutex DCQ_Mutex;
|
static RecursiveMutex DCQ_Mutex;
|
||||||
@@ -39,8 +40,8 @@ static void
|
|||||||
TFB_WaitForSpace (int requested_slots)
|
TFB_WaitForSpace (int requested_slots)
|
||||||
{
|
{
|
||||||
int old_depth, i;
|
int old_depth, i;
|
||||||
fprintf (stderr, "DCQ overload (Size = %d, FullSize = %d, "
|
log_add (log_Debug, "DCQ overload (Size = %d, FullSize = %d, "
|
||||||
"Requested = %d). Sleeping until renderer is done.\n",
|
"Requested = %d). Sleeping until renderer is done.",
|
||||||
DrawCommandQueue.Size, DrawCommandQueue.FullSize,
|
DrawCommandQueue.Size, DrawCommandQueue.FullSize,
|
||||||
requested_slots);
|
requested_slots);
|
||||||
// Restore the DCQ locking level. I *think* this is
|
// Restore the DCQ locking level. I *think* this is
|
||||||
@@ -52,7 +53,7 @@ TFB_WaitForSpace (int requested_slots)
|
|||||||
WaitCondVar (RenderingCond);
|
WaitCondVar (RenderingCond);
|
||||||
for (i = 0; i < old_depth; i++)
|
for (i = 0; i < old_depth; i++)
|
||||||
LockRecursiveMutex (DCQ_Mutex);
|
LockRecursiveMutex (DCQ_Mutex);
|
||||||
fprintf (stderr, "DCQ clear (Size = %d, FullSize = %d). Continuing.\n",
|
log_add (log_Debug, "DCQ clear (Size = %d, FullSize = %d). Continuing.",
|
||||||
DrawCommandQueue.Size, DrawCommandQueue.FullSize);
|
DrawCommandQueue.Size, DrawCommandQueue.FullSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,8 +174,8 @@ TFB_DrawCommandQueue_Pop (TFB_DrawCommand *target)
|
|||||||
if (DrawCommandQueue.Front == DrawCommandQueue.Back &&
|
if (DrawCommandQueue.Front == DrawCommandQueue.Back &&
|
||||||
DrawCommandQueue.Size != DCQ_MAX)
|
DrawCommandQueue.Size != DCQ_MAX)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Augh! Assertion failure in DCQ! Front == Back, "
|
log_add (log_Debug, "Augh! Assertion failure in DCQ! "
|
||||||
"Size != DCQ_MAX\n");
|
"Front == Back, Size != DCQ_MAX");
|
||||||
DrawCommandQueue.Size = 0;
|
DrawCommandQueue.Size = 0;
|
||||||
Unlock_DCQ ();
|
Unlock_DCQ ();
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "libs/graphics/sdl/opengl.h"
|
#include "libs/graphics/sdl/opengl.h"
|
||||||
#include "bbox.h"
|
#include "bbox.h"
|
||||||
#include "scalers.h"
|
#include "scalers.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
static SDL_Surface *scaled_display = NULL;
|
static SDL_Surface *scaled_display = NULL;
|
||||||
static SDL_Surface *scaled_transition = NULL;
|
static SDL_Surface *scaled_transition = NULL;
|
||||||
@@ -53,7 +54,7 @@ Create_Screen (SDL_Surface *template, int w, int h)
|
|||||||
template->format->Rmask, template->format->Gmask,
|
template->format->Rmask, template->format->Gmask,
|
||||||
template->format->Bmask, 0);
|
template->format->Bmask, 0);
|
||||||
if (newsurf == 0) {
|
if (newsurf == 0) {
|
||||||
fprintf (stderr, "Couldn't create screen buffers: %s\n",
|
log_add (log_Always, "Couldn't create screen buffers: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
}
|
}
|
||||||
return newsurf;
|
return newsurf;
|
||||||
@@ -117,19 +118,20 @@ AttemptColorDepth (int flags, int width, int height, int bpp)
|
|||||||
bpp, videomode_flags);
|
bpp, videomode_flags);
|
||||||
if (SDL_Video == NULL)
|
if (SDL_Video == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't set OpenGL %ix%ix%i video mode: %s\n",
|
log_add (log_Always, "Couldn't set OpenGL %ix%ix%i video mode: %s",
|
||||||
ScreenWidthActual, ScreenHeightActual, bpp,
|
ScreenWidthActual, ScreenHeightActual, bpp,
|
||||||
SDL_GetError ());
|
SDL_GetError ());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Set the resolution to: %ix%ix%i (surface reports %ix%ix%i)\n",
|
log_add (log_Always, "Set the resolution to: %ix%ix%i"
|
||||||
|
" (surface reports %ix%ix%i)",
|
||||||
width, height, bpp,
|
width, height, bpp,
|
||||||
SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h,
|
SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h,
|
||||||
SDL_GetVideoSurface()->format->BitsPerPixel);
|
SDL_GetVideoSurface()->format->BitsPerPixel);
|
||||||
|
|
||||||
fprintf (stderr, "OpenGL renderer: %s version: %s\n",
|
log_add (log_Always, "OpenGL renderer: %s version: %s",
|
||||||
glGetString (GL_RENDERER), glGetString (GL_VERSION));
|
glGetString (GL_RENDERER), glGetString (GL_VERSION));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -145,7 +147,7 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height)
|
|||||||
AttemptColorDepth (flags, width, height, 24) &&
|
AttemptColorDepth (flags, width, height, 24) &&
|
||||||
AttemptColorDepth (flags, width, height, 16))
|
AttemptColorDepth (flags, width, height, 16))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't set any OpenGL %ix%i video mode!\n",
|
log_add (log_Always, "Couldn't set any OpenGL %ix%i video mode!",
|
||||||
width, height);
|
width, height);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -156,7 +158,7 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height)
|
|||||||
R_MASK, G_MASK, B_MASK, A_MASK);
|
R_MASK, G_MASK, B_MASK, A_MASK);
|
||||||
if (format_conv_surf == NULL)
|
if (format_conv_surf == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't create format_conv_surf: %s\n",
|
log_add (log_Always, "Couldn't create format_conv_surf: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -231,21 +233,21 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height)
|
|||||||
{
|
{
|
||||||
char VideoName[256];
|
char VideoName[256];
|
||||||
|
|
||||||
fprintf (stderr, "Initializing SDL with OpenGL support.\n");
|
log_add (log_Always, "Initializing SDL with OpenGL support.");
|
||||||
|
|
||||||
SDL_VideoDriverName (VideoName, sizeof (VideoName));
|
SDL_VideoDriverName (VideoName, sizeof (VideoName));
|
||||||
fprintf (stderr, "SDL driver used: %s\n", VideoName);
|
log_add (log_Always, "SDL driver used: %s", VideoName);
|
||||||
fprintf (stderr, "SDL initialized.\n");
|
log_add (log_Always, "SDL initialized.");
|
||||||
fprintf (stderr, "Initializing Screen.\n");
|
log_add (log_Always, "Initializing Screen.");
|
||||||
|
|
||||||
ScreenWidth = 320;
|
ScreenWidth = 320;
|
||||||
ScreenHeight = 240;
|
ScreenHeight = 240;
|
||||||
|
|
||||||
if (TFB_GL_ConfigureVideo (driver, flags, width, height))
|
if (TFB_GL_ConfigureVideo (driver, flags, width, height))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Could not initialize video: "
|
log_add (log_Always, "Could not initialize video: "
|
||||||
"no fallback at start of program!\n");
|
"no fallback at start of program!");
|
||||||
exit (-1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize scalers (let them precompute whatever)
|
// Initialize scalers (let them precompute whatever)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "pure.h"
|
#include "pure.h"
|
||||||
#include "bbox.h"
|
#include "bbox.h"
|
||||||
#include "scalers.h"
|
#include "scalers.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
static SDL_Surface *fade_black = NULL;
|
static SDL_Surface *fade_black = NULL;
|
||||||
static SDL_Surface *fade_white = NULL;
|
static SDL_Surface *fade_white = NULL;
|
||||||
@@ -36,7 +37,7 @@ Create_Screen (SDL_Surface *template, int w, int h)
|
|||||||
template->format->Rmask, template->format->Gmask,
|
template->format->Rmask, template->format->Gmask,
|
||||||
template->format->Bmask, 0);
|
template->format->Bmask, 0);
|
||||||
if (newsurf == 0) {
|
if (newsurf == 0) {
|
||||||
fprintf (stderr, "Couldn't create screen buffers: %s\n",
|
log_add (log_Always, "Couldn't create screen buffers: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
}
|
}
|
||||||
return newsurf;
|
return newsurf;
|
||||||
@@ -75,8 +76,8 @@ TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height)
|
|||||||
ScreenHeightActual = 480;
|
ScreenHeightActual = 480;
|
||||||
|
|
||||||
if (width != 640 || height != 480)
|
if (width != 640 || height != 480)
|
||||||
fprintf (stderr, "Screen resolution of %dx%d not supported "
|
log_add (log_Always, "Screen resolution of %dx%d not supported "
|
||||||
"under pure SDL, using 640x480\n", width, height);
|
"under pure SDL, using 640x480", width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
videomode_flags |= SDL_ANYFORMAT;
|
videomode_flags |= SDL_ANYFORMAT;
|
||||||
@@ -90,14 +91,14 @@ TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height)
|
|||||||
|
|
||||||
if (SDL_Video == NULL)
|
if (SDL_Video == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't set %ix%i video mode: %s\n",
|
log_add (log_Always, "Couldn't set %ix%i video mode: %s",
|
||||||
ScreenWidthActual, ScreenHeightActual,
|
ScreenWidthActual, ScreenHeightActual,
|
||||||
SDL_GetError ());
|
SDL_GetError ());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Set the resolution to: %ix%ix%i\n",
|
log_add (log_Always, "Set the resolution to: %ix%ix%i",
|
||||||
SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h,
|
SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h,
|
||||||
SDL_GetVideoSurface()->format->BitsPerPixel);
|
SDL_GetVideoSurface()->format->BitsPerPixel);
|
||||||
ScreenColorDepth = SDL_GetVideoSurface()->format->BitsPerPixel;
|
ScreenColorDepth = SDL_GetVideoSurface()->format->BitsPerPixel;
|
||||||
@@ -125,7 +126,7 @@ TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height)
|
|||||||
}
|
}
|
||||||
if (!format_conv_surf)
|
if (!format_conv_surf)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't create format_conv_surf: %s\n",
|
log_add (log_Always, "Couldn't create format_conv_surf: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -178,27 +179,26 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height)
|
|||||||
{
|
{
|
||||||
char VideoName[256];
|
char VideoName[256];
|
||||||
|
|
||||||
fprintf (stderr, "Initializing Pure-SDL graphics.\n");
|
log_add (log_Always, "Initializing Pure-SDL graphics.");
|
||||||
|
|
||||||
SDL_VideoDriverName (VideoName, sizeof (VideoName));
|
SDL_VideoDriverName (VideoName, sizeof (VideoName));
|
||||||
fprintf (stderr, "SDL driver used: %s\n", VideoName);
|
log_add (log_Always, "SDL driver used: %s", VideoName);
|
||||||
// Set the environment variable SDL_VIDEODRIVER to override
|
// Set the environment variable SDL_VIDEODRIVER to override
|
||||||
// For Linux: x11 (default), dga, fbcon, directfb, svgalib,
|
// For Linux: x11 (default), dga, fbcon, directfb, svgalib,
|
||||||
// ggi, aalib
|
// ggi, aalib
|
||||||
// For Windows: directx (default), windib
|
// For Windows: directx (default), windib
|
||||||
|
|
||||||
fprintf (stderr, "SDL initialized.\n");
|
log_add (log_Always, "SDL initialized.");
|
||||||
|
log_add (log_Always, "Initializing Screen.");
|
||||||
fprintf (stderr, "Initializing Screen.\n");
|
|
||||||
|
|
||||||
ScreenWidth = 320;
|
ScreenWidth = 320;
|
||||||
ScreenHeight = 240;
|
ScreenHeight = 240;
|
||||||
|
|
||||||
if (TFB_Pure_ConfigureVideo (driver, flags, width, height))
|
if (TFB_Pure_ConfigureVideo (driver, flags, width, height))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Could not initialize video: "
|
log_add (log_Always, "Could not initialize video: "
|
||||||
"no fallback at start of program!\n");
|
"no fallback at start of program!");
|
||||||
exit (-1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize scalers (let them precompute whatever)
|
// Initialize scalers (let them precompute whatever)
|
||||||
@@ -369,14 +369,14 @@ Scale_PerfTest (void)
|
|||||||
|
|
||||||
if (!scaler)
|
if (!scaler)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "No scaler configured! "
|
log_add (log_Always, "No scaler configured! "
|
||||||
"Run with larger resolution, please\n");
|
"Run with larger resolution, please");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!scaled_display)
|
if (!scaled_display)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Run scaler performance tests "
|
log_add (log_Always, "Run scaler performance tests "
|
||||||
"in Pure mode, please\n");
|
"in Pure mode, please");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,13 +395,13 @@ Scale_PerfTest (void)
|
|||||||
if (i % 100 == 0)
|
if (i % 100 == 0)
|
||||||
{
|
{
|
||||||
Now = SDL_GetTicks ();
|
Now = SDL_GetTicks ();
|
||||||
fprintf(stderr, "%03ld(%04ld) ", 100*1000 / (Now - TimeIn),
|
log_add (log_Debug, "%03ld(%04ld) ", 100*1000 / (Now - TimeIn),
|
||||||
Now - TimeIn);
|
Now - TimeIn);
|
||||||
TimeIn = Now;
|
TimeIn = Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "Full frames scaled: %d; over %ld ms; %ld fps\n",
|
log_add (log_Always, "Full frames scaled: %d; over %ld ms; %ld fps\n",
|
||||||
(i - 1), Now - TimeStart, i * 1000 / (Now - TimeStart));
|
(i - 1), Now - TimeStart, i * 1000 / (Now - TimeStart));
|
||||||
|
|
||||||
SDL_UnlockSurface (scaled_display);
|
SDL_UnlockSurface (scaled_display);
|
||||||
|
|||||||
@@ -37,8 +37,6 @@
|
|||||||
#define R0 0.8
|
#define R0 0.8
|
||||||
#define RANDOM_METHOD 3
|
#define RANDOM_METHOD 3
|
||||||
|
|
||||||
#define RND_BLUR_PROFILE
|
|
||||||
|
|
||||||
#ifdef GFXMODULE_SDL
|
#ifdef GFXMODULE_SDL
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@@ -48,10 +46,7 @@
|
|||||||
|
|
||||||
#include "sdl_common.h"
|
#include "sdl_common.h"
|
||||||
#include "primitives.h"
|
#include "primitives.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#ifdef RND_BLUR_PROFILE
|
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX
|
#ifndef MAX
|
||||||
#define MAX(x,y) ((x) < (y) ? (y) : (x))
|
#define MAX(x,y) ((x) < (y) ? (y) : (x))
|
||||||
@@ -81,9 +76,6 @@ void blurSurface32 (SDL_Surface *src)
|
|||||||
Uint32 *ptr;
|
Uint32 *ptr;
|
||||||
int y, x, yy, xx;
|
int y, x, yy, xx;
|
||||||
Uint32 i, offset, ypos, yof;
|
Uint32 i, offset, ypos, yof;
|
||||||
#ifdef RND_BLUR_PROFILE
|
|
||||||
clock_t t1 = clock ();
|
|
||||||
#endif
|
|
||||||
#if BLUR_TYPE == 1
|
#if BLUR_TYPE == 1
|
||||||
#define MWID 3
|
#define MWID 3
|
||||||
#define ARRAY_SIZE 4
|
#define ARRAY_SIZE 4
|
||||||
@@ -172,7 +164,7 @@ void blurSurface32 (SDL_Surface *src)
|
|||||||
|
|
||||||
if (src->format->BitsPerPixel != 32)
|
if (src->format->BitsPerPixel != 32)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "blurSurface32 requires a 32bit Surface, but surface is %d bits!\n",
|
log_add (log_Debug, "blurSurface32 requires a 32bit Surface, but surface is %d bits!\n",
|
||||||
src->format->BitsPerPixel);
|
src->format->BitsPerPixel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -256,9 +248,6 @@ void blurSurface32 (SDL_Surface *src)
|
|||||||
SDL_UnlockSurface (src);
|
SDL_UnlockSurface (src);
|
||||||
for(i = 0; i < ARRAY_SIZE; i++)
|
for(i = 0; i < ARRAY_SIZE; i++)
|
||||||
HFree (blur_array[i]);
|
HFree (blur_array[i]);
|
||||||
#ifdef RND_BLUR_PROFILE
|
|
||||||
fprintf(stderr, "Blur took %f seconds\n",(float)(clock() - t1) / CLOCKS_PER_SEC);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the rZF_nearestneighbor method fills the 'dst' image with the 'src' image
|
/* the rZF_nearestneighbor method fills the 'dst' image with the 'src' image
|
||||||
@@ -520,10 +509,6 @@ void rZF_continuous (SDL_Surface *src, SDL_Surface *dst)
|
|||||||
/* perform a 16x zoom, and then apply a blur filter to the result */
|
/* perform a 16x zoom, and then apply a blur filter to the result */
|
||||||
void random16xZoomSurfaceRGBA (SDL_Surface *src, SDL_Surface *dst)
|
void random16xZoomSurfaceRGBA (SDL_Surface *src, SDL_Surface *dst)
|
||||||
{
|
{
|
||||||
#ifdef RND_BLUR_PROFILE
|
|
||||||
clock_t t1 = clock();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Alloc space to completely contain the zoomed surface
|
* Alloc space to completely contain the zoomed surface
|
||||||
*/
|
*/
|
||||||
@@ -543,9 +528,6 @@ void random16xZoomSurfaceRGBA (SDL_Surface *src, SDL_Surface *dst)
|
|||||||
SDL_UnlockSurface (src);
|
SDL_UnlockSurface (src);
|
||||||
SDL_UnlockSurface (dst);
|
SDL_UnlockSurface (dst);
|
||||||
SDL_SetAlpha(dst, SDL_SRCALPHA, 255);
|
SDL_SetAlpha(dst, SDL_SRCALPHA, 255);
|
||||||
#ifdef RND_BLUR_PROFILE
|
|
||||||
fprintf(stderr, "Randomize took %f seconds\n",(float)(clock() - t1) / CLOCKS_PER_SEC);
|
|
||||||
#endif
|
|
||||||
blurSurface32 (dst);
|
blurSurface32 (dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "libs/graphics/sdl/sdl_common.h"
|
#include "libs/graphics/sdl/sdl_common.h"
|
||||||
#include "libs/platform.h"
|
#include "libs/platform.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "scalers.h"
|
#include "scalers.h"
|
||||||
#include "scaleint.h"
|
#include "scaleint.h"
|
||||||
#include "2xscalers.h"
|
#include "2xscalers.h"
|
||||||
@@ -214,7 +215,7 @@ Scale_PrepPlatform (int flags, const SDL_PixelFormat* fmt)
|
|||||||
if ( (!force_platform && (SDL_HasSSE () || SDL_HasMMXExt ()))
|
if ( (!force_platform && (SDL_HasSSE () || SDL_HasMMXExt ()))
|
||||||
|| force_platform == SCALEPLAT_SSE)
|
|| force_platform == SCALEPLAT_SSE)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Screen scalers are using SSE/MMX-Ext/MMX code\n");
|
log_add (log_Always, "Screen scalers are using SSE/MMX-Ext/MMX code");
|
||||||
Scale_Platform = SCALEPLAT_SSE;
|
Scale_Platform = SCALEPLAT_SSE;
|
||||||
|
|
||||||
Scale_SSE_PrepPlatform (fmt);
|
Scale_SSE_PrepPlatform (fmt);
|
||||||
@@ -223,15 +224,15 @@ Scale_PrepPlatform (int flags, const SDL_PixelFormat* fmt)
|
|||||||
if ( (!force_platform && SDL_HasAltiVec ())
|
if ( (!force_platform && SDL_HasAltiVec ())
|
||||||
|| force_platform == SCALEPLAT_ALTIVEC)
|
|| force_platform == SCALEPLAT_ALTIVEC)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Screen scalers would use AltiVec code "
|
log_add (log_Always, "Screen scalers would use AltiVec code "
|
||||||
"if someone actually wrote it\n");
|
"if someone actually wrote it");
|
||||||
//Scale_Platform = SCALEPLAT_ALTIVEC;
|
//Scale_Platform = SCALEPLAT_ALTIVEC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if ( (!force_platform && SDL_Has3DNow ())
|
if ( (!force_platform && SDL_Has3DNow ())
|
||||||
|| force_platform == SCALEPLAT_3DNOW)
|
|| force_platform == SCALEPLAT_3DNOW)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Screen scalers are using 3DNow/MMX code\n");
|
log_add (log_Always, "Screen scalers are using 3DNow/MMX code");
|
||||||
Scale_Platform = SCALEPLAT_3DNOW;
|
Scale_Platform = SCALEPLAT_3DNOW;
|
||||||
|
|
||||||
Scale_3DNow_PrepPlatform (fmt);
|
Scale_3DNow_PrepPlatform (fmt);
|
||||||
@@ -240,7 +241,7 @@ Scale_PrepPlatform (int flags, const SDL_PixelFormat* fmt)
|
|||||||
if ( (!force_platform && SDL_HasMMX ())
|
if ( (!force_platform && SDL_HasMMX ())
|
||||||
|| force_platform == SCALEPLAT_MMX)
|
|| force_platform == SCALEPLAT_MMX)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Screen scalers are using MMX code\n");
|
log_add (log_Always, "Screen scalers are using MMX code");
|
||||||
Scale_Platform = SCALEPLAT_MMX;
|
Scale_Platform = SCALEPLAT_MMX;
|
||||||
|
|
||||||
Scale_MMX_PrepPlatform (fmt);
|
Scale_MMX_PrepPlatform (fmt);
|
||||||
@@ -259,15 +260,15 @@ Scale_PrepPlatform (int flags, const SDL_PixelFormat* fmt)
|
|||||||
Scale_Platform = SCALEPLAT_C_ABGR;
|
Scale_Platform = SCALEPLAT_C_ABGR;
|
||||||
else
|
else
|
||||||
{ // use slowest default
|
{ // use slowest default
|
||||||
fprintf (stderr, "Scale_PrepPlatform(): "
|
log_add (log_Warning, "Scale_PrepPlatform(): "
|
||||||
"unknown Red mask (0x%08x)\n", fmt->Rmask);
|
"unknown Red mask (0x%08x)", fmt->Rmask);
|
||||||
Scale_Platform = SCALEPLAT_C;
|
Scale_Platform = SCALEPLAT_C;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Scale_Platform == SCALEPLAT_C)
|
if (Scale_Platform == SCALEPLAT_C)
|
||||||
fprintf (stderr, "Screen scalers are using slow generic C code\n");
|
log_add (log_Always, "Screen scalers are using slow generic C code");
|
||||||
else
|
else
|
||||||
fprintf (stderr, "Screen scalers are using optimized C code\n");
|
log_add (log_Always, "Screen scalers are using optimized C code");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup the scaling function
|
// Lookup the scaling function
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "bbox.h"
|
#include "bbox.h"
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
#include "libs/uio.h"
|
#include "libs/uio.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
// XXX: Should not be included from here.
|
// XXX: Should not be included from here.
|
||||||
#include "uqmdebug.h"
|
#include "uqmdebug.h"
|
||||||
@@ -63,15 +64,15 @@ TFB_Abort (void)
|
|||||||
void
|
void
|
||||||
TFB_PreInit (void)
|
TFB_PreInit (void)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Initializing base SDL functionality.\n");
|
log_add (log_Always, "Initializing base SDL functionality.");
|
||||||
fprintf (stderr, "Using SDL version %d.%d.%d (compiled with "
|
log_add (log_Always, "Using SDL version %d.%d.%d (compiled with "
|
||||||
"%d.%d.%d)\n", SDL_Linked_Version ()->major,
|
"%d.%d.%d)", SDL_Linked_Version ()->major,
|
||||||
SDL_Linked_Version ()->minor, SDL_Linked_Version ()->patch,
|
SDL_Linked_Version ()->minor, SDL_Linked_Version ()->patch,
|
||||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
|
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
|
||||||
if ((SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) == -1))
|
if ((SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) == -1))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Could not initialize SDL: %s.\n", SDL_GetError());
|
log_add (log_Always, "Could not initialize SDL: %s.", SDL_GetError());
|
||||||
exit(-1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,8 +90,8 @@ TFB_ReInitGraphics (int driver, int flags, int width, int height)
|
|||||||
result = TFB_GL_ConfigureVideo (driver, flags, width, height);
|
result = TFB_GL_ConfigureVideo (driver, flags, width, height);
|
||||||
#else
|
#else
|
||||||
driver = TFB_GFXDRIVER_SDL_PURE;
|
driver = TFB_GFXDRIVER_SDL_PURE;
|
||||||
fprintf (stderr, "OpenGL support not compiled in, so using pure "
|
log_add (log_Always, "OpenGL support not compiled in,"
|
||||||
"sdl driver\n");
|
" so using pure SDL driver");
|
||||||
result = TFB_Pure_ConfigureVideo (driver, flags, width, height);
|
result = TFB_Pure_ConfigureVideo (driver, flags, width, height);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -126,8 +127,8 @@ TFB_InitGraphics (int driver, int flags, int width, int height)
|
|||||||
result = TFB_GL_InitGraphics (driver, flags, width, height);
|
result = TFB_GL_InitGraphics (driver, flags, width, height);
|
||||||
#else
|
#else
|
||||||
driver = TFB_GFXDRIVER_SDL_PURE;
|
driver = TFB_GFXDRIVER_SDL_PURE;
|
||||||
fprintf (stderr, "OpenGL support not compiled in, so using pure "
|
log_add (log_Always, "OpenGL support not compiled in,"
|
||||||
"sdl driver\n");
|
" so using pure SDL driver");
|
||||||
result = TFB_Pure_InitGraphics (driver, flags, width, height);
|
result = TFB_Pure_InitGraphics (driver, flags, width, height);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -178,7 +179,8 @@ TFB_ProcessEvents ()
|
|||||||
// TODO
|
// TODO
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
exit (0);
|
log_showBox (false, false);
|
||||||
|
exit (EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case SDL_VIDEORESIZE: /* User resized video mode */
|
case SDL_VIDEORESIZE: /* User resized video mode */
|
||||||
// TODO
|
// TODO
|
||||||
@@ -191,7 +193,10 @@ TFB_ProcessEvents ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImmediateInputState.menu[KEY_ABORT] || abortFlag)
|
if (ImmediateInputState.menu[KEY_ABORT] || abortFlag)
|
||||||
exit (0);
|
{
|
||||||
|
log_showBox (false, false);
|
||||||
|
exit (EXIT_SUCCESS);
|
||||||
|
}
|
||||||
#if defined(DEBUG) || defined(USE_DEBUG_KEY)
|
#if defined(DEBUG) || defined(USE_DEBUG_KEY)
|
||||||
if (ImmediateInputState.menu[KEY_DEBUG])
|
if (ImmediateInputState.menu[KEY_DEBUG])
|
||||||
{
|
{
|
||||||
@@ -262,7 +267,7 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
|
|||||||
{
|
{
|
||||||
// normal blit: dst = src
|
// normal blit: dst = src
|
||||||
|
|
||||||
// fprintf(stderr, "normal blit\n");
|
// log_add (log_Debug, "normal blit\n");
|
||||||
SDL_BlitSurface (src, srcrect, dst, dstrect);
|
SDL_BlitSurface (src, srcrect, dst, dstrect);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -369,9 +374,11 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
|
|||||||
if (blend_denom < 0)
|
if (blend_denom < 0)
|
||||||
{
|
{
|
||||||
// additive blit: dst = src + dst
|
// additive blit: dst = src + dst
|
||||||
|
#if 0
|
||||||
// fprintf(stderr, "additive blit %d %d, src %d %d %d %d dst %d %d, srcbpp %d\n",blend_numer, blend_denom, x1, y1, x2, y2, dstrect->x, dstrect->y, src->format->BitsPerPixel);
|
log_add (log_Debug, "additive blit %d %d, src %d %d %d %d dst %d %d,"
|
||||||
|
" srcbpp %d", blend_numer, blend_denom, x1, y1, x2, y2,
|
||||||
|
dstrect->x, dstrect->y, src->format->BitsPerPixel);
|
||||||
|
#endif
|
||||||
for (y = y1; y < y2; ++y)
|
for (y = y1; y < y2; ++y)
|
||||||
{
|
{
|
||||||
dst_y2 = dstrect->y + (y - y1);
|
dst_y2 = dstrect->y + (y - y1);
|
||||||
@@ -407,9 +414,12 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
|
|||||||
else if (blend_numer < 0)
|
else if (blend_numer < 0)
|
||||||
{
|
{
|
||||||
// subtractive blit: dst = src - dst
|
// subtractive blit: dst = src - dst
|
||||||
|
#if 0
|
||||||
// fprintf(stderr, "subtractive blit %d %d, src %d %d %d %d dst %d %d, srcbpp %d\n",blend_numer, blend_denom, x1, y1, x2, y2, dstrect->x, dstrect->y, src->format->BitsPerPixel);
|
log_add (log_Debug, "subtractive blit %d %d, src %d %d %d %d"
|
||||||
|
" dst %d %d, srcbpp %d", blend_numer, blend_denom,
|
||||||
|
x1, y1, x2, y2, dstrect->x, dstrect->y,
|
||||||
|
src->format->BitsPerPixel);
|
||||||
|
#endif
|
||||||
for (y = y1; y < y2; ++y)
|
for (y = y1; y < y2; ++y)
|
||||||
{
|
{
|
||||||
dst_y2 = dstrect->y + (y - y1);
|
dst_y2 = dstrect->y + (y - y1);
|
||||||
@@ -447,9 +457,12 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
|
|||||||
// modulated blit: dst = src * (blend_numer / blend_denom)
|
// modulated blit: dst = src * (blend_numer / blend_denom)
|
||||||
|
|
||||||
float f = blend_numer / (float)blend_denom;
|
float f = blend_numer / (float)blend_denom;
|
||||||
|
#if 0
|
||||||
// fprintf(stderr, "modulated blit %d %d, f %f, src %d %d %d %d dst %d %d, srcbpp %d\n",blend_numer, blend_denom, f, x1, y1, x2, y2, dstrect->x, dstrect->y, src->format->BitsPerPixel);
|
log_add (log_Debug, "modulated blit %d %d, f %f, src %d %d %d %d"
|
||||||
|
" dst %d %d, srcbpp %d\n", blend_numer, blend_denom, f,
|
||||||
|
x1, y1, x2, y2, dstrect->x, dstrect->y,
|
||||||
|
src->format->BitsPerPixel);
|
||||||
|
#endif
|
||||||
for (y = y1; y < y2; ++y)
|
for (y = y1; y < y2; ++y)
|
||||||
{
|
{
|
||||||
dst_y2 = dstrect->y + (y - y1);
|
dst_y2 = dstrect->y + (y - y1);
|
||||||
@@ -494,7 +507,7 @@ TFB_ComputeFPS (void)
|
|||||||
fps_counter += delta_time;
|
fps_counter += delta_time;
|
||||||
if (fps_counter > FPS_PERIOD)
|
if (fps_counter > FPS_PERIOD)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "fps %.2f, effective %.2f\n",
|
log_add (log_Always, "fps %.2f, effective %.2f",
|
||||||
1000.0 / delta_time,
|
1000.0 / delta_time,
|
||||||
1000.0 * RenderedFrames / fps_counter);
|
1000.0 * RenderedFrames / fps_counter);
|
||||||
|
|
||||||
@@ -573,7 +586,7 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
if (!livelock_deterrence && commands_handled + DrawCommandQueue.Size
|
if (!livelock_deterrence && commands_handled + DrawCommandQueue.Size
|
||||||
> DCQ_LIVELOCK_MAX)
|
> DCQ_LIVELOCK_MAX)
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "Initiating livelock deterrence!\n");
|
// log_add (log_Debug, "Initiating livelock deterrence!");
|
||||||
livelock_deterrence = TRUE;
|
livelock_deterrence = TRUE;
|
||||||
|
|
||||||
Lock_DCQ (-1);
|
Lock_DCQ (-1);
|
||||||
@@ -586,7 +599,7 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
int index = DC.data.setpalette.index;
|
int index = DC.data.setpalette.index;
|
||||||
if (index < 0 || index > 255)
|
if (index < 0 || index > 255)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "DCQ panic: Tried to set palette #%i",
|
log_add (log_Debug, "DCQ panic: Tried to set palette #%i",
|
||||||
index);
|
index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -731,8 +744,8 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
|
|
||||||
if (DC_image == 0)
|
if (DC_image == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "DCQ ERROR: COPYTOIMAGE passed null "
|
log_add (log_Debug, "DCQ ERROR: COPYTOIMAGE passed null "
|
||||||
"image ptr\n");
|
"image ptr");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LockMutex (DC_image->mutex);
|
LockMutex (DC_image->mutex);
|
||||||
@@ -788,12 +801,14 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
if (TFB_ReInitGraphics (DC.data.reinitvideo.driver, DC.data.reinitvideo.flags,
|
if (TFB_ReInitGraphics (DC.data.reinitvideo.driver, DC.data.reinitvideo.flags,
|
||||||
DC.data.reinitvideo.width, DC.data.reinitvideo.height))
|
DC.data.reinitvideo.width, DC.data.reinitvideo.height))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Could not provide requested mode: reverting to last known driver.\n");
|
log_add (log_Always, "Could not provide requested mode: "
|
||||||
|
"reverting to last known driver.");
|
||||||
if (TFB_ReInitGraphics (oldDriver, DC.data.reinitvideo.flags,
|
if (TFB_ReInitGraphics (oldDriver, DC.data.reinitvideo.flags,
|
||||||
DC.data.reinitvideo.width, DC.data.reinitvideo.height))
|
DC.data.reinitvideo.width, DC.data.reinitvideo.height))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't reinit at that point either. Your video has been somehow tied in knots.\n");
|
log_add (log_Always, "Couldn't reinit at that point either."
|
||||||
exit (-1);
|
" Your video has been somehow tied in knots.");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -816,11 +831,11 @@ TFB_SetGamma (float gamma)
|
|||||||
{
|
{
|
||||||
if (SDL_SetGamma (gamma, gamma, gamma) == -1)
|
if (SDL_SetGamma (gamma, gamma, gamma) == -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Unable to set gamma correction.\n");
|
log_add (log_Warning, "Unable to set gamma correction.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Gamma correction set to %1.4f.\n", gamma);
|
log_add (log_Info, "Gamma correction set to %1.4f.", gamma);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "tfb_draw.h"
|
#include "tfb_draw.h"
|
||||||
#include "drawcmd.h"
|
#include "drawcmd.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
static const HOT_SPOT NullHs = {0, 0};
|
static const HOT_SPOT NullHs = {0, 0};
|
||||||
|
|
||||||
@@ -340,8 +341,8 @@ TFB_DrawImage_New_Rotated (TFB_Image *img, int angle)
|
|||||||
/* sanity check */
|
/* sanity check */
|
||||||
if (!img->NormalImg)
|
if (!img->NormalImg)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_DrawImage_New_Rotated: "
|
log_add (log_Warning, "TFB_DrawImage_New_Rotated: "
|
||||||
"source canvas is NULL! Failing.\n");
|
"source canvas is NULL! Failing.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,8 +350,8 @@ TFB_DrawImage_New_Rotated (TFB_Image *img, int angle)
|
|||||||
dst = TFB_DrawCanvas_New_RotationTarget (img->NormalImg, angle);
|
dst = TFB_DrawCanvas_New_RotationTarget (img->NormalImg, angle);
|
||||||
if (!dst)
|
if (!dst)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_DrawImage_New_Rotated: "
|
log_add (log_Warning, "TFB_DrawImage_New_Rotated: "
|
||||||
"rotation target canvas not created! Failing.\n");
|
"rotation target canvas not created! Failing.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
TFB_DrawCanvas_Rotate (img->NormalImg, dst, angle, size);
|
TFB_DrawCanvas_Rotate (img->NormalImg, dst, angle, size);
|
||||||
@@ -364,7 +365,7 @@ TFB_DrawImage_Delete (TFB_Image *image)
|
|||||||
{
|
{
|
||||||
if (image == 0)
|
if (image == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "INTERNAL ERROR: Tried to delete a null image!\n");
|
log_add (log_Warning, "INTERNAL ERROR: Tried to delete a null image!");
|
||||||
/* Should we die here? */
|
/* Should we die here? */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "tfb_draw.h"
|
#include "tfb_draw.h"
|
||||||
#include "tfb_prim.h"
|
#include "tfb_prim.h"
|
||||||
#include "cmap.h"
|
#include "cmap.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
TFB_Prim_Point (PPOINT p, TFB_Palette *color)
|
TFB_Prim_Point (PPOINT p, TFB_Palette *color)
|
||||||
@@ -125,7 +126,8 @@ TFB_Prim_Stamp (PSTAMP stmp)
|
|||||||
SrcFramePtr = (PFRAME_DESC)stmp->frame;
|
SrcFramePtr = (PFRAME_DESC)stmp->frame;
|
||||||
if (!SrcFramePtr)
|
if (!SrcFramePtr)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_Prim_Stamp: Tried to draw a NULL frame (Stamp address = %p)\n", stmp);
|
log_add (log_Warning, "TFB_Prim_Stamp: Tried to draw a NULL frame"
|
||||||
|
" (Stamp address = %p)", stmp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
img = SrcFramePtr->image;
|
img = SrcFramePtr->image;
|
||||||
@@ -133,7 +135,7 @@ TFB_Prim_Stamp (PSTAMP stmp)
|
|||||||
|
|
||||||
if (!img)
|
if (!img)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Non-existent image to TFB_Prim_Stamp()\n");
|
log_add (log_Warning, "Non-existent image to TFB_Prim_Stamp()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +175,8 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color)
|
|||||||
SrcFramePtr = (PFRAME_DESC)stmp->frame;
|
SrcFramePtr = (PFRAME_DESC)stmp->frame;
|
||||||
if (!SrcFramePtr)
|
if (!SrcFramePtr)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_Prim_StampFill: Tried to draw a NULL frame (Stamp address = %p)\n", stmp);
|
log_add (log_Warning, "TFB_Prim_StampFill: Tried to draw a NULL frame"
|
||||||
|
" (Stamp address = %p)", stmp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
img = SrcFramePtr->image;
|
img = SrcFramePtr->image;
|
||||||
@@ -181,7 +184,7 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color)
|
|||||||
|
|
||||||
if (!img)
|
if (!img)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Non-existent image to TFB_Prim_StampFill()\n");
|
log_add (log_Warning, "Non-existent image to TFB_Prim_StampFill()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "libs/input/sdl/vcontrol.h"
|
#include "libs/input/sdl/vcontrol.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "libs/file.h"
|
#include "libs/file.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -109,7 +110,8 @@ static VControl_NameBinding control_names[] = {
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initKeyConfig(void) {
|
initKeyConfig (void)
|
||||||
|
{
|
||||||
uio_Stream *fp;
|
uio_Stream *fp;
|
||||||
int i, errors;
|
int i, errors;
|
||||||
|
|
||||||
@@ -120,16 +122,16 @@ initKeyConfig(void) {
|
|||||||
if (copyFile (contentDir, "starcon.key",
|
if (copyFile (contentDir, "starcon.key",
|
||||||
configDir, "keys.cfg") == -1)
|
configDir, "keys.cfg") == -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Could not copy default key config "
|
log_add (log_Always, "Error: Could not copy default key config "
|
||||||
"to user config dir: %s.\n", strerror (errno));
|
"to user config dir: %s.", strerror (errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Copying default key config file to user "
|
log_add (log_Info, "Copying default key config file to user "
|
||||||
"config dir.\n");
|
"config dir.");
|
||||||
|
|
||||||
if ((fp = res_OpenResFile (configDir, "keys.cfg", "rt")) == NULL)
|
if ((fp = res_OpenResFile (configDir, "keys.cfg", "rt")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Could not open keys.cfg\n");
|
log_add (log_Always, "Error: Could not open keys.cfg");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,45 +143,45 @@ initKeyConfig(void) {
|
|||||||
{
|
{
|
||||||
bool do_rename = false;
|
bool do_rename = false;
|
||||||
if (errors)
|
if (errors)
|
||||||
fprintf (stderr, "%d errors encountered in key configuration file.\n", errors);
|
log_add (log_Warning, "%d errors encountered in key configuration file.", errors);
|
||||||
|
|
||||||
if (VControl_GetValidCount () == 0)
|
if (VControl_GetValidCount () == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\nI didn't understand a single line in your configuration file.\n");
|
log_add (log_Always, "\nI didn't understand a single line in your configuration file.");
|
||||||
fprintf (stderr, "This is likely because you're still using a 0.2 era or earlier keys.cfg.\n");
|
log_add (log_Always, "This is likely because you're still using a 0.2 era or earlier keys.cfg.");
|
||||||
do_rename = true;
|
do_rename = true;
|
||||||
}
|
}
|
||||||
if (VControl_GetConfigFileVersion () != VCONTROL_VERSION)
|
if (VControl_GetConfigFileVersion () != VCONTROL_VERSION)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\nThe control scheme for UQM has changed since you last updated keys.cfg.\n");
|
log_add (log_Always, "\nThe control scheme for UQM has changed since you last updated keys.cfg.");
|
||||||
fprintf (stderr, "(I'm using control scheme version %d, while your config file appears to be\nfor version %d.)\n", VCONTROL_VERSION, VControl_GetConfigFileVersion ());
|
log_add (log_Always, "(I'm using control scheme version %d, while your config file appears to be\nfor version %d.)", VCONTROL_VERSION, VControl_GetConfigFileVersion ());
|
||||||
do_rename = true;
|
do_rename = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_rename)
|
if (do_rename)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\nRenaming keys.cfg to keys.old and retrying.\n");
|
log_add (log_Always, "\nRenaming keys.cfg to keys.old and retrying.");
|
||||||
|
|
||||||
if (fileExists2 (configDir, "keys.old"))
|
if (fileExists2 (configDir, "keys.old"))
|
||||||
uio_unlink (configDir, "keys.old");
|
uio_unlink (configDir, "keys.old");
|
||||||
if ((uio_rename (configDir, "keys.cfg", configDir, "keys.old")) == -1)
|
if ((uio_rename (configDir, "keys.cfg", configDir, "keys.old")) == -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Renaming failed!\n");
|
log_add (log_Always, "Error: Renaming failed!");
|
||||||
fprintf (stderr, "You must delete keys.cfg manually before you can run the game.\n");
|
log_add (log_Always, "You must delete keys.cfg manually before you can run the game.");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "\nRepair your keys.cfg file to continue.\n");
|
log_add (log_Always, "\nRepair your keys.cfg file to continue.");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "Error: Something went wrong and we were looping again and again so aborting.\n");
|
log_add (log_Always, "Error: Something went wrong and we were looping again and again so aborting.");
|
||||||
fprintf (stderr, "Possible cause is your content dir not being up-to-date.\n");
|
log_add (log_Always, "Possible cause is your content dir not being up-to-date.");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,19 +206,20 @@ TFB_InitInput (int driver, int flags)
|
|||||||
|
|
||||||
if ((SDL_InitSubSystem(SDL_INIT_JOYSTICK)) == -1)
|
if ((SDL_InitSubSystem(SDL_INIT_JOYSTICK)) == -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't initialize joystick subsystem: %s\n", SDL_GetError());
|
log_add (log_Always, "Couldn't initialize joystick subsystem: %s",
|
||||||
exit(-1);
|
SDL_GetError());
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "%i joysticks were found.\n", SDL_NumJoysticks ());
|
log_add (log_Info, "%i joysticks were found.", SDL_NumJoysticks ());
|
||||||
|
|
||||||
nJoysticks = SDL_NumJoysticks ();
|
nJoysticks = SDL_NumJoysticks ();
|
||||||
if (nJoysticks > 0)
|
if (nJoysticks > 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "The names of the joysticks are:\n");
|
log_add (log_Info, "The names of the joysticks are:");
|
||||||
for(i = 0; i < nJoysticks; i++)
|
for (i = 0; i < nJoysticks; i++)
|
||||||
{
|
{
|
||||||
fprintf (stderr, " %s\n", SDL_JoystickName (i));
|
log_add (log_Info, " %s", SDL_JoystickName (i));
|
||||||
}
|
}
|
||||||
SDL_JoystickEventState (SDL_ENABLE);
|
SDL_JoystickEventState (SDL_ENABLE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "vcontrol.h"
|
#include "vcontrol.h"
|
||||||
#include "vcontrol_malloc.h"
|
#include "vcontrol_malloc.h"
|
||||||
#include "keynames.h"
|
#include "keynames.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
/* How many binding slots are allocated at once. */
|
/* How many binding slots are allocated at once. */
|
||||||
#define POOL_CHUNK_SIZE 64
|
#define POOL_CHUNK_SIZE 64
|
||||||
@@ -97,7 +98,7 @@ create_joystick (int index)
|
|||||||
int axes, buttons, hats;
|
int axes, buttons, hats;
|
||||||
if (index >= joycount)
|
if (index >= joycount)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl warning: Tried to open a non-existent joystick!");
|
log_add (log_Warning, "VControl warning: Tried to open a non-existent joystick!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (joysticks[index].stick)
|
if (joysticks[index].stick)
|
||||||
@@ -110,11 +111,11 @@ create_joystick (int index)
|
|||||||
{
|
{
|
||||||
joystick *x = &joysticks[index];
|
joystick *x = &joysticks[index];
|
||||||
int j;
|
int j;
|
||||||
fprintf (stderr, "VControl opened joystick: %s\n", SDL_JoystickName (index));
|
log_add (log_Info, "VControl opened joystick: %s", SDL_JoystickName (index));
|
||||||
axes = SDL_JoystickNumAxes (stick);
|
axes = SDL_JoystickNumAxes (stick);
|
||||||
buttons = SDL_JoystickNumButtons (stick);
|
buttons = SDL_JoystickNumButtons (stick);
|
||||||
hats = SDL_JoystickNumHats (stick);
|
hats = SDL_JoystickNumHats (stick);
|
||||||
fprintf (stderr, "%d axes, %d buttons, %d hats.\n", axes, buttons, hats);
|
log_add (log_Info, "%d axes, %d buttons, %d hats.", axes, buttons, hats);
|
||||||
x->numaxes = axes;
|
x->numaxes = axes;
|
||||||
x->numbuttons = buttons;
|
x->numbuttons = buttons;
|
||||||
x->numhats = hats;
|
x->numhats = hats;
|
||||||
@@ -139,7 +140,7 @@ create_joystick (int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Could not initialize joystick #%d\n", index);
|
log_add (log_Warning, "VControl: Could not initialize joystick #%d", index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +239,7 @@ VControl_SetJoyThreshold (int port, int threshold)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "VControl_SetJoyThreshold passed illegal port %d\n", port);
|
// log_add (log_Warning, "VControl_SetJoyThreshold passed illegal port %d", port);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,7 +294,7 @@ add_binding (keybinding **newptr, int *target)
|
|||||||
/* Sanity check. */
|
/* Sanity check. */
|
||||||
if (!newbinding)
|
if (!newbinding)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "add_binding failed to find a free binding slot!\n");
|
log_add (log_Warning, "add_binding failed to find a free binding slot!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +379,7 @@ VControl_AddBinding (SDL_Event *e, int *target)
|
|||||||
result = VControl_AddJoyButtonBinding (e->jbutton.which, e->jbutton.button, target);
|
result = VControl_AddJoyButtonBinding (e->jbutton.which, e->jbutton.button, target);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "VControl_AddBinding didn't understand argument event\n");
|
log_add (log_Warning, "VControl_AddBinding didn't understand argument event");
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -403,7 +404,7 @@ VControl_RemoveBinding (SDL_Event *e, int *target)
|
|||||||
VControl_RemoveJoyButtonBinding (e->jbutton.which, e->jbutton.button, target);
|
VControl_RemoveJoyButtonBinding (e->jbutton.which, e->jbutton.button, target);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "VControl_RemoveBinding didn't understand argument event\n");
|
log_add (log_Warning, "VControl_RemoveBinding didn't understand argument event");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,7 +413,7 @@ int
|
|||||||
VControl_AddKeyBinding (SDLKey symbol, int *target)
|
VControl_AddKeyBinding (SDLKey symbol, int *target)
|
||||||
{
|
{
|
||||||
if ((symbol < 0) || (symbol >= SDLK_LAST)) {
|
if ((symbol < 0) || (symbol >= SDLK_LAST)) {
|
||||||
fprintf (stderr, "VControl: Illegal key index %d\n", symbol);
|
log_add (log_Warning, "VControl: Illegal key index %d", symbol);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
add_binding(&bindings[symbol], target);
|
add_binding(&bindings[symbol], target);
|
||||||
@@ -423,7 +424,7 @@ void
|
|||||||
VControl_RemoveKeyBinding (SDLKey symbol, int *target)
|
VControl_RemoveKeyBinding (SDLKey symbol, int *target)
|
||||||
{
|
{
|
||||||
if ((symbol < 0) || (symbol >= SDLK_LAST)) {
|
if ((symbol < 0) || (symbol >= SDLK_LAST)) {
|
||||||
fprintf (stderr, "VControl: Illegal key index %d\n", symbol);
|
log_add (log_Warning, "VControl: Illegal key index %d", symbol);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
remove_binding (&bindings[symbol], target);
|
remove_binding (&bindings[symbol], target);
|
||||||
@@ -449,19 +450,19 @@ VControl_AddJoyAxisBinding (int port, int axis, int polarity, int *target)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "VControl: Attempted to bind to polarity zero\n");
|
log_add (log_Debug, "VControl: Attempted to bind to polarity zero");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "VControl: Attempted to bind to illegal axis %d\n", axis);
|
// log_add (log_Debug, "VControl: Attempted to bind to illegal axis %d", axis);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "VControl: Attempted to bind to illegal port %d\n", port);
|
// log_add (log_Debug, "VControl: Attempted to bind to illegal port %d", port);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -487,17 +488,17 @@ VControl_RemoveJoyAxisBinding (int port, int axis, int polarity, int *target)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Attempted to unbind from polarity zero\n");
|
log_add (log_Debug, "VControl: Attempted to unbind from polarity zero");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Attempted to unbind from illegal axis %d\n", axis);
|
log_add (log_Debug, "VControl: Attempted to unbind from illegal axis %d", axis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Attempted to unbind from illegal port %d\n", port);
|
log_add (log_Debug, "VControl: Attempted to unbind from illegal port %d", port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,13 +517,13 @@ VControl_AddJoyButtonBinding (int port, int button, int *target)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "VControl: Attempted to bind to illegal button %d\n", button);
|
// log_add (log_Debug, "VControl: Attempted to bind to illegal button %d", button);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "VControl: Attempted to bind to illegal port %d\n", port);
|
// log_add (log_Debug, "VControl: Attempted to bind to illegal port %d", port);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,12 +542,12 @@ VControl_RemoveJoyButtonBinding (int port, int button, int *target)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Attempted to unbind from illegal button %d\n", button);
|
log_add (log_Debug, "VControl: Attempted to unbind from illegal button %d", button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Attempted to unbind from illegal port %d\n", port);
|
log_add (log_Debug, "VControl: Attempted to unbind from illegal port %d", port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,20 +579,20 @@ VControl_AddJoyHatBinding (int port, int which, Uint8 dir, int *target)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "VControl: Attempted to bind to illegal direction\n");
|
// log_add (log_Debug, "VControl: Attempted to bind to illegal direction");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "VControl: Attempted to bind to illegal hat %d\n", which);
|
// log_add (log_Debug, "VControl: Attempted to bind to illegal hat %d", which);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "VControl: Attempted to bind to illegal port %d\n", port);
|
// log_add (log_Debug, "VControl: Attempted to bind to illegal port %d", port);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -624,17 +625,17 @@ VControl_RemoveJoyHatBinding (int port, int which, Uint8 dir, int *target)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Attempted to unbind from illegal direction\n");
|
log_add (log_Debug, "VControl: Attempted to unbind from illegal direction");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Attempted to unbind from illegal hat %d\n", which);
|
log_add (log_Debug, "VControl: Attempted to unbind from illegal hat %d", which);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Attempted to unbind from illegal port %d\n", port);
|
log_add (log_Debug, "VControl: Attempted to unbind from illegal port %d", port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1213,7 +1214,8 @@ next_line (parse_state *state, uio_Stream *in)
|
|||||||
static void
|
static void
|
||||||
expected_error (parse_state *state, char *expected)
|
expected_error (parse_state *state, char *expected)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Expected '%s' on config file line %d\n", expected, state->linenum);
|
log_add (log_Warning, "VControl: Expected '%s' on config file line %d",
|
||||||
|
expected, state->linenum);
|
||||||
state->error = 1;
|
state->error = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1233,7 +1235,8 @@ consume_keyname (parse_state *state)
|
|||||||
int keysym = VControl_name2code (state->token);
|
int keysym = VControl_name2code (state->token);
|
||||||
if (!keysym)
|
if (!keysym)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Illegal key name '%s' on config file line %d\n", state->token, state->linenum);
|
log_add (log_Warning, "VControl: Illegal key name '%s' on config file line %d",
|
||||||
|
state->token, state->linenum);
|
||||||
state->error = 1;
|
state->error = 1;
|
||||||
}
|
}
|
||||||
next_token (state);
|
next_token (state);
|
||||||
@@ -1252,7 +1255,8 @@ consume_idname (parse_state *state)
|
|||||||
|
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Can't happen: blank token to consume_idname (line %d)\n", state->linenum);
|
log_add (log_Debug, "VControl: Can't happen: blank token to consume_idname (line %d)",
|
||||||
|
state->linenum);
|
||||||
state->error = 1;
|
state->error = 1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1270,7 +1274,8 @@ consume_idname (parse_state *state)
|
|||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Illegal command type '%s' on config file line %d\n", state->token, state->linenum);
|
log_add (log_Warning, "VControl: Illegal command type '%s' on config file line %d",
|
||||||
|
state->token, state->linenum);
|
||||||
state->error = 1;
|
state->error = 1;
|
||||||
}
|
}
|
||||||
next_token (state);
|
next_token (state);
|
||||||
@@ -1284,7 +1289,8 @@ consume_num (parse_state *state)
|
|||||||
int result = strtol (state->token, &end, 10);
|
int result = strtol (state->token, &end, 10);
|
||||||
if (*end != '\0')
|
if (*end != '\0')
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Expected integer on config line %d\n", state->linenum);
|
log_add (log_Warning, "VControl: Expected integer on config line %d",
|
||||||
|
state->linenum);
|
||||||
state->error = 1;
|
state->error = 1;
|
||||||
}
|
}
|
||||||
next_token (state);
|
next_token (state);
|
||||||
@@ -1490,7 +1496,7 @@ VControl_ReadConfiguration (uio_Stream *in)
|
|||||||
parse_state ps;
|
parse_state ps;
|
||||||
if (!in)
|
if (!in)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Invalid configuration file stream\n");
|
log_add (log_Warning, "VControl: Invalid configuration file stream");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ps.linenum = 0;
|
ps.linenum = 0;
|
||||||
@@ -1542,7 +1548,7 @@ VControl_TokenizeFile (FILE *in)
|
|||||||
parse_state ps;
|
parse_state ps;
|
||||||
if (!in)
|
if (!in)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VControl: Invalid configuration file stream\n");
|
log_add (log_Warning, "VControl: Invalid configuration file stream");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ps.linenum = 0;
|
ps.linenum = 0;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
#include "libs/threadlib.h"
|
#include "libs/threadlib.h"
|
||||||
#include "libs/memlib.h"
|
#include "libs/memlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#define GetToolFrame() 1
|
#define GetToolFrame() 1
|
||||||
|
|
||||||
@@ -64,55 +65,6 @@ typedef struct _szMemoryNode {
|
|||||||
static szMemoryNode extents[MAX_EXTENTS];
|
static szMemoryNode extents[MAX_EXTENTS];
|
||||||
static szMemoryNode *freeListHead = NULL;
|
static szMemoryNode *freeListHead = NULL;
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*FUNCTION
|
|
||||||
**
|
|
||||||
** SYNOPSIS
|
|
||||||
** Message(format, parms)
|
|
||||||
**
|
|
||||||
** DESCRIPTION
|
|
||||||
** Presents a windows message box to the user and echoes the
|
|
||||||
** message with printf().
|
|
||||||
**
|
|
||||||
** INPUT
|
|
||||||
** As for printf().
|
|
||||||
**
|
|
||||||
** OUTPUT
|
|
||||||
**
|
|
||||||
** HISTORY
|
|
||||||
** 10-Jul-96:AKL Creation.
|
|
||||||
**
|
|
||||||
** ASSUMPTIONS
|
|
||||||
**END*/
|
|
||||||
|
|
||||||
static void Message(char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
char buffer[256];
|
|
||||||
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsprintf(buffer, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
#ifndef FINAL
|
|
||||||
fprintf (stderr, "%s\n", buffer);
|
|
||||||
//fflush (stderr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (GetToolFrame ())
|
|
||||||
{
|
|
||||||
ShowWindow(GetToolFrame (),SW_HIDE);
|
|
||||||
}
|
|
||||||
MessageBox(NULL, buffer, "Message From Programmer Dude", MB_OK);
|
|
||||||
|
|
||||||
if (GetToolFrame ())
|
|
||||||
{
|
|
||||||
ShowWindow(GetToolFrame (),SW_NORMAL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -151,10 +103,8 @@ static int MessageWithRetry(char *fmt, ...)
|
|||||||
vsprintf(buffer, fmt, ap);
|
vsprintf(buffer, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
#ifndef FINAL
|
log_add (log_Always, "%s", buffer);
|
||||||
fprintf (stderr, "%s\n", buffer);
|
|
||||||
// fflush(stderr);
|
// fflush(stderr);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (GetToolFrame ())
|
if (GetToolFrame ())
|
||||||
@@ -258,12 +208,10 @@ MallocWithRetry(int bytes, char *diagStr)
|
|||||||
ptr = malloc (bytes);
|
ptr = malloc (bytes);
|
||||||
if (ptr)
|
if (ptr)
|
||||||
return (ptr);
|
return (ptr);
|
||||||
#ifndef FINAL
|
|
||||||
fprintf (stderr, "Malloc failed for %s. #Bytes %d.\n", diagStr, bytes);
|
|
||||||
// fflush (stderr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
abort();
|
log_add (log_Always, "Malloc failed for %s. #Bytes %d.", diagStr, bytes);
|
||||||
|
fflush (stderr);
|
||||||
|
abort ();
|
||||||
#if 0
|
#if 0
|
||||||
/* The user gets a chance to close other applications and try again. */
|
/* The user gets a chance to close other applications and try again. */
|
||||||
if (!MessageWithRetry ("I'm out of memory! "
|
if (!MessageWithRetry ("I'm out of memory! "
|
||||||
@@ -272,8 +220,9 @@ MallocWithRetry(int bytes, char *diagStr)
|
|||||||
if (MessageWithRetry ("Really OK to stop tfbtool?"))
|
if (MessageWithRetry ("Really OK to stop tfbtool?"))
|
||||||
{
|
{
|
||||||
/* User says "die". */
|
/* User says "die". */
|
||||||
fprintf (stderr, "Killed by the user (%s).\n", diagStr);
|
log_add (log_Always, "Killed by the user (%s).", diagStr);
|
||||||
exit (0);
|
log_showBox (false, false);
|
||||||
|
exit (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -293,10 +242,11 @@ mem_allocate (MEM_SIZE coreSize, MEM_FLAGS flags, MEM_PRIORITY priority,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((node = freeListHead) == NULL)
|
if ((node = freeListHead) == NULL)
|
||||||
Message ("mem_allocate: out of extents.");
|
log_add (log_Always, "mem_allocate: out of extents.");
|
||||||
else if ((node->memory = MallocWithRetry (coreSize, "mem_allocate:")) == 0
|
else if ((node->memory = MallocWithRetry (coreSize, "mem_allocate:")) == 0
|
||||||
&& coreSize)
|
&& coreSize)
|
||||||
Message ("mem_allocate: couldn't allocate %u bytes.", coreSize);
|
log_add (log_Always, "mem_allocate: couldn't allocate %u bytes.",
|
||||||
|
coreSize);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
freeListHead = node->next;
|
freeListHead = node->next;
|
||||||
@@ -309,10 +259,10 @@ mem_allocate (MEM_SIZE coreSize, MEM_FLAGS flags, MEM_PRIORITY priority,
|
|||||||
#ifdef LEAK_DEBUG
|
#ifdef LEAK_DEBUG
|
||||||
if (leak_debug)
|
if (leak_debug)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "alloc %d: %p, %lu\n", (int) node->handle,
|
log_add (log_Debug, "alloc %d: %p, %lu", (int) node->handle,
|
||||||
(void *) node->memory, node->size);
|
(void *) node->memory, node->size);
|
||||||
// Prefered form:
|
// Prefered form:
|
||||||
//fprintf (stderr, "alloc %d: %#8" PRIxPTR ", %lu\n",
|
//log_add (log_Debug, "alloc %d: %#8" PRIxPTR ", %lu",
|
||||||
// (int) node->handle, (intptr_t) node->memory, node->size);
|
// (int) node->handle, (intptr_t) node->memory, node->size);
|
||||||
}
|
}
|
||||||
if (node->handle == leak_idx && node->size == leak_size)
|
if (node->handle == leak_idx && node->size == leak_size)
|
||||||
@@ -445,12 +395,12 @@ mem_uninit(void)
|
|||||||
{
|
{
|
||||||
if (extents[i].handle != -1)
|
if (extents[i].handle != -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "LEAK: unreleased extent %d: %p, %lu\n",
|
log_add (log_Debug, "LEAK: unreleased extent %d: %p, %lu",
|
||||||
extents[i].handle, (void *) extents[i].memory,
|
extents[i].handle, (void *) extents[i].memory,
|
||||||
extents[i].size);
|
extents[i].size);
|
||||||
// Prefered form:
|
// Prefered form:
|
||||||
//fprintf (stderr, "LEAK: unreleased extent %d: %#8" PRIxPTR
|
//log_add (log_Debug, "LEAK: unreleased extent %d: %#8" PRIxPTR
|
||||||
// ", %lu\n", extents[i].handle,
|
// ", %lu", extents[i].handle,
|
||||||
// (intptr_t) extents[i].memory, extents[i].size);
|
// (intptr_t) extents[i].memory, extents[i].size);
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
extents[i].handle = -1;
|
extents[i].handle = -1;
|
||||||
@@ -501,18 +451,18 @@ mem_release(MEM_HANDLE h)
|
|||||||
|
|
||||||
--h;
|
--h;
|
||||||
if (h < 0 || h >= MAX_EXTENTS)
|
if (h < 0 || h >= MAX_EXTENTS)
|
||||||
fprintf (stderr, "LEAK: attempt to release invalid extent %d\n", h);
|
log_add (log_Debug, "LEAK: attempt to release invalid extent %d", h);
|
||||||
else if (extents[h].handle == -1)
|
else if (extents[h].handle == -1)
|
||||||
fprintf (stderr, "LEAK: attempt to release unallocated extent %d\n",h);
|
log_add (log_Debug, "LEAK: attempt to release unallocated extent %d",h);
|
||||||
else if (extents[h].refcount == 0)
|
else if (extents[h].refcount == 0)
|
||||||
{
|
{
|
||||||
#ifdef LEAK_DEBUG
|
#ifdef LEAK_DEBUG
|
||||||
if (leak_debug)
|
if (leak_debug)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "free %d: %p\n",
|
log_add (log_Debug, "free %d: %p",
|
||||||
extents[h].handle, (void *) extents[h].memory);
|
extents[h].handle, (void *) extents[h].memory);
|
||||||
// Prefered form:
|
// Prefered form:
|
||||||
//fprintf (stderr, "free %d: %#8" PRIxPTR "\n",
|
//log_add (log_Debug, "free %d: %#8" PRIxPTR,
|
||||||
// extents[h].handle, (intptr_t) extents[h].memory);
|
// extents[h].handle, (intptr_t) extents[h].memory);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -635,12 +585,9 @@ HMalloc (int size)
|
|||||||
if (size == 0) return (0);
|
if (size == 0) return (0);
|
||||||
|
|
||||||
if ((p = _alloc_mem(size)) == NULL) {
|
if ((p = _alloc_mem(size)) == NULL) {
|
||||||
fprintf(stderr, "Fatal Error: HMalloc(): out of memory.\n");
|
log_add (log_Always, "Fatal Error: HMalloc(): out of memory.");
|
||||||
#ifdef DEBUG
|
fflush (stderr);
|
||||||
abort();
|
abort ();
|
||||||
#else
|
|
||||||
exit(1);
|
|
||||||
#endif /* #ifdef DEBUG */
|
|
||||||
}
|
}
|
||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "libs/reslib.h"
|
#include "libs/reslib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "alist.h"
|
#include "alist.h"
|
||||||
|
|
||||||
alist_entry *
|
alist_entry *
|
||||||
@@ -161,12 +162,12 @@ Alist_New_FromString (char *d)
|
|||||||
while ((i < len) && (d[i] != '=') &&
|
while ((i < len) && (d[i] != '=') &&
|
||||||
(d[i] != '\n') && (d[i] != '#')) i++;
|
(d[i] != '\n') && (d[i] != '#')) i++;
|
||||||
if (i >= len) { /* Bare key at EOF */
|
if (i >= len) { /* Bare key at EOF */
|
||||||
fprintf (stderr, "Warning: Bare keyword at EOF\n");
|
log_add (log_Warning, "Warning: Bare keyword at EOF");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Comments here mean incomplete line too */
|
/* Comments here mean incomplete line too */
|
||||||
if (d[i] != '=') {
|
if (d[i] != '=') {
|
||||||
fprintf (stderr, "Warning: Key without value\n");
|
log_add (log_Warning, "Warning: Key without value");
|
||||||
while ((i < len) && (d[i] != '\n')) i++;
|
while ((i < len) && (d[i] != '\n')) i++;
|
||||||
if (i >= len) break;
|
if (i >= len) break;
|
||||||
continue; /* Back to keyword search */
|
continue; /* Back to keyword search */
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "port.h"
|
#include "port.h"
|
||||||
#include "resintrn.h"
|
#include "resintrn.h"
|
||||||
#include "libs/misc.h"
|
#include "libs/misc.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
const char *_cur_resfile_name;
|
const char *_cur_resfile_name;
|
||||||
@@ -75,8 +76,8 @@ loadResourceDesc (ResourceIndex *idx, ResourceDesc *desc)
|
|||||||
if (resType >= idx->typeInfo.numTypes ||
|
if (resType >= idx->typeInfo.numTypes ||
|
||||||
idx->typeInfo.handlers[resType].loadFun == NULL)
|
idx->typeInfo.handlers[resType].loadFun == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Warning: Unable to load '%s'; no handler "
|
log_add (log_Warning, "Warning: Unable to load '%s'; no handler "
|
||||||
"for type %d defined.\n", desc->path, resType);
|
"for type %d defined.", desc->path, resType);
|
||||||
return NULL_HANDLE;
|
return NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,19 +96,16 @@ loadResource(const char *path, ResourceLoadFun *loadFun)
|
|||||||
stream = res_OpenResFile (contentDir, path, "rb");
|
stream = res_OpenResFile (contentDir, path, "rb");
|
||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Warning: Can't open '%s'\n", path);
|
log_add (log_Warning, "Warning: Can't open '%s'", path);
|
||||||
return NULL_HANDLE;
|
return NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataLen = LengthResFile (stream);
|
dataLen = LengthResFile (stream);
|
||||||
//#ifdef DEBUG
|
log_add (log_Info, "\t'%s' -- %lu bytes", path, dataLen);
|
||||||
#if 1
|
|
||||||
fprintf (stderr, "\t'%s' -- %lu bytes\n", path, dataLen);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (dataLen == 0)
|
if (dataLen == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Warning: Trying to load empty file '%s'.\n", path);
|
log_add (log_Warning, "Warning: Trying to load empty file '%s'.", path);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +138,7 @@ res_GetResource (RESOURCE res)
|
|||||||
desc = lookupResourceDesc (resourceIndex, res);
|
desc = lookupResourceDesc (resourceIndex, res);
|
||||||
if (desc == NULL)
|
if (desc == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Trying to get undefined resource %08lx\n",
|
log_add (log_Warning, "Trying to get undefined resource %08lx",
|
||||||
(DWORD) res);
|
(DWORD) res);
|
||||||
return NULL_HANDLE;
|
return NULL_HANDLE;
|
||||||
}
|
}
|
||||||
@@ -166,19 +164,15 @@ res_FreeResource (RESOURCE res)
|
|||||||
desc = lookupResourceDesc (_get_current_index_header(), res);
|
desc = lookupResourceDesc (_get_current_index_header(), res);
|
||||||
if (desc == NULL)
|
if (desc == NULL)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "Warning: trying to free an unrecognised "
|
||||||
fprintf (stderr, "Warning: trying to free an unrecognised "
|
"resource.");
|
||||||
"resource.\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc->handle == NULL_HANDLE)
|
if (desc->handle == NULL_HANDLE)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "Warning: trying to free not loaded "
|
||||||
fprintf (stderr, "Warning: trying to free not loaded "
|
"resource.");
|
||||||
"resource.\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,19 +195,15 @@ res_DetachResource (RESOURCE res)
|
|||||||
desc = lookupResourceDesc (_get_current_index_header(), res);
|
desc = lookupResourceDesc (_get_current_index_header(), res);
|
||||||
if (desc == NULL)
|
if (desc == NULL)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "Warning: trying to detach from an unrecognised "
|
||||||
fprintf (stderr, "Warning: trying to detach from an unrecognised "
|
"resource.");
|
||||||
"resource.\n");
|
|
||||||
#endif
|
|
||||||
return NULL_HANDLE;
|
return NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc->handle == NULL_HANDLE)
|
if (desc->handle == NULL_HANDLE)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "Warning: trying to detach from a not loaded "
|
||||||
fprintf (stderr, "Warning: trying to detach from a not loaded "
|
"resource.");
|
||||||
"resource.\n");
|
|
||||||
#endif
|
|
||||||
return NULL_HANDLE;
|
return NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "libs/list.h"
|
#include "libs/list.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@@ -165,7 +166,7 @@ loadResourceIndex (uio_Stream *stream, const char *fileName) {
|
|||||||
if (sscanf (ptr, "%i %i %i %n",
|
if (sscanf (ptr, "%i %i %i %n",
|
||||||
&resPackage, &resInstance, &resType, &numParsed) != 3)
|
&resPackage, &resInstance, &resType, &numParsed) != 3)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Resource index '%s': Invalid line %d.\n",
|
log_add (log_Warning, "Resource index '%s': Invalid line %d.",
|
||||||
fileName, lineNum);
|
fileName, lineNum);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -179,7 +180,7 @@ loadResourceIndex (uio_Stream *stream, const char *fileName) {
|
|||||||
if (*path == '\0')
|
if (*path == '\0')
|
||||||
{
|
{
|
||||||
// No path supplied.
|
// No path supplied.
|
||||||
fprintf (stderr, "Resource index '%s': Invalid line %d.\n",
|
log_add (log_Warning, "Resource index '%s': Invalid line %d.",
|
||||||
fileName, lineNum);
|
fileName, lineNum);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -188,9 +189,9 @@ loadResourceIndex (uio_Stream *stream, const char *fileName) {
|
|||||||
// We need the list to be sorted, as we binary search through it.
|
// We need the list to be sorted, as we binary search through it.
|
||||||
if (res <= lastResource)
|
if (res <= lastResource)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Fatal: resource index '%s' is not sorted "
|
log_add (log_Always, "Fatal: resource index '%s' is not sorted "
|
||||||
"on the resource number, or contains a double entry. "
|
"on the resource number, or contains a double entry. "
|
||||||
"Problem encountered on line %d.\n", fileName, lineNum);
|
"Problem encountered on line %d.", fileName, lineNum);
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
lastResource = res;
|
lastResource = res;
|
||||||
@@ -231,11 +232,9 @@ loadResourceIndex (uio_Stream *stream, const char *fileName) {
|
|||||||
descs = newDescs;
|
descs = newDescs;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (numRes == 0)
|
if (numRes == 0)
|
||||||
fprintf (stderr, "Warning: Resource index '%s' contains no valid "
|
log_add (log_Debug, "Warning: Resource index '%s' contains no valid "
|
||||||
"entries.\n", fileName);
|
"entries.", fileName);
|
||||||
#endif
|
|
||||||
|
|
||||||
indexHandle = allocResourceIndex ();
|
indexHandle = allocResourceIndex ();
|
||||||
if (indexHandle == NULL_HANDLE)
|
if (indexHandle == NULL_HANDLE)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "audiocore.h"
|
#include "audiocore.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
static audio_Driver audiodrv;
|
static audio_Driver audiodrv;
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ initAudio (sint32 driver, sint32 flags)
|
|||||||
#else
|
#else
|
||||||
if (driver == audio_DRIVER_OPENAL)
|
if (driver == audio_DRIVER_OPENAL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "OpenAL driver not compiled in, so using MixSDL\n");
|
log_add (log_Always, "OpenAL driver not compiled in, so using MixSDL");
|
||||||
driver = audio_DRIVER_MIXSDL;
|
driver = audio_DRIVER_MIXSDL;
|
||||||
}
|
}
|
||||||
if (driver == audio_DRIVER_MIXSDL)
|
if (driver == audio_DRIVER_MIXSDL)
|
||||||
@@ -67,10 +68,10 @@ initAudio (sint32 driver, sint32 flags)
|
|||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Sound driver initialization failed.\n"
|
log_add (log_Always, "Sound driver initialization failed.\n"
|
||||||
"This may happen when a soundcard is "
|
"This may happen when a soundcard is "
|
||||||
"not present or not available.\n"
|
"not present or not available.\n"
|
||||||
"NOTICE: Try running UQM with '--sound=none' option\n");
|
"NOTICE: Try running UQM with '--sound=none' option");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "port.h"
|
#include "port.h"
|
||||||
#include "libs/misc.h"
|
#include "libs/misc.h"
|
||||||
#include "libs/file.h"
|
#include "libs/file.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "decoder.h"
|
#include "decoder.h"
|
||||||
#include "wav.h"
|
#include "wav.h"
|
||||||
#include "dukaud.h"
|
#include "dukaud.h"
|
||||||
@@ -177,7 +178,7 @@ SoundDecoder_Init (int flags, TFB_DecoderFormats *formats)
|
|||||||
|
|
||||||
if (!formats)
|
if (!formats)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Init(): missing decoder formats\n");
|
log_add (log_Always, "SoundDecoder_Init(): missing decoder formats");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
decoder_formats = *formats;
|
decoder_formats = *formats;
|
||||||
@@ -187,8 +188,8 @@ SoundDecoder_Init (int flags, TFB_DecoderFormats *formats)
|
|||||||
{
|
{
|
||||||
if (!info->funcs->InitModule (flags, &decoder_formats))
|
if (!info->funcs->InitModule (flags, &decoder_formats))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Init(): "
|
log_add (log_Always, "SoundDecoder_Init(): "
|
||||||
"%s audio decoder init failed\n",
|
"%s audio decoder init failed",
|
||||||
info->funcs->GetName ());
|
info->funcs->GetName ());
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
@@ -227,12 +228,12 @@ SoundDecoder_Register (const char* fileext, TFB_SoundDecoderFuncs* decvtbl)
|
|||||||
|
|
||||||
if (!decvtbl)
|
if (!decvtbl)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Register(): Null decoder table\n");
|
log_add (log_Warning, "SoundDecoder_Register(): Null decoder table");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!fileext)
|
if (!fileext)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Register(): Bad file type for %s\n",
|
log_add (log_Warning, "SoundDecoder_Register(): Bad file type for %s",
|
||||||
decvtbl->GetName ());
|
decvtbl->GetName ());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -249,20 +250,20 @@ SoundDecoder_Register (const char* fileext, TFB_SoundDecoderFuncs* decvtbl)
|
|||||||
|
|
||||||
if (info >= sd_decoders + MAX_REG_DECODERS)
|
if (info >= sd_decoders + MAX_REG_DECODERS)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Register(): Decoders limit reached\n");
|
log_add (log_Warning, "SoundDecoder_Register(): Decoders limit reached");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (info->ext)
|
else if (info->ext)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Register(): "
|
log_add (log_Warning, "SoundDecoder_Register(): "
|
||||||
"'%s' decoder already registered (%s denied)\n",
|
"'%s' decoder already registered (%s denied)",
|
||||||
fileext, decvtbl->GetName ());
|
fileext, decvtbl->GetName ());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!decvtbl->InitModule (sd_flags, &decoder_formats))
|
if (!decvtbl->InitModule (sd_flags, &decoder_formats))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Register(): %s decoder init failed\n",
|
log_add (log_Warning, "SoundDecoder_Register(): %s decoder init failed",
|
||||||
decvtbl->GetName ());
|
decvtbl->GetName ());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -289,8 +290,8 @@ SoundDecoder_Unregister (TFB_RegSoundDecoder* regdec)
|
|||||||
if (regdec < sd_decoders || regdec >= sd_decoders + MAX_REG_DECODERS ||
|
if (regdec < sd_decoders || regdec >= sd_decoders + MAX_REG_DECODERS ||
|
||||||
!regdec->ext || !regdec->funcs)
|
!regdec->ext || !regdec->funcs)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Unregister(): "
|
log_add (log_Warning, "SoundDecoder_Unregister(): "
|
||||||
"Invalid or expired decoder passed\n");
|
"Invalid or expired decoder passed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +325,7 @@ SoundDecoder_Load (uio_DirHandle *dir, char *filename,
|
|||||||
pext = strrchr (filename, '.');
|
pext = strrchr (filename, '.');
|
||||||
if (!pext)
|
if (!pext)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Load(): Unknown file type (%s)\n",
|
log_add (log_Warning, "SoundDecoder_Load(): Unknown file type (%s)",
|
||||||
filename);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -336,7 +337,7 @@ SoundDecoder_Load (uio_DirHandle *dir, char *filename,
|
|||||||
;
|
;
|
||||||
if (!info->ext)
|
if (!info->ext)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Load(): Unsupported file type (%s)\n",
|
log_add (log_Warning, "SoundDecoder_Load(): Unsupported file type (%s)",
|
||||||
filename);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -352,7 +353,7 @@ SoundDecoder_Load (uio_DirHandle *dir, char *filename,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Load(): %s does not exist\n",
|
log_add (log_Warning, "SoundDecoder_Load(): %s does not exist",
|
||||||
filename);
|
filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -366,8 +367,8 @@ SoundDecoder_Load (uio_DirHandle *dir, char *filename,
|
|||||||
decoder->funcs = funcs;
|
decoder->funcs = funcs;
|
||||||
if (!decoder->funcs->Init (decoder))
|
if (!decoder->funcs->Init (decoder))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Load(): "
|
log_add (log_Warning, "SoundDecoder_Load(): "
|
||||||
"%s decoder instance failed init\n",
|
"%s decoder instance failed init",
|
||||||
decoder->funcs->GetName ());
|
decoder->funcs->GetName ());
|
||||||
HFree (decoder);
|
HFree (decoder);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -375,8 +376,8 @@ SoundDecoder_Load (uio_DirHandle *dir, char *filename,
|
|||||||
|
|
||||||
if (!decoder->funcs->Open (decoder, dir, filename))
|
if (!decoder->funcs->Open (decoder, dir, filename))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Load(): "
|
log_add (log_Warning, "SoundDecoder_Load(): "
|
||||||
"%s decoder could not load %s\n",
|
"%s decoder could not load %s",
|
||||||
decoder->funcs->GetName (), filename);
|
decoder->funcs->GetName (), filename);
|
||||||
decoder->funcs->Term (decoder);
|
decoder->funcs->Term (decoder);
|
||||||
HFree (decoder);
|
HFree (decoder);
|
||||||
@@ -431,7 +432,7 @@ SoundDecoder_Decode (TFB_SoundDecoder *decoder)
|
|||||||
|
|
||||||
if (!decoder || !decoder->funcs)
|
if (!decoder || !decoder->funcs)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Decode(): null or bad decoder\n");
|
log_add (log_Warning, "SoundDecoder_Decode(): null or bad decoder");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,8 +457,8 @@ SoundDecoder_Decode (TFB_SoundDecoder *decoder)
|
|||||||
buffer_size - decoded_bytes);
|
buffer_size - decoded_bytes);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Decode(): "
|
log_add (log_Warning, "SoundDecoder_Decode(): "
|
||||||
"error decoding %s, code %ld\n",
|
"error decoding %s, code %ld",
|
||||||
decoder->filename, rc);
|
decoder->filename, rc);
|
||||||
}
|
}
|
||||||
else if (rc == 0)
|
else if (rc == 0)
|
||||||
@@ -467,21 +468,21 @@ SoundDecoder_Decode (TFB_SoundDecoder *decoder)
|
|||||||
SoundDecoder_Rewind (decoder);
|
SoundDecoder_Rewind (decoder);
|
||||||
if (decoder->error)
|
if (decoder->error)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Decode(): "
|
log_add (log_Warning, "SoundDecoder_Decode(): "
|
||||||
"tried to loop %s but couldn't rewind, "
|
"tried to loop %s but couldn't rewind, "
|
||||||
"error code %d\n",
|
"error code %d",
|
||||||
decoder->filename, decoder->error);
|
decoder->filename, decoder->error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Decode(): "
|
log_add (log_Info, "SoundDecoder_Decode(): "
|
||||||
"looping %s\n", decoder->filename);
|
"looping %s", decoder->filename);
|
||||||
rc = 1; // prime the loop again
|
rc = 1; // prime the loop again
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Decode(): eof for %s\n",
|
log_add (log_Info, "SoundDecoder_Decode(): eof for %s",
|
||||||
decoder->filename);
|
decoder->filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -518,7 +519,7 @@ SoundDecoder_DecodeAll (TFB_SoundDecoder *decoder)
|
|||||||
|
|
||||||
if (!decoder || !decoder->funcs)
|
if (!decoder || !decoder->funcs)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_DecodeAll(): null or bad decoder\n");
|
log_add (log_Warning, "SoundDecoder_DecodeAll(): null or bad decoder");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,19 +527,17 @@ SoundDecoder_DecodeAll (TFB_SoundDecoder *decoder)
|
|||||||
|
|
||||||
if (decoder->looping)
|
if (decoder->looping)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_DecodeAll(): "
|
log_add (log_Warning, "SoundDecoder_DecodeAll(): "
|
||||||
"called for %s with looping\n", decoder->filename);
|
"called for %s with looping", decoder->filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reqbufsize < 4096)
|
if (reqbufsize < 4096)
|
||||||
reqbufsize = 4096;
|
reqbufsize = 4096;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (reqbufsize < 16384)
|
if (reqbufsize < 16384)
|
||||||
fprintf (stderr, "SoundDecoder_DecodeAll(): WARNING, "
|
log_add (log_Debug, "SoundDecoder_DecodeAll(): WARNING, "
|
||||||
"called with a small buffer (%u)\n", reqbufsize);
|
"called with a small buffer (%u)", reqbufsize);
|
||||||
#endif
|
|
||||||
|
|
||||||
for (decoded_bytes = 0, rc = 1; rc > 0; )
|
for (decoded_bytes = 0, rc = 1; rc > 0; )
|
||||||
{
|
{
|
||||||
@@ -570,8 +569,8 @@ SoundDecoder_DecodeAll (TFB_SoundDecoder *decoder)
|
|||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
decoder->error = SOUNDDECODER_ERROR;
|
decoder->error = SOUNDDECODER_ERROR;
|
||||||
fprintf (stderr, "SoundDecoder_DecodeAll(): "
|
log_add (log_Warning, "SoundDecoder_DecodeAll(): "
|
||||||
"error decoding %s, code %ld\n",
|
"error decoding %s, code %ld",
|
||||||
decoder->filename, rc);
|
decoder->filename, rc);
|
||||||
return decoded_bytes;
|
return decoded_bytes;
|
||||||
}
|
}
|
||||||
@@ -605,7 +604,7 @@ SoundDecoder_Seek (TFB_SoundDecoder *decoder, uint32 seekTime)
|
|||||||
return;
|
return;
|
||||||
if (!decoder->funcs)
|
if (!decoder->funcs)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Seek(): bad decoder passed\n");
|
log_add (log_Warning, "SoundDecoder_Seek(): bad decoder passed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,7 +622,7 @@ SoundDecoder_Free (TFB_SoundDecoder *decoder)
|
|||||||
return;
|
return;
|
||||||
if (!decoder->funcs)
|
if (!decoder->funcs)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Free(): bad decoder passed\n");
|
log_add (log_Warning, "SoundDecoder_Free(): bad decoder passed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,7 +641,7 @@ SoundDecoder_GetTime (TFB_SoundDecoder *decoder)
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
if (!decoder->funcs)
|
if (!decoder->funcs)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_GetTime(): bad decoder passed\n");
|
log_add (log_Warning, "SoundDecoder_GetTime(): bad decoder passed");
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,7 +658,7 @@ SoundDecoder_GetFrame (TFB_SoundDecoder *decoder)
|
|||||||
return 0;
|
return 0;
|
||||||
if (!decoder->funcs)
|
if (!decoder->funcs)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_GetFrame(): bad decoder passed\n");
|
log_add (log_Warning, "SoundDecoder_GetFrame(): bad decoder passed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -679,7 +678,7 @@ static bool
|
|||||||
bufa_InitModule (int flags, const TFB_DecoderFormats* fmts)
|
bufa_InitModule (int flags, const TFB_DecoderFormats* fmts)
|
||||||
{
|
{
|
||||||
// this should never be called
|
// this should never be called
|
||||||
fprintf (stderr, "bufa_InitModule(): dead function called\n");
|
log_add (log_Debug, "bufa_InitModule(): dead function called");
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
(void)flags; (void)fmts; // laugh at compiler warning
|
(void)flags; (void)fmts; // laugh at compiler warning
|
||||||
@@ -689,7 +688,7 @@ static void
|
|||||||
bufa_TermModule (void)
|
bufa_TermModule (void)
|
||||||
{
|
{
|
||||||
// this should never be called
|
// this should never be called
|
||||||
fprintf (stderr, "bufa_TermModule(): dead function called\n");
|
log_add (log_Debug, "bufa_TermModule(): dead function called");
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32
|
static uint32
|
||||||
@@ -731,7 +730,7 @@ static bool
|
|||||||
bufa_Open (THIS_PTR, uio_DirHandle *dir, const char *filename)
|
bufa_Open (THIS_PTR, uio_DirHandle *dir, const char *filename)
|
||||||
{
|
{
|
||||||
// this should never be called
|
// this should never be called
|
||||||
fprintf (stderr, "bufa_Open(): dead function called\n");
|
log_add (log_Debug, "bufa_Open(): dead function called");
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// laugh at compiler warnings
|
// laugh at compiler warnings
|
||||||
@@ -807,7 +806,7 @@ static bool
|
|||||||
nula_InitModule (int flags, const TFB_DecoderFormats* fmts)
|
nula_InitModule (int flags, const TFB_DecoderFormats* fmts)
|
||||||
{
|
{
|
||||||
// this should never be called
|
// this should never be called
|
||||||
fprintf (stderr, "nula_InitModule(): dead function called\n");
|
log_add (log_Debug, "nula_InitModule(): dead function called");
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
(void)flags; (void)fmts; // laugh at compiler warning
|
(void)flags; (void)fmts; // laugh at compiler warning
|
||||||
@@ -817,7 +816,7 @@ static void
|
|||||||
nula_TermModule (void)
|
nula_TermModule (void)
|
||||||
{
|
{
|
||||||
// this should never be called
|
// this should never be called
|
||||||
fprintf (stderr, "nula_TermModule(): dead function called\n");
|
log_add (log_Debug, "nula_TermModule(): dead function called");
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32
|
static uint32
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "mikmod/mikmod.h"
|
#include "mikmod/mikmod.h"
|
||||||
#include "mikmod/drv_openal.h"
|
#include "mikmod/drv_openal.h"
|
||||||
#include "libs/sound/audiocore.h"
|
#include "libs/sound/audiocore.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "modaud.h"
|
#include "modaud.h"
|
||||||
|
|
||||||
#define THIS_PTR TFB_SoundDecoder* This
|
#define THIS_PTR TFB_SoundDecoder* This
|
||||||
@@ -174,7 +175,7 @@ moda_InitModule (int flags, const TFB_DecoderFormats* fmts)
|
|||||||
|
|
||||||
if (MikMod_Init (""))
|
if (MikMod_Init (""))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "MikMod_Init() failed, %s\n",
|
log_add (log_Always, "MikMod_Init() failed, %s",
|
||||||
MikMod_strerror (MikMod_errno));
|
MikMod_strerror (MikMod_errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -251,7 +252,7 @@ moda_Open (THIS_PTR, uio_DirHandle *dir, const char *filename)
|
|||||||
uio_fclose (fp);
|
uio_fclose (fp);
|
||||||
if (!mod)
|
if (!mod)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "moda_Open(): could not load %s\n", filename);
|
log_add (log_Warning, "moda_Open(): could not load %s", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,8 +306,8 @@ moda_Seek (THIS_PTR, uint32 pcm_pos)
|
|||||||
|
|
||||||
Player_Start (moda->module);
|
Player_Start (moda->module);
|
||||||
if (pcm_pos)
|
if (pcm_pos)
|
||||||
fprintf (stderr, "moda_Seek(): "
|
log_add (log_Debug, "moda_Seek(): "
|
||||||
"non-zero seek positions not supported for mod\n");
|
"non-zero seek positions not supported for mod");
|
||||||
Player_SetPosition (0);
|
Player_SetPosition (0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "libs/misc.h"
|
#include "libs/misc.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "uio.h"
|
#include "uio.h"
|
||||||
@@ -174,15 +175,15 @@ ova_Open (THIS_PTR, uio_DirHandle *dir, const char *filename)
|
|||||||
fp = uio_fopen (dir, filename, "rb");
|
fp = uio_fopen (dir, filename, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ova_Open(): could not open %s\n", filename);
|
log_add (log_Warning, "ova_Open(): could not open %s", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ov_open_callbacks (fp, &ova->vf, NULL, 0, ogg_callbacks);
|
rc = ov_open_callbacks (fp, &ova->vf, NULL, 0, ogg_callbacks);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ova_Open(): "
|
log_add (log_Warning, "ova_Open(): "
|
||||||
"ov_open_callbacks failed for %s, error code %d\n",
|
"ov_open_callbacks failed for %s, error code %d",
|
||||||
filename, rc);
|
filename, rc);
|
||||||
uio_fclose (fp);
|
uio_fclose (fp);
|
||||||
return false;
|
return false;
|
||||||
@@ -191,8 +192,8 @@ ova_Open (THIS_PTR, uio_DirHandle *dir, const char *filename)
|
|||||||
vinfo = ov_info (&ova->vf, -1);
|
vinfo = ov_info (&ova->vf, -1);
|
||||||
if (!vinfo)
|
if (!vinfo)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ova_Open(): "
|
log_add (log_Warning, "ova_Open(): "
|
||||||
"failed to retrieve ogg bitstream info for %s\n",
|
"failed to retrieve ogg bitstream info for %s",
|
||||||
filename);
|
filename);
|
||||||
ov_clear (&ova->vf);
|
ov_clear (&ova->vf);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "uio.h"
|
#include "uio.h"
|
||||||
#include "endian_uqm.h"
|
#include "endian_uqm.h"
|
||||||
#include "libs/misc.h"
|
#include "libs/misc.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "wav.h"
|
#include "wav.h"
|
||||||
|
|
||||||
#define RIFF 0x46464952 /* "RIFF" */
|
#define RIFF 0x46464952 /* "RIFF" */
|
||||||
@@ -234,8 +235,8 @@ wava_Open (THIS_PTR, uio_DirHandle *dir, const char *filename)
|
|||||||
}
|
}
|
||||||
if (FileHdr.Id != RIFF || FileHdr.Type != WAVE)
|
if (FileHdr.Id != RIFF || FileHdr.Type != WAVE)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "wava_Open(): "
|
log_add (log_Warning, "wava_Open(): "
|
||||||
"not a wave file, ID 0x%08x, Type 0x%08x\n",
|
"not a wave file, ID 0x%08x, Type 0x%08x",
|
||||||
FileHdr.Id, FileHdr.Type);
|
FileHdr.Id, FileHdr.Type);
|
||||||
wava_Close (This);
|
wava_Close (This);
|
||||||
return false;
|
return false;
|
||||||
@@ -276,7 +277,8 @@ wava_Open (THIS_PTR, uio_DirHandle *dir, const char *filename)
|
|||||||
|
|
||||||
if (!wava->data_size || !wava->data_ofs)
|
if (!wava->data_size || !wava->data_ofs)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "wava_Open(): bad wave file, no DATA chunk found\n");
|
log_add (log_Warning, "wava_Open(): bad wave file,"
|
||||||
|
" no DATA chunk found");
|
||||||
wava_Close (This);
|
wava_Close (This);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -294,7 +296,8 @@ wava_Open (THIS_PTR, uio_DirHandle *dir, const char *filename)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "wava_Open(): unsupported format %x\n", wava->FmtHdr.Format);
|
log_add (log_Warning, "wava_Open(): unsupported format %x",
|
||||||
|
wava->FmtHdr.Format);
|
||||||
wava_Close (This);
|
wava_Close (This);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "mixerint.h"
|
#include "mixerint.h"
|
||||||
#include "libs/misc.h"
|
#include "libs/misc.h"
|
||||||
#include "libs/threadlib.h"
|
#include "libs/threadlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
static uint32 mixer_initialized = 0;
|
static uint32 mixer_initialized = 0;
|
||||||
static uint32 mixer_format;
|
static uint32 mixer_format;
|
||||||
@@ -249,9 +250,7 @@ mixer_GenSources (uint32 n, mixer_Object *psrcobj)
|
|||||||
if (!psrcobj)
|
if (!psrcobj)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_GenSources() called with null ptr");
|
||||||
fprintf (stderr, "mixer_GenSources() called with null ptr\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (; n; n--, psrcobj++)
|
for (; n; n--, psrcobj++)
|
||||||
@@ -290,9 +289,7 @@ mixer_DeleteSources (uint32 n, mixer_Object *psrcobj)
|
|||||||
if (!psrcobj)
|
if (!psrcobj)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_DeleteSources() called with null ptr");
|
||||||
fprintf (stderr, "mixer_DeleteSources() called with null ptr\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,9 +310,7 @@ mixer_DeleteSources (uint32 n, mixer_Object *psrcobj)
|
|||||||
if (i)
|
if (i)
|
||||||
{ /* some source failed */
|
{ /* some source failed */
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_DeleteSources(): not a source");
|
||||||
fprintf (stderr, "mixer_DeleteSources(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* all sources checked out */
|
{ /* all sources checked out */
|
||||||
@@ -371,9 +366,7 @@ mixer_Sourcei (mixer_Object srcobj, mixer_SourceProp pname,
|
|||||||
if (!src)
|
if (!src)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_Sourcei() called with null source");
|
||||||
fprintf (stderr, "mixer_Sourcei() called with null source\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,9 +375,7 @@ mixer_Sourcei (mixer_Object srcobj, mixer_SourceProp pname,
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_Sourcei(): not a source");
|
||||||
fprintf (stderr, "mixer_Sourcei(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -419,14 +410,14 @@ mixer_Sourcei (mixer_Object srcobj, mixer_SourceProp pname,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "mixer_Sourcei(MIX_SOURCE_STATE): "
|
log_add (log_Debug, "mixer_Sourcei(MIX_SOURCE_STATE): "
|
||||||
"unsupported state, call ignored\n");
|
"unsupported state, call ignored");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mixer_SetError (MIX_INVALID_ENUM);
|
mixer_SetError (MIX_INVALID_ENUM);
|
||||||
fprintf (stderr, "mixer_Sourcei() called "
|
log_add (log_Debug, "mixer_Sourcei() called "
|
||||||
"with unsupported property %u\n", pname);
|
"with unsupported property %u", pname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,9 +433,7 @@ mixer_Sourcef (mixer_Object srcobj, mixer_SourceProp pname, float value)
|
|||||||
if (!src)
|
if (!src)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_Sourcef() called with null source");
|
||||||
fprintf (stderr, "mixer_Sourcef() called with null source\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,9 +442,7 @@ mixer_Sourcef (mixer_Object srcobj, mixer_SourceProp pname, float value)
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_Sourcef(): not a source");
|
||||||
fprintf (stderr, "mixer_Sourcef(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -465,8 +452,8 @@ mixer_Sourcef (mixer_Object srcobj, mixer_SourceProp pname, float value)
|
|||||||
src->gain = value * MIX_GAIN_ADJ;
|
src->gain = value * MIX_GAIN_ADJ;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "mixer_Sourcei() called "
|
log_add (log_Debug, "mixer_Sourcei() called "
|
||||||
"with unsupported property %u\n", pname);
|
"with unsupported property %u", pname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,9 +479,7 @@ mixer_GetSourcei (mixer_Object srcobj, mixer_SourceProp pname,
|
|||||||
if (!src || !value)
|
if (!src || !value)
|
||||||
{
|
{
|
||||||
mixer_SetError (src ? MIX_INVALID_VALUE : MIX_INVALID_NAME);
|
mixer_SetError (src ? MIX_INVALID_VALUE : MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_GetSourcei() called with null param");
|
||||||
fprintf (stderr, "mixer_GetSourcei() called with null param\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,9 +488,7 @@ mixer_GetSourcei (mixer_Object srcobj, mixer_SourceProp pname,
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_GetSourcei(): not a source");
|
||||||
fprintf (stderr, "mixer_GetSourcei(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -528,8 +511,8 @@ mixer_GetSourcei (mixer_Object srcobj, mixer_SourceProp pname,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mixer_SetError (MIX_INVALID_ENUM);
|
mixer_SetError (MIX_INVALID_ENUM);
|
||||||
fprintf (stderr, "mixer_GetSourcei() called "
|
log_add (log_Debug, "mixer_GetSourcei() called "
|
||||||
"with unsupported property %u\n", pname);
|
"with unsupported property %u", pname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,9 +529,7 @@ mixer_GetSourcef (mixer_Object srcobj, mixer_SourceProp pname,
|
|||||||
if (!src || !value)
|
if (!src || !value)
|
||||||
{
|
{
|
||||||
mixer_SetError (src ? MIX_INVALID_VALUE : MIX_INVALID_NAME);
|
mixer_SetError (src ? MIX_INVALID_VALUE : MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_GetSourcef() called with null param");
|
||||||
fprintf (stderr, "mixer_GetSourcef() called with null param\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,9 +538,7 @@ mixer_GetSourcef (mixer_Object srcobj, mixer_SourceProp pname,
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_GetSourcef(): not a source");
|
||||||
fprintf (stderr, "mixer_GetSourcef(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -569,8 +548,8 @@ mixer_GetSourcef (mixer_Object srcobj, mixer_SourceProp pname,
|
|||||||
*value = src->gain / MIX_GAIN_ADJ;
|
*value = src->gain / MIX_GAIN_ADJ;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "mixer_GetSourcef() called "
|
log_add (log_Debug, "mixer_GetSourcef() called "
|
||||||
"with unsupported property %u\n", pname);
|
"with unsupported property %u", pname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,9 +565,7 @@ mixer_SourcePlay (mixer_Object srcobj)
|
|||||||
if (!src)
|
if (!src)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourcePlay() called with null source");
|
||||||
fprintf (stderr, "mixer_SourcePlay() called with null source\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,9 +574,7 @@ mixer_SourcePlay (mixer_Object srcobj)
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourcePlay(): not a source");
|
||||||
fprintf (stderr, "mixer_SourcePlay(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else /* should make the source active */
|
else /* should make the source active */
|
||||||
{
|
{
|
||||||
@@ -624,9 +599,7 @@ mixer_SourceRewind (mixer_Object srcobj)
|
|||||||
if (!src)
|
if (!src)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourceRewind() called with null source");
|
||||||
fprintf (stderr, "mixer_SourceRewind() called with null source\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,9 +608,7 @@ mixer_SourceRewind (mixer_Object srcobj)
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourcePlay(): not a source");
|
||||||
fprintf (stderr, "mixer_SourcePlay(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -656,9 +627,7 @@ mixer_SourcePause (mixer_Object srcobj)
|
|||||||
if (!src)
|
if (!src)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourcePause() called with null source");
|
||||||
fprintf (stderr, "mixer_SourcePause() called with null source\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,9 +636,7 @@ mixer_SourcePause (mixer_Object srcobj)
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourcePause(): not a source");
|
||||||
fprintf (stderr, "mixer_SourcePause(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else /* should keep all buffers and offsets */
|
else /* should keep all buffers and offsets */
|
||||||
{
|
{
|
||||||
@@ -692,9 +659,7 @@ mixer_SourceStop (mixer_Object srcobj)
|
|||||||
if (!src)
|
if (!src)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourceStop() called with null source");
|
||||||
fprintf (stderr, "mixer_SourceStop() called with null source\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,9 +668,7 @@ mixer_SourceStop (mixer_Object srcobj)
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourceStop(): not a source");
|
||||||
fprintf (stderr, "mixer_SourceStop(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else /* should remove queued buffers */
|
else /* should remove queued buffers */
|
||||||
{
|
{
|
||||||
@@ -730,10 +693,8 @@ mixer_SourceQueueBuffers (mixer_Object srcobj, uint32 n,
|
|||||||
if (!src || !pbufobj)
|
if (!src || !pbufobj)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourceQueueBuffers() called "
|
||||||
fprintf (stderr, "mixer_SourceQueueBuffers() called "
|
"with null param");
|
||||||
"with null param\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -758,9 +719,7 @@ mixer_SourceQueueBuffers (mixer_Object srcobj, uint32 n,
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourceQueueBuffers(): not a source");
|
||||||
fprintf (stderr, "mixer_SourceQueueBuffers(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -801,10 +760,8 @@ mixer_SourceUnqueueBuffers (mixer_Object srcobj, uint32 n,
|
|||||||
if (!src || !pbufobj)
|
if (!src || !pbufobj)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourceUnqueueBuffers() called "
|
||||||
fprintf (stderr, "mixer_SourceUnqueueBuffers() called "
|
"with null source");
|
||||||
"with null source\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,9 +770,7 @@ mixer_SourceUnqueueBuffers (mixer_Object srcobj, uint32 n,
|
|||||||
if (src->magic != mixer_srcMagic)
|
if (src->magic != mixer_srcMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourceUnqueueBuffers(): not a source");
|
||||||
fprintf (stderr, "mixer_SourceUnqueueBuffers(): not a source\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (n > src->cqueued)
|
else if (n > src->cqueued)
|
||||||
{
|
{
|
||||||
@@ -834,10 +789,8 @@ mixer_SourceUnqueueBuffers (mixer_Object srcobj, uint32 n,
|
|||||||
if (i)
|
if (i)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_OPERATION);
|
mixer_SetError (MIX_INVALID_OPERATION);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourceUnqueueBuffers(): "
|
||||||
fprintf (stderr, "mixer_SourceUnqueueBuffers(): "
|
"active buffer attempted");
|
||||||
"active buffer attempted\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* all buffers checked out */
|
{ /* all buffers checked out */
|
||||||
@@ -882,10 +835,8 @@ mixer_SourceUnqueueAll (mixer_Source *src)
|
|||||||
|
|
||||||
if (!src)
|
if (!src)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_SourceUnqueueAll() called "
|
||||||
fprintf (stderr, "mixer_SourceUnqueueAll() called "
|
"with null source");
|
||||||
"with null source\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -893,13 +844,11 @@ mixer_SourceUnqueueAll (mixer_Source *src)
|
|||||||
|
|
||||||
for (buf = src->firstqueued; buf; buf = nextbuf)
|
for (buf = src->firstqueued; buf; buf = nextbuf)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
|
||||||
if (buf->state == MIX_BUF_PLAYING)
|
if (buf->state == MIX_BUF_PLAYING)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "mixer_SourceUnqueueAll(): "
|
log_add (log_Debug, "mixer_SourceUnqueueAll(): "
|
||||||
"attempted on active buffer\n");
|
"attempted on active buffer");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
nextbuf = buf->next;
|
nextbuf = buf->next;
|
||||||
buf->state = MIX_BUF_FILLED;
|
buf->state = MIX_BUF_FILLED;
|
||||||
buf->next = 0;
|
buf->next = 0;
|
||||||
@@ -925,18 +874,16 @@ mixer_SourceActivate (mixer_Source* src)
|
|||||||
|
|
||||||
LockRecursiveMutex (act_mutex);
|
LockRecursiveMutex (act_mutex);
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
/* check active sources, see if this source is there already */
|
/* check active sources, see if this source is there already */
|
||||||
for (i = 0; i < MAX_SOURCES && active_sources[i] != src; i++)
|
for (i = 0; i < MAX_SOURCES && active_sources[i] != src; i++)
|
||||||
;
|
;
|
||||||
if (i < MAX_SOURCES)
|
if (i < MAX_SOURCES)
|
||||||
{ /* source found */
|
{ /* source found */
|
||||||
fprintf (stderr, "mixer_SourceActivate(): "
|
log_add (log_Debug, "mixer_SourceActivate(): "
|
||||||
"source already active in slot %u\n", i);
|
"source already active in slot %u", i);
|
||||||
UnlockRecursiveMutex (act_mutex);
|
UnlockRecursiveMutex (act_mutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* find an empty slot */
|
/* find an empty slot */
|
||||||
for (i = 0; i < MAX_SOURCES && active_sources[i] != 0; i++)
|
for (i = 0; i < MAX_SOURCES && active_sources[i] != 0; i++)
|
||||||
@@ -945,13 +892,11 @@ mixer_SourceActivate (mixer_Source* src)
|
|||||||
{ /* slot found */
|
{ /* slot found */
|
||||||
active_sources[i] = src;
|
active_sources[i] = src;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "mixer_SourceActivate(): "
|
log_add (log_Debug, "mixer_SourceActivate(): "
|
||||||
"no more slots available (max=%d)\n", MAX_SOURCES);
|
"no more slots available (max=%d)", MAX_SOURCES);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
UnlockRecursiveMutex (act_mutex);
|
UnlockRecursiveMutex (act_mutex);
|
||||||
}
|
}
|
||||||
@@ -971,12 +916,10 @@ mixer_SourceDeactivate (mixer_Source* src)
|
|||||||
{ /* source found */
|
{ /* source found */
|
||||||
active_sources[i] = 0;
|
active_sources[i] = 0;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
else
|
else
|
||||||
{ /* source not found */
|
{ /* source not found */
|
||||||
fprintf (stderr, "mixer_SourceDeactivate(): source not active\n");
|
log_add (log_Debug, "mixer_SourceDeactivate(): source not active");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
UnlockRecursiveMutex (act_mutex);
|
UnlockRecursiveMutex (act_mutex);
|
||||||
}
|
}
|
||||||
@@ -990,15 +933,15 @@ mixer_SourceStop_internal (mixer_Source *src)
|
|||||||
if (!src->firstqueued)
|
if (!src->firstqueued)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
/* assert the source buffers state */
|
/* assert the source buffers state */
|
||||||
if (!src->lastqueued)
|
if (!src->lastqueued)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "mixer_SourceStop_internal(): "
|
log_add (log_Debug, "mixer_SourceStop_internal(): "
|
||||||
"desynced source state\n");
|
"desynced source state");
|
||||||
return;
|
#ifdef DEBUG
|
||||||
}
|
abort ();
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
LockRecursiveMutex (buf_mutex);
|
LockRecursiveMutex (buf_mutex);
|
||||||
|
|
||||||
@@ -1211,9 +1154,7 @@ mixer_GenBuffers (uint32 n, mixer_Object *pbufobj)
|
|||||||
if (!pbufobj)
|
if (!pbufobj)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_VALUE);
|
mixer_SetError (MIX_INVALID_VALUE);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_GenBuffers() called with null ptr");
|
||||||
fprintf (stderr, "mixer_GenBuffers() called with null ptr\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (; n; n--, pbufobj++)
|
for (; n; n--, pbufobj++)
|
||||||
@@ -1250,9 +1191,7 @@ mixer_DeleteBuffers (uint32 n, mixer_Object *pbufobj)
|
|||||||
if (!pbufobj)
|
if (!pbufobj)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_DeleteBuffers() called with null ptr");
|
||||||
fprintf (stderr, "mixer_DeleteBuffers() called with null ptr\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1269,26 +1208,20 @@ mixer_DeleteBuffers (uint32 n, mixer_Object *pbufobj)
|
|||||||
if (buf->magic != mixer_bufMagic)
|
if (buf->magic != mixer_bufMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_DeleteBuffers(): not a buffer");
|
||||||
fprintf (stderr, "mixer_DeleteBuffers(): not a buffer\n");
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (buf->locked)
|
else if (buf->locked)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_OPERATION);
|
mixer_SetError (MIX_INVALID_OPERATION);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_DeleteBuffers(): locked buffer");
|
||||||
fprintf (stderr, "mixer_DeleteBuffers(): locked buffer\n");
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (buf->state >= MIX_BUF_QUEUED)
|
else if (buf->state >= MIX_BUF_QUEUED)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_OPERATION);
|
mixer_SetError (MIX_INVALID_OPERATION);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_DeleteBuffers(): "
|
||||||
fprintf (stderr, "mixer_DeleteBuffers(): "
|
"attempted on queued/active buffer");
|
||||||
"attempted on queued/active buffer\n");
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1340,9 +1273,7 @@ mixer_GetBufferi (mixer_Object bufobj, mixer_BufferProp pname,
|
|||||||
if (!buf || !value)
|
if (!buf || !value)
|
||||||
{
|
{
|
||||||
mixer_SetError (buf ? MIX_INVALID_VALUE : MIX_INVALID_NAME);
|
mixer_SetError (buf ? MIX_INVALID_VALUE : MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_GetBufferi() called with null param");
|
||||||
fprintf (stderr, "mixer_GetBufferi() called with null param\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1352,18 +1283,14 @@ mixer_GetBufferi (mixer_Object bufobj, mixer_BufferProp pname,
|
|||||||
{
|
{
|
||||||
UnlockRecursiveMutex (buf_mutex);
|
UnlockRecursiveMutex (buf_mutex);
|
||||||
mixer_SetError (MIX_INVALID_OPERATION);
|
mixer_SetError (MIX_INVALID_OPERATION);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_GetBufferi() called with locked buffer");
|
||||||
fprintf (stderr, "mixer_GetBufferi() called with locked buffer\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf->magic != mixer_bufMagic)
|
if (buf->magic != mixer_bufMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_GetBufferi(): not a buffer");
|
||||||
fprintf (stderr, "mixer_GetBufferi(): not a buffer\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1388,8 +1315,8 @@ mixer_GetBufferi (mixer_Object bufobj, mixer_BufferProp pname,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mixer_SetError (MIX_INVALID_ENUM);
|
mixer_SetError (MIX_INVALID_ENUM);
|
||||||
fprintf (stderr, "mixer_GetBufferi() called "
|
log_add (log_Debug, "mixer_GetBufferi() called "
|
||||||
"with invalid property %u\n", pname);
|
"with invalid property %u", pname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1408,9 +1335,7 @@ mixer_BufferData (mixer_Object bufobj, uint32 format, void* data,
|
|||||||
if (!buf || !data || !size)
|
if (!buf || !data || !size)
|
||||||
{
|
{
|
||||||
mixer_SetError (buf ? MIX_INVALID_VALUE : MIX_INVALID_NAME);
|
mixer_SetError (buf ? MIX_INVALID_VALUE : MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_BufferData() called with bad param");
|
||||||
// fprintf (stderr, "mixer_BufferData() called with bad param\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1420,27 +1345,21 @@ mixer_BufferData (mixer_Object bufobj, uint32 format, void* data,
|
|||||||
{
|
{
|
||||||
UnlockRecursiveMutex (buf_mutex);
|
UnlockRecursiveMutex (buf_mutex);
|
||||||
mixer_SetError (MIX_INVALID_OPERATION);
|
mixer_SetError (MIX_INVALID_OPERATION);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_BufferData() called "
|
||||||
fprintf (stderr, "mixer_BufferData() called "
|
"with locked buffer");
|
||||||
"with locked buffer\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf->magic != mixer_bufMagic)
|
if (buf->magic != mixer_bufMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_BufferData(): not a buffer");
|
||||||
fprintf (stderr, "mixer_BufferData(): not a buffer\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (buf->state > MIX_BUF_FILLED)
|
else if (buf->state > MIX_BUF_FILLED)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_OPERATION);
|
mixer_SetError (MIX_INVALID_OPERATION);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "mixer_BufferData() attempted "
|
||||||
fprintf (stderr, "mixer_BufferData() attempted "
|
"on in-use buffer");
|
||||||
"on in-use buffer\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1551,27 +1470,21 @@ mixer_CheckBufferState (mixer_Buffer *buf, const char* FuncName)
|
|||||||
if (buf->magic != mixer_bufMagic)
|
if (buf->magic != mixer_bufMagic)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_NAME);
|
mixer_SetError (MIX_INVALID_NAME);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "%s(): not a buffer", FuncName);
|
||||||
fprintf (stderr, "%s(): not a buffer\n", FuncName);
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf->locked)
|
if (buf->locked)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_OPERATION);
|
mixer_SetError (MIX_INVALID_OPERATION);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "%s(): locked buffer attempted", FuncName);
|
||||||
fprintf (stderr, "%s(): locked buffer attempted\n", FuncName);
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf->state != MIX_BUF_FILLED)
|
if (buf->state != MIX_BUF_FILLED)
|
||||||
{
|
{
|
||||||
mixer_SetError (MIX_INVALID_OPERATION);
|
mixer_SetError (MIX_INVALID_OPERATION);
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "%s: invalid buffer attempted", FuncName);
|
||||||
fprintf (stderr, "%s: invalid buffer attempted\n", FuncName);
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "audiodrv_nosound.h"
|
#include "audiodrv_nosound.h"
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -109,26 +110,26 @@ noSound_Init (audio_Driver *driver, sint32 flags)
|
|||||||
audio_FORMAT_MONO16, audio_FORMAT_STEREO16
|
audio_FORMAT_MONO16, audio_FORMAT_STEREO16
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf (stderr, "Using nosound audio driver.\n");
|
log_add (log_Always, "Using nosound audio driver.");
|
||||||
fprintf (stderr, "Initializing mixer.\n");
|
log_add (log_Always, "Initializing mixer.");
|
||||||
|
|
||||||
if (!mixer_Init (nosound_freq, MIX_FORMAT_MAKE (1, 1),
|
if (!mixer_Init (nosound_freq, MIX_FORMAT_MAKE (1, 1),
|
||||||
MIX_QUALITY_LOW, MIX_FAKE_DATA))
|
MIX_QUALITY_LOW, MIX_FAKE_DATA))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Mixer initialization failed: %x\n",
|
log_add (log_Always, "Mixer initialization failed: %x",
|
||||||
mixer_GetError ());
|
mixer_GetError ());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Mixer initialized.\n");
|
log_add (log_Always, "Mixer initialized.");
|
||||||
|
|
||||||
fprintf (stderr, "Initializing sound decoders.\n");
|
log_add (log_Always, "Initializing sound decoders.");
|
||||||
if (SoundDecoder_Init (flags, &formats))
|
if (SoundDecoder_Init (flags, &formats))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Sound decoders initialization failed.\n");
|
log_add (log_Always, "Sound decoders initialization failed.");
|
||||||
mixer_Uninit ();
|
mixer_Uninit ();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Sound decoders initialized.\n");
|
log_add (log_Always, "Sound decoders initialized.");
|
||||||
|
|
||||||
*driver = noSound_Driver;
|
*driver = noSound_Driver;
|
||||||
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
|
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
|
||||||
@@ -250,7 +251,7 @@ noSound_GetError (void)
|
|||||||
case MIX_OUT_OF_MEMORY:
|
case MIX_OUT_OF_MEMORY:
|
||||||
return audio_OUT_OF_MEMORY;
|
return audio_OUT_OF_MEMORY;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "noSound_GetError: unknown value %x\n",
|
log_add (log_Debug, "noSound_GetError: unknown value %x",
|
||||||
value);
|
value);
|
||||||
return audio_DRIVER_FAILURE;
|
return audio_DRIVER_FAILURE;
|
||||||
break;
|
break;
|
||||||
@@ -326,7 +327,7 @@ noSound_GetSourcei (audio_Object srcobj, audio_SourceProp pname,
|
|||||||
*value = audio_PAUSED;
|
*value = audio_PAUSED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "noSound_GetSourcei(): unknown value %lx\n",
|
log_add (log_Debug, "noSound_GetSourcei(): unknown value %lx",
|
||||||
(long int) *value);
|
(long int) *value);
|
||||||
*value = audio_DRIVER_FAILURE;
|
*value = audio_DRIVER_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "audiodrv_sdl.h"
|
#include "audiodrv_sdl.h"
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -110,13 +111,14 @@ mixSDL_Init (audio_Driver *driver, sint32 flags)
|
|||||||
audio_FORMAT_MONO16, audio_FORMAT_STEREO16
|
audio_FORMAT_MONO16, audio_FORMAT_STEREO16
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf (stderr, "Initializing SDL audio subsystem.\n");
|
log_add (log_Always, "Initializing SDL audio subsystem.");
|
||||||
if ((SDL_InitSubSystem(SDL_INIT_AUDIO)) == -1)
|
if ((SDL_InitSubSystem(SDL_INIT_AUDIO)) == -1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't initialize audio subsystem: %s\n", SDL_GetError());
|
log_add (log_Always, "Couldn't initialize audio subsystem: %s",
|
||||||
|
SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "SDL audio subsystem initialized.\n");
|
log_add (log_Always, "SDL audio subsystem initialized.");
|
||||||
|
|
||||||
if (flags & audio_QUALITY_HIGH)
|
if (flags & audio_QUALITY_HIGH)
|
||||||
{
|
{
|
||||||
@@ -141,49 +143,52 @@ mixSDL_Init (audio_Driver *driver, sint32 flags)
|
|||||||
desired.channels = 2;
|
desired.channels = 2;
|
||||||
desired.callback = mixer_MixChannels;
|
desired.callback = mixer_MixChannels;
|
||||||
|
|
||||||
fprintf (stderr, "Opening SDL audio device.\n");
|
log_add (log_Always, "Opening SDL audio device.");
|
||||||
if (SDL_OpenAudio (&desired, &obtained) < 0)
|
if (SDL_OpenAudio (&desired, &obtained) < 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Unable to open audio device: %s\n", SDL_GetError ());
|
log_add (log_Always, "Unable to open audio device: %s",
|
||||||
|
SDL_GetError ());
|
||||||
SDL_QuitSubSystem (SDL_INIT_AUDIO);
|
SDL_QuitSubSystem (SDL_INIT_AUDIO);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (obtained.format != desired.format ||
|
if (obtained.format != desired.format ||
|
||||||
(obtained.channels != 1 && obtained.channels != 2))
|
(obtained.channels != 1 && obtained.channels != 2))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Unable to obtain desired audio format.\n");
|
log_add (log_Always, "Unable to obtain desired audio format.");
|
||||||
SDL_CloseAudio ();
|
SDL_CloseAudio ();
|
||||||
SDL_QuitSubSystem (SDL_INIT_AUDIO);
|
SDL_QuitSubSystem (SDL_INIT_AUDIO);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AudioDriverName (devicename, sizeof (devicename));
|
SDL_AudioDriverName (devicename, sizeof (devicename));
|
||||||
fprintf (stderr, " using %s at %d Hz 16 bit %s, %d samples audio buffer\n",
|
log_add (log_Always, " using %s at %d Hz 16 bit %s, "
|
||||||
devicename, obtained.freq, obtained.channels > 1 ? "stereo" : "mono",
|
"%d samples audio buffer",
|
||||||
|
devicename, obtained.freq,
|
||||||
|
obtained.channels > 1 ? "stereo" : "mono",
|
||||||
obtained.samples);
|
obtained.samples);
|
||||||
|
|
||||||
fprintf (stderr, "Initializing mixer.\n");
|
log_add (log_Always, "Initializing mixer.");
|
||||||
if (!mixer_Init (obtained.freq, MIX_FORMAT_MAKE (2, obtained.channels),
|
if (!mixer_Init (obtained.freq, MIX_FORMAT_MAKE (2, obtained.channels),
|
||||||
quality, 0))
|
quality, 0))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Mixer initialization failed: %x\n",
|
log_add (log_Always, "Mixer initialization failed: %x",
|
||||||
mixer_GetError ());
|
mixer_GetError ());
|
||||||
SDL_CloseAudio ();
|
SDL_CloseAudio ();
|
||||||
SDL_QuitSubSystem (SDL_INIT_AUDIO);
|
SDL_QuitSubSystem (SDL_INIT_AUDIO);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Mixer initialized.\n");
|
log_add (log_Always, "Mixer initialized.");
|
||||||
|
|
||||||
fprintf (stderr, "Initializing sound decoders.\n");
|
log_add (log_Always, "Initializing sound decoders.");
|
||||||
if (SoundDecoder_Init (flags, &formats))
|
if (SoundDecoder_Init (flags, &formats))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Sound decoders initialization failed.\n");
|
log_add (log_Always, "Sound decoders initialization failed.");
|
||||||
SDL_CloseAudio ();
|
SDL_CloseAudio ();
|
||||||
mixer_Uninit ();
|
mixer_Uninit ();
|
||||||
SDL_QuitSubSystem (SDL_INIT_AUDIO);
|
SDL_QuitSubSystem (SDL_INIT_AUDIO);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Sound decoders initialized.\n");
|
log_add (log_Always, "Sound decoders initialized.");
|
||||||
|
|
||||||
*driver = mixSDL_Driver;
|
*driver = mixSDL_Driver;
|
||||||
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
|
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
|
||||||
@@ -270,7 +275,7 @@ mixSDL_GetError (void)
|
|||||||
case MIX_OUT_OF_MEMORY:
|
case MIX_OUT_OF_MEMORY:
|
||||||
return audio_OUT_OF_MEMORY;
|
return audio_OUT_OF_MEMORY;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "mixSDL_GetError: unknown value %x\n", value);
|
log_add (log_Debug, "mixSDL_GetError: unknown value %x", value);
|
||||||
return audio_DRIVER_FAILURE;
|
return audio_DRIVER_FAILURE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "libs/reslib.h"
|
#include "libs/reslib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
static MUSIC_REF curMusicRef;
|
static MUSIC_REF curMusicRef;
|
||||||
@@ -139,7 +140,7 @@ CheckMusicResName (char* fileName)
|
|||||||
if (fileExists2 (contentDir, otherName))
|
if (fileExists2 (contentDir, otherName))
|
||||||
strcpy (fileName, otherName);
|
strcpy (fileName, otherName);
|
||||||
else
|
else
|
||||||
fprintf (stderr, "Requested track '%s' not found!\n", otherName);
|
log_add (log_Warning, "Requested track '%s' not found.", otherName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileName;
|
return fileName;
|
||||||
@@ -171,11 +172,11 @@ _GetMusicData (uio_Stream *fp, DWORD length)
|
|||||||
filename[sizeof(filename) - 1] = '\0';
|
filename[sizeof(filename) - 1] = '\0';
|
||||||
CheckMusicResName (filename);
|
CheckMusicResName (filename);
|
||||||
|
|
||||||
fprintf (stderr, "_GetMusicData(): loading %s\n", filename);
|
log_add (log_Info, "_GetMusicData(): loading %s", filename);
|
||||||
if (((*pmus)->decoder = SoundDecoder_Load (contentDir, filename,
|
if (((*pmus)->decoder = SoundDecoder_Load (contentDir, filename,
|
||||||
4096, 0, 0)) == 0)
|
4096, 0, 0)) == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "_GetMusicData(): couldn't load %s\n", filename);
|
log_add (log_Warning, "_GetMusicData(): couldn't load %s", filename);
|
||||||
|
|
||||||
UnlockMusicData (h);
|
UnlockMusicData (h);
|
||||||
mem_release (h);
|
mem_release (h);
|
||||||
@@ -183,7 +184,7 @@ _GetMusicData (uio_Stream *fp, DWORD length)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, " decoder: %s, rate %d format %x\n",
|
log_add (log_Info, " decoder: %s, rate %d format %x",
|
||||||
SoundDecoder_GetName ((*pmus)->decoder),
|
SoundDecoder_GetName ((*pmus)->decoder),
|
||||||
(*pmus)->decoder->frequency, (*pmus)->decoder->format);
|
(*pmus)->decoder->frequency, (*pmus)->decoder->format);
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "audiodrv_openal.h"
|
#include "audiodrv_openal.h"
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ openAL_Init (audio_Driver *driver, sint32 flags)
|
|||||||
audio_FORMAT_MONO16, audio_FORMAT_STEREO16
|
audio_FORMAT_MONO16, audio_FORMAT_STEREO16
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf (stderr, "Initializing OpenAL.\n");
|
log_add (log_Always, "Initializing OpenAL.");
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
alcDevice = alcOpenDevice ((ALubyte*)"DirectSound3D");
|
alcDevice = alcOpenDevice ((ALubyte*)"DirectSound3D");
|
||||||
#else
|
#else
|
||||||
@@ -124,7 +124,8 @@ openAL_Init (audio_Driver *driver, sint32 flags)
|
|||||||
|
|
||||||
if (!alcDevice)
|
if (!alcDevice)
|
||||||
{
|
{
|
||||||
fprintf (stderr,"Couldn't initialize OpenAL: %d\n", alcGetError (NULL));
|
log_add (log_Always, "Couldn't initialize OpenAL: %d",
|
||||||
|
alcGetError (NULL));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,22 +135,37 @@ openAL_Init (audio_Driver *driver, sint32 flags)
|
|||||||
alcContext = alcCreateContext (alcDevice, NULL);
|
alcContext = alcCreateContext (alcDevice, NULL);
|
||||||
if (!alcContext)
|
if (!alcContext)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't create OpenAL context: %d\n", alcGetError (alcDevice));
|
log_add (log_Always, "Couldn't create OpenAL context: %d",
|
||||||
|
alcGetError (alcDevice));
|
||||||
|
alcCloseDevice (alcDevice);
|
||||||
|
alcDevice = NULL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
alcMakeContextCurrent (alcContext);
|
alcMakeContextCurrent (alcContext);
|
||||||
|
|
||||||
fprintf (stderr, "OpenAL initialized.\n");
|
log_add (log_Always, "OpenAL initialized.\n"
|
||||||
fprintf (stderr, " version: %s\n", alGetString (AL_VERSION));
|
" version: %s\n",
|
||||||
fprintf (stderr, " vendor: %s\n", alGetString (AL_VENDOR));
|
" vendor: %s\n",
|
||||||
fprintf (stderr, " renderer: %s\n", alGetString (AL_RENDERER));
|
" renderer: %s\n",
|
||||||
fprintf (stderr, " device: %s\n",
|
" device: %s",
|
||||||
|
alGetString (AL_VERSION), alGetString (AL_VENDOR),
|
||||||
|
alGetString (AL_RENDERER),
|
||||||
alcGetString (alcDevice, ALC_DEFAULT_DEVICE_SPECIFIER));
|
alcGetString (alcDevice, ALC_DEFAULT_DEVICE_SPECIFIER));
|
||||||
//fprintf (stderr, " extensions: %s\n", alGetString (AL_EXTENSIONS));
|
//log_add (log_Info, " extensions: %s", alGetString (AL_EXTENSIONS));
|
||||||
|
|
||||||
fprintf (stderr, "Initializing sound decoders.\n");
|
log_add (log_Always, "Initializing sound decoders.");
|
||||||
SoundDecoder_Init (flags, &formats);
|
if (SoundDecoder_Init (flags, &formats))
|
||||||
fprintf (stderr, "Sound decoders initialized.\n");
|
{
|
||||||
|
log_add (log_Always, "Sound decoders initialization failed.");
|
||||||
|
alcMakeContextCurrent (NULL);
|
||||||
|
alcDestroyContext (alcContext);
|
||||||
|
alcContext = NULL;
|
||||||
|
alcCloseDevice (alcDevice);
|
||||||
|
alcDevice = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
log_add (log_Always, "Sound decoders initialized.");
|
||||||
|
|
||||||
alListenerfv (AL_POSITION, listenerPos);
|
alListenerfv (AL_POSITION, listenerPos);
|
||||||
alListenerfv (AL_VELOCITY, listenerVel);
|
alListenerfv (AL_VELOCITY, listenerVel);
|
||||||
@@ -250,7 +266,7 @@ openAL_GetError (void)
|
|||||||
case AL_OUT_OF_MEMORY:
|
case AL_OUT_OF_MEMORY:
|
||||||
return audio_OUT_OF_MEMORY;
|
return audio_OUT_OF_MEMORY;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "openAL_GetError: unknown value %x\n", value);
|
log_add (log_Debug, "openAL_GetError: unknown value %x", value);
|
||||||
return audio_DRIVER_FAILURE;
|
return audio_DRIVER_FAILURE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -323,7 +339,7 @@ openAL_GetSourcei (audio_Object srcobj, audio_SourceProp pname,
|
|||||||
*value = audio_PAUSED;
|
*value = audio_PAUSED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "openAL_GetSourcei(): unknown value %x\n",
|
log_add (log_Debug, "openAL_GetSourcei(): unknown value %x",
|
||||||
*value);
|
*value);
|
||||||
*value = audio_DRIVER_FAILURE;
|
*value = audio_DRIVER_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "libs/reslib.h"
|
#include "libs/reslib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ UpdateSoundPosition (COUNT channel, SoundPosition pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
audio_Sourcefv (soundSource[channel].handle, audio_POSITION, fpos);
|
audio_Sourcefv (soundSource[channel].handle, audio_POSITION, fpos);
|
||||||
//fprintf (stderr, "UpdateSoundPosition(): channel %d, pos %d %d, posobj %x\n",
|
//log_add (log_Debug, "UpdateSoundPosition(): channel %d, pos %d %d, posobj %x",
|
||||||
// channel, pos.x, pos.y, (unsigned int)soundSource[channel].positional_object);
|
// channel, pos.x, pos.y, (unsigned int)soundSource[channel].positional_object);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -210,7 +211,7 @@ _GetSoundBankData (uio_Stream *fp, DWORD length)
|
|||||||
{
|
{
|
||||||
if (sscanf(CurrentLine, "%s", &filename[n]) == 1)
|
if (sscanf(CurrentLine, "%s", &filename[n]) == 1)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "_GetSoundBankData(): loading %s\n", filename);
|
log_add (log_Info, "_GetSoundBankData(): loading %s", filename);
|
||||||
|
|
||||||
sndfx[snd_ct] = (TFB_SoundSample *) HCalloc (sizeof (TFB_SoundSample));
|
sndfx[snd_ct] = (TFB_SoundSample *) HCalloc (sizeof (TFB_SoundSample));
|
||||||
|
|
||||||
@@ -218,7 +219,7 @@ _GetSoundBankData (uio_Stream *fp, DWORD length)
|
|||||||
filename, 4096, 0, 0);
|
filename, 4096, 0, 0);
|
||||||
if (!sndfx[snd_ct]->decoder)
|
if (!sndfx[snd_ct]->decoder)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "_GetSoundBankData(): couldn't load %s\n", filename);
|
log_add (log_Warning, "_GetSoundBankData(): couldn't load %s", filename);
|
||||||
HFree (sndfx[snd_ct]);
|
HFree (sndfx[snd_ct]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -226,7 +227,7 @@ _GetSoundBankData (uio_Stream *fp, DWORD length)
|
|||||||
uint32 decoded_bytes;
|
uint32 decoded_bytes;
|
||||||
|
|
||||||
decoded_bytes = SoundDecoder_DecodeAll (sndfx[snd_ct]->decoder);
|
decoded_bytes = SoundDecoder_DecodeAll (sndfx[snd_ct]->decoder);
|
||||||
//fprintf (stderr, "_GetSoundBankData(): decoded_bytes %d\n", decoded_bytes);
|
log_add (log_Info, "_GetSoundBankData(): decoded_bytes %d", decoded_bytes);
|
||||||
|
|
||||||
sndfx[snd_ct]->num_buffers = 1;
|
sndfx[snd_ct]->num_buffers = 1;
|
||||||
sndfx[snd_ct]->buffer = (audio_Object *) HMalloc (
|
sndfx[snd_ct]->buffer = (audio_Object *) HMalloc (
|
||||||
@@ -244,7 +245,7 @@ _GetSoundBankData (uio_Stream *fp, DWORD length)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "_GetSoundBankData: Bad file!\n");
|
log_add (log_Warning, "_GetSoundBankData: Bad file!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// pkunk insult fix 2002/11/12 (ftell shouldn't be needed for loop to terminate)
|
// pkunk insult fix 2002/11/12 (ftell shouldn't be needed for loop to terminate)
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "../tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -58,9 +59,11 @@ PlayStream (TFB_SoundSample *sample, uint32 source, bool looping, bool scope,
|
|||||||
uint32 decoded_bytes;
|
uint32 decoded_bytes;
|
||||||
|
|
||||||
decoded_bytes = SoundDecoder_Decode (sample->decoder);
|
decoded_bytes = SoundDecoder_Decode (sample->decoder);
|
||||||
//fprintf (stderr, "PlayStream(): source %d filename:%s start: %d position:%d bytes %d\n", source,
|
#if 0
|
||||||
// sample->decoder->filename, sample->decoder->start_sample,
|
log_add (log_Debug, "PlayStream(): source:%d filename:%s start:%d position:%d bytes:%d\n",
|
||||||
// sample->decoder->pos, decoded_bytes);
|
source, sample->decoder->filename, sample->decoder->start_sample,
|
||||||
|
sample->decoder->pos, decoded_bytes);
|
||||||
|
#endif
|
||||||
if (decoded_bytes == 0)
|
if (decoded_bytes == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -245,8 +248,8 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
if (queued == 0 && soundSource[i].sample->decoder->error
|
if (queued == 0 && soundSource[i].sample->decoder->error
|
||||||
== SOUNDDECODER_EOF)
|
== SOUNDDECODER_EOF)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "StreamDecoderTaskFunc(): "
|
log_add (log_Info, "StreamDecoderTaskFunc(): "
|
||||||
"finished playing %s, source %d\n",
|
"finished playing %s, source %d",
|
||||||
soundSource[i].sample->decoder->filename, i);
|
soundSource[i].sample->decoder->filename, i);
|
||||||
soundSource[i].stream_should_be_playing = FALSE;
|
soundSource[i].stream_should_be_playing = FALSE;
|
||||||
if (soundSource[i].sample->callbacks.OnEndStream)
|
if (soundSource[i].sample->callbacks.OnEndStream)
|
||||||
@@ -255,15 +258,18 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "StreamDecoderTaskFunc(): buffer "
|
log_add (log_Warning, "StreamDecoderTaskFunc(): buffer "
|
||||||
"underrun when playing %s, source %d\n",
|
"underrun when playing %s, source %d",
|
||||||
soundSource[i].sample->decoder->filename, i);
|
soundSource[i].sample->decoder->filename, i);
|
||||||
audio_SourcePlay (soundSource[i].handle);
|
audio_SourcePlay (soundSource[i].handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf (stderr, "StreamDecoderTaskFunc(): source %d, processed %d queued %d\n", i, processed, queued);
|
#if 0
|
||||||
|
log_add (log_Debug, "StreamDecoderTaskFunc(): source %d, processed %d queued %d",
|
||||||
|
i, processed, queued);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (processed)
|
while (processed)
|
||||||
{
|
{
|
||||||
@@ -278,9 +284,9 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
error = audio_GetError();
|
error = audio_GetError();
|
||||||
if (error != audio_NO_ERROR)
|
if (error != audio_NO_ERROR)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "StreamDecoderTaskFunc(): OpenAL "
|
log_add (log_Warning, "StreamDecoderTaskFunc(): OpenAL "
|
||||||
"error after alSourceUnqueueBuffers: %x, "
|
"error after alSourceUnqueueBuffers: %x, "
|
||||||
"file %s, source %d\n", error,
|
"file %s, source %d", error,
|
||||||
soundSource[i].sample->decoder->filename, i);
|
soundSource[i].sample->decoder->filename, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -315,14 +321,21 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
!soundSource[i].sample->callbacks.OnEndChunk (
|
!soundSource[i].sample->callbacks.OnEndChunk (
|
||||||
soundSource[i].sample, last_buffer[i]))
|
soundSource[i].sample, last_buffer[i]))
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "StreamDecoderTaskFunc(): decoder->error is eof for %s\n", soundSource[i].sample->decoder->filename);
|
#if 0
|
||||||
|
log_add (log_Debug, "StreamDecoderTaskFunc(): decoder->error is eof for %s",
|
||||||
|
soundSource[i].sample->decoder->filename);
|
||||||
|
#endif
|
||||||
processed--;
|
processed--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "StreamDecoderTaskFunc(): decoder->error is %d for %s\n", soundSource[i].sample->decoder->error, soundSource[i].sample->decoder->filename);
|
#if 0
|
||||||
|
log_add (log_Debug, "StreamDecoderTaskFunc(): decoder->error is %d for %s",
|
||||||
|
soundSource[i].sample->decoder->error,
|
||||||
|
soundSource[i].sample->decoder->filename);
|
||||||
|
#endif
|
||||||
processed--;
|
processed--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -333,9 +346,9 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
if (soundSource[i].sample->decoder->error ==
|
if (soundSource[i].sample->decoder->error ==
|
||||||
SOUNDDECODER_ERROR)
|
SOUNDDECODER_ERROR)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "StreamDecoderTaskFunc(): "
|
log_add (log_Warning, "StreamDecoderTaskFunc(): "
|
||||||
"SoundDecoder_Decode error %d, file %s, "
|
"SoundDecoder_Decode error %d, file %s, "
|
||||||
"source %d\n",
|
"source %d",
|
||||||
soundSource[i].sample->decoder->error,
|
soundSource[i].sample->decoder->error,
|
||||||
soundSource[i].sample->decoder->filename, i);
|
soundSource[i].sample->decoder->filename, i);
|
||||||
soundSource[i].stream_should_be_playing = FALSE;
|
soundSource[i].stream_should_be_playing = FALSE;
|
||||||
@@ -354,9 +367,9 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
error = audio_GetError();
|
error = audio_GetError();
|
||||||
if (error != audio_NO_ERROR)
|
if (error != audio_NO_ERROR)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "StreamDecoderTaskFunc(): "
|
log_add (log_Warning, "StreamDecoderTaskFunc(): "
|
||||||
"TFBSound error after audio_BufferData: "
|
"TFBSound error after audio_BufferData: "
|
||||||
"%x, file %s, source %d, decoded_bytes %d\n",
|
"%x, file %s, source %d, decoded_bytes %d",
|
||||||
error, soundSource[i].sample->decoder->filename,
|
error, soundSource[i].sample->decoder->filename,
|
||||||
i, decoded_bytes);
|
i, decoded_bytes);
|
||||||
}
|
}
|
||||||
@@ -393,7 +406,6 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
|
|
||||||
if (j - soundSource[i].sbuf_start >= 1)
|
if (j - soundSource[i].sbuf_start >= 1)
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "copying_a to %d - %d, %d bytes\n", soundSource[i].sbuf_start, j, j - soundSource[i].sbuf_start);
|
|
||||||
memcpy (&sbuffer[soundSource[i].sbuf_start],
|
memcpy (&sbuffer[soundSource[i].sbuf_start],
|
||||||
decoder_buffer,
|
decoder_buffer,
|
||||||
j - soundSource[i].sbuf_start);
|
j - soundSource[i].sbuf_start);
|
||||||
@@ -401,7 +413,6 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
|
|
||||||
if (remaining_bytes)
|
if (remaining_bytes)
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "copying_b to 0 - %d\n", remaining_bytes);
|
|
||||||
memcpy (sbuffer, &decoder_buffer[
|
memcpy (sbuffer, &decoder_buffer[
|
||||||
j - soundSource[i].sbuf_start],
|
j - soundSource[i].sbuf_start],
|
||||||
remaining_bytes);
|
remaining_bytes);
|
||||||
@@ -416,10 +427,10 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
error = audio_GetError();
|
error = audio_GetError();
|
||||||
if (error != audio_NO_ERROR)
|
if (error != audio_NO_ERROR)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "StreamDecoderTaskFunc(): "
|
log_add (log_Warning, "StreamDecoderTaskFunc(): "
|
||||||
"TFBSound error after "
|
"TFBSound error after "
|
||||||
"audio_SourceQueueBuffers: %x, file %s, "
|
"audio_SourceQueueBuffers: %x, file %s, "
|
||||||
"source %d, decoded_bytes %d\n", error,
|
"source %d, decoded_bytes %d", error,
|
||||||
soundSource[i].sample->decoder->filename,
|
soundSource[i].sample->decoder->filename,
|
||||||
i, decoded_bytes);
|
i, decoded_bytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "libs/sound/trackplayer.h"
|
#include "libs/sound/trackplayer.h"
|
||||||
#include "libs/sound/trackint.h"
|
#include "libs/sound/trackint.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "sis.h"
|
#include "sis.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
@@ -267,7 +268,7 @@ OnChunkEnd (TFB_SoundSample* sample, audio_Object buffer)
|
|||||||
scd->read_chain_ptr = scd->read_chain_ptr->next;
|
scd->read_chain_ptr = scd->read_chain_ptr->next;
|
||||||
sample->decoder = scd->read_chain_ptr->decoder;
|
sample->decoder = scd->read_chain_ptr->decoder;
|
||||||
SoundDecoder_Rewind (sample->decoder);
|
SoundDecoder_Rewind (sample->decoder);
|
||||||
fprintf (stderr, "Switching to stream %s at pos %d\n",
|
log_add (log_Info, "Switching to stream %s at pos %d",
|
||||||
sample->decoder->filename, sample->decoder->start_sample);
|
sample->decoder->filename, sample->decoder->start_sample);
|
||||||
|
|
||||||
if (sample->buffer_tag && scd->read_chain_ptr->tag_me)
|
if (sample->buffer_tag && scd->read_chain_ptr->tag_me)
|
||||||
@@ -414,33 +415,31 @@ SpliceMultiTrack (UNICODE *TrackNames[], UNICODE *TrackText)
|
|||||||
|
|
||||||
if (!TrackText)
|
if (!TrackText)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
log_add (log_Debug, "SpliceMultiTrack(): no track text");
|
||||||
fprintf (stderr, "SpliceMultiTrack(): no track text\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tct >= MAX_CLIPS)
|
if (tct >= MAX_CLIPS)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SpliceMultiTrack(): no more clip slots (%d)\n",
|
log_add (log_Warning, "SpliceMultiTrack(): no more clip slots (%d)",
|
||||||
MAX_CLIPS);
|
MAX_CLIPS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! sound_sample)
|
if (! sound_sample)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SpliceMultiTrack(): Cannot be called before SpliceTrack()\n");
|
log_add (log_Warning, "SpliceMultiTrack(): Cannot be called before SpliceTrack()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "SpliceMultiTrack(): loading...\n");
|
log_add (log_Info, "SpliceMultiTrack(): loading...");
|
||||||
for (tracks = 0; *TrackNames && tracks < MAX_MULTI_TRACKS; TrackNames++, tracks++)
|
for (tracks = 0; *TrackNames && tracks < MAX_MULTI_TRACKS; TrackNames++, tracks++)
|
||||||
{
|
{
|
||||||
track_decs[tracks] = SoundDecoder_Load (contentDir, *TrackNames,
|
track_decs[tracks] = SoundDecoder_Load (contentDir, *TrackNames,
|
||||||
32768, 0, - 3 * TEXT_SPEED);
|
32768, 0, - 3 * TEXT_SPEED);
|
||||||
if (track_decs[tracks])
|
if (track_decs[tracks])
|
||||||
{
|
{
|
||||||
fprintf (stderr, " track: %s, decoder: %s, rate %d format %x\n",
|
log_add (log_Info, " track: %s, decoder: %s, rate %d format %x",
|
||||||
*TrackNames,
|
*TrackNames,
|
||||||
SoundDecoder_GetName (track_decs[tracks]),
|
SoundDecoder_GetName (track_decs[tracks]),
|
||||||
track_decs[tracks]->frequency,
|
track_decs[tracks]->frequency,
|
||||||
@@ -455,7 +454,8 @@ SpliceMultiTrack (UNICODE *TrackNames[], UNICODE *TrackText)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, " couldn't load %s\n", *TrackNames);
|
log_add (log_Warning, "SpliceMultiTrack(): couldn't load %s\n",
|
||||||
|
*TrackNames);
|
||||||
tracks--;
|
tracks--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -463,7 +463,7 @@ SpliceMultiTrack (UNICODE *TrackNames[], UNICODE *TrackText)
|
|||||||
|
|
||||||
if (tracks == 0)
|
if (tracks == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, " no tracks loaded\n");
|
log_add (log_Warning, "SpliceMultiTrack(): no tracks loaded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,12 +486,6 @@ SpliceMultiTrack (UNICODE *TrackNames[], UNICODE *TrackText)
|
|||||||
}
|
}
|
||||||
no_page_break = 1;
|
no_page_break = 1;
|
||||||
|
|
||||||
if (tracks > 0)
|
|
||||||
return;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf (stderr, " no tracks loaded\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -512,14 +506,14 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
|
|||||||
|
|
||||||
if (!last_ts_chain || !last_ts_chain->text)
|
if (!last_ts_chain || !last_ts_chain->text)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
log_add (log_Warning, "SpliceTrack(): Tried to append"
|
||||||
"SpliceTrack(): Tried to append a subtitle to a NULL string\n");
|
" a subtitle to a NULL string");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
split_text = SplitSubPages (TrackText, time_stamps, &num_pages);
|
split_text = SplitSubPages (TrackText, time_stamps, &num_pages);
|
||||||
if (! split_text)
|
if (! split_text)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SpliceTrack(): Failed to parse sutitles\n");
|
log_add (log_Warning, "SpliceTrack(): Failed to parse sutitles");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
oTT = (UNICODE *)last_ts_chain->text;
|
oTT = (UNICODE *)last_ts_chain->text;
|
||||||
@@ -532,7 +526,7 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
|
|||||||
{
|
{
|
||||||
if (! last_ts_chain->next)
|
if (! last_ts_chain->next)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SpliceTrack(): More text pages than timestamps!\n");
|
log_add (log_Warning, "SpliceTrack(): More text pages than timestamps!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
last_ts_chain = last_ts_chain->next;
|
last_ts_chain = last_ts_chain->next;
|
||||||
@@ -552,7 +546,7 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
|
|||||||
split_text = SplitSubPages (TrackText, time_stamps, &num_pages);
|
split_text = SplitSubPages (TrackText, time_stamps, &num_pages);
|
||||||
if (! split_text)
|
if (! split_text)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SpliceTrack(): Failed to parse sutitles\n");
|
log_add (log_Warning, "SpliceTrack(): Failed to parse sutitles");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (no_page_break && tct)
|
if (no_page_break && tct)
|
||||||
@@ -570,13 +564,14 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
|
|||||||
else
|
else
|
||||||
tct++;
|
tct++;
|
||||||
|
|
||||||
fprintf (stderr, "SpliceTrack(): loading %s\n", TrackName);
|
log_add (log_Info, "SpliceTrack(): loading %s", TrackName);
|
||||||
|
|
||||||
if (TimeStamp)
|
if (TimeStamp)
|
||||||
{
|
{
|
||||||
num_timestamps = GetTimeStamps (TimeStamp, time_stamps) + 1;
|
num_timestamps = GetTimeStamps (TimeStamp, time_stamps) + 1;
|
||||||
if (num_timestamps < num_pages)
|
if (num_timestamps < num_pages)
|
||||||
fprintf (stderr, "SpliceTrack(): number of timestamps doesn't match number of pages!\n");
|
log_add (log_Warning, "SpliceTrack(): number of timestamps"
|
||||||
|
" doesn't match number of pages!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
num_timestamps = num_pages;
|
num_timestamps = num_pages;
|
||||||
@@ -615,7 +610,11 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
|
|||||||
}
|
}
|
||||||
startTime += abs (time_stamps[page_counter]);
|
startTime += abs (time_stamps[page_counter]);
|
||||||
|
|
||||||
// fprintf (stderr, "page (%d of %d): %d ts: %d\n",page_counter, num_pages, startTime, time_stamps[page_counter]);
|
#if 0
|
||||||
|
log_add (log_Debug, "page (%d of %d): %d ts: %d",
|
||||||
|
page_counter, num_pages,
|
||||||
|
startTime, time_stamps[page_counter]);
|
||||||
|
#endif
|
||||||
if (last_chain->decoder)
|
if (last_chain->decoder)
|
||||||
{
|
{
|
||||||
static float old_volume = 0.0f;
|
static float old_volume = 0.0f;
|
||||||
@@ -627,13 +626,14 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
|
|||||||
ensure proper operation of oscilloscope and music fading */
|
ensure proper operation of oscilloscope and music fading */
|
||||||
old_volume = speechVolumeScale;
|
old_volume = speechVolumeScale;
|
||||||
speechVolumeScale = 0.0f;
|
speechVolumeScale = 0.0f;
|
||||||
fprintf (stderr, "SpliceTrack(): no voice ogg available so setting speech volume to zero\n");
|
log_add (log_Warning, "SpliceTrack(): no voice ogg"
|
||||||
|
" available so setting speech volume to zero");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (old_volume != 0.0f && speechVolumeScale != old_volume)
|
else if (old_volume != 0.0f && speechVolumeScale != old_volume)
|
||||||
{
|
{
|
||||||
/* This time voice ogg is there */
|
/* This time voice ogg is there */
|
||||||
fprintf (stderr, "SpliceTrack(): restoring speech volume\n");
|
log_add (log_Warning, "SpliceTrack(): restoring speech volume");
|
||||||
speechVolumeScale = old_volume;
|
speechVolumeScale = old_volume;
|
||||||
old_volume = 0.0f;
|
old_volume = 0.0f;
|
||||||
}
|
}
|
||||||
@@ -656,7 +656,7 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SpliceTrack(): couldn't load %s\n", TrackName);
|
log_add (log_Warning, "SpliceTrack(): couldn't load %s", TrackName);
|
||||||
audio_DeleteBuffers (sound_sample->num_buffers, sound_sample->buffer);
|
audio_DeleteBuffers (sound_sample->num_buffers, sound_sample->buffer);
|
||||||
destroy_soundchain (first_chain);
|
destroy_soundchain (first_chain);
|
||||||
first_chain = NULL;
|
first_chain = NULL;
|
||||||
@@ -848,17 +848,23 @@ GetSoundData (void *data)
|
|||||||
|
|
||||||
if (delta < 0)
|
if (delta < 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "GetSoundData(): something's messed with timing, delta %ld\n", delta);
|
log_add (log_Debug, "GetSoundData(): something's messed"
|
||||||
|
" with timing, delta %ld", delta);
|
||||||
delta = 0;
|
delta = 0;
|
||||||
}
|
}
|
||||||
else if (delta > (int)(soundSource[SPEECH_SOURCE].sbuf_size * 2))
|
else if (delta > (int)(soundSource[SPEECH_SOURCE].sbuf_size * 2))
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "GetSoundData(): something's messed with timing, delta %d\n", delta);
|
#if 0
|
||||||
|
log_add (log_Debug, "GetSoundData(): something's messed"
|
||||||
|
" with timing, delta %d", delta);
|
||||||
|
#endif
|
||||||
delta = 0;
|
delta = 0;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
//fprintf (stderr, "played_data %d total_decoded %d delta %d\n", played_data, soundSource[SPEECH_SOURCE].total_decoded, delta);
|
log_add (log_Debug, "played_data %d total_decoded %d delta %d",
|
||||||
|
played_data, soundSource[SPEECH_SOURCE].total_decoded,
|
||||||
|
delta);
|
||||||
|
#endif
|
||||||
pos = soundSource[SPEECH_SOURCE].sbuf_offset + delta;
|
pos = soundSource[SPEECH_SOURCE].sbuf_offset + delta;
|
||||||
if (pos % 2 == 1)
|
if (pos % 2 == 1)
|
||||||
pos++;
|
pos++;
|
||||||
@@ -921,17 +927,25 @@ GetSoundData (void *data)
|
|||||||
|
|
||||||
if (delta < 0)
|
if (delta < 0)
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "GetSoundData(): something's messed with timing, delta %d\n", delta);
|
#if 0
|
||||||
|
log_add (log_Debug, "GetSoundData(): something's messed"
|
||||||
|
" with timing, delta %d", delta);
|
||||||
|
#endif
|
||||||
delta = 0;
|
delta = 0;
|
||||||
}
|
}
|
||||||
else if (delta > (int)(soundSource[MUSIC_SOURCE].sbuf_size * 2))
|
else if (delta > (int)(soundSource[MUSIC_SOURCE].sbuf_size * 2))
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "GetSoundData(): something's messed with timing, delta %d\n", delta);
|
#if 0
|
||||||
|
log_add (log_Debug, "GetSoundData(): something's messed"
|
||||||
|
" with timing, delta %d", delta);
|
||||||
|
#endif
|
||||||
delta = 0;
|
delta = 0;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
//fprintf (stderr, "played_data %d total_decoded %d delta %d\n", played_data, soundSource[MUSIC_SOURCE].total_decoded, delta);
|
log_add (log_Debug, "played_data %d total_decoded %d delta %d",
|
||||||
|
played_data, soundSource[MUSIC_SOURCE].total_decoded,
|
||||||
|
delta);
|
||||||
|
#endif
|
||||||
pos = soundSource[MUSIC_SOURCE].sbuf_offset + delta;
|
pos = soundSource[MUSIC_SOURCE].sbuf_offset + delta;
|
||||||
if (pos % 2 == 1)
|
if (pos % 2 == 1)
|
||||||
pos++;
|
pos++;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "strintrn.h"
|
#include "strintrn.h"
|
||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/reslib.h"
|
#include "libs/reslib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -97,7 +98,7 @@ _GetStringData (uio_Stream *fp, DWORD length)
|
|||||||
if ((timestamp_fp = uio_fopen (contentDir, ts_file_name,
|
if ((timestamp_fp = uio_fopen (contentDir, ts_file_name,
|
||||||
"rb")))
|
"rb")))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Found timestamp file: %s\n", ts_file_name);
|
log_add (log_Info, "Found timestamp file: %s", ts_file_name);
|
||||||
if ((ts_data = HMalloc (tot_ts_size = POOL_SIZE)) == 0)
|
if ((ts_data = HMalloc (tot_ts_size = POOL_SIZE)) == 0)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -166,8 +167,8 @@ _GetStringData (uio_Stream *fp, DWORD length)
|
|||||||
if (!ts_ok)
|
if (!ts_ok)
|
||||||
{
|
{
|
||||||
// timestamp data is invalid, remove all of it
|
// timestamp data is invalid, remove all of it
|
||||||
fprintf (stderr, "Invalid timestamp data "
|
log_add (log_Warning, "Invalid timestamp data "
|
||||||
"for '%s'. Disabling timestamps\n", s);
|
"for '%s'. Disabling timestamps", s);
|
||||||
HFree (ts_data);
|
HFree (ts_data);
|
||||||
ts_data = NULL;
|
ts_data = NULL;
|
||||||
uio_fclose (timestamp_fp);
|
uio_fclose (timestamp_fp);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "strlib.h"
|
#include "strlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
// Resynchronise (skip everything starting with 0x10xxxxxx):
|
// Resynchronise (skip everything starting with 0x10xxxxxx):
|
||||||
@@ -117,7 +118,7 @@ getCharFromString(const unsigned char **ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err:
|
err:
|
||||||
fprintf(stderr, "Warning: Invalid UTF8 sequence.\n");
|
log_add(log_Warning, "Warning: Invalid UTF8 sequence.");
|
||||||
|
|
||||||
// Resynchronise (skip everything starting with 0x10xxxxxx):
|
// Resynchronise (skip everything starting with 0x10xxxxxx):
|
||||||
resyncUTF8(ptr);
|
resyncUTF8(ptr);
|
||||||
@@ -416,7 +417,7 @@ getStringFromChar(unsigned char *ptr, size_t size, wchar_t ch)
|
|||||||
;
|
;
|
||||||
if (def->mask == 0)
|
if (def->mask == 0)
|
||||||
{ // invalid or unsupported char
|
{ // invalid or unsupported char
|
||||||
fprintf(stderr, "Warning: Invalid or unsupported wide char (%lu)\n",
|
log_add(log_Warning, "Warning: Invalid or unsupported wide char (%lu)",
|
||||||
(unsigned long)ch);
|
(unsigned long)ch);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#define TASK_MAX 64
|
#define TASK_MAX 64
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ AssignTask (ThreadFunction task_func, SDWORD stackSize, const char *name)
|
|||||||
{
|
{
|
||||||
if (!Task_SetState (task_array+i, TASK_INUSE))
|
if (!Task_SetState (task_array+i, TASK_INUSE))
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "Assigning Task #%i: %s\n", i+1, name);
|
// log_add (log_Debug, "Assigning Task #%i: %s", i+1, name);
|
||||||
Task_ClearState (task_array+i, ~TASK_INUSE);
|
Task_ClearState (task_array+i, ~TASK_INUSE);
|
||||||
task_array[i].name = name;
|
task_array[i].name = name;
|
||||||
task_array[i].thread = CreateThread (task_func, task_array+i,
|
task_array[i].thread = CreateThread (task_func, task_array+i,
|
||||||
@@ -41,19 +42,19 @@ AssignTask (ThreadFunction task_func, SDWORD stackSize, const char *name)
|
|||||||
return task_array+i;
|
return task_array+i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Task error! Task array exhausted. Check for thread leaks.\n");
|
log_add (log_Always, "Task error! Task array exhausted. Check for thread leaks.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FinishTask (Task task)
|
FinishTask (Task task)
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "Releasing Task: %s\n", task->name);
|
// log_add (log_Debug, "Releasing Task: %s", task->name);
|
||||||
task->thread = 0;
|
task->thread = 0;
|
||||||
if (!Task_ClearState (task, TASK_INUSE))
|
if (!Task_ClearState (task, TASK_INUSE))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Task error! Attempted to FinishTask \"%s\"... "
|
log_add (log_Debug, "Task error! Attempted to FinishTask '%s'... "
|
||||||
"but it was already done!\n", task->name);
|
"but it was already done!", task->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ void
|
|||||||
ConcludeTask (Task task)
|
ConcludeTask (Task task)
|
||||||
{
|
{
|
||||||
Thread old = task->thread;
|
Thread old = task->thread;
|
||||||
// fprintf (stderr, "Awaiting conclusion of %s\n", task->name);
|
// log_add (log_Debug, "Awaiting conclusion of %s", task->name);
|
||||||
if (old)
|
if (old)
|
||||||
{
|
{
|
||||||
Task_SetState (task, TASK_EXIT);
|
Task_SetState (task, TASK_EXIT);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#if defined(PROFILE_THREADS) && !defined(WIN32)
|
#if defined(PROFILE_THREADS) && !defined(WIN32)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@@ -151,8 +152,8 @@ UnQueueThread (TrueThread thread)
|
|||||||
if (*ptr == NULL)
|
if (*ptr == NULL)
|
||||||
{
|
{
|
||||||
// Should not happen.
|
// Should not happen.
|
||||||
fprintf (stderr, "Error: Trying to remove non-present thread "
|
log_add (log_Debug, "Error: Trying to remove non-present thread "
|
||||||
"from thread queue.\n");
|
"from thread queue.");
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@@ -213,7 +214,7 @@ ThreadHelper (void *startInfo) {
|
|||||||
result = (*func) (data);
|
result = (*func) (data);
|
||||||
|
|
||||||
#ifdef DEBUG_THREADS
|
#ifdef DEBUG_THREADS
|
||||||
fprintf (stderr, "Thread '%s' done (returned %d).\n",
|
log_add (log_Debug, "Thread '%s' done (returned %d).",
|
||||||
thread->name, result);
|
thread->name, result);
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
#endif
|
#endif
|
||||||
@@ -271,8 +272,10 @@ CreateThread_SDL (ThreadFunction func, void *data, SDWORD stackSize
|
|||||||
QueueThread (thread);
|
QueueThread (thread);
|
||||||
|
|
||||||
#ifdef DEBUG_THREADS
|
#ifdef DEBUG_THREADS
|
||||||
// fprintf (stderr, "Thread '%s' created.\n", ThreadName (thread));
|
#if 0
|
||||||
// fflush (stderr);
|
log_add (log_Debug, "Thread '%s' created.", ThreadName (thread));
|
||||||
|
fflush (stderr);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Signal to the new thread that the thread structure is ready
|
// Signal to the new thread that the thread structure is ready
|
||||||
@@ -358,11 +361,15 @@ CreateMutex_SDL (void)
|
|||||||
if ((mutex == NULL) || (mutex->mutex == NULL))
|
if ((mutex == NULL) || (mutex->mutex == NULL))
|
||||||
{
|
{
|
||||||
#ifdef NAMED_SYNCHRO
|
#ifdef NAMED_SYNCHRO
|
||||||
fprintf (stderr, "Could not initialize mutex '%s': aborting.\n", name);
|
/* logging depends on Mutexes, so we have to use the
|
||||||
|
* non-threaded version instead */
|
||||||
|
log_add_nothread (log_Always, "Could not initialize mutex '%s':"
|
||||||
|
"aborting.", name);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, "Could not initialize mutex: aborting.\n");
|
log_add_nothread (log_Always, "Could not initialize mutex:"
|
||||||
|
"aborting.");
|
||||||
#endif
|
#endif
|
||||||
abort ();
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mutex;
|
return mutex;
|
||||||
@@ -391,8 +398,10 @@ LockMutex_SDL (Mutex m)
|
|||||||
* CrossThreadMutex code). This almost-measure is being added
|
* CrossThreadMutex code). This almost-measure is being added
|
||||||
* because for the most part it should suffice. */
|
* because for the most part it should suffice. */
|
||||||
if (mutex->owner && (mutex->syncClass & TRACK_CONTENTION_CLASSES))
|
if (mutex->owner && (mutex->syncClass & TRACK_CONTENTION_CLASSES))
|
||||||
{
|
{ /* logging depends on Mutexes, so we have to use the
|
||||||
fprintf (stderr, "Thread '%s' blocking on mutex '%s'\n", MyThreadName (), mutex->name);
|
* non-threaded version instead */
|
||||||
|
log_add_nothread (log_Debug, "Thread '%s' blocking on mutex '%s'",
|
||||||
|
MyThreadName (), mutex->name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
while (SDL_mutexP (mutex->mutex) != 0)
|
while (SDL_mutexP (mutex->mutex) != 0)
|
||||||
@@ -443,11 +452,13 @@ CreateSemaphore_SDL (DWORD initial
|
|||||||
if (sem->sem == NULL)
|
if (sem->sem == NULL)
|
||||||
{
|
{
|
||||||
#ifdef NAMED_SYNCHRO
|
#ifdef NAMED_SYNCHRO
|
||||||
fprintf (stderr, "Could not initialize semaphore '%s': aborting.\n", name);
|
log_add (log_Always, "Could not initialize semaphore '%s':"
|
||||||
|
" aborting.", name);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, "Could not initialize semaphore: aborting.\n");
|
log_add (log_Always, "Could not initialize semaphore:"
|
||||||
|
" aborting.");
|
||||||
#endif
|
#endif
|
||||||
abort ();
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return sem;
|
return sem;
|
||||||
}
|
}
|
||||||
@@ -468,7 +479,8 @@ SetSemaphore_SDL (Semaphore s)
|
|||||||
BOOLEAN contention = !(SDL_SemValue (sem->sem));
|
BOOLEAN contention = !(SDL_SemValue (sem->sem));
|
||||||
if (contention && (sem->syncClass & TRACK_CONTENTION_CLASSES))
|
if (contention && (sem->syncClass & TRACK_CONTENTION_CLASSES))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Thread '%s' blocking on semaphore '%s'\n", MyThreadName (), sem->name);
|
log_add (log_Debug, "Thread '%s' blocking on semaphore '%s'",
|
||||||
|
MyThreadName (), sem->name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
while (SDL_SemWait (sem->sem) == -1)
|
while (SDL_SemWait (sem->sem) == -1)
|
||||||
@@ -478,7 +490,8 @@ SetSemaphore_SDL (Semaphore s)
|
|||||||
#ifdef TRACK_CONTENTION
|
#ifdef TRACK_CONTENTION
|
||||||
if (contention && (sem->syncClass & TRACK_CONTENTION_CLASSES))
|
if (contention && (sem->syncClass & TRACK_CONTENTION_CLASSES))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Thread '%s' awakens, released from semaphore '%s'\n", MyThreadName (), sem->name);
|
log_add (log_Debug, "Thread '%s' awakens,"
|
||||||
|
" released from semaphore '%s'", MyThreadName (), sem->name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -520,11 +533,13 @@ CreateRecursiveMutex_SDL (void)
|
|||||||
if (mtx->mutex == NULL)
|
if (mtx->mutex == NULL)
|
||||||
{
|
{
|
||||||
#ifdef NAMED_SYNCHRO
|
#ifdef NAMED_SYNCHRO
|
||||||
fprintf (stderr, "Could not initialize recursive mutex '%s': aborting.\n", name);
|
log_add (log_Always, "Could not initialize recursive "
|
||||||
|
"mutex '%s': aborting.", name);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, "Could not initialize recursive mutex: aborting.\n");
|
log_add (log_Always, "Could not initialize recursive "
|
||||||
|
"mutex: aborting.");
|
||||||
#endif
|
#endif
|
||||||
abort ();
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef NAMED_SYNCHRO
|
#ifdef NAMED_SYNCHRO
|
||||||
mtx->name = name;
|
mtx->name = name;
|
||||||
@@ -552,7 +567,8 @@ LockRecursiveMutex_SDL (RecursiveMutex val)
|
|||||||
#ifdef TRACK_CONTENTION
|
#ifdef TRACK_CONTENTION
|
||||||
if (mtx->thread_id && (mtx->syncClass & TRACK_CONTENTION_CLASSES))
|
if (mtx->thread_id && (mtx->syncClass & TRACK_CONTENTION_CLASSES))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Thread '%s' blocking on '%s'\n", MyThreadName (), mtx->name);
|
log_add (log_Debug, "Thread '%s' blocking on '%s'",
|
||||||
|
MyThreadName (), mtx->name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
while (SDL_mutexP (mtx->mutex))
|
while (SDL_mutexP (mtx->mutex))
|
||||||
@@ -570,7 +586,8 @@ UnlockRecursiveMutex_SDL (RecursiveMutex val)
|
|||||||
if (!mtx->locks || mtx->thread_id != thread_id)
|
if (!mtx->locks || mtx->thread_id != thread_id)
|
||||||
{
|
{
|
||||||
#ifdef NAMED_SYNCHRO
|
#ifdef NAMED_SYNCHRO
|
||||||
fprintf (stderr, "'%s' attempted to unlock %s when it didn't hold it\n", MyThreadName (), mtx->name);
|
log_add (log_Debug, "'%s' attempted to unlock %s when it "
|
||||||
|
"didn't hold it", MyThreadName (), mtx->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -613,11 +630,13 @@ CreateCondVar_SDL (void)
|
|||||||
if ((cv->cond == NULL) || (cv->mutex == NULL))
|
if ((cv->cond == NULL) || (cv->mutex == NULL))
|
||||||
{
|
{
|
||||||
#ifdef NAMED_SYNCHRO
|
#ifdef NAMED_SYNCHRO
|
||||||
fprintf (stderr, "Could not initialize condition variable '%s': aborting.\n", name);
|
log_add (log_Always, "Could not initialize condition variable '%s':"
|
||||||
|
" aborting.", name);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, "Could not initialize condition variable: aborting.\n");
|
log_add (log_Always, "Could not initialize condition variable:"
|
||||||
|
" aborting.");
|
||||||
#endif
|
#endif
|
||||||
abort ();
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef NAMED_SYNCHRO
|
#ifdef NAMED_SYNCHRO
|
||||||
cv->name = name;
|
cv->name = name;
|
||||||
@@ -643,7 +662,8 @@ WaitCondVar_SDL (CondVar c)
|
|||||||
#ifdef TRACK_CONTENTION
|
#ifdef TRACK_CONTENTION
|
||||||
if (cv->syncClass & TRACK_CONTENTION_CLASSES)
|
if (cv->syncClass & TRACK_CONTENTION_CLASSES)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Thread '%s' waiting for signal from '%s'\n", MyThreadName (), cv->name);
|
log_add (log_Debug, "Thread '%s' waiting for signal from '%s'",
|
||||||
|
MyThreadName (), cv->name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
while (SDL_CondWait (cv->cond, cv->mutex) != 0)
|
while (SDL_CondWait (cv->cond, cv->mutex) != 0)
|
||||||
@@ -653,7 +673,8 @@ WaitCondVar_SDL (CondVar c)
|
|||||||
#ifdef TRACK_CONTENTION
|
#ifdef TRACK_CONTENTION
|
||||||
if (cv->syncClass & TRACK_CONTENTION_CLASSES)
|
if (cv->syncClass & TRACK_CONTENTION_CLASSES)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Thread '%s' received signal from '%s', awakening.\n", MyThreadName (), cv->name);
|
log_add (log_Debug, "Thread '%s' received signal from '%s',"
|
||||||
|
" awakening.", MyThreadName (), cv->name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SDL_mutexV (cv->mutex);
|
SDL_mutexV (cv->mutex);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "libs/threadlib.h"
|
#include "libs/threadlib.h"
|
||||||
#include "libs/timelib.h"
|
#include "libs/timelib.h"
|
||||||
#include "libs/misc.h"
|
#include "libs/misc.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "thrcommon.h"
|
#include "thrcommon.h"
|
||||||
|
|
||||||
#define LIFECYCLE_SIZE 8
|
#define LIFECYCLE_SIZE 8
|
||||||
@@ -85,8 +86,8 @@ FlagStartThread (SpawnRequest s)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Thread Lifecycle array filled. This is a fatal error! Make LIFECYCLE_SIZE something larger than %d.\n", LIFECYCLE_SIZE);
|
log_add (log_Always, "Thread Lifecycle array filled. This is a fatal error! Make LIFECYCLE_SIZE something larger than %d.", LIFECYCLE_SIZE);
|
||||||
exit (-1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -103,8 +104,8 @@ FinishThread (Thread thread)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Thread Lifecycle array filled. This is a fatal error! Make LIFECYCLE_SIZE something larger than %d.\n", LIFECYCLE_SIZE);
|
log_add (log_Always, "Thread Lifecycle array filled. This is a fatal error! Make LIFECYCLE_SIZE something larger than %d.", LIFECYCLE_SIZE);
|
||||||
exit (-1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only call from main thread! */
|
/* Only call from main thread! */
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "videodec.h"
|
#include "videodec.h"
|
||||||
#include "dukvid.h"
|
#include "dukvid.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#define MAX_REG_DECODERS 31
|
#define MAX_REG_DECODERS 31
|
||||||
|
|
||||||
@@ -57,15 +58,15 @@ VideoDecoder_Init (int flags, int depth, uint32 Rmask, uint32 Gmask,
|
|||||||
|
|
||||||
if (depth < 15 || depth > 32)
|
if (depth < 15 || depth > 32)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Init: "
|
log_add (log_Always, "VideoDecoder_Init: "
|
||||||
"Unsupported video depth %d\n", depth);
|
"Unsupported video depth %d", depth);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Rmask & Gmask) || (Rmask & Bmask) || (Rmask & Amask) ||
|
if ((Rmask & Gmask) || (Rmask & Bmask) || (Rmask & Amask) ||
|
||||||
(Gmask & Bmask) || (Gmask & Amask) || (Bmask & Amask))
|
(Gmask & Bmask) || (Gmask & Amask) || (Bmask & Amask))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Init: Invalid channel masks\n");
|
log_add (log_Always, "VideoDecoder_Init: Invalid channel masks");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +88,8 @@ VideoDecoder_Init (int flags, int depth, uint32 Rmask, uint32 Gmask,
|
|||||||
{
|
{
|
||||||
if (!info->funcs->InitModule (flags))
|
if (!info->funcs->InitModule (flags))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Init(): "
|
log_add (log_Always, "VideoDecoder_Init(): "
|
||||||
"%s video decoder init failed\n",
|
"%s video decoder init failed",
|
||||||
info->funcs->GetName ());
|
info->funcs->GetName ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,12 +130,12 @@ VideoDecoder_Register (const char* fileext, TFB_VideoDecoderFuncs* decvtbl)
|
|||||||
|
|
||||||
if (!decvtbl)
|
if (!decvtbl)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Register(): Null decoder table\n");
|
log_add (log_Warning, "VideoDecoder_Register(): Null decoder table");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!fileext)
|
if (!fileext)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Register(): Bad file type for %s\n",
|
log_add (log_Warning, "VideoDecoder_Register(): Bad file type for %s",
|
||||||
decvtbl->GetName ());
|
decvtbl->GetName ());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -151,20 +152,20 @@ VideoDecoder_Register (const char* fileext, TFB_VideoDecoderFuncs* decvtbl)
|
|||||||
|
|
||||||
if (info >= vd_decoders + MAX_REG_DECODERS)
|
if (info >= vd_decoders + MAX_REG_DECODERS)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Register(): Decoders limit reached\n");
|
log_add (log_Warning, "VideoDecoder_Register(): Decoders limit reached");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (info->ext)
|
else if (info->ext)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Register(): "
|
log_add (log_Warning, "VideoDecoder_Register(): "
|
||||||
"'%s' decoder already registered (%s denied)\n",
|
"'%s' decoder already registered (%s denied)",
|
||||||
fileext, decvtbl->GetName ());
|
fileext, decvtbl->GetName ());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!decvtbl->InitModule (vd_flags))
|
if (!decvtbl->InitModule (vd_flags))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Register(): %s decoder init failed\n",
|
log_add (log_Warning, "VideoDecoder_Register(): %s decoder init failed",
|
||||||
decvtbl->GetName ());
|
decvtbl->GetName ());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -191,8 +192,8 @@ VideoDecoder_Unregister (TFB_RegVideoDecoder* regdec)
|
|||||||
if (regdec < vd_decoders || regdec >= vd_decoders + MAX_REG_DECODERS ||
|
if (regdec < vd_decoders || regdec >= vd_decoders + MAX_REG_DECODERS ||
|
||||||
!regdec->ext || !regdec->funcs)
|
!regdec->ext || !regdec->funcs)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Unregister(): "
|
log_add (log_Warning, "VideoDecoder_Unregister(): "
|
||||||
"Invalid or expired decoder passed\n");
|
"Invalid or expired decoder passed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +228,7 @@ VideoDecoder_Load (uio_DirHandle *dir, const char *filename)
|
|||||||
pext = strrchr (filename, '.');
|
pext = strrchr (filename, '.');
|
||||||
if (!pext)
|
if (!pext)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Load: Unknown file type\n");
|
log_add (log_Warning, "VideoDecoder_Load: Unknown file type");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
++pext;
|
++pext;
|
||||||
@@ -238,7 +239,7 @@ VideoDecoder_Load (uio_DirHandle *dir, const char *filename)
|
|||||||
;
|
;
|
||||||
if (!info->ext)
|
if (!info->ext)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Load: Unsupported file type\n");
|
log_add (log_Warning, "VideoDecoder_Load: Unsupported file type");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,8 +247,8 @@ VideoDecoder_Load (uio_DirHandle *dir, const char *filename)
|
|||||||
decoder->funcs = info->funcs;
|
decoder->funcs = info->funcs;
|
||||||
if (!decoder->funcs->Init (decoder, &vd_vidfmt))
|
if (!decoder->funcs->Init (decoder, &vd_vidfmt))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Load: "
|
log_add (log_Warning, "VideoDecoder_Load: "
|
||||||
"Cannot init '%s' decoder, code %d\n",
|
"Cannot init '%s' decoder, code %d",
|
||||||
decoder->funcs->GetName (),
|
decoder->funcs->GetName (),
|
||||||
decoder->funcs->GetError (decoder));
|
decoder->funcs->GetError (decoder));
|
||||||
HFree (decoder);
|
HFree (decoder);
|
||||||
@@ -261,8 +262,8 @@ VideoDecoder_Load (uio_DirHandle *dir, const char *filename)
|
|||||||
|
|
||||||
if (!decoder->funcs->Open (decoder, dir, filename))
|
if (!decoder->funcs->Open (decoder, dir, filename))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "VideoDecoder_Load: "
|
log_add (log_Warning, "VideoDecoder_Load: "
|
||||||
"'%s' decoder did not load %s, code %d\n",
|
"'%s' decoder did not load %s, code %d",
|
||||||
decoder->funcs->GetName (), filename,
|
decoder->funcs->GetName (), filename,
|
||||||
decoder->funcs->GetError (decoder));
|
decoder->funcs->GetError (decoder));
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "sounds.h"
|
#include "sounds.h"
|
||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/graphics/tfb_draw.h"
|
#include "libs/graphics/tfb_draw.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
// video callbacks
|
// video callbacks
|
||||||
static void* vp_GetCanvasLine (TFB_VideoDecoder*, uint32 line);
|
static void* vp_GetCanvasLine (TFB_VideoDecoder*, uint32 line);
|
||||||
@@ -324,8 +324,8 @@ TFB_PlayVideo (VIDEO_REF VidRef, uint32 x, uint32 y)
|
|||||||
|
|
||||||
if (!vid->hAudio)
|
if (!vid->hAudio)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "TFB_PlayVideo: "
|
log_add (log_Warning, "TFB_PlayVideo: "
|
||||||
"Cannot load sound-track for audio-synced video\n");
|
"Cannot load sound-track for audio-synced video");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
//#define DEBUG_LOAD
|
//#define DEBUG_LOAD
|
||||||
|
|
||||||
@@ -172,8 +172,8 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc)
|
|||||||
1 /* time to destroy all races, plenty */ +
|
1 /* time to destroy all races, plenty */ +
|
||||||
25 /* for cheaters */)
|
25 /* for cheaters */)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Warning: Savegame corrupt or from an "
|
log_add (log_Always, "Warning: Savegame corrupt or from an "
|
||||||
"an incompatible platform.\n");
|
"an incompatible platform.");
|
||||||
res_CloseResFile (in_fp);
|
res_CloseResFile (in_fp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc)
|
|||||||
// But if it does happen, it needs to be reset to 0, since on load
|
// But if it does happen, it needs to be reset to 0, since on load
|
||||||
// the clock semaphore is gauranteed to be 0
|
// the clock semaphore is gauranteed to be 0
|
||||||
if (GLOBAL (GameClock.TimeCounter) != 0)
|
if (GLOBAL (GameClock.TimeCounter) != 0)
|
||||||
fprintf (stderr, "Warning: Game clock wasn't stopped during "
|
log_add (log_Always, "Warning: Game clock wasn't stopped during "
|
||||||
"save, Savegame may be corrupt!\n");
|
"save, Savegame may be corrupt!\n");
|
||||||
GLOBAL (GameClock.TimeCounter) = 0;
|
GLOBAL (GameClock.TimeCounter) = 0;
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc)
|
|||||||
cread ((PBYTE)&num_links, sizeof (num_links), 1, fh);
|
cread ((PBYTE)&num_links, sizeof (num_links), 1, fh);
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_LOAD
|
#ifdef DEBUG_LOAD
|
||||||
fprintf (stderr, "EVENTS:\n");
|
log_add (log_Debug, "EVENTS:");
|
||||||
#endif /* DEBUG_LOAD */
|
#endif /* DEBUG_LOAD */
|
||||||
while (num_links--)
|
while (num_links--)
|
||||||
{
|
{
|
||||||
@@ -243,7 +243,7 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc)
|
|||||||
cread ((PBYTE)EventPtr, sizeof (*EventPtr), 1, fh);
|
cread ((PBYTE)EventPtr, sizeof (*EventPtr), 1, fh);
|
||||||
|
|
||||||
#ifdef DEBUG_LOAD
|
#ifdef DEBUG_LOAD
|
||||||
fprintf (stderr, "\t%u/%u/%u -- %u\n",
|
log_add (log_Debug, "\t%u/%u/%u -- %u",
|
||||||
EventPtr->month_index,
|
EventPtr->month_index,
|
||||||
EventPtr->day_index,
|
EventPtr->day_index,
|
||||||
EventPtr->year_index,
|
EventPtr->year_index,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "libs/gfxlib.h"
|
#include "libs/gfxlib.h"
|
||||||
#include "libs/inplib.h"
|
#include "libs/inplib.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -1061,14 +1062,14 @@ GetNewList:
|
|||||||
{
|
{
|
||||||
BOOLEAN deleteStatus;
|
BOOLEAN deleteStatus;
|
||||||
|
|
||||||
fprintf (stderr, "Could not load '%s'\n", file);
|
log_add (log_Always, "Could not load '%s'", file);
|
||||||
|
|
||||||
deleteStatus = DeleteResFile (meleeDir, file);
|
deleteStatus = DeleteResFile (meleeDir, file);
|
||||||
if (deleteStatus == FALSE)
|
if (deleteStatus == FALSE)
|
||||||
{
|
{
|
||||||
// XXX: see bug #823
|
// XXX: see bug #823
|
||||||
fprintf (stderr, "FATAL: Could not delete '%s'\n", file);
|
log_add (log_Always, "FATAL: Could not delete '%s'", file);
|
||||||
abort ();
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
goto GetNewList;
|
goto GetNewList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "gamestr.h"
|
#include "gamestr.h"
|
||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
extern Task flash_task;
|
extern Task flash_task;
|
||||||
extern RECT flash_rect;
|
extern RECT flash_rect;
|
||||||
@@ -79,7 +79,7 @@ DrawPCMenu (BYTE beg_index, BYTE end_index, BYTE NewState, BYTE hilite, RECT *r)
|
|||||||
r->extent.width += 1;
|
r->extent.width += 1;
|
||||||
DrawFilledRectangle (r);
|
DrawFilledRectangle (r);
|
||||||
if (num_items * PC_MENU_HEIGHT > r->extent.height)
|
if (num_items * PC_MENU_HEIGHT > r->extent.height)
|
||||||
fprintf (stderr, "Warning, no room for all menu items!\n");
|
log_add (log_Always, "Warning, no room for all menu items!");
|
||||||
else
|
else
|
||||||
r->corner.y += (r->extent.height - num_items * PC_MENU_HEIGHT) / 2;
|
r->corner.y += (r->extent.height - num_items * PC_MENU_HEIGHT) / 2;
|
||||||
r->extent.height = num_items * PC_MENU_HEIGHT + 4;
|
r->extent.height = num_items * PC_MENU_HEIGHT + 4;
|
||||||
@@ -284,7 +284,8 @@ GetAlternateMenu (BYTE *BaseState, BYTE *CurState)
|
|||||||
*CurState = PM_ALT_EXITMENU0 - PM_ALT_CARGO;
|
*CurState = PM_ALT_EXITMENU0 - PM_ALT_CARGO;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Unknown state combination: %d, %d\n",*BaseState, *CurState);
|
log_add (log_Always, "Unknown state combination: %d, %d",
|
||||||
|
*BaseState, *CurState);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
/* ----------------------------- INCLUDES ---------------------------- */
|
/* ----------------------------- INCLUDES ---------------------------- */
|
||||||
#include "encount.h"
|
#include "encount.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
/* -------------------------------- DATA -------------------------------- */
|
/* -------------------------------- DATA -------------------------------- */
|
||||||
|
|
||||||
/* -------------------------------- CODE -------------------------------- */
|
/* -------------------------------- CODE -------------------------------- */
|
||||||
@@ -259,10 +260,10 @@ DoPlanetaryAnalysis (SYSTEM_INFOPTR SysInfoPtr, PPLANET_DESC
|
|||||||
"Supergiant",
|
"Supergiant",
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf (stderr, "%s %s\n",
|
log_add (log_Debug, "%s %s",
|
||||||
ColorClass[SysInfoPtr->StarIntensity],
|
ColorClass[SysInfoPtr->StarIntensity],
|
||||||
SizeName[SysInfoPtr->StarSize]);
|
SizeName[SysInfoPtr->StarSize]);
|
||||||
fprintf (stderr, "Stellar Energy: %d (sol = 3)\n",
|
log_add (log_Debug, "Stellar Energy: %d (sol = 3)",
|
||||||
SysInfoPtr->StarEnergy);
|
SysInfoPtr->StarEnergy);
|
||||||
}
|
}
|
||||||
#endif /* DEBUG_PLANET_CALC */
|
#endif /* DEBUG_PLANET_CALC */
|
||||||
@@ -344,62 +345,62 @@ DoPlanetaryAnalysis (SYSTEM_INFOPTR SysInfoPtr, PPLANET_DESC
|
|||||||
|
|
||||||
#ifdef DEBUG_PLANET_CALC
|
#ifdef DEBUG_PLANET_CALC
|
||||||
radius = (SIZE)((DWORD)UNSCALE_RADIUS (radius) * 100 / UNSCALE_RADIUS (EARTH_RADIUS));
|
radius = (SIZE)((DWORD)UNSCALE_RADIUS (radius) * 100 / UNSCALE_RADIUS (EARTH_RADIUS));
|
||||||
fprintf (stderr, "\tOrbital Distance : %d.%02d AU\n", radius / 100, radius % 100);
|
log_add (log_Debug, "\tOrbital Distance : %d.%02d AU", radius / 100, radius % 100);
|
||||||
//fprintf (stderr, "\tPlanetary Mass : %d.%02d Earth masses\n",
|
//log_add (log_Debug, "\tPlanetary Mass : %d.%02d Earth masses",
|
||||||
// SysInfoPtr->PlanetInfo.PlanetMass / 100,
|
// SysInfoPtr->PlanetInfo.PlanetMass / 100,
|
||||||
// SysInfoPtr->PlanetInfo.PlanetMass % 100);
|
// SysInfoPtr->PlanetInfo.PlanetMass % 100);
|
||||||
fprintf (stderr, "\tPlanetary Radius : %d.%02d Earth radii\n",
|
log_add (log_Debug, "\tPlanetary Radius : %d.%02d Earth radii",
|
||||||
SysInfoPtr->PlanetInfo.PlanetRadius / 100,
|
SysInfoPtr->PlanetInfo.PlanetRadius / 100,
|
||||||
SysInfoPtr->PlanetInfo.PlanetRadius % 100);
|
SysInfoPtr->PlanetInfo.PlanetRadius % 100);
|
||||||
fprintf (stderr, "\tSurface Gravity: %d.%02d gravities\n",
|
log_add (log_Debug, "\tSurface Gravity: %d.%02d gravities",
|
||||||
SysInfoPtr->PlanetInfo.SurfaceGravity / 100,
|
SysInfoPtr->PlanetInfo.SurfaceGravity / 100,
|
||||||
SysInfoPtr->PlanetInfo.SurfaceGravity % 100);
|
SysInfoPtr->PlanetInfo.SurfaceGravity % 100);
|
||||||
fprintf (stderr, "\tSurface Temperature: %d degrees C\n",
|
log_add (log_Debug, "\tSurface Temperature: %d degrees C",
|
||||||
SysInfoPtr->PlanetInfo.SurfaceTemperature );
|
SysInfoPtr->PlanetInfo.SurfaceTemperature );
|
||||||
fprintf (stderr, "\tAxial Tilt : %d degrees\n",
|
log_add (log_Debug, "\tAxial Tilt : %d degrees",
|
||||||
abs (SysInfoPtr->PlanetInfo.AxialTilt));
|
abs (SysInfoPtr->PlanetInfo.AxialTilt));
|
||||||
fprintf (stderr, "\tTectonics : Class %u\n",
|
log_add (log_Debug, "\tTectonics : Class %u",
|
||||||
SysInfoPtr->PlanetInfo.Tectonics + 1);
|
SysInfoPtr->PlanetInfo.Tectonics + 1);
|
||||||
fprintf (stderr, "\tAtmospheric Density: %u.%02u ",
|
log_add (log_Debug, "\tAtmospheric Density: %u.%02u",
|
||||||
SysInfoPtr->PlanetInfo.AtmoDensity / EARTH_ATMOSPHERE,
|
SysInfoPtr->PlanetInfo.AtmoDensity / EARTH_ATMOSPHERE,
|
||||||
(SysInfoPtr->PlanetInfo.AtmoDensity * 100 / EARTH_ATMOSPHERE) % 100);
|
(SysInfoPtr->PlanetInfo.AtmoDensity * 100 / EARTH_ATMOSPHERE) % 100);
|
||||||
if (SysInfoPtr->PlanetInfo.AtmoDensity == 0)
|
if (SysInfoPtr->PlanetInfo.AtmoDensity == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "(Vacuum)\n");
|
log_add (log_Debug, "\tAtmosphere: (Vacuum)");
|
||||||
}
|
}
|
||||||
else if (SysInfoPtr->PlanetInfo.AtmoDensity < THIN_ATMOSPHERE)
|
else if (SysInfoPtr->PlanetInfo.AtmoDensity < THIN_ATMOSPHERE)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "(Thin)\n");
|
log_add (log_Debug, "\tAtmosphere: (Thin)");
|
||||||
}
|
}
|
||||||
else if (SysInfoPtr->PlanetInfo.AtmoDensity < NORMAL_ATMOSPHERE)
|
else if (SysInfoPtr->PlanetInfo.AtmoDensity < NORMAL_ATMOSPHERE)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "(Normal)\n");
|
log_add (log_Debug, "\tAtmosphere: (Normal)");
|
||||||
}
|
}
|
||||||
else if (SysInfoPtr->PlanetInfo.AtmoDensity < THICK_ATMOSPHERE)
|
else if (SysInfoPtr->PlanetInfo.AtmoDensity < THICK_ATMOSPHERE)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "(Thick)\n");
|
log_add (log_Debug, "\tAtmosphere: (Thick)");
|
||||||
}
|
}
|
||||||
else if (SysInfoPtr->PlanetInfo.AtmoDensity < SUPER_THICK_ATMOSPHERE)
|
else if (SysInfoPtr->PlanetInfo.AtmoDensity < SUPER_THICK_ATMOSPHERE)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "(Super thick)\n");
|
log_add (log_Debug, "\tAtmosphere: (Super thick)");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "(Gas Giant atmosphere)\n");
|
log_add (log_Debug, "\tAtmosphere: (Gas Giant)");
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "\tWeather : Class %u\n",
|
log_add (log_Debug, "\tWeather : Class %u",
|
||||||
SysInfoPtr->PlanetInfo.Weather + 1);
|
SysInfoPtr->PlanetInfo.Weather + 1);
|
||||||
|
|
||||||
if (SysInfoPtr->PlanetInfo.RotationPeriod >= 480)
|
if (SysInfoPtr->PlanetInfo.RotationPeriod >= 480)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\tLength of day : %d.%d Earth days\n",
|
log_add (log_Debug, "\tLength of day : %d.%d Earth days",
|
||||||
SysInfoPtr->PlanetInfo.RotationPeriod / 240,
|
SysInfoPtr->PlanetInfo.RotationPeriod / 240,
|
||||||
SysInfoPtr->PlanetInfo.RotationPeriod % 240);
|
SysInfoPtr->PlanetInfo.RotationPeriod % 240);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\tLength of day : %d.%d Earth hours\n",
|
log_add (log_Debug, "\tLength of day : %d.%d Earth hours",
|
||||||
SysInfoPtr->PlanetInfo.RotationPeriod / 10,
|
SysInfoPtr->PlanetInfo.RotationPeriod / 10,
|
||||||
SysInfoPtr->PlanetInfo.RotationPeriod % 10);
|
SysInfoPtr->PlanetInfo.RotationPeriod % 10);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "planets/planets.h"
|
#include "planets/planets.h"
|
||||||
#include "libs/compiler.h"
|
#include "libs/compiler.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_ORBITS
|
//#define DEBUG_ORBITS
|
||||||
@@ -506,7 +507,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'};
|
|||||||
|
|
||||||
#ifdef DEBUG_ORBITS
|
#ifdef DEBUG_ORBITS
|
||||||
GetClusterName (CurStarDescPtr, buf);
|
GetClusterName (CurStarDescPtr, buf);
|
||||||
fprintf (stderr, "cluster name = %s color = %c type = %c\n", buf,
|
log_add (log_Debug, "cluster name = %s color = %c type = %c", buf,
|
||||||
scolor[STAR_COLOR (CurStarDescPtr->Type)],
|
scolor[STAR_COLOR (CurStarDescPtr->Type)],
|
||||||
stype[STAR_TYPE (CurStarDescPtr->Type)]);
|
stype[STAR_TYPE (CurStarDescPtr->Type)]);
|
||||||
#endif /* DEBUG_ORBITS */
|
#endif /* DEBUG_ORBITS */
|
||||||
|
|||||||
@@ -25,12 +25,12 @@
|
|||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/graphics/drawable.h"
|
#include "libs/graphics/drawable.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
#define PROFILE 1
|
#define PROFILE_ROTATION 1
|
||||||
#define ROTATION_TIME 12
|
#define ROTATION_TIME 12
|
||||||
|
|
||||||
// The initial size of the planet when zooming. MUST BE ODD
|
// The initial size of the planet when zooming. MUST BE ODD
|
||||||
@@ -748,7 +748,7 @@ RenderLevelMasks (FRAME MaskFrame, int offset, BOOLEAN doThrob)
|
|||||||
SBYTE *elevs;
|
SBYTE *elevs;
|
||||||
int shLevel;
|
int shLevel;
|
||||||
|
|
||||||
#if PROFILE
|
#if PROFILE_ROTATION
|
||||||
static clock_t t = 0;
|
static clock_t t = 0;
|
||||||
static int frames_done = 1;
|
static int frames_done = 1;
|
||||||
clock_t t1;
|
clock_t t1;
|
||||||
@@ -851,11 +851,12 @@ RenderLevelMasks (FRAME MaskFrame, int offset, BOOLEAN doThrob)
|
|||||||
process_rgb_bmp (MaskFrame, rgba, DIAMETER, DIAMETER);
|
process_rgb_bmp (MaskFrame, rgba, DIAMETER, DIAMETER);
|
||||||
SetFrameHot (MaskFrame, MAKE_HOT_SPOT (RADIUS + 1, RADIUS + 1));
|
SetFrameHot (MaskFrame, MAKE_HOT_SPOT (RADIUS + 1, RADIUS + 1));
|
||||||
|
|
||||||
#if PROFILE
|
#if PROFILE_ROTATION
|
||||||
t += clock() - t1;
|
t += clock() - t1;
|
||||||
if (frames_done == MAP_WIDTH)
|
if (frames_done == MAP_WIDTH)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "frames/sec: %d/%ld(msec)=%f\n", frames_done,
|
log_add (log_Debug, "Rotation frames/sec: %d/%ld(msec)=%f",
|
||||||
|
frames_done,
|
||||||
(long int) (((double)t / CLOCKS_PER_SEC) * 1000.0 + 0.5),
|
(long int) (((double)t / CLOCKS_PER_SEC) * 1000.0 + 0.5),
|
||||||
frames_done / ((double)t / CLOCKS_PER_SEC + 0.5));
|
frames_done / ((double)t / CLOCKS_PER_SEC + 0.5));
|
||||||
frames_done = 1;
|
frames_done = 1;
|
||||||
@@ -2121,8 +2122,8 @@ rotate_planet_task (void *data)
|
|||||||
frame_num++;
|
frame_num++;
|
||||||
if (frame_num > zoom_frames)
|
if (frame_num > zoom_frames)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "rotate_planet_task() : zoom frame "
|
log_add (log_Warning, "rotate_planet_task() : zoom frame"
|
||||||
"out of bounds!\n");
|
" out of bounds!");
|
||||||
frame_num = zoom_frames;
|
frame_num = zoom_frames;
|
||||||
}
|
}
|
||||||
zoom_amt = zoom_arr[frame_num];
|
zoom_amt = zoom_arr[frame_num];
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
#include "libs/inplib.h"
|
#include "libs/inplib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_SOLARSYS
|
//#define DEBUG_SOLARSYS
|
||||||
@@ -390,7 +391,8 @@ FreeSolarSys (void)
|
|||||||
{
|
{
|
||||||
if (pSolarSysState->MenuState.flash_task != (Task)(~0))
|
if (pSolarSysState->MenuState.flash_task != (Task)(~0))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "DIAGNOSTIC: FreeSolarSys cancels a flash_task that wasn't the placeholder for IP flight\n");
|
log_add (log_Warning, "DIAGNOSTIC: FreeSolarSys cancels a "
|
||||||
|
"flash_task that wasn't the placeholder for IP flight");
|
||||||
ConcludeTask (pSolarSysState->MenuState.flash_task);
|
ConcludeTask (pSolarSysState->MenuState.flash_task);
|
||||||
}
|
}
|
||||||
pSolarSysState->MenuState.flash_task = 0;
|
pSolarSysState->MenuState.flash_task = 0;
|
||||||
@@ -445,7 +447,10 @@ CheckIntersect (BOOLEAN just_checking)
|
|||||||
{
|
{
|
||||||
PlanetOffset = pCurDesc - pSolarSysState->PlanetDesc + 1;
|
PlanetOffset = pCurDesc - pSolarSysState->PlanetDesc + 1;
|
||||||
MoonOffset = 1;
|
MoonOffset = 1;
|
||||||
//fprintf (stderr, "0: Planet %d, Moon %d\n", PlanetOffset, MoonOffset);
|
#ifdef DEBUG_SOLARSYS
|
||||||
|
log_add (log_Debug, "0: Planet %d, Moon %d", PlanetOffset,
|
||||||
|
MoonOffset);
|
||||||
|
#endif /* DEBUG_SOLARSYS */
|
||||||
NewWaitPlanet = MAKE_WORD (PlanetOffset, MoonOffset);
|
NewWaitPlanet = MAKE_WORD (PlanetOffset, MoonOffset);
|
||||||
if (pSolarSysState->WaitIntersect != (COUNT)~0
|
if (pSolarSysState->WaitIntersect != (COUNT)~0
|
||||||
&& pSolarSysState->WaitIntersect != NewWaitPlanet)
|
&& pSolarSysState->WaitIntersect != NewWaitPlanet)
|
||||||
@@ -461,7 +466,7 @@ ShowPlanet:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_SOLARSYS
|
#ifdef DEBUG_SOLARSYS
|
||||||
fprintf (stderr, "Star index = %d, Planet index = %d, <%d, %d>\n",
|
log_add (log_Debug, "Star index = %d, Planet index = %d, <%d, %d>",
|
||||||
CurStarDescPtr - star_array,
|
CurStarDescPtr - star_array,
|
||||||
pCurDesc - pSolarSysState->PlanetDesc,
|
pCurDesc - pSolarSysState->PlanetDesc,
|
||||||
pSolarSysState->SunDesc[0].location.x,
|
pSolarSysState->SunDesc[0].location.x,
|
||||||
@@ -499,7 +504,10 @@ ShowPlanet:
|
|||||||
if (DrawablesIntersect (&ShipIntersect,
|
if (DrawablesIntersect (&ShipIntersect,
|
||||||
&PlanetIntersect, MAX_TIME_VALUE))
|
&PlanetIntersect, MAX_TIME_VALUE))
|
||||||
{
|
{
|
||||||
// fprintf (stderr, "1: Planet %d, Moon %d\n", PlanetOffset, MoonOffset);
|
#ifdef DEBUG_SOLARSYS
|
||||||
|
log_add (log_Debug, "1: Planet %d, Moon %d", PlanetOffset,
|
||||||
|
MoonOffset);
|
||||||
|
#endif /* DEBUG_SOLARSYS */
|
||||||
NewWaitPlanet = MAKE_WORD (PlanetOffset, MoonOffset);
|
NewWaitPlanet = MAKE_WORD (PlanetOffset, MoonOffset);
|
||||||
|
|
||||||
if (pSolarSysState->WaitIntersect == (COUNT)~0)
|
if (pSolarSysState->WaitIntersect == (COUNT)~0)
|
||||||
@@ -1594,11 +1602,11 @@ GenerateRandomIP (BYTE control)
|
|||||||
#ifdef DEBUG_SOLARSYS
|
#ifdef DEBUG_SOLARSYS
|
||||||
if (pSolarSysState->pOrbitalDesc->pPrevDesc ==
|
if (pSolarSysState->pOrbitalDesc->pPrevDesc ==
|
||||||
pSolarSysState->SunDesc)
|
pSolarSysState->SunDesc)
|
||||||
fprintf (stderr, "Planet index = %d\n",
|
log_add (log_Debug, "Planet index = %d",
|
||||||
pSolarSysState->pOrbitalDesc -
|
pSolarSysState->pOrbitalDesc -
|
||||||
pSolarSysState->PlanetDesc);
|
pSolarSysState->PlanetDesc);
|
||||||
else
|
else
|
||||||
fprintf (stderr, "Planet index = %d, Moon index = %d\n",
|
log_add (log_Debug, "Planet index = %d, Moon index = %d",
|
||||||
pSolarSysState->pOrbitalDesc->pPrevDesc -
|
pSolarSysState->pOrbitalDesc->pPrevDesc -
|
||||||
pSolarSysState->PlanetDesc,
|
pSolarSysState->PlanetDesc,
|
||||||
pSolarSysState->pOrbitalDesc -
|
pSolarSysState->pOrbitalDesc -
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "lifeform.h"
|
#include "lifeform.h"
|
||||||
#include "planets.h"
|
#include "planets.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_SURFACE
|
//#define DEBUG_SURFACE
|
||||||
@@ -77,7 +78,7 @@ CalcMineralDeposits (SYSTEM_INFOPTR SysInfoPtr, COUNT which_deposit)
|
|||||||
);
|
);
|
||||||
SysInfoPtr->PlanetInfo.CurType = eptr->ElementType;
|
SysInfoPtr->PlanetInfo.CurType = eptr->ElementType;
|
||||||
#ifdef DEBUG_SURFACE
|
#ifdef DEBUG_SURFACE
|
||||||
fprintf (stderr, "\t\t%d units of %Fs\n",
|
log_add (log_Debug, "\t\t%d units of %Fs",
|
||||||
SysInfoPtr->PlanetInfo.CurDensity,
|
SysInfoPtr->PlanetInfo.CurDensity,
|
||||||
Elements[eptr->ElementType].name);
|
Elements[eptr->ElementType].name);
|
||||||
#endif /* DEBUG_SURFACE */
|
#endif /* DEBUG_SURFACE */
|
||||||
@@ -241,7 +242,7 @@ CalcLifeForms (SYSTEM_INFOPTR SysInfoPtr, COUNT which_life)
|
|||||||
}
|
}
|
||||||
#ifdef DEBUG_SURFACE
|
#ifdef DEBUG_SURFACE
|
||||||
else
|
else
|
||||||
fprintf (stderr, "It's dead, Jim! (%d >= %d)\n", life_var,
|
log_add (log_Debug, "It's dead, Jim! (%d >= %d)", life_var,
|
||||||
SysInfoPtr->PlanetInfo.LifeChance);
|
SysInfoPtr->PlanetInfo.LifeChance);
|
||||||
#endif /* DEBUG_SURFACE */
|
#endif /* DEBUG_SURFACE */
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -27,7 +27,7 @@
|
|||||||
#include "libs/graphics/drawable.h"
|
#include "libs/graphics/drawable.h"
|
||||||
#include "libs/graphics/drawcmd.h"
|
#include "libs/graphics/drawcmd.h"
|
||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
//#define DEBUG_PROCESS
|
//#define DEBUG_PROCESS
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ CalcReduction (SIZE dx, SIZE dy)
|
|||||||
COUNT next_reduction;
|
COUNT next_reduction;
|
||||||
|
|
||||||
#ifdef KDEBUG
|
#ifdef KDEBUG
|
||||||
fprintf (stderr, "CalcReduction:\n");
|
log_add (log_Debug, "CalcReduction:");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (optMeleeScale == TFB_SCALE_STEP)
|
if (optMeleeScale == TFB_SCALE_STEP)
|
||||||
@@ -263,7 +263,7 @@ CalcReduction (SIZE dx, SIZE dy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KDEBUG
|
#ifdef KDEBUG
|
||||||
fprintf (stderr, "CalcReduction: exit\n");
|
log_add (log_Debug, "CalcReduction: exit");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (next_reduction);
|
return (next_reduction);
|
||||||
@@ -277,7 +277,7 @@ CalcView (PPOINT pNewScrollPt, SIZE next_reduction,
|
|||||||
VIEW_STATE view_state;
|
VIEW_STATE view_state;
|
||||||
|
|
||||||
#ifdef KDEBUG
|
#ifdef KDEBUG
|
||||||
fprintf (stderr, "CalcView:\n");
|
log_add (log_Debug, "CalcView:");
|
||||||
#endif
|
#endif
|
||||||
dx = ((COORD)(LOG_SPACE_WIDTH >> 1) - pNewScrollPt->x);
|
dx = ((COORD)(LOG_SPACE_WIDTH >> 1) - pNewScrollPt->x);
|
||||||
dy = ((COORD)(LOG_SPACE_HEIGHT >> 1) - pNewScrollPt->y);
|
dy = ((COORD)(LOG_SPACE_HEIGHT >> 1) - pNewScrollPt->y);
|
||||||
@@ -340,7 +340,7 @@ CalcView (PPOINT pNewScrollPt, SIZE next_reduction,
|
|||||||
*pdy = dy;
|
*pdy = dy;
|
||||||
|
|
||||||
#ifdef KDEBUG
|
#ifdef KDEBUG
|
||||||
fprintf (stderr, "CalcView: exit\n");
|
log_add (log_Debug, "CalcView: exit");
|
||||||
#endif
|
#endif
|
||||||
return (view_state);
|
return (view_state);
|
||||||
}
|
}
|
||||||
@@ -388,7 +388,7 @@ ProcessCollisions (HELEMENT hSuccElement, ELEMENTPTR ElementPtr,
|
|||||||
&& !((state_flags | test_state_flags) & FINITE_LIFE))
|
&& !((state_flags | test_state_flags) & FINITE_LIFE))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
fprintf (stderr, "BAD NEWS 0x%x <--> 0x%x\n", ElementPtr,
|
log_add (log_Debug, "BAD NEWS 0x%x <--> 0x%x", ElementPtr,
|
||||||
TestElementPtr);
|
TestElementPtr);
|
||||||
#endif /* DEBUG_PROCESS */
|
#endif /* DEBUG_PROCESS */
|
||||||
if (state_flags & COLLISION)
|
if (state_flags & COLLISION)
|
||||||
@@ -510,7 +510,7 @@ ProcessCollisions (HELEMENT hSuccElement, ELEMENTPTR ElementPtr,
|
|||||||
POINT SavePt, TestSavePt;
|
POINT SavePt, TestSavePt;
|
||||||
|
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
fprintf (stderr, "0x%x <--> 0x%x at %u\n", ElementPtr,
|
log_add (log_Debug, "0x%x <--> 0x%x at %u", ElementPtr,
|
||||||
TestElementPtr, time_val);
|
TestElementPtr, time_val);
|
||||||
#endif /* DEBUG_PROCESS */
|
#endif /* DEBUG_PROCESS */
|
||||||
SavePt = ElementPtr->IntersectControl.EndPoint;
|
SavePt = ElementPtr->IntersectControl.EndPoint;
|
||||||
@@ -532,7 +532,7 @@ ProcessCollisions (HELEMENT hSuccElement, ELEMENTPTR ElementPtr,
|
|||||||
test_state_flags = TestElementPtr->state_flags;
|
test_state_flags = TestElementPtr->state_flags;
|
||||||
|
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
fprintf (stderr, "PROCESSING 0x%x <--> 0x%x at %u\n",
|
log_add (log_Debug, "PROCESSING 0x%x <--> 0x%x at %u",
|
||||||
ElementPtr, TestElementPtr, time_val);
|
ElementPtr, TestElementPtr, time_val);
|
||||||
#endif /* DEBUG_PROCESS */
|
#endif /* DEBUG_PROCESS */
|
||||||
if (test_state_flags & PLAYER_SHIP)
|
if (test_state_flags & PLAYER_SHIP)
|
||||||
@@ -625,7 +625,7 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
|||||||
COUNT ships_alive;
|
COUNT ships_alive;
|
||||||
|
|
||||||
#ifdef KDEBUG
|
#ifdef KDEBUG
|
||||||
fprintf (stderr, "PreProcess:\n");
|
log_add (log_Debug, "PreProcess:");
|
||||||
#endif
|
#endif
|
||||||
num_ships = (LOBYTE (battle_counter) ? 1 : 0)
|
num_ships = (LOBYTE (battle_counter) ? 1 : 0)
|
||||||
+ (HIBYTE (battle_counter) ? 1 : 0);
|
+ (HIBYTE (battle_counter) ? 1 : 0);
|
||||||
@@ -710,7 +710,7 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
|||||||
|| reduction < min_reduction)
|
|| reduction < min_reduction)
|
||||||
min_reduction = reduction;
|
min_reduction = reduction;
|
||||||
}
|
}
|
||||||
// fprintf (stderr, "dx = %d dy = %d min_red = %d max_red = %d\n",
|
// log_add (log_Debug, "dx = %d dy = %d min_red = %d max_red = %d",
|
||||||
// dx, dy, min_reduction, max_reduction);
|
// dx, dy, min_reduction, max_reduction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,7 +729,7 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KDEBUG
|
#ifdef KDEBUG
|
||||||
fprintf (stderr, "PreProcess: exit\n");
|
log_add (log_Debug, "PreProcess: exit");
|
||||||
#endif
|
#endif
|
||||||
return (CalcView (&Origin, min_reduction, pscroll_x, pscroll_y, ships_alive));
|
return (CalcView (&Origin, min_reduction, pscroll_x, pscroll_y, ships_alive));
|
||||||
}
|
}
|
||||||
@@ -793,7 +793,7 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
|||||||
HELEMENT hElement;
|
HELEMENT hElement;
|
||||||
|
|
||||||
#ifdef KDEBUG
|
#ifdef KDEBUG
|
||||||
fprintf (stderr, "PostProcess:\n");
|
log_add (log_Debug, "PostProcess:");
|
||||||
#endif
|
#endif
|
||||||
if (optMeleeScale == TFB_SCALE_STEP)
|
if (optMeleeScale == TFB_SCALE_STEP)
|
||||||
reduction = zoom_out + ONE_SHIFT;
|
reduction = zoom_out + ONE_SHIFT;
|
||||||
@@ -976,7 +976,7 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
|||||||
hElement = hNextElement;
|
hElement = hNextElement;
|
||||||
}
|
}
|
||||||
#ifdef KDEBUG
|
#ifdef KDEBUG
|
||||||
fprintf (stderr, "PostProcess: exit\n");
|
log_add (log_Debug, "PostProcess: exit");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "libs/inplib.h"
|
#include "libs/inplib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -321,11 +322,13 @@ RetrySave:
|
|||||||
mem_release (h);
|
mem_release (h);
|
||||||
|
|
||||||
FreeSC2Data ();
|
FreeSC2Data ();
|
||||||
// fprintf (stderr, "Insufficient room for save buffers -- RETRYING\n");
|
log_add (log_Debug, "Insufficient room for save buffers"
|
||||||
|
" -- RETRYING");
|
||||||
goto RetrySave;
|
goto RetrySave;
|
||||||
}
|
}
|
||||||
// else
|
else
|
||||||
// fprintf (stderr, "Insufficient room for save buffers -- GIVING UP!\n");
|
log_add (log_Debug, "Insufficient room for save buffers"
|
||||||
|
" -- GIVING UP!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -481,7 +484,8 @@ RetrySave:
|
|||||||
|
|
||||||
// Write the memory file to the actual savegame file.
|
// Write the memory file to the actual savegame file.
|
||||||
sprintf (file, "starcon2.%02u", which_game);
|
sprintf (file, "starcon2.%02u", which_game);
|
||||||
// fprintf (stderr, "'%s' is %lu bytes long\n", file, flen + sizeof (*summary_desc));
|
log_add (log_Debug, "'%s' is %lu bytes long", file,
|
||||||
|
flen + sizeof (*summary_desc));
|
||||||
if (flen && (out_fp = (PVOID)res_OpenResFile (saveDir, file, "wb")))
|
if (flen && (out_fp = (PVOID)res_OpenResFile (saveDir, file, "wb")))
|
||||||
{
|
{
|
||||||
PrepareSummary (summary_desc);
|
PrepareSummary (summary_desc);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/threadlib.h"
|
#include "libs/threadlib.h"
|
||||||
#include "libs/vidlib.h"
|
#include "libs/vidlib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -238,8 +239,9 @@ initIO (void)
|
|||||||
repository = uio_openRepository (0);
|
repository = uio_openRepository (0);
|
||||||
|
|
||||||
rootDir = uio_openDir (repository, "/", 0);
|
rootDir = uio_openDir (repository, "/", 0);
|
||||||
if (rootDir == NULL) {
|
if (rootDir == NULL)
|
||||||
fprintf(stderr, "Could not open '/' dir.\n");
|
{
|
||||||
|
log_add (log_Always, "Could not open '/' dir.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -253,5 +255,3 @@ uninitIO (void)
|
|||||||
uio_unInit ();
|
uio_unInit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+33
-31
@@ -30,6 +30,7 @@
|
|||||||
#include "libs/reslib.h"
|
#include "libs/reslib.h"
|
||||||
#include "libs/sound/sound.h"
|
#include "libs/sound/sound.h"
|
||||||
#include "libs/resource/stringbank.h"
|
#include "libs/resource/stringbank.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "resinst.h"
|
#include "resinst.h"
|
||||||
#include "nameref.h"
|
#include "nameref.h"
|
||||||
|
|
||||||
@@ -425,8 +426,8 @@ init_widgets (void)
|
|||||||
|
|
||||||
if (count < 3)
|
if (count < 3)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: Setup string table too short to even hold all indices!\n");
|
log_add (log_Always, "PANIC: Setup string table too short to even hold all indices!");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Menus */
|
/* Menus */
|
||||||
@@ -434,8 +435,8 @@ init_widgets (void)
|
|||||||
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, 1)), '\n', 100, buffer, bank) != MENU_COUNT)
|
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, 1)), '\n', 100, buffer, bank) != MENU_COUNT)
|
||||||
{
|
{
|
||||||
/* TODO: Ignore extras instead of dying. */
|
/* TODO: Ignore extras instead of dying. */
|
||||||
fprintf (stderr, "PANIC: Incorrect number of Menu Subtitles\n");
|
log_add (log_Always, "PANIC: Incorrect number of Menu Subtitles");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MENU_COUNT; i++)
|
for (i = 0; i < MENU_COUNT; i++)
|
||||||
@@ -460,8 +461,8 @@ init_widgets (void)
|
|||||||
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, 2)), '\n', 100, buffer, bank) != CHOICE_COUNT)
|
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, 2)), '\n', 100, buffer, bank) != CHOICE_COUNT)
|
||||||
{
|
{
|
||||||
/* TODO: Ignore extras instead of dying. */
|
/* TODO: Ignore extras instead of dying. */
|
||||||
fprintf (stderr, "PANIC: Incorrect number of Choice Options\n");
|
log_add (log_Always, "PANIC: Incorrect number of Choice Options");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CHOICE_COUNT; i++)
|
for (i = 0; i < CHOICE_COUNT; i++)
|
||||||
@@ -488,8 +489,8 @@ init_widgets (void)
|
|||||||
|
|
||||||
if (index >= count)
|
if (index >= count)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: String table cut short while reading choices\n");
|
log_add (log_Always, "PANIC: String table cut short while reading choices");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
||||||
optcount = SplitString (str, '\n', 100, buffer, bank);
|
optcount = SplitString (str, '\n', 100, buffer, bank);
|
||||||
@@ -508,8 +509,8 @@ init_widgets (void)
|
|||||||
|
|
||||||
if (index >= count)
|
if (index >= count)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: String table cut short while reading choices\n");
|
log_add (log_Always, "PANIC: String table cut short while reading choices");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
||||||
tipcount = SplitString (str, '\n', 100, buffer, bank);
|
tipcount = SplitString (str, '\n', 100, buffer, bank);
|
||||||
@@ -530,15 +531,15 @@ init_widgets (void)
|
|||||||
/* Sliders */
|
/* Sliders */
|
||||||
if (index >= count)
|
if (index >= count)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: String table cut short while reading sliders\n");
|
log_add (log_Always, "PANIC: String table cut short while reading sliders");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, index++)), '\n', 100, buffer, bank) != SLIDER_COUNT)
|
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, index++)), '\n', 100, buffer, bank) != SLIDER_COUNT)
|
||||||
{
|
{
|
||||||
/* TODO: Ignore extras instead of dying. */
|
/* TODO: Ignore extras instead of dying. */
|
||||||
fprintf (stderr, "PANIC: Incorrect number of Slider Options\n");
|
log_add (log_Always, "PANIC: Incorrect number of Slider Options");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < SLIDER_COUNT; i++)
|
for (i = 0; i < SLIDER_COUNT; i++)
|
||||||
@@ -566,8 +567,8 @@ init_widgets (void)
|
|||||||
|
|
||||||
if (index >= count)
|
if (index >= count)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: String table cut short while reading sliders\n");
|
log_add (log_Always, "PANIC: String table cut short while reading sliders");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
||||||
tipcount = SplitString (str, '\n', 100, buffer, bank);
|
tipcount = SplitString (str, '\n', 100, buffer, bank);
|
||||||
@@ -584,15 +585,15 @@ init_widgets (void)
|
|||||||
/* Buttons */
|
/* Buttons */
|
||||||
if (index >= count)
|
if (index >= count)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: String table cut short while reading buttons\n");
|
log_add (log_Always, "PANIC: String table cut short while reading buttons");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, index++)), '\n', 100, buffer, bank) != BUTTON_COUNT)
|
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, index++)), '\n', 100, buffer, bank) != BUTTON_COUNT)
|
||||||
{
|
{
|
||||||
/* TODO: Ignore extras instead of dying. */
|
/* TODO: Ignore extras instead of dying. */
|
||||||
fprintf (stderr, "PANIC: Incorrect number of Button Options\n");
|
log_add (log_Always, "PANIC: Incorrect number of Button Options");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < BUTTON_COUNT; i++)
|
for (i = 0; i < BUTTON_COUNT; i++)
|
||||||
@@ -615,8 +616,8 @@ init_widgets (void)
|
|||||||
|
|
||||||
if (index >= count)
|
if (index >= count)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: String table cut short while reading buttons\n");
|
log_add (log_Always, "PANIC: String table cut short while reading buttons");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
||||||
tipcount = SplitString (str, '\n', 100, buffer, bank);
|
tipcount = SplitString (str, '\n', 100, buffer, bank);
|
||||||
@@ -633,15 +634,15 @@ init_widgets (void)
|
|||||||
/* Labels */
|
/* Labels */
|
||||||
if (index >= count)
|
if (index >= count)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: String table cut short while reading labels\n");
|
log_add (log_Always, "PANIC: String table cut short while reading labels");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, index++)), '\n', 100, buffer, bank) != LABEL_COUNT)
|
if (SplitString (GetStringAddress (SetAbsStringTableIndex (SetupTab, index++)), '\n', 100, buffer, bank) != LABEL_COUNT)
|
||||||
{
|
{
|
||||||
/* TODO: Ignore extras instead of dying. */
|
/* TODO: Ignore extras instead of dying. */
|
||||||
fprintf (stderr, "PANIC: Incorrect number of Label Options\n");
|
log_add (log_Always, "PANIC: Incorrect number of Label Options");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < LABEL_COUNT; i++)
|
for (i = 0; i < LABEL_COUNT; i++)
|
||||||
@@ -662,8 +663,8 @@ init_widgets (void)
|
|||||||
|
|
||||||
if (index >= count)
|
if (index >= count)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: String table cut short while reading labels\n");
|
log_add (log_Always, "PANIC: String table cut short while reading labels");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
str = GetStringAddress (SetAbsStringTableIndex (SetupTab, index++));
|
||||||
linecount = SplitString (str, '\n', 100, buffer, bank);
|
linecount = SplitString (str, '\n', 100, buffer, bank);
|
||||||
@@ -678,7 +679,8 @@ init_widgets (void)
|
|||||||
/* Check for garbage at the end */
|
/* Check for garbage at the end */
|
||||||
if (index < count)
|
if (index < count)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "WARNING: Setup strings had %d garbage entries at the end.\n", count - index);
|
log_add (log_Warning, "WARNING: Setup strings had %d garbage entries at the end.",
|
||||||
|
count - index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -737,8 +739,8 @@ SetupMenu (void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PANIC: Could not find strings for the setup menu!\n");
|
log_add (log_Always, "PANIC: Could not find strings for the setup menu!");
|
||||||
exit (1);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
done = FALSE;
|
done = FALSE;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -1542,7 +1543,7 @@ SetFlashRect (PRECT pRect, FRAME f)
|
|||||||
flash_screen_frame = 0;
|
flash_screen_frame = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf (stderr, "couldn't locate flash_screen_rect\n");
|
log_add (log_Always, "Couldn't locate flash_screen_rect");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flash_rect.extent.width)
|
if (flash_rect.extent.width)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "starcon.h"
|
#include "starcon.h"
|
||||||
#include "uqmdebug.h"
|
#include "uqmdebug.h"
|
||||||
#include "libs/tasklib.h"
|
#include "libs/tasklib.h"
|
||||||
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
// Open or close the periodically occuring QuasiSpace portal.
|
// Open or close the periodically occuring QuasiSpace portal.
|
||||||
@@ -140,7 +141,7 @@ while (--ac > 0)
|
|||||||
|
|
||||||
if (LoadKernel (0,0))
|
if (LoadKernel (0,0))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "We've loaded the Kernel\n");
|
log_add (log_Info, "We've loaded the Kernel");
|
||||||
|
|
||||||
Logo ();
|
Logo ();
|
||||||
|
|
||||||
@@ -274,7 +275,7 @@ while (--ac > 0)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Kernel failed to load!\n");
|
log_add (log_Always, "Kernel failed to load!");
|
||||||
}
|
}
|
||||||
FreeKernel ();
|
FreeKernel ();
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "encount.h"
|
#include "encount.h"
|
||||||
#include "libs/misc.h"
|
#include "libs/misc.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -58,8 +59,8 @@ OpenStateFile (int stateFile, const char *mode)
|
|||||||
fp = &state_files[stateFile];
|
fp = &state_files[stateFile];
|
||||||
fp->open_count++;
|
fp->open_count++;
|
||||||
if (fp->open_count > 1)
|
if (fp->open_count > 1)
|
||||||
fprintf (stderr, "WARNING: "
|
log_add (log_Warning, "WARNING: "
|
||||||
"State file %s open count is %d after open()\n",
|
"State file %s open count is %d after open()",
|
||||||
fp->symname, fp->open_count);
|
fp->symname, fp->open_count);
|
||||||
|
|
||||||
if (!fp->data)
|
if (!fp->data)
|
||||||
@@ -85,8 +86,8 @@ OpenStateFile (int stateFile, const char *mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "WARNING: "
|
log_add (log_Warning, "WARNING: "
|
||||||
"State file %s opened with unsupported mode '%s'\n",
|
"State file %s opened with unsupported mode '%s'",
|
||||||
fp->symname, mode);
|
fp->symname, mode);
|
||||||
}
|
}
|
||||||
fp->ptr = 0;
|
fp->ptr = 0;
|
||||||
@@ -100,8 +101,8 @@ CloseStateFile (GAME_STATE_FILE *fp)
|
|||||||
fp->ptr = 0;
|
fp->ptr = 0;
|
||||||
fp->open_count--;
|
fp->open_count--;
|
||||||
if (fp->open_count < 0)
|
if (fp->open_count < 0)
|
||||||
fprintf (stderr, "WARNING: "
|
log_add (log_Warning, "WARNING: "
|
||||||
"State file %s open count is %d after close()\n",
|
"State file %s open count is %d after close()",
|
||||||
fp->symname, fp->open_count);
|
fp->symname, fp->open_count);
|
||||||
// Erm, Ok, it's closed! Honest!
|
// Erm, Ok, it's closed! Honest!
|
||||||
}
|
}
|
||||||
@@ -116,8 +117,8 @@ DeleteStateFile (int stateFile)
|
|||||||
|
|
||||||
fp = &state_files[stateFile];
|
fp = &state_files[stateFile];
|
||||||
if (fp->open_count != 0)
|
if (fp->open_count != 0)
|
||||||
fprintf (stderr, "WARNING: "
|
log_add (log_Warning, "WARNING: "
|
||||||
"State file %s open count is %d during delete()\n",
|
"State file %s open count is %d during delete()",
|
||||||
fp->symname, fp->open_count);
|
fp->symname, fp->open_count);
|
||||||
|
|
||||||
fp->used = 0;
|
fp->used = 0;
|
||||||
|
|||||||
+90
-74
@@ -34,6 +34,7 @@
|
|||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
#include "libs/platform.h"
|
#include "libs/platform.h"
|
||||||
|
#include "libs/log.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "uqmversion.h"
|
#include "uqmversion.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
@@ -127,8 +128,10 @@ main (int argc, char *argv[])
|
|||||||
/* .sfxVolumeScale = */ 1.0f,
|
/* .sfxVolumeScale = */ 1.0f,
|
||||||
/* .speechVolumeScale = */ 1.0f,
|
/* .speechVolumeScale = */ 1.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
int optionsResult;
|
int optionsResult;
|
||||||
|
|
||||||
|
log_init (15);
|
||||||
|
|
||||||
optionsResult = preParseOptions(argc, argv, &options);
|
optionsResult = preParseOptions(argc, argv, &options);
|
||||||
if (optionsResult != 0)
|
if (optionsResult != 0)
|
||||||
{
|
{
|
||||||
@@ -141,19 +144,20 @@ main (int argc, char *argv[])
|
|||||||
int i;
|
int i;
|
||||||
freopen (options.logFile, "w", stderr);
|
freopen (options.logFile, "w", stderr);
|
||||||
for (i = 0; i < argc; ++i)
|
for (i = 0; i < argc; ++i)
|
||||||
fprintf (stderr, "argv[%d] = [%s]\n", i, argv[i]);
|
log_add (log_Always, "argv[%d] = [%s]", i, argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.runMode == runMode_version)
|
if (options.runMode == runMode_version)
|
||||||
{
|
{
|
||||||
printf ("%d.%d.%d%s\n", UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
|
printf ("%d.%d.%d%s\n", UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
|
||||||
UQM_PATCH_VERSION, UQM_EXTRA_VERSION);
|
UQM_PATCH_VERSION, UQM_EXTRA_VERSION);
|
||||||
|
log_showBox (false, false);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "The Ur-Quan Masters v%d.%d.%d%s (compiled %s %s)\n"
|
log_add (log_Always, "The Ur-Quan Masters v%d.%d.%d%s (compiled %s %s)\n"
|
||||||
"This software comes with ABSOLUTELY NO WARRANTY;\n"
|
"This software comes with ABSOLUTELY NO WARRANTY;\n"
|
||||||
"for details see the included 'COPYING' file.\n\n",
|
"for details see the included 'COPYING' file.\n",
|
||||||
UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
|
UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
|
||||||
UQM_PATCH_VERSION, UQM_EXTRA_VERSION,
|
UQM_PATCH_VERSION, UQM_EXTRA_VERSION,
|
||||||
__DATE__, __TIME__);
|
__DATE__, __TIME__);
|
||||||
@@ -161,6 +165,7 @@ main (int argc, char *argv[])
|
|||||||
if (options.runMode == runMode_usage)
|
if (options.runMode == runMode_usage)
|
||||||
{
|
{
|
||||||
usage (stdout, &options);
|
usage (stdout, &options);
|
||||||
|
log_showBox (true, false);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +176,7 @@ main (int argc, char *argv[])
|
|||||||
TFB_PreInit ();
|
TFB_PreInit ();
|
||||||
mem_init ();
|
mem_init ();
|
||||||
InitThreadSystem ();
|
InitThreadSystem ();
|
||||||
|
log_initThreads ();
|
||||||
initIO ();
|
initIO ();
|
||||||
prepareConfigDir (options.configDir);
|
prepareConfigDir (options.configDir);
|
||||||
|
|
||||||
@@ -319,7 +325,7 @@ main (int argc, char *argv[])
|
|||||||
/* This is an unsigned, so no < 0 check is necessary */
|
/* This is an unsigned, so no < 0 check is necessary */
|
||||||
if (PlayerOne >= NUM_TEMPLATES)
|
if (PlayerOne >= NUM_TEMPLATES)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Illegal control template '%d' for Player One.\n", PlayerOne);
|
log_add (log_Always, "Illegal control template '%d' for Player One.", PlayerOne);
|
||||||
PlayerOne = CONTROL_TEMPLATE_KB_1;
|
PlayerOne = CONTROL_TEMPLATE_KB_1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,7 +335,7 @@ main (int argc, char *argv[])
|
|||||||
PlayerTwo = res_GetInteger ("config.player2control");
|
PlayerTwo = res_GetInteger ("config.player2control");
|
||||||
if (PlayerTwo >= NUM_TEMPLATES)
|
if (PlayerTwo >= NUM_TEMPLATES)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Illegal control template '%d' for Player Two.\n", PlayerTwo);
|
log_add (log_Always, "Illegal control template '%d' for Player Two.", PlayerTwo);
|
||||||
PlayerTwo = CONTROL_TEMPLATE_KB_2;
|
PlayerTwo = CONTROL_TEMPLATE_KB_2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -415,7 +421,8 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
unInitTempDir ();
|
unInitTempDir ();
|
||||||
uninitIO ();
|
uninitIO ();
|
||||||
exit (EXIT_SUCCESS);
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@@ -511,7 +518,7 @@ preParseOptions(int argc, char *argv[], struct options_struct *options)
|
|||||||
static int
|
static int
|
||||||
parseOptions(int argc, char *argv[], struct options_struct *options)
|
parseOptions(int argc, char *argv[], struct options_struct *options)
|
||||||
{
|
{
|
||||||
int optionIndex = 0;
|
int optionIndex;
|
||||||
BOOLEAN badArg = FALSE;
|
BOOLEAN badArg = FALSE;
|
||||||
|
|
||||||
options->addons = HMalloc(1 * sizeof (const char *));
|
options->addons = HMalloc(1 * sizeof (const char *));
|
||||||
@@ -520,13 +527,14 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
|
|||||||
|
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Bad command line.\n");
|
log_add (log_Always, "Error: Bad command line.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!badArg)
|
while (!badArg)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
optionIndex = -1;
|
||||||
c = getopt_long(argc, argv, optString, longOptions, &optionIndex);
|
c = getopt_long(argc, argv, optString, longOptions, &optionIndex);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
@@ -537,8 +545,8 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
|
|||||||
int width, height;
|
int width, height;
|
||||||
if (sscanf (optarg, "%dx%d", &width, &height) != 2)
|
if (sscanf (optarg, "%dx%d", &width, &height) != 2)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: invalid argument specified "
|
log_add (log_Always, "Error: invalid argument specified "
|
||||||
"as resolution.\n");
|
"as resolution.");
|
||||||
badArg = TRUE;
|
badArg = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -646,7 +654,7 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
|
|||||||
case 'm':
|
case 'm':
|
||||||
{
|
{
|
||||||
if (Check_PC_3DO_opt (optarg, OPT_PC | OPT_3DO,
|
if (Check_PC_3DO_opt (optarg, OPT_PC | OPT_3DO,
|
||||||
longOptions[optionIndex].name,
|
optionIndex >= 0 ? longOptions[optionIndex].name : "m",
|
||||||
&options->whichMusic) == -1)
|
&options->whichMusic) == -1)
|
||||||
badArg = TRUE;
|
badArg = TRUE;
|
||||||
break;
|
break;
|
||||||
@@ -668,7 +676,7 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
|
|||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
if (Check_PC_3DO_opt (optarg, OPT_PC | OPT_3DO,
|
if (Check_PC_3DO_opt (optarg, OPT_PC | OPT_3DO,
|
||||||
longOptions[optionIndex].name,
|
optionIndex >= 0 ? longOptions[optionIndex].name : "i",
|
||||||
&options->whichIntro) == -1)
|
&options->whichIntro) == -1)
|
||||||
badArg = TRUE;
|
badArg = TRUE;
|
||||||
break;
|
break;
|
||||||
@@ -715,8 +723,8 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Invalid sound driver "
|
log_add (log_Always, "Error: Invalid sound driver "
|
||||||
"specified.\n");
|
"specified.");
|
||||||
badArg = TRUE;
|
badArg = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -747,7 +755,7 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "Error: Invalid option '%s' not found.\n",
|
log_add (log_Always, "Error: Invalid option '%s' not found.",
|
||||||
longOptions[optionIndex].name);
|
longOptions[optionIndex].name);
|
||||||
badArg = TRUE;
|
badArg = TRUE;
|
||||||
break;
|
break;
|
||||||
@@ -756,14 +764,14 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
|
|||||||
|
|
||||||
if (optind != argc)
|
if (optind != argc)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\nError: Extra arguments found on the command "
|
log_add (log_Always, "\nError: Extra arguments found on the command "
|
||||||
"line.\n");
|
"line.");
|
||||||
badArg = TRUE;
|
badArg = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (badArg)
|
if (badArg)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Run with -h to see the allowed arguments.\n");
|
log_add (log_Always, "Run with -h to see the allowed arguments.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -778,14 +786,14 @@ parseVolume (const char *str, float *vol, const char *optName)
|
|||||||
|
|
||||||
if (str[0] == '\0')
|
if (str[0] == '\0')
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Invalid value for '%s'.\n", optName);
|
log_add (log_Always, "Error: Invalid value for '%s'.", optName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
intVol = (int) strtol(str, &endPtr, 10);
|
intVol = (int) strtol(str, &endPtr, 10);
|
||||||
if (*endPtr != '\0')
|
if (*endPtr != '\0')
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Junk characters in volume specified "
|
log_add (log_Always, "Error: Junk characters in volume specified "
|
||||||
"for '%s'.\n", optName);
|
"for '%s'.", optName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,13 +821,13 @@ parseIntOption (const char *str, int *result, const char *optName)
|
|||||||
|
|
||||||
if (str[0] == '\0')
|
if (str[0] == '\0')
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Invalid value for '%s'.\n", optName);
|
log_add (log_Always, "Error: Invalid value for '%s'.", optName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
temp = (int) strtol(str, &endPtr, 10);
|
temp = (int) strtol(str, &endPtr, 10);
|
||||||
if (*endPtr != '\0')
|
if (*endPtr != '\0')
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Junk characters in argument '%s'.\n",
|
log_add (log_Always, "Error: Junk characters in argument '%s'.",
|
||||||
optName);
|
optName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -836,13 +844,13 @@ parseFloatOption (const char *str, float *f, const char *optName)
|
|||||||
|
|
||||||
if (str[0] == '\0')
|
if (str[0] == '\0')
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Invalid value for '%s'.\n", optName);
|
log_add (log_Always, "Error: Invalid value for '%s'.", optName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
temp = (float) strtod(str, &endPtr);
|
temp = (float) strtod(str, &endPtr);
|
||||||
if (*endPtr != '\0')
|
if (*endPtr != '\0')
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: Junk characters in argument '%s'.\n",
|
log_add (log_Always, "Error: Junk characters in argument '%s'.",
|
||||||
optName);
|
optName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -854,62 +862,67 @@ parseFloatOption (const char *str, float *f, const char *optName)
|
|||||||
static void
|
static void
|
||||||
usage (FILE *out, const struct options_struct *defaultOptions)
|
usage (FILE *out, const struct options_struct *defaultOptions)
|
||||||
{
|
{
|
||||||
fprintf (out, "Options:\n");
|
FILE *old = log_setOutput (out);
|
||||||
fprintf (out, " -r, --res=WIDTHxHEIGHT (default 640x480, bigger "
|
log_captureLines (LOG_CAPTURE_ALL);
|
||||||
"works only with --opengl)\n");
|
|
||||||
fprintf (out, " -f, --fullscreen (default off)\n");
|
log_add (log_Always, "Options:");
|
||||||
fprintf (out, " -o, --opengl (default off)\n");
|
log_add (log_Always, " -r, --res=WIDTHxHEIGHT (default 640x480, bigger "
|
||||||
fprintf (out, " -c, --scale=MODE (bilinear, biadapt, biadv, triscan, "
|
"works only with --opengl)");
|
||||||
"hq or none (default) )\n");
|
log_add (log_Always, " -f, --fullscreen (default off)");
|
||||||
fprintf (out, " -b, --meleezoom=MODE (step, aka pc, or smooth, aka 3do; "
|
log_add (log_Always, " -o, --opengl (default off)");
|
||||||
"default is 3do)\n");
|
log_add (log_Always, " -c, --scale=MODE (bilinear, biadapt, biadv, triscan, "
|
||||||
fprintf (out, " -s, --scanlines (default off)\n");
|
"hq or none (default) )");
|
||||||
fprintf (out, " -p, --fps (default off)\n");
|
log_add (log_Always, " -b, --meleezoom=MODE (step, aka pc, or smooth, aka 3do; "
|
||||||
fprintf (out, " -g, --gamma=CORRECTIONVALUE (default 1.0, which "
|
"default is 3do)");
|
||||||
"causes no change)\n");
|
log_add (log_Always, " -s, --scanlines (default off)");
|
||||||
fprintf (out, " -C, --configdir=CONFIGDIR\n");
|
log_add (log_Always, " -p, --fps (default off)");
|
||||||
fprintf (out, " -n, --contentdir=CONTENTDIR\n");
|
log_add (log_Always, " -g, --gamma=CORRECTIONVALUE (default 1.0, which "
|
||||||
fprintf (out, " -M, --musicvol=VOLUME (0-100, default 100)\n");
|
"causes no change)");
|
||||||
fprintf (out, " -S, --sfxvol=VOLUME (0-100, default 100)\n");
|
log_add (log_Always, " -C, --configdir=CONFIGDIR");
|
||||||
fprintf (out, " -T, --speechvol=VOLUME (0-100, default 100)\n");
|
log_add (log_Always, " -n, --contentdir=CONTENTDIR");
|
||||||
fprintf (out, " -q, --audioquality=QUALITY (high, medium or low, "
|
log_add (log_Always, " -M, --musicvol=VOLUME (0-100, default 100)");
|
||||||
"default medium)\n");
|
log_add (log_Always, " -S, --sfxvol=VOLUME (0-100, default 100)");
|
||||||
fprintf (out, " -u, --nosubtitles\n");
|
log_add (log_Always, " -T, --speechvol=VOLUME (0-100, default 100)");
|
||||||
fprintf (out, " -l, --logfile=FILE (sends console output to logfile "
|
log_add (log_Always, " -q, --audioquality=QUALITY (high, medium or low, "
|
||||||
"FILE)\n");
|
"default medium)");
|
||||||
fprintf (out, " --addon ADDON (using a specific addon; "
|
log_add (log_Always, " -u, --nosubtitles");
|
||||||
"may be specified multiple times)\n");
|
log_add (log_Always, " -l, --logfile=FILE (sends console output to logfile "
|
||||||
fprintf (out, " --sound=DRIVER (openal, mixsdl, none; default "
|
"FILE)");
|
||||||
"mixsdl)\n");
|
log_add (log_Always, " --addon ADDON (using a specific addon; "
|
||||||
fprintf (out, " --stereosfx (enables positional sound effects, "
|
"may be specified multiple times)");
|
||||||
"currently only for openal)\n");
|
log_add (log_Always, " --sound=DRIVER (openal, mixsdl, none; default "
|
||||||
fprintf (out, "The following options can take either '3do' or 'pc' "
|
"mixsdl)");
|
||||||
"as an option:\n");
|
log_add (log_Always, " --stereosfx (enables positional sound effects, "
|
||||||
fprintf (out, " -m, --music : Music version (default %s)\n",
|
"currently only for openal)");
|
||||||
|
log_add (log_Always, "The following options can take either '3do' or 'pc' "
|
||||||
|
"as an option:");
|
||||||
|
log_add (log_Always, " -m, --music : Music version (default %s)",
|
||||||
PC_3DO_optString(defaultOptions->whichMusic));
|
PC_3DO_optString(defaultOptions->whichMusic));
|
||||||
fprintf (out, " -i, --intro : Intro/ending version (default %s)\n",
|
log_add (log_Always, " -i, --intro : Intro/ending version (default %s)",
|
||||||
PC_3DO_optString(defaultOptions->whichIntro));
|
PC_3DO_optString(defaultOptions->whichIntro));
|
||||||
fprintf (out, " --cscan : coarse-scan display, pc=text, "
|
log_add (log_Always, " --cscan : coarse-scan display, pc=text, "
|
||||||
"3do=hieroglyphs (default %s)\n",
|
"3do=hieroglyphs (default %s)",
|
||||||
PC_3DO_optString(defaultOptions->whichCoarseScan));
|
PC_3DO_optString(defaultOptions->whichCoarseScan));
|
||||||
fprintf (out, " --menu : menu type, pc=text, 3do=graphical "
|
log_add (log_Always, " --menu : menu type, pc=text, 3do=graphical "
|
||||||
"(default %s)\n", PC_3DO_optString(defaultOptions->whichMenu));
|
"(default %s)", PC_3DO_optString(defaultOptions->whichMenu));
|
||||||
fprintf (out, " --font : font types and colors (default %s)\n",
|
log_add (log_Always, " --font : font types and colors (default %s)",
|
||||||
PC_3DO_optString(defaultOptions->whichFonts));
|
PC_3DO_optString(defaultOptions->whichFonts));
|
||||||
fprintf (out, " --shield : slave shield type; pc=static, "
|
log_add (log_Always, " --shield : slave shield type; pc=static, "
|
||||||
"3do=throbbing (default %s)\n",
|
"3do=throbbing (default %s)",
|
||||||
PC_3DO_optString(defaultOptions->whichShield));
|
PC_3DO_optString(defaultOptions->whichShield));
|
||||||
fprintf (out, " --scroll : ff/frev during comm. pc=per-page, "
|
log_add (log_Always, " --scroll : ff/frev during comm. pc=per-page, "
|
||||||
"3do=smooth (default %s)\n",
|
"3do=smooth (default %s)",
|
||||||
PC_3DO_optString(defaultOptions->smoothScroll));
|
PC_3DO_optString(defaultOptions->smoothScroll));
|
||||||
|
|
||||||
|
log_setOutput (old);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
InvalidArgument(const char *supplied, const char *opt_name)
|
InvalidArgument (const char *supplied, const char *opt_name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid argument '%s' to option %s.\n",
|
log_add (log_Always, "Invalid argument '%s' to option %s.",
|
||||||
supplied, opt_name);
|
supplied, opt_name);
|
||||||
fprintf (stderr, "Use -h to see the allowed arguments.\n");
|
log_add (log_Always, "Use -h to see the allowed arguments.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -919,7 +932,8 @@ Check_PC_3DO_opt (const char *value, DWORD mask, const char *optName,
|
|||||||
{
|
{
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error: option '%s' requires a value.\n", optName);
|
log_add (log_Always, "Error: option '%s' requires a value.",
|
||||||
|
optName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -933,12 +947,14 @@ Check_PC_3DO_opt (const char *value, DWORD mask, const char *optName,
|
|||||||
*result = OPT_PC;
|
*result = OPT_PC;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Error: Invalid option '%s %s' found.", optName, value);
|
log_add (log_Always, "Error: Invalid option '%s %s' found.",
|
||||||
|
optName, value);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
PC_3DO_optString(DWORD optMask) {
|
PC_3DO_optString (DWORD optMask)
|
||||||
|
{
|
||||||
if (optMask & OPT_3DO)
|
if (optMask & OPT_3DO)
|
||||||
{
|
{
|
||||||
if (optMask & OPT_PC)
|
if (optMask & OPT_PC)
|
||||||
|
|||||||
Reference in New Issue
Block a user