[Scummvm-git-logs] scummvm master -> 84627d68a7171fc7870e0a2cee065a33866385e0
sev-
noreply at scummvm.org
Wed Feb 25 10:14:24 UTC 2026
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
ab0087f3f3 SCUMM: EDITOR: Introduce File class
84627d68a7 SCUMM: EDITOR: Introduce Resource class
Commit: ab0087f3f329f3f5ed120cf977ed22dcd69689b6
https://github.com/scummvm/scummvm/commit/ab0087f3f329f3f5ed120cf977ed22dcd69689b6
Author: Sebastien Ronsse (sronsse at gmail.com)
Date: 2026-02-25T11:14:20+01:00
Commit Message:
SCUMM: EDITOR: Introduce File class
Changed paths:
A engines/scumm/debugger/file.cpp
A engines/scumm/debugger/file.h
engines/scumm/module.mk
diff --git a/engines/scumm/debugger/file.cpp b/engines/scumm/debugger/file.cpp
new file mode 100644
index 00000000000..49e29ee03e6
--- /dev/null
+++ b/engines/scumm/debugger/file.cpp
@@ -0,0 +1,115 @@
+/* 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/endian.h"
+#include "common/fs.h"
+
+#include "scumm/debugger/file.h"
+
+namespace Scumm {
+
+namespace Editor {
+
+File::File()
+ : _encByte(0),
+ _stream(nullptr) {
+}
+
+File::~File() {
+ close();
+}
+
+bool File::open(const Common::Path &path, byte encByte) {
+ close();
+
+ _path = path;
+ _encByte = encByte;
+ _stream = Common::FSNode(path).createReadStream();
+
+ return _stream != nullptr;
+}
+
+void File::close() {
+ delete _stream;
+ _stream = nullptr;
+}
+
+const Common::Path &File::getPath() const {
+ return _path;
+}
+
+int64 File::pos() const {
+ return _stream ? _stream->pos() : 0;
+}
+
+int64 File::size() const {
+ return _stream ? _stream->size() : 0;
+}
+
+bool File::seek(int64 offs, int whence) {
+ return _stream ? _stream->seek(offs, whence) : false;
+}
+
+uint32 File::read(void *dataPtr, uint32 dataSize) {
+ if (!_stream)
+ return 0;
+
+ uint32 bytesRead = _stream->read(dataPtr, dataSize);
+ byte *p = (byte *)dataPtr;
+ for (uint32 i = 0; i < bytesRead; ++i)
+ p[i] ^= _encByte;
+
+ return bytesRead;
+}
+
+byte File::readByte() {
+ byte b = 0;
+ read(&b, 1);
+ return b;
+}
+
+uint16 File::readUint16LE() {
+ byte buf[2];
+ read(buf, 2);
+ return READ_LE_UINT16(buf);
+}
+
+uint32 File::readUint32LE() {
+ byte buf[4];
+ read(buf, 4);
+ return READ_LE_UINT32(buf);
+}
+
+uint16 File::readUint16BE() {
+ byte buf[2];
+ read(buf, 2);
+ return READ_BE_UINT16(buf);
+}
+
+uint32 File::readUint32BE() {
+ byte buf[4];
+ read(buf, 4);
+ return READ_BE_UINT32(buf);
+}
+
+} // End of namespace Editor
+
+} // End of namespace Scumm
diff --git a/engines/scumm/debugger/file.h b/engines/scumm/debugger/file.h
new file mode 100644
index 00000000000..32313e27463
--- /dev/null
+++ b/engines/scumm/debugger/file.h
@@ -0,0 +1,64 @@
+/* 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 SCUMM_EDITOR_FILE_H
+#define SCUMM_EDITOR_FILE_H
+
+#include "common/noncopyable.h"
+#include "common/path.h"
+#include "common/stream.h"
+
+namespace Scumm {
+
+namespace Editor {
+
+class File : public Common::NonCopyable {
+private:
+ Common::Path _path;
+ byte _encByte;
+ Common::SeekableReadStream *_stream;
+
+public:
+ File();
+ ~File();
+
+ bool open(const Common::Path &path, byte encByte);
+ void close();
+
+ const Common::Path &getPath() const;
+
+ int64 pos() const;
+ int64 size() const;
+ bool seek(int64 offs, int whence = SEEK_SET);
+ uint32 read(void *dataPtr, uint32 dataSize);
+
+ byte readByte();
+ uint16 readUint16LE();
+ uint32 readUint32LE();
+ uint16 readUint16BE();
+ uint32 readUint32BE();
+};
+
+} // End of namespace Editor
+
+} // End of namespace Scumm
+
+#endif
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk
index 3e59ad2fa07..0867fdb3e91 100644
--- a/engines/scumm/module.mk
+++ b/engines/scumm/module.mk
@@ -99,7 +99,8 @@ MODULE_OBJS := \
ifdef USE_IMGUI
MODULE_OBJS += \
debugger/debugtools.o \
- debugger/editor.o
+ debugger/editor.o \
+ debugger/file.o
endif
ifdef USE_ARM_COSTUME_ASM
Commit: 84627d68a7171fc7870e0a2cee065a33866385e0
https://github.com/scummvm/scummvm/commit/84627d68a7171fc7870e0a2cee065a33866385e0
Author: Sebastien Ronsse (sronsse at gmail.com)
Date: 2026-02-25T11:14:20+01:00
Commit Message:
SCUMM: EDITOR: Introduce Resource class
Changed paths:
A engines/scumm/debugger/resource.cpp
A engines/scumm/debugger/resource.h
engines/scumm/module.mk
diff --git a/engines/scumm/debugger/resource.cpp b/engines/scumm/debugger/resource.cpp
new file mode 100644
index 00000000000..1ac7642beef
--- /dev/null
+++ b/engines/scumm/debugger/resource.cpp
@@ -0,0 +1,171 @@
+/* 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 "scumm/debugger/file.h"
+#include "scumm/debugger/resource.h"
+
+namespace Scumm {
+
+namespace Editor {
+
+static const int headerSize = 8;
+
+Resource::Resource(int version)
+ : _version(version) {
+ if (_version < 5)
+ warning("Editor: SCUMM v%d resources not supported", _version);
+}
+
+Resource::~Resource() {
+ for (uint i = 0; i < _files.size(); ++i)
+ delete _files[i];
+}
+
+void Resource::buildBlocks(File &file, uint32 startOffset, uint32 endOffset, int parentIndex, Common::Array<Block> &blocks) {
+ // Parse provided range
+ uint32 offset = startOffset;
+ while (offset + headerSize <= endOffset) {
+ file.seek(offset);
+ uint32 tag = file.readUint32BE();
+ uint32 size = file.readUint32BE();
+
+ // Break if data is exhausted
+ if (size < headerSize || offset + size > endOffset)
+ break;
+
+ // Push block
+ int blockIndex = blocks.size();
+ Block block;
+ block.offset = offset;
+ block.tag = tag;
+ block.size = size;
+ block.parent = parentIndex;
+ blocks.push_back(block);
+
+ // Add block to parent
+ if (parentIndex >= 0)
+ blocks[parentIndex].children.push_back(blockIndex);
+
+ // Build children blocks
+ if (isContainerBlock(tag)) {
+ buildBlocks(file, offset + headerSize, offset + size, blockIndex, blocks);
+
+ // Warn if children sizes don't match parent payload
+ uint32 childrenSize = 0;
+ for (uint i = 0; i < blocks[blockIndex].children.size(); ++i)
+ childrenSize += blocks[blocks[blockIndex].children[i]].size;
+ if (childrenSize != size - headerSize)
+ warning("Editor: %s at 0x%08X children size mismatch (%u vs %u)", tag2str(tag), offset, childrenSize, size - headerSize);
+ }
+
+ offset += size;
+ }
+}
+
+bool Resource::isContainerBlock(uint32 tag) const {
+ // Handle v5+ blocks
+ if (_version >= 5)
+ switch (tag) {
+ case MKTAG('L','E','C','F'):
+ case MKTAG('L','F','L','F'):
+ case MKTAG('O','B','C','D'):
+ case MKTAG('O','B','I','M'):
+ case MKTAG('R','M','I','M'):
+ case MKTAG('R','O','O','M'):
+ case MKTAG('W','R','A','P'):
+ return true;
+ default:
+ break;
+ }
+
+ // Handle v6+ blocks
+ if (_version >= 6)
+ switch (tag) {
+ case MKTAG('P','A','L','S'):
+ return true;
+ default:
+ break;
+ }
+
+ // Handle v5-v7 IMxx blocks
+ if (_version >= 5 && _version <= 7) {
+ byte b0 = (tag >> 24) & 0xFF;
+ byte b1 = (tag >> 16) & 0xFF;
+ byte b2 = (tag >> 8) & 0xFF;
+ byte b3 = tag & 0xFF;
+ if (b0 == 'I' && b1 == 'M' && Common::isXDigit(b2) && Common::isXDigit(b3))
+ return true;
+ }
+
+ // Handle v7+ blocks
+ if (_version >= 7)
+ switch (tag) {
+ case MKTAG('A','K','O','S'):
+ return true;
+ default:
+ break;
+ }
+
+ // Handle v8 blocks
+ if (_version == 8)
+ switch (tag) {
+ case MKTAG('I','M','A','G'):
+ case MKTAG('R','M','S','C'):
+ case MKTAG('S','M','A','P'):
+ case MKTAG('Z','P','L','N'):
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
+void Resource::addFile(const Common::Path &path, byte encByte) {
+ // Open resource file
+ File *file = new File();
+ if (!file->open(path, encByte)) {
+ delete file;
+ return;
+ }
+ _files.push_back(file);
+
+ // Build block tree
+ Common::Array<Block> blocks;
+ buildBlocks(*file, 0, (uint32)file->size(), -1, blocks);
+ _blocks.push_back(blocks);
+}
+
+int Resource::getFileCount() const {
+ return _files.size();
+}
+
+File *Resource::getFile(int index) {
+ return _files[index];
+}
+
+const Common::Array<Block> &Resource::getBlocks(int index) const {
+ return _blocks[index];
+}
+
+} // End of namespace Editor
+
+} // End of namespace Scumm
diff --git a/engines/scumm/debugger/resource.h b/engines/scumm/debugger/resource.h
new file mode 100644
index 00000000000..8198ea361af
--- /dev/null
+++ b/engines/scumm/debugger/resource.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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef SCUMM_EDITOR_RESOURCE_H
+#define SCUMM_EDITOR_RESOURCE_H
+
+#include "common/array.h"
+#include "common/noncopyable.h"
+#include "common/path.h"
+
+namespace Scumm {
+
+namespace Editor {
+
+class File;
+
+struct Block {
+ uint32 offset;
+ uint32 tag;
+ uint32 size;
+ int parent;
+ Common::Array<int> children;
+};
+
+class Resource : public Common::NonCopyable {
+private:
+ int _version;
+ Common::Array<File *> _files;
+ Common::Array<Common::Array<Block>> _blocks;
+
+ void buildBlocks(File &file, uint32 startOffset, uint32 endOffset, int parentIndex, Common::Array<Block> &blocks);
+ bool isContainerBlock(uint32 tag) const;
+
+public:
+ Resource(int version);
+ ~Resource();
+
+ void addFile(const Common::Path &path, byte encByte);
+ int getFileCount() const;
+ File *getFile(int index);
+ const Common::Array<Block> &getBlocks(int index) const;
+};
+
+} // End of namespace Editor
+
+} // End of namespace Scumm
+
+#endif
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk
index 0867fdb3e91..476871c5ad5 100644
--- a/engines/scumm/module.mk
+++ b/engines/scumm/module.mk
@@ -100,7 +100,8 @@ ifdef USE_IMGUI
MODULE_OBJS += \
debugger/debugtools.o \
debugger/editor.o \
- debugger/file.o
+ debugger/file.o \
+ debugger/resource.o
endif
ifdef USE_ARM_COSTUME_ASM
More information about the Scummvm-git-logs
mailing list