3DS: Fix code styling, add license header, remove unused portdefs.h

This commit is contained in:
Thomas Edvalson 2016-04-19 03:22:32 -04:00
parent 1ea737bbd8
commit e8dcfc3a4e
7 changed files with 106 additions and 123 deletions

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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 {

View File

@ -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

View File

@ -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]

View File

@ -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);