summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-03-25 09:08:33 +0100
committerGitHub <noreply@github.com>2020-03-25 09:08:33 +0100
commit8703758a7b1d0fe1f8c837bb0a114d1e03145d1e (patch)
tree7111cc0686ba3d42a8853ce16464b079b79365be
parentchange default script to story (diff)
parentobrstr + Debug (diff)
downloadre3-8703758a7b1d0fe1f8c837bb0a114d1e03145d1e.tar
re3-8703758a7b1d0fe1f8c837bb0a114d1e03145d1e.tar.gz
re3-8703758a7b1d0fe1f8c837bb0a114d1e03145d1e.tar.bz2
re3-8703758a7b1d0fe1f8c837bb0a114d1e03145d1e.tar.lz
re3-8703758a7b1d0fe1f8c837bb0a114d1e03145d1e.tar.xz
re3-8703758a7b1d0fe1f8c837bb0a114d1e03145d1e.tar.zst
re3-8703758a7b1d0fe1f8c837bb0a114d1e03145d1e.zip
-rw-r--r--src/core/Debug.cpp85
-rw-r--r--src/core/Debug.h13
-rw-r--r--src/core/obrstr.cpp119
-rw-r--r--src/core/obrstr.h9
4 files changed, 221 insertions, 5 deletions
diff --git a/src/core/Debug.cpp b/src/core/Debug.cpp
index b80e9959..bdcbaf04 100644
--- a/src/core/Debug.cpp
+++ b/src/core/Debug.cpp
@@ -1,12 +1,91 @@
+#include "common.h"
#include "Debug.h"
+#include "Font.h"
+#include "main.h"
+#include "Text.h"
-int CDebug::ms_nCurrentTextLine;
+bool gbDebugStuffInRelease = false;
-void CDebug::DebugInitTextBuffer()
+#define DEBUG_X_POS (300)
+#define DEBUG_Y_POS (41)
+#define DEBUG_LINE_HEIGHT (22)
+
+int16 CDebug::ms_nCurrentTextLine;
+char CDebug::ms_aTextBuffer[MAX_LINES][MAX_STR_LEN];
+
+void
+CDebug::DebugInitTextBuffer()
{
ms_nCurrentTextLine = 0;
}
-void CDebug::DebugDisplayTextBuffer()
+void
+CDebug::DebugAddText(const char *str)
+{
+ int32 i = 0;
+ if (*str != '\0') {
+ while (i < MAX_STR_LEN) {
+ ms_aTextBuffer[ms_nCurrentTextLine][i++] = *(str++);
+ if (*str == '\0')
+ break;
+ }
+ }
+
+ ms_aTextBuffer[ms_nCurrentTextLine++][i] = '\0';
+ if (ms_nCurrentTextLine >= MAX_LINES)
+ ms_nCurrentTextLine = 0;
+}
+
+void
+CDebug::DebugDisplayTextBuffer()
{
+#ifndef MASTER
+ if (gbDebugStuffInRelease)
+ {
+ int32 i = 0;
+ int32 y = DEBUG_Y_POS;
+#ifdef FIX_BUGS
+ CFont::SetPropOn();
+ CFont::SetBackgroundOff();
+ CFont::SetScale(1.0f, 1.0f);
+ CFont::SetCentreOff();
+ CFont::SetRightJustifyOff();
+ CFont::SetJustifyOn();
+ CFont::SetRightJustifyWrap(0.0f);
+ CFont::SetBackGroundOnlyTextOff();
+ CFont::SetFontStyle(FONT_BANK);
+#else
+ // this is not even readable
+ CFont::SetPropOff();
+ CFont::SetBackgroundOff();
+ CFont::SetScale(1.0f, 1.0f);
+ CFont::SetCentreOff();
+ CFont::SetRightJustifyOn();
+ CFont::SetRightJustifyWrap(0.0f);
+ CFont::SetBackGroundOnlyTextOff();
+ CFont::SetFontStyle(FONT_BANK);
+ CFont::SetPropOff();
+#endif
+ do {
+ char *line;
+ while (true) {
+ line = ms_aTextBuffer[(ms_nCurrentTextLine + i++) % MAX_LINES];
+ if (*line != '\0')
+ break;
+ y += DEBUG_LINE_HEIGHT;
+ if (i == MAX_LINES) {
+ CFont::DrawFonts();
+ return;
+ }
+ }
+ AsciiToUnicode(line, gUString);
+ CFont::SetColor(CRGBA(0, 0, 0, 255));
+ CFont::PrintString(DEBUG_X_POS, y-1, gUString);
+ CFont::SetColor(CRGBA(255, 128, 128, 255));
+ CFont::PrintString(DEBUG_X_POS+1, y, gUString);
+ y += DEBUG_LINE_HEIGHT;
+ } while (i != MAX_LINES);
+ CFont::DrawFonts();
+ }
+#endif
}
diff --git a/src/core/Debug.h b/src/core/Debug.h
index 395f66af..444a0cf5 100644
--- a/src/core/Debug.h
+++ b/src/core/Debug.h
@@ -2,10 +2,19 @@
class CDebug
{
- static int ms_nCurrentTextLine;
+ enum
+ {
+ MAX_LINES = 15,
+ MAX_STR_LEN = 80,
+ };
+
+ static int16 ms_nCurrentTextLine;
+ static char ms_aTextBuffer[MAX_LINES][MAX_STR_LEN];
public:
static void DebugInitTextBuffer();
static void DebugDisplayTextBuffer();
-
+ static void DebugAddText(const char *str);
};
+
+extern bool gbDebugStuffInRelease;
diff --git a/src/core/obrstr.cpp b/src/core/obrstr.cpp
new file mode 100644
index 00000000..3663d134
--- /dev/null
+++ b/src/core/obrstr.cpp
@@ -0,0 +1,119 @@
+#include "common.h"
+#include "Debug.h"
+#include "obrstr.h"
+
+char obrstr[128];
+char obrstr2[128];
+
+void ObrInt(int32 n1)
+{
+ IntToStr(n1, obrstr);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt2(int32 n1, int32 n2)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt3(int32 n1, int32 n2, int32 n3)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n3, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt4(int32 n1, int32 n2, int32 n3, int32 n4)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n3, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n4, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt5(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n3, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n4, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n5, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void ObrInt6(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6)
+{
+ IntToStr(n1, obrstr);
+ strcat(obrstr, " ");
+ IntToStr(n2, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n3, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n4, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n5, obrstr2);
+ strcat(obrstr, obrstr2);
+ strcat(obrstr, " ");
+ IntToStr(n6, obrstr2);
+ strcat(obrstr, obrstr2);
+ CDebug::DebugAddText(obrstr);
+}
+
+void IntToStr(int32 inNum, char *outStr)
+{
+ bool isNeg = inNum < 0;
+
+ if (isNeg) {
+ inNum = -inNum;
+ *outStr = '-';
+ }
+
+ int16 digits = 1;
+
+ if (inNum > 9) {
+ int32 _inNum = inNum;
+ do {
+ digits++;
+ _inNum /= 10;
+ } while (_inNum > 9);
+ }
+
+ int32 strSize = digits;
+ if (isNeg)
+ strSize++;
+
+ char *pStr = &outStr[strSize];
+ int32 i = 0;
+ do {
+ *(pStr-- - 1) = (inNum % 10) + '0';
+ inNum /= 10;
+ } while (++i < strSize);
+ outStr[strSize] = '\0';
+} \ No newline at end of file
diff --git a/src/core/obrstr.h b/src/core/obrstr.h
new file mode 100644
index 00000000..6838afb5
--- /dev/null
+++ b/src/core/obrstr.h
@@ -0,0 +1,9 @@
+#pragma once
+
+void ObrInt(int32 n1);
+void ObrInt2(int32 n1, int32 n2);
+void ObrInt3(int32 n1, int32 n2, int32 n3);
+void ObrInt4(int32 n1, int32 n2, int32 n3, int32 n4);
+void ObrInt5(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5);
+void ObrInt6(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6);
+void IntToStr(int32 inNum, char *outStr); \ No newline at end of file