[Scummvm-git-logs] scummvm master -> 066979c96a47a7edf273e1c9a9b3acef92b430ba

ccawley2011 noreply at scummvm.org
Thu Dec 22 18:21:13 UTC 2022


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

Summary:
066979c96a DS: Display the ScummVM logo on the top screen when the launcher is active


Commit: 066979c96a47a7edf273e1c9a9b3acef92b430ba
    https://github.com/scummvm/scummvm/commit/066979c96a47a7edf273e1c9a9b3acef92b430ba
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-12-22T18:21:04Z

Commit Message:
DS: Display the ScummVM logo on the top screen when the launcher is active

Changed paths:
  A backends/platform/ds/gfx/banner.grit
  A backends/platform/ds/gfx/banner.png
    .gitignore
    backends/platform/ds/background.cpp
    backends/platform/ds/background.h
    backends/platform/ds/ds-graphics.cpp
    backends/platform/ds/ds.mk
    backends/platform/ds/module.mk
    backends/platform/ds/osystem_ds.cpp
    backends/platform/ds/osystem_ds.h


diff --git a/.gitignore b/.gitignore
index a53f2f0b5fd..cee8d1665df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -81,6 +81,9 @@ lib*.a
 /backends/platform/dc/SCUMMVM.BIN
 /backends/platform/dc/*.PLG
 
+/backends/platform/ds/gfx/*.s
+/backends/platform/ds/gfx/*.h
+
 /backends/platform/maemo/scummvm
 
 /dists/rpl.exe
diff --git a/backends/platform/ds/background.cpp b/backends/platform/ds/background.cpp
index ac0f1c77bb0..9e03a36175c 100644
--- a/backends/platform/ds/background.cpp
+++ b/backends/platform/ds/background.cpp
@@ -214,4 +214,43 @@ Common::Point Background::scaledToReal(int16 x, int16 y) const {
 	return Common::Point(x, y);
 }
 
+TiledBackground::TiledBackground(const unsigned int *tiles, size_t tilesLen, const unsigned short *map, size_t mapLen, int layer, bool isSub, int mapBase, int tileBase) :
+	_tiles(tiles), _tilesLen(tilesLen), _map(map), _mapLen(mapLen),
+	_bg(-1), _visible(true) {
+
+	if (isSub) {
+		_bg = bgInitSub(layer, BgType_Text8bpp, BgSize_T_256x256, mapBase, tileBase);
+	} else {
+		_bg = bgInit(layer, BgType_Text8bpp, BgSize_T_256x256, mapBase, tileBase);
+	}
+}
+
+void TiledBackground::update() {
+	if (_bg < 0)
+		return;
+
+	dmaCopy(_tiles, bgGetGfxPtr(_bg), _tilesLen);
+	dmaCopy(_map, bgGetMapPtr(_bg), _mapLen);
+}
+
+void TiledBackground::reset() {
+	if (_bg < 0)
+		return;
+
+	dmaFillHalfWords(0, bgGetMapPtr(_bg), _mapLen);
+	dmaFillHalfWords(0, bgGetGfxPtr(_bg), _tilesLen);
+}
+
+void TiledBackground::show() {
+	if (_bg >= 0)
+		bgShow(_bg);
+	_visible = true;
+}
+
+void TiledBackground::hide() {
+	if (_bg >= 0)
+		bgHide(_bg);
+	_visible = false;
+}
+
 } // End of namespace DS
diff --git a/backends/platform/ds/background.h b/backends/platform/ds/background.h
index cc74203ae1b..79a917b7f56 100644
--- a/backends/platform/ds/background.h
+++ b/backends/platform/ds/background.h
@@ -59,6 +59,26 @@ protected:
 	Graphics::Surface *_surface;
 };
 
+class TiledBackground {
+public:
+	TiledBackground(const unsigned int *tiles, size_t tilesLen, const unsigned short *map, size_t mapLen, int layer, bool isSub, int mapBase, int tileBase);
+
+	void update();
+	void reset();
+
+	void show();
+	void hide();
+	inline bool isVisible() const { return _visible; }
+
+protected:
+	const unsigned int *_tiles;
+	const unsigned short *_map;
+	size_t _tilesLen, _mapLen;
+
+	int _bg;
+	bool _visible;
+};
+
 } // End of namespace DS
 
 #endif // #ifndef DS_BACKGROUND_H
diff --git a/backends/platform/ds/ds-graphics.cpp b/backends/platform/ds/ds-graphics.cpp
index 75ae848cef6..a1b2a4f6353 100644
--- a/backends/platform/ds/ds-graphics.cpp
+++ b/backends/platform/ds/ds-graphics.cpp
@@ -22,6 +22,7 @@
 #include <nds.h>
 
 #include "backends/platform/ds/osystem_ds.h"
+#include "backends/platform/ds/gfx/banner.h"
 
 #include "common/translation.h"
 
@@ -167,6 +168,13 @@ void initHardware() {
 
 #ifdef DISABLE_TEXT_CONSOLE
 	videoSetModeSub(MODE_3_2D | DISPLAY_BG3_ACTIVE);
+
+	bgExtPaletteEnableSub();
+
+	/* The extended palette data can only be accessed in LCD mode. */
+	vramSetBankH(VRAM_H_LCD);
+	dmaCopy(bannerPal, &VRAM_H_EXT_PALETTE[1][0], bannerPalLen);
+	vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
 #endif
 }
 
