Skip to content
Permalink
Browse files

3DS: Implement cloud sync support

(cherry picked from commit 036d61c)
  • Loading branch information...
bgK committed Nov 3, 2019
1 parent 0e64097 commit c159f7e1f5a896de986e624f2f6613ff7de1e18a
@@ -28,7 +28,7 @@ clean_3ds:
$(RM) $(TARGET).cia
$(RM) -rf romfs

romfs: $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD)
romfs: $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD) $(DIST_3DS_EXTRA_FILES)
@rm -rf romfs
@mkdir -p romfs
@cp $(DIST_FILES_THEMES) romfs/
@@ -41,6 +41,9 @@ endif
ifdef DIST_FILES_VKEYBD
@cp $(DIST_FILES_VKEYBD) romfs/
endif
ifdef DIST_3DS_EXTRA_FILES
@cp -a $(DIST_3DS_EXTRA_FILES) romfs/
endif

$(TARGET).smdh: $(APP_ICON)
@smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@
@@ -49,7 +52,7 @@ $(TARGET).smdh: $(APP_ICON)
$(TARGET).3dsx: $(EXECUTABLE) $(TARGET).smdh romfs
@3dsxtool $< $@ --smdh=$(TARGET).smdh --romfs=romfs
@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 $@)
@@ -202,6 +202,12 @@ Note: In more recent codebases of ScummVM, you may or may not need to set the fo
```$ export PKG_CONFIG_LIBDIR=$PORTLIBS/lib/pkgconfig```
See above for $PORTLIBS.
ScummVM doesn't provide the CA certificates bundle required by the cloud synchronization features.
You need to download it from the curl website: https://curl.haxx.se/ca/cacert.pem, and instruct
the build system to package it in the binary:
```$ export DIST_3DS_EXTRA_FILES=/path/to/cacert.pem```
The name of the file must be `cacert.pem`.
From the root of the scummvm repository:
```
$ ./configure --host=3ds
@@ -22,6 +22,7 @@

#include "osystem.h"
#include <3ds.h>
#include <malloc.h>

int main(int argc, char *argv[]) {
// Initialize basic libctru stuff
@@ -31,6 +32,12 @@ int main(int argc, char *argv[]) {
osSetSpeedupEnable(true);
// consoleInit(GFX_TOP, NULL);

#ifdef USE_LIBCURL
const uint32 soc_sharedmem_size = 0x10000;
void *soc_sharedmem = memalign(0x1000, soc_sharedmem_size);
socInit((u32 *)soc_sharedmem, soc_sharedmem_size);
#endif

g_system = new _3DS::OSystem_3DS();
assert(g_system);

@@ -51,6 +58,9 @@ int main(int argc, char *argv[]) {
gspLcdExit();
}

#ifdef USE_LIBCURL
socExit();
#endif
romfsExit();
cfguExit();
gfxExit();
@@ -86,6 +86,7 @@ void OSystem_3DS::destroyGraphics() {
_gameTopTexture.free();
_gameBottomTexture.free();
_overlay.free();
_activityIcon.free();

shaderProgramFree(&_program);
DVLB_Free(_dvlb);
@@ -278,6 +279,7 @@ void OSystem_3DS::updateScreen() {
if (_cursorVisible && config.showCursor) {
_cursorTexture.transfer();
}
_activityIcon.transfer();
C3D_FrameEnd(0);

C3D_FrameBegin(0);
@@ -292,6 +294,11 @@ void OSystem_3DS::updateScreen() {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _overlay.getMatrix());
_overlay.render();
}
if (_activityIcon.getPixels() && config.screen == kScreenTop) {
_activityIcon.setPosition(400 - _activityIcon.actualWidth, 0);
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _activityIcon.getMatrix());
_activityIcon.render();
}
if (_cursorVisible && config.showCursor && config.screen == kScreenTop) {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
_cursorTexture.render();
@@ -309,6 +316,11 @@ void OSystem_3DS::updateScreen() {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _overlay.getMatrix());
_overlay.render();
}
if (_activityIcon.getPixels()) {
_activityIcon.setPosition(320 - _activityIcon.actualWidth, 0);
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _activityIcon.getMatrix());
_activityIcon.render();
}
if (_cursorVisible && config.showCursor) {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
_cursorTexture.render();
@@ -434,6 +446,22 @@ void OSystem_3DS::copyRectToOverlay(const void *buf, int pitch, int x,
_overlay.markDirty();
}

void OSystem_3DS::displayActivityIconOnOSD(const Graphics::Surface *icon) {
if (!icon) {
_activityIcon.free();
} else {
if (!_activityIcon.getPixels() || icon->w != _activityIcon.w || icon->h != _activityIcon.h) {
_activityIcon.create(icon->w, icon->h, _pfGameTexture);
}

Graphics::Surface *converted = icon->convertTo(_pfGameTexture);
_activityIcon.copyRectToSurface(*converted, 0, 0, Common::Rect(converted->w, converted->h));
_activityIcon.markDirty();
converted->free();
delete converted;
}
}

int16 OSystem_3DS::getOverlayHeight() {
return 240;
}
@@ -193,7 +193,7 @@ void OSystem_3DS::fatalError() {
}

void OSystem_3DS::logMessage(LogMessageType::Type type, const char *message) {
printf("3DS log: %s\n", message);
printf("%s", message);
}

} // namespace _3DS
@@ -126,6 +126,7 @@ class OSystem_3DS : public EventsBaseBackend, public PaletteManager {
virtual int16 getOverlayHeight();
virtual int16 getOverlayWidth();
virtual void displayMessageOnOSD(const char *msg);
void displayActivityIconOnOSD(const Graphics::Surface *icon) override;

bool showMouse(bool visible);
void warpMouse(int x, int y);
@@ -176,6 +177,7 @@ class OSystem_3DS : public EventsBaseBackend, public PaletteManager {
Sprite _gameTopTexture;
Sprite _gameBottomTexture;
Sprite _overlay;
Sprite _activityIcon;

int _screenShakeOffset;
bool _overlayVisible;
@@ -101,7 +101,7 @@ void Sprite::convertToInPlace(const Graphics::PixelFormat &dstFormat, const byte
}

void Sprite::transfer() {
if (dirtyPixels) {
if (pixels && dirtyPixels) {
dirtyPixels = false;
GSPGPU_FlushDataCache(pixels, w * h * format.bytesPerPixel);
C3D_SyncDisplayTransfer((u32*)pixels, GX_BUFFER_DIM(w, h), (u32*)texture.data, GX_BUFFER_DIM(w, h), TEXTURE_TRANSFER_FLAGS);
@@ -123,15 +123,19 @@ void Sprite::clear(uint32 color) {
}

void Sprite::setScale (float x, float y) {
scaleX = x;
scaleY = y;
dirtyMatrix = true;
if (x != scaleX || y != scaleY) {
scaleX = x;
scaleY = y;
dirtyMatrix = true;
}
}

void Sprite::setPosition(int x, int y) {
posX = x;
posY = y;
dirtyMatrix = true;
if (x != posX || y != posY) {
posX = x;
posY = y;
dirtyMatrix = true;
}
}

C3D_Mtx* Sprite::getMatrix() {

0 comments on commit c159f7e

Please sign in to comment.
You can’t perform that action at this time.