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
This commit is contained in:
Paul Gilbert
2025-03-01 19:43:57 -08:00
committed by Eugene Sandulenko
parent ed0135946f
commit 3e2b25445f
10 changed files with 157 additions and 35 deletions
-1
View File
@@ -1 +0,0 @@
*
@@ -1,3 +0,0 @@
The following is a list of resource bitmaps:
fuge/art/ball.bmp
+1 -1
View File
@@ -58,7 +58,7 @@ namespace Fuge {
// //
// This mini-game's main screen bitmap // 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 N_PADDLE_CELS 31
#define PADDLE_START_X 285 #define PADDLE_START_X 285
+20 -17
View File
@@ -148,21 +148,21 @@ static const SIZE ptBrickSize[N_BRICKS] = {
}; };
static const char *pszFugeArt[N_ROWS + 1] = { static const char *pszFugeArt[N_ROWS + 1] = {
"ART/FUGE6.BMP", "FUGE/ART/FUGE6.BMP",
"ART/FUGE1.BMP", "FUGE/ART/FUGE1.BMP",
"ART/FUGE2.BMP", "FUGE/ART/FUGE2.BMP",
"ART/FUGE3.BMP", "FUGE/ART/FUGE3.BMP",
"ART/FUGE4.BMP", "FUGE/ART/FUGE4.BMP",
"ART/FUGE5.BMP", "FUGE/ART/FUGE5.BMP",
"ART/FUGE6.BMP" "FUGE/ART/FUGE6.BMP"
}; };
#define N_PADDLE_SIZES (PSIZE_MAX + 1) #define N_PADDLE_SIZES (PSIZE_MAX + 1)
static const char *pszPaddles[N_PADDLE_SIZES] = { static const char *pszPaddles[N_PADDLE_SIZES] = {
"ART/PADCEL45.BMP", "FUGE/ART/PADCEL45.BMP",
"ART/PADCEL60.BMP", "FUGE/ART/PADCEL60.BMP",
"ART/PADCEL90.BMP" "FUGE/ART/PADCEL90.BMP"
}; };
static double fPaddleAngles[N_PADDLE_SIZES] = { static double fPaddleAngles[N_PADDLE_SIZES] = {
@@ -171,7 +171,7 @@ static double fPaddleAngles[N_PADDLE_SIZES] = {
PADDLE2_ANGLE 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, m_rNewGameButton(NEWGAME_LOCATION_X, NEWGAME_LOCATION_Y,
NEWGAME_LOCATION_X + NEWGAME_WIDTH, NEWGAME_LOCATION_Y + NEWGAME_HEIGHT), NEWGAME_LOCATION_X + NEWGAME_WIDTH, NEWGAME_LOCATION_Y + NEWGAME_HEIGHT),
m_ScrollButton("ScrollButton", this, Common::Rect( m_ScrollButton("ScrollButton", this, Common::Rect(
@@ -180,12 +180,15 @@ Fuge::Fuge() : View("Fuge"), m_GamePalette(0),
SCROLL_BUTTON_Y + SCROLL_BUTTON_DY)), SCROLL_BUTTON_Y + SCROLL_BUTTON_DY)),
m_ptOrigin(GAME_WIDTH / 2, GAME_HEIGHT / 2) { m_ptOrigin(GAME_WIDTH / 2, GAME_HEIGHT / 2) {
clear();
// The vector table is rotated by 11 or so degrees, because it // 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). // was easier to type in (125, 320) as opposed to (114.452865, 300.526372).
// So the conversion is done here. // So the conversion is done here.
realignVectors(); realignVectors();
clear(); // Add mappings to resource entries
addResource("fuge/art/ball.bmp", 103);
} }
void Fuge::clear() { void Fuge::clear() {
@@ -217,9 +220,7 @@ void Fuge::clear() {
} }
bool Fuge::msgOpen(const OpenMessage &msg) { bool Fuge::msgOpen(const OpenMessage &msg) {
// Add the minigame's folder to the search path MinigameView::msgOpen(msg);
Common::FSNode gamePath(ConfMan.getPath("path"));
SearchMan.addDirectory("minigame", gamePath.getChild("fuge"), 0, 2);
// Clear fields // Clear fields
clear(); clear();
@@ -249,8 +250,7 @@ bool Fuge::msgOpen(const OpenMessage &msg) {
} }
bool Fuge::msgClose(const CloseMessage &msg) { bool Fuge::msgClose(const CloseMessage &msg) {
// Remove the SearchMan reference to our subfolder MinigameView::msgClose(msg);
SearchMan.remove("minigame");
// Clear bitmaps // Clear bitmaps
_background.clear(); _background.clear();
@@ -270,6 +270,9 @@ bool Fuge::msgKeypress(const KeypressMessage &msg) {
void Fuge::draw() { void Fuge::draw() {
paintBricks(); paintBricks();
repaintSpriteList(); repaintSpriteList();
GfxSurface s = getSurface();
s.blitFrom(m_pPaddle, Common::Point(360, 240)); //***DEBUG****
} }
void Fuge::paintBricks() { void Fuge::paintBricks() {
+2 -2
View File
@@ -22,7 +22,7 @@
#ifndef HODJNPODJ_FUGE_FUGE_H #ifndef HODJNPODJ_FUGE_FUGE_H
#define 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/gfx/bmp_button.h"
#include "bagel/hodjnpodj/boflib/vector.h" #include "bagel/hodjnpodj/boflib/vector.h"
#include "bagel/hodjnpodj/fuge/defines.h" #include "bagel/hodjnpodj/fuge/defines.h"
@@ -33,7 +33,7 @@ namespace Bagel {
namespace HodjNPodj { namespace HodjNPodj {
namespace Fuge { namespace Fuge {
class Fuge : public View { class Fuge : public MinigameView {
private: private:
BmpButton m_ScrollButton; BmpButton m_ScrollButton;
Graphics::Palette m_GamePalette; Graphics::Palette m_GamePalette;
@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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
@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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<Common::String, int,
Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _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
+2 -2
View File
@@ -19,8 +19,8 @@
* *
*/ */
#ifndef HODJNPODJ_VIEW_H #ifndef HODJNPODJ_GFX_VIEW_H
#define HODJNPODJ_VIEW_H #define HODJNPODJ_GFX_VIEW_H
#include "bagel/hodjnpodj/events.h" #include "bagel/hodjnpodj/events.h"
-9
View File
@@ -22,7 +22,6 @@
#include "common/scummsys.h" #include "common/scummsys.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/debug-channels.h" #include "common/debug-channels.h"
#include "common/engine_data.h"
#include "common/events.h" #include "common/events.h"
#include "common/system.h" #include "common/system.h"
#include "engines/util.h" #include "engines/util.h"
@@ -66,14 +65,6 @@ Common::Error HodjNPodjEngine::run() {
// Set the engine's debugger console // Set the engine's debugger console
setDebugger(new 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 // Run the game
runGame(); runGame();
+1
View File
@@ -121,6 +121,7 @@ MODULE_OBJS = \
hodjnpodj/messages.o \ hodjnpodj/messages.o \
hodjnpodj/gfx/bmp_button.o \ hodjnpodj/gfx/bmp_button.o \
hodjnpodj/gfx/gfx_surface.o \ hodjnpodj/gfx/gfx_surface.o \
hodjnpodj/gfx/minigame_view.o \
hodjnpodj/gfx/view.o \ hodjnpodj/gfx/view.o \
hodjnpodj/boflib/vector.o \ hodjnpodj/boflib/vector.o \
hodjnpodj/dialogs/rules.o \ hodjnpodj/dialogs/rules.o \