aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorThomas Edvalson2016-04-19 03:22:32 -0400
committerThomas Edvalson2016-04-19 03:22:32 -0400
commite8dcfc3a4efeeaffad0380e88223fabbc12e1423 (patch)
treefe58902ccbc752cb44c60e51b6704255b48df64a /backends/platform
parent1ea737bbd87b27c1acf068f20845611a44adb98d (diff)
downloadscummvm-rg350-e8dcfc3a4efeeaffad0380e88223fabbc12e1423.tar.gz
scummvm-rg350-e8dcfc3a4efeeaffad0380e88223fabbc12e1423.tar.bz2
scummvm-rg350-e8dcfc3a4efeeaffad0380e88223fabbc12e1423.zip
3DS: Fix code styling, add license header, remove unused portdefs.h
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/3ds/osystem-audio.cpp16
-rw-r--r--backends/platform/3ds/osystem-events.cpp41
-rw-r--r--backends/platform/3ds/osystem-graphics.cpp22
-rw-r--r--backends/platform/3ds/osystem.cpp73
-rw-r--r--backends/platform/3ds/portdefs.h28
-rw-r--r--backends/platform/3ds/shader.v.pica21
-rw-r--r--backends/platform/3ds/sprite.cpp28
7 files changed, 106 insertions, 123 deletions
diff --git a/backends/platform/3ds/osystem-audio.cpp b/backends/platform/3ds/osystem-audio.cpp
index 7e4822b8e9..da74ab6d8a 100644
--- a/backends/platform/3ds/osystem-audio.cpp
+++ b/backends/platform/3ds/osystem-audio.cpp
@@ -25,9 +25,9 @@
static bool hasAudio = false;
-static void audioThreadFunc(void* arg) {
- Audio::MixerImpl *mixer = (Audio::MixerImpl *) arg;
- OSystem_3DS *osys = (OSystem_3DS*)g_system;
+static void audioThreadFunc(void *arg) {
+ Audio::MixerImpl *mixer = (Audio::MixerImpl *)arg;
+ OSystem_3DS *osys = (OSystem_3DS *)g_system;
int i;
const int channel = 0;
@@ -40,7 +40,7 @@ static void audioThreadFunc(void* arg) {
uint32 time = lastTime;
ndspWaveBuf buffers[bufferCount];
- for(i = 0; i < bufferCount; ++i) {
+ for (i = 0; i < bufferCount; ++i) {
memset(&buffers[i], 0, sizeof(ndspWaveBuf));
buffers[i].data_vaddr = linearAlloc(bufferSize);
buffers[i].looping = false;
@@ -52,7 +52,7 @@ static void audioThreadFunc(void* arg) {
ndspChnSetRate(channel, sampleRate);
ndspChnSetFormat(channel, NDSP_FORMAT_STEREO_PCM16);
- while(!osys->exiting) {
+ while (!osys->exiting) {
osys->delayMillis(100); // Note: Increasing the delay requires a bigger buffer
time = osys->getMillis(true);
@@ -62,7 +62,7 @@ static void audioThreadFunc(void* arg) {
if (!osys->sleeping && sampleLen > 0) {
bufferIndex++;
bufferIndex %= bufferCount;
- ndspWaveBuf* buf = &buffers[bufferIndex];
+ ndspWaveBuf *buf = &buffers[bufferIndex];
buf->nsamples = mixer->mixCallback(buf->data_adpcm, sampleLen);
if (buf->nsamples > 0) {
@@ -72,7 +72,7 @@ static void audioThreadFunc(void* arg) {
}
}
- for(i = 0; i < bufferCount; ++i)
+ for (i = 0; i < bufferCount; ++i)
linearFree(buffers[i].data_pcm8);
}
@@ -85,7 +85,7 @@ void OSystem_3DS::initAudio() {
if (hasAudio) {
s32 prio = 0;
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
- audioThread = threadCreate(&audioThreadFunc, _mixer, 32*1048, prio-1, -2, false);
+ audioThread = threadCreate(&audioThreadFunc, _mixer, 32 * 1048, prio - 1, -2, false);
}
}
diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp
index 46efdd3b7a..5135e3ac1b 100644
--- a/backends/platform/3ds/osystem-events.cpp
+++ b/backends/platform/3ds/osystem-events.cpp
@@ -20,30 +20,29 @@
*
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "backends/timer/default/default-timer.h"
-#include "backends/platform/3ds/gui.h"
+#include "gui.h"
#include "osystem.h"
static Common::Mutex *eventMutex;
static InputMode inputMode = MODE_DRAG;
static aptHookCookie cookie;
-static void pushEventQueue(Common::Queue<Common::Event>* queue, Common::Event& event) {
+static void pushEventQueue(Common::Queue<Common::Event> *queue, Common::Event &event) {
Common::StackLock lock(*eventMutex);
queue->push(event);
}
-static void eventThreadFunc(void* arg) {
- OSystem_3DS* osys = (OSystem_3DS*) g_system;
- auto eventQueue = (Common::Queue<Common::Event>*) arg;
+static void eventThreadFunc(void *arg) {
+ OSystem_3DS *osys = (OSystem_3DS *)g_system;
+ auto eventQueue = (Common::Queue<Common::Event> *)arg;
uint32 touchStartTime = osys->getMillis();
- touchPosition lastTouch = {0,0};
+ touchPosition lastTouch = {0, 0};
bool isRightClick = false;
Common::Event event;
- while(!osys->exiting) {
+ while (!osys->exiting) {
do {
osys->delayMillis(10);
} while (osys->sleeping && !osys->exiting);
@@ -69,23 +68,19 @@ static void eventThreadFunc(void* arg) {
event.type = isRightClick ? Common::EVENT_RBUTTONDOWN : Common::EVENT_LBUTTONDOWN;
pushEventQueue(eventQueue, event);
}
- }
- else if (touch.px != lastTouch.px || touch.py != lastTouch.py) {
+ } else if (touch.px != lastTouch.px || touch.py != lastTouch.py) {
event.type = Common::EVENT_MOUSEMOVE;
pushEventQueue(eventQueue, event);
}
lastTouch = touch;
- }
- else if (keysReleased & KEY_TOUCH) {
+ } else if (keysReleased & KEY_TOUCH) {
event.mouse.x = lastTouch.px;
event.mouse.y = lastTouch.py;
- printf("clicked %u, %u\n", lastTouch.px, lastTouch.py);
if (inputMode == MODE_DRAG) {
event.type = isRightClick ? Common::EVENT_RBUTTONUP : Common::EVENT_LBUTTONUP;
pushEventQueue(eventQueue, event);
- }
- else if (osys->getMillis() - touchStartTime < 200) {
+ } else if (osys->getMillis() - touchStartTime < 200) {
// Process click in MODE_HOVER
event.type = Common::EVENT_MOUSEMOVE;
pushEventQueue(eventQueue, event);
@@ -144,15 +139,15 @@ static void eventThreadFunc(void* arg) {
event.kbd.flags = 0;
pushEventQueue(eventQueue, event);
}
-
+
// TODO: EVENT_PREDICTIVE_DIALOG
// EVENT_SCREEN_CHANGED
}
}
-static void aptHookFunc(APT_HookType hookType, void* param) {
- auto eventQueue = (Common::Queue<Common::Event>*) param;
- OSystem_3DS* osys = (OSystem_3DS*) g_system;
+static void aptHookFunc(APT_HookType hookType, void *param) {
+ auto eventQueue = (Common::Queue<Common::Event> *)param;
+ OSystem_3DS *osys = (OSystem_3DS *)g_system;
Common::Event event;
switch (hookType) {
@@ -174,8 +169,8 @@ static void aptHookFunc(APT_HookType hookType, void* param) {
}
static void timerThreadFunc(void *arg) {
- OSystem_3DS* osys = (OSystem_3DS*) arg;
- DefaultTimerManager *tm = (DefaultTimerManager *) osys->getTimerManager();
+ OSystem_3DS *osys = (OSystem_3DS *)arg;
+ DefaultTimerManager *tm = (DefaultTimerManager *)osys->getTimerManager();
while (!osys->exiting) {
tm->handler();
g_system->delayMillis(10);
@@ -187,8 +182,8 @@ void OSystem_3DS::initEvents() {
eventMutex = new Common::Mutex();
s32 prio = 0;
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
- _timerThread = threadCreate(&timerThreadFunc, this, 32*1024, prio-1, -2, false);
- _eventThread = threadCreate(&eventThreadFunc, &_eventQueue, 32*1024, prio-1, -2, false);
+ _timerThread = threadCreate(&timerThreadFunc, this, 32 * 1024, prio - 1, -2, false);
+ _eventThread = threadCreate(&eventThreadFunc, &_eventQueue, 32 * 1024, prio - 1, -2, false);
aptHook(&cookie, aptHookFunc, &_eventQueue);
}
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index 7ee4efa0a5..0e50d2b911 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -21,11 +21,9 @@
*
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "backends/platform/3ds/osystem.h"
#include "backends/platform/3ds/shader_shbin.h"
-#include <common/rect.h>
-#include <algorithm>
+#include "common/rect.h"
// Used to transfer the final rendered display to the framebuffer
#define DISPLAY_TRANSFER_FLAGS \
@@ -62,7 +60,7 @@ void OSystem_3DS::initGraphics() {
_projectionLocation = shaderInstanceGetUniformLocation(_program.vertexShader, "projection");
_modelviewLocation = shaderInstanceGetUniformLocation(_program.vertexShader, "modelView");
- C3D_AttrInfo* attrInfo = C3D_GetAttrInfo();
+ C3D_AttrInfo *attrInfo = C3D_GetAttrInfo();
AttrInfo_Init(attrInfo);
AttrInfo_AddLoader(attrInfo, 0, GPU_FLOAT, 3); // v0=position
AttrInfo_AddLoader(attrInfo, 1, GPU_FLOAT, 2); // v1=texcoord
@@ -70,7 +68,7 @@ void OSystem_3DS::initGraphics() {
Mtx_OrthoTilt(&_projectionTop, 0.0, 400.0, 240.0, 0.0, 0.0, 1.0);
Mtx_OrthoTilt(&_projectionBottom, 0.0, 320.0, 240.0, 0.0, 0.0, 1.0);
- C3D_TexEnv* env = C3D_GetTexEnv(0);
+ C3D_TexEnv *env = C3D_GetTexEnv(0);
C3D_TexEnvSrc(env, C3D_Both, GPU_TEXTURE0, 0, 0);
C3D_TexEnvOp(env, C3D_Both, 0, 0, 0);
C3D_TexEnvFunc(env, C3D_Both, GPU_REPLACE);
@@ -138,7 +136,7 @@ bool OSystem_3DS::setGraphicsMode(int mode) {
}
void OSystem_3DS::resetGraphicsScale() {
- printf("resetGraphicsScale\n");
+ debug("resetGraphicsScale");
}
int OSystem_3DS::getGraphicsMode() const {
@@ -146,14 +144,14 @@ int OSystem_3DS::getGraphicsMode() const {
}
void OSystem_3DS::initSize(uint width, uint height,
const Graphics::PixelFormat *format) {
- printf("3ds initsize w:%d h:%d\n", width, height);
+ debug("3ds initsize w:%d h:%d", width, height);
_gameWidth = width;
_gameHeight = height;
_gameTexture.create(width, height, _pfGameTexture);
_overlay.create(getOverlayWidth(), getOverlayHeight(), _pfGameTexture);
if (format) {
- printf("pixelformat: %d %d %d %d %d\n", format->bytesPerPixel, format->rBits(), format->gBits(), format->bBits(), format->aBits());;
+ debug("pixelformat: %d %d %d %d %d", format->bytesPerPixel, format->rBits(), format->gBits(), format->bBits(), format->aBits());;
_pfGame = *format;
}
@@ -207,7 +205,6 @@ OSystem::TransactionError OSystem_3DS::endGFXTransaction() {
}
void OSystem_3DS::setPalette(const byte *colors, uint start, uint num) {
-// printf("setPalette\n");
assert(start + num <= 256);
memcpy(_palette + 3 * start, colors, 3 * num);
@@ -217,7 +214,6 @@ void OSystem_3DS::setPalette(const byte *colors, uint start, uint num) {
}
}
void OSystem_3DS::grabPalette(byte *colors, uint start, uint num) {
-// printf("grabPalette\n");
assert(start + num <= 256);
memcpy(colors, _palette + 3 * start, 3 * num);
}
@@ -245,11 +241,9 @@ void OSystem_3DS::flushGameScreen() {
}
Graphics::Surface *OSystem_3DS::lockScreen() {
- printf("lockScreen\n");
return &_gameScreen;
}
void OSystem_3DS::unlockScreen() {
- printf("unlockScreen\n");
flushGameScreen();
}
@@ -291,7 +285,7 @@ void OSystem_3DS::setShakePos(int shakeOffset) {
}
void OSystem_3DS::setFocusRectangle(const Common::Rect &rect) {
-// printf("setfocus: %d %d %d %d\n", rect.left, rect.top, rect.width(), rect.height());
+ debug("setfocus: %d %d %d %d", rect.left, rect.top, rect.width(), rect.height());
_focusRect = rect;
_focusDirty = true;
_focusClearTime = 0;
@@ -388,7 +382,7 @@ void OSystem_3DS::clearOverlay() {
}
void OSystem_3DS::grabOverlay(void *buf, int pitch) {
- for(int y = 0; y < getOverlayHeight(); ++y) {
+ for (int y = 0; y < getOverlayHeight(); ++y) {
memcpy(buf, _overlay.getBasePtr(0, y), pitch);
}
}
diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp
index d3fc1c7136..af0b7b5700 100644
--- a/backends/platform/3ds/osystem.cpp
+++ b/backends/platform/3ds/osystem.cpp
@@ -20,7 +20,9 @@
*
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
+#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
#include "osystem.h"
@@ -38,36 +40,37 @@
#include <time.h>
OSystem_3DS::OSystem_3DS():
-_focusDirty(true),
-_focusRect(Common::Rect(1,1)),
-_focusPosX(0),
-_focusPosY(0),
-_focusTargetPosX(0),
-_focusTargetPosY(0),
-_focusStepPosX(0),
-_focusStepPosY(0),
-_focusScaleX(1.f),
-_focusScaleY(1.f),
-_focusTargetScaleX(1.f),
-_focusTargetScaleY(1.f),
-_focusStepScaleX(0.f),
-_focusStepScaleY(0.f),
-_focusClearTime(0),
-_showMessageOSD(false),
-_isFullscreen(false),
-_cursorVisible(false),
-_cursorScalable(false),
-_cursorPaletteEnabled(false),
-_cursorX(0),
-_cursorY(0),
-_cursorHotspotX(0),
-_cursorHotspotY(0),
-_gameX(0),
-_gameY(0),
-_gameWidth(320),
-_gameHeight(240),
-exiting(false),
-sleeping(false) {
+ _focusDirty(true),
+ _focusRect(Common::Rect(1, 1)),
+ _focusPosX(0),
+ _focusPosY(0),
+ _focusTargetPosX(0),
+ _focusTargetPosY(0),
+ _focusStepPosX(0),
+ _focusStepPosY(0),
+ _focusScaleX(1.f),
+ _focusScaleY(1.f),
+ _focusTargetScaleX(1.f),
+ _focusTargetScaleY(1.f),
+ _focusStepScaleX(0.f),
+ _focusStepScaleY(0.f),
+ _focusClearTime(0),
+ _showMessageOSD(false),
+ _isFullscreen(false),
+ _cursorVisible(false),
+ _cursorScalable(false),
+ _cursorPaletteEnabled(false),
+ _cursorX(0),
+ _cursorY(0),
+ _cursorHotspotX(0),
+ _cursorHotspotY(0),
+ _gameX(0),
+ _gameY(0),
+ _gameWidth(320),
+ _gameHeight(240),
+ exiting(false),
+ sleeping(false)
+{
chdir("sdmc:/");
_fsFactory = new POSIXFilesystemFactory();
Posix::assureDirectoryExists("/3ds/scummvm/saves/");
@@ -133,18 +136,18 @@ void OSystem_3DS::getTimeAndDate(TimeDate& td) const {
}
OSystem::MutexRef OSystem_3DS::createMutex() {
- RecursiveLock* mutex = new RecursiveLock();
+ RecursiveLock *mutex = new RecursiveLock();
RecursiveLock_Init(mutex);
return (OSystem::MutexRef) mutex;
}
void OSystem_3DS::lockMutex(MutexRef mutex) {
- RecursiveLock_Lock((RecursiveLock *)mutex);
+ RecursiveLock_Lock((RecursiveLock*)mutex);
}
void OSystem_3DS::unlockMutex(MutexRef mutex) {
- RecursiveLock_Unlock((RecursiveLock *)mutex);
+ RecursiveLock_Unlock((RecursiveLock*)mutex);
}
void OSystem_3DS::deleteMutex(MutexRef mutex) {
- delete (RecursiveLock *)mutex;
+ delete (RecursiveLock*)mutex;
}
Common::String OSystem_3DS::getSystemLanguage() const {
diff --git a/backends/platform/3ds/portdefs.h b/backends/platform/3ds/portdefs.h
deleted file mode 100644
index f58cf5a675..0000000000
--- a/backends/platform/3ds/portdefs.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _PORTDEFS_H_
-#define _PORTDEFS_H_
-
-#define LURE_CLICKABLE_MENUS
-
-#endif
diff --git a/backends/platform/3ds/shader.v.pica b/backends/platform/3ds/shader.v.pica
index a359768218..2d18985622 100644
--- a/backends/platform/3ds/shader.v.pica
+++ b/backends/platform/3ds/shader.v.pica
@@ -1,4 +1,23 @@
-; PICA200 vertex shader
+;* ScummVM - Graphic Adventure Engine
+;*
+;* ScummVM is the legal property of its developers, whose names
+;* are too numerous to list here. Please refer to the COPYRIGHT
+;* file distributed with this source distribution.
+;*
+;* This program is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU General Public License
+;* as published by the Free Software Foundation; either version 2
+;* of the License, or (at your option) any later version.
+;*
+;* This program is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;* GNU General Public License for more details.
+;*
+;* You should have received a copy of the GNU General Public License
+;* along with this program; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+;*
; Uniforms
.fvec projection[4], modelView[4]
diff --git a/backends/platform/3ds/sprite.cpp b/backends/platform/3ds/sprite.cpp
index 0d5780ef12..a0aee385a9 100644
--- a/backends/platform/3ds/sprite.cpp
+++ b/backends/platform/3ds/sprite.cpp
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "backends/platform/3ds/sprite.h"
-#include <algorithm>
+#include "common/util.h"
#include <3ds.h>
static uint nextHigher2(uint v) {
@@ -37,18 +37,18 @@ static uint nextHigher2(uint v) {
}
Sprite::Sprite()
-: dirtyPixels(true)
-, dirtyMatrix(true)
-, actualWidth(0)
-, actualHeight(0)
-, posX(0)
-, posY(0)
-, scaleX(1.f)
-, scaleY(1.f)
+ : dirtyPixels(true)
+ , dirtyMatrix(true)
+ , actualWidth(0)
+ , actualHeight(0)
+ , posX(0)
+ , posY(0)
+ , scaleX(1.f)
+ , scaleY(1.f)
{
Mtx_Identity(&modelview);
- vertices = (vertex*)linearAlloc(sizeof(vertex) * 4);
+ vertices = (vertex *)linearAlloc(sizeof(vertex) * 4);
}
Sprite::~Sprite() {
@@ -61,8 +61,8 @@ void Sprite::create(uint16 width, uint16 height, const Graphics::PixelFormat &f)
actualWidth = width;
actualHeight = height;
format = f;
- w = std::max(nextHigher2(width), 64u);
- h = std::max(nextHigher2(height), 64u);;
+ w = MAX(nextHigher2(width), 64u);
+ h = MAX(nextHigher2(height), 64u);;
pitch = w * format.bytesPerPixel;
dirtyPixels = true;
@@ -110,7 +110,7 @@ void Sprite::render() {
}
C3D_TexBind(0, &texture);
- C3D_BufInfo* bufInfo = C3D_GetBufInfo();
+ C3D_BufInfo *bufInfo = C3D_GetBufInfo();
BufInfo_Init(bufInfo);
BufInfo_Add(bufInfo, vertices, sizeof(vertex), 2, 0x10);
C3D_DrawArrays(GPU_TRIANGLE_STRIP, 0, 4);