2024-04-20 15:57:49 +00:00
|
|
|
/*
|
|
|
|
* Descent 3
|
|
|
|
* Copyright (C) 2024 Parallax Software
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2024-04-16 03:43:29 +00:00
|
|
|
/*
|
|
|
|
* $Logfile: /DescentIII/Main/mac/macdebug.cpp $
|
|
|
|
* $Revision: 1.1.1.1 $
|
|
|
|
* $Date: 2003/08/26 03:58:15 $
|
|
|
|
* $Author: kevinb $
|
|
|
|
*
|
|
|
|
* MacOS Debugging routines
|
|
|
|
*
|
|
|
|
* $Log: macdebug.cpp,v $
|
|
|
|
* Revision 1.1.1.1 2003/08/26 03:58:15 kevinb
|
|
|
|
* initial 1.5 import
|
|
|
|
*
|
2024-04-16 18:56:40 +00:00
|
|
|
*
|
2024-04-16 03:43:29 +00:00
|
|
|
* 4 4/12/00 7:08p Matt
|
|
|
|
* From Duane for 1.4
|
2024-04-16 18:56:40 +00:00
|
|
|
*
|
2024-04-16 03:43:29 +00:00
|
|
|
* 3 10/21/99 1:55p Kevin
|
|
|
|
* Mac Merge!
|
2024-04-16 18:56:40 +00:00
|
|
|
*
|
2024-04-16 03:43:29 +00:00
|
|
|
* 2 7/28/99 2:51p Kevin
|
2024-04-16 18:56:40 +00:00
|
|
|
*
|
2024-04-16 03:43:29 +00:00
|
|
|
* 4 5/15/97 1:51 AM Jeremy
|
|
|
|
* made osMessage/Error box correctly handle newlines and added some error
|
|
|
|
* checking for strings which are too long to fit into pascal strings
|
2024-04-16 18:56:40 +00:00
|
|
|
*
|
2024-04-16 03:43:29 +00:00
|
|
|
* 3 5/9/97 8:04 PM Jeremy
|
|
|
|
* changed include of <Strings.h> to <TextUtils.h>
|
2024-04-16 18:56:40 +00:00
|
|
|
*
|
2024-04-16 03:43:29 +00:00
|
|
|
* 2 3/21/97 6:53 PM Jeremy
|
|
|
|
* First crack at implementing debugging and console io routines.
|
|
|
|
* Currently the functions display a mac dialog box for errors and
|
|
|
|
* messages and send all console messages through the macintosh's modem
|
|
|
|
* port.
|
2024-04-16 18:56:40 +00:00
|
|
|
*
|
2024-04-16 03:43:29 +00:00
|
|
|
* 1 2/28/97 12:16 PM Jeremy
|
|
|
|
* MacOS specific Debug object libraries
|
|
|
|
*
|
|
|
|
* $NoKeywords: $
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include "mono.h"
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <sioux.h>
|
|
|
|
|
|
|
|
extern int debug_level;
|
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
void setup_sioux(void) {
|
|
|
|
SIOUXSettings.standalone = true;
|
|
|
|
SIOUXSettings.setupmenus = true;
|
|
|
|
SIOUXSettings.asktosaveonclose = false;
|
|
|
|
SIOUXSettings.toppixel = 526;
|
|
|
|
SIOUXSettings.leftpixel = 10;
|
|
|
|
SIOUXSettings.rows = 20;
|
|
|
|
SIOUXSettings.columns = 120;
|
2024-04-16 03:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
bool Debug_break = false;
|
|
|
|
bool Debug_mono = false;
|
2024-04-16 03:43:29 +00:00
|
|
|
|
|
|
|
char *Debug_DumpInfo();
|
|
|
|
#include "stringtable.h"
|
|
|
|
#include "newui_core.h"
|
|
|
|
#include "newui.h"
|
|
|
|
#include "descent.h"
|
|
|
|
#include "renderer.h"
|
|
|
|
|
|
|
|
// if we are running under a debugger, then pass true
|
2024-04-16 18:56:40 +00:00
|
|
|
bool Debug_Init(bool debugger, bool mono_debug) {
|
2024-04-16 03:43:29 +00:00
|
|
|
#ifdef DAJ_DEBUG
|
2024-04-16 20:59:11 +00:00
|
|
|
// #ifndef RELEASE
|
2024-04-16 18:56:40 +00:00
|
|
|
Debug_break = debugger;
|
2024-04-16 03:43:29 +00:00
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
if (mono_debug) {
|
2024-04-16 03:43:29 +00:00
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
mprintf((0, "Linux system.\n"));
|
|
|
|
}
|
2024-04-16 03:43:29 +00:00
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
if (Debug_break)
|
|
|
|
mprintf((0, "Debug Break enabled.\n"));
|
2024-04-16 03:43:29 +00:00
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
#endif // ifndef RELEASE
|
2024-04-16 03:43:29 +00:00
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
return true;
|
2024-04-16 03:43:29 +00:00
|
|
|
}
|
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
// Does a messagebox with a stack dump
|
|
|
|
// Messagebox shows topstring, then stack dump, then bottomstring
|
|
|
|
// Return types are the same as the Windows return values
|
|
|
|
int Debug_ErrorBox(int type, const char *title, const char *topstring, const char *bottomstring) {
|
|
|
|
int answer = 0;
|
|
|
|
// char *dumptext = Debug_DumpInfo();
|
|
|
|
|
|
|
|
Str255 debug_str;
|
|
|
|
sprintf((char *)debug_str, "%s:%s\r\n%s", title, topstring, bottomstring);
|
2024-04-16 03:43:29 +00:00
|
|
|
#ifdef DAJ_DEBUG
|
2024-04-16 18:56:40 +00:00
|
|
|
DebugStr(debug_str);
|
2024-04-16 03:43:29 +00:00
|
|
|
#else
|
2024-04-16 18:56:40 +00:00
|
|
|
// if (GetFunctionMode() > INIT_MODE) {
|
|
|
|
rend_Close();
|
|
|
|
::ShowCursor();
|
|
|
|
::ParamText(c2pstr(topstring), c2pstr(bottomstring), NULL, NULL);
|
|
|
|
::Alert(911, NULL);
|
|
|
|
// } else {
|
|
|
|
// DoMessageBox(TXT_ERROR, (char *)debug_str, MSGBOX_OK, UICOL_WINDOW_TITLE,UICOL_TEXT_NORMAL);
|
|
|
|
// }
|
|
|
|
exit(0);
|
2024-04-16 03:43:29 +00:00
|
|
|
// fprintf(stderr,"%s:%s\r\n\r\n%s\r\n\r\n%s",title,topstring,dumptext,bottomstring);
|
|
|
|
#endif
|
2024-04-16 18:56:40 +00:00
|
|
|
// debug_break();
|
2024-04-16 03:43:29 +00:00
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
return answer;
|
2024-04-16 03:43:29 +00:00
|
|
|
}
|
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
// displays an message box
|
2024-04-16 03:43:29 +00:00
|
|
|
// Returns the same values as the Win32 MessageBox() function
|
2024-04-16 18:56:40 +00:00
|
|
|
int Debug_MessageBox(int type, const char *title, const char *str) {
|
|
|
|
return Debug_ErrorBox(type, str, "Descent 3 Message", "");
|
2024-04-16 03:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
char *Debug_DumpInfo(void) {
|
|
|
|
static char e[] = "System Error";
|
|
|
|
return e;
|
|
|
|
}
|