mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Cleanup mono debugging code
Remove unused mono debug code.
This commit is contained in:
parent
4795388500
commit
9416458f9c
@ -6127,12 +6127,7 @@ void AIDoFrame(object *obj) {
|
||||
ai_frame *ai_info = obj->ai_info;
|
||||
ASSERT((obj->control_type == CT_AI) || (obj->control_type == CT_DYING_AND_AI));
|
||||
|
||||
DebugBlockPrint("A ");
|
||||
|
||||
// mprintf(0, "Awareness = %d\n", ai_info->awareness);
|
||||
|
||||
if ((ai_info->flags & AIF_DISABLED) || (obj->type == OBJ_DUMMY)) {
|
||||
DebugBlockPrint("DA");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -6165,7 +6160,6 @@ void AIDoFrame(object *obj) {
|
||||
}
|
||||
|
||||
if ((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT)) {
|
||||
DebugBlockPrint("DA");
|
||||
if (!f_attach_done) {
|
||||
AttachUpdateSubObjects(obj);
|
||||
f_attach_done = true;
|
||||
@ -6183,7 +6177,6 @@ void AIDoFrame(object *obj) {
|
||||
|
||||
// If the object is dead, it does not think
|
||||
if (obj->flags & OF_DEAD) {
|
||||
DebugBlockPrint("DA");
|
||||
if (!f_attach_done) {
|
||||
AttachUpdateSubObjects(obj);
|
||||
f_attach_done = true;
|
||||
@ -6297,7 +6290,6 @@ void AIDoFrame(object *obj) {
|
||||
}
|
||||
}
|
||||
|
||||
DebugBlockPrint("DA");
|
||||
}
|
||||
|
||||
void AIFrameAll(void) {
|
||||
|
@ -97,18 +97,7 @@ void InvReset(int playernum, bool reset_all) {
|
||||
}
|
||||
|
||||
// mprintf
|
||||
void MonoPrintf(int n, char *format, ...) {
|
||||
#ifndef RELEASE
|
||||
char tempbuffer[300];
|
||||
|
||||
std::va_list ap;
|
||||
va_start(ap, format);
|
||||
std::vsnprintf(tempbuffer, 300, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
Debug_ConsolePrintf(n, tempbuffer);
|
||||
#endif
|
||||
}
|
||||
void MonoPrintf(int n, char *format, ...) {}
|
||||
|
||||
// wrapper for cfopen
|
||||
void OpenCFILE(CFILE **handle, const char *filename, const char *mode) { *handle = cfopen(filename, mode); }
|
||||
|
@ -2506,8 +2506,6 @@ void GameDrawMainView() {
|
||||
bool rear_view = 0;
|
||||
object *save_view;
|
||||
|
||||
DebugBlockPrint("SR");
|
||||
|
||||
// Start rendering
|
||||
StartFrame(false);
|
||||
|
||||
@ -2540,8 +2538,6 @@ void GameDrawMainView() {
|
||||
|
||||
// We're done with this window
|
||||
EndFrame();
|
||||
|
||||
DebugBlockPrint("DR");
|
||||
}
|
||||
|
||||
// Added by Samir
|
||||
|
@ -1058,15 +1058,12 @@ int merc_hid = -1;
|
||||
*/
|
||||
void PreInitD3Systems() {
|
||||
// initialize error system
|
||||
bool debugging = false, console_output = false;
|
||||
bool debugging = false;
|
||||
|
||||
#ifndef RELEASE
|
||||
|
||||
debugging = (FindArg("-debug") != 0);
|
||||
|
||||
#ifdef LOGGER
|
||||
console_output = true;
|
||||
#endif
|
||||
if (FindArg("-logfile"))
|
||||
Debug_Logfile("d3.log");
|
||||
|
||||
@ -1076,7 +1073,7 @@ void PreInitD3Systems() {
|
||||
debugging = true;
|
||||
#endif
|
||||
|
||||
error_Init(debugging, console_output, PRODUCT_NAME);
|
||||
error_Init(debugging, false, PRODUCT_NAME);
|
||||
|
||||
if (FindArg("-lowmem"))
|
||||
Mem_low_memory_mode = true;
|
||||
@ -1907,24 +1904,6 @@ void InitD3Systems1(bool editor) {
|
||||
if (!FindArg("-nonetwork")) {
|
||||
nw_InitNetworking();
|
||||
nw_InitSockets(Gameport);
|
||||
|
||||
int tcplogarg;
|
||||
tcplogarg = FindArg("-tcplog");
|
||||
if (tcplogarg) {
|
||||
char ipparse[50];
|
||||
char *pport;
|
||||
int port = 9999;
|
||||
strcpy(ipparse, GameArgs[tcplogarg + 1]);
|
||||
pport = strchr(ipparse, ':');
|
||||
if (pport) {
|
||||
*pport = '\0';
|
||||
pport++;
|
||||
port = atoi(pport);
|
||||
}
|
||||
#if !defined(RELEASE)
|
||||
nw_InitTCPLogging(ipparse, port);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int timeoutarg = FindArg("-timeout");
|
||||
|
@ -597,16 +597,12 @@ int DoUI() {
|
||||
ui_ShowCursor();
|
||||
ui_Flush();
|
||||
|
||||
DebugBlockPrint("UJ");
|
||||
|
||||
while (UI_frame_result == -1) {
|
||||
Descent->defer();
|
||||
DoUIFrame();
|
||||
rend_Flip();
|
||||
}
|
||||
|
||||
DebugBlockPrint("UO");
|
||||
|
||||
ui_HideCursor();
|
||||
ui_Flush();
|
||||
|
||||
@ -618,10 +614,8 @@ void DoUIFrame() {
|
||||
if (Multi_bail_ui_menu) {
|
||||
UI_frame_result = NEWUIRES_FORCEQUIT;
|
||||
} else {
|
||||
DebugBlockPrint("UK");
|
||||
if (UI_callback)
|
||||
(*UI_callback)();
|
||||
DebugBlockPrint("UL");
|
||||
|
||||
if (GetFunctionMode() == MENU_MODE) {
|
||||
tMusicSeqInfo music_info;
|
||||
@ -636,9 +630,7 @@ void DoUIFrame() {
|
||||
Sound_system.EndSoundFrame();
|
||||
}
|
||||
|
||||
DebugBlockPrint("UM");
|
||||
UI_frame_result = ui_DoFrame();
|
||||
DebugBlockPrint("UN");
|
||||
}
|
||||
|
||||
if (UI_input.printscreen) {
|
||||
@ -4151,7 +4143,6 @@ int newuiTiledWindow::DoUI() {
|
||||
|
||||
// this should poll UI_frame_result.
|
||||
while (UI_frame_result == -1) {
|
||||
DebugBlockPrint("UA");
|
||||
|
||||
Descent->defer();
|
||||
DoUIFrame();
|
||||
@ -4164,7 +4155,6 @@ int newuiTiledWindow::DoUI() {
|
||||
ui_EndDraw();
|
||||
ui_DoCursor();
|
||||
}
|
||||
DebugBlockPrint("UZ");
|
||||
rend_Flip();
|
||||
}
|
||||
|
||||
|
@ -2828,7 +2828,6 @@ void ObjDoFrame(object *obj) {
|
||||
RTP_STARTINCTIME(mt_physicsframe_time);
|
||||
|
||||
do_physics_sim(obj);
|
||||
DebugBlockPrint("DP");
|
||||
ObjCheckTriggers(obj);
|
||||
|
||||
RTP_ENDINCTIME(mt_physicsframe_time);
|
||||
@ -2837,7 +2836,6 @@ void ObjDoFrame(object *obj) {
|
||||
case MT_WALKING: {
|
||||
RTP_STARTINCTIME(mt_walkingframe_time);
|
||||
do_walking_sim(obj);
|
||||
DebugBlockPrint("DW");
|
||||
ObjCheckTriggers(obj);
|
||||
RTP_ENDINCTIME(mt_walkingframe_time);
|
||||
} break;
|
||||
|
@ -156,18 +156,14 @@ bool Debug_Init(bool debugger, bool mono_debug);
|
||||
// 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 *topstring, const char *title, const char *bottomstring);
|
||||
// displays an message box
|
||||
// displays a message box
|
||||
// Returns the same values as the Win32 MessageBox() function
|
||||
int Debug_MessageBox(int type, const char *title, const char *str);
|
||||
// these functions deal with debug spew support
|
||||
bool Debug_Logfile(const char *filename);
|
||||
void Debug_LogWrite(const char *str);
|
||||
bool Debug_ConsoleInit();
|
||||
void Debug_ConsoleOpen(int n, int row, int col, int width, int height, const char *title);
|
||||
void Debug_ConsoleClose(int n);
|
||||
void Debug_ConsolePrintf(int n, const char *format, ...);
|
||||
void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...);
|
||||
void Debug_ConsoleRedirectMessages(int virtual_window, int physical_window);
|
||||
// DEBUGGING MACROS
|
||||
// Break into the debugger, if this feature was enabled in Debug_init()
|
||||
#if !defined(RELEASE)
|
||||
|
@ -38,17 +38,14 @@
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "debug.h"
|
||||
#include "mono.h"
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Debug_break = false;
|
||||
bool Debug_mono = false;
|
||||
|
||||
static char *Debug_DumpInfo();
|
||||
|
||||
@ -57,15 +54,6 @@ bool Debug_Init(bool debugger, bool mono_debug) {
|
||||
#ifndef RELEASE
|
||||
Debug_break = debugger;
|
||||
|
||||
if (mono_debug) {
|
||||
Debug_ConsoleInit();
|
||||
Debug_ConsoleOpen(0, 9, 1, 78, 15, "Debug Spew");
|
||||
Debug_ConsoleOpen(1, 1, 1, 58, 6, "Warnings");
|
||||
Debug_ConsoleOpen(2, 1, 61, 18, 6, "Stats");
|
||||
|
||||
mprintf(0, "Linux system.\n");
|
||||
}
|
||||
|
||||
if (Debug_break)
|
||||
mprintf(0, "Debug Break enabled.\n");
|
||||
|
||||
@ -96,7 +84,7 @@ int Debug_MessageBox(int type, const char *title, const char *str) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char *Debug_DumpInfo(void) {
|
||||
char *Debug_DumpInfo() {
|
||||
static char e[] = "System Error";
|
||||
return e;
|
||||
}
|
||||
|
@ -43,285 +43,20 @@
|
||||
*
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
#include "mono.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cerrno>
|
||||
#include <csignal>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <memory.h>
|
||||
|
||||
// -------- Start TCP/IP Mono Logging Section
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAX_TCPLOG_LEN 2000
|
||||
#define SOCKET int
|
||||
#define SOCKADDR_IN sockaddr_in
|
||||
#define SOCKADDR sockaddr
|
||||
#define INVALID_SOCKET -1
|
||||
static SOCKET tcp_log_sock;
|
||||
static struct sockaddr_in tcp_log_addr;
|
||||
static char tcp_log_buffer[MAX_TCPLOG_LEN];
|
||||
static int Console_fd = -1;
|
||||
static bool Mono_initialized = false;
|
||||
static bool Mono_use_real = false;
|
||||
static bool Mono_use_window_remote = false;
|
||||
static int Debug_logfile = 0;
|
||||
bool Debug_print_block = false;
|
||||
|
||||
// ===============================
|
||||
// pthread library functions
|
||||
// ===============================
|
||||
#include <pthread.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if DLOPEN_PTHREAD
|
||||
typedef int (*pthread_create_fp)(pthread_t *__thread, __const pthread_attr_t *__attr, void *(*__start_routine)(void *),
|
||||
void *__arg);
|
||||
typedef int (*pthread_detach_fp)(pthread_t __th);
|
||||
typedef pthread_t (*pthread_self_fp)(void);
|
||||
|
||||
static pthread_create_fp dpthread_create = NULL;
|
||||
static pthread_detach_fp dpthread_detach = NULL;
|
||||
static pthread_self_fp dpthread_self = NULL;
|
||||
#else
|
||||
#define dpthread_create pthread_create
|
||||
#define dpthread_detach pthread_detach
|
||||
#define dpthread_self pthread_self
|
||||
#endif
|
||||
|
||||
static uint64_t Timer_sys_start_time = 0;
|
||||
static uint64_t Timer_accum = 0, Timer_high_mark = 0;
|
||||
|
||||
static float nw_TCPLoggingTimer(void) {
|
||||
uint32_t time_ms;
|
||||
uint64_t ret;
|
||||
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
|
||||
ret = (uint64_t)t.tv_sec * 1000000.0 + t.tv_usec;
|
||||
|
||||
if (ret > Timer_high_mark) {
|
||||
Timer_high_mark = ret;
|
||||
} else {
|
||||
// timer roll over
|
||||
if (Timer_high_mark > 0)
|
||||
Timer_accum += (Timer_high_mark - Timer_sys_start_time);
|
||||
Timer_high_mark = ret;
|
||||
Timer_sys_start_time = ret;
|
||||
ret = 100; // give some time
|
||||
}
|
||||
|
||||
time_ms = Timer_accum + ret - Timer_sys_start_time;
|
||||
|
||||
return (float)((double)time_ms / ((double)1000000.0));
|
||||
}
|
||||
|
||||
static bool nw_TCPLoggingTimer_Init(void) {
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
|
||||
Timer_sys_start_time = (uint64_t)t.tv_sec * 1000000.0 + t.tv_usec;
|
||||
Timer_accum = 0;
|
||||
Timer_high_mark = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static uint8_t outgoing_mono_packet[512];
|
||||
static volatile int outgoing_packet_size = 0;
|
||||
static volatile float outgoing_last_time_sent = 0;
|
||||
static volatile bool outgoing_packet_flush = false;
|
||||
static volatile bool outgoing_building_packet = false;
|
||||
|
||||
void *nw_TCPLoggingWorker(void *arg) {
|
||||
dpthread_detach(dpthread_self());
|
||||
|
||||
while (1) {
|
||||
if (tcp_log_sock == INVALID_SOCKET)
|
||||
break;
|
||||
|
||||
fd_set wfds;
|
||||
timeval timeout = {0, 0};
|
||||
|
||||
FD_ZERO(&wfds);
|
||||
FD_SET(tcp_log_sock, &wfds);
|
||||
|
||||
int sock_writable = select(tcp_log_sock + 1, NULL, &wfds, NULL, &timeout);
|
||||
|
||||
if (sock_writable == -1) {
|
||||
fprintf(stdout, "Error blocking on Monochrome server port\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
if (!sock_writable) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (outgoing_packet_size == 0)
|
||||
continue;
|
||||
if (outgoing_building_packet)
|
||||
continue;
|
||||
|
||||
int save_size = outgoing_packet_size;
|
||||
outgoing_packet_size = -1; // this informs the other thread that we are sending
|
||||
|
||||
float curr_time = nw_TCPLoggingTimer();
|
||||
if (curr_time > (outgoing_last_time_sent + 0.05f)) {
|
||||
// time to send the packet
|
||||
outgoing_last_time_sent = curr_time;
|
||||
|
||||
send(tcp_log_sock, outgoing_mono_packet, save_size, 0);
|
||||
|
||||
save_size = 0;
|
||||
}
|
||||
|
||||
outgoing_packet_size = save_size;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool nw_InitTCPLogging(char *ip, uint16_t port) {
|
||||
#if DLOPEN_PTHREAD
|
||||
// load up the pthread library
|
||||
void *lib = dlopen("libpthread.so", RTLD_GLOBAL | RTLD_NOW);
|
||||
if (!lib) {
|
||||
fprintf(stdout, "Error: Unable to load libpthread.so\n");
|
||||
_exit(1);
|
||||
}
|
||||
dpthread_create = (pthread_create_fp)dlsym(lib, "pthread_create");
|
||||
dpthread_detach = (pthread_detach_fp)dlsym(lib, "pthread_detach");
|
||||
dpthread_self = (pthread_self_fp)dlsym(lib, "pthread_self");
|
||||
#endif
|
||||
|
||||
uint32_t argp = 1;
|
||||
int addrlen = sizeof(SOCKADDR_IN);
|
||||
tcp_log_sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (INVALID_SOCKET == tcp_log_sock) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(&tcp_log_addr, 0, sizeof(SOCKADDR_IN));
|
||||
tcp_log_addr.sin_family = AF_INET;
|
||||
tcp_log_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
tcp_log_addr.sin_port = 0;
|
||||
|
||||
if (bind(tcp_log_sock, (SOCKADDR *)&tcp_log_addr, sizeof(sockaddr))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
tcp_log_addr.sin_addr.s_addr = inet_addr(ip);
|
||||
tcp_log_addr.sin_port = htons(port);
|
||||
|
||||
fd_set write_fs;
|
||||
FD_ZERO(&write_fs);
|
||||
FD_SET(tcp_log_sock, &write_fs);
|
||||
select(tcp_log_sock + 1, NULL, &write_fs, NULL, NULL);
|
||||
|
||||
fprintf(stdout, "Connecting to monochrome server (%s:%d)...\n", ip, port);
|
||||
|
||||
if (connect(tcp_log_sock, (SOCKADDR *)&tcp_log_addr, addrlen)) {
|
||||
int wserr;
|
||||
wserr = errno;
|
||||
fprintf(stdout, "Mono: Connect Failed...");
|
||||
|
||||
switch (wserr) {
|
||||
case EBADF:
|
||||
fprintf(stdout, "EBADF\n");
|
||||
break;
|
||||
case EFAULT:
|
||||
fprintf(stdout, "EFAULT\n");
|
||||
break;
|
||||
case ENOTSOCK:
|
||||
fprintf(stdout, "ENOTSOCK\n");
|
||||
break;
|
||||
case EISCONN:
|
||||
fprintf(stdout, "EISCONN\n");
|
||||
break;
|
||||
case ECONNREFUSED:
|
||||
fprintf(stdout, "EREFUSED\n");
|
||||
break;
|
||||
case ETIMEDOUT:
|
||||
fprintf(stdout, "ETIMEDOUT\n");
|
||||
break;
|
||||
case ENETUNREACH:
|
||||
fprintf(stdout, "ENETUNREACH\n");
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "Unknown error %d\n", wserr);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Monochrome server connected\n");
|
||||
|
||||
// init the packet sent time
|
||||
pthread_t thread;
|
||||
nw_TCPLoggingTimer_Init();
|
||||
outgoing_last_time_sent = nw_TCPLoggingTimer();
|
||||
|
||||
dpthread_create(&thread, NULL, nw_TCPLoggingWorker, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void nw_TCPPrintf(int n, char *format, ...) { return; }
|
||||
|
||||
void nw_SendMonoPacket(uint8_t *data, int size) {
|
||||
if (tcp_log_sock == INVALID_SOCKET) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (size > 512) {
|
||||
fprintf(stdout, "Mono: Packet > 512 bytes\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
outgoing_building_packet = true;
|
||||
while (outgoing_packet_size == -1)
|
||||
;
|
||||
|
||||
if (outgoing_packet_size + size > 512) {
|
||||
// crap...we need to flush
|
||||
fd_set wfds;
|
||||
FD_ZERO(&wfds);
|
||||
FD_SET(tcp_log_sock, &wfds);
|
||||
|
||||
int sock_writable = select(tcp_log_sock + 1, NULL, &wfds, NULL, NULL);
|
||||
|
||||
if (sock_writable == -1) {
|
||||
fprintf(stdout, "Error blocking on Monochrome server port\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
send(tcp_log_sock, outgoing_mono_packet, outgoing_packet_size, 0);
|
||||
outgoing_packet_size = 0;
|
||||
}
|
||||
|
||||
memcpy(&outgoing_mono_packet[outgoing_packet_size], data, size);
|
||||
outgoing_packet_size += size;
|
||||
|
||||
outgoing_building_packet = false;
|
||||
}
|
||||
|
||||
// ---------------- End TCP/IP Mono Logging Section
|
||||
|
||||
void Debug_LogClose();
|
||||
|
||||
@ -352,166 +87,18 @@ void Debug_LogClose() {
|
||||
}
|
||||
}
|
||||
|
||||
// void Debug_SetSpewFilter(uint32_t spew_filter)
|
||||
void Debug_SetSpewFilter(uint32_t) {}
|
||||
|
||||
// uint32_t Debug_GetSpewFilter(uint32_t spew_filter)
|
||||
uint32_t Debug_GetSpewFilter(uint32_t) { return 0; }
|
||||
|
||||
void Debug_ConsoleExit() {
|
||||
if (Console_fd >= 0)
|
||||
close(Console_fd);
|
||||
Console_fd = -1;
|
||||
}
|
||||
|
||||
#define MAX_ARGS 30
|
||||
#define MAX_CHARS_PER_ARG 100
|
||||
extern char GameArgs[MAX_ARGS][MAX_CHARS_PER_ARG];
|
||||
extern int FindArg(const char *which);
|
||||
|
||||
bool Debug_ConsoleInit() {
|
||||
int n = 0;
|
||||
|
||||
if (Mono_initialized)
|
||||
return true;
|
||||
|
||||
// Only use monochrome if D3_MONO environment var is set
|
||||
atexit(Debug_ConsoleExit);
|
||||
|
||||
Console_fd = open("/dev/omono", O_WRONLY);
|
||||
if (Console_fd >= 0) {
|
||||
Mono_use_real = true;
|
||||
Mono_initialized = true;
|
||||
}
|
||||
|
||||
int arg;
|
||||
if ((arg = FindArg("-monotcp")) != 0) {
|
||||
char address[256];
|
||||
strcpy(address, GameArgs[arg + 1]);
|
||||
char *port_ptr;
|
||||
port_ptr = strchr(address, ':');
|
||||
if (port_ptr) {
|
||||
*port_ptr = '\0';
|
||||
port_ptr++;
|
||||
uint16_t port;
|
||||
port = atoi(port_ptr);
|
||||
if (nw_InitTCPLogging(address, port)) {
|
||||
Mono_use_window_remote = true;
|
||||
Mono_initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Debug_ConsoleRedirectMessages(int virtual_window, int physical_window) {
|
||||
if (!Mono_initialized)
|
||||
return;
|
||||
|
||||
/*
|
||||
0x02 Redirect Messages
|
||||
|
||||
Parameters:
|
||||
Offset Size Value Description
|
||||
====== ==== ===== ===========
|
||||
0x01 0x01 0-7 Virtual window handle to be associated with physical window
|
||||
0x02 0x01 0-3 Window handle to be redirected
|
||||
*/
|
||||
// create the packet and send it off
|
||||
uint8_t packet[3];
|
||||
packet[0x00] = 0x02; // control code
|
||||
packet[0x01] = virtual_window; // virtual_handle
|
||||
packet[0x02] = physical_window; // physical_handle
|
||||
|
||||
// send the packet
|
||||
if (Mono_use_real) {
|
||||
write(Console_fd, packet, 3);
|
||||
}
|
||||
if (Mono_use_window_remote) {
|
||||
nw_SendMonoPacket(packet, 3);
|
||||
}
|
||||
}
|
||||
|
||||
void Debug_ConsoleOpen(int n, int row, int col, int width, int height, const char *title) {
|
||||
if (!Mono_initialized)
|
||||
return;
|
||||
|
||||
/*
|
||||
0x00 Open a window
|
||||
|
||||
Parameters:
|
||||
Offset Size Value Description
|
||||
====== ==== ===== ===========
|
||||
0x01 0x01 0-3 Window handle to be associated with window
|
||||
0x02 0x01 0-23 Upper left corner row value
|
||||
0x03 0x01 0-78 Upper left corner col value
|
||||
0x04 0x01 1-79 Number of cols (width)
|
||||
0x05 0x01 1-24 Number of rows (height)
|
||||
0x06 0x01 1-255 Length of the title string
|
||||
0x07-> [0x06] ---- Title string (not \0 terminated)
|
||||
*/
|
||||
|
||||
// create the packet and send it off
|
||||
uint8_t packet[512];
|
||||
int len = (title) ? strlen(title) : 1;
|
||||
packet[0x00] = 0x00; // control code
|
||||
packet[0x01] = n; // window_handle
|
||||
packet[0x02] = row; // row
|
||||
packet[0x03] = col; // col
|
||||
packet[0x04] = width; // width
|
||||
packet[0x05] = height; // height
|
||||
packet[0x06] = len;
|
||||
if (title)
|
||||
memcpy(&packet[0x07], title, len);
|
||||
else
|
||||
packet[0x07] = ' ';
|
||||
|
||||
// send the packet
|
||||
if (Mono_use_real) {
|
||||
write(Console_fd, packet, len + 7);
|
||||
}
|
||||
if (Mono_use_window_remote) {
|
||||
nw_SendMonoPacket(packet, len + 7);
|
||||
}
|
||||
}
|
||||
|
||||
void Debug_ConsoleClose(int n) {
|
||||
if (!Mono_initialized)
|
||||
return;
|
||||
|
||||
/*
|
||||
0x01 Closes a window
|
||||
|
||||
Parameters:
|
||||
Offset Size Value Description
|
||||
====== ==== ===== ===========
|
||||
0x01 0x01 0-3 Window handle to be associated with window
|
||||
|
||||
*/
|
||||
// create the packet and send it off
|
||||
uint8_t packet[2];
|
||||
packet[0x00] = 0x01; // control code
|
||||
packet[0x01] = n; // window_handle
|
||||
|
||||
// send the packet
|
||||
if (Mono_use_real) {
|
||||
write(Console_fd, packet, 2);
|
||||
}
|
||||
if (Mono_use_window_remote) {
|
||||
nw_SendMonoPacket(packet, 2);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define MAX_MONO_BUFFER 2048
|
||||
#else
|
||||
#define MAX_MONO_BUFFER 32
|
||||
#endif
|
||||
|
||||
static char Mono_buffer[MAX_MONO_BUFFER];
|
||||
|
||||
void Debug_ConsolePrintf(int n, const char *format, ...) {
|
||||
va_list marker;
|
||||
va_start(marker, format);
|
||||
int text_len = std::vsnprintf(Mono_buffer, MAX_MONO_BUFFER, format, marker);
|
||||
std::vsnprintf(Mono_buffer, MAX_MONO_BUFFER, format, marker);
|
||||
va_end(marker);
|
||||
|
||||
if (n == 0) {
|
||||
@ -522,76 +109,6 @@ void Debug_ConsolePrintf(int n, const char *format, ...) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
nw_TCPPrintf(n, Mono_buffer);
|
||||
|
||||
if (!Mono_initialized)
|
||||
return;
|
||||
|
||||
/*
|
||||
0x03 Window Print at cursor position
|
||||
|
||||
Parameters:
|
||||
Offset Size Value Description
|
||||
====== ==== ===== ===========
|
||||
0x01 0x01 0-3 Window handle to be associated with window
|
||||
0x02 0x02 0-512 (Little Endian) Length of the text string
|
||||
0x04 [0x02] ---- Text string (not \0 terminated)
|
||||
*/
|
||||
|
||||
// create the packet and send it off
|
||||
text_len = std::min(text_len, 512);
|
||||
uint8_t packet[518];
|
||||
packet[0x00] = 0x03; // control code
|
||||
packet[0x01] = n; // window_handle
|
||||
*((uint16_t *)&packet[0x02]) = text_len;
|
||||
memcpy(&packet[0x04], Mono_buffer, text_len);
|
||||
|
||||
// send the packet
|
||||
if (Mono_use_real) {
|
||||
write(Console_fd, packet, text_len + 4);
|
||||
}
|
||||
if (Mono_use_window_remote) {
|
||||
nw_SendMonoPacket(packet, text_len + 4);
|
||||
}
|
||||
}
|
||||
|
||||
void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...) {
|
||||
if (!Mono_initialized)
|
||||
return;
|
||||
|
||||
va_list marker;
|
||||
va_start(marker, format);
|
||||
int text_len = std::vsnprintf(Mono_buffer, MAX_MONO_BUFFER, format, marker);
|
||||
va_end(marker);
|
||||
|
||||
/*
|
||||
0x04 Window Print at row/col given
|
||||
|
||||
Parameters:
|
||||
Offset Size Value Description
|
||||
====== ==== ===== ===========
|
||||
0x01 0x01 0-3 Window handle to be associated with window
|
||||
0x02 0x01 0-24 Starting row (relative to window) of text
|
||||
0x03 0x01 0-79 Starting col (relative to window) of text
|
||||
0x04 0x02 0-512 (Little Endian) Length of the text string
|
||||
0x06 [0x04] ---- Text string (not \0 terminated)
|
||||
*/
|
||||
// create the packet and send it off
|
||||
uint8_t packet[518];
|
||||
text_len = std::min(text_len, 512);
|
||||
packet[0x00] = 0x04; // control code
|
||||
packet[0x01] = n; // window_handle
|
||||
packet[0x02] = row; // row
|
||||
packet[0x03] = col; // col
|
||||
*((uint16_t *)&packet[0x04]) = text_len;
|
||||
memcpy(&packet[0x06], Mono_buffer, text_len);
|
||||
|
||||
// send the packet
|
||||
if (Mono_use_real) {
|
||||
write(Console_fd, packet, text_len + 6);
|
||||
}
|
||||
if (Mono_use_window_remote) {
|
||||
// we can't send these to a mono server, they flood us
|
||||
// nw_SendMonoPacket(packet,text_len+6);
|
||||
}
|
||||
}
|
||||
void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...) {}
|
||||
|
@ -64,19 +64,12 @@
|
||||
#ifndef _MONO_H
|
||||
#define _MONO_H
|
||||
#include "debug.h"
|
||||
bool nw_InitTCPLogging(char *ip, uint16_t port);
|
||||
void nw_TCPPrintf(int n, char *format, ...);
|
||||
#if (!defined(RELEASE)) && defined(LOGGER)
|
||||
extern bool Debug_print_block;
|
||||
// Prints a formatted string to the debug window
|
||||
#define mprintf(...) Debug_ConsolePrintf(__VA_ARGS__)
|
||||
// Prints a formatted string on window n at row, col.
|
||||
#define mprintf_at(...) Debug_ConsolePrintfAt(__VA_ARGS__)
|
||||
#define DebugBlockPrint(...) \
|
||||
do { \
|
||||
if (Debug_print_block) \
|
||||
mprintf_at(1, 5, 51, __VA_ARGS__); \
|
||||
} while (0)
|
||||
#define DebugBlockPrint(...)
|
||||
#else // ifdef _DEBUG
|
||||
// DAJ defined in target headers
|
||||
#define mprintf(...)
|
||||
|
@ -200,49 +200,18 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Debug_break = false;
|
||||
bool Debug_NT = false;
|
||||
|
||||
char *Debug_DumpInfo();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Debug_Init(bool debugger, bool con_debug) {
|
||||
bool Debug_Init(bool debugger, bool mono_debug) {
|
||||
// initialization of debugging consoles.
|
||||
|
||||
DWORD version = GetVersion();
|
||||
|
||||
if (version & 0x80000000) {
|
||||
// Are we 95 or Win32s!
|
||||
if ((version & 0xff) < 4) {
|
||||
MessageBox(NULL, "This application will only run on Windows 95 or Windows NT.", "Error", MB_OK);
|
||||
exit(1);
|
||||
}
|
||||
Debug_NT = false;
|
||||
} else {
|
||||
if ((version & 0xff) < 4) {
|
||||
MessageBox(NULL, "This application needs Windows NT 4.0 or higher.", "Error", MB_OK);
|
||||
exit(1);
|
||||
}
|
||||
Debug_NT = true;
|
||||
}
|
||||
|
||||
#ifndef RELEASE
|
||||
|
||||
Debug_break = debugger;
|
||||
|
||||
if (con_debug) {
|
||||
Debug_ConsoleInit();
|
||||
Debug_ConsoleOpen(0, 9, 1, 78, 15, "Debug Spew");
|
||||
Debug_ConsoleOpen(1, 1, 1, 58, 6, "Warnings");
|
||||
|
||||
if (!Debug_NT) {
|
||||
Debug_ConsoleOpen(2, 1, 61, 18, 6, "Stats");
|
||||
mprintf(0, "Win95 system.\n");
|
||||
} else {
|
||||
mprintf(0, "WinNT system.\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (Debug_break) {
|
||||
mprintf(0, "Debug Break enabled.\n");
|
||||
}
|
||||
@ -260,7 +229,7 @@ bool Debug_Init(bool debugger, bool con_debug) {
|
||||
int Debug_ErrorBox(int type, const char *title, const char *topstring, const char *bottomstring) {
|
||||
int answer;
|
||||
char *dumptext = Debug_DumpInfo();
|
||||
HWND wnd = GetActiveWindow();
|
||||
// HWND wnd = GetActiveWindow();
|
||||
|
||||
// ShowWindow(wnd, SW_SHOWMINNOACTIVE);
|
||||
|
||||
@ -325,7 +294,7 @@ int Debug_MessageBox(int type, const char *title, const char *str) {
|
||||
|
||||
ShowCursor(TRUE);
|
||||
// ShowWindow(wnd, SW_SHOWMINNOACTIVE);
|
||||
answer = MessageBox(NULL, str, title, flags | MB_TASKMODAL | MB_SETFOREGROUND);
|
||||
answer = MessageBox(nullptr, str, title, flags | MB_TASKMODAL | MB_SETFOREGROUND);
|
||||
ShowCursor(FALSE);
|
||||
// ShowWindow(wnd, SW_SHOWMAXIMIZED);
|
||||
|
||||
@ -1206,7 +1175,7 @@ int __cdecl RecordExceptionInfo(PEXCEPTION_POINTERS data, const char *Message) {
|
||||
char bottommsg[1000] = "";
|
||||
char callstack[1000] = "";
|
||||
|
||||
wsprintf(topmsg, "Excecution in %s was stopped by %s", Message, desc);
|
||||
wsprintf(topmsg, "Execution in %s was stopped by %s", Message, desc);
|
||||
|
||||
wsprintf(bottommsg, FORMAT_REG, Context->Eax, Context->SegCs, Context->Eip, Context->EFlags, Context->Ebx,
|
||||
Context->SegSs, Context->Esp, Context->Ebp, Context->Ecx, Context->SegDs, Context->Esi, Context->SegFs,
|
||||
|
@ -20,78 +20,18 @@
|
||||
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "networking.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
#include <assert.h>
|
||||
#include <conio.h>
|
||||
#include <stdlib.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
extern bool Debug_NT;
|
||||
extern bool Debug_print_block = false;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// NT MONO DRIVER SPECS
|
||||
|
||||
//
|
||||
// Define the various device type values. Note that values used by Microsoft
|
||||
// Corporation are in the range 0-32767, and 32768-65535 are reserved for use
|
||||
// by customers.
|
||||
//
|
||||
|
||||
#define FILE_DEVICE_MONO 0x00008100
|
||||
|
||||
//
|
||||
// Macro definition for defining IOCTL and FSCTL function control codes. Note
|
||||
// that function codes 0-2047 are reserved for Microsoft Corporation, and
|
||||
// 2048-4095 are reserved for customers.
|
||||
//
|
||||
|
||||
#define MONO_IOCTL_INDEX 0x810
|
||||
|
||||
//
|
||||
// The MONO device driver IOCTLs
|
||||
//
|
||||
|
||||
#define IOCTL_MONO_PRINT CTL_CODE(FILE_DEVICE_MONO, MONO_IOCTL_INDEX, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_MONO_CLEAR_SCREEN CTL_CODE(FILE_DEVICE_MONO, MONO_IOCTL_INDEX + 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// console debugging functions
|
||||
|
||||
#define MAX_NUM_WINDOWS 4
|
||||
#define MAX_NUM_VWINDOWS 8
|
||||
|
||||
struct mono_element {
|
||||
uint8_t character;
|
||||
uint8_t attribute;
|
||||
};
|
||||
|
||||
struct WINDOW {
|
||||
int16_t first_row;
|
||||
int16_t height;
|
||||
int16_t first_col;
|
||||
int16_t width;
|
||||
int16_t cursor_row;
|
||||
int16_t cursor_col;
|
||||
int16_t open;
|
||||
struct mono_element save_buf[25][80];
|
||||
struct mono_element text[25][80];
|
||||
};
|
||||
|
||||
static bool Mono_initialized = 0;
|
||||
static mono_element (*Mono_screen)[25][80];
|
||||
static char Dbgstr_format[512];
|
||||
static WINDOW Window[MAX_NUM_WINDOWS];
|
||||
static uint8_t Mono_virtual_window_list[MAX_NUM_VWINDOWS];
|
||||
|
||||
#ifndef RELEASE
|
||||
#define MAX_MONO_LENGTH 2048
|
||||
#else
|
||||
@ -100,181 +40,8 @@ static uint8_t Mono_virtual_window_list[MAX_NUM_VWINDOWS];
|
||||
|
||||
static char Mono_buffer[MAX_MONO_LENGTH];
|
||||
|
||||
static HANDLE hNTMonoDriver = NULL;
|
||||
static int Debug_logfile = -1;
|
||||
|
||||
#define ROW Window[n].first_row
|
||||
#define HEIGHT Window[n].height
|
||||
#define COL Window[n].first_col
|
||||
#define WIDTH Window[n].width
|
||||
#define CROW Window[n].cursor_row
|
||||
#define CCOL Window[n].cursor_col
|
||||
#define OPEN Window[n].open
|
||||
#define CHAR(r, c) (*Mono_screen)[ROW + (r)][COL + (c)].character
|
||||
#define ATTR(r, c) (*Mono_screen)[ROW + (r)][COL + (c)].attribute
|
||||
#define XCHAR(r, c) Window[n].text[ROW + (r)][COL + (c)].character
|
||||
#define XATTR(r, c) Window[n].text[ROW + (r)][COL + (c)].attribute
|
||||
|
||||
void con_scroll(int n);
|
||||
void con_drawbox(int n);
|
||||
void con_clear(int n);
|
||||
void con_setcursor(int r, int c);
|
||||
void con_mputc(int n, char ch);
|
||||
|
||||
#define MAX_TCPLOG_LEN 2000
|
||||
SOCKET tcp_log_sock;
|
||||
SOCKADDR_IN tcp_log_addr;
|
||||
char tcp_log_buffer[MAX_TCPLOG_LEN];
|
||||
|
||||
bool nw_InitTCPLogging(char *ip, uint16_t port) {
|
||||
int addrlen = sizeof(SOCKADDR_IN);
|
||||
tcp_log_sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (INVALID_SOCKET == tcp_log_sock) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(&tcp_log_addr, 0, sizeof(SOCKADDR_IN));
|
||||
tcp_log_addr.sin_family = AF_INET;
|
||||
tcp_log_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
tcp_log_addr.sin_port = 0;
|
||||
|
||||
if (SOCKET_ERROR == bind(tcp_log_sock, (SOCKADDR *)&tcp_log_addr, sizeof(sockaddr))) {
|
||||
return false;
|
||||
}
|
||||
unsigned long arg = 1;
|
||||
ioctlsocket(tcp_log_sock, FIONBIO, &arg);
|
||||
|
||||
tcp_log_addr.sin_addr.s_addr = inet_addr(ip);
|
||||
tcp_log_addr.sin_port = htons(port);
|
||||
connect(tcp_log_sock, (SOCKADDR *)&tcp_log_addr, addrlen);
|
||||
return true;
|
||||
}
|
||||
|
||||
void nw_TCPPrintf(int n, char *format, ...) {
|
||||
std::va_list args;
|
||||
|
||||
if (tcp_log_sock == INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
// filter out messages for other windows
|
||||
if (n != 0)
|
||||
return;
|
||||
|
||||
va_start(args, format);
|
||||
std::vsnprintf(tcp_log_buffer, MAX_TCPLOG_LEN, format, args);
|
||||
|
||||
fd_set read_fds;
|
||||
timeval tv = {0, 0};
|
||||
|
||||
FD_ZERO(&read_fds);
|
||||
FD_SET(tcp_log_sock, &read_fds);
|
||||
|
||||
if (select(0, NULL, &read_fds, 0, &tv)) {
|
||||
send(tcp_log_sock, tcp_log_buffer, strlen(tcp_log_buffer), 0);
|
||||
} else {
|
||||
// Int3();
|
||||
}
|
||||
}
|
||||
|
||||
void Debug_ConsoleExit() {
|
||||
if (hNTMonoDriver)
|
||||
CloseHandle(hNTMonoDriver);
|
||||
}
|
||||
|
||||
bool Debug_ConsoleInit() {
|
||||
int n = 0;
|
||||
|
||||
if (Mono_initialized)
|
||||
return 1;
|
||||
|
||||
// Only use monochrome if D3_MONO environment var is set
|
||||
atexit(Debug_ConsoleExit);
|
||||
|
||||
if (Debug_NT == true) {
|
||||
hNTMonoDriver =
|
||||
CreateFile("\\\\.\\MONO", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hNTMonoDriver != (HANDLE)(-1))
|
||||
Mono_initialized = 1;
|
||||
else
|
||||
Mono_initialized = 0;
|
||||
}
|
||||
#ifdef OLD
|
||||
else {
|
||||
_outp(0x3b4, 0x0f);
|
||||
_outp(0x3b4 + 1, 0x55);
|
||||
|
||||
if (_inp(0x3b4 + 1) != 0x55) {
|
||||
if (getenv("D3_MONO"))
|
||||
Mono_initialized = 1;
|
||||
else
|
||||
Mono_initialized = 0;
|
||||
} else {
|
||||
_outp(0x3b4 + 1, 0);
|
||||
Mono_initialized = 1;
|
||||
}
|
||||
Mono_screen = (mono_element(*)[25][80])0xB0000;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Mono_initialized)
|
||||
OPEN = 1;
|
||||
else
|
||||
OPEN = 0;
|
||||
|
||||
ROW = 2;
|
||||
COL = 0;
|
||||
WIDTH = 80;
|
||||
HEIGHT = 24;
|
||||
CCOL = 0;
|
||||
CROW = 0;
|
||||
|
||||
con_clear(0);
|
||||
|
||||
for (n = 1; n < MAX_NUM_WINDOWS; n++) {
|
||||
OPEN = 0;
|
||||
ROW = 2;
|
||||
COL = 1;
|
||||
WIDTH = 78;
|
||||
HEIGHT = 23;
|
||||
CROW = 0;
|
||||
CCOL = 0;
|
||||
}
|
||||
|
||||
// map 0 always to itself.
|
||||
Mono_virtual_window_list[0] = 0;
|
||||
|
||||
for (n = 1; n < MAX_NUM_VWINDOWS; n++) {
|
||||
Mono_virtual_window_list[n] = -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Debug_ConsoleRedirectMessages(int virtual_window, int physical_window) {
|
||||
int i, n;
|
||||
|
||||
if (virtual_window < 1 || virtual_window >= MAX_NUM_VWINDOWS) {
|
||||
return;
|
||||
}
|
||||
if (physical_window < 1 || physical_window >= MAX_NUM_WINDOWS) {
|
||||
return;
|
||||
}
|
||||
|
||||
n = physical_window;
|
||||
if (!OPEN)
|
||||
return;
|
||||
|
||||
// clear out any bindings and map virtual window to physical window.
|
||||
for (i = 0; i < MAX_NUM_VWINDOWS; i++) {
|
||||
if (Mono_virtual_window_list[i] == physical_window) {
|
||||
Mono_virtual_window_list[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
Mono_virtual_window_list[virtual_window] = physical_window;
|
||||
con_clear(physical_window);
|
||||
}
|
||||
|
||||
void Debug_LogClose();
|
||||
|
||||
bool Debug_Logfile(const char *filename) {
|
||||
@ -304,333 +71,25 @@ void Debug_LogClose() {
|
||||
}
|
||||
}
|
||||
|
||||
void Debug_ConsoleOpen(int n, int row, int col, int width, int height, const char *title) {
|
||||
if (!Mono_initialized)
|
||||
return; // error! no mono card
|
||||
if (n >= MAX_NUM_WINDOWS)
|
||||
return;
|
||||
|
||||
if (OPEN)
|
||||
Debug_ConsoleClose(n);
|
||||
|
||||
OPEN = 1;
|
||||
ROW = row;
|
||||
COL = col;
|
||||
WIDTH = width;
|
||||
HEIGHT = height;
|
||||
|
||||
Mono_virtual_window_list[n] = n;
|
||||
|
||||
if (Debug_NT) {
|
||||
|
||||
} else {
|
||||
for (row = -1; row < HEIGHT + 1; row++)
|
||||
for (col = -1; col < WIDTH + 1; col++) {
|
||||
CHAR(row, col) = 32;
|
||||
ATTR(row, col) = 7;
|
||||
XCHAR(row, col) = 32;
|
||||
XATTR(row, col) = 7;
|
||||
}
|
||||
|
||||
con_drawbox(n);
|
||||
CROW = -1;
|
||||
CCOL = 0;
|
||||
Debug_ConsolePrintf(n, title);
|
||||
CROW = 0;
|
||||
CCOL = 0;
|
||||
con_setcursor(ROW + CROW, COL + CCOL);
|
||||
}
|
||||
}
|
||||
|
||||
void Debug_ConsoleClose(int n) {
|
||||
int row, col;
|
||||
|
||||
if (!OPEN)
|
||||
return;
|
||||
if (n >= MAX_NUM_WINDOWS)
|
||||
return;
|
||||
|
||||
if (Debug_NT) {
|
||||
|
||||
} else {
|
||||
for (row = -1; row < HEIGHT + 1; row++)
|
||||
for (col = -1; col < WIDTH + 1; col++) {
|
||||
CHAR(row, col) = 32;
|
||||
ATTR(row, col) = 7;
|
||||
}
|
||||
}
|
||||
|
||||
OPEN = 0;
|
||||
CCOL = 0;
|
||||
CROW = 0;
|
||||
|
||||
con_setcursor(0, 0);
|
||||
Mono_virtual_window_list[n] = -1;
|
||||
}
|
||||
|
||||
void Debug_ConsolePrintf(int n, const char *format, ...) {
|
||||
static bool newline = false;
|
||||
char *ptr = Mono_buffer;
|
||||
std::va_list args;
|
||||
|
||||
if (n >= MAX_NUM_VWINDOWS)
|
||||
return;
|
||||
if (n > 0) {
|
||||
n = Mono_virtual_window_list[n];
|
||||
}
|
||||
|
||||
// filter out messages
|
||||
if (n > MAX_NUM_WINDOWS || n < 0)
|
||||
return;
|
||||
|
||||
// if (!OPEN) return;
|
||||
|
||||
va_start(args, format);
|
||||
std::vsnprintf(ptr, MAX_MONO_LENGTH, format, args);
|
||||
va_end(args);
|
||||
|
||||
if (strlen(ptr) >= MAX_MONO_LENGTH) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (OPEN) {
|
||||
if (Debug_NT) {
|
||||
DWORD cbReturned;
|
||||
DeviceIoControl(hNTMonoDriver, (DWORD)IOCTL_MONO_PRINT, ptr, strlen(ptr) + 1, NULL, 0, &cbReturned, 0);
|
||||
} else {
|
||||
while (*ptr)
|
||||
con_mputc(n, *ptr++);
|
||||
}
|
||||
}
|
||||
|
||||
Debug_LogWrite(Mono_buffer);
|
||||
|
||||
if (n == 0) {
|
||||
OutputDebugString(Mono_buffer);
|
||||
nw_TCPPrintf(n, Mono_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...) {
|
||||
char *ptr = Mono_buffer;
|
||||
int r, c;
|
||||
std::va_list args;
|
||||
|
||||
if (Debug_NT)
|
||||
return;
|
||||
|
||||
if (n >= MAX_NUM_VWINDOWS)
|
||||
return;
|
||||
if (n > 0) {
|
||||
n = Mono_virtual_window_list[n];
|
||||
}
|
||||
|
||||
if (n > MAX_NUM_WINDOWS || n < 0)
|
||||
return;
|
||||
|
||||
va_start(args, format);
|
||||
std::vsnprintf(ptr, MAX_MONO_LENGTH, format, args);
|
||||
|
||||
// if (n==MAX_NUM_WINDOWS)
|
||||
// OutputDebugString (Mono_buffer);
|
||||
|
||||
if (!OPEN)
|
||||
return;
|
||||
|
||||
r = CROW;
|
||||
c = CCOL;
|
||||
CROW = row;
|
||||
CCOL = col;
|
||||
|
||||
while (*ptr)
|
||||
con_mputc(n, *ptr++);
|
||||
|
||||
CROW = r;
|
||||
CCOL = c;
|
||||
|
||||
if (n == 0)
|
||||
OutputDebugString(Mono_buffer);
|
||||
}
|
||||
|
||||
void con_mputc(int n, char c) {
|
||||
if (!OPEN)
|
||||
return;
|
||||
|
||||
if (Debug_NT) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case 8:
|
||||
if (CCOL > 0)
|
||||
CCOL--;
|
||||
break;
|
||||
case 9:
|
||||
CHAR(CROW, CCOL) = ' ';
|
||||
ATTR(CROW, CCOL) = XATTR(CROW, CCOL);
|
||||
XCHAR(CROW, CCOL) = ' ';
|
||||
CCOL++;
|
||||
while (CCOL % 4) {
|
||||
CHAR(CROW, CCOL) = ' ';
|
||||
ATTR(CROW, CCOL) = XATTR(CROW, CCOL);
|
||||
XCHAR(CROW, CCOL) = ' ';
|
||||
CCOL++;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
case 13:
|
||||
CCOL = 0;
|
||||
CROW++;
|
||||
break;
|
||||
default:
|
||||
CHAR(CROW, CCOL) = c;
|
||||
ATTR(CROW, CCOL) = XATTR(CROW, CCOL);
|
||||
XCHAR(CROW, CCOL) = c;
|
||||
CCOL++;
|
||||
}
|
||||
|
||||
if (CCOL >= WIDTH) {
|
||||
CCOL = 0;
|
||||
CROW++;
|
||||
}
|
||||
if (CROW >= HEIGHT) {
|
||||
CROW--;
|
||||
con_scroll(n);
|
||||
}
|
||||
|
||||
con_setcursor(ROW + CROW, COL + CCOL);
|
||||
}
|
||||
|
||||
void copy_row(int nwords, int16_t *src, int16_t *dest1, int16_t *dest2) {
|
||||
// TODO: disabled for now to get the x64 build compiling
|
||||
// do we even need all this old 'mono' stuff anymore?
|
||||
#ifndef _WIN64
|
||||
__asm {
|
||||
mov ecx,nwords
|
||||
mov esi,src
|
||||
mov ebx,dest1
|
||||
mov edx,dest2
|
||||
shr ecx, 1
|
||||
jnc even_num
|
||||
mov ax, [esi]
|
||||
add esi, 2
|
||||
mov [ebx], ax
|
||||
add ebx, 2
|
||||
mov [edx], ax
|
||||
add edx, 2
|
||||
even_num: cmp ecx, 0
|
||||
je done
|
||||
rowloop: mov eax, [esi]
|
||||
add esi, 4
|
||||
mov [edx], eax
|
||||
add edx, 4
|
||||
mov [ebx], eax
|
||||
add ebx, 4
|
||||
loop rowloop
|
||||
done:
|
||||
}
|
||||
#endif // _WIN64
|
||||
}
|
||||
|
||||
void con_scroll(int n) {
|
||||
register int row, col;
|
||||
|
||||
if (!OPEN)
|
||||
return;
|
||||
if (Debug_NT)
|
||||
return;
|
||||
|
||||
col = 0;
|
||||
for (row = 0; row < (HEIGHT - 1); row++)
|
||||
copy_row(WIDTH, (int16_t *)&XCHAR(row + 1, col), (int16_t *)&CHAR(row, col), (int16_t *)&XCHAR(row, col));
|
||||
|
||||
// for ( col = 0; col < WIDTH; col++ )
|
||||
// {
|
||||
// CHAR( row, col ) = XCHAR( row+1, col );
|
||||
// ATTR( row, col ) = XATTR( row+1, col );
|
||||
// XCHAR( row, col ) = XCHAR( row+1, col );
|
||||
// XATTR( row, col ) = XATTR( row+1, col );
|
||||
// }
|
||||
|
||||
for (col = 0; col < WIDTH; col++) {
|
||||
CHAR(HEIGHT - 1, col) = ' ';
|
||||
ATTR(HEIGHT - 1, col) = XATTR(HEIGHT - 1, col);
|
||||
XCHAR(HEIGHT - 1, col) = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
void con_setcursor(int row, int col) {
|
||||
int pos = row * 80 + col;
|
||||
|
||||
if (Debug_NT) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef OLD
|
||||
_outp(0x3b4, 15);
|
||||
_outp(0x3b5, pos & 0xFF);
|
||||
_outp(0x3b4, 14);
|
||||
_outp(0x3b5, (pos >> 8) & 0xff);
|
||||
#endif
|
||||
}
|
||||
|
||||
void con_drawbox(int n) {
|
||||
int16_t row, col;
|
||||
|
||||
if (!OPEN)
|
||||
return;
|
||||
|
||||
if (Debug_NT) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (row = 0; row < HEIGHT; row++) {
|
||||
CHAR(row, -1) = 179;
|
||||
CHAR(row, WIDTH) = 179;
|
||||
XCHAR(row, -1) = 179;
|
||||
XCHAR(row, WIDTH) = 179;
|
||||
}
|
||||
|
||||
for (col = 0; col < WIDTH; col++) {
|
||||
CHAR(-1, col) = 196;
|
||||
CHAR(HEIGHT, col) = 196;
|
||||
XCHAR(-1, col) = 196;
|
||||
XCHAR(HEIGHT, col) = 196;
|
||||
}
|
||||
|
||||
CHAR(-1, -1) = 218;
|
||||
CHAR(-1, WIDTH) = 191;
|
||||
CHAR(HEIGHT, -1) = 192;
|
||||
CHAR(HEIGHT, WIDTH) = 217;
|
||||
XCHAR(-1, -1) = 218;
|
||||
XCHAR(-1, WIDTH) = 191;
|
||||
XCHAR(HEIGHT, -1) = 192;
|
||||
XCHAR(HEIGHT, WIDTH) = 217;
|
||||
}
|
||||
|
||||
void con_clear(int n) {
|
||||
int16_t row, col;
|
||||
|
||||
if (!OPEN)
|
||||
return;
|
||||
|
||||
if (Debug_NT) {
|
||||
DWORD cbReturned;
|
||||
|
||||
DeviceIoControl(hNTMonoDriver, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0, &cbReturned, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
for (row = 0; row < HEIGHT; row++)
|
||||
for (col = 0; col < WIDTH; col++) {
|
||||
CHAR(row, col) = 32;
|
||||
ATTR(row, col) = 7;
|
||||
XCHAR(row, col) = 32;
|
||||
XATTR(row, col) = 7;
|
||||
}
|
||||
CCOL = 0;
|
||||
CROW = 0;
|
||||
}
|
||||
void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...) {}
|
||||
|
||||
#endif
|
||||
|
12
ddio/key.cpp
12
ddio/key.cpp
@ -288,18 +288,6 @@ void ddio_AddKeyToQueue(int key) {
|
||||
#ifdef _DEBUG
|
||||
if (DDIO_key_state[KEY_DEBUG])
|
||||
keycode |= KEY_DEBUGGED;
|
||||
if (keycode == (KEY_DEBUGGED + KEY_SHIFTED + KEY_M)) {
|
||||
static int current_virtual_window = 1;
|
||||
|
||||
current_virtual_window++;
|
||||
if (current_virtual_window == 2) { // skip stats window
|
||||
current_virtual_window++;
|
||||
}
|
||||
if (current_virtual_window == 5) {
|
||||
current_virtual_window = 1;
|
||||
}
|
||||
Debug_ConsoleRedirectMessages(current_virtual_window, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
temp = DDIO_key_queue.tail + 1;
|
||||
|
@ -780,8 +780,6 @@ void do_physics_sim(object *obj) {
|
||||
ASSERT(obj->movement_type == MT_PHYSICS);
|
||||
ASSERT(!(obj->mtype.phys_info.flags & PF_USES_THRUST) || obj->mtype.phys_info.drag != 0.0);
|
||||
|
||||
DebugBlockPrint("P ");
|
||||
|
||||
ASSERT(std::isfinite(obj->mtype.phys_info.velocity.x)); // Caller wants to go to infinity! -- Not FVI's fault.
|
||||
ASSERT(std::isfinite(obj->mtype.phys_info.velocity.y)); // Caller wants to go to infinity! -- Not FVI's fault.
|
||||
ASSERT(std::isfinite(obj->mtype.phys_info.velocity.z)); // Caller wants to go to infinity! -- Not FVI's fault.
|
||||
@ -2299,8 +2297,6 @@ void do_walking_sim(object *obj) {
|
||||
ASSERT(std::isfinite(obj->mtype.phys_info.velocity.y)); // Caller wants to go to infinity! -- Not FVI's fault.
|
||||
ASSERT(std::isfinite(obj->mtype.phys_info.velocity.z)); // Caller wants to go to infinity! -- Not FVI's fault.
|
||||
|
||||
DebugBlockPrint("PW");
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (!Game_do_walking_sim) {
|
||||
return;
|
||||
@ -2892,16 +2888,12 @@ void do_vis_physics_sim(vis_effect *vis) {
|
||||
}
|
||||
#endif
|
||||
|
||||
DebugBlockPrint("V ");
|
||||
|
||||
if (vis->flags & VF_DEAD) {
|
||||
DebugBlockPrint("DV");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fabsf(vis->velocity.x) < 0.000001f && fabsf(vis->velocity.y) < 0.000001f && fabsf(vis->velocity.z) < 0.000001f &&
|
||||
!(vis->phys_flags & PF_GRAVITY)) {
|
||||
DebugBlockPrint("DV");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2962,7 +2954,6 @@ void do_vis_physics_sim(vis_effect *vis) {
|
||||
}
|
||||
|
||||
if (vis->phys_flags & PF_NO_COLLIDE) {
|
||||
DebugBlockPrint("DV");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3005,7 +2996,6 @@ void do_vis_physics_sim(vis_effect *vis) {
|
||||
VisEffectDelete(vis - VisEffects);
|
||||
}
|
||||
|
||||
DebugBlockPrint("DV");
|
||||
}
|
||||
|
||||
void phys_apply_force(object *obj, vector *force_vec, int16_t weapon_index) {
|
||||
|
@ -651,7 +651,6 @@ void hlsSystem::BeginSoundFrame(bool f_in_game) {
|
||||
const int num_samples_this_frame = (int)(Frametime * 22050);
|
||||
if (!m_f_hls_system_init)
|
||||
return;
|
||||
DebugBlockPrint("S ");
|
||||
// determine if we're using hardware for sound support.
|
||||
m_ll_sound_ptr->SoundStartFrame();
|
||||
// non game sound frame, this, just updates currently playing sounds.
|
||||
@ -825,18 +824,15 @@ void hlsSystem::BeginSoundFrame(bool f_in_game) {
|
||||
// mprintf(0, "BeginSoundFrame: used sound_objects %d\n", counter);
|
||||
end_beginsoundframe:
|
||||
AudioStream::Frame();
|
||||
DebugBlockPrint("DS");
|
||||
mprintf_at(3, 1, 0, "HNS: %04d", counter);
|
||||
}
|
||||
|
||||
// Plays the deffered 3d stuff
|
||||
void hlsSystem::EndSoundFrame() {
|
||||
DebugBlockPrint("X ");
|
||||
if (!m_f_hls_system_init)
|
||||
return;
|
||||
sound_render_end_frame();
|
||||
m_ll_sound_ptr->SoundEndFrame();
|
||||
DebugBlockPrint("DX");
|
||||
}
|
||||
// Allows for changes in a currently playing sound
|
||||
int hlsSystem::Update2dSound(int hlsound_uid, float volume, float pan) {
|
||||
|
Loading…
Reference in New Issue
Block a user