summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-03-22 15:26:18 +0100
committerNikolay Korolev <nickvnuk@gmail.com>2020-03-22 15:26:18 +0100
commit360d9cf8895123d978ac4c4dae56f6ba76f379b6 (patch)
tree716e881db18506e2fee9a53f5674f28edce72138
parentCGame::Initialise (diff)
parentConsole (diff)
downloadre3-360d9cf8895123d978ac4c4dae56f6ba76f379b6.tar
re3-360d9cf8895123d978ac4c4dae56f6ba76f379b6.tar.gz
re3-360d9cf8895123d978ac4c4dae56f6ba76f379b6.tar.bz2
re3-360d9cf8895123d978ac4c4dae56f6ba76f379b6.tar.lz
re3-360d9cf8895123d978ac4c4dae56f6ba76f379b6.tar.xz
re3-360d9cf8895123d978ac4c4dae56f6ba76f379b6.tar.zst
re3-360d9cf8895123d978ac4c4dae56f6ba76f379b6.zip
-rw-r--r--src/core/RwMatFX.cpp1
-rw-r--r--src/core/common.h3
-rw-r--r--src/core/re3.cpp1
-rw-r--r--src/render/Console.cpp104
-rw-r--r--src/render/Console.h28
5 files changed, 97 insertions, 40 deletions
diff --git a/src/core/RwMatFX.cpp b/src/core/RwMatFX.cpp
index 5fd00c54..ca9a633b 100644
--- a/src/core/RwMatFX.cpp
+++ b/src/core/RwMatFX.cpp
@@ -143,6 +143,7 @@ _rpMatFXD3D8AtomicMatFXEnvRender_ps2(RxD3D8InstanceData *inst, int flags, int se
RwD3D8SetTexture(texture, 0);
else
RwD3D8SetTexture(nil, 0);
+ RwD3D8SetPixelShader(0);
RwD3D8SetVertexShader(inst->vertexShader);
RwD3D8SetStreamSource(0, inst->vertexBuffer, inst->stride);
RwD3D8SetIndices(inst->indexBuffer, inst->baseIndex);
diff --git a/src/core/common.h b/src/core/common.h
index 9a5cdb38..562a69b4 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -370,3 +370,6 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value)
assert(ReadSaveBuf<char>(buf) == c);\
assert(ReadSaveBuf<char>(buf) == d);\
assert(ReadSaveBuf<uint32>(buf) == size);
+
+
+void cprintf(char*, ...); \ No newline at end of file
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index ed32632f..6f0a4682 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -19,6 +19,7 @@
#include "Ped.h"
#include "debugmenu_public.h"
#include "Particle.h"
+#include "Console.h"
#include <vector>
#include <list>
diff --git a/src/render/Console.cpp b/src/render/Console.cpp
index b4a10e54..7f783264 100644
--- a/src/render/Console.cpp
+++ b/src/render/Console.cpp
@@ -1,43 +1,95 @@
+#include "common.h"
+#include "patcher.h"
#include "Console.h"
-
#include "Font.h"
#include "Timer.h"
-#define CONSOLE_MESSAGE_SHOW_TIME 20000
-#define CONSOLE_MESSAGE_HEIGHT 12.0f
-#define CONSOLE_MESSAGE_X_OFFSET 30.0f
-#define CONSOLE_MESSAGE_Y_OFFSET 10.0f
-#define CONSOLE_MESSAGE_X_SHADOW_OFFSET 1.0f
-#define CONSOLE_MESSAGE_Y_SHADOW_OFFSET 1.0f
+#define CONSOLE_X_POS (30.0f)
+#define CONSOLE_Y_POS (10.0f)
+#define CONSOLE_LINE_HEIGHT (12.0f)
+
+CConsole &TheConsole = *(CConsole*)0x8F6498;
+
+void
+CConsole::AddLine(char *s, uint8 r, uint8 g, uint8 b)
+{
+ char tempstr[MAX_STR_LEN+1];
+
+ while (strlen(s) > MAX_STR_LEN) {
+ strncpy_s(tempstr, s, MAX_STR_LEN);
+ tempstr[MAX_STR_LEN-1] = '\0';
+ s += MAX_STR_LEN - 1;
+ AddOneLine(tempstr, r, g, b);
+ }
+ AddOneLine(s, r, g, b);
+}
+
+void
+CConsole::AddOneLine(char *s, uint8 r, uint8 g, uint8 b)
+{
+ int32 StrIndex = (m_nLineCount + m_nCurrentLine) % MAX_LINES;
+
+ for (int32 i = 0; i < MAX_STR_LEN; i++) {
+ Buffers[StrIndex][i] = s[i];
+ if (s[i] == '\0') break;
+ }
+
+ uint8 _strNum1 = m_nLineCount;
+ if (_strNum1 < MAX_LINES)
+ _strNum1++;
+
+ m_aTimer[StrIndex] = CTimer::GetTimeInMilliseconds();
+ Buffers[StrIndex][MAX_STR_LEN-1] = '\0';
+ m_aRed[StrIndex] = r;
+ m_aGreen[StrIndex] = g;
+ m_aBlue[StrIndex] = b;
-CConsole& TheConsole = *(CConsole*)0x8F6498;
+ if (_strNum1 >= MAX_LINES)
+ m_nCurrentLine = (m_nCurrentLine + 1) % MAX_LINES;
+ else
+ m_nLineCount = _strNum1;
-void CConsole::Display()
+}
+
+void
+CConsole::Display()
{
CFont::SetPropOn();
CFont::SetBackgroundOff();
- CFont::SetScale(0.6f, 0.6f);
+ CFont::SetScale(0.6f, 0.6f);
CFont::SetCentreOff();
CFont::SetRightJustifyOff();
+ CFont::SetJustifyOn();
+ CFont::SetRightJustifyWrap(0.0f);
CFont::SetBackGroundOnlyTextOff();
- CFont::SetFontStyle(0);
- CFont::SetPropOff();
+ CFont::SetFontStyle(FONT_BANK);
+#ifndef FIX_BUGS
+ CFont::SetPropOff(); // not sure why this is here anyway
+#endif
CFont::SetWrapx(RsGlobal.width);
- while (m_nActiveMessages != 0 && CTimer::GetTimeInMilliseconds() - m_anTimeStart[m_nCurrentMessage] > CONSOLE_MESSAGE_SHOW_TIME) {
- m_nActiveMessages--;
- m_nCurrentMessage = (m_nCurrentMessage + 1) % NUM_CONSOLEMESSAGES;
+
+ while (m_nLineCount != 0 && CTimer::GetTimeInMilliseconds() - m_aTimer[m_nCurrentLine] > 20000) {
+ m_nLineCount--;
+ m_nCurrentLine = (m_nCurrentLine + 1) % MAX_LINES;
}
- for (int i = 0; i < m_nActiveMessages; i++) {
- int actualIndex = (i + m_nCurrentMessage) % NUM_CONSOLEMESSAGES;
+
+ for (int16 i = 0; i < m_nLineCount; i++) {
+ int16 line = (i + m_nCurrentLine) % MAX_LINES;
CFont::SetColor(CRGBA(0, 0, 0, 200));
- CFont::PrintString(
- CONSOLE_MESSAGE_X_OFFSET + CONSOLE_MESSAGE_X_SHADOW_OFFSET,
- CONSOLE_MESSAGE_Y_OFFSET + CONSOLE_MESSAGE_Y_SHADOW_OFFSET + i * CONSOLE_MESSAGE_HEIGHT,
- m_asMessages[actualIndex]);
- CFont::SetColor(CRGBA(m_anColourRed[actualIndex], m_anColourGreen[actualIndex], m_anColourBlue[actualIndex], 200));
- CFont::PrintString(
- CONSOLE_MESSAGE_X_OFFSET,
- CONSOLE_MESSAGE_Y_OFFSET + i * CONSOLE_MESSAGE_HEIGHT,
- m_asMessages[actualIndex]);
+ CFont::PrintString(CONSOLE_X_POS + 1.0f, CONSOLE_Y_POS + 1.0f + i * CONSOLE_LINE_HEIGHT, Buffers[line]);
+ CFont::SetColor(CRGBA(m_aRed[line], m_aGreen[line], m_aBlue[line], 200));
+ CFont::PrintString(CONSOLE_X_POS, CONSOLE_Y_POS + i * CONSOLE_LINE_HEIGHT, Buffers[line]);
}
+}
+
+void
+cprintf(char* format, ...)
+{
+ char s[256];
+ va_list vl1, vl2;
+
+ va_start(vl1, format);
+ va_copy(vl2, vl1);
+ vsprintf(s, format, vl1);
+ TheConsole.AddLine(s, 255, 255, 128);
} \ No newline at end of file
diff --git a/src/render/Console.h b/src/render/Console.h
index 726f96cf..f66d63d5 100644
--- a/src/render/Console.h
+++ b/src/render/Console.h
@@ -1,24 +1,24 @@
#pragma once
-#include "common.h"
class CConsole
{
- enum {
- MAX_MESSAGE_LENGTH = 40
+ enum
+ {
+ MAX_LINES = 8, // BUG? only shows 7
+ MAX_STR_LEN = 40,
};
- uint8 m_nActiveMessages;
- uint8 m_nCurrentMessage;
- wchar m_asMessages[NUM_CONSOLEMESSAGES][MAX_MESSAGE_LENGTH];
- uint32 m_anTimeStart[NUM_CONSOLEMESSAGES];
- uint8 m_anColourRed[NUM_CONSOLEMESSAGES];
- uint8 m_anColourGreen[NUM_CONSOLEMESSAGES];
- uint8 m_anColourBlue[NUM_CONSOLEMESSAGES];
+ uint8 m_nLineCount;
+ uint8 m_nCurrentLine;
+ wchar Buffers[MAX_LINES][MAX_STR_LEN];
+ uint32 m_aTimer[MAX_LINES];
+ uint8 m_aRed[MAX_LINES];
+ uint8 m_aGreen[MAX_LINES];
+ uint8 m_aBlue[MAX_LINES];
public:
- void Init() { m_nCurrentMessage = 0; m_nActiveMessages = 0; }
+ void AddLine(char *s, uint8 r, uint8 g, uint8 b);
+ void AddOneLine(char *s, uint8 r, uint8 g, uint8 b);
void Display();
};
-extern CConsole& TheConsole;
-
-static_assert(sizeof(CConsole) == 0x2BC, "CConsole: error"); \ No newline at end of file
+extern CConsole &TheConsole; \ No newline at end of file