Skip to content

Commit e5567e7

Browse files
committed
Library refactor up to prim
1 parent fc301e5 commit e5567e7

File tree

98 files changed

+2939
-2426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2939
-2426
lines changed

.clang-format

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ WhitespaceSensitiveMacros: [
2121
NW4R_EF_LIST_FOREACH_SAFE,
2222
EGG_ASSERT,
2323
EGG_ASSERT_MSG,
24+
K_ASM,
25+
KOKESHI_BY_PACK,
26+
KM_BRANCH_MF,
27+
KM_BRANCH,
28+
KM_CALL_MF,
29+
KM_CALL,
2430
ASM,
2531
TRAMPOLINE,
2632
TRAMPOLINE_EX,

base/symbols_resort.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3636,6 +3636,8 @@ AppendDrawObject__13RPGrpRendererFP16IRPGrpDrawObject=0x80253d44
36363636
CreateView2D__13RPGrpRendererFUcP11RPGrpScreen=0x80253e1c
36373637
CorrectView__13RPGrpRendererFv=0x80253d68
36383638
__vt__11RPGrpScreen=0x806b5358
3639+
spInstance__16RPSysSaveDataMgr=0x806f4cc0
3640+
setSaveDisable__16RPSysSaveDataMgrFb=0x802338d4
36393641

36403642
startSeWithRemote__Q23Sp23SndFUlUl=0x802b735c
36413643
startSe__Q23Sp23SndFUl=0x802b73bc

docs/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,10 @@ Macros can be documented like functions, but also a single-line comment will suf
444444
* @param major Major version number
445445
* @param minor Minor version number
446446
*/
447-
#define K_VERSION(major, minor) ((major << 8) | minor)
447+
#define K_BIN_VERSION(major, minor) ((major << 8) | minor)
448448
449449
//! Helper for creating version numbers
450-
#define K_VERSION(major, minor) ((major << 8) | minor)
450+
#define K_BIN_VERSION(major, minor) ((major << 8) | minor)
451451
```
452452

453453
##### Data

examples/CustomScene.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ class CustomScene : public kiwi::IScene {
7878
// To make the scene creator aware of your custom scene, you need to construct a
7979
// scene declaration, or SceneDecl object.
8080
//
81-
// To simplify construction, libkiwi provides the K_SCENE_DECL macro.
81+
// To simplify construction, libkiwi provides the K_DECL_SCENE macro.
8282
// Its argument must be the scene's class name.
8383
//
8484
// This macro creates a static object, so it must be placed within the .cpp
8585
// file, not the header file.
8686
//
87-
K_SCENE_DECL(CustomScene);
87+
K_DECL_SCENE(CustomScene);
8888

8989
//=============================================================================
9090
// Scene change

include/Pack/RPSystem/RPSysScene.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RPSysScene : public EGG::Scene, public IRPGrpDrawObject {
2828
* @brief Scene type
2929
* @ws2
3030
*/
31-
enum EKind{
31+
enum EKind {
3232
EKind_System = 'SYS_', //!< RPSysScene
3333
EKind_Base = 'BASE', //!< RPSportsBaseScene
3434
EKind_Game = 'GAME', //!< RPSportsGameScene
@@ -39,7 +39,7 @@ class RPSysScene : public EGG::Scene, public IRPGrpDrawObject {
3939
* @brief Island time
4040
* @ws2
4141
*/
42-
enum ETime{
42+
enum ETime {
4343
ETime_Day, //!< Force daytime
4444
ETime_Evening, //!< Force evening
4545
ETime_Night, //!< Force night
@@ -177,7 +177,7 @@ class RPSysScene : public EGG::Scene, public IRPGrpDrawObject {
177177
* @brief Updates the scene's MotionPlus state
178178
* @ws2
179179
*/
180-
virtual void CalculateMotionPlus() {}
180+
virtual void CalculateMPlus() {}
181181
#endif
182182

183183
/**

include/egg/core/eggExpHeap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ struct ExpHeap : Heap {
1616
virtual u32 getAllocatableSize(s32); // at 0x24
1717
virtual u32 adjust(); // at 0x28
1818

19-
static ExpHeap* create(void*, u32, u16);
20-
static ExpHeap* create(u32, Heap*, u16);
19+
static ExpHeap* create(void*, u32, u16 = 0);
20+
static ExpHeap* create(u32, Heap*, u16 = 0);
2121
};
2222
} // namespace EGG
2323

lib/libkiwi/core/kiwiColor.h

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace kiwi {
1111
/**
1212
* @brief RGBA/YUV color
1313
*/
14-
class Color {
14+
class Color : public nw4r::ut::Color {
1515
public:
1616
/**
1717
* @brief Constructor
@@ -29,48 +29,51 @@ class Color {
2929
* @param b Blue component
3030
* @param a Alpha component
3131
*/
32-
Color(u8 r, u8 g, u8 b, u8 a) : r(r), g(g), b(b), a(a) {}
32+
Color(u8 _r, u8 _g, u8 _b, u8 _a) {
33+
r = _r;
34+
g = _g;
35+
b = _b;
36+
a = _a;
37+
}
3338

3439
/**
3540
* @brief Constructor
3641
*
3742
* @param color RGBA32 color
3843
*/
39-
Color(u32 color)
40-
: r(color >> 24 & 0xFF),
41-
g(color >> 16 & 0xFF),
42-
b(color >> 8 & 0xFF),
43-
a(color >> 0 & 0xFF) {}
44+
Color(u32 color) {
45+
r = color >> 24 & 0xFF;
46+
g = color >> 16 & 0xFF;
47+
b = color >> 8 & 0xFF;
48+
a = color >> 0 & 0xFF;
49+
}
4450

4551
/**
46-
* @brief Converts RGB color to YUV format
52+
* @brief Implicit conversion operator (RGBA order)
4753
*/
48-
Color Yuv() const;
54+
operator u32() const {
55+
return Rgba32();
56+
}
4957

5058
/**
51-
* @brief Converts color to u32 (RGBA order)
59+
* @brief Converts color to u32 representation (RGBA order)
5260
*/
5361
u32 Rgba32() const {
5462
return r << 24 | g << 16 | b << 8 | a;
5563
}
5664
/**
57-
* @brief Converts color to u32 (ARGB order)
65+
* @brief Converts color to u32 representation (ARGB order)
5866
*/
5967
u32 Argb32() const {
6068
return a << 24 | r << 16 | g << 8 | b;
6169
}
6270

63-
// clang-format off
64-
operator u32() const { return Rgba32(); } //!< Implicitly convert to u32 (RGBA order)
65-
operator nw4r::ut::Color() const { return nw4r::ut::Color(Rgba32()); } //!< Implicitly convert to NW4R color
66-
// clang-format on
71+
/**
72+
* @brief Converts RGB color to YUV format
73+
*/
74+
Color Yuv() const;
6775

6876
public:
69-
u8 r; //!< Red component
70-
u8 g; //!< Green component
71-
u8 b; //!< Blue component
72-
u8 a; //!< Alpha component
73-
7477
/**
7578
* @name Preset Colors
7679
*/

lib/libkiwi/core/kiwiConsoleOut.h

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,66 @@ namespace detail {
1212
//! @addtogroup libkiwi_core
1313
//! @{
1414

15+
struct Hex {};
16+
struct Dec {};
17+
1518
/**
1619
* @brief Console text output stream
1720
* @see kiwi::cout
1821
*/
1922
class ConsoleOut : private NonCopyable {
2023
public:
24+
/**
25+
* @brief Constructor
26+
*/
27+
ConsoleOut() : mHexFormat(false) {}
28+
2129
/**
2230
* @brief Logs output to the console
2331
*
2432
* @param rValue Value (converted to string)
33+
* @return Self for method chaining
2534
*/
2635
template <typename T> const ConsoleOut& operator<<(const T& rValue) const {
27-
K_LOG(ToString(rValue));
36+
K_LOG(mHexFormat ? ToHexString(rValue) : ToString(rValue));
37+
return *this;
38+
}
39+
40+
/**
41+
* @brief Applies decimal formatting to the stream (default)
42+
* @return Self for method chaining
43+
*/
44+
ConsoleOut& operator<<(Dec) {
45+
mHexFormat = false;
46+
return *this;
47+
}
48+
/**
49+
* @brief Applies hexadecimal formatting to the stream
50+
* @return Self for method chaining
51+
*/
52+
ConsoleOut& operator<<(Hex) {
53+
mHexFormat = true;
2854
return *this;
2955
}
56+
57+
private:
58+
bool mHexFormat; //!< Whether to display values as hex
3059
};
3160

3261
//! @}
3362
} // namespace detail
3463

3564
//! Global console handle
3665
extern const detail::ConsoleOut cout;
66+
3767
//! Newline character
3868
static const char endl = '\n';
3969

70+
//! Decimal display modifier (default)
71+
static const detail::Dec dec = detail::Dec();
72+
//! Hexadecimal display modifier
73+
static const detail::Hex hex = detail::Hex();
74+
4075
//! @}
4176
} // namespace kiwi
4277

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,45 @@
1-
#include <revolution/KPAD.h>
2-
31
#include <libkiwi.h>
42

3+
#include <revolution/KPAD.h>
4+
55
namespace kiwi {
66

7+
/******************************************************************************
8+
*
9+
* WiiCtrl
10+
*
11+
******************************************************************************/
12+
13+
/**
14+
* @brief Tests whether specific buttons were held down last frame
15+
*
16+
* @param buttons Button mask
17+
*/
18+
bool WiiCtrl::IsHold(u32 buttons) const {
19+
u32 mask = ConvertMask(buttons);
20+
return (GetStatus().hold & mask) == mask;
21+
}
22+
23+
/**
24+
* @brief Tests whether specific buttons were released last frame
25+
*
26+
* @param buttons Button mask
27+
*/
28+
bool WiiCtrl::IsRelease(u32 buttons) const {
29+
u32 mask = ConvertMask(buttons);
30+
return (GetStatus().release & mask) == mask;
31+
}
32+
33+
/**
34+
* @brief Tests whether specific buttons were triggered (pressed) last frame
35+
*
36+
* @param buttons Button mask
37+
*/
38+
bool WiiCtrl::IsTrig(u32 buttons) const {
39+
u32 mask = ConvertMask(buttons);
40+
return (GetStatus().trig & mask) == mask;
41+
}
42+
743
/**
844
* @brief Converts generic (EButton) mask to button mask for KPAD
945
*
@@ -29,7 +65,7 @@ u32 WiiCtrl::ConvertMask(u32 mask) {
2965

3066
u32 conv = 0;
3167

32-
for (int i = 0; i < LENGTHOF(table); i++) {
68+
for (int i = 0; i < K_LENGTHOF(table); i++) {
3369
if (mask & table[i][0]) {
3470
conv |= table[i][1];
3571
}
@@ -38,48 +74,24 @@ u32 WiiCtrl::ConvertMask(u32 mask) {
3874
return conv;
3975
}
4076

41-
/**
42-
* @brief Tests whether specific buttons were held down last frame
43-
*
44-
* @param buttons Button mask
45-
*/
46-
bool WiiCtrl::IsHold(u32 buttons) const {
47-
u32 mask = ConvertMask(buttons);
48-
return (GetStatus().hold & mask) == mask;
49-
}
50-
51-
/**
52-
* @brief Tests whether specific buttons were released last frame
77+
/******************************************************************************
5378
*
54-
* @param buttons Button mask
55-
*/
56-
bool WiiCtrl::IsRelease(u32 buttons) const {
57-
u32 mask = ConvertMask(buttons);
58-
return (GetStatus().release & mask) == mask;
59-
}
60-
61-
/**
62-
* @brief Tests whether specific buttons were triggered (pressed) last frame
79+
* CtrlMgr
6380
*
64-
* @param buttons Button mask
65-
*/
66-
bool WiiCtrl::IsTrig(u32 buttons) const {
67-
u32 mask = ConvertMask(buttons);
68-
return (GetStatus().trig & mask) == mask;
69-
}
81+
******************************************************************************/
7082

7183
/**
7284
* @brief Gets Wii Remote controller by player index
7385
*
7486
* @param i Player index
7587
*/
76-
const WiiCtrl& CtrlMgr::GetWiiCtrl(EPlayer i) {
88+
const WiiCtrl& CtrlMgr::GetWiiCtrl(int i) {
7789
K_ASSERT(i < EPlayer_Max);
7890

79-
EGG::CoreController* pBase = getNthController(i);
80-
K_ASSERT(pBase != nullptr);
91+
const EGG::CoreController* pBase = getNthController(i);
92+
K_ASSERT_PTR(pBase);
8193

82-
return *reinterpret_cast<WiiCtrl*>(pBase);
94+
return *reinterpret_cast<const WiiCtrl*>(pBase);
8395
}
8496

8597
} // namespace kiwi

lib/libkiwi/core/kiwiController.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#ifndef LIBKIWI_CORE_CONTROLLER_H
22
#define LIBKIWI_CORE_CONTROLLER_H
3-
#include <egg/core.h>
43
#include <libkiwi/k_types.h>
54
#include <libkiwi/util/kiwiExtension.h>
65

6+
#include <egg/core.h>
7+
78
namespace kiwi {
89
//! @addtogroup libkiwi_core
910
//! @{
@@ -82,7 +83,7 @@ class WiiCtrl : public Extension<EGG::CoreController> {
8283
* @brief Gets KPAD data (read-only)
8384
*/
8485
const KPADStatus& GetStatus() const {
85-
return *reinterpret_cast<KPADStatus*>(getCoreStatus(0));
86+
return *reinterpret_cast<KPADStatus*>(getCoreStatus());
8687
}
8788
};
8889

@@ -97,7 +98,7 @@ class CtrlMgr : public ExtSingletonPtr<EGG::CoreControllerMgr, CtrlMgr> {
9798
*
9899
* @param i Player index
99100
*/
100-
const WiiCtrl& GetWiiCtrl(EPlayer i);
101+
const WiiCtrl& GetWiiCtrl(int i);
101102
};
102103

103104
//! @}

0 commit comments

Comments
 (0)