Skip to content

Commit 5d4fd1b

Browse files
committed
d_debug_pad mostly done
1 parent 9872237 commit 5d4fd1b

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

include/d/d_debug_pad.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
#ifndef D_DEBUG_PAD_H
22
#define D_DEBUG_PAD_H
33

4-
#include "m_Do/m_Do_controller_pad.h"
54
#include "JSystem/JUtility/TColor.h"
65

76
class dDebugPad_c {
87
public:
8+
enum Mode_e {
9+
MODE_CAMERA_e,
10+
MODE_LIGHT_e,
11+
MODE_WINDTEST_e,
12+
MODE_SDCARD_e,
13+
14+
MODE_MAX_e,
15+
};
16+
917
dDebugPad_c();
1018

1119
bool Active() { return mIsActive; }
@@ -14,6 +22,8 @@ class dDebugPad_c {
1422
bool Enable(s32);
1523
bool Trigger();
1624

25+
static const char mode_name[MODE_MAX_e][9];
26+
1727
/* 0x0 */ bool mIsActive;
1828
/* 0x1 */ u8 mTrigger;
1929
/* 0x4 */ s32 mMode;

src/d/d_debug_pad.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#include "d/d_debug_pad.h"
2+
#include "m_Do/m_Do_controller_pad.h"
3+
#include "JSystem/JUtility/JUTDbPrint.h"
4+
#include "JSystem/JUtility/JUTReport.h"
5+
#include "f_ap/f_ap_game.h"
6+
7+
dDebugPad_c::dDebugPad_c() {
8+
mIsActive = false;
9+
mMode = MODE_CAMERA_e;
10+
mTrigger = false;
11+
}
12+
13+
const char dDebugPad_c::mode_name[MODE_MAX_e][9] = {
14+
"CAMERA",
15+
"BsLight",
16+
"WindTest",
17+
"SDCARD",
18+
};
19+
20+
bool dDebugPad_c::Update() {
21+
mTrigger = false;
22+
23+
if (mDoCPd_c::getTrigStart(PAD_3)) {
24+
mIsActive = mIsActive ? false : true;
25+
mTrigger = true;
26+
}
27+
28+
if (mIsActive) {
29+
if (mDoCPd_c::getTrigZ(PAD_3)) {
30+
mMode = (mMode + 1) % MODE_MAX_e;
31+
}
32+
33+
int x = 10;
34+
int y = 40;
35+
int line_height = 15;
36+
JUtility::TColor sp40(0xC8, 0x80, 0xFF, 0xC0);
37+
JUtility::TColor sp3C(0xFF, 0xC0, 0xC0, 0xFF);
38+
39+
Report(x, y, sp40, "+-DEBUG-PAD-+");
40+
41+
int i;
42+
for (i = 0; i < MODE_MAX_e; i++) {
43+
y += line_height;
44+
45+
if (i == mMode) {
46+
Report(x, y, sp40, "| |");
47+
Report(x, y, sp3C, " @%-8s ", mode_name[i]);
48+
} else {
49+
Report(x, y, sp40, "| %-8s |", mode_name[i]);
50+
}
51+
}
52+
53+
for (i = 0; i < 1; i++) {
54+
y += line_height;
55+
Report(x, y, sp40, "| |");
56+
}
57+
58+
y += line_height;
59+
Report(x, y, sp40, "+-----------+");
60+
}
61+
62+
return mIsActive;
63+
}
64+
65+
bool dDebugPad_c::Report(int x, int y, JUtility::TColor color, const char* message, ...) {
66+
char buffer[256];
67+
68+
static JUtility::TColor ShadowDarkColor(0, 0, 0, 0x80);
69+
70+
if (mIsActive) {
71+
va_list list;
72+
va_start(list, message);
73+
vsnprintf(buffer, sizeof(buffer), message, list);
74+
va_end(list);
75+
76+
JUTDbPrint::getManager()->flush();
77+
JUTDbPrint::getManager()->setCharColor(ShadowDarkColor);
78+
JUTReport(x + 2, y + 2, buffer);
79+
JUTDbPrint::getManager()->flush();
80+
JUTDbPrint::getManager()->setCharColor(color);
81+
JUTReport(x, y, buffer);
82+
JUTDbPrint::getManager()->flush();
83+
JUTDbPrint::getManager()->setCharColor(g_HIO.mColor);
84+
return true;
85+
}
86+
87+
return false;
88+
}
89+
90+
dDebugPad_c dDebugPad;

0 commit comments

Comments
 (0)