Skip to content

Commit

Permalink
Adapt clang-format file and apply to codebase
Browse files Browse the repository at this point in the history
It isn't fully applied to all the codebase. It is first applied and then
checked manually to decide whether to apply the changes or not.
  • Loading branch information
AntonioND committed Dec 8, 2019
1 parent d1debb1 commit 096bd2d
Show file tree
Hide file tree
Showing 91 changed files with 2,676 additions and 2,526 deletions.
46 changes: 22 additions & 24 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This file isn't meant to be applied to all the codebase, it's meant to be
# applied to patches and checked manually.
---
Language: Cpp
# BasedOnStyle: LLVM
Expand All @@ -11,7 +13,7 @@ AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
Expand All @@ -20,10 +22,10 @@ AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterEnum: true
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
Expand All @@ -36,61 +38,57 @@ BraceWrapping:
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
IncludeCategories:
- Regex: '<*'
Priority: 3
- Regex: '.*'
- Regex: '"*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakComment: 500
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyExcessCharacter: 300
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
Expand All @@ -112,10 +110,10 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
TabWidth: 4
UseTab: Never
...

7 changes: 4 additions & 3 deletions source/build_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define MAX_PATHLEN (2048)
#endif

#define ARRAY_NUM_ELEMENTS(a) (sizeof(a)/sizeof(a[0]))
#define ARRAY_NUM_ELEMENTS(a) (sizeof(a) / sizeof(a[0]))

//---------------------------------------------------------------
//----------------------- GENERAL DEFINES -----------------------
Expand All @@ -22,8 +22,9 @@
#define GIIBIIADVANCE_VERSION_MAJOR (0)
#define GIIBIIADVANCE_VERSION_MINOR (2)
#define GIIBIIADVANCE_VERSION_PATCH (0)
#define GIIBIIADVANCE_VERSION ((GIIBIIADVANCE_VERSION_MAJOR<<16) | (GIIBIIADVANCE_VERSION_MINOR<<8) | \
(GIIBIIADVANCE_VERSION_PATCH))
#define GIIBIIADVANCE_VERSION \
((GIIBIIADVANCE_VERSION_MAJOR << 16) | (GIIBIIADVANCE_VERSION_MINOR << 8) \
| (GIIBIIADVANCE_VERSION_PATCH))

#define GIIBIIADVANCE_VERSION_STRING "0.2.X"

Expand Down
81 changes: 40 additions & 41 deletions source/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@
//
// GiiBiiAdvance - GBA/GB emulator

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "build_options.h"
#include "file_utils.h"
#include "config.h"
#include "file_utils.h"
#include "input_utils.h"

#include "gb_core/gameboy.h"
#include "gb_core/sound.h"
#include "gb_core/gb_main.h"
#include "gb_core/sound.h"
#include "gb_core/video.h"

#include "gba_core/sound.h"