@@ -185,11 +193,12 @@ void OSystem_DS::initGraphics() {
 	_screen = nullptr;
 #ifndef DISABLE_TEXT_CONSOLE
 	_subScreen = nullptr;
+	_banner = nullptr;
 #endif
 
 	_keyboard = new DS::Keyboard(_eventManager->getEventDispatcher());
 #ifndef DISABLE_TEXT_CONSOLE
-	_keyboard->init(0, 34, 1, false);
+	_keyboard->init(0, 21, 1, false);
 #endif
 }
 
@@ -226,8 +235,10 @@ void OSystem_DS::setFeatureState(Feature f, bool enable) {
 				if (_subScreen) {
 					_subScreen->hide();
 					_subScreen->reset();
+				} else if (_banner) {
+					_banner->hide();
 				}
-				_keyboard->init(0, 34, 1, false);
+				_keyboard->init(0, 21, 1, false);
 			}
 #endif
 			_keyboard->show();
@@ -237,9 +248,11 @@ void OSystem_DS::setFeatureState(Feature f, bool enable) {
 			if (_subScreen) {
 				_subScreen->reset();
 				_subScreen->show();
+				_paletteDirty = true;
+			} else if (_banner) {
+				_banner->show();
 			}
 			_subScreenActive = true;
-			_paletteDirty = true;
 #endif
 			setSwapLCDs(false);
 		}
