[Scummvm-git-logs] scummvm master -> b1fcbd51625229af371d7104c3c2ae8282653327
mduggan
mgithub at guarana.org
Fri Jun 26 10:01:47 UTC 2020
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:
b1fcbd5162 ULTIMA8: Implement Crusader computer gump
Commit: b1fcbd51625229af371d7104c3c2ae8282653327
https://github.com/scummvm/scummvm/commit/b1fcbd51625229af371d7104c3c2ae8282653327
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-06-26T19:00:46+09:00
Commit Message:
ULTIMA8: Implement Crusader computer gump
Changed paths:
A engines/ultima/ultima8/gumps/computer_gump.cpp
A engines/ultima/ultima8/gumps/computer_gump.h
engines/ultima/module.mk
engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h
engines/ultima/ultima8/ultima8.cpp
engines/ultima/ultima8/usecode/remorse_intrinsics.h
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index 96ebd7b901..88a8abea58 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -457,6 +457,7 @@ MODULE_OBJS := \
ultima8/gumps/ask_gump.o \
ultima8/gumps/bark_gump.o \
ultima8/gumps/book_gump.o \
+ ultima8/gumps/computer_gump.o \
ultima8/gumps/container_gump.o \
ultima8/gumps/credits_gump.o \
ultima8/gumps/cru_ammo_gump.o \
diff --git a/engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h b/engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h
index c62fa1ed3a..328fbdcd00 100644
--- a/engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h
+++ b/engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h
@@ -336,7 +336,7 @@ const char* const ConvertUsecodeCrusader::_intrinsics[] = {
"int16 Item::I_getQHi(Item *)", // same as 026 based on same coff set 026, 045, 047, 049, 04B, 04D, 04F, 0AF, 0BE, 0C9, 0F0, 0F3, 0FB, 133
"void Item::I_andStatus(Item *, uint16 status)", // part of same coff set 01A, 031, 069, 06E, 099, 0B2, 0BF, 0C1, 0C3, 0E9, 0FC, 101, 104, 106, 108, 10A, 10C, 10E, 110, 114, 117, 11A, 128, 132
"byte MainActor::I_hasKeycard(int)",
- "void I_displayText_0FE(char *)",
+ "void ComputerGump::I_readComputer(char *)",
"int16 UCMachine::I_numToStr(int16 num)", // same as 113 based on same coff set 0FF, 113, 126
// 0100
"int16 Item::I_getNPCNum(Item *)", // part of same coff set 067, 06D, 089, 08E, 0AD, 0F8, 100, 102, 105, 107, 109, 10B, 10D, 10F, 111, 115, 11C, 123, 129
diff --git a/engines/ultima/ultima8/gumps/computer_gump.cpp b/engines/ultima/ultima8/gumps/computer_gump.cpp
new file mode 100644
index 0000000000..25f7f99485
--- /dev/null
+++ b/engines/ultima/ultima8/gumps/computer_gump.cpp
@@ -0,0 +1,144 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "ultima/ultima8/misc/pent_include.h"
+#include "ultima/ultima8/gumps/computer_gump.h"
+#include "ultima/ultima8/gumps/widgets/text_widget.h"
+#include "ultima/ultima8/games/game_data.h"
+#include "ultima/ultima8/audio/audio_process.h"
+#include "ultima/ultima8/graphics/shape.h"
+#include "ultima/ultima8/graphics/gump_shape_archive.h"
+#include "ultima/ultima8/graphics/shape_frame.h"
+#include "ultima/ultima8/usecode/uc_machine.h"
+#include "ultima/ultima8/gumps/gump_notify_process.h"
+#include "ultima/ultima8/world/item.h"
+#include "ultima/ultima8/world/get_object.h"
+#include "ultima/ultima8/kernel/core_app.h"
+#include "ultima/ultima8/games/game_info.h"
+#include "ultima/ultima8/misc/util.h"
+
+namespace Ultima {
+namespace Ultima8 {
+
+DEFINE_RUNTIME_CLASSTYPE_CODE(ComputerGump)
+
+static const int COMPUTER_FONT = 6;
+static const int COMPUTER_GUMP_SHAPE = 30;
+static const int COMPUTER_GUMP_SOUND = 0x33;
+
+ComputerGump::ComputerGump()
+ : ModalGump() {
+
+}
+
+ComputerGump::ComputerGump(const Std::string &msg) :
+ ModalGump(0, 0, 100, 100), _text(msg) {
+}
+
+ComputerGump::~ComputerGump(void) {
+}
+
+void ComputerGump::InitGump(Gump *newparent, bool take_focus) {
+ ModalGump::InitGump(newparent, take_focus);
+
+ Shape *shape = GameData::get_instance()->getGumps()->
+ getShape(COMPUTER_GUMP_SHAPE);
+ if (!shape) {
+ error("Couldn't load shape for computer");
+ return;
+ }
+
+ const ShapeFrame *topFrame = shape->getFrame(0);
+ const ShapeFrame *botFrame = shape->getFrame(1);
+ if (!topFrame || !botFrame) {
+ error("Couldn't load shape frames for computer");
+ return;
+ }
+
+ _dims.w = topFrame->_width;
+ _dims.h = topFrame->_height + botFrame->_height;
+ _dims.x = 0;
+ _dims.y = 0;
+
+ Gump *topGump = new Gump(0, 0, topFrame->_width, topFrame->_height);
+ topGump->SetShape(shape, 0);
+ topGump->InitGump(this, false);
+ Gump *botGump = new Gump(0, topFrame->_height, botFrame->_width, botFrame->_height);
+ botGump->SetShape(shape, 1);
+ botGump->InitGump(this, false);
+
+ _textWidget = new TextWidget(42, 42, _text, true, COMPUTER_FONT, _dims.w - 42 * 2, 0, Font::TEXT_LEFT);
+ _textWidget->InitGump(this);
+
+ AudioProcess *audio = AudioProcess::get_instance();
+ if (audio) {
+ audio->playSFX(COMPUTER_GUMP_SOUND, 0x80, 0, 1);
+ }
+}
+
+void ComputerGump::run() {
+ ModalGump::run();
+ TextWidget *widget = dynamic_cast<TextWidget *>(_textWidget);
+ assert(widget);
+ //widget->setupNextText();
+
+ // TODO:
+ // * Implement gradual display of the text
+ // * Pause on '^' char
+ // * Play sound 0x33 for each letter
+ // * Add <MORE> if there is too many lines of text
+}
+
+Gump *ComputerGump::onMouseDown(int button, int32 mx, int32 my) {
+ Close();
+ return this;
+}
+
+bool ComputerGump::OnKeyDown(int key, int mod) {
+ Close();
+ return true;
+}
+
+
+
+uint32 ComputerGump::I_readComputer(const uint8 *args, unsigned int /*argsize*/) {
+ ARG_STRING(str);
+
+ Gump *gump = new ComputerGump(str);
+ gump->InitGump(0);
+ gump->setRelativePosition(CENTER);
+
+ return 0;
+}
+
+void ComputerGump::saveData(Common::WriteStream *ws) {
+ CANT_HAPPEN_MSG("Trying to load ModalGump");
+}
+
+bool ComputerGump::loadData(Common::ReadStream *rs, uint32 version) {
+ CANT_HAPPEN_MSG("Trying to load ModalGump");
+
+ return false;
+}
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/gumps/computer_gump.h b/engines/ultima/ultima8/gumps/computer_gump.h
new file mode 100644
index 0000000000..d58c86907c
--- /dev/null
+++ b/engines/ultima/ultima8/gumps/computer_gump.h
@@ -0,0 +1,73 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ULTIMA8_GUMPS_COMPUTERGUMP_H
+#define ULTIMA8_GUMPS_COMPUTERGUMP_H
+
+#include "ultima/ultima8/gumps/modal_gump.h"
+#include "ultima/ultima8/usecode/intrinsics.h"
+#include "ultima/ultima8/misc/p_dynamic_cast.h"
+
+namespace Ultima {
+namespace Ultima8 {
+
+/**
+ * The gump for showing the computer with text in Crusader
+ */
+class ComputerGump : public ModalGump {
+ Std::string _text;
+public:
+ ENABLE_RUNTIME_CLASSTYPE()
+
+ ComputerGump();
+ ComputerGump(const Std::string &msg);
+ ~ComputerGump() override;
+
+ // Close on mouse click on key press
+ Gump *onMouseDown(int button, int32 mx, int32 my) override;
+ bool OnKeyDown(int key, int mod) override;
+
+ // Init the gump, call after construction
+ void InitGump(Gump *newparent, bool take_focus = true) override;
+
+ void run() override;
+
+ INTRINSIC(I_readComputer);
+
+ bool loadData(Common::ReadStream *rs, uint32 version);
+ void saveData(Common::WriteStream *ws) override;
+
+private:
+ /*
+ TODO: Implement stepping through the text
+ int _charOff;
+ int _charX;
+ int _charY;
+ */
+
+ Gump *_textWidget;
+};
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 591954200a..059ed77cc9 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -68,6 +68,7 @@
#include "ultima/ultima8/gumps/modal_gump.h"
#include "ultima/ultima8/gumps/message_box_gump.h"
#include "ultima/ultima8/gumps/keypad_gump.h"
+#include "ultima/ultima8/gumps/computer_gump.h"
#include "ultima/ultima8/world/actors/quick_avatar_mover_process.h"
#include "ultima/ultima8/world/actors/actor.h"
#include "ultima/ultima8/world/actors/actor_anim_process.h"
diff --git a/engines/ultima/ultima8/usecode/remorse_intrinsics.h b/engines/ultima/ultima8/usecode/remorse_intrinsics.h
index f87139b50a..f2c086b42e 100644
--- a/engines/ultima/ultima8/usecode/remorse_intrinsics.h
+++ b/engines/ultima/ultima8/usecode/remorse_intrinsics.h
@@ -304,7 +304,7 @@ Intrinsic RemorseIntrinsics[] = {
Item::I_getQHi, // based on same coff set as 026
Item::I_andStatus, // void Intrinsic0FC(6 bytes)
MainActor::I_hasKeycard, // int Intrinsic0FD(2 bytes)
- 0, // void Intrinsic0FE(4 bytes)
+ ComputerGump::I_readComputer, // void Intrinsic0FE(4 bytes)
UCMachine::I_numToStr, // same as 113 based on same coff set 0FF, 113, 126
// 0x100
Item::I_getNpcNum, // based on same coff as 102 (-> variable name in TRIGGER::ordinal21)
More information about the Scummvm-git-logs
mailing list