Skip to content

Commit 1c9a040

Browse files
1 parent 7fd44ef commit 1c9a040

File tree

7 files changed

+178
-141
lines changed

7 files changed

+178
-141
lines changed

.clang-format

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,34 @@
66
# Generated from CLion C/C++ Code Style settings
77
BasedOnStyle: LLVM
88
AccessModifierOffset: -2
9-
AlignAfterOpenBracket: DontAlign
10-
AlignConsecutiveAssignments: false
9+
AlignAfterOpenBracket: BlockIndent
10+
AlignConsecutiveAssignments: None
11+
AlignEscapedNewlines: DontAlign
1112
AlignOperands: Align
1213
AllowAllArgumentsOnNextLine: false
1314
AllowAllConstructorInitializersOnNextLine: false
1415
AllowAllParametersOfDeclarationOnNextLine: false
15-
AllowShortBlocksOnASingleLine: Always
16+
AllowShortBlocksOnASingleLine: Empty
1617
AllowShortCaseLabelsOnASingleLine: false
17-
AllowShortFunctionsOnASingleLine: All
18-
AllowShortIfStatementsOnASingleLine: WithoutElse
19-
AllowShortLambdasOnASingleLine: All
18+
AllowShortEnumsOnASingleLine: false
19+
AllowShortFunctionsOnASingleLine: None
20+
AllowShortIfStatementsOnASingleLine: Never
21+
AllowShortLambdasOnASingleLine: None
2022
AllowShortLoopsOnASingleLine: true
2123
AlignTrailingComments: false
22-
AlwaysBreakAfterReturnType: All
24+
AlwaysBreakAfterDefinitionReturnType: None
25+
AlwaysBreakAfterReturnType: None
26+
AlwaysBreakBeforeMultilineStrings: true
2327
AlwaysBreakTemplateDeclarations: MultiLine
24-
BreakBeforeBraces: Custom
28+
BinPackArguments: false
29+
BinPackParameters: false
30+
BracedInitializerIndentWidth: 2
2531
BraceWrapping:
2632
AfterCaseLabel: false
2733
AfterClass: false
2834
AfterControlStatement: Never
2935
AfterEnum: false
36+
AfterExternBlock: true
3037
AfterFunction: false
3138
AfterNamespace: false
3239
AfterObjCDeclaration: false
@@ -36,39 +43,74 @@ BraceWrapping:
3643
IndentBraces: false
3744
SplitEmptyFunction: false
3845
SplitEmptyRecord: true
46+
BreakArrays: true
3947
BreakBeforeBinaryOperators: None
48+
BreakBeforeBraces: Attach
4049
BreakBeforeTernaryOperators: false
4150
BreakConstructorInitializers: AfterColon
4251
BreakInheritanceList: AfterColon
4352
ColumnLimit: 0
4453
CompactNamespaces: false
4554
ContinuationIndentWidth: 2
55+
Cpp11BracedListStyle: false
56+
EmptyLineAfterAccessModifier: Never
57+
EmptyLineBeforeAccessModifier: Always
58+
ExperimentalAutoDetectBinPacking: true
59+
FixNamespaceComments: true
60+
IncludeBlocks: Regroup
61+
IndentAccessModifiers: false
62+
IndentCaseBlocks: true
4663
IndentCaseLabels: true
64+
IndentExternBlock: Indent
65+
IndentGotoLabels: true
4766
IndentPPDirectives: BeforeHash
4867
IndentWidth: 2
68+
IndentWrappedFunctionNames: true
69+
InsertBraces: true
70+
InsertNewlineAtEOF: true
4971
KeepEmptyLinesAtTheStartOfBlocks: false
72+
LineEnding: LF
5073
MaxEmptyLinesToKeep: 1
5174
NamespaceIndentation: All
75+
ObjCBinPackProtocolList: Never
5276
ObjCSpaceAfterProperty: true
5377
ObjCSpaceBeforeProtocolList: true
78+
PackConstructorInitializers: Never
79+
PenaltyBreakBeforeFirstCallParameter: 1
80+
PenaltyBreakComment: 1
81+
PenaltyBreakString: 1
82+
PenaltyBreakFirstLessLess: 0
83+
PenaltyExcessCharacter: 1000000
5484
PointerAlignment: Right
85+
ReferenceAlignment: Pointer
5586
ReflowComments: true
87+
RemoveBracesLLVM: false
88+
RemoveSemicolon: false
89+
SeparateDefinitionBlocks: Always
90+
SortIncludes: CaseInsensitive
91+
SortUsingDeclarations: Lexicographic
5692
SpaceAfterCStyleCast: true
5793
SpaceAfterLogicalNot: false
58-
SpaceAfterTemplateKeyword: true
94+
SpaceAfterTemplateKeyword: false
5995
SpaceBeforeAssignmentOperators: true
96+
SpaceBeforeCaseColon: false
6097
SpaceBeforeCpp11BracedList: true
6198
SpaceBeforeCtorInitializerColon: false
6299
SpaceBeforeInheritanceColon: false
100+
SpaceBeforeJsonColon: false
63101
SpaceBeforeParens: ControlStatements
64102
SpaceBeforeRangeBasedForLoopColon: true
103+
SpaceBeforeSquareBrackets: false
104+
SpaceInEmptyBlock: false
65105
SpaceInEmptyParentheses: false
66106
SpacesBeforeTrailingComments: 2
67107
SpacesInAngles: Never
68108
SpacesInCStyleCastParentheses: false
69109
SpacesInContainerLiterals: false
110+
SpacesInLineCommentPrefix:
111+
Maximum: 3
112+
Minimum: 1
70113
SpacesInParentheses: false
71114
SpacesInSquareBrackets: false
72115
TabWidth: 2
73-
Cpp11BracedListStyle: false
74116
UseTab: Never

