aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorThomas Edvalson2016-04-11 15:15:42 -0400
committerThomas Edvalson2016-04-11 15:15:42 -0400
commitf5d73cac8a2d21962ed34b18de5aee36c2bce9ad (patch)
tree83f75236444bd29e4067dec7ea27ad00fd421557 /backends/platform
parentfe8d48005717a4c77d34da1a5f9e4b5bfc597c6f (diff)
downloadscummvm-rg350-f5d73cac8a2d21962ed34b18de5aee36c2bce9ad.tar.gz
scummvm-rg350-f5d73cac8a2d21962ed34b18de5aee36c2bce9ad.tar.bz2
scummvm-rg350-f5d73cac8a2d21962ed34b18de5aee36c2bce9ad.zip
3DS: Add CIA format build, add timer handler thread, fix APT service suspending/sleeping/exiting
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/3ds/3ds.mk21
-rw-r--r--backends/platform/3ds/app/banner.pngbin0 -> 19241 bytes
-rw-r--r--backends/platform/3ds/app/banner.wavbin0 -> 2212 bytes
-rw-r--r--backends/platform/3ds/app/icon.png (renamed from backends/platform/3ds/icon.png)bin3800 -> 3800 bytes
-rw-r--r--backends/platform/3ds/app/scummvm.rsf218
-rw-r--r--backends/platform/3ds/osystem-audio.cpp17
-rw-r--r--backends/platform/3ds/osystem-events.cpp55
-rw-r--r--backends/platform/3ds/osystem-graphics.cpp11
-rw-r--r--backends/platform/3ds/osystem.cpp9
-rw-r--r--backends/platform/3ds/osystem.h4
10 files changed, 308 insertions, 27 deletions
diff --git a/backends/platform/3ds/3ds.mk b/backends/platform/3ds/3ds.mk
index bd8e743e14..7ab58995f6 100644
--- a/backends/platform/3ds/3ds.mk
+++ b/backends/platform/3ds/3ds.mk
@@ -3,7 +3,11 @@ TARGET := scummvm
APP_TITLE := ScummVM
APP_DESCRIPTION := Point-and-click adventure game engines
APP_AUTHOR := ScummVM Team
-APP_ICON := backends/platform/3ds/icon.png
+APP_ICON := backends/platform/3ds/app/icon.png
+
+APP_RSF := backends/platform/3ds/app/scummvm.rsf
+APP_BANNER_IMAGE:= backends/platform/3ds/app/banner.png
+APP_BANNER_AUDIO:= backends/platform/3ds/app/banner.wav
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CXXFLAGS += -std=gnu++11
@@ -12,20 +16,27 @@ LDFLAGS += -specs=3dsx.specs $(ARCH) -L$(DEVKITPRO)/libctru/lib -L$(DEVKITPRO)/
.PHONY: clean_3ds
-all: $(TARGET).3dsx
-
clean: clean_3ds
clean_3ds:
$(RM) $(TARGET).3dsx
+ $(RM) $(TARGET).cia
-$(TARGET).smdh: $(APP_ICON) $(MAKEFILE_LIST)
- @smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@
+$(TARGET).smdh: $(APP_ICON)
+ @bannertool makesmdh -s "$(APP_TITLE)" -l "$(APP_DESCRIPTION)" -p "$(APP_AUTHOR)" -i $(APP_ICON) -o $@
@echo built ... $(notdir $@)
$(TARGET).3dsx: $(EXECUTABLE) $(TARGET).smdh
@3dsxtool $< $@ --smdh=$(TARGET).smdh
@echo built ... $(notdir $@)
+
+$(TARGET).bnr: $(APP_BANNER_IMAGE) $(APP_BANNER_AUDIO)
+ @bannertool makebanner -o $@ -i $(APP_BANNER_IMAGE) -a $(APP_BANNER_AUDIO)
+ @echo built ... $(notdir $@)
+
+$(TARGET).cia: $(EXECUTABLE) $(APP_RSF) $(TARGET).smdh $(TARGET).bnr
+ @makerom -f cia -target t -exefslogo -o $@ -elf $(EXECUTABLE) -rsf $(APP_RSF) -banner $(TARGET).bnr -icon $(TARGET).smdh
+ @echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
diff --git a/backends/platform/3ds/app/banner.png b/backends/platform/3ds/app/banner.png
new file mode 100644
index 0000000000..a3b02150ec
--- /dev/null
+++ b/backends/platform/3ds/app/banner.png
Binary files differ
diff --git a/backends/platform/3ds/app/banner.wav b/backends/platform/3ds/app/banner.wav
new file mode 100644
index 0000000000..e0b684b62f
--- /dev/null
+++ b/backends/platform/3ds/app/banner.wav
Binary files differ
diff --git a/backends/platform/3ds/icon.png b/backends/platform/3ds/app/icon.png
index 07022fbac1..07022fbac1 100644
--- a/backends/platform/3ds/icon.png
+++ b/backends/platform/3ds/app/icon.png
Binary files differ
diff --git a/backends/platform/3ds/app/scummvm.rsf b/backends/platform/3ds/app/scummvm.rsf
new file mode 100644
index 0000000000..d403bdbe91
--- /dev/null
+++ b/backends/platform/3ds/app/scummvm.rsf
@@ -0,0 +1,218 @@
+BasicInfo:
+ Title : ScummVM
+ ProductCode : ScummVM
+ Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
+
+TitleInfo:
+ Category : Application
+ UniqueId : 0xFF321
+
+Option:
+ UseOnSD : true # true if App is to be installed to SD
+ FreeProductCode : true # Removes limitations on ProductCode
+ MediaFootPadding : false # If true CCI files are created with padding
+ EnableCrypt : false # Enables encryption for NCCH and CIA
+ EnableCompress : false # Compresses where applicable (currently only exefs:/.code)
+
+AccessControlInfo:
+ CoreVersion : 2
+
+ # Exheader Format Version
+ DescVersion : 2
+
+ # Minimum Required Kernel Version (below is for 4.5.0)
+ ReleaseKernelMajor : "02"
+ ReleaseKernelMinor : "33"
+
+ # ExtData
+ UseExtSaveData : false # enables ExtData
+ #ExtSaveDataId : 0x300 # only set this when the ID is different to the UniqueId
+
+ # FS:USER Archive Access Permissions
+ # Uncomment as required
+ FileSystemAccess:
+ #- CategorySystemApplication
+ #- CategoryHardwareCheck
+ #- CategoryFileSystemTool
+ #- Debug
+ #- TwlCardBackup
+ #- TwlNandData
+ #- Boss
+ - DirectSdmc
+ #- Core
+ #- CtrNandRo
+ #- CtrNandRw
+ #- CtrNandRoWrite
+ #- CategorySystemSettings
+ #- CardBoard
+ #- ExportImportIvs
+ #- DirectSdmcWrite
+ #- SwitchCleanup
+ #- SaveDataMove
+ #- Shop
+ #- Shell
+ #- CategoryHomeMenu
+
+ # Process Settings
+ MemoryType : Application # Application/System/Base
+ SystemMode : 64MB # 64MB(Default)/96MB/80MB/72MB/32MB
+ IdealProcessor : 0
+ AffinityMask : 1
+ Priority : 16
+ MaxCpu : 0 # Let system decide
+ HandleTableSize : 0x200
+ DisableDebug : false
+ EnableForceDebug : false
+ CanWriteSharedPage : true
+ CanUsePrivilegedPriority : false
+ CanUseNonAlphabetAndNumber : true
+ PermitMainFunctionArgument : true
+ CanShareDeviceMemory : true
+ RunnableOnSleep : false
+ SpecialMemoryArrange : true
+
+ # New3DS Exclusive Process Settings
+ SystemModeExt : 124MB # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode
+ CpuSpeed : 804MHz # 268MHz(Default)/804MHz
+ EnableL2Cache : true # false(default)/true
+ CanAccessCore2 : true
+
+ # Virtual Address Mappings
+ IORegisterMapping:
+ - 1ff00000-1ff7ffff # DSP memory
+ MemoryMapping:
+ - 1f000000-1f5fffff:r # VRAM
+
+ # Accessible SVCs, <Name>:<ID>
+ SystemCallAccess:
+ ArbitrateAddress: 34
+ Break: 60
+ CancelTimer: 28
+ ClearEvent: 25
+ ClearTimer: 29
+ CloseHandle: 35
+ ConnectToPort: 45
+ ControlMemory: 1
+ CreateAddressArbiter: 33
+ CreateEvent: 23
+ CreateMemoryBlock: 30
+ CreateMutex: 19
+ CreateSemaphore: 21
+ CreateThread: 8
+ CreateTimer: 26
+ DuplicateHandle: 39
+ ExitProcess: 3
+ ExitThread: 9
+ GetCurrentProcessorNumber: 17
+ GetHandleInfo: 41
+ GetProcessId: 53
+ GetProcessIdOfThread: 54
+ GetProcessIdealProcessor: 6
+ GetProcessInfo: 43
+ GetResourceLimit: 56
+ GetResourceLimitCurrentValues: 58
+ GetResourceLimitLimitValues: 57
+ GetSystemInfo: 42
+ GetSystemTick: 40
+ GetThreadContext: 59
+ GetThreadId: 55
+ GetThreadIdealProcessor: 15
+ GetThreadInfo: 44
+ GetThreadPriority: 11
+ MapMemoryBlock: 31
+ OutputDebugString: 61
+ QueryMemory: 2
+ ReleaseMutex: 20
+ ReleaseSemaphore: 22
+ SendSyncRequest1: 46
+ SendSyncRequest2: 47
+ SendSyncRequest3: 48
+ SendSyncRequest4: 49
+ SendSyncRequest: 50
+ SetThreadPriority: 12
+ SetTimer: 27
+ SignalEvent: 24
+ SleepThread: 10
+ UnmapMemoryBlock: 32
+ WaitSynchronization1: 36
+ WaitSynchronizationN: 37
+ Backdoor: 123
+
+ # Service List
+ # Maximum 34 services (32 if firmware is prior to 9.3.0)
+ ServiceAccessControl:
+ - cfg:u
+ - fs:USER
+ - gsp::Gpu
+ - hid:USER
+ - ndm:u
+ - pxi:dev
+ - APT:U
+ - ac:u
+ - act:u
+ - am:net
+ - boss:U
+ - cam:u
+ - cecd:u
+ - dsp::DSP
+ - frd:u
+ - http:C
+ - ir:USER
+ - ir:u
+ - ir:rst
+ - ldr:ro
+ - mic:u
+ - news:u
+ - nim:aoc
+ - nwm::UDS
+ - ptm:u
+ - qtm:u
+ - soc:U
+ - ssl:C
+ - y2r:u
+
+
+SystemControlInfo:
+ SaveDataSize: 0K
+ RemasterVersion: 0
+ StackSize: 0x40000
+
+ # Modules that run services listed above should be included below
+ # Maximum 48 dependencies
+ # If a module is listed that isn't present on the 3DS, the title will get stuck at the logo (3ds waves)
+ # So act, nfc and qtm are commented for 4.x support. Uncomment if you need these.
+ # <module name>:<module titleid>
+ Dependency:
+ ac: 0x0004013000002402
+ #act: 0x0004013000003802
+ am: 0x0004013000001502
+ boss: 0x0004013000003402
+ camera: 0x0004013000001602
+ cecd: 0x0004013000002602
+ cfg: 0x0004013000001702
+ codec: 0x0004013000001802
+ csnd: 0x0004013000002702
+ dlp: 0x0004013000002802
+ dsp: 0x0004013000001a02
+ friends: 0x0004013000003202
+ gpio: 0x0004013000001b02
+ gsp: 0x0004013000001c02
+ hid: 0x0004013000001d02
+ http: 0x0004013000002902
+ i2c: 0x0004013000001e02
+ ir: 0x0004013000003302
+ mcu: 0x0004013000001f02
+ mic: 0x0004013000002002
+ ndm: 0x0004013000002b02
+ news: 0x0004013000003502
+ #nfc: 0x0004013000004002
+ nim: 0x0004013000002c02
+ nwm: 0x0004013000002d02
+ pdn: 0x0004013000002102
+ ps: 0x0004013000003102
+ ptm: 0x0004013000002202
+ #qtm: 0x0004013020004202
+ ro: 0x0004013000003702
+ socket: 0x0004013000002e02
+ spi: 0x0004013000002302
+ ssl: 0x0004013000002f02
diff --git a/backends/platform/3ds/osystem-audio.cpp b/backends/platform/3ds/osystem-audio.cpp
index 7ff788b430..7e4822b8e9 100644
--- a/backends/platform/3ds/osystem-audio.cpp
+++ b/backends/platform/3ds/osystem-audio.cpp
@@ -21,8 +21,8 @@
*/
#include "osystem.h"
+#include "audio/mixer.h"
-static bool exitAudioThread = false;
static bool hasAudio = false;
static void audioThreadFunc(void* arg) {
@@ -34,7 +34,7 @@ static void audioThreadFunc(void* arg) {
int bufferIndex = 0;
const int bufferCount = 3;
const int bufferSize = 80000; // Can't be too small, based on delayMillis duration
- const int sampleRate = 22050;
+ const int sampleRate = mixer->getOutputRate();
int sampleLen = 0;
uint32 lastTime = osys->getMillis(true);
uint32 time = lastTime;
@@ -52,18 +52,18 @@ static void audioThreadFunc(void* arg) {
ndspChnSetRate(channel, sampleRate);
ndspChnSetFormat(channel, NDSP_FORMAT_STEREO_PCM16);
- while(!exitAudioThread) {
- bufferIndex++;
- bufferIndex %= bufferCount;
- ndspWaveBuf* buf = &buffers[bufferIndex];
-
+ while(!osys->exiting) {
osys->delayMillis(100); // Note: Increasing the delay requires a bigger buffer
time = osys->getMillis(true);
sampleLen = (time - lastTime) * 22 * 4; // sampleRate / 1000 * channelCount * sizeof(int16);
lastTime = time;
- if (sampleLen > 0) {
+ if (!osys->sleeping && sampleLen > 0) {
+ bufferIndex++;
+ bufferIndex %= bufferCount;
+ ndspWaveBuf* buf = &buffers[bufferIndex];
+
buf->nsamples = mixer->mixCallback(buf->data_adpcm, sampleLen);
if (buf->nsamples > 0) {
DSP_FlushDataCache(buf->data_vaddr, bufferSize);
@@ -91,7 +91,6 @@ void OSystem_3DS::initAudio() {
void OSystem_3DS::destroyAudio() {
if (hasAudio) {
- exitAudioThread = true;
threadJoin(audioThread, U64_MAX);
threadFree(audioThread);
ndspExit();
diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp
index a4ce92c394..46efdd3b7a 100644
--- a/backends/platform/3ds/osystem-events.cpp
+++ b/backends/platform/3ds/osystem-events.cpp
@@ -21,12 +21,13 @@
*/
#define FORBIDDEN_SYMBOL_ALLOW_ALL
+#include "backends/timer/default/default-timer.h"
#include "backends/platform/3ds/gui.h"
#include "osystem.h"
static Common::Mutex *eventMutex;
-static bool exitEventThread = false;
static InputMode inputMode = MODE_DRAG;
+static aptHookCookie cookie;
static void pushEventQueue(Common::Queue<Common::Event>* queue, Common::Event& event) {
Common::StackLock lock(*eventMutex);
@@ -42,8 +43,10 @@ static void eventThreadFunc(void* arg) {
bool isRightClick = false;
Common::Event event;
- while(!exitEventThread) {
- osys->delayMillis(10);
+ while(!osys->exiting) {
+ do {
+ osys->delayMillis(10);
+ } while (osys->sleeping && !osys->exiting);
hidScanInput();
touchPosition touch;
@@ -51,10 +54,6 @@ static void eventThreadFunc(void* arg) {
u32 keysPressed = hidKeysDown();
u32 keysReleased = hidKeysUp();
- if (!aptMainLoop()) {
- event.type = Common::EVENT_QUIT;
- pushEventQueue(eventQueue, event);
- }
if (held & KEY_TOUCH) {
hidTouchRead(&touch);
osys->transformPoint(touch);
@@ -151,15 +150,53 @@ static void eventThreadFunc(void* arg) {
}
}
+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) {
+ case APTHOOK_ONSUSPEND:
+ case APTHOOK_ONSLEEP:
+ event.type = Common::EVENT_MAINMENU;
+ pushEventQueue(eventQueue, event);
+ osys->sleeping = true;
+ break;
+ case APTHOOK_ONRESTORE:
+ case APTHOOK_ONWAKEUP:
+ osys->sleeping = false;
+ break;
+ default:
+ event.type = Common::EVENT_QUIT;
+ pushEventQueue(eventQueue, event);
+ break;
+ }
+}
+
+static void timerThreadFunc(void *arg) {
+ OSystem_3DS* osys = (OSystem_3DS*) arg;
+ DefaultTimerManager *tm = (DefaultTimerManager *) osys->getTimerManager();
+ while (!osys->exiting) {
+ tm->handler();
+ g_system->delayMillis(10);
+ aptMainLoop(); // Call apt hook when necessary
+ }
+}
+
void OSystem_3DS::initEvents() {
eventMutex = new Common::Mutex();
s32 prio = 0;
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
- _eventThread = threadCreate(&eventThreadFunc, &_eventQueue, 2048, 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);
}
void OSystem_3DS::destroyEvents() {
- exitEventThread = true;
+ threadJoin(_timerThread, U64_MAX);
+ threadFree(_timerThread);
+
threadJoin(_eventThread, U64_MAX);
threadFree(_eventThread);
delete eventMutex;
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index 5e70dced73..7ee4efa0a5 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -180,6 +180,12 @@ void OSystem_3DS::initSize(uint width, uint height,
}
_gameTexture.setPosition(_gameX, _gameY);
_cursorTexture.setScale(_gameTexture.getScaleX(), _gameTexture.getScaleY());
+
+ float ratio = 400.f / _gameWidth;
+ int y = (_gameHeight * ratio - 240.f) / 2;
+ Mtx_Identity(&_focusMatrix);
+ Mtx_Translate(&_focusMatrix, 0, -y, 0);
+ Mtx_Scale(&_focusMatrix, ratio, ratio, 1.f);
}
Common::List<Graphics::PixelFormat> OSystem_3DS::getSupportedFormats() const {
@@ -248,8 +254,11 @@ void OSystem_3DS::unlockScreen() {
}
void OSystem_3DS::updateScreen() {
+
+ if (sleeping || exiting)
+ return;
- updateFocus();
+// updateFocus();
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
// Render top screen
diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp
index fa2980a361..d3fc1c7136 100644
--- a/backends/platform/3ds/osystem.cpp
+++ b/backends/platform/3ds/osystem.cpp
@@ -65,13 +65,16 @@ _cursorHotspotY(0),
_gameX(0),
_gameY(0),
_gameWidth(320),
-_gameHeight(240) {
- chdir("/");
+_gameHeight(240),
+exiting(false),
+sleeping(false) {
+ chdir("sdmc:/");
_fsFactory = new POSIXFilesystemFactory();
Posix::assureDirectoryExists("/3ds/scummvm/saves/");
}
OSystem_3DS::~OSystem_3DS() {
+ exiting = true;
destroyEvents();
destroyAudio();
destroyGraphics();
@@ -81,7 +84,7 @@ OSystem_3DS::~OSystem_3DS() {
}
void OSystem_3DS::quit() {
- //
+ printf("OSystem_3DS::quit()\n");
}
void OSystem_3DS::initBackend() {
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
index 98d9ad0cb6..a8c2a909f1 100644
--- a/backends/platform/3ds/osystem.h
+++ b/backends/platform/3ds/osystem.h
@@ -55,6 +55,9 @@ class OSystem_3DS : public EventsBaseBackend, public PaletteManager {
public:
OSystem_3DS();
~OSystem_3DS();
+
+ volatile bool exiting;
+ volatile bool sleeping;
virtual void initBackend();
@@ -191,6 +194,7 @@ private:
// Events
Thread _eventThread;
+ Thread _timerThread;
Common::Queue<Common::Event> _eventQueue;
Common::String _messageOSD;