@@ -357,8 +370,22 @@ void OSystem_DS::initSize(uint width, uint height, const Graphics::PixelFormat *
 	delete _subScreen;
 	_subScreen = nullptr;
 
-	if (DS::Background::getRequiredVRAM(width, height, isRGB, false) <= 0x20000) {
-		_subScreen = new DS::Background(&_framebuffer, 3, true, 0, false);
+	if (_engineRunning) {
+		if (_banner) {
+			_banner->reset();
+			_banner->hide();
+		}
+
+		delete _banner;
+		_banner = nullptr;
+
+		if (DS::Background::getRequiredVRAM(width, height, isRGB, false) <= 0x20000) {
+			_subScreen = new DS::Background(&_framebuffer, 3, true, 0, false);
+		}
+	} else {
+		if (!_banner)
+			_banner = new DS::TiledBackground(bannerTiles, bannerTilesLen, bannerMap, bannerMapLen, 1, true, 30, 0);
+		_banner->update();
 	}
 #endif
 
@@ -430,7 +457,7 @@ void OSystem_DS::updateScreen() {
 	if (_paletteDirty) {
 		dmaCopyHalfWords(3, _palette, BG_PALETTE, 256 * 2);
 #ifdef DISABLE_TEXT_CONSOLE
-		if (_subScreenActive)
+		if (_subScreen && _subScreenActive)
 			dmaCopyHalfWords(3, _palette, BG_PALETTE_SUB, 256 * 2);
 #endif
 		_paletteDirty = false;
diff --git a/backends/platform/ds/ds.mk b/backends/platform/ds/ds.mk
index 10e1591ed65..2d5acd64c43 100644
--- a/backends/platform/ds/ds.mk
+++ b/backends/platform/ds/ds.mk
@@ -4,11 +4,16 @@ else
 DESCRIPTION ?= DS Port
 endif
 
+NDSTOOL ?= ndstool
+GRIT ?= grit
+
 all: scummvm.nds
 
 clean: dsclean
 
 dsclean:
+	$(RM) backends/platform/ds/gfx/*.h
+	$(RM) backends/platform/ds/gfx/*.s
 	$(RM) scummvm.nds
 	$(RM) map.txt
 	$(RM_REC) romfs
@@ -23,7 +28,7 @@ dsdist: scummvm.nds $(DIST_FILES_DOCS)
 .PHONY: dsclean dsdist
 
 %.nds: %.elf romfs
-	ndstool -c $@ -9 $< -b $(srcdir)/backends/platform/ds/logo.bmp "$(@F);ScummVM $(VERSION);$(DESCRIPTION)" -d romfs
+	$(NDSTOOL) -c $@ -9 $< -b $(srcdir)/backends/platform/ds/logo.bmp "$(@F);ScummVM $(VERSION);$(DESCRIPTION)" -d romfs
 
 romfs: $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD) $(PLUGINS)
 	@rm -rf romfs
@@ -44,6 +49,16 @@ ifeq ($(DYNAMIC_MODULES),1)
 endif
 
 
+QUIET_GRIT    = @echo '   ' GRIT '   ' $@;
+
+vpath %.grit $(srcdir)
+vpath %.png $(srcdir)
+
+%.s %.h	: %.png %.grit
+	$(QUIET)$(MKDIR) $(*D)
+	$(QUIET_GRIT)$(GRIT) $< -fts -o$*
+
+
 # Command to build libmad is:
 # ./configure --host=arm-elf --enable-speed --enable-sso -enable-fpm=arm CFLAGS='-specs=ds_arm9.specs -mthumb-interwork'
 #
diff --git a/backends/platform/ds/gfx/banner.grit b/backends/platform/ds/gfx/banner.grit
new file mode 100644
index 00000000000..d993e0e2fce
--- /dev/null
+++ b/backends/platform/ds/gfx/banner.grit
@@ -0,0 +1,11 @@
+# 8 bit bitmap
+-gB8
+
+# tile format
+-gt
+
+# tile reduction by tiles, palette and hflip/vflip
+-mRtf
+
+# map layout standard bg format
+-mLs
diff --git a/backends/platform/ds/gfx/banner.png b/backends/platform/ds/gfx/banner.png
new file mode 100644
index 00000000000..2c269fd8d83
Binary files /dev/null and b/backends/platform/ds/gfx/banner.png differ
diff --git a/backends/platform/ds/module.mk b/backends/platform/ds/module.mk
index 0a689453a1b..33203155125 100644
--- a/backends/platform/ds/module.mk
+++ b/backends/platform/ds/module.mk
@@ -6,7 +6,8 @@ MODULE_OBJS := \
 	ds-graphics.o \
 	dsmain.o \
 	keyboard.o \
-	osystem_ds.o
+	osystem_ds.o \
+	gfx/banner.o
 
 # We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
 MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
diff --git a/backends/platform/ds/osystem_ds.cpp b/backends/platform/ds/osystem_ds.cpp
index 30029fb1aed..4f8ee2bc1de 100644
--- a/backends/platform/ds/osystem_ds.cpp
+++ b/backends/platform/ds/osystem_ds.cpp
@@ -44,7 +44,7 @@
 OSystem_DS *OSystem_DS::_instance = NULL;
 
 OSystem_DS::OSystem_DS()
-	: _eventSource(NULL), _disableCursorPalette(true),
+	: _eventSource(NULL), _engineRunning(false), _disableCursorPalette(true),
 	_graphicsMode(GFX_HWSCALE), _stretchMode(100),
 	_paletteDirty(false), _cursorDirty(false), _overlayInGUI(false),
 	_pfCLUT8(Graphics::PixelFormat::createFormatCLUT8()),
@@ -209,3 +209,11 @@ Common::String OSystem_DS::getSystemLanguage() const {
 		default: return "en_US";
 	}
 }
+
+void OSystem_DS::engineInit() {
+	_engineRunning = true;
+}
+
+void OSystem_DS::engineDone() {
+	_engineRunning = false;
+}
diff --git a/backends/platform/ds/osystem_ds.h b/backends/platform/ds/osystem_ds.h
index 5a189f684f4..113d76bb9f4 100644
--- a/backends/platform/ds/osystem_ds.h
+++ b/backends/platform/ds/osystem_ds.h
@@ -43,6 +43,7 @@ protected:
 	DS::Background *_screen, *_overlayScreen;
 #ifdef DISABLE_TEXT_CONSOLE
 	DS::Background *_subScreen;
+	DS::TiledBackground *_banner;
 #endif
 	bool _subScreenActive;
 	Graphics::Surface _cursor;
@@ -71,6 +72,8 @@ protected:
 
 	const Graphics::PixelFormat _pfCLUT8, _pfABGR1555;
 
+	bool _engineRunning;
+
 public:
 	OSystem_DS();
 	virtual ~OSystem_DS();
@@ -138,6 +141,8 @@ public:
 
 	virtual Common::String getSystemLanguage() const;
 
+	virtual void engineInit();
+	virtual void engineDone();
 	virtual void quit();
 
 	virtual void setFocusRectangle(const Common::Rect& rect);




More information about the Scummvm-git-logs mailing list