From 3e2b25445f20773dfe55f8ca849e6aa75966e479 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Mar 2025 19:43:57 -0800 Subject: [PATCH] BAGEL: FUGE: Change to reading resources directly from DLL files Different minigames store some needed bitmaps as resources for some unknown reason. This commit introduces a new parent class MinigameView to handle accessing the resources by filenames --- devtools/create_bagel/files/.gitignore | 1 - .../create_bagel/files/hodjnpodj_files.txt | 3 - engines/bagel/hodjnpodj/fuge/defines.h | 2 +- engines/bagel/hodjnpodj/fuge/fuge.cpp | 37 ++++++----- engines/bagel/hodjnpodj/fuge/fuge.h | 4 +- engines/bagel/hodjnpodj/gfx/minigame_view.cpp | 65 ++++++++++++++++++ engines/bagel/hodjnpodj/gfx/minigame_view.h | 66 +++++++++++++++++++ engines/bagel/hodjnpodj/gfx/view.h | 4 +- engines/bagel/hodjnpodj/hodjnpodj.cpp | 9 --- engines/bagel/module.mk | 1 + 10 files changed, 157 insertions(+), 35 deletions(-) delete mode 100644 devtools/create_bagel/files/.gitignore delete mode 100644 devtools/create_bagel/files/hodjnpodj_files.txt create mode 100644 engines/bagel/hodjnpodj/gfx/minigame_view.cpp create mode 100644 engines/bagel/hodjnpodj/gfx/minigame_view.h diff --git a/devtools/create_bagel/files/.gitignore b/devtools/create_bagel/files/.gitignore deleted file mode 100644 index 72e8ffc0db8..00000000000 --- a/devtools/create_bagel/files/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/devtools/create_bagel/files/hodjnpodj_files.txt b/devtools/create_bagel/files/hodjnpodj_files.txt deleted file mode 100644 index cad0922e387..00000000000 --- a/devtools/create_bagel/files/hodjnpodj_files.txt +++ /dev/null @@ -1,3 +0,0 @@ -The following is a list of resource bitmaps: - -fuge/art/ball.bmp diff --git a/engines/bagel/hodjnpodj/fuge/defines.h b/engines/bagel/hodjnpodj/fuge/defines.h index 7bdde1b0635..47624146f63 100644 --- a/engines/bagel/hodjnpodj/fuge/defines.h +++ b/engines/bagel/hodjnpodj/fuge/defines.h @@ -58,7 +58,7 @@ namespace Fuge { // // This mini-game's main screen bitmap // -#define MINI_GAME_MAP "ART/FUGE6.BMP" +#define MINI_GAME_MAP "FUGE/ART/FUGE6.BMP" #define N_PADDLE_CELS 31 #define PADDLE_START_X 285 diff --git a/engines/bagel/hodjnpodj/fuge/fuge.cpp b/engines/bagel/hodjnpodj/fuge/fuge.cpp index 1ab7334e096..03c4f18e0b9 100644 --- a/engines/bagel/hodjnpodj/fuge/fuge.cpp +++ b/engines/bagel/hodjnpodj/fuge/fuge.cpp @@ -148,21 +148,21 @@ static const SIZE ptBrickSize[N_BRICKS] = { }; static const char *pszFugeArt[N_ROWS + 1] = { - "ART/FUGE6.BMP", - "ART/FUGE1.BMP", - "ART/FUGE2.BMP", - "ART/FUGE3.BMP", - "ART/FUGE4.BMP", - "ART/FUGE5.BMP", - "ART/FUGE6.BMP" + "FUGE/ART/FUGE6.BMP", + "FUGE/ART/FUGE1.BMP", + "FUGE/ART/FUGE2.BMP", + "FUGE/ART/FUGE3.BMP", + "FUGE/ART/FUGE4.BMP", + "FUGE/ART/FUGE5.BMP", + "FUGE/ART/FUGE6.BMP" }; #define N_PADDLE_SIZES (PSIZE_MAX + 1) static const char *pszPaddles[N_PADDLE_SIZES] = { - "ART/PADCEL45.BMP", - "ART/PADCEL60.BMP", - "ART/PADCEL90.BMP" + "FUGE/ART/PADCEL45.BMP", + "FUGE/ART/PADCEL60.BMP", + "FUGE/ART/PADCEL90.BMP" }; static double fPaddleAngles[N_PADDLE_SIZES] = { @@ -171,7 +171,7 @@ static double fPaddleAngles[N_PADDLE_SIZES] = { PADDLE2_ANGLE }; -Fuge::Fuge() : View("Fuge"), m_GamePalette(0), +Fuge::Fuge() : MinigameView("Fuge", "fuge/hnpfuge.dll"), m_GamePalette(0), m_rNewGameButton(NEWGAME_LOCATION_X, NEWGAME_LOCATION_Y, NEWGAME_LOCATION_X + NEWGAME_WIDTH, NEWGAME_LOCATION_Y + NEWGAME_HEIGHT), m_ScrollButton("ScrollButton", this, Common::Rect( @@ -180,12 +180,15 @@ Fuge::Fuge() : View("Fuge"), m_GamePalette(0), SCROLL_BUTTON_Y + SCROLL_BUTTON_DY)), m_ptOrigin(GAME_WIDTH / 2, GAME_HEIGHT / 2) { + clear(); + // The vector table is rotated by 11 or so degrees, because it // was easier to type in (125, 320) as opposed to (114.452865, 300.526372). // So the conversion is done here. realignVectors(); - clear(); + // Add mappings to resource entries + addResource("fuge/art/ball.bmp", 103); } void Fuge::clear() { @@ -217,9 +220,7 @@ void Fuge::clear() { } bool Fuge::msgOpen(const OpenMessage &msg) { - // Add the minigame's folder to the search path - Common::FSNode gamePath(ConfMan.getPath("path")); - SearchMan.addDirectory("minigame", gamePath.getChild("fuge"), 0, 2); + MinigameView::msgOpen(msg); // Clear fields clear(); @@ -249,8 +250,7 @@ bool Fuge::msgOpen(const OpenMessage &msg) { } bool Fuge::msgClose(const CloseMessage &msg) { - // Remove the SearchMan reference to our subfolder - SearchMan.remove("minigame"); + MinigameView::msgClose(msg); // Clear bitmaps _background.clear(); @@ -270,6 +270,9 @@ bool Fuge::msgKeypress(const KeypressMessage &msg) { void Fuge::draw() { paintBricks(); repaintSpriteList(); + + GfxSurface s = getSurface(); + s.blitFrom(m_pPaddle, Common::Point(360, 240)); //***DEBUG**** } void Fuge::paintBricks() { diff --git a/engines/bagel/hodjnpodj/fuge/fuge.h b/engines/bagel/hodjnpodj/fuge/fuge.h index 9b3735640e7..24370348a0e 100644 --- a/engines/bagel/hodjnpodj/fuge/fuge.h +++ b/engines/bagel/hodjnpodj/fuge/fuge.h @@ -22,7 +22,7 @@ #ifndef HODJNPODJ_FUGE_FUGE_H #define HODJNPODJ_FUGE_FUGE_H -#include "bagel/hodjnpodj/gfx/view.h" +#include "bagel/hodjnpodj/gfx/minigame_view.h" #include "bagel/hodjnpodj/gfx/bmp_button.h" #include "bagel/hodjnpodj/boflib/vector.h" #include "bagel/hodjnpodj/fuge/defines.h" @@ -33,7 +33,7 @@ namespace Bagel { namespace HodjNPodj { namespace Fuge { -class Fuge : public View { +class Fuge : public MinigameView { private: BmpButton m_ScrollButton; Graphics::Palette m_GamePalette; diff --git a/engines/bagel/hodjnpodj/gfx/minigame_view.cpp b/engines/bagel/hodjnpodj/gfx/minigame_view.cpp new file mode 100644 index 00000000000..c37035fdadf --- /dev/null +++ b/engines/bagel/hodjnpodj/gfx/minigame_view.cpp @@ -0,0 +1,65 @@ +/* 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 3 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, see . + * + */ + +#include "common/file.h" +#include "common/formats/winexe_ne.h" +#include "bagel/hodjnpodj/gfx/minigame_view.h" + +namespace Bagel { +namespace HodjNPodj { + +bool MinigameView::msgOpen(const OpenMessage &msg) { + SearchMan.add("Resources", this, 0, false); + + return View::msgOpen(msg); +} + +bool MinigameView::msgClose(const CloseMessage &msg) { + SearchMan.remove("Resources"); + + return View::msgClose(msg); +} + +bool MinigameView::hasFile(const Common::Path &path) const { + return _resourceFiles.contains(path.baseName()); +} + +int MinigameView::listMembers(Common::ArchiveMemberList &list) const { + return 0; +} + +const Common::ArchiveMemberPtr MinigameView::getMember(const Common::Path &path) const { + return Common::ArchiveMemberPtr(); +} + +Common::SeekableReadStream *MinigameView::createReadStreamForMember(const Common::Path &path) const { + Common::NEResources winResources; + + if (!_resourceFiles.contains(path.toString()) || + !winResources.loadFromEXE(Common::Path(_resourceFilename))) + return nullptr; + + return winResources.getResource(Common::kWinBitmap, + _resourceFiles[path.toString()]); +} + +} // namespace HodjNPodj +} // namespace Bagel diff --git a/engines/bagel/hodjnpodj/gfx/minigame_view.h b/engines/bagel/hodjnpodj/gfx/minigame_view.h new file mode 100644 index 00000000000..e8f3ccdbcbe --- /dev/null +++ b/engines/bagel/hodjnpodj/gfx/minigame_view.h @@ -0,0 +1,66 @@ +/* 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 3 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, see . + * + */ + +#ifndef HODJNPODJ_GFX_MINIGAME_VIEW_H +#define HODJNPODJ_GFX_MINIGAME_VIEW_H + +#include "common/archive.h" +#include "common/hashmap.h" +#include "common/formats/winexe_ne.h" +#include "bagel/hodjnpodj/gfx/view.h" + +namespace Bagel { +namespace HodjNPodj { + +/** + * Base view class for the main view for each minigame + */ +class MinigameView : public View, public Common::Archive { +private: + Common::String _resourceFilename; + Common::HashMap _resourceFiles; + +protected: + void addResource(const Common::String &filename, int resourceId) { + _resourceFiles[filename] = resourceId; + } + +public: + MinigameView(const Common::String &name, const Common::String &resFilename) : + View(name), _resourceFilename(resFilename) { + } + virtual ~MinigameView() {} + + bool msgOpen(const OpenMessage &msg) override; + bool msgClose(const CloseMessage &msg) override; + + // Archive methods + bool hasFile(const Common::Path &path) const override; + int listMembers(Common::ArchiveMemberList &list) const override; + const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override; + Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const; +}; + +} // namespace HodjNPodj +} // namespace Bagel + +#endif diff --git a/engines/bagel/hodjnpodj/gfx/view.h b/engines/bagel/hodjnpodj/gfx/view.h index 824603b36d3..9dd843334c9 100644 --- a/engines/bagel/hodjnpodj/gfx/view.h +++ b/engines/bagel/hodjnpodj/gfx/view.h @@ -19,8 +19,8 @@ * */ -#ifndef HODJNPODJ_VIEW_H -#define HODJNPODJ_VIEW_H +#ifndef HODJNPODJ_GFX_VIEW_H +#define HODJNPODJ_GFX_VIEW_H #include "bagel/hodjnpodj/events.h" diff --git a/engines/bagel/hodjnpodj/hodjnpodj.cpp b/engines/bagel/hodjnpodj/hodjnpodj.cpp index fb990287f8f..417e225c8fe 100644 --- a/engines/bagel/hodjnpodj/hodjnpodj.cpp +++ b/engines/bagel/hodjnpodj/hodjnpodj.cpp @@ -22,7 +22,6 @@ #include "common/scummsys.h" #include "common/config-manager.h" #include "common/debug-channels.h" -#include "common/engine_data.h" #include "common/events.h" #include "common/system.h" #include "engines/util.h" @@ -66,14 +65,6 @@ Common::Error HodjNPodjEngine::run() { // Set the engine's debugger console setDebugger(new Console()); - // Initialise engine data for the game - Common::U32String errMsg; - if (!Common::load_engine_data("bagel.dat", "", 1, 0, errMsg)) { - GUIErrorMessage("Could not find bagel.dat data file"); - const Common::String msg(errMsg); - error("%s", msg.c_str()); - } - // Run the game runGame(); diff --git a/engines/bagel/module.mk b/engines/bagel/module.mk index 5c07c680ee3..92b3bfe32ff 100644 --- a/engines/bagel/module.mk +++ b/engines/bagel/module.mk @@ -121,6 +121,7 @@ MODULE_OBJS = \ hodjnpodj/messages.o \ hodjnpodj/gfx/bmp_button.o \ hodjnpodj/gfx/gfx_surface.o \ + hodjnpodj/gfx/minigame_view.o \ hodjnpodj/gfx/view.o \ hodjnpodj/boflib/vector.o \ hodjnpodj/dialogs/rules.o \