// Default values...
t_config EmulatorConfig = {
0, // debug_msg_enable
2, // screen_size
0, // load_from_boot_rom
0, // frameskip
0, // oglfilter
0, // auto_close_debugger
0, // webcam_select
0, // debug_msg_enable
2, // screen_size
0, // load_from_boot_rom
0, // frameskip
0, // oglfilter
0, // auto_close_debugger
0, // webcam_select
//---------
64, // volume
0x3F, // chn_flags
0, // snd_mute
64, // volume
0x3F, // chn_flags
0, // snd_mute
//---------
-1, // hardware_type
-1, // hardware_type
SERIAL_GBPRINTER, // serial_device
0, // enableblur
0, // realcolors
0x0200, // gbcam_exposure_reference
0, // enableblur
0, // realcolors
0x0200, // gbcam_exposure_reference

// The GB palette is not stored here, it is stored in gb_main.c
// The input config not here, either... it's in input_utils.c
Expand Down Expand Up @@ -124,7 +124,7 @@ void Config_Save(void)
fprintf(ini_file, CFG_SCREEN_SIZE "=%d\n", EmulatorConfig.screen_size);
fprintf(ini_file, CFG_LOAD_BOOT_ROM "=%s\n",
EmulatorConfig.load_from_boot_rom ? "true" : "false");
fprintf(ini_file, CFG_FRAMESKIP "=%d\n",EmulatorConfig.frameskip);
fprintf(ini_file, CFG_FRAMESKIP "=%d\n", EmulatorConfig.frameskip);
fprintf(ini_file, CFG_OPENGL_FILTER "=%s\n",
oglfiltertype[EmulatorConfig.oglfilter]);
fprintf(ini_file, CFG_AUTO_CLOSE_DEBUGGER "=%s\n",
Expand Down Expand Up @@ -165,7 +165,7 @@ void Config_Save(void)
// Check if the player is enabled (P1 is always enabled)
if (!(Input_PlayerGetEnabled(player) || (player == 0)))
{
fprintf(ini_file,"P%d_Enabled=false\n",player+1);
fprintf(ini_file, "P%d_Enabled=false\n", player + 1);
continue;
}

Expand All @@ -175,8 +175,8 @@ void Config_Save(void)

if (controller != -1) // If this is a joystick
{
char *controllername = Input_GetJoystickName(
Input_PlayerGetController(player));
char *controllername =
Input_GetJoystickName(Input_PlayerGetController(player));
if (strlen(controllername) > 0)
{
fprintf(ini_file, "P%d_Enabled=true\n", player + 1);
Expand Down Expand Up @@ -241,7 +241,7 @@ void Config_Load(void)

char *ini;
unsigned int size;
FileLoad_NoError(path, (void*)&ini, &size);
FileLoad_NoError(path, (void *)&ini, &size);
if (ini == NULL)
return;

Expand All @@ -262,7 +262,7 @@ void Config_Load(void)
if (tmp)
{
tmp += strlen(CFG_DB_MSG_ENABLE) + 1;
if(strncmp(tmp, "true", strlen("true")) == 0)
if (strncmp(tmp, "true", strlen("true")) == 0)
EmulatorConfig.debug_msg_enable = 1;
else
EmulatorConfig.debug_msg_enable = 0;
Expand All @@ -275,11 +275,11 @@ void Config_Load(void)
EmulatorConfig.screen_size = atoi(tmp);
if (EmulatorConfig.screen_size > 4)
EmulatorConfig.screen_size = 4;
else if(EmulatorConfig.screen_size < 2)
else if (EmulatorConfig.screen_size < 2)
EmulatorConfig.screen_size = 2;
}

tmp = strstr(ini,CFG_LOAD_BOOT_ROM);
tmp = strstr(ini, CFG_LOAD_BOOT_ROM);
if (tmp)
{
tmp += strlen(CFG_LOAD_BOOT_ROM) + 1;
Expand All @@ -295,7 +295,7 @@ void Config_Load(void)
{
tmp += strlen(CFG_FRAMESKIP) + 1;
if (*tmp == '-') //&& (*(tmp+1) == 1)
EmulatorConfig.frameskip = -1;
EmulatorConfig.frameskip = -1;
else
EmulatorConfig.frameskip = *tmp - '0';

Expand All @@ -310,7 +310,7 @@ void Config_Load(void)

int result = 0;
for (int i = 0; i < ARRAY_NUM_ELEMENTS(oglfiltertype); i++)
if(strncmp(tmp, oglfiltertype[i], strlen(oglfiltertype[i])) == 0)
if (strncmp(tmp, oglfiltertype[i], strlen(oglfiltertype[i])) == 0)
result = i;

EmulatorConfig.oglfilter = result;
Expand All @@ -320,7 +320,7 @@ void Config_Load(void)
if (tmp)
{
tmp += strlen(CFG_AUTO_CLOSE_DEBUGGER) + 1;
if(strncmp(tmp, "true", strlen("true")) == 0)
if (strncmp(tmp, "true", strlen("true")) == 0)
EmulatorConfig.auto_close_debugger = 1;
else
EmulatorConfig.auto_close_debugger = 0;
Expand All @@ -343,7 +343,7 @@ void Config_Load(void)
tmp += strlen(CFG_SND_CHN_ENABLE) + 1;
if (*tmp == '#')
{
tmp ++;
tmp++;
char aux[3];
aux[0] = *tmp++;
aux[1] = *tmp;
Expand Down Expand Up @@ -374,7 +374,7 @@ void Config_Load(void)
if (tmp)
{
tmp += strlen(CFG_SND_MUTE) + 1;
if(strncmp(tmp, "true", strlen("true")) == 0)
if (strncmp(tmp, "true", strlen("true")) == 0)
EmulatorConfig.snd_mute = 1;
else
EmulatorConfig.snd_mute = 0;
Expand All @@ -388,7 +388,7 @@ void Config_Load(void)

int result = -1;
for (int i = 0; i < ARRAY_NUM_ELEMENTS(hwtype); i++)
if(strncmp(tmp, hwtype[i], strlen(hwtype[i])) == 0)
if (strncmp(tmp, hwtype[i], strlen(hwtype[i])) == 0)
result = i;

EmulatorConfig.hardware_type = result - 1;
Expand All @@ -401,7 +401,7 @@ void Config_Load(void)

int result = 0;
for (int i = 0; i < ARRAY_NUM_ELEMENTS(serialdevice); i++)
if(strncmp(tmp, serialdevice[i], strlen(serialdevice[i])) == 0)
if (strncmp(tmp, serialdevice[i], strlen(serialdevice[i])) == 0)
result = i;

EmulatorConfig.serial_device = result;
Expand All @@ -411,7 +411,7 @@ void Config_Load(void)
if (tmp)
{
tmp += strlen(CFG_ENABLE_BLUR) + 1;
if(strncmp(tmp, "true", strlen("true")) == 0)
if (strncmp(tmp, "true", strlen("true")) == 0)
EmulatorConfig.enableblur = 1;
else
EmulatorConfig.enableblur = 0;
Expand All @@ -423,7 +423,7 @@ void Config_Load(void)
if (tmp)
{
tmp += strlen(CFG_REAL_GB_COLORS) + 1;
if(strncmp(tmp, "true", strlen("true")) == 0)
if (strncmp(tmp, "true", strlen("true")) == 0)
EmulatorConfig.realcolors = 1;
else
EmulatorConfig.realcolors = 0;
Expand All @@ -437,7 +437,7 @@ void Config_Load(void)
tmp += strlen(CFG_GBCAM_EXPOSURE_REFERENCE) + 1;
if (*tmp == '#')
{
tmp ++;
tmp++;
char aux[5];
aux[0] = *tmp++;
aux[1] = *tmp++;
Expand All @@ -447,7 +447,7 @@ void Config_Load(void)

unsigned int value = asciihex_to_int(aux);

if(value <= 0xFFFF)
if (value <= 0xFFFF)
EmulatorConfig.gbcam_exposure_reference = value;
}
}
Expand Down Expand Up @@ -516,10 +516,10 @@ void Config_Load(void)

for (int i = 0; i < sizeof(temp_str); i++)
{
if(temp_str[i] == ']')
if (temp_str[i] == ']')
temp_str[i] = '\0';
}
//temp_str now has the name of the controller
// temp_str now has the name of the controller

int index = Input_GetJoystickFromName(temp_str);
if (index == -2)
Expand All @@ -537,8 +537,8 @@ void Config_Load(void)
// Now, read keys
for (int key = 0; key < P_NUM_KEYS; key++)
{
snprintf(temp_str, sizeof(temp_str), "P%d_%s=",
player + 1, GBKeyNames[key]);
snprintf(temp_str, sizeof(temp_str),
"P%d_%s=", player + 1, GBKeyNames[key]);
tmp = strstr(ini, temp_str);
if (tmp)
{
Expand All @@ -552,7 +552,6 @@ void Config_Load(void)
}
}
}

}
else
{
Expand Down
Loading

0 comments on commit 096bd2d

Please sign in to comment.