Skip to content

Commit

Permalink
Clang-format all source code
Browse files Browse the repository at this point in the history
  • Loading branch information
polldo committed Mar 4, 2022
1 parent 50aa271 commit eadd61b
Show file tree
Hide file tree
Showing 51 changed files with 1,309 additions and 1,153 deletions.
6 changes: 3 additions & 3 deletions src/dolp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ void Dolp::deleteEntity(PEntity entity)
}

// TODO
//void Dolp::clear()
// void Dolp::clear()
//{
//// Clear the world
//// Clear all the drivers' state: timeouts, notes...
//// Clear the world
//// Clear all the drivers' state: timeouts, notes...
//}

Dolp dolp;
3 changes: 2 additions & 1 deletion src/dolp.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#define GAME_LOOP_BEGIN (dolp.loopBegin)
#define GAME_LOOP_END (dolp.loopEnd)

class Dolp {
class Dolp
{
public:
Dolp() {}
virtual ~Dolp() {}
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ void Display::draw(uint8_t x, uint8_t y, DisplayColor color)
hwDisplayDraw(x, y, color);
}

void Display::drawImage(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t* image)
void Display::drawImage(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *image)
{
hwDisplayDrawImage(x, y, w, h, image);
}

void Display::drawImage(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t* image)
void Display::drawImage(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t *image)
{
hwDisplayDrawImage(x, y, w, h, image);
}
Expand Down
7 changes: 4 additions & 3 deletions src/drivers/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <Common.h>
#include "hardware/HwDisplay.h"

class Display {
class Display
{
public:
Display();
virtual ~Display();
Expand All @@ -14,8 +15,8 @@ class Display {
void send();

void draw(uint8_t x, uint8_t y, DisplayColor color);
void drawImage(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t* image);
void drawImage(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t* image);
void drawImage(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *image);
void drawImage(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t *image);
void drawRectangle(uint8_t x, uint8_t y, uint8_t width, uint8_t height, DisplayColor color);
void fill(DisplayColor color);

Expand Down
3 changes: 2 additions & 1 deletion src/drivers/DriverLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ extern Joystick joystick;
extern NotePlayer notePlayer;
extern Timer timer;

class DriverLayer {
class DriverLayer
{
public:
DriverLayer();
virtual ~DriverLayer();
Expand Down
9 changes: 4 additions & 5 deletions src/drivers/Joystick.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#include <drivers/Joystick.h>
#include <hardware/HwJoystick.h>

Joystick::Joystick() :
_buttonStateOld(0x00),
_buttonPressed(0x00)
Joystick::Joystick() : _buttonStateOld(0x00),
_buttonPressed(0x00)
{
}

Joystick::~Joystick()
Joystick::~Joystick()
{
}

Expand All @@ -23,7 +22,7 @@ void Joystick::update()
ButtonStateType buttonStateCurrent = hwJoystickState();
/* Check whether some button has been pressed */
_buttonPressed = (_buttonStateOld ^ buttonStateCurrent) & (buttonStateCurrent ^ 0x00);
/* Update old button values */
/* Update old button values */
_buttonStateOld = buttonStateCurrent;
}

Expand Down
3 changes: 2 additions & 1 deletion src/drivers/Joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <Common.h>
#include "hardware/HwJoystick.h"

class Joystick {
class Joystick
{
public:
Joystick();
virtual ~Joystick();
Expand Down
12 changes: 6 additions & 6 deletions src/drivers/NotePlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <drivers/NotePlayer.h>
#include <hardware/HwNotePlayer.h>

NotePlayer::NotePlayer()
NotePlayer::NotePlayer()
{
}

NotePlayer::~NotePlayer()
NotePlayer::~NotePlayer()
{
}

Expand All @@ -19,28 +19,28 @@ void NotePlayer::stop()
hwNotePlayerStop();
}

void NotePlayer::play(Song &song)
void NotePlayer::play(Song &song)
{
hwNotePlayerStop();
hwNotePlayerSong(song.notes, song.size, 0, false);
hwNotePlayerStart();
}

void NotePlayer::play(Song &song, uint16_t startIndex)
void NotePlayer::play(Song &song, uint16_t startIndex)
{
hwNotePlayerStop();
hwNotePlayerSong(song.notes, song.size, startIndex, false);
hwNotePlayerStart();
}

void NotePlayer::play(Song &song, bool loopEn)
void NotePlayer::play(Song &song, bool loopEn)
{
hwNotePlayerStop();
hwNotePlayerSong(song.notes, song.size, 0, loopEn);
hwNotePlayerStart();
}

void NotePlayer::play(Song &song, uint16_t startIndex, bool loopEn)
void NotePlayer::play(Song &song, uint16_t startIndex, bool loopEn)
{
hwNotePlayerStop();
hwNotePlayerSong(song.notes, song.size, startIndex, loopEn);
Expand Down
3 changes: 2 additions & 1 deletion src/drivers/NotePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <Common.h>
#include "hardware/HwNotePlayer.h"

class NotePlayer {
class NotePlayer
{
public:
NotePlayer();
virtual ~NotePlayer();
Expand Down
50 changes: 31 additions & 19 deletions src/drivers/Timer.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include <drivers/Timer.h>
#include <hardware/HwRefresh.h>

Timer::Timer() :
_tick(0),
_secTick(0),
_seconds(0)
Timer::Timer() : _tick(0),
_secTick(0),
_seconds(0)
{
for (int i = 0; i < NUM_TIMEOUTS; i++) {
for (int i = 0; i < NUM_TIMEOUTS; i++)
{
_timeouts[i].startTicks = 0;
_timeouts[i].ticks = 0;
_timeouts[i].assigned = false;
_timeouts[i].reset = false;
}
}
}

Timer::~Timer()
Expand Down Expand Up @@ -40,7 +40,8 @@ void Timer::waitEndFrame()
// Update ticks and time counters
++_tick;
_milliseconds += FRAME_MSEC;
if (++_secTick == FPS) {
if (++_secTick == FPS)
{
_secTick = 0;
++_seconds;
}
Expand All @@ -51,8 +52,10 @@ void Timer::waitEndFrame()
TimeoutId Timer::newTimeout()
{
// Timeout 0 is reserved
for (int i = 1; i < NUM_TIMEOUTS; i++) {
if (!_timeouts[i].assigned) {
for (int i = 1; i < NUM_TIMEOUTS; i++)
{
if (!_timeouts[i].assigned)
{
_timeouts[i].assigned = true;
_timeouts[i].reset = false;
return i;
Expand All @@ -64,8 +67,10 @@ TimeoutId Timer::newTimeout()
TimeoutId Timer::newTimeout(uint64_t time)
{
// Timeout 0 is reserved
for (int i = 1; i < NUM_TIMEOUTS; i++) {
if (!_timeouts[i].assigned) {
for (int i = 1; i < NUM_TIMEOUTS; i++)
{
if (!_timeouts[i].assigned)
{
_timeouts[i].startTicks = time / FRAME_MSEC + 1;
_timeouts[i].ticks = _timeouts[i].startTicks;
_timeouts[i].assigned = true;
Expand All @@ -78,7 +83,8 @@ TimeoutId Timer::newTimeout(uint64_t time)

void Timer::deleteTimeout(TimeoutId id)
{
if (_timeouts[id].assigned) {
if (_timeouts[id].assigned)
{
_timeouts[id].ticks = 0;
_timeouts[id].startTicks = 0;
_timeouts[id].assigned = false;
Expand All @@ -88,13 +94,17 @@ void Timer::deleteTimeout(TimeoutId id)

void Timer::updateTimeout()
{
for (int i = 1; i < NUM_TIMEOUTS; i++) {
if (_timeouts[i].assigned) {
for (int i = 1; i < NUM_TIMEOUTS; i++)
{
if (_timeouts[i].assigned)
{

if (_timeouts[i].ticks > 1) {
if (_timeouts[i].ticks > 1)
{
_timeouts[i].ticks -= 1;

} else if ( (_timeouts[i].ticks == 1) && _timeouts[i].reset) {
}
else if ((_timeouts[i].ticks == 1) && _timeouts[i].reset)
{
_timeouts[i].ticks = _timeouts[i].startTicks;
_timeouts[i].reset = false;
}
Expand All @@ -104,7 +114,8 @@ void Timer::updateTimeout()

void Timer::setTimeout(TimeoutId id, uint64_t time)
{
if (_timeouts[id].assigned) {
if (_timeouts[id].assigned)
{
_timeouts[id].startTicks = time / FRAME_MSEC + 1;
_timeouts[id].ticks = _timeouts[id].startTicks;
_timeouts[id].reset = false;
Expand All @@ -114,7 +125,8 @@ void Timer::setTimeout(TimeoutId id, uint64_t time)
bool Timer::checkTimeout(TimeoutId id)
{
bool ret = (_timeouts[id].ticks == 1);
if (ret) {
if (ret)
{
_timeouts[id].reset = true;
}
return ret;
Expand Down
6 changes: 4 additions & 2 deletions src/drivers/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#define NUM_TIMEOUTS 200
#endif

struct Timeout {
struct Timeout
{
// Timeout id corresponds to its index in _timeouts array
// Id 0 is reserved
uint8_t startTicks;
Expand All @@ -18,7 +19,8 @@ struct Timeout {

typedef uint8_t TimeoutId;

class Timer {
class Timer
{
public:
Timer();
virtual ~Timer();
Expand Down
13 changes: 7 additions & 6 deletions src/engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

#include "drivers/DriverLayer.h"

Engine::Engine() :
_world(NULL)
Engine::Engine() : _world(NULL)
{
}

Expand All @@ -18,23 +17,25 @@ void Engine::setup()
void Engine::loopBegin()
{
// Update world
if (_world) {
if (_world)
{
_world->update();
}
}

void Engine::loopEnd()
{
// Draw world
//clearDisplay();
// clearDisplay();
display.fill(BLACK_COLOR);
if (_world) {
if (_world)
{
_world->render();
}
}

// setActiveWorld
void Engine::setWorld(World& world)
void Engine::setWorld(World &world)
{
_world = &world;
}
Expand Down
21 changes: 11 additions & 10 deletions src/engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
#include "Entity.h"
#include "World.h"

class Engine {
public:
Engine();
~Engine();
class Engine
{
public:
Engine();
~Engine();

void setup();
void loopBegin();
void loopEnd();
void setup();
void loopBegin();
void loopEnd();

void setWorld(World& world);
void setWorld(World &world);

private:
World* _world;
private:
World *_world;
};

extern Engine engine;
Expand Down
Loading

0 comments on commit eadd61b

Please sign in to comment.