From 4a0e27624bb79b7a55cbefad2a7ecea559eff4b6 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 5 Feb 2022 14:28:08 +0100 Subject: [PATCH] Format the code via clang-format --- .clang-format | 67 ++++ .github/workflows/pr.yml | 25 ++ .github/workflows/push_image.yml | 8 + Dockerfile.buildlocal | 3 + README.md | 28 +- include/gui/FreeTypeGX.h | 31 +- include/gui/Gui.h | 2 +- include/gui/GuiButton.h | 25 +- include/gui/GuiCheckBox.h | 6 +- include/gui/GuiController.h | 5 +- include/gui/GuiDragListener.h | 7 +- include/gui/GuiElement.h | 130 +++--- include/gui/GuiFrame.h | 9 +- include/gui/GuiImage.h | 10 +- include/gui/GuiImageAsync.h | 4 +- include/gui/GuiImageData.h | 14 +- include/gui/GuiScrollbar.h | 8 +- include/gui/GuiSelectBox.h | 7 +- include/gui/GuiSwitch.h | 9 +- include/gui/GuiText.h | 11 +- include/gui/GuiToggle.h | 2 - include/gui/GuiTrigger.h | 78 ++-- include/gui/VPadController.h | 10 +- include/gui/WPadController.h | 2 +- include/gui/gx2_ext.h | 154 ++++--- include/gui/memory.h | 1 + include/gui/sigslot.h | 379 +++++++++--------- include/gui/sounds/BufferCircle.hpp | 31 +- include/gui/sounds/SoundDecoder.hpp | 15 +- include/gui/sounds/SoundHandler.hpp | 5 +- include/gui/sounds/Voice.h | 27 +- include/gui/system/CThread.h | 19 +- include/gui/video/CVideo.h | 30 +- include/gui/video/CursorDrawer.h | 2 +- include/gui/video/shaders/ColorShader.h | 7 +- include/gui/video/shaders/FXAAShader.h | 8 +- include/gui/video/shaders/FetchShader.h | 2 +- include/gui/video/shaders/PixelShader.h | 4 +- include/gui/video/shaders/Shader.h | 12 +- include/gui/video/shaders/Shader3D.h | 9 +- .../gui/video/shaders/ShaderFractalColor.h | 11 +- include/gui/video/shaders/Texture2DShader.h | 9 +- include/gui/video/shaders/VertexShader.h | 8 +- source/fs/CFile.cpp | 24 +- source/fs/CFile.hpp | 6 +- source/gui/FreeTypeGX.cpp | 44 +- source/gui/GameBgImage.cpp | 12 +- source/gui/GridBackground.cpp | 24 +- source/gui/GuiButton.cpp | 48 ++- source/gui/GuiCheckBox.cpp | 3 +- source/gui/GuiDragListener.cpp | 4 +- source/gui/GuiElement.cpp | 95 +++-- source/gui/GuiFrame.cpp | 8 +- source/gui/GuiImage.cpp | 135 ++++--- source/gui/GuiImageAsync.cpp | 34 +- source/gui/GuiImageData.cpp | 20 +- source/gui/GuiParticleImage.cpp | 34 +- source/gui/GuiScrollbar.cpp | 15 +- source/gui/GuiSelectBox.cpp | 40 +- source/gui/GuiSound.cpp | 8 +- source/gui/GuiSwitch.cpp | 5 +- source/gui/GuiText.cpp | 244 ++++++----- source/gui/GuiToggle.cpp | 3 +- source/gui/GuiTrigger.cpp | 7 +- source/sounds/BufferCircle.cpp | 14 +- source/sounds/Mp3Decoder.cpp | 30 +- source/sounds/OggDecoder.cpp | 25 +- source/sounds/SoundDecoder.cpp | 56 ++- source/sounds/SoundHandler.cpp | 50 +-- source/sounds/WavDecoder.cpp | 20 +- source/system/memory.c | 32 +- source/utils/utils.h | 29 +- source/video/CVideo.cpp | 43 +- source/video/CursorDrawer.cpp | 5 +- source/video/shaders/ColorShader.cpp | 54 +-- source/video/shaders/FXAAShader.cpp | 42 +- source/video/shaders/Shader3D.cpp | 75 ++-- source/video/shaders/ShaderFractalColor.cpp | 84 ++-- source/video/shaders/Texture2DShader.cpp | 68 ++-- 79 files changed, 1372 insertions(+), 1302 deletions(-) create mode 100644 .clang-format create mode 100644 .github/workflows/pr.yml create mode 100644 Dockerfile.buildlocal diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..56cc685 --- /dev/null +++ b/.clang-format @@ -0,0 +1,67 @@ +# Generated from CLion C/C++ Code Style settings +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: Consecutive +AlignConsecutiveMacros: AcrossEmptyLinesAndComments +AlignOperands: Align +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Always +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: true +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +ColumnLimit: 0 +CompactNamespaces: false +ContinuationIndentWidth: 8 +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: All +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PointerAlignment: Right +ReflowComments: false +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Never diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..242c31d --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,25 @@ +name: CI-PR + +on: [pull_request] + +jobs: + clang-format: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: clang-format + run: | + docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include + build-binary: + runs-on: ubuntu-18.04 + needs: clang-format + steps: + - uses: actions/checkout@v2 + - name: build binary + run: | + docker build . -f Dockerfile.buildlocal -t builder + docker run --rm -v ${PWD}:/project builder make + - uses: actions/upload-artifact@master + with: + name: binary + path: "lib/*.a" \ No newline at end of file diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 9cd7bbd..df6eb37 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -4,8 +4,16 @@ on: branches: - master jobs: + clang-format: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: clang-format + run: | + docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include build: runs-on: ubuntu-latest + needs: clang-format steps: - uses: actions/checkout@master - name: Get release version diff --git a/Dockerfile.buildlocal b/Dockerfile.buildlocal new file mode 100644 index 0000000..080eec7 --- /dev/null +++ b/Dockerfile.buildlocal @@ -0,0 +1,3 @@ +FROM wiiuenv/devkitppc:20211229 + +WORKDIR project \ No newline at end of file diff --git a/README.md b/README.md index f6c67b3..62e279d 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,16 @@ +[![Publish Docker Image](https://github.com/wiiu-env/libgui/actions/workflows/push_image.yml/badge.svg)](https://github.com/wiiu-env/libgui/actions/workflows/push_image.yml) + # libgui [![Build Status](https://travis-ci.org/Maschell/libgui.svg?branch=wut)](https://travis-ci.org/Maschell/libgui/tree/wut) -# build - -``` -pacman -Syu ppc-portlibs -pacman -Syu ppc-glm ppc-libmad - -``` - ## Usage Following steps are required for initialization: ```C -memoryInitialize(); // Initialize memory management +libgui_memoryInitialize(); // Initialize memory management //DO GUI STUFF HERE! -memoryRelease(); +libgui_memoryRelease(); ``` Link the application with: @@ -39,6 +33,20 @@ To be able to use libgui, you need to install the following dependencies: - [wut](https://github.com/devkitPro/wut/) - Install the required portlibs via `(dkp-)pacman -Syu ppc-zlib ppc-libmad ppc-libogg ppc-libgd ppc-freetype ppc-libjpeg-turbo ppc-libpng ppc-libvorbisidec ppc-glm ppc-bzip2` +## Use this lib in Dockerfiles. +A prebuilt version of this lib can found on dockerhub. To use it for your projects, add this to your Dockerfile. +``` +[...] +COPY --from=wiiuenv/libgui:[tag] /artifacts $DEVKITPRO +[...] +``` +Replace [tag] with a tag you want to use, a list of tags can be found [here](https://hub.docker.com/r/wiiuenv/libgui/tags). +It's highly recommended to pin the version to the **latest date** instead of using `latest`. + +## Format the code via docker + +`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include -i` + # Credits - Orignally based on https://github.com/dborth/libwiigui - Wii U port / modification / new functions / sound / much more by dimok. diff --git a/include/gui/FreeTypeGX.h b/include/gui/FreeTypeGX.h index 7ad1954..b91ee13 100644 --- a/include/gui/FreeTypeGX.h +++ b/include/gui/FreeTypeGX.h @@ -22,16 +22,16 @@ #pragma once -#include #include +#include #include FT_FREETYPE_H #include FT_BITMAP_H #include -#include -#include #include #include +#include +#include #include @@ -47,12 +47,12 @@ * Font face character glyph relevant data structure. */ typedef struct ftgxCharData_ { - int16_t renderOffsetX; /**< Texture X axis bearing offset. */ + int16_t renderOffsetX; /**< Texture X axis bearing offset. */ uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */ uint16_t glyphAdvanceY; /**< Character glyph Y coordinate advance in pixels. */ - uint32_t glyphIndex; /**< Charachter glyph index in the font face. */ + uint32_t glyphIndex; /**< Charachter glyph index in the font face. */ - int16_t renderOffsetY; /**< Texture Y axis bearing offset. */ + int16_t renderOffsetY; /**< Texture Y axis bearing offset. */ int16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */ int16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */ @@ -64,15 +64,15 @@ typedef struct ftgxCharData_ { * Offset structure which hold both a maximum and minimum value. */ typedef struct ftgxDataOffset_ { - int16_t ascender; /**< Maximum data offset. */ + int16_t ascender; /**< Maximum data offset. */ int16_t descender; /**< Minimum data offset. */ - int16_t max; /**< Maximum data offset. */ - int16_t min; /**< Minimum data offset. */ + int16_t max; /**< Maximum data offset. */ + int16_t min; /**< Minimum data offset. */ } ftgxDataOffset; typedef struct ftgxCharData_ ftgxCharData; typedef struct ftgxDataOffset_ ftgxDataOffset; -#define _TEXT(t) L ## t /**< Unicode helper macro. */ +#define _TEXT(t) L##t /**< Unicode helper macro. */ #define FTGX_NULL 0x0000 #define FTGX_JUSTIFY_LEFT 0x0001 @@ -94,9 +94,8 @@ typedef struct ftgxDataOffset_ ftgxDataOffset; #define FTGX_STYLE_MASK 0xf000 /**< Constant color value used only to sanitize Doxygen documentation. */ -static const GX2ColorF32 ftgxWhite = (GX2ColorF32) { - 1.0f, 1.0f, 1.0f, 1.0f -}; +static const GX2ColorF32 ftgxWhite = (GX2ColorF32){ + 1.0f, 1.0f, 1.0f, 1.0f}; //! forward declaration @@ -113,10 +112,10 @@ class CVideo; */ class FreeTypeGX { private: - FT_Library ftLibrary; /**< FreeType FT_Library instance. */ - FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */ + FT_Library ftLibrary; /**< FreeType FT_Library instance. */ + FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */ bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */ - uint8_t vertexIndex; /**< Vertex format descriptor index. */ + uint8_t vertexIndex; /**< Vertex format descriptor index. */ GX2Sampler ftSampler; std::recursive_mutex faceMutex; std::recursive_mutex fontDataMutex; diff --git a/include/gui/Gui.h b/include/gui/Gui.h index 07d8615..345a980 100644 --- a/include/gui/Gui.h +++ b/include/gui/Gui.h @@ -30,13 +30,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include diff --git a/include/gui/GuiButton.h b/include/gui/GuiButton.h index 82211e0..1ef5b86 100644 --- a/include/gui/GuiButton.h +++ b/include/gui/GuiButton.h @@ -17,11 +17,11 @@ #ifndef GUI_BUTTON_H_ #define GUI_BUTTON_H_ -#include -#include #include +#include #include #include +#include #include #include @@ -110,22 +110,23 @@ public: sigslot::signal3 clicked; sigslot::signal3 held; sigslot::signal3 released; + protected: static const int32_t iMaxGuiTriggers = 10; - GuiImage *image; //!< Button image (default) - GuiImage *imageOver; //!< Button image for STATE_SELECTED - GuiImage *imageHold; //!< Button image for STATE_HELD + GuiImage *image; //!< Button image (default) + GuiImage *imageOver; //!< Button image for STATE_SELECTED + GuiImage *imageHold; //!< Button image for STATE_HELD GuiImage *imageClick; //!< Button image for STATE_CLICKED GuiImage *icon; GuiImage *iconOver; - GuiText *label[4]; //!< Label(s) to display (default) - GuiText *labelOver[4]; //!< Label(s) to display for STATE_SELECTED - GuiText *labelHold[4]; //!< Label(s) to display for STATE_HELD - GuiText *labelClick[4]; //!< Label(s) to display for STATE_CLICKED - GuiSound *soundOver; //!< Sound to play for STATE_SELECTED - GuiSound *soundHold; //!< Sound to play for STATE_HELD - GuiSound *soundClick; //!< Sound to play for STATE_CLICKED + GuiText *label[4]; //!< Label(s) to display (default) + GuiText *labelOver[4]; //!< Label(s) to display for STATE_SELECTED + GuiText *labelHold[4]; //!< Label(s) to display for STATE_HELD + GuiText *labelClick[4]; //!< Label(s) to display for STATE_CLICKED + GuiSound *soundOver; //!< Sound to play for STATE_SELECTED + GuiSound *soundHold; //!< Sound to play for STATE_HELD + GuiSound *soundClick; //!< Sound to play for STATE_CLICKED GuiTrigger *trigger[iMaxGuiTriggers]; //!< GuiTriggers (input actions) that this element responds to GuiTrigger *clickedTrigger; GuiTrigger *heldTrigger; diff --git a/include/gui/GuiCheckBox.h b/include/gui/GuiCheckBox.h index 4a37c66..52fab4c 100644 --- a/include/gui/GuiCheckBox.h +++ b/include/gui/GuiCheckBox.h @@ -17,9 +17,9 @@ #ifndef GUI_CHECKBOX_H_ #define GUI_CHECKBOX_H_ -#include #include #include +#include //!A simple CheckBox class GuiCheckBox : public GuiToggle { @@ -38,8 +38,8 @@ public: void setImageHighlighted(GuiImage *img); protected: - GuiImage *backgroundImg = NULL; - GuiImage *selectedImg = NULL; + GuiImage *backgroundImg = NULL; + GuiImage *selectedImg = NULL; GuiImage *highlightedImg = NULL; void update(GuiController *c); diff --git a/include/gui/GuiController.h b/include/gui/GuiController.h index c81cc19..868f504 100644 --- a/include/gui/GuiController.h +++ b/include/gui/GuiController.h @@ -17,14 +17,14 @@ #ifndef GUI_CONTROLLER_H_ #define GUI_CONTROLLER_H_ -#include #include +#include class GuiController { public: //!Constructor GuiController(int32_t channel) - : chan(channel) { + : chan(channel) { memset(&lastData, 0, sizeof(lastData)); memset(&data, 0, sizeof(data)); @@ -68,7 +68,6 @@ public: int32_t chanIdx; PadData data; PadData lastData; - }; #endif diff --git a/include/gui/GuiDragListener.h b/include/gui/GuiDragListener.h index 8075c32..40c4a55 100644 --- a/include/gui/GuiDragListener.h +++ b/include/gui/GuiDragListener.h @@ -17,10 +17,10 @@ #ifndef GUI_DRAG_LISTENER_H_ #define GUI_DRAG_LISTENER_H_ -#include -#include -#include #include +#include +#include +#include class GuiDragListener : public GuiElement { public: @@ -44,6 +44,7 @@ public: void update(GuiController *c); sigslot::signal5 dragged; + protected: static const int32_t iMaxGuiTriggers = 10; diff --git a/include/gui/GuiElement.h b/include/gui/GuiElement.h index 762ce40..0023b1e 100644 --- a/include/gui/GuiElement.h +++ b/include/gui/GuiElement.h @@ -21,45 +21,45 @@ #include #include +#include #include #include #include #include #include -#include #include -#include #include #include +#include enum { - EFFECT_NONE = 0x00, - EFFECT_SLIDE_TOP = 0x01, - EFFECT_SLIDE_BOTTOM = 0x02, - EFFECT_SLIDE_RIGHT = 0x04, - EFFECT_SLIDE_LEFT = 0x08, - EFFECT_SLIDE_IN = 0x10, - EFFECT_SLIDE_OUT = 0x20, - EFFECT_SLIDE_FROM = 0x40, - EFFECT_FADE = 0x80, - EFFECT_SCALE = 0x100, - EFFECT_COLOR_TRANSITION = 0x200 + EFFECT_NONE = 0x00, + EFFECT_SLIDE_TOP = 0x01, + EFFECT_SLIDE_BOTTOM = 0x02, + EFFECT_SLIDE_RIGHT = 0x04, + EFFECT_SLIDE_LEFT = 0x08, + EFFECT_SLIDE_IN = 0x10, + EFFECT_SLIDE_OUT = 0x20, + EFFECT_SLIDE_FROM = 0x40, + EFFECT_FADE = 0x80, + EFFECT_SCALE = 0x100, + EFFECT_COLOR_TRANSITION = 0x200 }; enum { - ALIGN_LEFT = 0x01, - ALIGN_CENTER = 0x02, - ALIGN_RIGHT = 0x04, - ALIGN_TOP = 0x10, - ALIGN_MIDDLE = 0x20, - ALIGN_BOTTOM = 0x40, - ALIGN_TOP_LEFT = ALIGN_LEFT | ALIGN_TOP, - ALIGN_TOP_CENTER = ALIGN_CENTER | ALIGN_TOP, - ALIGN_TOP_RIGHT = ALIGN_RIGHT | ALIGN_TOP, - ALIGN_CENTERED = ALIGN_CENTER | ALIGN_MIDDLE, + ALIGN_LEFT = 0x01, + ALIGN_CENTER = 0x02, + ALIGN_RIGHT = 0x04, + ALIGN_TOP = 0x10, + ALIGN_MIDDLE = 0x20, + ALIGN_BOTTOM = 0x40, + ALIGN_TOP_LEFT = ALIGN_LEFT | ALIGN_TOP, + ALIGN_TOP_CENTER = ALIGN_CENTER | ALIGN_TOP, + ALIGN_TOP_RIGHT = ALIGN_RIGHT | ALIGN_TOP, + ALIGN_CENTERED = ALIGN_CENTER | ALIGN_MIDDLE, }; //!Forward declaration @@ -154,21 +154,21 @@ public: if (alignment & ALIGN_TOP) { float pHeight = 0.0f; - float pScale = 0.0f; + float pScale = 0.0f; if (parentElement) { pHeight = parentElement->getHeight(); - pScale = parentElement->getScaleY(); + pScale = parentElement->getScaleY(); } pCenterY += pHeight * 0.5f * pScale - getHeight() * 0.5f * getScaleY(); } else if (alignment & ALIGN_BOTTOM) { float pHeight = 0.0f; - float pScale = 0.0f; + float pScale = 0.0f; if (parentElement) { pHeight = parentElement->getHeight(); - pScale = parentElement->getScaleY(); + pScale = parentElement->getScaleY(); } pCenterY -= pHeight * 0.5f * pScale - getHeight() * 0.5f * getScaleY(); @@ -202,7 +202,7 @@ public: //!\param w Width of element //!\param h Height of element virtual void setSize(float w, float h) { - width = w; + width = w; height = h; } @@ -471,10 +471,7 @@ public: //!\param y Y coordinate //!\return true if contained within, false otherwise virtual bool isInside(float x, float y) { - return (x > (this->getCenterX() - getScaleX() * getWidth() * 0.5f) - && x < (this->getCenterX() + getScaleX() * getWidth() * 0.5f) - && y > (this->getCenterY() - getScaleY() * getHeight() * 0.5f) - && y < (this->getCenterY() + getScaleY() * getHeight() * 0.5f)); + return (x > (this->getCenterX() - getScaleX() * getWidth() * 0.5f) && x < (this->getCenterX() + getScaleX() * getWidth() * 0.5f) && y > (this->getCenterY() - getScaleY() * getHeight() * 0.5f) && y < (this->getCenterY() + getScaleY() * getHeight() * 0.5f)); } //!Sets the element's position @@ -545,15 +542,15 @@ public: } POINT; enum { - STATE_DEFAULT = 0, - STATE_SELECTED = 0x01, - STATE_CLICKED = 0x02, - STATE_HELD = 0x04, - STATE_OVER = 0x08, - STATE_HIDDEN = 0x10, + STATE_DEFAULT = 0, + STATE_SELECTED = 0x01, + STATE_CLICKED = 0x02, + STATE_HELD = 0x04, + STATE_OVER = 0x08, + STATE_HIDDEN = 0x10, STATE_DISABLE_INPUT = 0x20, STATE_CLICKED_TOUCH = 0x40, - STATE_DISABLED = 0x80 + STATE_DISABLED = 0x80 }; //! Switch pointer from control to screen position @@ -574,37 +571,38 @@ public: sigslot::signal2 visibleChanged; sigslot::signal3 stateChanged; sigslot::signal1 effectFinished; + protected: - bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event - bool visible; //!< Visibility of the element. If false, Draw() is skipped - bool selectable; //!< Whether or not this element selectable (can change to SELECTED state) - bool clickable; //!< Whether or not this element is clickable (can change to CLICKED state) - bool holdable; //!< Whether or not this element is holdable (can change to HELD state) + bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event + bool visible; //!< Visibility of the element. If false, Draw() is skipped + bool selectable; //!< Whether or not this element selectable (can change to SELECTED state) + bool clickable; //!< Whether or not this element is clickable (can change to CLICKED state) + bool holdable; //!< Whether or not this element is holdable (can change to HELD state) bool drawOverOnlyWhenSelected; //!< Whether or not this element is holdable (can change to HELD state) - float width; //!< Element width - float height; //!< Element height - float xoffset; //!< Element X offset - float yoffset; //!< Element Y offset - float zoffset; //!< Element Z offset - float alpha; //!< Element alpha value (0-255) - float angle; //!< Angle of the object (0-360) - float scaleX; //!< Element scale (1 = 100%) - float scaleY; //!< Element scale (1 = 100%) - float scaleZ; //!< Element scale (1 = 100%) - int32_t alignment; //!< Horizontal element alignment, respective to parent element - int32_t state[5]; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED) - int32_t stateChan; //!< Which controller channel is responsible for the last change in state - GuiElement *parentElement; //!< Parent element + float width; //!< Element width + float height; //!< Element height + float xoffset; //!< Element X offset + float yoffset; //!< Element Y offset + float zoffset; //!< Element Z offset + float alpha; //!< Element alpha value (0-255) + float angle; //!< Angle of the object (0-360) + float scaleX; //!< Element scale (1 = 100%) + float scaleY; //!< Element scale (1 = 100%) + float scaleZ; //!< Element scale (1 = 100%) + int32_t alignment; //!< Horizontal element alignment, respective to parent element + int32_t state[5]; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED) + int32_t stateChan; //!< Which controller channel is responsible for the last change in state + GuiElement *parentElement; //!< Parent element //! TODO: Move me to some Animator class - int32_t xoffsetDyn; //!< Element X offset, dynamic (added to xoffset value for animation effects) - int32_t yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects) - float alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects) - float scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects) - int32_t effects; //!< Currently enabled effect(s). 0 when no effects are enabled - int32_t effectAmount; //!< Effect amount. Used by different effects for different purposes - int32_t effectTarget; //!< Effect target amount. Used by different effects for different purposes - int32_t effectsOver; //!< Effects to enable when wiimote cursor is over this element. Copied to effects variable on over event + int32_t xoffsetDyn; //!< Element X offset, dynamic (added to xoffset value for animation effects) + int32_t yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects) + float alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects) + float scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects) + int32_t effects; //!< Currently enabled effect(s). 0 when no effects are enabled + int32_t effectAmount; //!< Effect amount. Used by different effects for different purposes + int32_t effectTarget; //!< Effect target amount. Used by different effects for different purposes + int32_t effectsOver; //!< Effects to enable when wiimote cursor is over this element. Copied to effects variable on over event int32_t effectAmountOver; //!< EffectAmount to set when wiimote cursor is over this element int32_t effectTargetOver; //!< EffectTarget to set when wiimote cursor is over this element }; diff --git a/include/gui/GuiFrame.h b/include/gui/GuiFrame.h index 7a00ba0..a28262e 100644 --- a/include/gui/GuiFrame.h +++ b/include/gui/GuiFrame.h @@ -17,10 +17,10 @@ #ifndef GUI_FRAME_H_ #define GUI_FRAME_H_ -#include -#include #include #include +#include +#include //!Allows GuiElements to be grouped together into a "window" class GuiFrame : public GuiElement { @@ -116,9 +116,10 @@ public: //! Signals //! On Closing sigslot::signal1 closing; + protected: - bool dim; //! Enable/disable dim of a window only - GuiFrame *parent; //!< Parent Window + bool dim; //! Enable/disable dim of a window only + GuiFrame *parent; //!< Parent Window std::vector elements; //!< Contains all elements within the GuiFrame std::recursive_mutex mutex; }; diff --git a/include/gui/GuiImage.h b/include/gui/GuiImage.h index 64f640c..3754b75 100644 --- a/include/gui/GuiImage.h +++ b/include/gui/GuiImage.h @@ -17,10 +17,10 @@ #ifndef GUI_IMAGE_H_ #define GUI_IMAGE_H_ -#include #include #include #include +#include //!Display, manage, and manipulate images in the GUI class GuiImage : public GuiElement { @@ -103,10 +103,10 @@ public: protected: void internalInit(int32_t w, int32_t h); - int32_t imgType; //!< Type of image data (IMAGE_TEXTURE, IMAGE_COLOR, IMAGE_DATA) - GuiImageData *imageData; //!< Poiner to image data. May be shared with GuiImageData data - int32_t tileHorizontal; //!< Number of times to draw (tile) the image horizontally - int32_t tileVertical; //!< Number of times to draw (tile) the image vertically + int32_t imgType; //!< Type of image data (IMAGE_TEXTURE, IMAGE_COLOR, IMAGE_DATA) + GuiImageData *imageData; //!< Poiner to image data. May be shared with GuiImageData data + int32_t tileHorizontal; //!< Number of times to draw (tile) the image horizontally + int32_t tileVertical; //!< Number of times to draw (tile) the image vertically //! Internally used variables for rendering uint8_t *colorVtxs; diff --git a/include/gui/GuiImageAsync.h b/include/gui/GuiImageAsync.h index 0debc72..77f7194 100644 --- a/include/gui/GuiImageAsync.h +++ b/include/gui/GuiImageAsync.h @@ -17,10 +17,10 @@ #ifndef _GUIIMAGEASYNC_H_ #define _GUIIMAGEASYNC_H_ -#include -#include #include #include +#include +#include class GuiImageAsync : public GuiImage { public: diff --git a/include/gui/GuiImageData.h b/include/gui/GuiImageData.h index 4317ce2..0bc1624 100644 --- a/include/gui/GuiImageData.h +++ b/include/gui/GuiImageData.h @@ -51,15 +51,21 @@ public: //!Gets the image width //!\return image width int32_t getWidth() const { - if (texture) { return texture->surface.width; } - else { return 0; } + if (texture) { + return texture->surface.width; + } else { + return 0; + } }; //!Gets the image height //!\return image height int32_t getHeight() const { - if (texture) { return texture->surface.height; } - else { return 0; } + if (texture) { + return texture->surface.height; + } else { + return 0; + } }; //! release memory of the image data diff --git a/include/gui/GuiScrollbar.h b/include/gui/GuiScrollbar.h index 2212fa1..b3faf78 100644 --- a/include/gui/GuiScrollbar.h +++ b/include/gui/GuiScrollbar.h @@ -24,8 +24,8 @@ #ifndef GUI_SCROLLBAR_HPP_ #define GUI_SCROLLBAR_HPP_ -#include #include +#include class GuiScrollbar : public GuiElement, public sigslot::has_slots<> { public: @@ -139,9 +139,9 @@ protected: GuiSound *clickSound = NULL; GuiImage *scrollbarLineImage = NULL; - GuiImage *arrowDownImage = NULL; - GuiImage *arrowUpImage = NULL; - GuiImage *scrollbarBoxImage = NULL; + GuiImage *arrowDownImage = NULL; + GuiImage *arrowUpImage = NULL; + GuiImage *scrollbarBoxImage = NULL; GuiTrigger touchTrigger; GuiTrigger wpadTouchTrigger; diff --git a/include/gui/GuiSelectBox.h b/include/gui/GuiSelectBox.h index 472c7d0..032d147 100644 --- a/include/gui/GuiSelectBox.h +++ b/include/gui/GuiSelectBox.h @@ -101,12 +101,12 @@ protected: bool opened; std::string captionText; GuiFrame valuesFrame; - GuiImage *topBackgroundImg = NULL; + GuiImage *topBackgroundImg = NULL; GuiImage *topHighlightedImg = NULL; GuiButton topValueButton; - GuiImageData *valueImageData = NULL; - GuiImageData *valueSelectedImageData = NULL; + GuiImageData *valueImageData = NULL; + GuiImageData *valueSelectedImageData = NULL; GuiImageData *valueHighlightedImageData = NULL; GuiText topValueText; @@ -134,7 +134,6 @@ protected: std::map buttonToValue; std::vector valueButtons; - }; #endif diff --git a/include/gui/GuiSwitch.h b/include/gui/GuiSwitch.h index 3de664e..e58c1b5 100644 --- a/include/gui/GuiSwitch.h +++ b/include/gui/GuiSwitch.h @@ -17,9 +17,9 @@ #ifndef GUI_SWTICH_H_ #define GUI_SWTICH_H_ -#include #include #include +#include //!A simple switch class GuiSwitch : public GuiToggle { @@ -40,10 +40,9 @@ public: void setImageHighlighted(GuiImage *img); protected: - - GuiImage *backgroundImg = NULL; - GuiImage *onImg = NULL; - GuiImage *offImg = NULL; + GuiImage *backgroundImg = NULL; + GuiImage *onImg = NULL; + GuiImage *offImg = NULL; GuiImage *highlightedImg = NULL; void draw(CVideo *v); diff --git a/include/gui/GuiText.h b/include/gui/GuiText.h index 0fc3a85..8b0841e 100644 --- a/include/gui/GuiText.h +++ b/include/gui/GuiText.h @@ -152,7 +152,7 @@ public: virtual void setSize(float w, float h) { //! We calculate the size based on the text. - this->width = 0; + this->width = 0; this->height = 0; } @@ -167,6 +167,7 @@ public: SCROLL_HORIZONTAL, SCROLL_NONE }; + protected: static FreeTypeGX *presentFont; static int32_t presetSSAA; @@ -193,11 +194,11 @@ protected: wchar_t *text; std::vector textDyn; std::vector textDynWidth; - int32_t wrapMode; //!< Wrapping toggle - int32_t textScrollPos; //!< Current starting index of text string for scrolling + int32_t wrapMode; //!< Wrapping toggle + int32_t textScrollPos; //!< Current starting index of text string for scrolling int32_t textScrollInitialDelay; //!< Delay to wait before starting to scroll - int32_t textScrollDelay; //!< Scrolling speed - int32_t maxWidth; //!< Maximum width of the generated text object (for text wrapping) + int32_t textScrollDelay; //!< Scrolling speed + int32_t maxWidth; //!< Maximum width of the generated text object (for text wrapping) FreeTypeGX *font; int32_t currentSize; int32_t linestodraw; diff --git a/include/gui/GuiToggle.h b/include/gui/GuiToggle.h index dd8d5c6..aeff790 100644 --- a/include/gui/GuiToggle.h +++ b/include/gui/GuiToggle.h @@ -40,7 +40,6 @@ public: void setChecked() { setValue(true); - } void setUnchecked() { @@ -56,7 +55,6 @@ public: void OnToggleClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); protected: - bool selected; bool bChanged; diff --git a/include/gui/GuiTrigger.h b/include/gui/GuiTrigger.h index 2ee9097..a456cbd 100644 --- a/include/gui/GuiTrigger.h +++ b/include/gui/GuiTrigger.h @@ -25,49 +25,49 @@ class GuiController; class GuiTrigger { public: enum eClicked { - CLICKED_NONE = 0x00, - CLICKED_TOUCH = 0x01, - CLICKED_BUTTON = 0x02, + CLICKED_NONE = 0x00, + CLICKED_TOUCH = 0x01, + CLICKED_BUTTON = 0x02, }; enum eChannels { - CHANNEL_1 = 0x01, - CHANNEL_2 = 0x02, - CHANNEL_3 = 0x04, - CHANNEL_4 = 0x08, - CHANNEL_5 = 0x10, - CHANNEL_ALL = 0xFF + CHANNEL_1 = 0x01, + CHANNEL_2 = 0x02, + CHANNEL_3 = 0x04, + CHANNEL_4 = 0x08, + CHANNEL_5 = 0x10, + CHANNEL_ALL = 0xFF }; enum eButtons { - BUTTON_NONE = 0x0000, - VPAD_TOUCH = 0x80000000, - BUTTON_Z = 0x20000, - BUTTON_C = 0x10000, - BUTTON_A = 0x8000, - BUTTON_B = 0x4000, - BUTTON_X = 0x2000, - BUTTON_Y = 0x1000, - BUTTON_1 = BUTTON_Y, - BUTTON_2 = BUTTON_X, - BUTTON_LEFT = 0x0800, - BUTTON_RIGHT = 0x0400, - BUTTON_UP = 0x0200, - BUTTON_DOWN = 0x0100, - BUTTON_ZL = 0x0080, - BUTTON_ZR = 0x0040, - BUTTON_L = 0x0020, - BUTTON_R = 0x0010, - BUTTON_PLUS = 0x0008, - BUTTON_MINUS = 0x0004, - BUTTON_HOME = 0x0002, - BUTTON_SYNC = 0x0001, - STICK_R_LEFT = 0x04000000, - STICK_R_RIGHT = 0x02000000, - STICK_R_UP = 0x01000000, - STICK_R_DOWN = 0x00800000, - STICK_L_LEFT = 0x40000000, - STICK_L_RIGHT = 0x20000000, - STICK_L_UP = 0x10000000, - STICK_L_DOWN = 0x08000000 + BUTTON_NONE = 0x0000, + VPAD_TOUCH = 0x80000000, + BUTTON_Z = 0x20000, + BUTTON_C = 0x10000, + BUTTON_A = 0x8000, + BUTTON_B = 0x4000, + BUTTON_X = 0x2000, + BUTTON_Y = 0x1000, + BUTTON_1 = BUTTON_Y, + BUTTON_2 = BUTTON_X, + BUTTON_LEFT = 0x0800, + BUTTON_RIGHT = 0x0400, + BUTTON_UP = 0x0200, + BUTTON_DOWN = 0x0100, + BUTTON_ZL = 0x0080, + BUTTON_ZR = 0x0040, + BUTTON_L = 0x0020, + BUTTON_R = 0x0010, + BUTTON_PLUS = 0x0008, + BUTTON_MINUS = 0x0004, + BUTTON_HOME = 0x0002, + BUTTON_SYNC = 0x0001, + STICK_R_LEFT = 0x04000000, + STICK_R_RIGHT = 0x02000000, + STICK_R_UP = 0x01000000, + STICK_R_DOWN = 0x00800000, + STICK_L_LEFT = 0x40000000, + STICK_L_RIGHT = 0x20000000, + STICK_L_UP = 0x10000000, + STICK_L_DOWN = 0x08000000 }; //!Constructor diff --git a/include/gui/VPadController.h b/include/gui/VPadController.h index 819843f..6406eb6 100644 --- a/include/gui/VPadController.h +++ b/include/gui/VPadController.h @@ -24,7 +24,7 @@ class VPadController : public GuiController { public: //!Constructor VPadController(int32_t channel) - : GuiController(channel) { + : GuiController(channel) { memset(&vpad, 0, sizeof(vpad)); } @@ -38,11 +38,11 @@ public: VPADRead(VPAD_CHAN_0, &vpad, 1, &vpadError); if (vpadError == VPAD_READ_SUCCESS) { - data.buttons_r = vpad.release; - data.buttons_h = vpad.hold; - data.buttons_d = vpad.trigger; + data.buttons_r = vpad.release; + data.buttons_h = vpad.hold; + data.buttons_d = vpad.trigger; data.validPointer = !vpad.tpNormal.validity; - data.touched = vpad.tpNormal.touched; + data.touched = vpad.tpNormal.touched; VPADGetTPCalibratedPoint(VPAD_CHAN_0, &tpCalib, &vpad.tpFiltered1); diff --git a/include/gui/WPadController.h b/include/gui/WPadController.h index 6c2344a..2c8218c 100644 --- a/include/gui/WPadController.h +++ b/include/gui/WPadController.h @@ -25,7 +25,7 @@ class WPadController : public GuiController { public: //!Constructor WPadController(int32_t channel) - : GuiController(channel) { + : GuiController(channel) { memset(&kpadData, 0, sizeof(kpadData)); } diff --git a/include/gui/gx2_ext.h b/include/gui/gx2_ext.h index 8290776..ff1b353 100644 --- a/include/gui/gx2_ext.h +++ b/include/gui/gx2_ext.h @@ -1,5 +1,5 @@ #ifndef __GX2_EXTENSION_H -#define __GX2_EXTENSION_H +#define __GX2_EXTENSION_H #ifdef __cplusplus extern "C" { @@ -14,19 +14,19 @@ extern "C" { #include #include -#define GX2_AA_BUFFER_CLEAR_VALUE 0xCC +#define GX2_AA_BUFFER_CLEAR_VALUE 0xCC -#define GX2_COMP_SEL_NONE 0x04040405 -#define GX2_COMP_SEL_X001 0x00040405 -#define GX2_COMP_SEL_XY01 0x00010405 -#define GX2_COMP_SEL_XYZ1 0x00010205 -#define GX2_COMP_SEL_XYZW 0x00010203 -#define GX2_COMP_SEL_XXXX 0x00000000 -#define GX2_COMP_SEL_YYYY 0x01010101 -#define GX2_COMP_SEL_ZZZZ 0x02020202 -#define GX2_COMP_SEL_WWWW 0x03030303 -#define GX2_COMP_SEL_WZYX 0x03020100 -#define GX2_COMP_SEL_WXYZ 0x03000102 +#define GX2_COMP_SEL_NONE 0x04040405 +#define GX2_COMP_SEL_X001 0x00040405 +#define GX2_COMP_SEL_XY01 0x00010405 +#define GX2_COMP_SEL_XYZ1 0x00010205 +#define GX2_COMP_SEL_XYZW 0x00010203 +#define GX2_COMP_SEL_XXXX 0x00000000 +#define GX2_COMP_SEL_YYYY 0x01010101 +#define GX2_COMP_SEL_ZZZZ 0x02020202 +#define GX2_COMP_SEL_WWWW 0x03030303 +#define GX2_COMP_SEL_WZYX 0x03020100 +#define GX2_COMP_SEL_WXYZ 0x03000102 typedef struct _GX2Color { uint8_t r, g, b, a; @@ -40,8 +40,7 @@ static const uint32_t attribute_dest_comp_selector[20] = { GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, - GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW -}; + GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW}; static const uint32_t texture_comp_selector[54] = { GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, @@ -52,58 +51,56 @@ static const uint32_t texture_comp_selector[54] = { GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, - GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01 -}; + GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01}; static inline void GX2InitDepthBuffer(GX2DepthBuffer *depthBuffer, GX2SurfaceDim dim, uint32_t width, uint32_t height, uint32_t depth, GX2SurfaceFormat format, GX2AAMode aa) { - depthBuffer->surface.dim = dim; - depthBuffer->surface.width = width; - depthBuffer->surface.height = height; - depthBuffer->surface.depth = depth; + depthBuffer->surface.dim = dim; + depthBuffer->surface.width = width; + depthBuffer->surface.height = height; + depthBuffer->surface.depth = depth; depthBuffer->surface.mipLevels = 1; - depthBuffer->surface.format = format; - depthBuffer->surface.aa = aa; - depthBuffer->surface.use = (GX2SurfaceUse) (((format == GX2_SURFACE_FORMAT_UNORM_R24_X8) || (format == GX2_SURFACE_FORMAT_FLOAT_D24_S8)) ? - GX2_SURFACE_USE_DEPTH_BUFFER : (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE)); - depthBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT; - depthBuffer->surface.swizzle = 0; - depthBuffer->viewMip = 0; - depthBuffer->viewFirstSlice = 0; - depthBuffer->viewNumSlices = depth; - depthBuffer->depthClear = 1.0f; - depthBuffer->stencilClear = 0; - depthBuffer->hiZPtr = NULL; - depthBuffer->hiZSize = 0; + depthBuffer->surface.format = format; + depthBuffer->surface.aa = aa; + depthBuffer->surface.use = (GX2SurfaceUse) (((format == GX2_SURFACE_FORMAT_UNORM_R24_X8) || (format == GX2_SURFACE_FORMAT_FLOAT_D24_S8)) ? GX2_SURFACE_USE_DEPTH_BUFFER : (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE)); + depthBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT; + depthBuffer->surface.swizzle = 0; + depthBuffer->viewMip = 0; + depthBuffer->viewFirstSlice = 0; + depthBuffer->viewNumSlices = depth; + depthBuffer->depthClear = 1.0f; + depthBuffer->stencilClear = 0; + depthBuffer->hiZPtr = NULL; + depthBuffer->hiZSize = 0; GX2CalcSurfaceSizeAndAlignment(&depthBuffer->surface); GX2InitDepthBufferRegs(depthBuffer); } static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, GX2SurfaceDim dim, uint32_t width, uint32_t height, uint32_t depth, GX2SurfaceFormat format, GX2AAMode aa) { - colorBuffer->surface.dim = dim; - colorBuffer->surface.width = width; - colorBuffer->surface.height = height; - colorBuffer->surface.depth = depth; - colorBuffer->surface.mipLevels = 1; - colorBuffer->surface.format = format; - colorBuffer->surface.aa = aa; - colorBuffer->surface.use = GX2_SURFACE_USE_TEXTURE_COLOR_BUFFER_TV; - colorBuffer->surface.imageSize = 0; - colorBuffer->surface.image = NULL; + colorBuffer->surface.dim = dim; + colorBuffer->surface.width = width; + colorBuffer->surface.height = height; + colorBuffer->surface.depth = depth; + colorBuffer->surface.mipLevels = 1; + colorBuffer->surface.format = format; + colorBuffer->surface.aa = aa; + colorBuffer->surface.use = GX2_SURFACE_USE_TEXTURE_COLOR_BUFFER_TV; + colorBuffer->surface.imageSize = 0; + colorBuffer->surface.image = NULL; colorBuffer->surface.mipmapSize = 0; - colorBuffer->surface.mipmaps = NULL; - colorBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT; - colorBuffer->surface.swizzle = 0; - colorBuffer->surface.alignment = 0; - colorBuffer->surface.pitch = 0; + colorBuffer->surface.mipmaps = NULL; + colorBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT; + colorBuffer->surface.swizzle = 0; + colorBuffer->surface.alignment = 0; + colorBuffer->surface.pitch = 0; uint32_t i; for (i = 0; i < 13; i++) { colorBuffer->surface.mipLevelOffset[i] = 0; } - colorBuffer->viewMip = 0; + colorBuffer->viewMip = 0; colorBuffer->viewFirstSlice = 0; - colorBuffer->viewNumSlices = depth; - colorBuffer->aaBuffer = NULL; - colorBuffer->aaSize = 0; + colorBuffer->viewNumSlices = depth; + colorBuffer->aaBuffer = NULL; + colorBuffer->aaSize = 0; for (i = 0; i < 5; i++) { colorBuffer->regs[i] = 0; } @@ -113,42 +110,42 @@ static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, GX2SurfaceDim } static inline void GX2InitAttribStream(GX2AttribStream *attr, uint32_t location, uint32_t buffer, uint32_t offset, GX2AttribFormat format) { - attr->location = location; - attr->buffer = buffer; - attr->offset = offset; - attr->format = format; - attr->type = GX2_ATTRIB_INDEX_PER_VERTEX; + attr->location = location; + attr->buffer = buffer; + attr->offset = offset; + attr->format = format; + attr->type = GX2_ATTRIB_INDEX_PER_VERTEX; attr->aluDivisor = 0; - attr->mask = attribute_dest_comp_selector[format & 0xff]; + attr->mask = attribute_dest_comp_selector[format & 0xff]; attr->endianSwap = GX2_ENDIAN_SWAP_DEFAULT; } static inline void GX2InitTexture(GX2Texture *tex, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevels, GX2SurfaceFormat format, GX2SurfaceDim dim, GX2TileMode tile) { - tex->surface.dim = dim; - tex->surface.width = width; - tex->surface.height = height; - tex->surface.depth = depth; - tex->surface.mipLevels = mipLevels; - tex->surface.format = format; - tex->surface.aa = GX2_AA_MODE1X; - tex->surface.use = GX2_SURFACE_USE_TEXTURE; - tex->surface.imageSize = 0; - tex->surface.image = NULL; + tex->surface.dim = dim; + tex->surface.width = width; + tex->surface.height = height; + tex->surface.depth = depth; + tex->surface.mipLevels = mipLevels; + tex->surface.format = format; + tex->surface.aa = GX2_AA_MODE1X; + tex->surface.use = GX2_SURFACE_USE_TEXTURE; + tex->surface.imageSize = 0; + tex->surface.image = NULL; tex->surface.mipmapSize = 0; - tex->surface.mipmaps = NULL; - tex->surface.tileMode = tile; - tex->surface.swizzle = 0; - tex->surface.alignment = 0; - tex->surface.pitch = 0; + tex->surface.mipmaps = NULL; + tex->surface.tileMode = tile; + tex->surface.swizzle = 0; + tex->surface.alignment = 0; + tex->surface.pitch = 0; uint32_t i; for (i = 0; i < 13; i++) { tex->surface.mipLevelOffset[i] = 0; } - tex->viewFirstMip = 0; - tex->viewNumMips = mipLevels; + tex->viewFirstMip = 0; + tex->viewNumMips = mipLevels; tex->viewFirstSlice = 0; - tex->viewNumSlices = depth; - tex->compMap = texture_comp_selector[format & 0x3f]; + tex->viewNumSlices = depth; + tex->compMap = texture_comp_selector[format & 0x3f]; for (i = 0; i < 5; i++) { tex->regs[i] = 0; } @@ -162,4 +159,3 @@ static inline void GX2InitTexture(GX2Texture *tex, uint32_t width, uint32_t heig #endif #endif - diff --git a/include/gui/memory.h b/include/gui/memory.h index a9cea4d..392688b 100644 --- a/include/gui/memory.h +++ b/include/gui/memory.h @@ -21,6 +21,7 @@ extern "C" { #endif +#include #include void libgui_memoryInitialize(void); diff --git a/include/gui/sigslot.h b/include/gui/sigslot.h index f578c47..def6b1f 100644 --- a/include/gui/sigslot.h +++ b/include/gui/sigslot.h @@ -77,17 +77,17 @@ #ifndef SIGSLOT_H__ #define SIGSLOT_H__ -#include #include +#include #define _SIGSLOT_SINGLE_THREADED #ifndef SIGSLOT_DEFAULT_MT_POLICY -# ifdef _SIGSLOT_SINGLE_THREADED -# define SIGSLOT_DEFAULT_MT_POLICY single_threaded -# else -# define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local -# endif +#ifdef _SIGSLOT_SINGLE_THREADED +#define SIGSLOT_DEFAULT_MT_POLICY single_threaded +#else +#define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local +#endif #endif @@ -119,13 +119,13 @@ namespace sigslot { multi_threaded_global() { static bool isinitialised = false; - if(!isinitialised) { + if (!isinitialised) { InitializeCriticalSection(get_critsec()); isinitialised = true; } } - multi_threaded_global(const multi_threaded_global&) { + multi_threaded_global(const multi_threaded_global &) { ; } @@ -142,7 +142,7 @@ namespace sigslot { } private: - CRITICAL_SECTION* get_critsec() { + CRITICAL_SECTION *get_critsec() { static CRITICAL_SECTION g_critsec; return &g_critsec; } @@ -154,7 +154,7 @@ namespace sigslot { InitializeCriticalSection(&m_critsec); } - multi_threaded_local(const multi_threaded_local&) { + multi_threaded_local(const multi_threaded_local &) { InitializeCriticalSection(&m_critsec); } @@ -183,7 +183,7 @@ namespace sigslot { pthread_mutex_init(get_mutex(), NULL); } - multi_threaded_global(const multi_threaded_global&) { + multi_threaded_global(const multi_threaded_global &) { ; } @@ -200,7 +200,7 @@ namespace sigslot { } private: - pthread_mutex_t* get_mutex() { + pthread_mutex_t *get_mutex() { static pthread_mutex_t g_mutex; return &g_mutex; } @@ -212,7 +212,7 @@ namespace sigslot { pthread_mutex_init(&m_mutex, NULL); } - multi_threaded_local(const multi_threaded_local&) { + multi_threaded_local(const multi_threaded_local &) { pthread_mutex_init(&m_mutex, NULL); } @@ -241,7 +241,7 @@ namespace sigslot { ; } - multi_threaded_global(const multi_threaded_global&) { + multi_threaded_global(const multi_threaded_global &) { ; } @@ -264,7 +264,7 @@ namespace sigslot { ; } - multi_threaded_local(const multi_threaded_local&) { + multi_threaded_local(const multi_threaded_local &) { ; } @@ -288,7 +288,7 @@ namespace sigslot { mt_policy *m_mutex; lock_block(mt_policy *mtx) - : m_mutex(mtx) { + : m_mutex(mtx) { m_mutex->lock(); } @@ -381,7 +381,7 @@ namespace sigslot { }; template + class arg5_type, class mt_policy> class _connection_base5 { public: virtual ~_connection_base5() { @@ -394,14 +394,16 @@ namespace sigslot { arg5_type) = 0; virtual _connection_base5 *clone() = 0; + arg5_type, mt_policy> * + clone() = 0; virtual _connection_base5 *duplicate(has_slots *pnewdest) = 0; + arg5_type, mt_policy> * + duplicate(has_slots *pnewdest) = 0; }; template + class arg5_type, class arg6_type, class mt_policy> class _connection_base6 { public: virtual ~_connection_base6() { @@ -414,14 +416,16 @@ namespace sigslot { arg6_type) = 0; virtual _connection_base6 *clone() = 0; + arg5_type, arg6_type, mt_policy> * + clone() = 0; virtual _connection_base6 *duplicate(has_slots *pnewdest) = 0; + arg5_type, arg6_type, mt_policy> * + duplicate(has_slots *pnewdest) = 0; }; template + class arg5_type, class arg6_type, class arg7_type, class mt_policy> class _connection_base7 { public: virtual ~_connection_base7() { @@ -434,14 +438,16 @@ namespace sigslot { arg6_type, arg7_type) = 0; virtual _connection_base7 *clone() = 0; + arg5_type, arg6_type, arg7_type, mt_policy> * + clone() = 0; virtual _connection_base7 *duplicate(has_slots *pnewdest) = 0; + arg5_type, arg6_type, arg7_type, mt_policy> * + duplicate(has_slots *pnewdest) = 0; }; template + class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy> class _connection_base8 { public: virtual ~_connection_base8() { @@ -454,10 +460,12 @@ namespace sigslot { arg6_type, arg7_type, arg8_type) = 0; virtual _connection_base8 *clone() = 0; + arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> * + clone() = 0; virtual _connection_base8 *duplicate(has_slots *pnewdest) = 0; + arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> * + duplicate(has_slots *pnewdest) = 0; }; template @@ -480,9 +488,9 @@ namespace sigslot { } has_slots(const has_slots &hs) - : mt_policy(hs) { + : mt_policy(hs) { lock_block lock(this); - const_iterator it = hs.m_senders.begin(); + const_iterator it = hs.m_senders.begin(); const_iterator itEnd = hs.m_senders.end(); while (it != itEnd) { @@ -508,7 +516,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_senders.begin(); + const_iterator it = m_senders.begin(); const_iterator itEnd = m_senders.end(); while (it != itEnd) { @@ -535,9 +543,9 @@ namespace sigslot { } _signal_base0(const _signal_base0 &s) - : _signal_base(s) { + : _signal_base(s) { lock_block lock(this); - const_iterator it = s.m_connected_slots.begin(); + const_iterator it = s.m_connected_slots.begin(); const_iterator itEnd = s.m_connected_slots.end(); while (it != itEnd) { @@ -554,7 +562,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_connected_slots.begin(); + const_iterator it = m_connected_slots.begin(); const_iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -569,7 +577,7 @@ namespace sigslot { void disconnect(has_slots *pclass) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -590,7 +598,7 @@ namespace sigslot { void slot_disconnect(has_slots *pslot) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -609,7 +617,7 @@ namespace sigslot { void slot_duplicate(const has_slots *oldtarget, has_slots *newtarget) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -637,9 +645,9 @@ namespace sigslot { } _signal_base1(const _signal_base1 &s) - : _signal_base(s) { + : _signal_base(s) { lock_block lock(this); - const_iterator it = s.m_connected_slots.begin(); + const_iterator it = s.m_connected_slots.begin(); const_iterator itEnd = s.m_connected_slots.end(); while (it != itEnd) { @@ -652,7 +660,7 @@ namespace sigslot { void slot_duplicate(const has_slots *oldtarget, has_slots *newtarget) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -670,7 +678,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_connected_slots.begin(); + const_iterator it = m_connected_slots.begin(); const_iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -685,7 +693,7 @@ namespace sigslot { void disconnect(has_slots *pclass) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -706,7 +714,7 @@ namespace sigslot { void slot_disconnect(has_slots *pslot) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -741,9 +749,9 @@ namespace sigslot { } _signal_base2(const _signal_base2 &s) - : _signal_base(s) { + : _signal_base(s) { lock_block lock(this); - const_iterator it = s.m_connected_slots.begin(); + const_iterator it = s.m_connected_slots.begin(); const_iterator itEnd = s.m_connected_slots.end(); while (it != itEnd) { @@ -756,7 +764,7 @@ namespace sigslot { void slot_duplicate(const has_slots *oldtarget, has_slots *newtarget) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -774,7 +782,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_connected_slots.begin(); + const_iterator it = m_connected_slots.begin(); const_iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -789,7 +797,7 @@ namespace sigslot { void disconnect(has_slots *pclass) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -810,7 +818,7 @@ namespace sigslot { void slot_disconnect(has_slots *pslot) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -845,9 +853,9 @@ namespace sigslot { } _signal_base3(const _signal_base3 &s) - : _signal_base(s) { + : _signal_base(s) { lock_block lock(this); - const_iterator it = s.m_connected_slots.begin(); + const_iterator it = s.m_connected_slots.begin(); const_iterator itEnd = s.m_connected_slots.end(); while (it != itEnd) { @@ -860,7 +868,7 @@ namespace sigslot { void slot_duplicate(const has_slots *oldtarget, has_slots *newtarget) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -878,7 +886,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_connected_slots.begin(); + const_iterator it = m_connected_slots.begin(); const_iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -893,7 +901,7 @@ namespace sigslot { void disconnect(has_slots *pclass) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -914,7 +922,7 @@ namespace sigslot { void slot_disconnect(has_slots *pslot) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -939,7 +947,8 @@ namespace sigslot { class _signal_base4 : public _signal_base { public: typedef std::list<_connection_base4 *> connections_list; + arg4_type, mt_policy> *> + connections_list; typedef typename connections_list::const_iterator const_iterator; typedef typename connections_list::iterator iterator; @@ -948,9 +957,9 @@ namespace sigslot { } _signal_base4(const _signal_base4 &s) - : _signal_base(s) { + : _signal_base(s) { lock_block lock(this); - const_iterator it = s.m_connected_slots.begin(); + const_iterator it = s.m_connected_slots.begin(); const_iterator itEnd = s.m_connected_slots.end(); while (it != itEnd) { @@ -963,7 +972,7 @@ namespace sigslot { void slot_duplicate(const has_slots *oldtarget, has_slots *newtarget) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -981,7 +990,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_connected_slots.begin(); + const_iterator it = m_connected_slots.begin(); const_iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -996,7 +1005,7 @@ namespace sigslot { void disconnect(has_slots *pclass) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1017,7 +1026,7 @@ namespace sigslot { void slot_disconnect(has_slots *pslot) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1039,11 +1048,12 @@ namespace sigslot { }; template + class arg5_type, class mt_policy> class _signal_base5 : public _signal_base { public: typedef std::list<_connection_base5 *> connections_list; + arg4_type, arg5_type, mt_policy> *> + connections_list; typedef typename connections_list::const_iterator const_iterator; typedef typename connections_list::iterator iterator; @@ -1052,10 +1062,10 @@ namespace sigslot { } _signal_base5(const _signal_base5 &s) - : _signal_base(s) { + arg5_type, mt_policy> &s) + : _signal_base(s) { lock_block lock(this); - const_iterator it = s.m_connected_slots.begin(); + const_iterator it = s.m_connected_slots.begin(); const_iterator itEnd = s.m_connected_slots.end(); while (it != itEnd) { @@ -1068,7 +1078,7 @@ namespace sigslot { void slot_duplicate(const has_slots *oldtarget, has_slots *newtarget) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1086,7 +1096,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_connected_slots.begin(); + const_iterator it = m_connected_slots.begin(); const_iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1101,7 +1111,7 @@ namespace sigslot { void disconnect(has_slots *pclass) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1122,7 +1132,7 @@ namespace sigslot { void slot_disconnect(has_slots *pslot) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1144,11 +1154,12 @@ namespace sigslot { }; template + class arg5_type, class arg6_type, class mt_policy> class _signal_base6 : public _signal_base { public: typedef std::list<_connection_base6 *> connections_list; + arg4_type, arg5_type, arg6_type, mt_policy> *> + connections_list; typedef typename connections_list::const_iterator const_iterator; typedef typename connections_list::iterator iterator; @@ -1157,10 +1168,10 @@ namespace sigslot { } _signal_base6(const _signal_base6 &s) - : _signal_base(s) { + arg5_type, arg6_type, mt_policy> &s) + : _signal_base(s) { lock_block lock(this); - const_iterator it = s.m_connected_slots.begin(); + const_iterator it = s.m_connected_slots.begin(); const_iterator itEnd = s.m_connected_slots.end(); while (it != itEnd) { @@ -1173,7 +1184,7 @@ namespace sigslot { void slot_duplicate(const has_slots *oldtarget, has_slots *newtarget) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1191,7 +1202,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_connected_slots.begin(); + const_iterator it = m_connected_slots.begin(); const_iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1206,7 +1217,7 @@ namespace sigslot { void disconnect(has_slots *pclass) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1227,7 +1238,7 @@ namespace sigslot { void slot_disconnect(has_slots *pslot) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1249,11 +1260,12 @@ namespace sigslot { }; template + class arg5_type, class arg6_type, class arg7_type, class mt_policy> class _signal_base7 : public _signal_base { public: typedef std::list<_connection_base7 *> connections_list; + arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> *> + connections_list; typedef typename connections_list::const_iterator const_iterator; typedef typename connections_list::iterator iterator; @@ -1262,10 +1274,10 @@ namespace sigslot { } _signal_base7(const _signal_base7 &s) - : _signal_base(s) { + arg5_type, arg6_type, arg7_type, mt_policy> &s) + : _signal_base(s) { lock_block lock(this); - const_iterator it = s.m_connected_slots.begin(); + const_iterator it = s.m_connected_slots.begin(); const_iterator itEnd = s.m_connected_slots.end(); while (it != itEnd) { @@ -1278,7 +1290,7 @@ namespace sigslot { void slot_duplicate(const has_slots *oldtarget, has_slots *newtarget) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1296,7 +1308,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_connected_slots.begin(); + const_iterator it = m_connected_slots.begin(); const_iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1311,7 +1323,7 @@ namespace sigslot { void disconnect(has_slots *pclass) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1332,7 +1344,7 @@ namespace sigslot { void slot_disconnect(has_slots *pslot) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1354,11 +1366,11 @@ namespace sigslot { }; template + class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy> class _signal_base8 : public _signal_base { public: typedef std::list<_connection_base8 *> + arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> *> connections_list; typedef typename connections_list::const_iterator const_iterator; typedef typename connections_list::iterator iterator; @@ -1368,10 +1380,10 @@ namespace sigslot { } _signal_base8(const _signal_base8 &s) - : _signal_base(s) { + arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> &s) + : _signal_base(s) { lock_block lock(this); - const_iterator it = s.m_connected_slots.begin(); + const_iterator it = s.m_connected_slots.begin(); const_iterator itEnd = s.m_connected_slots.end(); while (it != itEnd) { @@ -1384,7 +1396,7 @@ namespace sigslot { void slot_duplicate(const has_slots *oldtarget, has_slots *newtarget) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1402,7 +1414,7 @@ namespace sigslot { void disconnect_all() { lock_block lock(this); - const_iterator it = m_connected_slots.begin(); + const_iterator it = m_connected_slots.begin(); const_iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1417,7 +1429,7 @@ namespace sigslot { void disconnect(has_slots *pclass) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1438,7 +1450,7 @@ namespace sigslot { void slot_disconnect(has_slots *pslot) { lock_block lock(this); - iterator it = m_connected_slots.begin(); + iterator it = m_connected_slots.begin(); iterator itEnd = m_connected_slots.end(); while (it != itEnd) { @@ -1496,7 +1508,7 @@ namespace sigslot { private: dest_type *m_pobject; - void (dest_type::* m_pmemfun)(); + void (dest_type::*m_pmemfun)(); }; template @@ -1535,7 +1547,7 @@ namespace sigslot { private: dest_type *m_pobject; - void (dest_type::* m_pmemfun)(arg1_type); + void (dest_type::*m_pmemfun)(arg1_type); }; template @@ -1576,7 +1588,7 @@ namespace sigslot { private: dest_type *m_pobject; - void (dest_type::* m_pmemfun)(arg1_type, arg2_type); + void (dest_type::*m_pmemfun)(arg1_type, arg2_type); }; template @@ -1617,13 +1629,13 @@ namespace sigslot { private: dest_type *m_pobject; - void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type); + void (dest_type::*m_pmemfun)(arg1_type, arg2_type, arg3_type); }; template + class arg4_type, class mt_policy> class _connection4 : public _connection_base4 { + arg3_type, arg4_type, mt_policy> { public: _connection4() { this->pobject = NULL; @@ -1660,14 +1672,14 @@ namespace sigslot { private: dest_type *m_pobject; - void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, - arg4_type); + void (dest_type::*m_pmemfun)(arg1_type, arg2_type, arg3_type, + arg4_type); }; template + class arg4_type, class arg5_type, class mt_policy> class _connection5 : public _connection_base5 { + arg3_type, arg4_type, arg5_type, mt_policy> { public: _connection5() { this->pobject = NULL; @@ -1685,15 +1697,17 @@ namespace sigslot { } virtual _connection_base5 *clone() { + arg5_type, mt_policy> * + clone() { return new _connection5(*this); + arg5_type, mt_policy>(*this); } virtual _connection_base5 *duplicate(has_slots *pnewdest) { + arg5_type, mt_policy> * + duplicate(has_slots *pnewdest) { return new _connection5((dest_type *) pnewdest, m_pmemfun); + arg5_type, mt_policy>((dest_type *) pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, @@ -1708,14 +1722,14 @@ namespace sigslot { private: dest_type *m_pobject; - void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, - arg5_type); + void (dest_type::*m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, + arg5_type); }; template + class arg4_type, class arg5_type, class arg6_type, class mt_policy> class _connection6 : public _connection_base6 { + arg3_type, arg4_type, arg5_type, arg6_type, mt_policy> { public: _connection6() { this->pobject = NULL; @@ -1733,15 +1747,17 @@ namespace sigslot { } virtual _connection_base6 *clone() { + arg5_type, arg6_type, mt_policy> * + clone() { return new _connection6(*this); + arg5_type, arg6_type, mt_policy>(*this); } virtual _connection_base6 *duplicate(has_slots *pnewdest) { + arg5_type, arg6_type, mt_policy> * + duplicate(has_slots *pnewdest) { return new _connection6((dest_type *) pnewdest, m_pmemfun); + arg5_type, arg6_type, mt_policy>((dest_type *) pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, @@ -1756,14 +1772,14 @@ namespace sigslot { private: dest_type *m_pobject; - void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, - arg5_type, arg6_type); + void (dest_type::*m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, + arg5_type, arg6_type); }; template + class arg4_type, class arg5_type, class arg6_type, class arg7_type, class mt_policy> class _connection7 : public _connection_base7 { + arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> { public: _connection7() { this->pobject = NULL; @@ -1781,15 +1797,17 @@ namespace sigslot { } virtual _connection_base7 *clone() { + arg5_type, arg6_type, arg7_type, mt_policy> * + clone() { return new _connection7(*this); + arg5_type, arg6_type, arg7_type, mt_policy>(*this); } virtual _connection_base7 *duplicate(has_slots *pnewdest) { + arg5_type, arg6_type, arg7_type, mt_policy> * + duplicate(has_slots *pnewdest) { return new _connection7((dest_type *) pnewdest, m_pmemfun); + arg5_type, arg6_type, arg7_type, mt_policy>((dest_type *) pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, @@ -1804,15 +1822,15 @@ namespace sigslot { private: dest_type *m_pobject; - void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, - arg5_type, arg6_type, arg7_type); + void (dest_type::*m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, + arg5_type, arg6_type, arg7_type); }; template + class arg4_type, class arg5_type, class arg6_type, class arg7_type, + class arg8_type, class mt_policy> class _connection8 : public _connection_base8 { + arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> { public: _connection8() { this->pobject = NULL; @@ -1831,15 +1849,17 @@ namespace sigslot { } virtual _connection_base8 *clone() { + arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> * + clone() { return new _connection8(*this); + arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>(*this); } virtual _connection_base8 *duplicate(has_slots *pnewdest) { + arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> * + duplicate(has_slots *pnewdest) { return new _connection8((dest_type *) pnewdest, m_pmemfun); + arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>((dest_type *) pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, @@ -1854,8 +1874,8 @@ namespace sigslot { private: dest_type *m_pobject; - void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, - arg5_type, arg6_type, arg7_type, arg8_type); + void (dest_type::*m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, + arg5_type, arg6_type, arg7_type, arg8_type); }; template @@ -1868,7 +1888,7 @@ namespace sigslot { } signal0(const signal0 &s) - : _signal_base0(s) { + : _signal_base0(s) { ; } @@ -1926,7 +1946,7 @@ namespace sigslot { } signal1(const signal1 &s) - : _signal_base1(s) { + : _signal_base1(s) { ; } @@ -1984,7 +2004,7 @@ namespace sigslot { } signal2(const signal2 &s) - : _signal_base2(s) { + : _signal_base2(s) { ; } @@ -1996,8 +2016,7 @@ namespace sigslot { void connect(desttype *pclass, void (desttype::*pmemfun)(arg1_type, arg2_type)) { lock_block lock(this); - _connection2 *conn = new - _connection2(pclass, pmemfun); + _connection2 *conn = new _connection2(pclass, pmemfun); this->m_connected_slots.push_back(conn); pclass->signal_connect(this); } @@ -2043,7 +2062,7 @@ namespace sigslot { } signal3(const signal3 &s) - : _signal_base3(s) { + : _signal_base3(s) { ; } @@ -2095,7 +2114,7 @@ namespace sigslot { template class signal4 : public _signal_base4 { + arg4_type, mt_policy> { public: typedef typename _signal_base4::connections_list::const_iterator const_iterator; @@ -2104,7 +2123,7 @@ namespace sigslot { } signal4(const signal4 &s) - : _signal_base4(s) { + : _signal_base4(s) { ; } @@ -2118,7 +2137,7 @@ namespace sigslot { lock_block lock(this); _connection4 * conn = new _connection4(pclass, pmemfun); + arg4_type, mt_policy>(pclass, pmemfun); this->m_connected_slots.push_back(conn); pclass->signal_connect(this); } @@ -2155,9 +2174,9 @@ namespace sigslot { }; template + class arg5_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class signal5 : public _signal_base5 { + arg4_type, arg5_type, mt_policy> { public: typedef typename _signal_base5::connections_list::const_iterator const_iterator; @@ -2166,9 +2185,9 @@ namespace sigslot { } signal5(const signal5 &s) - : _signal_base5(s) { + arg5_type, mt_policy> &s) + : _signal_base5(s) { ; } @@ -2181,8 +2200,8 @@ namespace sigslot { arg2_type, arg3_type, arg4_type, arg5_type)) { lock_block lock(this); _connection5 *conn = new _connection5(pclass, pmemfun); + arg5_type, mt_policy> *conn = new _connection5(pclass, pmemfun); this->m_connected_slots.push_back(conn); pclass->signal_connect(this); } @@ -2222,21 +2241,21 @@ namespace sigslot { template + class arg5_type, class arg6_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class signal6 : public _signal_base6 { + arg4_type, arg5_type, arg6_type, mt_policy> { public: typedef typename _signal_base6::connections_list::const_iterator const_iterator; + arg4_type, arg5_type, arg6_type, mt_policy>::connections_list::const_iterator const_iterator; signal6() { ; } signal6(const signal6 &s) - : _signal_base6(s) { + arg5_type, arg6_type, mt_policy> &s) + : _signal_base6(s) { ; } @@ -2249,9 +2268,9 @@ namespace sigslot { arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) { lock_block lock(this); _connection6 *conn = + arg5_type, arg6_type, mt_policy> *conn = new _connection6(pclass, pmemfun); + arg4_type, arg5_type, arg6_type, mt_policy>(pclass, pmemfun); this->m_connected_slots.push_back(conn); pclass->signal_connect(this); } @@ -2290,21 +2309,21 @@ namespace sigslot { }; template + class arg5_type, class arg6_type, class arg7_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class signal7 : public _signal_base7 { + arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> { public: typedef typename _signal_base7::connections_list::const_iterator const_iterator; + arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>::connections_list::const_iterator const_iterator; signal7() { ; } signal7(const signal7 &s) - : _signal_base7(s) { + arg5_type, arg6_type, arg7_type, mt_policy> &s) + : _signal_base7(s) { ; } @@ -2318,9 +2337,9 @@ namespace sigslot { arg7_type)) { lock_block lock(this); _connection7 *conn = + arg5_type, arg6_type, arg7_type, mt_policy> *conn = new _connection7(pclass, pmemfun); + arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>(pclass, pmemfun); this->m_connected_slots.push_back(conn); pclass->signal_connect(this); } @@ -2359,21 +2378,21 @@ namespace sigslot { }; template + class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class signal8 : public _signal_base8 { + arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> { public: typedef typename _signal_base8::connections_list::const_iterator const_iterator; + arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>::connections_list::const_iterator const_iterator; signal8() { ; } signal8(const signal8 &s) - : _signal_base8(s) { + arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> &s) + : _signal_base8(s) { ; } @@ -2387,10 +2406,10 @@ namespace sigslot { arg7_type, arg8_type)) { lock_block lock(this); _connection8 *conn = + arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> *conn = new _connection8(pclass, pmemfun); + arg4_type, arg5_type, arg6_type, arg7_type, + arg8_type, mt_policy>(pclass, pmemfun); this->m_connected_slots.push_back(conn); pclass->signal_connect(this); } diff --git a/include/gui/sounds/BufferCircle.hpp b/include/gui/sounds/BufferCircle.hpp index de5d7b9..43314f6 100644 --- a/include/gui/sounds/BufferCircle.hpp +++ b/include/gui/sounds/BufferCircle.hpp @@ -26,8 +26,9 @@ #ifndef BUFFER_CIRCLE_HPP_ #define BUFFER_CIRCLE_HPP_ -#include +#include #include +#include class BufferCircle { public: @@ -67,8 +68,11 @@ public: //!> Get a buffer at a position uint8_t *GetBuffer(int32_t pos) { - if (!Valid(pos)) { return NULL; } - else { return SoundBuffer[pos]; } + if (!Valid(pos)) { + return NULL; + } else { + return SoundBuffer[pos]; + } }; //!> Get current buffer size @@ -78,8 +82,11 @@ public: //!> Get buffer size at position uint32_t GetBufferSize(int32_t pos) { - if (!Valid(pos)) { return 0; } - else { return BufferSize[pos]; } + if (!Valid(pos)) { + return 0; + } else { + return BufferSize[pos]; + } }; //!> Is current buffer ready @@ -89,8 +96,11 @@ public: //!> Is a buffer at a position ready bool IsBufferReady(int32_t pos) { - if (!Valid(pos)) { return false; } - else { return BufferReady[pos]; } + if (!Valid(pos)) { + return false; + } else { + return BufferReady[pos]; + } }; //!> Set a buffer at a position to a ready state @@ -110,8 +120,11 @@ public: } inline uint16_t Prev() { - if (Size() == 0) { return 0; } - else { return ((int32_t) which - 1 < 0) ? Size() - 1 : which - 1; } + if (Size() == 0) { + return 0; + } else { + return ((int32_t) which - 1 < 0) ? Size() - 1 : which - 1; + } } protected: diff --git a/include/gui/sounds/SoundDecoder.hpp b/include/gui/sounds/SoundDecoder.hpp index 42115f4..17ca2af 100644 --- a/include/gui/sounds/SoundDecoder.hpp +++ b/include/gui/sounds/SoundDecoder.hpp @@ -26,9 +26,9 @@ #ifndef SOUND_DECODER_HPP #define SOUND_DECODER_HPP -#include -#include #include +#include +#include class CFile; @@ -91,7 +91,7 @@ public: } virtual void SetLoop(bool l) { - Loop = l; + Loop = l; EndOfFile = false; } @@ -119,12 +119,12 @@ public: void EnableUpsample(void); enum SoundFormats { - FORMAT_PCM_16_BIT = 0x0A, - FORMAT_PCM_8_BIT = 0x19, + FORMAT_PCM_16_BIT = 0x0A, + FORMAT_PCM_8_BIT = 0x19, }; enum SoundChannels { - CHANNELS_MONO = 0x100, - CHANNELS_STEREO = 0x200 + CHANNELS_MONO = 0x100, + CHANNELS_STEREO = 0x200 }; enum SoundType { @@ -133,6 +133,7 @@ public: SOUND_OGG, SOUND_WAV }; + protected: void Init(); diff --git a/include/gui/sounds/SoundHandler.hpp b/include/gui/sounds/SoundHandler.hpp index dcdff15..504494e 100644 --- a/include/gui/sounds/SoundHandler.hpp +++ b/include/gui/sounds/SoundHandler.hpp @@ -28,12 +28,12 @@ #include -#include #include #include +#include #include -#define MAX_DECODERS 16 // can be increased up to 96 +#define MAX_DECODERS 16 // can be increased up to 96 class SoundHandler : public CThread { public: @@ -70,6 +70,7 @@ public: bool IsDecoding() { return Decoding; }; + protected: SoundHandler(); diff --git a/include/gui/sounds/Voice.h b/include/gui/sounds/Voice.h index 3f7414d..56a9b45 100644 --- a/include/gui/sounds/Voice.h +++ b/include/gui/sounds/Voice.h @@ -17,12 +17,11 @@ #ifndef _AXSOUND_H_ #define _AXSOUND_H_ -#include #include +#include class Voice { public: - enum VoicePriorities { PRIO_MIN = 1, PRIO_MAX = 31 @@ -36,9 +35,9 @@ public: }; Voice(int32_t prio) - : state(STATE_STOPPED) { + : state(STATE_STOPPED) { lastLoopCounter = 0; - nextBufferSize = 0; + nextBufferSize = 0; voice = AXAcquireVoice(prio, 0, 0); if (voice) { @@ -50,9 +49,9 @@ public: AXVoiceDeviceMixData mix[6]; memset(mix, 0, sizeof(mix)); mix[0].bus[0].volume = 0x8000; - mix[0].bus[0].delta = 0; + mix[0].bus[0].delta = 0; mix[1].bus[0].volume = 0x8000; - mix[1].bus[0].delta = 0; + mix[1].bus[0].delta = 0; AXSetVoiceDeviceMix(voice, 0, 0, mix); AXSetVoiceDeviceMix(voice, 1, 0, mix); @@ -74,13 +73,13 @@ public: memset(&voiceBuffer, 0, sizeof(voiceBuffer)); - voiceBuffer.data = buffer; - voiceBuffer.dataType = format; + voiceBuffer.data = buffer; + voiceBuffer.dataType = format; voiceBuffer.loopingEnabled = (nextBuffer == NULL) ? 0 : 1; - voiceBuffer.currentOffset = 0; - voiceBuffer.endOffset = (bufferSize >> 1) - 1; - voiceBuffer.loopOffset = ((nextBuffer - buffer) >> 1); - nextBufferSize = nextBufSize; + voiceBuffer.currentOffset = 0; + voiceBuffer.endOffset = (bufferSize >> 1) - 1; + voiceBuffer.loopOffset = ((nextBuffer - buffer) >> 1); + nextBufferSize = nextBufSize; // TODO: handle support for 3.1.0 with dynamic libs instead of static linking it //uint32_t samplesPerSec = (AXGetInputSamplesPerSec != 0) ? AXGetInputSamplesPerSec() : 32000; @@ -105,7 +104,7 @@ public: if (voice) { AXVoiceVeData data; data.volume = vol >> 16; - data.delta = vol & 0xFFFF; + data.delta = vol & 0xFFFF; AXSetVoiceVe(voice, &data); } } @@ -113,7 +112,7 @@ public: void setNextBuffer(const uint8_t *buffer, uint32_t bufferSize) { voiceBuffer.loopOffset = ((buffer - (const uint8_t *) voiceBuffer.data) >> 1); - nextBufferSize = bufferSize; + nextBufferSize = bufferSize; AXSetVoiceLoopOffset(voice, voiceBuffer.loopOffset); } diff --git a/include/gui/system/CThread.h b/include/gui/system/CThread.h index b556d53..d1b9acb 100644 --- a/include/gui/system/CThread.h +++ b/include/gui/system/CThread.h @@ -17,9 +17,9 @@ #ifndef CTHREAD_H_ #define CTHREAD_H_ +#include #include #include -#include class CThread { public: @@ -27,7 +27,7 @@ public: //! constructor CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL) - : pThread(NULL), pThreadStack(NULL), pCallback(callback), pCallbackArg(callbackArg) { + : pThread(NULL), pThreadStack(NULL), pCallback(callback), pCallbackArg(callbackArg) { //! save attribute assignment iAttributes = iAttr; //! allocate the thread @@ -127,19 +127,20 @@ public: free(pThread); } - pThread = NULL; + pThread = NULL; pThreadStack = NULL; } //! Thread attributes enum eCThreadAttributes { - eAttributeNone = 0x07, - eAttributeAffCore0 = 0x01, - eAttributeAffCore1 = 0x02, - eAttributeAffCore2 = 0x04, - eAttributeDetach = 0x08, - eAttributePinnedAff = 0x10 + eAttributeNone = 0x07, + eAttributeAffCore0 = 0x01, + eAttributeAffCore1 = 0x02, + eAttributeAffCore2 = 0x04, + eAttributeDetach = 0x08, + eAttributePinnedAff = 0x10 }; + private: static int32_t threadCallback(int32_t argc, const char **argv) { //! After call to start() continue with the internal function diff --git a/include/gui/video/CVideo.h b/include/gui/video/CVideo.h index 2964e25..3347015 100644 --- a/include/gui/video/CVideo.h +++ b/include/gui/video/CVideo.h @@ -17,16 +17,16 @@ #ifndef __CVIDEO_H_ #define __CVIDEO_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -38,15 +38,15 @@ public: void prepareTvRendering(void) { currContextState = tvContextState; - currColorBuffer = &tvColorBuffer; - currDepthBuffer = &tvDepthBuffer; + currColorBuffer = &tvColorBuffer; + currDepthBuffer = &tvDepthBuffer; prepareRendering(); } void prepareDrcRendering(void) { currContextState = drcContextState; - currColorBuffer = &drcColorBuffer; - currDepthBuffer = &drcDepthBuffer; + currColorBuffer = &drcColorBuffer; + currDepthBuffer = &drcDepthBuffer; prepareRendering(); } @@ -156,7 +156,7 @@ public: glm::vec4 rayStart(posX, posY, 0.0f, 1.0f); glm::vec4 rayEnd(posX, posY, 1.0f, 1.0f); - glm::mat4 IMV = glm::inverse(projectionMtx * viewMtx); + glm::mat4 IMV = glm::inverse(projectionMtx * viewMtx); glm::vec4 rayStartWorld = IMV * rayStart; rayStartWorld /= rayStartWorld.w; @@ -166,7 +166,7 @@ public: glm::vec3 rayDirectionWorld(rayEndWorld - rayStartWorld); rayDirectionWorld = glm::normalize(rayDirectionWorld); - rayOrigin = glm::vec3(rayStartWorld); + rayOrigin = glm::vec3(rayStartWorld); rayDirection = glm::normalize(rayDirectionWorld); } diff --git a/include/gui/video/CursorDrawer.h b/include/gui/video/CursorDrawer.h index 6290cd1..9cced4f 100644 --- a/include/gui/video/CursorDrawer.h +++ b/include/gui/video/CursorDrawer.h @@ -19,8 +19,8 @@ #include -#include #include +#include class CursorDrawer { diff --git a/include/gui/video/shaders/ColorShader.h b/include/gui/video/shaders/ColorShader.h index 0ab77e4..e545405 100644 --- a/include/gui/video/shaders/ColorShader.h +++ b/include/gui/video/shaders/ColorShader.h @@ -17,9 +17,9 @@ #ifndef __COLOR_SHADER_H_ #define __COLOR_SHADER_H_ -#include -#include #include +#include +#include class ColorShader : public Shader { private: @@ -27,7 +27,7 @@ private: virtual ~ColorShader(); - static const uint32_t cuAttributeCount = 2; + static const uint32_t cuAttributeCount = 2; static const uint32_t cuPositionVtxsSize = 4 * cuVertexAttrSize; static ColorShader *shaderInstance; @@ -44,6 +44,7 @@ private: uint32_t colorLocation; uint32_t colorIntensityLocation; uint32_t positionLocation; + public: static const uint32_t cuColorVtxsSize = 4 * cuColorAttrSize; diff --git a/include/gui/video/shaders/FXAAShader.h b/include/gui/video/shaders/FXAAShader.h index 9fbbab6..218ca4a 100644 --- a/include/gui/video/shaders/FXAAShader.h +++ b/include/gui/video/shaders/FXAAShader.h @@ -17,9 +17,9 @@ #ifndef __FXAA_SHADER_H_ #define __FXAA_SHADER_H_ -#include -#include #include +#include +#include class FXAAShader : public Shader { public: @@ -62,8 +62,8 @@ private: virtual ~FXAAShader(); - static const uint32_t cuAttributeCount = 2; - static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize; + static const uint32_t cuAttributeCount = 2; + static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize; static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize; static FXAAShader *shaderInstance; diff --git a/include/gui/video/shaders/FetchShader.h b/include/gui/video/shaders/FetchShader.h index 0cf8f3d..bdb2e1f 100644 --- a/include/gui/video/shaders/FetchShader.h +++ b/include/gui/video/shaders/FetchShader.h @@ -22,7 +22,7 @@ class FetchShader : public Shader { public: FetchShader(GX2AttribStream *attributes, uint32_t attrCount, GX2FetchShaderType type = GX2_FETCH_SHADER_TESSELLATION_NONE, GX2TessellationMode tess = GX2_TESSELLATION_MODE_DISCRETE) - : fetchShader(NULL), fetchShaderProgramm(NULL) { + : fetchShader(NULL), fetchShaderProgramm(NULL) { uint32_t shaderSize = GX2CalcFetchShaderSizeEx(attrCount, type, tess); fetchShaderProgramm = (uint8_t *) memalign(GX2_SHADER_PROGRAM_ALIGNMENT, shaderSize); if (fetchShaderProgramm) { diff --git a/include/gui/video/shaders/PixelShader.h b/include/gui/video/shaders/PixelShader.h index c906a62..dcd448a 100644 --- a/include/gui/video/shaders/PixelShader.h +++ b/include/gui/video/shaders/PixelShader.h @@ -22,7 +22,7 @@ class PixelShader : public Shader { public: PixelShader() - : pixelShader((GX2PixelShader *) memalign(0x40, sizeof(GX2PixelShader))) { + : pixelShader((GX2PixelShader *) memalign(0x40, sizeof(GX2PixelShader))) { if (pixelShader) { memset(pixelShader, 0, sizeof(GX2PixelShader)); pixelShader->mode = GX2_SHADER_MODE_UNIFORM_REGISTER; @@ -77,7 +77,7 @@ public: } //! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100 - pixelShader->size = programSize; + pixelShader->size = programSize; pixelShader->program = (uint8_t *) memalign(GX2_SHADER_PROGRAM_ALIGNMENT, pixelShader->size); if (pixelShader->program) { memcpy(pixelShader->program, program, pixelShader->size); diff --git a/include/gui/video/shaders/Shader.h b/include/gui/video/shaders/Shader.h index 64aad24..ffcbcbd 100644 --- a/include/gui/video/shaders/Shader.h +++ b/include/gui/video/shaders/Shader.h @@ -19,11 +19,11 @@ #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include #include class Shader { @@ -33,9 +33,9 @@ protected: virtual ~Shader() {} public: - static const uint16_t cuVertexAttrSize = sizeof(float) * 3; + static const uint16_t cuVertexAttrSize = sizeof(float) * 3; static const uint16_t cuTexCoordAttrSize = sizeof(float) * 2; - static const uint16_t cuColorAttrSize = sizeof(uint8_t) * 4; + static const uint16_t cuColorAttrSize = sizeof(uint8_t) * 4; static void setLineWidth(const float &width) { GX2SetLineWidth(width); diff --git a/include/gui/video/shaders/Shader3D.h b/include/gui/video/shaders/Shader3D.h index 0ca9131..01da804 100644 --- a/include/gui/video/shaders/Shader3D.h +++ b/include/gui/video/shaders/Shader3D.h @@ -17,9 +17,9 @@ #ifndef SHADER_3D_H_ #define SHADER_3D_H_ -#include -#include #include +#include +#include class Shader3D : public Shader { private: @@ -30,8 +30,8 @@ private: static Shader3D *shaderInstance; static const unsigned char cuAttributeCount = 2; - static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize; - static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize; + static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize; + static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize; FetchShader *fetchShader; VertexShader vertexShader; @@ -50,6 +50,7 @@ private: uint32_t fadeDistanceLocation; uint32_t fadeOutLocation; uint32_t samplerLocation; + public: static Shader3D *instance() { if (!shaderInstance) { diff --git a/include/gui/video/shaders/ShaderFractalColor.h b/include/gui/video/shaders/ShaderFractalColor.h index 0a0ff04..4d11721 100644 --- a/include/gui/video/shaders/ShaderFractalColor.h +++ b/include/gui/video/shaders/ShaderFractalColor.h @@ -17,9 +17,9 @@ #ifndef SHADER_FRACTAL_COLOR_H_ #define SHADER_FRACTAL_COLOR_H_ -#include -#include #include +#include +#include class ShaderFractalColor : public Shader { private: @@ -30,9 +30,9 @@ private: static ShaderFractalColor *shaderInstance; static const unsigned char cuAttributeCount = 3; - static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize; - static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize; - static const uint32_t ciColorVtxsSize = 4 * cuColorAttrSize; + static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize; + static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize; + static const uint32_t ciColorVtxsSize = 4 * cuColorAttrSize; FetchShader *fetchShader; VertexShader vertexShader; @@ -53,6 +53,7 @@ private: uint32_t colorIntensityLocation; uint32_t fadeOutLocation; uint32_t fractalLocation; + public: static ShaderFractalColor *instance() { if (!shaderInstance) { diff --git a/include/gui/video/shaders/Texture2DShader.h b/include/gui/video/shaders/Texture2DShader.h index c68857c..ca8db6b 100644 --- a/include/gui/video/shaders/Texture2DShader.h +++ b/include/gui/video/shaders/Texture2DShader.h @@ -17,9 +17,9 @@ #ifndef __TEXTURE_2D_SHADER_H_ #define __TEXTURE_2D_SHADER_H_ -#include -#include #include +#include +#include class Texture2DShader : public Shader { @@ -28,8 +28,8 @@ private: virtual ~Texture2DShader(); - static const uint32_t cuAttributeCount = 2; - static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize; + static const uint32_t cuAttributeCount = 2; + static const uint32_t ciPositionVtxsSize = 4 * cuVertexAttrSize; static const uint32_t ciTexCoordsVtxsSize = 4 * cuTexCoordAttrSize; static Texture2DShader *shaderInstance; @@ -49,6 +49,7 @@ private: uint32_t samplerLocation; uint32_t positionLocation; uint32_t texCoordLocation; + public: static Texture2DShader *instance() { if (!shaderInstance) { diff --git a/include/gui/video/shaders/VertexShader.h b/include/gui/video/shaders/VertexShader.h index 109d619..754bf52 100644 --- a/include/gui/video/shaders/VertexShader.h +++ b/include/gui/video/shaders/VertexShader.h @@ -17,14 +17,14 @@ #ifndef VERTEX_SHADER_H #define VERTEX_SHADER_H -#include -#include #include +#include +#include class VertexShader : public Shader { public: VertexShader(uint32_t numAttr) - : attributesCount(numAttr), attributes(new GX2AttribStream[attributesCount]), vertexShader((GX2VertexShader *) memalign(0x40, sizeof(GX2VertexShader))) { + : attributesCount(numAttr), attributes(new GX2AttribStream[attributesCount]), vertexShader((GX2VertexShader *) memalign(0x40, sizeof(GX2VertexShader))) { if (vertexShader) { memset(vertexShader, 0, sizeof(GX2VertexShader)); vertexShader->mode = GX2_SHADER_MODE_UNIFORM_REGISTER; @@ -89,7 +89,7 @@ public: } //! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100 - vertexShader->size = programSize; + vertexShader->size = programSize; vertexShader->program = (uint8_t *) memalign(GX2_SHADER_PROGRAM_ALIGNMENT, vertexShader->size); if (vertexShader->program) { memcpy(vertexShader->program, program, vertexShader->size); diff --git a/source/fs/CFile.cpp b/source/fs/CFile.cpp index b8b3dff..16fa2f2 100644 --- a/source/fs/CFile.cpp +++ b/source/fs/CFile.cpp @@ -1,15 +1,15 @@ -#include -#include -#include -#include #include +#include +#include +#include +#include CFile::CFile() { - iFd = -1; + iFd = -1; mem_file = NULL; filesize = 0; - pos = 0; + pos = 0; } CFile::CFile(const std::string &filepath, eOpenTypes mode) { @@ -35,7 +35,7 @@ int32_t CFile::open(const std::string &filepath, eOpenTypes mode) { switch (mode) { default: - case ReadOnly: // file must exist + case ReadOnly: // file must exist openMode = O_RDONLY; break; case WriteOnly: // file will be created / zerod @@ -79,10 +79,10 @@ void CFile::close() { ::close(iFd); } - iFd = -1; + iFd = -1; mem_file = NULL; filesize = 0; - pos = 0; + pos = 0; } int32_t CFile::read(uint8_t *ptr, size_t size) { @@ -133,7 +133,7 @@ int32_t CFile::write(const uint8_t *ptr, size_t size) { } int32_t CFile::seek(long int offset, int32_t origin) { - int32_t ret = 0; + int32_t ret = 0; int64_t newPos = pos; if (origin == SEEK_SET) { @@ -165,7 +165,7 @@ int32_t CFile::seek(long int offset, int32_t origin) { int32_t CFile::fwrite(const char *format, ...) { char tmp[512]; - tmp[0] = 0; + tmp[0] = 0; int32_t result = -1; va_list va; @@ -178,5 +178,3 @@ int32_t CFile::fwrite(const char *format, ...) { return result; } - - diff --git a/source/fs/CFile.hpp b/source/fs/CFile.hpp index 9572b7c..0fd8944 100644 --- a/source/fs/CFile.hpp +++ b/source/fs/CFile.hpp @@ -1,10 +1,10 @@ #ifndef CFILE_HPP_ #define CFILE_HPP_ -#include -#include -#include #include +#include +#include +#include #include #include diff --git a/source/gui/FreeTypeGX.cpp b/source/gui/FreeTypeGX.cpp index fcdef55..a6ee2af 100644 --- a/source/gui/FreeTypeGX.cpp +++ b/source/gui/FreeTypeGX.cpp @@ -75,8 +75,8 @@ FreeTypeGX::~FreeTypeGX() { wchar_t *FreeTypeGX::charToWideChar(const char *strChar) { if (!strChar) { return NULL; } - size_t len = strlen(strChar) + 1; - wchar_t *strWChar = new(std::nothrow) wchar_t[len]; + size_t len = strlen(strChar) + 1; + wchar_t *strWChar = new (std::nothrow) wchar_t[len]; if (!strWChar) { return NULL; } size_t bt = mbstowcs(strWChar, strChar, len); @@ -112,7 +112,7 @@ char *FreeTypeGX::wideCharToUTF8(const wchar_t *strChar) { } } - char *pOut = new(std::nothrow) char[len]; + char *pOut = new (std::nothrow) char[len]; if (!pOut) { return NULL; } @@ -194,7 +194,7 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) { FT_Set_Pixel_Sizes(ftFace, 0, pixelSize); - ftData->ftgxAlign.ascender = (int16_t) ftFace->size->metrics.ascender >> 6; + ftData->ftgxAlign.ascender = (int16_t) ftFace->size->metrics.ascender >> 6; ftData->ftgxAlign.descender = (int16_t) ftFace->size->metrics.descender >> 6; FT_UInt gIndex; @@ -205,7 +205,7 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) { if (ftFace->glyph->format == FT_GLYPH_FORMAT_BITMAP) { FT_Bitmap *glyphBitmap = &ftFace->glyph->bitmap; - textureWidth = ALIGN4(glyphBitmap->width); + textureWidth = ALIGN4(glyphBitmap->width); textureHeight = ALIGN4(glyphBitmap->rows); if (textureWidth == 0) { textureWidth = 4; @@ -214,19 +214,19 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) { textureHeight = 4; } - ftgxCharData *charData = &ftData->ftgxCharMap[charCode]; - charData->renderOffsetX = (int16_t) ftFace->glyph->bitmap_left; - charData->glyphAdvanceX = (uint16_t) (ftFace->glyph->advance.x >> 6); - charData->glyphAdvanceY = (uint16_t) (ftFace->glyph->advance.y >> 6); - charData->glyphIndex = (uint32_t) gIndex; - charData->renderOffsetY = (int16_t) ftFace->glyph->bitmap_top; + ftgxCharData *charData = &ftData->ftgxCharMap[charCode]; + charData->renderOffsetX = (int16_t) ftFace->glyph->bitmap_left; + charData->glyphAdvanceX = (uint16_t) (ftFace->glyph->advance.x >> 6); + charData->glyphAdvanceY = (uint16_t) (ftFace->glyph->advance.y >> 6); + charData->glyphIndex = (uint32_t) gIndex; + charData->renderOffsetY = (int16_t) ftFace->glyph->bitmap_top; charData->renderOffsetMax = (int16_t) ftFace->glyph->bitmap_top; charData->renderOffsetMin = (int16_t) glyphBitmap->rows - ftFace->glyph->bitmap_top; - int16_t oldMax = ftData->ftgxAlign.max; + int16_t oldMax = ftData->ftgxAlign.max; ftData->ftgxAlign.max = charData->renderOffsetMax > oldMax ? charData->renderOffsetMax : oldMax; - int16_t oldMin = ftData->ftgxAlign.min; + int16_t oldMin = ftData->ftgxAlign.min; ftData->ftgxAlign.min = charData->renderOffsetMin > oldMin ? charData->renderOffsetMin : oldMin; //! Initialize texture @@ -290,13 +290,13 @@ bool FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) { memset(charData->texture->surface.image, 0x00, charData->texture->surface.imageSize); - uint8_t *src = (uint8_t *) bmp->buffer; + uint8_t *src = (uint8_t *) bmp->buffer; uint16_t *dst = (uint16_t *) charData->texture->surface.image; uint32_t x, y; for (y = 0; y < bmp->rows; y++) { for (x = 0; x < bmp->width; x++) { - uint8_t intensity = src[y * bmp->width + x] >> 3; + uint8_t intensity = src[y * bmp->width + x] >> 3; dst[y * charData->texture->surface.pitch + x] = intensity ? ((intensity << 11) | (intensity << 6) | (intensity << 1) | 1) : 0; } } @@ -317,7 +317,9 @@ int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) { return 0; } else if (format & FTGX_JUSTIFY_CENTER) { return -(width >> 1); - } else if (format & FTGX_JUSTIFY_RIGHT) { return -width; } + } else if (format & FTGX_JUSTIFY_RIGHT) { + return -width; + } return 0; } @@ -434,7 +436,7 @@ uint16_t FreeTypeGX::getWidth(const wchar_t *text, int16_t pixelSize) { if (!text) { return 0; } uint16_t strWidth = 0; - int32_t i = 0; + int32_t i = 0; while (text[i]) { strWidth += getCharWidth(text[i], pixelSize, i > 0 ? text[i - 1] : 0); ++i; @@ -446,7 +448,7 @@ uint16_t FreeTypeGX::getWidth(const wchar_t *text, int16_t pixelSize) { * Single char width */ uint16_t FreeTypeGX::getCharWidth(const wchar_t wChar, int16_t pixelSize, const wchar_t prevChar) { - uint16_t strWidth = 0; + uint16_t strWidth = 0; ftgxCharData *glyphData = cacheGlyphData(wChar, pixelSize); if (glyphData != NULL) { @@ -510,12 +512,12 @@ uint16_t FreeTypeGX::getHeight(const wchar_t *text, int16_t pixelSize) { void FreeTypeGX::copyTextureToFramebuffer(CVideo *pVideo, GX2Texture *texture, int16_t x, int16_t y, int16_t z, const glm::vec4 &color, const float &defaultBlur, const float &blurIntensity, const glm::vec4 &blurColor, const float &superSamplingScale) { static const float imageAngle = 0.0f; - static const float blurScale = (2.0f); + static const float blurScale = (2.0f); float offsetLeft = blurScale * (1.0f / superSamplingScale) * ((float) x + 0.5f * (float) texture->surface.width) * (float) pVideo->getWidthScaleFactor(); - float offsetTop = blurScale * (1.0f / superSamplingScale) * ((float) y - 0.5f * (float) texture->surface.height) * (float) pVideo->getHeightScaleFactor(); + float offsetTop = blurScale * (1.0f / superSamplingScale) * ((float) y - 0.5f * (float) texture->surface.height) * (float) pVideo->getHeightScaleFactor(); - float widthScale = blurScale * (1.0f / superSamplingScale) * (float) texture->surface.width * pVideo->getWidthScaleFactor(); + float widthScale = blurScale * (1.0f / superSamplingScale) * (float) texture->surface.width * pVideo->getWidthScaleFactor(); float heightScale = blurScale * (1.0f / superSamplingScale) * (float) texture->surface.height * pVideo->getHeightScaleFactor(); glm::vec3 positionOffsets(offsetLeft, offsetTop, (float) z); diff --git a/source/gui/GameBgImage.cpp b/source/gui/GameBgImage.cpp index 483fee8..c6eac22 100644 --- a/source/gui/GameBgImage.cpp +++ b/source/gui/GameBgImage.cpp @@ -3,8 +3,8 @@ #include GameBgImage::GameBgImage(const std::string &filename, GuiImageData *preloadImage) - : GuiImageAsync(filename, preloadImage) { - identity = glm::mat4(1.0f); + : GuiImageAsync(filename, preloadImage) { + identity = glm::mat4(1.0f); alphaFadeOut = glm::vec4(1.0f, 0.075f, 5.305f, 2.0f); } @@ -17,15 +17,15 @@ void GameBgImage::draw(CVideo *pVideo) { } //! first setup 2D GUI positions - float currPosX = getCenterX(); - float currPosY = getCenterY(); - float currPosZ = getDepth(); + float currPosX = getCenterX(); + float currPosY = getCenterY(); + float currPosZ = getDepth(); float currScaleX = getScaleX() * (float) getWidth() * pVideo->getWidthScaleFactor(); float currScaleY = getScaleY() * (float) getHeight() * pVideo->getHeightScaleFactor(); float currScaleZ = getScaleZ() * (float) getWidth() * pVideo->getDepthScaleFactor(); glm::mat4 m_modelView = glm::translate(identity, glm::vec3(currPosX, currPosY, currPosZ)); - m_modelView = glm::scale(m_modelView, glm::vec3(currScaleX, currScaleY, currScaleZ)); + m_modelView = glm::scale(m_modelView, glm::vec3(currScaleX, currScaleY, currScaleZ)); Shader3D::instance()->setShaders(); Shader3D::instance()->setProjectionMtx(identity); diff --git a/source/gui/GridBackground.cpp b/source/gui/GridBackground.cpp index 6e2da42..942d4af 100644 --- a/source/gui/GridBackground.cpp +++ b/source/gui/GridBackground.cpp @@ -1,25 +1,25 @@ +#include "utils/utils.h" #include #include #include -#include "utils/utils.h" -static const float bgRepeat = 1000.0f; +static const float bgRepeat = 1000.0f; static const float bgTexRotate = 39.0f; GridBackground::GridBackground(GuiImageData *img) - : GuiImage(img) { - colorIntensity = glm::vec4(1.0f, 1.0f, 1.0f, 0.9f); - alphaFadeOut = glm::vec4(0.0f); + : GuiImage(img) { + colorIntensity = glm::vec4(1.0f, 1.0f, 1.0f, 0.9f); + alphaFadeOut = glm::vec4(0.0f); distanceFadeOut = 0.15f; vtxCount = 4; //! texture and vertex coordinates - float *m_posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, vtxCount * Shader3D::cuVertexAttrSize); + float *m_posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, vtxCount * Shader3D::cuVertexAttrSize); float *m_texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, vtxCount * Shader3D::cuTexCoordAttrSize); if (m_posVtxs) { - int32_t i = 0; + int32_t i = 0; m_posVtxs[i++] = -1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = 1.0f; @@ -49,13 +49,11 @@ GridBackground::GridBackground(GuiImageData *img) const float cosRot = cosf(DegToRad(bgTexRotate)); const float sinRot = sinf(DegToRad(bgTexRotate)); - glm::mat2 texRotateMtx({ - cosRot, -sinRot, - sinRot, cosRot - }); + glm::mat2 texRotateMtx({cosRot, -sinRot, + sinRot, cosRot}); for (int32_t i = 0; i < 4; i++) { - texCoordVec[i] = texRotateMtx * texCoordVec[i]; + texCoordVec[i] = texRotateMtx * texCoordVec[i]; m_texCoords[i * 2 + 0] = texCoordVec[i][0]; m_texCoords[i * 2 + 1] = texCoordVec[i][1]; } @@ -64,7 +62,7 @@ GridBackground::GridBackground(GuiImageData *img) } //! assign to internal variables which are const but oh well - posVtxs = m_posVtxs; + posVtxs = m_posVtxs; texCoords = m_texCoords; } diff --git a/source/gui/GuiButton.cpp b/source/gui/GuiButton.cpp index a541ae6..a658af5 100644 --- a/source/gui/GuiButton.cpp +++ b/source/gui/GuiButton.cpp @@ -15,41 +15,41 @@ * along with this program. If not, see . ****************************************************************************/ #include -#include #include +#include /** * Constructor for the GuiButton class. */ GuiButton::GuiButton(float w, float h) { - width = w; - height = h; - image = NULL; - imageOver = NULL; - imageHold = NULL; + width = w; + height = h; + image = NULL; + imageOver = NULL; + imageHold = NULL; imageClick = NULL; - icon = NULL; - iconOver = NULL; + icon = NULL; + iconOver = NULL; for (int32_t i = 0; i < 4; i++) { - label[i] = NULL; - labelOver[i] = NULL; - labelHold[i] = NULL; + label[i] = NULL; + labelOver[i] = NULL; + labelHold[i] = NULL; labelClick[i] = NULL; } for (int32_t i = 0; i < iMaxGuiTriggers; i++) { trigger[i] = NULL; } - soundOver = NULL; - soundHold = NULL; - soundClick = NULL; + soundOver = NULL; + soundHold = NULL; + soundClick = NULL; clickedTrigger = NULL; - heldTrigger = NULL; - selectable = true; - holdable = false; - clickable = true; + heldTrigger = NULL; + selectable = true; + holdable = false; + clickable = true; } /** @@ -135,7 +135,7 @@ void GuiButton::setTrigger(GuiTrigger *t, int32_t idx) { void GuiButton::resetState(void) { clickedTrigger = NULL; - heldTrigger = NULL; + heldTrigger = NULL; GuiElement::resetState(); } @@ -193,7 +193,7 @@ void GuiButton::update(GuiController *c) { if (effectsOver && !effects) { // initiate effects - effects = effectsOver; + effects = effectsOver; effectAmount = effectAmountOver; effectTarget = effectTargetOver; } @@ -206,7 +206,7 @@ void GuiButton::update(GuiController *c) { if (effectTarget == effectTargetOver && effectAmount == effectAmountOver) { // initiate effects (in reverse) - effects = effectsOver; + effects = effectsOver; effectAmount = -effectAmountOver; effectTarget = 100; } @@ -223,8 +223,7 @@ void GuiButton::update(GuiController *c) { int32_t isClicked = trigger[i]->clicked(c); - if (!clickedTrigger && (isClicked != GuiTrigger::CLICKED_NONE) - && (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) { + if (!clickedTrigger && (isClicked != GuiTrigger::CLICKED_NONE) && (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) { if (soundClick) { soundClick->Play(); } @@ -253,8 +252,7 @@ void GuiButton::update(GuiController *c) { if (holdable) { bool isHeld = trigger[i]->held(c); - if ((!heldTrigger || heldTrigger == trigger[i]) && isHeld - && (trigger[i]->isHoldEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) { + if ((!heldTrigger || heldTrigger == trigger[i]) && isHeld && (trigger[i]->isHoldEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) { heldTrigger = trigger[i]; if (!isStateSet(STATE_HELD, c->chanIdx)) { diff --git a/source/gui/GuiCheckBox.cpp b/source/gui/GuiCheckBox.cpp index a4cff67..7bf2981 100644 --- a/source/gui/GuiCheckBox.cpp +++ b/source/gui/GuiCheckBox.cpp @@ -23,7 +23,7 @@ */ GuiCheckBox::GuiCheckBox(GuiImage *background, bool checked, float width, float height) - : GuiToggle(checked, width, height) { + : GuiToggle(checked, width, height) { setImageBackground(background); } @@ -31,7 +31,6 @@ GuiCheckBox::GuiCheckBox(GuiImage *background, bool checked, float width, float * Destructor for the GuiCheckBox class. */ GuiCheckBox::~GuiCheckBox() { - } void GuiCheckBox::setImageBackground(GuiImage *img) { diff --git a/source/gui/GuiDragListener.cpp b/source/gui/GuiDragListener.cpp index 8edec01..f52516c 100644 --- a/source/gui/GuiDragListener.cpp +++ b/source/gui/GuiDragListener.cpp @@ -15,15 +15,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#include #include +#include /** * Constructor for the GuiDragListener class. */ GuiDragListener::GuiDragListener(float w, float h) { - width = w; + width = w; height = h; for (int32_t i = 0; i < iMaxGuiTriggers; i++) { trigger[i] = NULL; diff --git a/source/gui/GuiElement.cpp b/source/gui/GuiElement.cpp index 7f445eb..16847ab 100644 --- a/source/gui/GuiElement.cpp +++ b/source/gui/GuiElement.cpp @@ -17,7 +17,7 @@ #include //! TODO remove this! -static int32_t screenwidth = 1280; +static int32_t screenwidth = 1280; static int32_t screenheight = 720; /** @@ -27,34 +27,34 @@ GuiElement::GuiElement() { xoffset = 0.0f; yoffset = 0.0f; zoffset = 0.0f; - width = 0.0f; - height = 0.0f; - alpha = 1.0f; - scaleX = 1.0f; - scaleY = 1.0f; - scaleZ = 1.0f; + width = 0.0f; + height = 0.0f; + alpha = 1.0f; + scaleX = 1.0f; + scaleY = 1.0f; + scaleZ = 1.0f; for (int32_t i = 0; i < 5; i++) { state[i] = STATE_DEFAULT; } - stateChan = -1; - parentElement = NULL; - rumble = true; - selectable = false; - clickable = false; - holdable = false; + stateChan = -1; + parentElement = NULL; + rumble = true; + selectable = false; + clickable = false; + holdable = false; drawOverOnlyWhenSelected = false; - visible = true; - yoffsetDyn = 0; - xoffsetDyn = 0; - alphaDyn = -1; - scaleDyn = 1; - effects = EFFECT_NONE; - effectAmount = 0; - effectTarget = 0; - effectsOver = EFFECT_NONE; - effectAmountOver = 0; - effectTargetOver = 0; - angle = 0.0f; + visible = true; + yoffsetDyn = 0; + xoffsetDyn = 0; + alphaDyn = -1; + scaleDyn = 1; + effects = EFFECT_NONE; + effectAmount = 0; + effectTarget = 0; + effectsOver = EFFECT_NONE; + effectAmountOver = 0; + effectTargetOver = 0; + angle = 0.0f; // default alignment - align to top left alignment = (ALIGN_CENTER | ALIGN_MIDDLE); @@ -66,13 +66,13 @@ GuiElement::GuiElement() { * @return Left position in pixel. */ float GuiElement::getLeft() { - float pWidth = 0; - float pLeft = 0; + float pWidth = 0; + float pLeft = 0; float pScaleX = 1.0f; if (parentElement) { - pWidth = parentElement->getWidth(); - pLeft = parentElement->getLeft(); + pWidth = parentElement->getWidth(); + pLeft = parentElement->getLeft(); pScaleX = parentElement->getScaleX(); } @@ -97,12 +97,12 @@ float GuiElement::getLeft() { */ float GuiElement::getTop() { float pHeight = 0; - float pTop = 0; + float pTop = 0; float pScaleY = 1.0f; if (parentElement) { pHeight = parentElement->getHeight(); - pTop = parentElement->getTop(); + pTop = parentElement->getTop(); pScaleY = parentElement->getScaleY(); } @@ -170,14 +170,14 @@ void GuiElement::setEffectOnOver(int32_t e, int32_t a, int32_t t) { } void GuiElement::resetEffects() { - yoffsetDyn = 0; - xoffsetDyn = 0; - alphaDyn = -1; - scaleDyn = 1; - effects = EFFECT_NONE; - effectAmount = 0; - effectTarget = 0; - effectsOver = EFFECT_NONE; + yoffsetDyn = 0; + xoffsetDyn = 0; + alphaDyn = -1; + scaleDyn = 1; + effects = EFFECT_NONE; + effectAmount = 0; + effectTarget = 0; + effectsOver = EFFECT_NONE; effectAmountOver = 0; effectTargetOver = 0; } @@ -194,7 +194,7 @@ void GuiElement::updateEffects() { if (xoffsetDyn >= 0) { xoffsetDyn = 0; - effects = 0; + effects = 0; effectFinished(this); } } else if (effects & EFFECT_SLIDE_RIGHT) { @@ -202,7 +202,7 @@ void GuiElement::updateEffects() { if (xoffsetDyn <= 0) { xoffsetDyn = 0; - effects = 0; + effects = 0; effectFinished(this); } } else if (effects & EFFECT_SLIDE_TOP) { @@ -210,7 +210,7 @@ void GuiElement::updateEffects() { if (yoffsetDyn >= 0) { yoffsetDyn = 0; - effects = 0; + effects = 0; effectFinished(this); } } else if (effects & EFFECT_SLIDE_BOTTOM) { @@ -218,7 +218,7 @@ void GuiElement::updateEffects() { if (yoffsetDyn <= 0) { yoffsetDyn = 0; - effects = 0; + effects = 0; effectFinished(this); } } @@ -270,20 +270,19 @@ void GuiElement::updateEffects() { if (effectAmount < 0 && alphaDyn <= 0) { alphaDyn = 0; - effects = 0; // shut off effect + effects = 0; // shut off effect effectFinished(this); } else if (effectAmount > 0 && alphaDyn >= alpha) { alphaDyn = alpha; - effects = 0; // shut off effect + effects = 0; // shut off effect effectFinished(this); } } else if (effects & EFFECT_SCALE) { scaleDyn += effectAmount * 0.01f; - if ((effectAmount < 0 && scaleDyn <= (effectTarget * 0.01f)) - || (effectAmount > 0 && scaleDyn >= (effectTarget * 0.01f))) { + if ((effectAmount < 0 && scaleDyn <= (effectTarget * 0.01f)) || (effectAmount > 0 && scaleDyn >= (effectTarget * 0.01f))) { scaleDyn = effectTarget * 0.01f; - effects = 0; // shut off effect + effects = 0; // shut off effect effectFinished(this); } } diff --git a/source/gui/GuiFrame.cpp b/source/gui/GuiFrame.cpp index 5d561cf..ed3b51f 100644 --- a/source/gui/GuiFrame.cpp +++ b/source/gui/GuiFrame.cpp @@ -18,9 +18,9 @@ GuiFrame::GuiFrame(GuiFrame *p) { parent = p; - width = 0; + width = 0; height = 0; - dim = false; + dim = false; if (parent) { parent->append(this); @@ -29,9 +29,9 @@ GuiFrame::GuiFrame(GuiFrame *p) { GuiFrame::GuiFrame(float w, float h, GuiFrame *p) { parent = p; - width = w; + width = w; height = h; - dim = false; + dim = false; if (parent) { parent->append(this); diff --git a/source/gui/GuiImage.cpp b/source/gui/GuiImage.cpp index b5fe6ed..2b725dd 100644 --- a/source/gui/GuiImage.cpp +++ b/source/gui/GuiImage.cpp @@ -14,17 +14,17 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ +#include "utils/utils.h" #include #include -#include #include -#include "utils/utils.h" +#include static const float fPiDiv180 = ((float) M_PI / 180.0f); GuiImage::GuiImage(GuiImageData *img) { if (img && img->getTexture()) { - width = img->getWidth(); + width = img->getWidth(); height = img->getHeight(); } @@ -34,7 +34,7 @@ GuiImage::GuiImage(GuiImageData *img) { GuiImage::GuiImage(int32_t w, int32_t h, const GX2Color &c, int32_t type) { internalInit(w, h); - imgType = type; + imgType = type; colorCount = ColorShader::cuColorVtxsSize / ColorShader::cuColorAttrSize; colorVtxs = (uint8_t *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, colorCount * ColorShader::cuColorAttrSize); @@ -47,7 +47,7 @@ GuiImage::GuiImage(int32_t w, int32_t h, const GX2Color &c, int32_t type) { GuiImage::GuiImage(int32_t w, int32_t h, const GX2Color *c, uint32_t color_count, int32_t type) { internalInit(w, h); - imgType = type; + imgType = type; colorCount = ColorShader::cuColorVtxsSize / ColorShader::cuColorAttrSize; if (colorCount < color_count) { colorCount = color_count; @@ -74,33 +74,33 @@ GuiImage::~GuiImage() { } void GuiImage::internalInit(int32_t w, int32_t h) { - imageData = NULL; - width = w; - height = h; + imageData = NULL; + width = w; + height = h; tileHorizontal = -1; - tileVertical = -1; - imgType = IMAGE_TEXTURE; + tileVertical = -1; + imgType = IMAGE_TEXTURE; colorVtxsDirty = false; - colorVtxs = NULL; - colorCount = 0; - posVtxs = NULL; - texCoords = NULL; - vtxCount = 4; - primitive = GX2_PRIMITIVE_MODE_QUADS; + colorVtxs = NULL; + colorCount = 0; + posVtxs = NULL; + texCoords = NULL; + vtxCount = 4; + primitive = GX2_PRIMITIVE_MODE_QUADS; - imageAngle = 0.0f; - blurDirection = glm::vec3(0.0f); + imageAngle = 0.0f; + blurDirection = glm::vec3(0.0f); positionOffsets = glm::vec3(0.0f); - scaleFactor = glm::vec3(1.0f); - colorIntensity = glm::vec4(1.0f); + scaleFactor = glm::vec3(1.0f); + colorIntensity = glm::vec4(1.0f); } void GuiImage::setImageData(GuiImageData *img) { imageData = img; - width = 0; - height = 0; + width = 0; + height = 0; if (img && img->getTexture()) { - width = img->getWidth(); + width = img->getWidth(); height = img->getHeight(); } imgType = IMAGE_TEXTURE; @@ -108,12 +108,11 @@ void GuiImage::setImageData(GuiImageData *img) { GX2Color GuiImage::getPixel(int32_t x, int32_t y) { if (!imageData || this->getWidth() <= 0 || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight()) { - return (GX2Color) { - 0, 0, 0, 0 - }; + return (GX2Color){ + 0, 0, 0, 0}; } - uint32_t pitch = imageData->getTexture()->surface.pitch; + uint32_t pitch = imageData->getTexture()->surface.pitch; uint32_t *imagePtr = (uint32_t *) imageData->getTexture()->surface.image; uint32_t color_u32 = imagePtr[y * pitch + x]; @@ -131,8 +130,8 @@ void GuiImage::setPixel(int32_t x, int32_t y, const GX2Color &color) { } - uint32_t pitch = imageData->getTexture()->surface.pitch; - uint32_t *imagePtr = (uint32_t *) imageData->getTexture()->surface.image; + uint32_t pitch = imageData->getTexture()->surface.pitch; + uint32_t *imagePtr = (uint32_t *) imageData->getTexture()->surface.image; imagePtr[y * pitch + x] = (color.r << 24) | (color.g << 16) | (color.b << 8) | (color.a << 0); } @@ -146,7 +145,7 @@ void GuiImage::setImageColor(const GX2Color &c, int32_t idx) { colorVtxs[(idx << 2) + 1] = c.g; colorVtxs[(idx << 2) + 2] = c.b; colorVtxs[(idx << 2) + 3] = c.a; - colorVtxsDirty = true; + colorVtxsDirty = true; } else if (colorVtxs) { for (uint32_t i = 0; i < (ColorShader::cuColorVtxsSize / sizeof(uint8_t)); i += 4) { colorVtxs[i + 0] = c.r; @@ -159,14 +158,14 @@ void GuiImage::setImageColor(const GX2Color &c, int32_t idx) { } void GuiImage::setSize(int32_t w, int32_t h) { - width = w; + width = w; height = h; } void GuiImage::setPrimitiveVertex(int32_t prim, const float *posVtx, const float *texCoord, uint32_t vtxcount) { primitive = prim; - vtxCount = vtxcount; - posVtxs = posVtx; + vtxCount = vtxcount; + posVtxs = posVtx; texCoords = texCoord; if (imgType == IMAGE_COLOR) { @@ -174,7 +173,7 @@ void GuiImage::setPrimitiveVertex(int32_t prim, const float *posVtx, const float for (uint32_t i = 0; i < vtxCount; i++) { int32_t newColorIdx = (i << 2); - int32_t colorIdx = (i < colorCount) ? (newColorIdx) : ((colorCount - 1) << 2); + int32_t colorIdx = (i < colorCount) ? (newColorIdx) : ((colorCount - 1) << 2); newColorVtxs[newColorIdx + 0] = colorVtxs[colorIdx + 0]; newColorVtxs[newColorIdx + 1] = colorVtxs[colorIdx + 1]; @@ -183,8 +182,8 @@ void GuiImage::setPrimitiveVertex(int32_t prim, const float *posVtx, const float } free(colorVtxs); - colorVtxs = newColorVtxs; - colorCount = vtxCount; + colorVtxs = newColorVtxs; + colorCount = vtxCount; colorVtxsDirty = true; } } @@ -211,38 +210,38 @@ void GuiImage::draw(CVideo *pVideo) { //! angle of the object imageAngle = DegToRad(getAngle()); -// if(image && tileHorizontal > 0 && tileVertical > 0) -// { -// for(int32_t n=0; n 0) -// { -// for(int32_t i=0; i 0) -// { -// for(int32_t i=0; i 0 && tileVertical > 0) + // { + // for(int32_t n=0; n 0) + // { + // for(int32_t i=0; i 0) + // { + // for(int32_t i=0; i. ****************************************************************************/ -#include -#include #include "../fs/CFile.hpp" +#include +#include std::vector GuiImageAsync::imageQueue; -CThread *GuiImageAsync::pThread = NULL; +CThread *GuiImageAsync::pThread = NULL; std::recursive_mutex *GuiImageAsync::pMutex = NULL; -uint32_t GuiImageAsync::threadRefCounter = 0; -bool GuiImageAsync::bExitRequested = false; -GuiImageAsync *GuiImageAsync::pInUse = NULL; +uint32_t GuiImageAsync::threadRefCounter = 0; +bool GuiImageAsync::bExitRequested = false; +GuiImageAsync *GuiImageAsync::pInUse = NULL; GuiImageAsync::GuiImageAsync(const uint8_t *imageBuffer, const uint32_t &imageBufferSize, GuiImageData *preloadImg) - : GuiImage(preloadImg), imgData(NULL), imgBuffer(imageBuffer), imgBufferSize(imageBufferSize) { + : GuiImage(preloadImg), imgData(NULL), imgBuffer(imageBuffer), imgBufferSize(imageBufferSize) { threadInit(); threadAddImage(this); } GuiImageAsync::GuiImageAsync(const std::string &file, GuiImageData *preloadImg) - : GuiImage(preloadImg), imgData(NULL), filename(file), imgBuffer(NULL), imgBufferSize(0) { + : GuiImage(preloadImg), imgData(NULL), filename(file), imgBuffer(NULL), imgBufferSize(0) { threadInit(); threadAddImage(this); } @@ -93,17 +93,17 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) { if (pInUse->imgBuffer && pInUse->imgBufferSize) { pInUse->imgData = new GuiImageData(pInUse->imgBuffer, pInUse->imgBufferSize); } else { - uint8_t *buffer = NULL; + uint8_t *buffer = NULL; uint64_t bufferSize = 0; CFile file(pInUse->filename, CFile::ReadOnly); if (file.isOpen()) { uint64_t filesize = file.size(); - buffer = (uint8_t *) malloc(filesize); + buffer = (uint8_t *) malloc(filesize); if (buffer != NULL) { uint32_t blocksize = 0x4000; - uint32_t done = 0; - int32_t readBytes = 0; + uint32_t done = 0; + int32_t readBytes = 0; while (done < filesize) { if (done + blocksize > filesize) { blocksize = filesize - done; @@ -133,8 +133,8 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) { if (pInUse->imgData) { if (pInUse->imgData->getTexture()) { - pInUse->width = pInUse->imgData->getWidth(); - pInUse->height = pInUse->imgData->getHeight(); + pInUse->width = pInUse->imgData->getWidth(); + pInUse->height = pInUse->imgData->getHeight(); pInUse->imageData = pInUse->imgData; } else { delete pInUse->imgData; @@ -150,8 +150,8 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) { void GuiImageAsync::threadInit() { if (pThread == NULL) { bExitRequested = false; - pMutex = new std::recursive_mutex(); - pThread = CThread::create(GuiImageAsync::guiImageAsyncThread, NULL, CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 10); + pMutex = new std::recursive_mutex(); + pThread = CThread::create(GuiImageAsync::guiImageAsyncThread, NULL, CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 10); pThread->resumeThread(); } @@ -168,6 +168,6 @@ void GuiImageAsync::threadExit() { delete pThread; delete pMutex; pThread = NULL; - pMutex = NULL; + pMutex = NULL; } } diff --git a/source/gui/GuiImageData.cpp b/source/gui/GuiImageData.cpp index 19fb685..08d0756 100644 --- a/source/gui/GuiImageData.cpp +++ b/source/gui/GuiImageData.cpp @@ -14,18 +14,18 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#include -#include -#include #include #include +#include +#include +#include /** * Constructor for the GuiImageData class. */ GuiImageData::GuiImageData() { - texture = NULL; - sampler = NULL; + texture = NULL; + sampler = NULL; memoryType = eMemTypeMEM2; } @@ -90,7 +90,7 @@ void GuiImageData::loadImage(const uint8_t *img, int32_t imgSize, GX2TexClampMod // IMAGE_PNG gdImg = gdImageCreateFromPngPtr(imgSize, (uint8_t *) img); } - //!This must be last since it can also intefere with outher formats + //!This must be last since it can also intefere with outher formats else if (img[0] == 0x00) { // Try loading TGA image gdImg = gdImageCreateFromTgaPtr(imgSize, (uint8_t *) img); @@ -100,7 +100,7 @@ void GuiImageData::loadImage(const uint8_t *img, int32_t imgSize, GX2TexClampMod return; } - uint32_t width = (gdImageSX(gdImg)); + uint32_t width = (gdImageSX(gdImg)); uint32_t height = (gdImageSY(gdImg)); //! Initialize texture @@ -116,16 +116,16 @@ void GuiImageData::loadImage(const uint8_t *img, int32_t imgSize, GX2TexClampMod } //! allocate memory for the surface - memoryType = eMemTypeMEM2; + memoryType = eMemTypeMEM2; texture->surface.image = memalign(texture->surface.alignment, texture->surface.imageSize); //! try MEM1 on failure if (!texture->surface.image) { - memoryType = eMemTypeMEM1; + memoryType = eMemTypeMEM1; texture->surface.image = MEM1_alloc(texture->surface.imageSize, texture->surface.alignment); } //! try MEM bucket on failure if (!texture->surface.image) { - memoryType = eMemTypeMEMBucket; + memoryType = eMemTypeMEMBucket; texture->surface.image = MEMBucket_alloc(texture->surface.imageSize, texture->surface.alignment); } //! check if memory is available for image diff --git a/source/gui/GuiParticleImage.cpp b/source/gui/GuiParticleImage.cpp index 3abfa8e..2cd1b34 100644 --- a/source/gui/GuiParticleImage.cpp +++ b/source/gui/GuiParticleImage.cpp @@ -14,12 +14,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ +#include "utils/utils.h" #include #include #include -#include "utils/utils.h" -#define CIRCLE_VERTEX_COUNT 36 +#define CIRCLE_VERTEX_COUNT 36 static inline float getRandZeroToOneF32() { return (rand() % 10000) * 0.0001f; @@ -30,16 +30,16 @@ static inline float getRandMinusOneToOneF32() { } GuiParticleImage::GuiParticleImage(int32_t w, int32_t h, uint32_t particleCount, float minRadius, float maxRadius, float minSpeed, float maxSpeed) - : GuiImage(NULL) { - width = w; - height = h; - imgType = IMAGE_COLOR; + : GuiImage(NULL) { + width = w; + height = h; + imgType = IMAGE_COLOR; this->minRadius = minRadius; this->maxRadius = maxRadius; - this->minSpeed = minSpeed; - this->maxSpeed = maxSpeed; + this->minSpeed = minSpeed; + this->maxSpeed = maxSpeed; - posVertexs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ColorShader::cuVertexAttrSize * CIRCLE_VERTEX_COUNT); + posVertexs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ColorShader::cuVertexAttrSize * CIRCLE_VERTEX_COUNT); colorVertexs = (uint8_t *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ColorShader::cuColorAttrSize * CIRCLE_VERTEX_COUNT); for (uint32_t i = 0; i < CIRCLE_VERTEX_COUNT; i++) { @@ -61,10 +61,10 @@ GuiParticleImage::GuiParticleImage(int32_t w, int32_t h, uint32_t particleCount, particles[i].position.x = getRandMinusOneToOneF32() * getWidth() * 0.5f; particles[i].position.y = getRandMinusOneToOneF32() * getHeight() * 0.5f; particles[i].position.z = 0.0f; - particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f); - particles[i].radius = getRandZeroToOneF32() * (maxRadius - minRadius) + minRadius; - particles[i].speed = (getRandZeroToOneF32() * (maxSpeed - minSpeed)) + minSpeed; - particles[i].direction = getRandMinusOneToOneF32(); + particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f); + particles[i].radius = getRandZeroToOneF32() * (maxRadius - minRadius) + minRadius; + particles[i].speed = (getRandZeroToOneF32() * (maxSpeed - minSpeed)) + minSpeed; + particles[i].direction = getRandMinusOneToOneF32(); } } @@ -93,10 +93,10 @@ void GuiParticleImage::draw(CVideo *pVideo) { if (particles[i].position.y > (getHeight() * 0.5f + 30.0f)) { particles[i].position.x = getRandMinusOneToOneF32() * getWidth() * 0.5f; particles[i].position.y = -getHeight() * 0.5f - 30.0f; - particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f); - particles[i].radius = getRandZeroToOneF32() * (maxRadius - minRadius) + minRadius; - particles[i].speed = (getRandZeroToOneF32() * (maxSpeed - minSpeed)) + minSpeed; - particles[i].direction = getRandMinusOneToOneF32(); + particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f); + particles[i].radius = getRandZeroToOneF32() * (maxRadius - minRadius) + minRadius; + particles[i].speed = (getRandZeroToOneF32() * (maxSpeed - minSpeed)) + minSpeed; + particles[i].direction = getRandMinusOneToOneF32(); } if (particles[i].position.x < (-getWidth() * 0.5f - 50.0f)) { particles[i].position.x = -particles[i].position.x; diff --git a/source/gui/GuiScrollbar.cpp b/source/gui/GuiScrollbar.cpp index 9000d47..7fb9e44 100644 --- a/source/gui/GuiScrollbar.cpp +++ b/source/gui/GuiScrollbar.cpp @@ -21,14 +21,14 @@ * 3. This notice may not be removed or altered from any source * distribution. ***************************************************************************/ -#include #include "utils/utils.h" +#include GuiScrollbar::GuiScrollbar(int32_t h) - : touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH), wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A) { - SelItem = 0; - SelInd = 0; - PageSize = 0; + : touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH), wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A) { + SelItem = 0; + SelInd = 0; + PageSize = 0; EntrieCount = 0; SetScrollSpeed(15); ScrollState = 0; @@ -133,10 +133,10 @@ void GuiScrollbar::OnBoxButtonHold(GuiButton *button, const GuiController *contr if (newSelected <= 0) { SelItem = 0; - SelInd = 0; + SelInd = 0; } else if (newSelected >= EntrieCount - 1) { SelItem = (PageSize - 1 < EntrieCount - 1) ? PageSize - 1 : EntrieCount - 1; - SelInd = EntrieCount - PageSize; + SelInd = EntrieCount - PageSize; } else if (newSelected < PageSize && SelInd == 0 && diff < 0) { SelItem = std::max(SelItem + diff, (int32_t) 0); } else if (EntrieCount - newSelected < PageSize && SelInd == EntrieCount - PageSize && diff > 0) { @@ -219,4 +219,3 @@ void GuiScrollbar::update(GuiController *t) { ++ScrollState; } - diff --git a/source/gui/GuiSelectBox.cpp b/source/gui/GuiSelectBox.cpp index 425a711..4c94e67 100644 --- a/source/gui/GuiSelectBox.cpp +++ b/source/gui/GuiSelectBox.cpp @@ -14,28 +14,28 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#include #include +#include -#include #include -#include #include +#include +#include /** * Constructor for the GuiCheckBox class. */ GuiSelectBox::GuiSelectBox(GuiImage *background, std::string caption, float width, float height, GuiFrame *parent) - : GuiFrame(width, height, parent), selected(0), captionText(caption), topValueButton(0, 0), touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH), - wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A), buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true), - buttonBTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_B, true), buttonUpTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, true), - buttonDownTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true), DPADButtons(0, 0) { + : GuiFrame(width, height, parent), selected(0), captionText(caption), topValueButton(0, 0), touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH), + wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A), buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true), + buttonBTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_B, true), buttonUpTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, true), + buttonDownTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true), DPADButtons(0, 0) { setImageTopBackground(background); - showValues = false; - bChanged = false; + showValues = false; + bChanged = false; bSelectedChanged = false; - opened = false; + opened = false; topValueText.setFontSize(32); topValueText.setAlignment(ALIGN_LEFT); topValueText.setPosition(10, -7); @@ -58,7 +58,7 @@ GuiSelectBox::GuiSelectBox(GuiImage *background, std::string caption, float widt append(&topValueButton); showValues = false; - bChanged = true; + bChanged = true; } void GuiSelectBox::setSize(float width, float height) { @@ -97,7 +97,7 @@ void GuiSelectBox::OnTopValueClicked(GuiButton *button, const GuiController *con void GuiSelectBox::ShowHideValues(bool showhide) { showValues = showhide; - bChanged = true; + bChanged = true; } void GuiSelectBox::OnDPADClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { @@ -129,7 +129,7 @@ void GuiSelectBox::Init(std::map values, int32_t value valueID = 0; } - selected = valueID; + selected = valueID; bSelectedChanged = true; DeleteValueData(); @@ -140,7 +140,7 @@ void GuiSelectBox::Init(std::map values, int32_t value valueButtons.resize(values.size()); - int32_t i = 0; + int32_t i = 0; float imgScale = 1.0f; std::map::iterator itr; for (itr = values.begin(); itr != values.end(); itr++) { @@ -148,11 +148,11 @@ void GuiSelectBox::Init(std::map values, int32_t value topValueText.setText(itr->first.c_str()); } - valueButtons[i].valueButtonImg = new GuiImage(valueImageData); - valueButtons[i].valueButtonCheckedImg = new GuiImage(valueSelectedImageData); + valueButtons[i].valueButtonImg = new GuiImage(valueImageData); + valueButtons[i].valueButtonCheckedImg = new GuiImage(valueSelectedImageData); valueButtons[i].valueButtonHighlightedImg = new GuiImage(valueHighlightedImageData); - valueButtons[i].valueButton = new GuiButton(valueButtons[i].valueButtonImg->getWidth() * imgScale, valueButtons[i].valueButtonImg->getHeight() * imgScale); + valueButtons[i].valueButton = new GuiButton(valueButtons[i].valueButtonImg->getWidth() * imgScale, valueButtons[i].valueButtonImg->getHeight() * imgScale); valueButtons[i].valueButtonText = new GuiText(itr->first.c_str(), 32, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); valueButtons[i].valueButtonText->setMaxWidth(valueButtons[i].valueButtonImg->getWidth() * imgScale - 20.0f, GuiText::WRAP); @@ -187,7 +187,7 @@ void GuiSelectBox::Init(std::map values, int32_t value //Collapse the thing! showValues = false; - bChanged = true; + bChanged = true; } void GuiSelectBox::DeleteValueData() { @@ -208,8 +208,8 @@ void GuiSelectBox::DeleteValueData() { */ GuiSelectBox::~GuiSelectBox() { DeleteValueData(); - bChanged = false; - selected = 0; + bChanged = false; + selected = 0; showValues = false; } diff --git a/source/gui/GuiSound.cpp b/source/gui/GuiSound.cpp index 232310e..d6b9639 100644 --- a/source/gui/GuiSound.cpp +++ b/source/gui/GuiSound.cpp @@ -14,11 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#include -#include -#include #include #include +#include +#include +#include GuiSound::GuiSound(const char *filepath) { voice = -1; @@ -102,8 +102,6 @@ void GuiSound::Play() { if (v) { v->setState(Voice::STATE_START); } - - } void GuiSound::Stop() { diff --git a/source/gui/GuiSwitch.cpp b/source/gui/GuiSwitch.cpp index 8aeb6a8..c396654 100644 --- a/source/gui/GuiSwitch.cpp +++ b/source/gui/GuiSwitch.cpp @@ -14,16 +14,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#include #include #include +#include /** * Constructor for the GuiSwitch class. */ GuiSwitch::GuiSwitch(GuiImage *background, bool checked, float w, float h) - : GuiToggle(checked, w, h) { + : GuiToggle(checked, w, h) { setImageBackground(background); } @@ -31,7 +31,6 @@ GuiSwitch::GuiSwitch(GuiImage *background, bool checked, float w, float h) * Destructor for the GuiSwitch class. */ GuiSwitch::~GuiSwitch() { - } void GuiSwitch::setImageBackground(GuiImage *img) { diff --git a/source/gui/GuiText.cpp b/source/gui/GuiText.cpp index be66f7a..b17470c 100644 --- a/source/gui/GuiText.cpp +++ b/source/gui/GuiText.cpp @@ -14,69 +14,68 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#include #include +#include #include FreeTypeGX *GuiText::presentFont = NULL; -int32_t GuiText::presetSSAA = 2; -int32_t GuiText::presetSize = 28; -int32_t GuiText::presetMaxWidth = 0xFFFF; +int32_t GuiText::presetSSAA = 2; +int32_t GuiText::presetSize = 28; +int32_t GuiText::presetMaxWidth = 0xFFFF; int32_t GuiText::presetAlignment = ALIGN_CENTER | ALIGN_MIDDLE; -GX2ColorF32 GuiText::presetColor = (GX2ColorF32) { - 1.0f, 1.0f, 1.0f, 1.0f -}; +GX2ColorF32 GuiText::presetColor = (GX2ColorF32){ + 1.0f, 1.0f, 1.0f, 1.0f}; -#define TEXT_SCROLL_DELAY 6 -#define TEXT_SCROLL_INITIAL_DELAY 10 -#define MAX_LINES_TO_DRAW 10 +#define TEXT_SCROLL_DELAY 6 +#define TEXT_SCROLL_INITIAL_DELAY 10 +#define MAX_LINES_TO_DRAW 10 /** * Constructor for the GuiText class. */ GuiText::GuiText() { - text = NULL; - currentSize = presetSize; - color = glm::vec4(presetColor.r, presetColor.g, presetColor.b, presetColor.a); - alpha = presetColor.a; - alignment = presetAlignment; - maxWidth = presetMaxWidth; - internalSSAA = presetSSAA; - wrapMode = 0; - font = presentFont; - linestodraw = MAX_LINES_TO_DRAW; - textScrollPos = 0; + text = NULL; + currentSize = presetSize; + color = glm::vec4(presetColor.r, presetColor.g, presetColor.b, presetColor.a); + alpha = presetColor.a; + alignment = presetAlignment; + maxWidth = presetMaxWidth; + internalSSAA = presetSSAA; + wrapMode = 0; + font = presentFont; + linestodraw = MAX_LINES_TO_DRAW; + textScrollPos = 0; textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; - textScrollDelay = TEXT_SCROLL_DELAY; - defaultBlur = 4.0f; - blurGlowIntensity = 0.0f; - blurAlpha = 0.0f; - blurGlowColor = glm::vec4(0.0f); - width = 0; - height = 0; + textScrollDelay = TEXT_SCROLL_DELAY; + defaultBlur = 4.0f; + blurGlowIntensity = 0.0f; + blurAlpha = 0.0f; + blurGlowColor = glm::vec4(0.0f); + width = 0; + height = 0; } GuiText::GuiText(const char *t, int32_t s, const glm::vec4 &c) { - text = NULL; - currentSize = s; - color = c; - alpha = c[3]; - alignment = ALIGN_CENTER | ALIGN_MIDDLE; - maxWidth = presetMaxWidth; - internalSSAA = presetSSAA; - wrapMode = 0; - font = presentFont; - linestodraw = MAX_LINES_TO_DRAW; - textScrollPos = 0; + text = NULL; + currentSize = s; + color = c; + alpha = c[3]; + alignment = ALIGN_CENTER | ALIGN_MIDDLE; + maxWidth = presetMaxWidth; + internalSSAA = presetSSAA; + wrapMode = 0; + font = presentFont; + linestodraw = MAX_LINES_TO_DRAW; + textScrollPos = 0; textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; - textScrollDelay = TEXT_SCROLL_DELAY; - defaultBlur = 4.0f; - blurGlowIntensity = 0.0f; - blurAlpha = 0.0f; - blurGlowColor = glm::vec4(0.0f); - width = 0; - height = 0; + textScrollDelay = TEXT_SCROLL_DELAY; + defaultBlur = 4.0f; + blurGlowIntensity = 0.0f; + blurAlpha = 0.0f; + blurGlowColor = glm::vec4(0.0f); + width = 0; + height = 0; if (t) { textMutex.lock(); @@ -86,29 +85,29 @@ GuiText::GuiText(const char *t, int32_t s, const glm::vec4 &c) { } GuiText::GuiText(const wchar_t *t, int32_t s, const glm::vec4 &c) { - text = NULL; - currentSize = s; - color = c; - alpha = c[3]; - alignment = ALIGN_CENTER | ALIGN_MIDDLE; - maxWidth = presetMaxWidth; - internalSSAA = presetSSAA; - wrapMode = 0; - font = presentFont; - linestodraw = MAX_LINES_TO_DRAW; - textScrollPos = 0; + text = NULL; + currentSize = s; + color = c; + alpha = c[3]; + alignment = ALIGN_CENTER | ALIGN_MIDDLE; + maxWidth = presetMaxWidth; + internalSSAA = presetSSAA; + wrapMode = 0; + font = presentFont; + linestodraw = MAX_LINES_TO_DRAW; + textScrollPos = 0; textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; - textScrollDelay = TEXT_SCROLL_DELAY; - defaultBlur = 4.0f; - blurGlowIntensity = 0.0f; - blurAlpha = 0.0f; - blurGlowColor = glm::vec4(0.0f); - width = 0; - height = 0; + textScrollDelay = TEXT_SCROLL_DELAY; + defaultBlur = 4.0f; + blurGlowIntensity = 0.0f; + blurAlpha = 0.0f; + blurGlowColor = glm::vec4(0.0f); + width = 0; + height = 0; if (t) { textMutex.lock(); - text = new(std::nothrow) wchar_t[wcslen(t) + 1]; + text = new (std::nothrow) wchar_t[wcslen(t) + 1]; if (!text) { textMutex.unlock(); return; @@ -123,25 +122,25 @@ GuiText::GuiText(const wchar_t *t, int32_t s, const glm::vec4 &c) { * Constructor for the GuiText class, uses presets */ GuiText::GuiText(const char *t) { - text = NULL; - currentSize = presetSize; - color = glm::vec4(presetColor.r, presetColor.g, presetColor.b, presetColor.a); - alpha = presetColor.a; - alignment = presetAlignment; - maxWidth = presetMaxWidth; - internalSSAA = presetSSAA; - wrapMode = 0; - font = presentFont; - linestodraw = MAX_LINES_TO_DRAW; - textScrollPos = 0; + text = NULL; + currentSize = presetSize; + color = glm::vec4(presetColor.r, presetColor.g, presetColor.b, presetColor.a); + alpha = presetColor.a; + alignment = presetAlignment; + maxWidth = presetMaxWidth; + internalSSAA = presetSSAA; + wrapMode = 0; + font = presentFont; + linestodraw = MAX_LINES_TO_DRAW; + textScrollPos = 0; textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; - textScrollDelay = TEXT_SCROLL_DELAY; - defaultBlur = 4.0f; - blurGlowIntensity = 0.0f; - blurAlpha = 0.0f; - blurGlowColor = glm::vec4(0.0f); - width = 0; - height = 0; + textScrollDelay = TEXT_SCROLL_DELAY; + defaultBlur = 4.0f; + blurGlowIntensity = 0.0f; + blurAlpha = 0.0f; + blurGlowColor = glm::vec4(0.0f); + width = 0; + height = 0; if (t) { textMutex.lock(); @@ -174,7 +173,7 @@ void GuiText::setText(const char *t) { clearDynamicText(); - textScrollPos = 0; + textScrollPos = 0; textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; if (t) { @@ -190,7 +189,7 @@ void GuiText::setTextf(const char *format, ...) { } int32_t max_len = strlen(format) + 8192; - char *tmp = new(std::nothrow) char[max_len]; + char *tmp = new (std::nothrow) char[max_len]; va_list va; va_start(va, format); if ((vsnprintf(tmp, max_len, format, va) >= 0) && tmp) { @@ -213,11 +212,11 @@ void GuiText::setText(const wchar_t *t) { clearDynamicText(); - textScrollPos = 0; + textScrollPos = 0; textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; if (t) { - text = new(std::nothrow) wchar_t[wcslen(t) + 1]; + text = new (std::nothrow) wchar_t[wcslen(t) + 1]; if (!text) { textMutex.unlock(); return; @@ -241,11 +240,10 @@ void GuiText::clearDynamicText() { } void GuiText::setPresets(int32_t sz, const glm::vec4 &c, int32_t w, int32_t a) { - presetSize = sz; - presetColor = (GX2ColorF32) { - (float) c.r / 255.0f, (float) c.g / 255.0f, (float) c.b / 255.0f, (float) c.a / 255.0f - }; - presetMaxWidth = w; + presetSize = sz; + presetColor = (GX2ColorF32){ + (float) c.r / 255.0f, (float) c.g / 255.0f, (float) c.b / 255.0f, (float) c.a / 255.0f}; + presetMaxWidth = w; presetAlignment = a; } @@ -262,9 +260,9 @@ void GuiText::setMaxWidth(int32_t width, int32_t w) { wrapMode = w; if (w == SCROLL_HORIZONTAL) { - textScrollPos = 0; + textScrollPos = 0; textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; - textScrollDelay = TEXT_SCROLL_DELAY; + textScrollDelay = TEXT_SCROLL_DELAY; } clearDynamicText(); @@ -276,9 +274,9 @@ void GuiText::setColor(const glm::vec4 &c) { } void GuiText::setBlurGlowColor(float blur, const glm::vec4 &c) { - blurGlowColor = c; + blurGlowColor = c; blurGlowIntensity = blur; - blurAlpha = c[3]; + blurAlpha = c[3]; } int32_t GuiText::getTextWidth(int32_t ind) { @@ -297,7 +295,7 @@ int32_t GuiText::getTextWidth(int32_t ind) { int32_t GuiText::getTextWidth() { textMutex.lock(); auto res = font->getWidth(text, currentSize); - res = res > maxWidth && maxWidth > 0 ? maxWidth : res; + res = res > maxWidth && maxWidth > 0 ? maxWidth : res; textMutex.unlock(); return res; } @@ -365,7 +363,7 @@ void GuiText::makeDottedText() { textDyn.resize(pos + 1); int32_t i = 0, currentWidth = 0; - textDyn[pos] = new(std::nothrow) wchar_t[maxWidth]; + textDyn[pos] = new (std::nothrow) wchar_t[maxWidth]; if (!textDyn[pos]) { textDyn.resize(pos); textMutex.unlock(); @@ -377,7 +375,7 @@ void GuiText::makeDottedText() { if (currentWidth >= maxWidth && i > 2) { textDyn[pos][i - 2] = '.'; textDyn[pos][i - 1] = '.'; - textDyn[pos][i] = '.'; + textDyn[pos][i] = '.'; i++; break; } @@ -397,7 +395,7 @@ void GuiText::scrollText(uint32_t frameCount) { int32_t i = 0, currentWidth = 0; textDyn.resize(pos + 1); - textDyn[pos] = new(std::nothrow) wchar_t[maxWidth]; + textDyn[pos] = new (std::nothrow) wchar_t[maxWidth]; if (!textDyn[pos]) { textDyn.resize(pos); textMutex.unlock(); @@ -431,15 +429,15 @@ void GuiText::scrollText(uint32_t frameCount) { ++textScrollPos; if (textScrollPos > stringlen) { - textScrollPos = 0; + textScrollPos = 0; textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; } - int32_t ch = textScrollPos; + int32_t ch = textScrollPos; int32_t pos = textDyn.size() - 1; if (!textDyn[pos]) { - textDyn[pos] = new(std::nothrow) wchar_t[maxWidth]; + textDyn[pos] = new (std::nothrow) wchar_t[maxWidth]; } if (!textDyn[pos]) { @@ -481,37 +479,37 @@ void GuiText::wrapText() { return; } - int32_t i = 0; - int32_t ch = 0; - int32_t linenum = 0; - int32_t lastSpace = -1; + int32_t i = 0; + int32_t ch = 0; + int32_t linenum = 0; + int32_t lastSpace = -1; int32_t lastSpaceIndex = -1; - int32_t currentWidth = 0; + int32_t currentWidth = 0; while (text[ch] && linenum < linestodraw) { if (linenum >= (int32_t) textDyn.size()) { textDyn.resize(linenum + 1); - textDyn[linenum] = new(std::nothrow) wchar_t[maxWidth]; + textDyn[linenum] = new (std::nothrow) wchar_t[maxWidth]; if (!textDyn[linenum]) { textDyn.resize(linenum); break; } } - textDyn[linenum][i] = text[ch]; + textDyn[linenum][i] = text[ch]; textDyn[linenum][i + 1] = 0; currentWidth += font->getCharWidth(text[ch], currentSize, ch > 0 ? text[ch - 1] : 0x0000); if (currentWidth >= maxWidth || (text[ch] == '\n')) { if (text[ch] == '\n') { - lastSpace = -1; + lastSpace = -1; lastSpaceIndex = -1; } else if (lastSpace >= 0) { - textDyn[linenum][lastSpaceIndex] = 0; // discard space, and everything after - ch = lastSpace; // go backwards to the last space - lastSpace = -1; // we have used this space - lastSpaceIndex = -1; + textDyn[linenum][lastSpaceIndex] = 0; // discard space, and everything after + ch = lastSpace; // go backwards to the last space + lastSpace = -1; // we have used this space + lastSpaceIndex = -1; } if (linenum + 1 == linestodraw && text[ch + 1] != 0x0000) { @@ -521,7 +519,7 @@ void GuiText::wrapText() { textDyn[linenum][i - 2] = '.'; textDyn[linenum][i - 1] = '.'; - textDyn[linenum][i] = '.'; + textDyn[linenum][i] = '.'; textDyn[linenum][i + 1] = 0; } @@ -530,7 +528,7 @@ void GuiText::wrapText() { i = -1; } if (text[ch] == ' ' && i >= 0) { - lastSpace = ch; + lastSpace = ch; lastSpaceIndex = i; } ++ch; @@ -589,21 +587,21 @@ float GuiText::getCenterY(void) { if (alignment & ALIGN_TOP) { float pHeight = 0.0f; - float pScale = 0.0f; + float pScale = 0.0f; if (parentElement) { pHeight = parentElement->getHeight(); - pScale = parentElement->getScaleY(); + pScale = parentElement->getScaleY(); } pCenterY += pHeight * 0.5f * pScale; } else if (alignment & ALIGN_BOTTOM) { float pHeight = 0.0f; - float pScale = 0.0f; + float pScale = 0.0f; if (parentElement) { pHeight = parentElement->getHeight(); - pScale = parentElement->getScaleY(); + pScale = parentElement->getScaleY(); } pCenterY -= pHeight * 0.5f * pScale; @@ -626,12 +624,12 @@ void GuiText::draw(CVideo *pVideo) { return; } - color[3] = getAlpha(); + color[3] = getAlpha(); blurGlowColor[3] = blurAlpha * getAlpha(); auto internalRenderingScale = internalSSAA == 0 ? 1 : internalSSAA << 1; - int32_t normal_size = currentSize * getScale(); + int32_t normal_size = currentSize * getScale(); int32_t internalRenderingSize = normal_size * internalRenderingScale; auto textWidth = font->getWidth(text, normal_size); diff --git a/source/gui/GuiToggle.cpp b/source/gui/GuiToggle.cpp index 6ca6c6c..c6df4be 100644 --- a/source/gui/GuiToggle.cpp +++ b/source/gui/GuiToggle.cpp @@ -21,7 +21,7 @@ */ GuiToggle::GuiToggle(bool checked, float width, float height) - : GuiButton(width, height) { + : GuiButton(width, height) { bChanged = false; selected = checked; clicked.connect(this, &GuiToggle::OnToggleClick); @@ -48,4 +48,3 @@ void GuiToggle::OnToggleClick(GuiButton *button, const GuiController *controller void GuiToggle::update(GuiController *c) { GuiButton::update(c); } - diff --git a/source/gui/GuiTrigger.cpp b/source/gui/GuiTrigger.cpp index 3e7d6c8..297635f 100644 --- a/source/gui/GuiTrigger.cpp +++ b/source/gui/GuiTrigger.cpp @@ -14,19 +14,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#include #include +#include #include /** * Constructor for the GuiTrigger class. */ GuiTrigger::GuiTrigger() - : chan(CHANNEL_ALL), btns(BUTTON_NONE), bClickEverywhere(false), bHoldEverywhere(false), bSelectionClickEverywhere(false), bLastTouched(false) { + : chan(CHANNEL_ALL), btns(BUTTON_NONE), bClickEverywhere(false), bHoldEverywhere(false), bSelectionClickEverywhere(false), bLastTouched(false) { } GuiTrigger::GuiTrigger(uint32_t ch, uint32_t btn, bool clickEverywhere, bool holdEverywhere, bool selectionClickEverywhere) - : chan(ch), btns(btn), bClickEverywhere(clickEverywhere), bHoldEverywhere(holdEverywhere), bSelectionClickEverywhere(selectionClickEverywhere), bLastTouched(false) { + : chan(ch), btns(btn), bClickEverywhere(clickEverywhere), bHoldEverywhere(holdEverywhere), bSelectionClickEverywhere(selectionClickEverywhere), bLastTouched(false) { } /** @@ -141,4 +141,3 @@ bool GuiTrigger::released(const GuiController *controller) const { return bResult; } - diff --git a/source/sounds/BufferCircle.cpp b/source/sounds/BufferCircle.cpp index 4b613a6..699efc9 100644 --- a/source/sounds/BufferCircle.cpp +++ b/source/sounds/BufferCircle.cpp @@ -23,12 +23,12 @@ * * for WiiXplorer 2010 ***************************************************************************/ +#include #include #include -#include BufferCircle::BufferCircle() { - which = 0; + which = 0; BufferBlockSize = 0; } @@ -52,7 +52,7 @@ void BufferCircle::SetBufferBlockSize(int32_t size) { } SoundBuffer[i] = (uint8_t *) memalign(32, ALIGN32(BufferBlockSize)); - BufferSize[i] = 0; + BufferSize[i] = 0; BufferReady[i] = false; } } @@ -73,7 +73,7 @@ void BufferCircle::Resize(int32_t size) { } else { SoundBuffer[i] = NULL; } - BufferSize[i] = 0; + BufferSize[i] = 0; BufferReady[i] = false; } } @@ -94,7 +94,7 @@ void BufferCircle::RemoveBuffer(int32_t pos) { void BufferCircle::ClearBuffer() { for (int32_t i = 0; i < Size(); i++) { - BufferSize[i] = 0; + BufferSize[i] = 0; BufferReady[i] = false; } which = 0; @@ -107,14 +107,14 @@ void BufferCircle::FreeBuffer() { } SoundBuffer[i] = NULL; - BufferSize[i] = 0; + BufferSize[i] = 0; BufferReady[i] = false; } } void BufferCircle::LoadNext() { BufferReady[which] = false; - BufferSize[which] = 0; + BufferSize[which] = 0; which = Next(); } diff --git a/source/sounds/Mp3Decoder.cpp b/source/sounds/Mp3Decoder.cpp index b11fda7..75ab28d 100644 --- a/source/sounds/Mp3Decoder.cpp +++ b/source/sounds/Mp3Decoder.cpp @@ -23,20 +23,20 @@ * * for WiiXplorer 2010 ***************************************************************************/ -#include -#include +#include "fs/CFile.hpp" +#include +#include +#include #include -#include #include #include -#include -#include -#include -#include "fs/CFile.hpp" +#include +#include +#include Mp3Decoder::Mp3Decoder(const char *filepath) - : SoundDecoder(filepath) { - SoundType = SOUND_MP3; + : SoundDecoder(filepath) { + SoundType = SOUND_MP3; ReadBuffer = NULL; mad_timer_reset(&Timer); mad_stream_init(&Stream); @@ -51,8 +51,8 @@ Mp3Decoder::Mp3Decoder(const char *filepath) } Mp3Decoder::Mp3Decoder(const uint8_t *snd, int32_t len) - : SoundDecoder(snd, len) { - SoundType = SOUND_MP3; + : SoundDecoder(snd, len) { + SoundType = SOUND_MP3; ReadBuffer = NULL; mad_timer_reset(&Timer); mad_stream_init(&Stream); @@ -82,7 +82,7 @@ Mp3Decoder::~Mp3Decoder() { } void Mp3Decoder::OpenFile() { - GuardPtr = NULL; + GuardPtr = NULL; ReadBuffer = (uint8_t *) memalign(32, SoundBlockSize * SoundBlocks); if (!ReadBuffer) { if (file_fd) { @@ -103,7 +103,7 @@ void Mp3Decoder::OpenFile() { } SampleRate = (uint32_t) Frame.header.samplerate; - Format = ((MAD_NCHANNELS(&Frame.header) == 2) ? (FORMAT_PCM_16_BIT | CHANNELS_STEREO) : (FORMAT_PCM_16_BIT | CHANNELS_MONO)); + Format = ((MAD_NCHANNELS(&Frame.header) == 2) ? (FORMAT_PCM_16_BIT | CHANNELS_STEREO) : (FORMAT_PCM_16_BIT | CHANNELS_MONO)); Rewind(); } @@ -170,8 +170,8 @@ int32_t Mp3Decoder::Read(uint8_t *buffer, int32_t buffer_size, int32_t pos) { if (Stream.buffer == NULL || Stream.error == MAD_ERROR_BUFLEN) { uint8_t *ReadStart = ReadBuffer; - int32_t ReadSize = SoundBlockSize * SoundBlocks; - int32_t Remaining = 0; + int32_t ReadSize = SoundBlockSize * SoundBlocks; + int32_t Remaining = 0; if (Stream.next_frame != NULL) { Remaining = Stream.bufend - Stream.next_frame; diff --git a/source/sounds/OggDecoder.cpp b/source/sounds/OggDecoder.cpp index 2396145..edeb1e5 100644 --- a/source/sounds/OggDecoder.cpp +++ b/source/sounds/OggDecoder.cpp @@ -23,12 +23,12 @@ * * for WiiXplorer 2010 ***************************************************************************/ -#include -#include -#include -#include -#include #include "fs/CFile.hpp" +#include +#include +#include +#include +#include static int ogg_read(void *punt, int bytes, int blocks, int *f) { return ((CFile *) f)->read((uint8_t *) punt, bytes * blocks); @@ -48,14 +48,13 @@ static long ogg_tell(int *f) { } static ov_callbacks callbacks = { - (size_t (*)(void *, size_t, size_t, void *)) ogg_read, + (size_t(*)(void *, size_t, size_t, void *)) ogg_read, (int (*)(void *, ogg_int64_t, int)) ogg_seek, (int (*)(void *)) ogg_close, - (long (*)(void *)) ogg_tell -}; + (long (*)(void *)) ogg_tell}; OggDecoder::OggDecoder(const char *filepath) - : SoundDecoder(filepath) { + : SoundDecoder(filepath) { SoundType = SOUND_OGG; if (!file_fd) { @@ -66,7 +65,7 @@ OggDecoder::OggDecoder(const char *filepath) } OggDecoder::OggDecoder(const uint8_t *snd, int32_t len) - : SoundDecoder(snd, len) { + : SoundDecoder(snd, len) { SoundType = SOUND_OGG; if (!file_fd) { @@ -101,7 +100,7 @@ void OggDecoder::OpenFile() { return; } - Format = ((ogg_info->channels == 2) ? (FORMAT_PCM_16_BIT | CHANNELS_STEREO) : (FORMAT_PCM_16_BIT | CHANNELS_MONO)); + Format = ((ogg_info->channels == 2) ? (FORMAT_PCM_16_BIT | CHANNELS_STEREO) : (FORMAT_PCM_16_BIT | CHANNELS_MONO)); SampleRate = ogg_info->rate; } @@ -111,8 +110,8 @@ int32_t OggDecoder::Rewind() { } int32_t ret = ov_time_seek(&ogg_file, 0); - CurPos = 0; - EndOfFile = false; + CurPos = 0; + EndOfFile = false; return ret; } diff --git a/source/sounds/SoundDecoder.cpp b/source/sounds/SoundDecoder.cpp index 73a06ee..85abb2d 100644 --- a/source/sounds/SoundDecoder.cpp +++ b/source/sounds/SoundDecoder.cpp @@ -15,14 +15,14 @@ * along with this program. If not, see . ****************************************************************************/ +#include "fs/CFile.hpp" +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include "fs/CFile.hpp" static const uint32_t FixedPointShift = 15; static const uint32_t FixedPointScale = 1 << FixedPointShift; @@ -67,24 +67,24 @@ int32_t SoundDecoder::Seek(int32_t pos) { } void SoundDecoder::Init() { - SoundType = SOUND_RAW; - SoundBlocks = 8; - SoundBlockSize = 0x4000; + SoundType = SOUND_RAW; + SoundBlocks = 8; + SoundBlockSize = 0x4000; ResampleTo48kHz = false; - CurPos = 0; - whichLoad = 0; - Loop = false; - EndOfFile = false; - Decoding = false; - ExitRequested = false; + CurPos = 0; + whichLoad = 0; + Loop = false; + EndOfFile = false; + Decoding = false; + ExitRequested = false; SoundBuffer.SetBufferBlockSize(SoundBlockSize); SoundBuffer.Resize(SoundBlocks); ResampleBuffer = NULL; - ResampleRatio = 0; + ResampleRatio = 0; } int32_t SoundDecoder::Rewind() { - CurPos = 0; + CurPos = 0; EndOfFile = false; file_fd->rewind(); @@ -99,12 +99,9 @@ int32_t SoundDecoder::Read(uint8_t *buffer, int32_t buffer_size, int32_t pos) { } void SoundDecoder::EnableUpsample(void) { - if ((ResampleBuffer == NULL) - && IsStereo() && Is16Bit() - && SampleRate != 32000 - && SampleRate != 48000) { + if ((ResampleBuffer == NULL) && IsStereo() && Is16Bit() && SampleRate != 32000 && SampleRate != 48000) { ResampleBuffer = (uint8_t *) memalign(32, SoundBlockSize); - ResampleRatio = (FixedPointScale * SampleRate) / 48000; + ResampleRatio = (FixedPointScale * SampleRate) / 48000; SoundBlockSize = (SoundBlockSize * ResampleRatio) / FixedPointScale; SoundBlockSize &= ~0x03; // set new sample rate @@ -118,10 +115,10 @@ void SoundDecoder::Upsample(int16_t *src, int16_t *dst, uint32_t nr_src_samples, for (uint32_t i = 0, n = 0; i < nr_dst_samples; i += 2) { if ((n + 3) < nr_src_samples) { // simple fixed point linear interpolation - dst[i] = src[n] + (((src[n + 2] - src[n]) * timer) >> FixedPointShift); + dst[i] = src[n] + (((src[n + 2] - src[n]) * timer) >> FixedPointShift); dst[i + 1] = src[n + 1] + (((src[n + 3] - src[n + 1]) * timer) >> FixedPointShift); } else { - dst[i] = src[n]; + dst[i] = src[n]; dst[i + 1] = src[n + 1]; } @@ -141,19 +138,17 @@ void SoundDecoder::Decode() { // check if we are not at the pre-last buffer (last buffer is playing) uint16_t whichPlaying = SoundBuffer.Which(); - if (((whichPlaying == 0) && (whichLoad == SoundBuffer.Size() - 2)) - || ((whichPlaying == 1) && (whichLoad == SoundBuffer.Size() - 1)) - || (whichLoad == (whichPlaying - 2))) { + if (((whichPlaying == 0) && (whichLoad == SoundBuffer.Size() - 2)) || ((whichPlaying == 1) && (whichLoad == SoundBuffer.Size() - 1)) || (whichLoad == (whichPlaying - 2))) { return; } Decoding = true; - int32_t done = 0; + int32_t done = 0; uint8_t *write_buf = SoundBuffer.GetBuffer(whichLoad); if (!write_buf) { ExitRequested = true; - Decoding = false; + Decoding = false; return; } @@ -182,7 +177,7 @@ void SoundDecoder::Decode() { if (ResampleBuffer && ResampleRatio) { memcpy(ResampleBuffer, write_buf, done); - int32_t src_samples = done >> 1; + int32_t src_samples = done >> 1; int32_t dest_samples = (src_samples * FixedPointScale) / ResampleRatio; dest_samples &= ~0x01; Upsample((int16_t *) ResampleBuffer, (int16_t *) write_buf, src_samples, dest_samples); @@ -192,7 +187,7 @@ void SoundDecoder::Decode() { //! TODO: remove this later and add STEREO support with two voices, for now we convert to MONO if (IsStereo()) { int16_t *monoBuf = (int16_t *) write_buf; - done = done >> 1; + done = done >> 1; for (int32_t i = 0; i < done; i++) { monoBuf[i] = monoBuf[i << 1]; @@ -214,4 +209,3 @@ void SoundDecoder::Decode() { Decoding = false; } - diff --git a/source/sounds/SoundHandler.cpp b/source/sounds/SoundHandler.cpp index 62c6797..18d6e6c 100644 --- a/source/sounds/SoundHandler.cpp +++ b/source/sounds/SoundHandler.cpp @@ -23,24 +23,24 @@ * * for WiiXplorer 2010 ***************************************************************************/ -#include -#include #include -#include -#include #include #include +#include +#include +#include #include +#include SoundHandler *SoundHandler::handlerInstance = NULL; SoundHandler::SoundHandler() - : CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x8000) { - Decoding = false; + : CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x8000) { + Decoding = false; ExitRequested = false; for (uint32_t i = 0; i < MAX_DECODERS; ++i) { DecoderList[i] = NULL; - voiceList[i] = NULL; + voiceList[i] = NULL; } resumeThread(); @@ -115,19 +115,19 @@ void SoundHandler::ClearDecoderList() { static inline bool CheckMP3Signature(const uint8_t *buffer) { const char MP3_Magic[][3] = { - {'I', 'D', '3'}, //'ID3' - {0xff, 0xfe}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'), - {0xff, 0xff}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'), - {0xff, 0xfa}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'), - {0xff, 0xfb}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'), - {0xff, 0xf2}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'), - {0xff, 0xf3}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'), - {0xff, 0xf4}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'), - {0xff, 0xf5}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'), - {0xff, 0xf6}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'), - {0xff, 0xf7}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'), - {0xff, 0xe2}, //'MPEG ADTS, layer III, v2.5 [protected]', 'mp3', 'audio/mpeg'), - {0xff, 0xe3}, //'MPEG ADTS, layer III, v2.5', 'mp3', 'audio/mpeg'), + {'I', 'D', '3'}, //'ID3' + {0xff, 0xfe}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'), + {0xff, 0xff}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'), + {0xff, 0xfa}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'), + {0xff, 0xfb}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'), + {0xff, 0xf2}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'), + {0xff, 0xf3}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'), + {0xff, 0xf4}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'), + {0xff, 0xf5}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'), + {0xff, 0xf6}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'), + {0xff, 0xf7}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'), + {0xff, 0xe2}, //'MPEG ADTS, layer III, v2.5 [protected]', 'mp3', 'audio/mpeg'), + {0xff, 0xe3}, //'MPEG ADTS, layer III, v2.5', 'mp3', 'audio/mpeg'), }; if (buffer[0] == MP3_Magic[0][0] && buffer[1] == MP3_Magic[0][1] && @@ -176,7 +176,7 @@ SoundDecoder *SoundHandler::GetSoundDecoder(const char *filepath) { SoundDecoder *SoundHandler::GetSoundDecoder(const uint8_t *sound, int32_t length) { const uint8_t *check = sound; - int32_t counter = 0; + int32_t counter = 0; while (check[0] == 0 && counter < length) { check++; @@ -224,7 +224,7 @@ void SoundHandler::executeThread() { // we would need MAX_DECODERS > Voice::PRIO_MAX for (uint32_t i = 0; i < MAX_DECODERS; ++i) { int32_t priority = (MAX_DECODERS - i) * Voice::PRIO_MAX / MAX_DECODERS; - voiceList[i] = new Voice(priority); // allocate voice 0 with highest priority + voiceList[i] = new Voice(priority); // allocate voice 0 with highest priority } AXRegisterAppFrameCallback(SoundHandler::axFrameCallback); @@ -279,15 +279,15 @@ void SoundHandler::axFrameCallback(void) { SoundDecoder *decoder = handlerInstance->getDecoder(i); decoder->Lock(); if (decoder->IsBufferReady()) { - const uint8_t *buffer = decoder->GetBuffer(); + const uint8_t *buffer = decoder->GetBuffer(); const uint32_t bufferSize = decoder->GetBufferSize(); decoder->LoadNext(); const uint8_t *nextBuffer = NULL; - uint32_t nextBufferSize = 0; + uint32_t nextBufferSize = 0; if (decoder->IsBufferReady()) { - nextBuffer = decoder->GetBuffer(); + nextBuffer = decoder->GetBuffer(); nextBufferSize = decoder->GetBufferSize(); decoder->LoadNext(); } diff --git a/source/sounds/WavDecoder.cpp b/source/sounds/WavDecoder.cpp index 4186002..88509b4 100644 --- a/source/sounds/WavDecoder.cpp +++ b/source/sounds/WavDecoder.cpp @@ -23,16 +23,16 @@ * * for WiiXplorer 2010 ***************************************************************************/ -#include -#include #include "fs/CFile.hpp" #include "utils/utils.h" +#include +#include WavDecoder::WavDecoder(const char *filepath) - : SoundDecoder(filepath) { - SoundType = SOUND_WAV; + : SoundDecoder(filepath) { + SoundType = SOUND_WAV; SampleRate = 48000; - Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT; + Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT; if (!file_fd) { return; @@ -42,10 +42,10 @@ WavDecoder::WavDecoder(const char *filepath) } WavDecoder::WavDecoder(const uint8_t *snd, int32_t len) - : SoundDecoder(snd, len) { - SoundType = SOUND_WAV; + : SoundDecoder(snd, len) { + SoundType = SOUND_WAV; SampleRate = 48000; - Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT; + Format = CHANNELS_STEREO | FORMAT_PCM_16_BIT; if (!file_fd) { return; @@ -94,8 +94,8 @@ void WavDecoder::OpenFile() { } DataOffset += 8; - DataSize = le32(DataChunk.size); - Is16Bit = (le16(FmtChunk.bps) == 16); + DataSize = le32(DataChunk.size); + Is16Bit = (le16(FmtChunk.bps) == 16); SampleRate = le32(FmtChunk.freq); if (le16(FmtChunk.channels) == 1 && le16(FmtChunk.bps) == 8 && le16(FmtChunk.alignment) <= 1) { diff --git a/source/system/memory.c b/source/system/memory.c index f5c384b..40ce6e9 100644 --- a/source/system/memory.c +++ b/source/system/memory.c @@ -14,35 +14,35 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ +#include "memory.h" +#include +#include +#include #include #include -#include -#include -#include -#include "memory.h" -#define MEMORY_ARENA_1 0 -#define MEMORY_ARENA_2 1 -#define MEMORY_ARENA_3 2 -#define MEMORY_ARENA_4 3 -#define MEMORY_ARENA_5 4 -#define MEMORY_ARENA_6 5 -#define MEMORY_ARENA_7 6 -#define MEMORY_ARENA_8 7 -#define MEMORY_ARENA_FG_BUCKET 8 +#define MEMORY_ARENA_1 0 +#define MEMORY_ARENA_2 1 +#define MEMORY_ARENA_3 2 +#define MEMORY_ARENA_4 3 +#define MEMORY_ARENA_5 4 +#define MEMORY_ARENA_6 5 +#define MEMORY_ARENA_7 6 +#define MEMORY_ARENA_8 7 +#define MEMORY_ARENA_FG_BUCKET 8 //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Memory functions //! This is the only place where those are needed so lets keep them more or less private //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -static MEMHeapHandle mem1_heap = NULL; +static MEMHeapHandle mem1_heap = NULL; static MEMHeapHandle bucket_heap = NULL; void libgui_memoryInitialize(void) { if (!mem1_heap) { MEMHeapHandle mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); uint32_t mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); - void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4); + void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4); if (mem1_memory) mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0); } @@ -50,7 +50,7 @@ void libgui_memoryInitialize(void) { if (!bucket_heap) { MEMHeapHandle bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET); uint32_t bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4); - void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4); + void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4); if (bucket_memory) bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0); } diff --git a/source/utils/utils.h b/source/utils/utils.h index 1d00f98..a65f134 100644 --- a/source/utils/utils.h +++ b/source/utils/utils.h @@ -7,23 +7,24 @@ extern "C" { #endif -#define LIMIT(x, min, max) \ - ({ \ - typeof( x ) _x = x; \ - typeof( min ) _min = min; \ - typeof( max ) _max = max; \ - ( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \ -}) +#define LIMIT(x, min, max) \ + ({ \ + typeof(x) _x = x; \ + typeof(min) _min = min; \ + typeof(max) _max = max; \ + (((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \ + : (_x)); \ + }) -#define DegToRad(a) ( (a) * 0.01745329252f ) -#define RadToDeg(a) ( (a) * 57.29577951f ) +#define DegToRad(a) ((a) *0.01745329252f) +#define RadToDeg(a) ((a) *57.29577951f) -#define ALIGN4(x) (((x) + 3) & ~3) -#define ALIGN32(x) (((x) + 31) & ~31) +#define ALIGN4(x) (((x) + 3) & ~3) +#define ALIGN32(x) (((x) + 31) & ~31) -#define le16(i) ((((uint16_t) ((i) & 0xFF)) << 8) | ((uint16_t) (((i) & 0xFF00) >> 8))) -#define le32(i) ((((uint32_t)le16((i) & 0xFFFF)) << 16) | ((uint32_t)le16(((i) & 0xFFFF0000) >> 16))) -#define le64(i) ((((uint64_t)le32((i) & 0xFFFFFFFFLL)) << 32) | ((uint64_t)le32(((i) & 0xFFFFFFFF00000000LL) >> 32))) +#define le16(i) ((((uint16_t) ((i) &0xFF)) << 8) | ((uint16_t) (((i) &0xFF00) >> 8))) +#define le32(i) ((((uint32_t) le16((i) &0xFFFF)) << 16) | ((uint32_t) le16(((i) &0xFFFF0000) >> 16))) +#define le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32))) //Needs to have log_init() called beforehand. void dumpHex(const void *data, size_t size); diff --git a/source/video/CVideo.cpp b/source/video/CVideo.cpp index 25a4fcb..530fed7 100644 --- a/source/video/CVideo.cpp +++ b/source/video/CVideo.cpp @@ -14,19 +14,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#include -#include -#include +#include "utils/utils.h" +#include #include -#include +#include #include +#include #include #include -#include -#include "utils/utils.h" +#include +#include +#include CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) { - tvEnabled = false; + tvEnabled = false; drcEnabled = false; //! allocate MEM2 command buffer memory @@ -46,43 +47,43 @@ CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) { GX2Init(gx2_init_attributes); uint32_t scanBufferSize = 0; - uint32_t scaleNeeded = 0; + uint32_t scaleNeeded = 0; - int32_t tvScanMode = ((forceTvScanMode >= 0) ? forceTvScanMode : (int32_t) GX2GetSystemTVScanMode()); + int32_t tvScanMode = ((forceTvScanMode >= 0) ? forceTvScanMode : (int32_t) GX2GetSystemTVScanMode()); int32_t drcScanMode = ((forceDrcScanMode >= 0) ? forceDrcScanMode : (int32_t) GX2GetSystemDRCScanMode()); int32_t tvRenderMode; - uint32_t tvWidth = 0; + uint32_t tvWidth = 0; uint32_t tvHeight = 0; switch (tvScanMode) { case GX2_TV_SCAN_MODE_480I: case GX2_TV_SCAN_MODE_480P: - tvWidth = 854; - tvHeight = 480; + tvWidth = 854; + tvHeight = 480; tvRenderMode = GX2_TV_RENDER_MODE_WIDE_480P; break; case GX2_TV_SCAN_MODE_1080I: case GX2_TV_SCAN_MODE_1080P: - tvWidth = 1920; - tvHeight = 1080; + tvWidth = 1920; + tvHeight = 1080; tvRenderMode = GX2_TV_RENDER_MODE_WIDE_1080P; break; case GX2_TV_SCAN_MODE_720P: default: - tvWidth = 1280; - tvHeight = 720; + tvWidth = 1280; + tvHeight = 720; tvRenderMode = GX2_TV_RENDER_MODE_WIDE_720P; break; } - int32_t tvAAMode = GX2_AA_MODE1X; + int32_t tvAAMode = GX2_AA_MODE1X; int32_t drcAAMode = GX2_AA_MODE4X; //! calculate the scale factor for later texture resize - widthScaleFactor = 1.0f / (float) tvWidth; + widthScaleFactor = 1.0f / (float) tvWidth; heightScaleFactor = 1.0f / (float) tvHeight; - depthScaleFactor = widthScaleFactor; + depthScaleFactor = widthScaleFactor; //! calculate the size needed for the TV scan buffer and allocate the buffer from bucket memory GX2CalcTVSize((GX2TVRenderMode) tvRenderMode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE, &scanBufferSize, &scaleNeeded); @@ -197,9 +198,9 @@ CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) { GX2InitSampler(&aaSampler, GX2_TEX_CLAMP_MODE_CLAMP, GX2_TEX_XY_FILTER_MODE_LINEAR); GX2InitTexture(&tvAaTexture, tvColorBuffer.surface.width, tvColorBuffer.surface.height, 1, 0, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_SURFACE_DIM_TEXTURE_2D, GX2_TILE_MODE_DEFAULT); - tvAaTexture.surface.image = tvColorBuffer.surface.image; + tvAaTexture.surface.image = tvColorBuffer.surface.image; tvAaTexture.surface.imageSize = tvColorBuffer.surface.imageSize; - tvAaTexture.surface.mipmaps = tvColorBuffer.surface.mipmaps; + tvAaTexture.surface.mipmaps = tvColorBuffer.surface.mipmaps; } CVideo::~CVideo() { diff --git a/source/video/CursorDrawer.cpp b/source/video/CursorDrawer.cpp index f844412..e1b8bea 100644 --- a/source/video/CursorDrawer.cpp +++ b/source/video/CursorDrawer.cpp @@ -18,12 +18,12 @@ #include #include +#include #include #include #include #include #include -#include CursorDrawer *CursorDrawer::instance = NULL; @@ -48,7 +48,6 @@ void CursorDrawer::init_colorVtxs() { if (!this->colorVtxs) { this->colorVtxs = (uint8_t *) memalign(0x40, sizeof(uint8_t) * 16); if (this->colorVtxs == NULL) { return; } - } memset(this->colorVtxs, 0xFF, 16 * sizeof(uint8_t)); @@ -62,7 +61,7 @@ void CursorDrawer::draw_Cursor(float x, float y) { return; } - float widthScaleFactor = 1.0f / (float) 1280; + float widthScaleFactor = 1.0f / (float) 1280; float heightScaleFactor = 1.0f / (float) 720; int32_t width = 20; diff --git a/source/video/shaders/ColorShader.cpp b/source/video/shaders/ColorShader.cpp index b7158ee..d70d75b 100644 --- a/source/video/shaders/ColorShader.cpp +++ b/source/video/shaders/ColorShader.cpp @@ -14,9 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ +#include #include #include -#include static const uint32_t cpVertexShaderProgram[] = { 0x00000000, 0x00008009, 0x20000000, 0x000078a0, @@ -51,8 +51,7 @@ static const uint32_t cpVertexShaderProgram[] = { 0x02c49f80, 0x80000060, 0x02e08f01, 0xfe0c620f, 0x02c01f80, 0x7f00622f, 0xfe242000, 0x10000000, 0xfe20a080, 0x10000020, 0xf2178647, 0x49c0e9fb, - 0xfbbdb2ab, 0x768ac733 -}; + 0xfbbdb2ab, 0x768ac733}; static const uint32_t cpVertexShaderRegs[] = { 0x00000103, 0x00000000, 0x00000000, 0x00000001, @@ -67,8 +66,7 @@ static const uint32_t cpVertexShaderRegs[] = { 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, - 0x000000ff, 0x00000000, 0x0000000e, 0x00000010 -}; + 0x000000ff, 0x00000000, 0x0000000e, 0x00000010}; static const uint32_t cpPixelShaderProgram[] = { 0x20000000, 0x00000ca0, 0x00000000, 0x88062094, @@ -89,8 +87,7 @@ static const uint32_t cpPixelShaderProgram[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00002000, 0x90000000, 0x0004a000, 0x90000020, 0x00082001, 0x90000040, 0x000ca081, 0x90000060, - 0xbb7dd898, 0x9746c59c, 0xc69b00e7, 0x03c36218 -}; + 0xbb7dd898, 0x9746c59c, 0xc69b00e7, 0x03c36218}; static const uint32_t cpPixelShaderRegs[] = { 0x00000001, 0x00000002, 0x14000001, 0x00000000, 0x00000001, 0x00000100, 0x00000000, 0x00000000, @@ -102,45 +99,38 @@ static const uint32_t cpPixelShaderRegs[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x00000001, 0x00000010, - 0x00000000 -}; + 0x00000000}; ColorShader *ColorShader::shaderInstance = NULL; ColorShader::ColorShader() - : vertexShader(cuAttributeCount) { + : vertexShader(cuAttributeCount) { //! create pixel shader pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs)); colorIntensityLocation = 0; - pixelShader.addUniformVar((GX2UniformVar) { - "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1 - }); + pixelShader.addUniformVar((GX2UniformVar){ + "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1}); //! create vertex shader vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); - angleLocation = 0; + angleLocation = 0; offsetLocation = 4; - scaleLocation = 8; - vertexShader.addUniformVar((GX2UniformVar) { - "unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1 - }); - vertexShader.addUniformVar((GX2UniformVar) { - "unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1 - }); - vertexShader.addUniformVar((GX2UniformVar) { - "unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1 - }); + scaleLocation = 8; + vertexShader.addUniformVar((GX2UniformVar){ + "unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1}); + vertexShader.addUniformVar((GX2UniformVar){ + "unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1}); + vertexShader.addUniformVar((GX2UniformVar){ + "unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1}); - colorLocation = 1; + colorLocation = 1; positionLocation = 0; - vertexShader.addAttribVar((GX2AttribVar) { - "attr_color", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation - }); - vertexShader.addAttribVar((GX2AttribVar) { - "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation - }); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_color", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation}); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation}); //! setup attribute streams GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32); @@ -153,7 +143,7 @@ ColorShader::ColorShader() positionVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, cuPositionVtxsSize); if (positionVtxs) { //! position vertex structure - int32_t i = 0; + int32_t i = 0; positionVtxs[i++] = -1.0f; positionVtxs[i++] = -1.0f; positionVtxs[i++] = 0.0f; diff --git a/source/video/shaders/FXAAShader.cpp b/source/video/shaders/FXAAShader.cpp index b59379e..ab2257c 100644 --- a/source/video/shaders/FXAAShader.cpp +++ b/source/video/shaders/FXAAShader.cpp @@ -14,9 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ +#include #include #include -#include static const uint32_t cpVertexShaderProgram[] = { 0x00000000, 0x00008009, 0x20000000, 0x000004a0, @@ -36,8 +36,7 @@ static const uint32_t cpVertexShaderProgram[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xfd001f80, 0x900c2060, 0x0000803f, 0x00000000, - 0xc1a229f5, 0xd0eddc33, 0x426618fd, 0x8509cfe7 -}; + 0xc1a229f5, 0xd0eddc33, 0x426618fd, 0x8509cfe7}; static const uint32_t cpVertexShaderRegs[] = { 0x00000102, 0x00000000, 0x00000000, 0x00000001, @@ -52,8 +51,7 @@ static const uint32_t cpVertexShaderRegs[] = { 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, - 0x000000ff, 0x00000000, 0x0000000e, 0x00000010 -}; + 0x000000ff, 0x00000000, 0x0000000e, 0x00000010}; static const uint32_t cpPixelShaderProgram[] = { 0x20000000, 0x00003ca0, 0xa0000000, 0x000c8080, @@ -145,8 +143,7 @@ static const uint32_t cpPixelShaderProgram[] = { 0x10000400, 0x04101df0, 0x00008010, 0xecdfea0d, 0x10000500, 0x05101df0, 0x00000011, 0xecdfea0d, 0x10000100, 0x01101df0, 0x00008010, 0xecdfea0d, - 0xfe2e963a, 0x0269a9a3, 0x38f88096, 0x400cf48b -}; + 0xfe2e963a, 0x0269a9a3, 0x38f88096, 0x400cf48b}; static const uint32_t cpPixelShaderRegs[] = { 0x00000007, 0x00000002, 0x04000101, 0x00000000, 0x00000001, 0x00000100, 0x00000000, 0x00000000, @@ -158,37 +155,32 @@ static const uint32_t cpPixelShaderRegs[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x00000001, 0x00000010, - 0x00000000 -}; + 0x00000000}; FXAAShader *FXAAShader::shaderInstance = NULL; FXAAShader::FXAAShader() - : vertexShader(cuAttributeCount) { + : vertexShader(cuAttributeCount) { //! create pixel shader pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs)); resolutionLocation = 0; - pixelShader.addUniformVar((GX2UniformVar) { - "unf_resolution", GX2_SHADER_VAR_TYPE_FLOAT2, 1, resolutionLocation, -1 - }); + pixelShader.addUniformVar((GX2UniformVar){ + "unf_resolution", GX2_SHADER_VAR_TYPE_FLOAT2, 1, resolutionLocation, -1}); samplerLocation = 0; - pixelShader.addSamplerVar((GX2SamplerVar) { - "sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation - }); + pixelShader.addSamplerVar((GX2SamplerVar){ + "sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation}); //! create vertex shader vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); positionLocation = 0; texCoordLocation = 1; - vertexShader.addAttribVar((GX2AttribVar) { - "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation - }); - vertexShader.addAttribVar((GX2AttribVar) { - "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation - }); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation}); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation}); //! setup attribute streams GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32); @@ -198,11 +190,11 @@ FXAAShader::FXAAShader() fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount()); //! model vertex has to be align and cannot be in unknown regions for GX2 like 0xBCAE1000 - posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize); + posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize); texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize); //! position vertex structure and texture coordinate vertex structure - int32_t i = 0; + int32_t i = 0; posVtxs[i++] = -1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; @@ -217,7 +209,7 @@ FXAAShader::FXAAShader() posVtxs[i++] = 0.0f; GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize); - i = 0; + i = 0; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; diff --git a/source/video/shaders/Shader3D.cpp b/source/video/shaders/Shader3D.cpp index 8b77cdc..725871b 100644 --- a/source/video/shaders/Shader3D.cpp +++ b/source/video/shaders/Shader3D.cpp @@ -14,9 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ +#include #include #include -#include static const uint32_t cpVertexShaderProgram[] = { 0x00000000, 0x00008009, 0x20000000, 0x0000e4a1, @@ -108,8 +108,7 @@ static const uint32_t cpVertexShaderProgram[] = { 0x07c09f80, 0x7e048200, 0x07e00f00, 0xfe008220, 0x07cc1f01, 0x7e086a4f, 0x07c09f81, 0x7f0c8240, 0x07c08f80, 0xfe088260, 0x2c34800d, 0xe3b4f15e, - 0x7642ed30, 0x7408600d -}; + 0x7642ed30, 0x7408600d}; static const uint32_t cpVertexShaderRegs[] = { 0x00000108, 0x00000000, 0x00000002, 0x00000001, @@ -124,8 +123,7 @@ static const uint32_t cpVertexShaderRegs[] = { 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, - 0x000000ff, 0x00000000, 0x0000000e, 0x00000010 -}; + 0x000000ff, 0x00000000, 0x0000000e, 0x00000010}; static const uint32_t cPixelShaderProgram[] = { 0x20000000, 0x000008a4, 0x03000000, 0x01004085, @@ -169,8 +167,7 @@ static const uint32_t cPixelShaderProgram[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000100, 0x01100df0, 0x00008010, 0xecdfea0d, - 0x99720984, 0x041cab0d, 0xa28a9ccd, 0x95d199a5 -}; + 0x99720984, 0x041cab0d, 0xa28a9ccd, 0x95d199a5}; static const uint32_t cPixelShaderRegs[] = { 0x00000102, 0x00000002, 0x14000002, 0x00000000, 0x00000002, 0x00000100, 0x00000101, 0x00000000, @@ -182,57 +179,47 @@ static const uint32_t cPixelShaderRegs[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x00000001, 0x00000010, - 0x00000000 -}; + 0x00000000}; Shader3D *Shader3D::shaderInstance = NULL; Shader3D::Shader3D() - : vertexShader(cuAttributeCount) { + : vertexShader(cuAttributeCount) { //! create pixel shader pixelShader.setProgram(cPixelShaderProgram, sizeof(cPixelShaderProgram), cPixelShaderRegs, sizeof(cPixelShaderRegs)); colorIntensityLocation = 0; - fadeDistanceLocation = 4; - fadeOutLocation = 8; - pixelShader.addUniformVar((GX2UniformVar) { - "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1 - }); - pixelShader.addUniformVar((GX2UniformVar) { - "unf_fade_distance", GX2_SHADER_VAR_TYPE_FLOAT, 1, fadeDistanceLocation, -1 - }); - pixelShader.addUniformVar((GX2UniformVar) { - "unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1 - }); + fadeDistanceLocation = 4; + fadeOutLocation = 8; + pixelShader.addUniformVar((GX2UniformVar){ + "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1}); + pixelShader.addUniformVar((GX2UniformVar){ + "unf_fade_distance", GX2_SHADER_VAR_TYPE_FLOAT, 1, fadeDistanceLocation, -1}); + pixelShader.addUniformVar((GX2UniformVar){ + "unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1}); samplerLocation = 0; - pixelShader.addSamplerVar((GX2SamplerVar) { - "sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation - }); + pixelShader.addSamplerVar((GX2SamplerVar){ + "sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation}); //! create vertex shader vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); - modelMatrixLocation = 0; + modelMatrixLocation = 0; projectionMatrixLocation = 16; - viewMatrixLocation = 32; - vertexShader.addUniformVar((GX2UniformVar) { - "modelMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, modelMatrixLocation, -1 - }); - vertexShader.addUniformVar((GX2UniformVar) { - "viewMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, projectionMatrixLocation, -1 - }); - vertexShader.addUniformVar((GX2UniformVar) { - "projectionMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, viewMatrixLocation, -1 - }); + viewMatrixLocation = 32; + vertexShader.addUniformVar((GX2UniformVar){ + "modelMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, modelMatrixLocation, -1}); + vertexShader.addUniformVar((GX2UniformVar){ + "viewMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, projectionMatrixLocation, -1}); + vertexShader.addUniformVar((GX2UniformVar){ + "projectionMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, viewMatrixLocation, -1}); positionLocation = 0; texCoordLocation = 1; - vertexShader.addAttribVar((GX2AttribVar) { - "attr_position", GX2_SHADER_VAR_TYPE_FLOAT4, 0, positionLocation - }); - vertexShader.addAttribVar((GX2AttribVar) { - "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation - }); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_position", GX2_SHADER_VAR_TYPE_FLOAT4, 0, positionLocation}); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation}); //! setup attribute streams GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32); @@ -243,11 +230,11 @@ Shader3D::Shader3D() //! initialize default quad texture vertexes as those are very commonly used //! model vertex has to be align and cannot be in unknown regions for GX2 like 0xBCAE1000 - posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize); + posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize); texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize); //! position vertex structure and texture coordinate vertex structure - int32_t i = 0; + int32_t i = 0; posVtxs[i++] = -1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; @@ -262,7 +249,7 @@ Shader3D::Shader3D() posVtxs[i++] = 0.0f; GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize); - i = 0; + i = 0; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; diff --git a/source/video/shaders/ShaderFractalColor.cpp b/source/video/shaders/ShaderFractalColor.cpp index 0a4d3ce..d457cd9 100644 --- a/source/video/shaders/ShaderFractalColor.cpp +++ b/source/video/shaders/ShaderFractalColor.cpp @@ -14,9 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ +#include #include #include -#include static const uint32_t cpVertexShaderProgram[] = { 0x00000000, 0x00008009, 0x20000000, 0x0000eca1, @@ -106,8 +106,7 @@ static const uint32_t cpVertexShaderProgram[] = { 0x02c41f01, 0x06086a4f, 0x02c49f01, 0x060c6a6f, 0x02e00f80, 0xfe000220, 0x02c08f00, 0xfe040200, 0x02e08f01, 0xfe0c0240, 0x02c01f80, 0xfe080260, - 0x8aa480ad, 0x2bfc5ca6, 0xb5e05b5b, 0xd48dc71c -}; + 0x8aa480ad, 0x2bfc5ca6, 0xb5e05b5b, 0xd48dc71c}; static const uint32_t cpVertexShaderRegs[] = { 0x00000108, 0x00000000, 0x00000004, 0x00000001, @@ -122,8 +121,7 @@ static const uint32_t cpVertexShaderRegs[] = { 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, - 0x000000ff, 0x00000000, 0x0000000e, 0x00000010 -}; + 0x000000ff, 0x00000000, 0x0000000e, 0x00000010}; static const uint32_t cpPixelShaderProgram[] = { 0x20000000, 0x000008a4, 0x04000000, 0x01004085, @@ -262,8 +260,7 @@ static const uint32_t cpPixelShaderProgram[] = { 0x01c49f80, 0x90000020, 0x0000803f, 0x00000000, 0x7fcc9f80, 0xf880630f, 0xfe20a081, 0x80000000, 0x01cc1f80, 0x90000060, 0xc21e82a7, 0x62ccc547, - 0x1708607c, 0x73ea57a6 -}; + 0x1708607c, 0x73ea57a6}; static const uint32_t cpPixelShaderRegs[] = { 0x00000106, 0x00000002, 0x14000003, 0x00000000, 0x00000003, 0x00000100, 0x00000101, 0x00000102, @@ -275,60 +272,49 @@ static const uint32_t cpPixelShaderRegs[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x00000001, 0x00000010, - 0x00000000 -}; + 0x00000000}; ShaderFractalColor *ShaderFractalColor::shaderInstance = NULL; ShaderFractalColor::ShaderFractalColor() - : vertexShader(cuAttributeCount) { + : vertexShader(cuAttributeCount) { //! create pixel shader pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs)); - blurLocation = 0; + blurLocation = 0; colorIntensityLocation = 4; - fadeOutLocation = 8; - fractalLocation = 12; - pixelShader.addUniformVar((GX2UniformVar) { - "unf_blur_border", GX2_SHADER_VAR_TYPE_FLOAT, 1, blurLocation, -1 - }); - pixelShader.addUniformVar((GX2UniformVar) { - "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1 - }); - pixelShader.addUniformVar((GX2UniformVar) { - "unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1 - }); - pixelShader.addUniformVar((GX2UniformVar) { - "unf_fract_alpha", GX2_SHADER_VAR_TYPE_INT, 1, fractalLocation, -1 - }); + fadeOutLocation = 8; + fractalLocation = 12; + pixelShader.addUniformVar((GX2UniformVar){ + "unf_blur_border", GX2_SHADER_VAR_TYPE_FLOAT, 1, blurLocation, -1}); + pixelShader.addUniformVar((GX2UniformVar){ + "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1}); + pixelShader.addUniformVar((GX2UniformVar){ + "unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1}); + pixelShader.addUniformVar((GX2UniformVar){ + "unf_fract_alpha", GX2_SHADER_VAR_TYPE_INT, 1, fractalLocation, -1}); //! create vertex shader vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); - modelMatrixLocation = 0; + modelMatrixLocation = 0; projectionMatrixLocation = 16; - viewMatrixLocation = 32; - vertexShader.addUniformVar((GX2UniformVar) { - "modelMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, modelMatrixLocation, -1 - }); - vertexShader.addUniformVar((GX2UniformVar) { - "projectionMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, projectionMatrixLocation, -1 - }); - vertexShader.addUniformVar((GX2UniformVar) { - "viewMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, viewMatrixLocation, -1 - }); + viewMatrixLocation = 32; + vertexShader.addUniformVar((GX2UniformVar){ + "modelMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, modelMatrixLocation, -1}); + vertexShader.addUniformVar((GX2UniformVar){ + "projectionMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, projectionMatrixLocation, -1}); + vertexShader.addUniformVar((GX2UniformVar){ + "viewMatrix", GX2_SHADER_VAR_TYPE_FLOAT4X4, 1, viewMatrixLocation, -1}); positionLocation = 0; - colorLocation = 1; + colorLocation = 1; texCoordLocation = 2; - vertexShader.addAttribVar((GX2AttribVar) { - "attr_colors", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation - }); - vertexShader.addAttribVar((GX2AttribVar) { - "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation - }); - vertexShader.addAttribVar((GX2AttribVar) { - "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation - }); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_colors", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation}); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation}); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation}); //! setup attribute streams GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32); @@ -340,12 +326,12 @@ ShaderFractalColor::ShaderFractalColor() //! initialize default quad texture vertexes as those are very commonly used //! model vertex has to be align and cannot be in unknown regions for GX2 like 0xBCAE1000 - posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize); + posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize); texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize); colorVtxs = (uint8_t *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciColorVtxsSize); //! position vertex structure and texture coordinate vertex structure - int32_t i = 0; + int32_t i = 0; posVtxs[i++] = -1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; @@ -360,7 +346,7 @@ ShaderFractalColor::ShaderFractalColor() posVtxs[i++] = 0.0f; GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize); - i = 0; + i = 0; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; diff --git a/source/video/shaders/Texture2DShader.cpp b/source/video/shaders/Texture2DShader.cpp index 32837ed..8a51003 100644 --- a/source/video/shaders/Texture2DShader.cpp +++ b/source/video/shaders/Texture2DShader.cpp @@ -14,9 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ +#include #include #include -#include static const uint32_t cpVertexShaderProgram[] = { 0x00000000, 0x00008009, 0x20000000, 0x000080a0, @@ -52,8 +52,7 @@ static const uint32_t cpVertexShaderProgram[] = { 0x02c11f80, 0x80000040, 0x01e08f00, 0xfe04624f, 0x01c01f81, 0x7f08626f, 0xfe2c2000, 0x10004000, 0xfe28a080, 0x10004020, 0xeb825790, 0xb6f711be, - 0x7c0e2df2, 0x81173cfa -}; + 0x7c0e2df2, 0x81173cfa}; static const uint32_t cpVertexShaderRegs[] = { 0x00000103, 0x00000000, 0x00000000, 0x00000001, @@ -68,8 +67,7 @@ static const uint32_t cpVertexShaderRegs[] = { 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, - 0x000000ff, 0x00000000, 0x0000000e, 0x00000010 -}; + 0x000000ff, 0x00000000, 0x0000000e, 0x00000010}; static const uint32_t cPixelShaderProgram[] = { 0x20000000, 0x00000ca4, 0x0b000000, 0x00000085, @@ -176,8 +174,7 @@ static const uint32_t cPixelShaderProgram[] = { 0x10000400, 0x04100df0, 0x00008010, 0xecdfea0d, 0x10000300, 0x06100df0, 0x00008010, 0xecdfea0d, 0x10000000, 0x00100df0, 0x00008010, 0xecdfea0d, - 0xc8581837, 0x22740275, 0x281eddcc, 0xfa8b9b65 -}; + 0xc8581837, 0x22740275, 0x281eddcc, 0xfa8b9b65}; static const uint32_t cPixelShaderRegs[] = { 0x00000109, 0x00000002, 0x14000001, 0x00000000, 0x00000001, 0x00000100, 0x00000000, 0x00000000, @@ -189,54 +186,45 @@ static const uint32_t cPixelShaderRegs[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x00000001, 0x00000010, - 0x00000000 -}; + 0x00000000}; Texture2DShader *Texture2DShader::shaderInstance = NULL; Texture2DShader::Texture2DShader() - : vertexShader(cuAttributeCount) { + : vertexShader(cuAttributeCount) { //! create pixel shader pixelShader.setProgram(cPixelShaderProgram, sizeof(cPixelShaderProgram), cPixelShaderRegs, sizeof(cPixelShaderRegs)); - blurLocation = 0; + blurLocation = 0; colorIntensityLocation = 4; - pixelShader.addUniformVar((GX2UniformVar) { - "unf_blur_texture_direction", GX2_SHADER_VAR_TYPE_FLOAT3, 1, blurLocation, -1 - }); - pixelShader.addUniformVar((GX2UniformVar) { - "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1 - }); + pixelShader.addUniformVar((GX2UniformVar){ + "unf_blur_texture_direction", GX2_SHADER_VAR_TYPE_FLOAT3, 1, blurLocation, -1}); + pixelShader.addUniformVar((GX2UniformVar){ + "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1}); samplerLocation = 0; - pixelShader.addSamplerVar((GX2SamplerVar) { - "sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation - }); + pixelShader.addSamplerVar((GX2SamplerVar){ + "sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation}); //! create vertex shader vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); - angleLocation = 0; + angleLocation = 0; offsetLocation = 4; - scaleLocation = 8; - vertexShader.addUniformVar((GX2UniformVar) { - "unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1 - }); - vertexShader.addUniformVar((GX2UniformVar) { - "unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1 - }); - vertexShader.addUniformVar((GX2UniformVar) { - "unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1 - }); + scaleLocation = 8; + vertexShader.addUniformVar((GX2UniformVar){ + "unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1}); + vertexShader.addUniformVar((GX2UniformVar){ + "unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1}); + vertexShader.addUniformVar((GX2UniformVar){ + "unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1}); positionLocation = 0; texCoordLocation = 1; - vertexShader.addAttribVar((GX2AttribVar) { - "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation - }); - vertexShader.addAttribVar((GX2AttribVar) { - "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation - }); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation}); + vertexShader.addAttribVar((GX2AttribVar){ + "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation}); //! setup attribute streams GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32); @@ -246,12 +234,12 @@ Texture2DShader::Texture2DShader() fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount()); //! model vertex has to be align and cannot be in unknown regions for GX2 like 0xBCAE1000 - posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize); + posVtxs = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciPositionVtxsSize); texCoords = (float *) memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize); //! defaults for normal square //! position vertex structure and texture coordinate vertex structure - int32_t i = 0; + int32_t i = 0; posVtxs[i++] = -1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; @@ -266,7 +254,7 @@ Texture2DShader::Texture2DShader() posVtxs[i++] = 0.0f; GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize); - i = 0; + i = 0; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f;