[Scummvm-git-logs] scummvm master -> 1de6764891a88933f3573093dac94fb34f9e4b5b

bgK bastien.bouclet at gmail.com
Sun Jul 19 15:43:16 UTC 2020


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0a567b6058 3DS: Implement OSystem::kFeatureFilteringMode
5b69df78d4 3DS: Fix potential integer overflow in circle pad handling
4825e9f967 3DS: Upgrade to libctru v2.0.0
1de6764891 3DS: Use the 800x240px graphics mode for the top screen


Commit: 0a567b6058b4b18617dc0236a932a216333b7f66
    https://github.com/scummvm/scummvm/commit/0a567b6058b4b18617dc0236a932a216333b7f66
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-07-19T17:41:05+02:00

Commit Message:
3DS: Implement OSystem::kFeatureFilteringMode

Changed paths:
    backends/platform/3ds/osystem-graphics.cpp
    backends/platform/3ds/osystem.cpp
    backends/platform/3ds/osystem.h
    backends/platform/3ds/sprite.cpp
    backends/platform/3ds/sprite.h


diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index ad2b1d3ca0..2722ddb90e 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -123,6 +123,7 @@ void OSystem_3DS::destroy3DSGraphics() {
 
 bool OSystem_3DS::hasFeature(OSystem::Feature f) {
 	return (f == OSystem::kFeatureCursorPalette ||
+	        f == OSystem::kFeatureFilteringMode ||
 	        f == OSystem::kFeatureOverlaySupportsAlpha ||
 	        f == OSystem::kFeatureKbdMouseSpeed ||
 	        f == OSystem::kFeatureJoystickDeadzone);
@@ -134,6 +135,9 @@ void OSystem_3DS::setFeatureState(OSystem::Feature f, bool enable) {
 		_cursorPaletteEnabled = enable;
 		flushCursor();
 		break;
+	case OSystem::kFeatureFilteringMode:
+		_filteringEnabled = enable;
+		break;
 	default:
 		break;
 	}
@@ -143,6 +147,8 @@ bool OSystem_3DS::getFeatureState(OSystem::Feature f) {
 	switch (f) {
 	case OSystem::kFeatureCursorPalette:
 		return _cursorPaletteEnabled;
+	case OSystem::kFeatureFilteringMode:
+		return _filteringEnabled;
 	default:
 		return false;
 	}
@@ -429,6 +435,7 @@ void OSystem_3DS::updateScreen() {
 		if (config.screen == kScreenTop || config.screen == kScreenBoth) {
 			C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _projectionLocation, &_projectionTop);
 			C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _gameTopTexture.getMatrix());
+			_gameTopTexture.setFilteringMode(_magnifyMode != MODE_MAGON && _filteringEnabled);
 			_gameTopTexture.render();
 			if (_overlayVisible && config.screen == kScreenTop) {
 				C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _overlay.getMatrix());
@@ -446,6 +453,7 @@ void OSystem_3DS::updateScreen() {
 			}
 			if (_cursorVisible && config.showCursor && config.screen == kScreenTop) {
 				C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
+				_cursorTexture.setFilteringMode(!_overlayVisible && _filteringEnabled);
 				_cursorTexture.render();
 			}
 		}
@@ -456,6 +464,7 @@ void OSystem_3DS::updateScreen() {
 		if (config.screen == kScreenBottom || config.screen == kScreenBoth) {
 			C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _projectionLocation, &_projectionBottom);
 			C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _gameBottomTexture.getMatrix());
+			_gameTopTexture.setFilteringMode(_filteringEnabled);
 			_gameTopTexture.render();
 			if (_overlayVisible) {
 				C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _overlay.getMatrix());
@@ -473,6 +482,7 @@ void OSystem_3DS::updateScreen() {
 			}
 			if (_cursorVisible && config.showCursor) {
 				C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
+				_cursorTexture.setFilteringMode(!_overlayVisible && _filteringEnabled);
 				_cursorTexture.render();
 			}
 		}
diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp
index 6c405cffab..0f80d6fcfe 100644
--- a/backends/platform/3ds/osystem.cpp
+++ b/backends/platform/3ds/osystem.cpp
@@ -79,6 +79,7 @@ OSystem_3DS::OSystem_3DS():
 	_magWidth(400),
 	_magHeight(240),
 	_gameTextureDirty(false),
+	_filteringEnabled(true),
 	_overlayVisible(false),
 	_screenChangeId(0),
 	_magnifyMode(MODE_MAGOFF),
@@ -127,6 +128,7 @@ void OSystem_3DS::initBackend() {
 	loadConfig();
 	ConfMan.registerDefault("fullscreen", true);
 	ConfMan.registerDefault("aspect_ratio", true);
+	ConfMan.registerDefault("filtering", true);
 	if (!ConfMan.hasKey("vkeybd_pack_name")) {
 		ConfMan.set("vkeybd_pack_name", "vkeybd_small");
 	}
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
index d9c9bcc113..b17f744ffb 100644
--- a/backends/platform/3ds/osystem.h
+++ b/backends/platform/3ds/osystem.h
@@ -229,6 +229,7 @@ private:
 	Sprite _overlay;
 	Sprite _activityIcon;
 	Sprite _osdMessage;
+	bool _filteringEnabled;
 
 	enum {
 		kOSDMessageDuration = 800
diff --git a/backends/platform/3ds/sprite.cpp b/backends/platform/3ds/sprite.cpp
index b3bbcb3e44..65f78dba25 100644
--- a/backends/platform/3ds/sprite.cpp
+++ b/backends/platform/3ds/sprite.cpp
@@ -64,7 +64,6 @@ void Sprite::create(uint16 width, uint16 height, const GfxMode3DS *mode) {
 	if (width && height) {
 		pixels = linearAlloc(h * pitch);
 		C3D_TexInit(&texture, w, h, mode->textureFormat);
-		C3D_TexSetFilter(&texture, GPU_LINEAR, GPU_LINEAR);
 		assert(pixels && texture.data);
 		clear();
 	}
@@ -149,4 +148,9 @@ C3D_Mtx* Sprite::getMatrix() {
 	return &modelview;
 }
 
+void Sprite::setFilteringMode(bool enableLinearFiltering) {
+	GPU_TEXTURE_FILTER_PARAM filteringMode = enableLinearFiltering ? GPU_LINEAR : GPU_NEAREST;
+	C3D_TexSetFilter(&texture, filteringMode, filteringMode);
+}
+
 } // namespace _3DS
diff --git a/backends/platform/3ds/sprite.h b/backends/platform/3ds/sprite.h
index 36cc5fcb1f..b8c55768a3 100644
--- a/backends/platform/3ds/sprite.h
+++ b/backends/platform/3ds/sprite.h
@@ -59,6 +59,8 @@ public:
 	int getPosY() const { return posY; }
 	C3D_Mtx* getMatrix();
 
+	void setFilteringMode(bool enableLinearFiltering);
+
 	uint16 actualWidth;
 	uint16 actualHeight;
 


Commit: 5b69df78d4c137e382f9add9fb1efc6d544516d9
    https://github.com/scummvm/scummvm/commit/5b69df78d4c137e382f9add9fb1efc6d544516d9
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-07-19T17:41:05+02:00

Commit Message:
3DS: Fix potential integer overflow in circle pad handling

Changed paths:
    backends/platform/3ds/osystem-events.cpp


diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp
index a42898fa4a..abb97e6d90 100644
--- a/backends/platform/3ds/osystem-events.cpp
+++ b/backends/platform/3ds/osystem-events.cpp
@@ -168,16 +168,20 @@ static void eventThreadFunc(void *arg) {
 		hidCircleRead(&circle);
 
 		if (circle.dx != lastCircle.dx) {
+			int32 position = (int32)circle.dx * Common::JOYAXIS_MAX / CIRCLE_MAX;
+
 			event.type              = Common::EVENT_JOYAXIS_MOTION;
 			event.joystick.axis     = Common::JOYSTICK_AXIS_LEFT_STICK_X;
-			event.joystick.position = (int32)circle.dx * Common::JOYAXIS_MAX / CIRCLE_MAX;
+			event.joystick.position = CLIP<int32>(position, Common::JOYAXIS_MIN, Common::JOYAXIS_MAX);
 			pushEventQueue(eventQueue, event);
 		}
 
 		if (circle.dy != lastCircle.dy) {
+			int32 position = -(int32)circle.dy * Common::JOYAXIS_MAX / CIRCLE_MAX;
+
 			event.type              = Common::EVENT_JOYAXIS_MOTION;
 			event.joystick.axis     = Common::JOYSTICK_AXIS_LEFT_STICK_Y;
-			event.joystick.position = -(int32)circle.dy * Common::JOYAXIS_MAX / CIRCLE_MAX;
+			event.joystick.position = CLIP<int32>(position, Common::JOYAXIS_MIN, Common::JOYAXIS_MAX);
 			pushEventQueue(eventQueue, event);
 		}
 


Commit: 4825e9f9678056572653be62eac9b4fc73609f6c
    https://github.com/scummvm/scummvm/commit/4825e9f9678056572653be62eac9b4fc73609f6c
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-07-19T17:41:05+02:00

Commit Message:
3DS: Upgrade to libctru v2.0.0

Changed paths:
    backends/platform/3ds/osystem-events.cpp
    backends/plugins/3ds/3ds-provider.cpp


diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp
index abb97e6d90..7f4928d691 100644
--- a/backends/platform/3ds/osystem-events.cpp
+++ b/backends/platform/3ds/osystem-events.cpp
@@ -228,17 +228,8 @@ static void aptHookFunc(APT_HookType hookType, void *param) {
 			osys->sleeping = false;
 			loadConfig();
 			break;
-		case APTHOOK_ONEXIT: {
-			if (osys->_sleepPauseToken.isActive()) {
-				osys->_sleepPauseToken.clear();
-			}
-
-			Common::StackLock lock(*eventMutex);
-			Common::Event event;
-			event.type = Common::EVENT_QUIT;
-			g_system->getEventManager()->pushEvent(event);
+		case APTHOOK_ONEXIT:
 			break;
-		}
 		default:
 			warning("Unhandled APT hook, type: %d", hookType);
 	}
@@ -349,7 +340,15 @@ Common::KeymapperDefaultBindings *OSystem_3DS::getKeymapperDefaultBindings() {
 }
 
 bool OSystem_3DS::pollEvent(Common::Event &event) {
-	aptMainLoop(); // Call apt hook when necessary
+	if (!aptMainLoop()) {
+		// The system requested us to quit
+		if (_sleepPauseToken.isActive()) {
+			_sleepPauseToken.clear();
+		}
+
+		event.type = Common::EVENT_QUIT;
+		return true;
+	}
 
 	// If magnify mode is on when returning to Launcher, turn it off
 	if (_eventManager->shouldReturnToLauncher()) {
diff --git a/backends/plugins/3ds/3ds-provider.cpp b/backends/plugins/3ds/3ds-provider.cpp
index fd813669a5..352e981080 100644
--- a/backends/plugins/3ds/3ds-provider.cpp
+++ b/backends/plugins/3ds/3ds-provider.cpp
@@ -51,7 +51,7 @@ protected:
 	uint32 _segmentHeapAddress;
 
 	void flushDataCache(void *ptr, uint32 len) const override {
-		svcFlushProcessDataCache(CUR_PROCESS_HANDLE, ptr, len);
+		svcFlushProcessDataCache(CUR_PROCESS_HANDLE, (uint32)ptr, len);
 	}
 
 	void protectMemory(void *ptr, uint32 len, int prot) const override {


Commit: 1de6764891a88933f3573093dac94fb34f9e4b5b
    https://github.com/scummvm/scummvm/commit/1de6764891a88933f3573093dac94fb34f9e4b5b
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-07-19T17:41:05+02:00

Commit Message:
3DS: Use the 800x240px graphics mode for the top screen

The extra horizontal resolution results in much improved visuals
for hi-resolution games.

Changed paths:
    backends/platform/3ds/main.cpp
    backends/platform/3ds/osystem-graphics.cpp


diff --git a/backends/platform/3ds/main.cpp b/backends/platform/3ds/main.cpp
index e003d2ce3b..0371ab042b 100644
--- a/backends/platform/3ds/main.cpp
+++ b/backends/platform/3ds/main.cpp
@@ -26,10 +26,20 @@
 #include <3ds.h>
 #include <malloc.h>
 
+enum {
+	SYSTEM_MODEL_2DS = 3
+};
+
 int main(int argc, char *argv[]) {
 	// Initialize basic libctru stuff
-	gfxInitDefault();
 	cfguInit();
+	gfxInitDefault();
+
+	// 800px wide top screen is not available on old 2DS systems
+	u8 systemModel = 0;
+	CFGU_GetSystemModel(&systemModel);
+	gfxSetWide(systemModel != SYSTEM_MODEL_2DS);
+
 	romfsInit();
 	osSetSpeedupEnable(true);
 // 	consoleInit(GFX_TOP, NULL);
@@ -64,7 +74,7 @@ int main(int argc, char *argv[]) {
 #endif
 	gdbHioDevExit();
 	romfsExit();
-	cfguExit();
 	gfxExit();
+	cfguExit();
 	return res;
 }
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index 2722ddb90e..9049a149bd 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -65,8 +65,11 @@ void OSystem_3DS::init3DSGraphics() {
 	C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
 
 	// Initialize the render targets
+
+	int topScreenWidth = gfxIsWide() ? 800 : 400;
+
 	_renderTargetTop =
-	    C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
+	    C3D_RenderTargetCreate(240, topScreenWidth, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
 	C3D_RenderTargetClear(_renderTargetTop, C3D_CLEAR_ALL, 0x0000000, 0);
 	C3D_RenderTargetSetOutput(_renderTargetTop, GFX_TOP, GFX_LEFT,
 	                          DISPLAY_TRANSFER_FLAGS);




More information about the Scummvm-git-logs mailing list