diff --git a/ion/src/simulator/shared/crc32.cpp b/ion/src/simulator/shared/crc32.cpp index 0fdfd3f6a..04718ea71 100644 --- a/ion/src/simulator/shared/crc32.cpp +++ b/ion/src/simulator/shared/crc32.cpp @@ -1,28 +1,32 @@ #include -uint32_t crc32Helper(const uint8_t * data, size_t length, bool wordAccess) { +namespace Ion { + +static uint32_t crc32Helper(const uint8_t * data, size_t length, bool wordAccess) { size_t uint32ByteLength = sizeof(uint32_t)/sizeof(uint8_t); uint32_t crc = 0xFFFFFFFF; size_t byteLength = (wordAccess ? length * uint32ByteLength : length); size_t wordLength = byteLength / uint32ByteLength; - for (int i = 0; i < (int)wordLength; i++) { + for (int i = 0; i < wordLength; i++) { // FIXME: Assumes little-endian byte order! for (int j = uint32ByteLength-1; j >= 0; j--) { // scan byte by byte to avoid alignment issue when building for emscripten platform - crc = Ion::crc32EatByte(crc, data[i*uint32ByteLength+j]); + crc = crc32EatByte(crc, data[i*uint32ByteLength+j]); } } - for (int i = (int) wordLength * uint32ByteLength; i < byteLength; i++) { - crc = Ion::crc32EatByte(crc, data[i]); + for (int i = wordLength * uint32ByteLength; i < byteLength; i++) { + crc = crc32EatByte(crc, data[i]); } return crc; } -uint32_t Ion::crc32Word(const uint32_t * data, size_t length) { - return crc32Helper((const uint8_t *) data, length, true); +uint32_t crc32Word(const uint32_t * data, size_t length) { + return crc32Helper(reinterpret_cast(data), length, true); } -uint32_t Ion::crc32Byte(const uint8_t * data, size_t length) { +uint32_t crc32Byte(const uint8_t * data, size_t length) { return crc32Helper(data, length, false); } + +} diff --git a/ion/src/simulator/shared/events_platform.cpp b/ion/src/simulator/shared/events_platform.cpp index 8dfc68671..8eb5b894a 100644 --- a/ion/src/simulator/shared/events_platform.cpp +++ b/ion/src/simulator/shared/events_platform.cpp @@ -19,8 +19,8 @@ static inline Event eventFromSDLKeyboardEvent(SDL_KeyboardEvent event) { /* If an event is detected, we want to remove the Shift modifier to mimic the * device behaviour. If no event was detected, we restore the previous * ShiftAlphaStatus. */ - Ion::Events::ShiftAlphaStatus previousShiftAlphaStatus = Ion::Events::shiftAlphaStatus(); - Ion::Events::removeShift(); + ShiftAlphaStatus previousShiftAlphaStatus = shiftAlphaStatus(); + removeShift(); if (event.keysym.mod & (KMOD_CTRL|KMOD_GUI)) { switch (event.keysym.sym) { @@ -87,7 +87,7 @@ static inline Event eventFromSDLKeyboardEvent(SDL_KeyboardEvent event) { return Termination; } // No event was detected, restore the previous ShiftAlphaStatus. - Ion::Events::setShiftAlphaStatus(previousShiftAlphaStatus); + setShiftAlphaStatus(previousShiftAlphaStatus); return None; } @@ -116,7 +116,7 @@ static Event eventFromSDLTextInputEvent(SDL_TextInputEvent event) { * then we press "&", transformed by eventFromSDLTextInputEvent into the * text "1". If we do not remove the Shift here, it would still be * pressed afterwards. */ - Ion::Events::removeShift(); + Events::removeShift(); Event res = sEventForASCIICharAbove32[character-32]; if (res != None) { return res; @@ -133,7 +133,7 @@ Event getPlatformEvent() { Event result = None; while (SDL_PollEvent(&event)) { // That "while" is important: it'll do a fast-pass over all useless SDL events if (event.type == SDL_WINDOWEVENT) { - Ion::Simulator::Window::relayout(); + Simulator::Window::relayout(); break; } if (event.type == SDL_QUIT) { diff --git a/ion/src/simulator/shared/framebuffer.cpp b/ion/src/simulator/shared/framebuffer.cpp index 714f3f3c8..eb5a25fff 100644 --- a/ion/src/simulator/shared/framebuffer.cpp +++ b/ion/src/simulator/shared/framebuffer.cpp @@ -19,7 +19,7 @@ static bool sFrameBufferActive = false; namespace Ion { namespace Display { -static KDFrameBuffer sFrameBuffer = KDFrameBuffer(sPixels, KDSize(Ion::Display::Width, Ion::Display::Height)); +static KDFrameBuffer sFrameBuffer = KDFrameBuffer(sPixels, KDSize(Width, Height)); void pushRect(KDRect r, const KDColor * pixels) { if (sFrameBufferActive) { diff --git a/ion/src/simulator/shared/journal.cpp b/ion/src/simulator/shared/journal.cpp index 8677fb40c..4dd532133 100644 --- a/ion/src/simulator/shared/journal.cpp +++ b/ion/src/simulator/shared/journal.cpp @@ -27,15 +27,15 @@ private: }; void init() { - Ion::Events::logTo(logJournal()); + Events::logTo(logJournal()); } -Ion::Events::Journal * replayJournal() { +Events::Journal * replayJournal() { static Journal journal; return &journal; } -Ion::Events::Journal * logJournal() { +Events::Journal * logJournal() { static Journal journal; return &journal; } diff --git a/ion/src/simulator/shared/keyboard.cpp b/ion/src/simulator/shared/keyboard.cpp index 9a3849f4e..9113c8b90 100644 --- a/ion/src/simulator/shared/keyboard.cpp +++ b/ion/src/simulator/shared/keyboard.cpp @@ -5,32 +5,34 @@ #include #include -static Ion::Keyboard::State sKeyboardState; +using namespace Ion::Keyboard; + +static State sKeyboardState; class KeySDLKeyPair { public: - constexpr KeySDLKeyPair(Ion::Keyboard::Key key, SDL_Scancode SDLKey) : + constexpr KeySDLKeyPair(Key key, SDL_Scancode SDLKey) : m_key(key), m_SDLKey(SDLKey) {} - Ion::Keyboard::Key key() const { return m_key; } + Key key() const { return m_key; } SDL_Scancode SDLKey() const { return m_SDLKey; } private: - Ion::Keyboard::Key m_key; + Key m_key; SDL_Scancode m_SDLKey; }; constexpr static KeySDLKeyPair sKeyPairs[] = { - KeySDLKeyPair(Ion::Keyboard::Key::Down, SDL_SCANCODE_DOWN), - KeySDLKeyPair(Ion::Keyboard::Key::Up, SDL_SCANCODE_UP), - KeySDLKeyPair(Ion::Keyboard::Key::Left, SDL_SCANCODE_LEFT), - KeySDLKeyPair(Ion::Keyboard::Key::Right, SDL_SCANCODE_RIGHT), - KeySDLKeyPair(Ion::Keyboard::Key::Shift, SDL_SCANCODE_LSHIFT), - KeySDLKeyPair(Ion::Keyboard::Key::Shift, SDL_SCANCODE_RSHIFT), - KeySDLKeyPair(Ion::Keyboard::Key::EXE, SDL_SCANCODE_RETURN), - KeySDLKeyPair(Ion::Keyboard::Key::Back, SDL_SCANCODE_ESCAPE), - KeySDLKeyPair(Ion::Keyboard::Key::Toolbox, SDL_SCANCODE_TAB), - KeySDLKeyPair(Ion::Keyboard::Key::Backspace, SDL_SCANCODE_BACKSPACE) + KeySDLKeyPair(Key::Down, SDL_SCANCODE_DOWN), + KeySDLKeyPair(Key::Up, SDL_SCANCODE_UP), + KeySDLKeyPair(Key::Left, SDL_SCANCODE_LEFT), + KeySDLKeyPair(Key::Right, SDL_SCANCODE_RIGHT), + KeySDLKeyPair(Key::Shift, SDL_SCANCODE_LSHIFT), + KeySDLKeyPair(Key::Shift, SDL_SCANCODE_RSHIFT), + KeySDLKeyPair(Key::EXE, SDL_SCANCODE_RETURN), + KeySDLKeyPair(Key::Back, SDL_SCANCODE_ESCAPE), + KeySDLKeyPair(Key::Toolbox, SDL_SCANCODE_TAB), + KeySDLKeyPair(Key::Backspace, SDL_SCANCODE_BACKSPACE) }; constexpr int sNumberOfKeyPairs = sizeof(sKeyPairs)/sizeof(KeySDLKeyPair); diff --git a/ion/src/simulator/shared/platform_action_modifier_ctrl.cpp b/ion/src/simulator/shared/platform_action_modifier_ctrl.cpp deleted file mode 100644 index 9f6c3a3f2..000000000 --- a/ion/src/simulator/shared/platform_action_modifier_ctrl.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "../shared/platform.h" - -namespace Ion { -namespace Simulator { -namespace Platform { - -SDL_Keymod actionModifier() { - return static_cast(KMOD_CTRL); -} - -} -} -} diff --git a/ion/src/simulator/shared/platform_action_modifier_gui.cpp b/ion/src/simulator/shared/platform_action_modifier_gui.cpp deleted file mode 100644 index b9f3021ad..000000000 --- a/ion/src/simulator/shared/platform_action_modifier_gui.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "../shared/platform.h" - -namespace Ion { -namespace Simulator { -namespace Platform { - -SDL_Keymod actionModifier() { - return KMOD_GUI; -} - -} -} -}