src/main.cpp

Lines changed: 113 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -10,161 +10,156 @@
1010

1111
// nxdk includes
1212
#include "src/nxdk/hal/debug.h"
13-
#include "src/nxdk/hal/xbox.h"
1413
#include "src/nxdk/hal/video.h"
14+
#include "src/nxdk/hal/xbox.h"
1515
#include "src/nxdk/windows.h"
1616

1717
// local includes
1818
#include "src/os.h"
1919

20-
static void printSDLErrorAndReboot()
21-
{
22-
debugPrint("SDL_Error: %s\n", SDL_GetError());
23-
debugPrint("Rebooting in 5 seconds.\n");
24-
Sleep(5000);
25-
XReboot();
20+
static void printSDLErrorAndReboot() {
21+
debugPrint("SDL_Error: %s\n", SDL_GetError());
22+
debugPrint("Rebooting in 5 seconds.\n");
23+
Sleep(5000);
24+
XReboot();
2625
}
2726

28-
static void printIMGErrorAndReboot()
29-
{
30-
debugPrint("SDL_Image Error: %s\n", IMG_GetError());
31-
debugPrint("Rebooting in 5 seconds.\n");
32-
Sleep(5000);
33-
XReboot();
27+
static void printIMGErrorAndReboot() {
28+
debugPrint("SDL_Image Error: %s\n", IMG_GetError());
29+
debugPrint("Rebooting in 5 seconds.\n");
30+
Sleep(5000);
31+
XReboot();
3432
}
3533

3634
// Screen dimension globals
3735
static int SCREEN_WIDTH;
3836
static int SCREEN_HEIGHT;
3937

40-
void splash_screen()
41-
{
42-
int done = 0;
43-
SDL_Window *window;
44-
SDL_Event event;
45-
SDL_Surface *screenSurface, *imageSurface;
46-
47-
// Enable standard application logging
48-
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
38+
void splash_screen() {
39+
int done = 0;
40+
SDL_Window *window;
41+
SDL_Event event;
42+
SDL_Surface *screenSurface, *imageSurface;
43+
44+
// Enable standard application logging
45+
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
46+
47+
if (SDL_VideoInit(NULL) < 0) {
48+
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video.\n");
49+
printSDLErrorAndReboot();
50+
}
51+
52+
window = SDL_CreateWindow("splash",
53+
SDL_WINDOWPOS_UNDEFINED,
54+
SDL_WINDOWPOS_UNDEFINED,
55+
SCREEN_WIDTH, SCREEN_HEIGHT,
56+
SDL_WINDOW_SHOWN);
57+
if(window == NULL) {
58+
debugPrint( "Window could not be created!\n");
59+
SDL_VideoQuit();
60+
printSDLErrorAndReboot();
61+
}
4962

50-
if (SDL_VideoInit(NULL) < 0) {
51-
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video.\n");
52-
printSDLErrorAndReboot();
53-
}
63+
if (!(IMG_Init(IMG_INIT_JPG) & IMG_INIT_JPG)) {
64+
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't intialize SDL_image.\n");
65+
SDL_VideoQuit();
66+
printIMGErrorAndReboot();
67+
}
5468

55-
window = SDL_CreateWindow("splash",
56-
SDL_WINDOWPOS_UNDEFINED,
57-
SDL_WINDOWPOS_UNDEFINED,
58-
SCREEN_WIDTH, SCREEN_HEIGHT,
59-
SDL_WINDOW_SHOWN);
60-
if(window == NULL)
61-
{
62-
debugPrint( "Window could not be created!\n");
63-
SDL_VideoQuit();
64-
printSDLErrorAndReboot();
65-
}
69+
screenSurface = SDL_GetWindowSurface(window);
70+
if (!screenSurface) {
71+
SDL_VideoQuit();
72+
printSDLErrorAndReboot();
73+
}
6674

67-
if (!(IMG_Init(IMG_INIT_JPG) & IMG_INIT_JPG)) {
68-
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't intialize SDL_image.\n");
69-
SDL_VideoQuit();
70-
printIMGErrorAndReboot();
71-
}
75+
// set string variable for splash screen path
76+
std::string _splashScreenPath = std::string(DATA_PATH) + "assets" + PATH_SEP + "moonlight-splash-" +
77+
std::to_string(SCREEN_WIDTH) + "x" + std::to_string(SCREEN_HEIGHT) + ".jpg";
78+
const char *splashScreenPath = _splashScreenPath.c_str();
7279

73-
screenSurface = SDL_GetWindowSurface(window);
74-
if (!screenSurface) {
75-
SDL_VideoQuit();
76-
printSDLErrorAndReboot();
80+
imageSurface = IMG_Load(splashScreenPath);
81+
if (!imageSurface) {
82+
SDL_VideoQuit();
83+
printIMGErrorAndReboot();
84+
}
85+
86+
while (!done) {
87+
// Check for events
88+
while (SDL_PollEvent(&event)) {
89+
switch (event.type) {
90+
case SDL_QUIT:
91+
done = 1;
92+
break;
93+
default:
94+
break;
95+
}
7796
}
7897

79-
// set string variable for splash screen path
80-
std::string _splashScreenPath = std::string(DATA_PATH) + "assets" + PATH_SEP + "moonlight-splash-" +
81-
std::to_string(SCREEN_WIDTH) + "x" + std::to_string(SCREEN_HEIGHT) + ".jpg";
82-
const char *splashScreenPath = _splashScreenPath.c_str();
98+
SDL_BlitSurface(imageSurface, NULL, screenSurface, NULL);
99+
SDL_UpdateWindowSurface(window);
83100

84-
imageSurface = IMG_Load(splashScreenPath);
85-
if (!imageSurface) {
86-
SDL_VideoQuit();
87-
printIMGErrorAndReboot();
88-
}
89-
90-
while (!done) {
91-
// Check for events
92-
while (SDL_PollEvent(&event)) {
93-
switch (event.type) {
94-
case SDL_QUIT:
95-
done = 1;
96-
break;
97-
default:
98-
break;
99-
}
100-
}
101-
102-
SDL_BlitSurface(imageSurface, NULL, screenSurface, NULL);
103-
SDL_UpdateWindowSurface(window);
104-
105-
Sleep(1000);
106-
}
101+
Sleep(1000);
102+
}
107103

108-
SDL_VideoQuit();
104+
SDL_VideoQuit();
109105
}
110106

111-
int main()
112-
{
113-
// create an empty list for the available video modes
114-
std::vector<VIDEO_MODE> availableVideoModes;
115-
116-
// save the best video mode here
117-
VIDEO_MODE bestVideoMode = {0, 0, 0, 0};
107+
int main() {
108+
// create an empty list for the available video modes
109+
std::vector<VIDEO_MODE> availableVideoModes;
118110

119-
VIDEO_MODE vm;
120-
int bpp = 32; // Bits per pixel
121-
void *p = NULL; // Initialize to NULL for the first call
111+
// save the best video mode here
112+
VIDEO_MODE bestVideoMode = {0, 0, 0, 0};
122113

123-
// get the available video modes
124-
while (XVideoListModes(&vm, bpp, REFRESH_DEFAULT, &p)) {
125-
availableVideoModes.push_back(vm);
114+
VIDEO_MODE vm;
115+
int bpp = 32; // Bits per pixel
116+
void *p = NULL; // Initialize to NULL for the first call
126117

127-
// ensure height is equal to or better than the current best video mode
128-
if (vm.height < bestVideoMode.height) {
129-
continue;
130-
}
118+
// get the available video modes
119+
while (XVideoListModes(&vm, bpp, REFRESH_DEFAULT, &p)) {
120+
availableVideoModes.push_back(vm);
131121

132-
// ensure width is equal to or better than the current best video mode
133-
if (vm.width < bestVideoMode.width) {
134-
continue;
135-
}
122+
// ensure height is equal to or better than the current best video mode
123+
if (vm.height < bestVideoMode.height) {
124+
continue;
125+
}
136126

137-
// ensure bpp is equal to or better than the current best video mode
138-
if (vm.bpp < bestVideoMode.bpp) {
139-
continue;
140-
}
127+
// ensure width is equal to or better than the current best video mode
128+
if (vm.width < bestVideoMode.width) {
129+
continue;
130+
}
141131

142-
// ensure refresh is equal to or better than the current best video mode
143-
if (vm.refresh < bestVideoMode.refresh) {
144-
continue;
145-
}
132+
// ensure bpp is equal to or better than the current best video mode
133+
if (vm.bpp < bestVideoMode.bpp) {
134+
continue;
135+
}
146136

147-
// save the best video mode
148-
bestVideoMode = vm;
137+
// ensure refresh is equal to or better than the current best video mode
138+
if (vm.refresh < bestVideoMode.refresh) {
139+
continue;
149140
}
150141

151-
SCREEN_WIDTH = bestVideoMode.width;
152-
SCREEN_HEIGHT = bestVideoMode.height;
142+
// save the best video mode
143+
bestVideoMode = vm;
144+
}
153145

154-
XVideoSetMode(640, 480, 32, REFRESH_DEFAULT);
146+
SCREEN_WIDTH = bestVideoMode.width;
147+
SCREEN_HEIGHT = bestVideoMode.height;
155148

156-
debugPrint("Available video modes:\n");
157-
for (VIDEO_MODE vm : availableVideoModes) {
158-
debugPrint("Width: %d, Height: %d, BPP: %d, Refresh: %d\n", vm.width, vm.height, vm.bpp, vm.refresh);
159-
}
149+
XVideoSetMode(640, 480, 32, REFRESH_DEFAULT);
150+
151+
debugPrint("Available video modes:\n");
152+
for (VIDEO_MODE vm : availableVideoModes) {
153+
debugPrint("Width: %d, Height: %d, BPP: %d, Refresh: %d\n", vm.width, vm.height, vm.bpp, vm.refresh);
154+
}
160155

161-
debugPrint("Best video mode:\n");
162-
debugPrint("Width: %d, Height: %d, BPP: %d, Refresh: %d\n", bestVideoMode.width, bestVideoMode.height, bestVideoMode.bpp, bestVideoMode.refresh);
156+
debugPrint("Best video mode:\n");
157+
debugPrint("Width: %d, Height: %d, BPP: %d, Refresh: %d\n", bestVideoMode.width, bestVideoMode.height, bestVideoMode.bpp, bestVideoMode.refresh);
163158

164-
Sleep(2000);
159+
Sleep(2000);
165160

166-
XVideoSetMode(SCREEN_WIDTH, SCREEN_HEIGHT, bestVideoMode.bpp, bestVideoMode.refresh);
161+
XVideoSetMode(SCREEN_WIDTH, SCREEN_HEIGHT, bestVideoMode.bpp, bestVideoMode.refresh);
167162

168-
splash_screen();
169-
return 0;
163+
splash_screen();
164+
return 0;
170165
}

0 commit comments

Comments
 (0)