[Scummvm-git-logs] scummvm master -> 92f86a2cfde11acd1fa17c79a5a7763b5fdd584c
sluicebox
noreply at scummvm.org
Fri Oct 10 00:26:45 UTC 2025
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:
3f85ea823a SCI: Cleanup picture code
92f86a2cfd AGI: PREAGI: Cleanup MICKEY file parsing
Commit: 3f85ea823aeda506c71ce6b436b07b3272f7709c
https://github.com/scummvm/scummvm/commit/3f85ea823aeda506c71ce6b436b07b3272f7709c
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-10-09T17:25:23-07:00
Commit Message:
SCI: Cleanup picture code
Changed paths:
engines/sci/graphics/picture.cpp
engines/sci/graphics/picture.h
diff --git a/engines/sci/graphics/picture.cpp b/engines/sci/graphics/picture.cpp
index cc1571b4af0..631927b882f 100644
--- a/engines/sci/graphics/picture.cpp
+++ b/engines/sci/graphics/picture.cpp
@@ -49,7 +49,6 @@ GfxPicture::GfxPicture(ResourceManager *resMan, GfxCoordAdjuster16 *coordAdjuste
_priority(0),
_EGAdrawingVisualize(EGAdrawingVisualize) {
- assert(resourceId != -1);
initData(resourceId);
}
@@ -72,14 +71,12 @@ GuiResourceId GfxPicture::getResourceId() {
// Games like PQ1 use the "old" vector data picture format, but are actually SCI1.1
// We should leave this that way to decide the format on-the-fly instead of hardcoding it in any way
void GfxPicture::draw(bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
- uint16 headerSize;
-
_mirroredFlag = mirroredFlag;
_addToFlag = addToFlag;
_EGApaletteNo = EGApaletteNo;
_priority = 0;
- headerSize = _resource->getUint16LEAt(0);
+ uint16 headerSize = _resource->getUint16LEAt(0);
switch (headerSize) {
case 0x26: // SCI 1.1 VGA picture
_resourceType = SCI_PICTURE_TYPE_SCI11;
@@ -92,23 +89,9 @@ void GfxPicture::draw(bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
}
}
-#if 0
-void GfxPicture::reset() {
- int16 startY = _ports->getPort()->top;
- int16 startX = 0;
- int16 x, y;
- _screen->vectorAdjustCoordinate(&startX, &startY);
- for (y = startY; y < _screen->getHeight(); y++) {
- for (x = startX; x < _screen->getWidth(); x++) {
- _screen->vectorPutPixel(x, y, GFX_SCREEN_MASK_ALL, 255, 0, 0);
- }
- }
-}
-#endif
-
void GfxPicture::drawSci11Vga() {
SciSpan<const byte> inbuffer(*_resource);
- int priorityBandsCount = inbuffer[3];
+ int priorityBandCount = inbuffer[3];
int has_cel = inbuffer[4];
int vector_dataPos = inbuffer.getUint32LEAt(16);
int vector_size = _resource->size() - vector_dataPos;
@@ -129,10 +112,12 @@ void GfxPicture::drawSci11Vga() {
// [priority:BYTE] [unknown:BYTE]
// priority bands are supposed to be 14 for sci1.1 pictures
- assert(priorityBandsCount == 14);
+ if (priorityBandCount != 14) {
+ error("invalid priorityBandCount for sci1.1 pic: %d", priorityBandCount);
+ }
if (_addToFlag) {
- _priority = inbuffer[40 + priorityBandsCount * 2] & 0xF;
+ _priority = inbuffer[40 + priorityBandCount * 2] & 0xF;
}
// display Cel-data
@@ -873,7 +858,6 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by
// Translate coordinates, if required (needed for Macintosh 480x300)
_screen->vectorAdjustCoordinate(&borderLeft, &borderTop);
_screen->vectorAdjustCoordinate(&borderRight, &borderBottom);
- //return;
stack.push(p);
diff --git a/engines/sci/graphics/picture.h b/engines/sci/graphics/picture.h
index 9c75997b91a..ed781fdd954 100644
--- a/engines/sci/graphics/picture.h
+++ b/engines/sci/graphics/picture.h
@@ -56,9 +56,6 @@ public:
private:
void initData(GuiResourceId resourceId);
-#if 0
- void reset();
-#endif
void drawSci11Vga();
void drawCelData(const SciSpan<const byte> &inbuffer, int headerPos, int rlePos, int literalPos, int16 drawX, int16 drawY, int16 pictureX, int16 pictureY, bool isEGA);
void drawVectorData(const SciSpan<const byte> &data);
Commit: 92f86a2cfde11acd1fa17c79a5a7763b5fdd584c
https://github.com/scummvm/scummvm/commit/92f86a2cfde11acd1fa17c79a5a7763b5fdd584c
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-10-09T17:25:23-07:00
Commit Message:
AGI: PREAGI: Cleanup MICKEY file parsing
Changed paths:
engines/agi/preagi/mickey.cpp
diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 8a957101a18..97d26a2bf1d 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -51,48 +51,36 @@ void MickeyEngine::readExe(int ofs, uint8 *buffer, long buflen) {
return;
infile.seek(ofs, SEEK_SET);
infile.read(buffer, buflen);
- infile.close();
}
-void MickeyEngine::getDatFileName(int iRoom, char *szFile) {
- Common::sprintf_s(szFile, 256, IDS_MSA_PATH_DAT, IDS_MSA_NAME_DAT[getDat(iRoom)]);
+void MickeyEngine::getDatFileName(int iRoom, char *fileName) {
+ Common::sprintf_s(fileName, 256, IDS_MSA_PATH_DAT, IDS_MSA_NAME_DAT[getDat(iRoom)]);
}
-void MickeyEngine::readDatHdr(char *szFile, MSA_DAT_HEADER *hdr) {
+void MickeyEngine::readDatHdr(char *fileName, MSA_DAT_HEADER *hdr) {
Common::File infile;
-
- if (!infile.open(szFile))
+ if (!infile.open(fileName))
return;
- hdr->filelen = infile.readByte();
- hdr->filelen += infile.readByte() * 0x100;
+ hdr->filelen = infile.readUint16LE();
for (int i = 0; i < IDI_MSA_MAX_ROOM; i++) {
- hdr->ofsRoom[i] = infile.readByte();
- hdr->ofsRoom[i] += infile.readByte() * 0x100;
+ hdr->ofsRoom[i] = infile.readUint16LE();
}
for (int i = 0; i < IDI_MSA_MAX_ROOM; i++) {
- hdr->ofsDesc[i] = infile.readByte();
- hdr->ofsDesc[i] += infile.readByte() * 0x100;
+ hdr->ofsDesc[i] = infile.readUint16LE();
}
for (int i = 0; i < IDI_MSA_MAX_ROOM; i++) {
- hdr->ofsStr[i] = infile.readByte();
- hdr->ofsStr[i] += infile.readByte() * 0x100;
+ hdr->ofsStr[i] = infile.readUint16LE();
}
-
- infile.close();
}
void MickeyEngine::readOfsData(int offset, int iItem, uint8 *buffer, long buflen) {
- uint16 ofs[256];
-
readExe(offset, buffer, buflen);
- memcpy(ofs, buffer, sizeof(ofs));
- for (int i = 0; i < 256; i++)
- ofs[i] = buffer[i * 2] + 256 * buffer[i * 2 + 1];
+ uint16 ofs = READ_LE_UINT16(&buffer[iItem * 2]);
- readExe(ofs[iItem] + IDI_MSA_OFS_EXE, buffer, buflen);
+ readExe(ofs + IDI_MSA_OFS_EXE, buffer, buflen);
}
// User Interface
@@ -120,17 +108,19 @@ bool MickeyEngine::chooseY_N(int ofsPrompt, bool fErrorMsg) {
}
int MickeyEngine::choose1to9(int ofsPrompt) {
- int answer = 0;
printExeStr(ofsPrompt);
while (!shouldQuit()) {
- answer = getSelection(kSelNumber);
+ int answer = getSelection(kSelNumber);
if (answer == 10) {
printExeStr(IDO_MSA_PRESS_1_TO_9);
- if (getSelection(kSelAnyKey) == 0)
+ if (getSelection(kSelAnyKey) == 0) {
return 0;
+ }
printExeStr(ofsPrompt);
- } else return answer;
+ } else {
+ return answer;
+ }
}
return 0;
@@ -182,60 +172,52 @@ void MickeyEngine::printExeMsg(int ofs) {
}
void MickeyEngine::printDatString(int iStr) {
- char buffer[256];
+ char fileName[256] = {0};
int iDat = getDat(_gameStateMickey.iRoom);
-
+ Common::sprintf_s(fileName, IDS_MSA_PATH_DAT, IDS_MSA_NAME_DAT[iDat]);
+
MSA_DAT_HEADER hdr;
- char szFile[256] = {0};
-
- Common::sprintf_s(szFile, IDS_MSA_PATH_DAT, IDS_MSA_NAME_DAT[iDat]);
- readDatHdr(szFile, &hdr);
+ readDatHdr(fileName, &hdr);
Common::File infile;
-
- if (!infile.open(szFile))
+ if (!infile.open(fileName))
return;
+ char buffer[256];
infile.seek(hdr.ofsStr[iStr] + IDI_MSA_OFS_DAT, SEEK_SET);
infile.read((uint8 *)buffer, 256);
- infile.close();
printStr(buffer);
}
void MickeyEngine::printDesc(int iRoom) {
+ char fileName[256] = {0};
+ getDatFileName(iRoom, fileName);
+
MSA_DAT_HEADER hdr;
- char szFile[256] = {0};
-
- getDatFileName(iRoom, szFile);
- readDatHdr(szFile, &hdr);
+ readDatHdr(fileName, &hdr);
Common::File infile;
-
- if (!infile.open(szFile))
+ if (!infile.open(fileName))
return;
- char *buffer = (char *)malloc(256);
- memset(buffer, 0, 256);
-
+ char buffer[256] = {0};
infile.seek(hdr.ofsDesc[iRoom - 1] + IDI_MSA_OFS_DAT, SEEK_SET);
infile.read(buffer, 256);
- infile.close();
printStr(buffer);
- free(buffer);
}
bool MickeyEngine::checkMenu() {
MSA_MENU menu;
int iSel0, iSel1;
MSA_DAT_HEADER hdr;
- char szFile[256] = {0};
+ char fileName[256] = {0};
Common::File infile;
- getDatFileName(_gameStateMickey.iRoom, szFile);
- readDatHdr(szFile, &hdr);
- if (!infile.open(szFile))
+ getDatFileName(_gameStateMickey.iRoom, fileName);
+ readDatHdr(fileName, &hdr);
+ if (!infile.open(fileName))
return false;
char *buffer = new char[sizeof(MSA_MENU)];
@@ -693,11 +675,11 @@ bool MickeyEngine::playSound(ENUM_MSA_SOUND iSound, WaitOptions options) {
// Graphics
void MickeyEngine::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
- char szFile[255] = {0};
- Common::sprintf_s(szFile, IDS_MSA_PATH_OBJ, IDS_MSA_NAME_OBJ[iObj]);
+ char fileName[255] = {0};
+ Common::sprintf_s(fileName, IDS_MSA_PATH_OBJ, IDS_MSA_NAME_OBJ[iObj]);
Common::File file;
- if (!file.open(szFile))
+ if (!file.open(fileName))
return;
uint8 *buffer = new uint8[4096];
@@ -723,11 +705,11 @@ void MickeyEngine::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
}
void MickeyEngine::drawPic(int iPic) {
- char szFile[255] = {0};
- Common::sprintf_s(szFile, IDS_MSA_PATH_PIC, iPic);
+ char fileName[255] = {0};
+ Common::sprintf_s(fileName, IDS_MSA_PATH_PIC, iPic);
Common::File file;
- if (!file.open(szFile))
+ if (!file.open(fileName))
return;
uint8 *buffer = new uint8[4096];
@@ -949,7 +931,7 @@ void MickeyEngine::printRoomDesc() {
bool MickeyEngine::loadGame() {
Common::InSaveFile *infile;
- char szFile[256] = {0};
+ char fileName[256] = {0};
bool diskerror = true;
int i = 0;
@@ -959,8 +941,8 @@ bool MickeyEngine::loadGame() {
return false;
// load game
- Common::sprintf_s(szFile, "%s.s%02d", getTargetName().c_str(), sel);
- if (!(infile = getSaveFileMan()->openForLoading(szFile))) {
+ Common::sprintf_s(fileName, "%s.s%02d", getTargetName().c_str(), sel);
+ if (!(infile = getSaveFileMan()->openForLoading(fileName))) {
printLine("PLEASE CHECK THE DISK DRIVE");
if (getSelection(kSelAnyKey) == 0)
@@ -1046,7 +1028,7 @@ bool MickeyEngine::loadGame() {
void MickeyEngine::saveGame() {
Common::OutSaveFile *outfile;
- char szFile[256] = {0};
+ char fileName[256] = {0};
bool diskerror = true;
int i = 0;
@@ -1074,8 +1056,8 @@ void MickeyEngine::saveGame() {
return;
// save game
- Common::sprintf_s(szFile, "%s.s%02d", getTargetName().c_str(), sel);
- if (!(outfile = getSaveFileMan()->openForSaving(szFile))) {
+ Common::sprintf_s(fileName, "%s.s%02d", getTargetName().c_str(), sel);
+ if (!(outfile = getSaveFileMan()->openForSaving(fileName))) {
printLine("PLEASE CHECK THE DISK DRIVE");
if (getSelection(kSelAnyKey) == 0)
@@ -1143,7 +1125,7 @@ void MickeyEngine::saveGame() {
outfile->finalize();
if (outfile->err())
- warning("Can't write file '%s'. (Disk full?)", szFile);
+ warning("Can't write file '%s'. (Disk full?)", fileName);
diskerror = false;
delete outfile;
@@ -2235,23 +2217,11 @@ void MickeyEngine::init() {
// clear game struct
memset(&_gameStateMickey, 0, sizeof(_gameStateMickey));
memset(&_gameStateMickey.iItem, IDI_MSA_OBJECT_NONE, sizeof(_gameStateMickey.iItem));
- // read room extended desc flags
- //readExe(IDO_MSA_ROOM_TEXT, buffer, sizeof(buffer));
- //memcpy(_gameStateMickey.fRmTxt, buffer, sizeof(_gameStateMickey.fRmTxt));
// read room extended desc offsets
readExe(IDO_MSA_ROOM_TEXT_OFFSETS, buffer, sizeof(buffer));
- memcpy(_gameStateMickey.oRmTxt, buffer, sizeof(_gameStateMickey.oRmTxt));
for (int i = 0; i < IDI_MSA_MAX_ROOM; i++)
- _gameStateMickey.oRmTxt[i] = buffer[i * 2] + 256 * buffer[i * 2 + 1];
-
- // read room object indices
- //readExe(IDO_MSA_ROOM_OBJECT, buffer, sizeof(buffer));
- //memcpy(_gameStateMickey.iRmObj, buffer, sizeof(_gameStateMickey.iRmObj));
-
- // read room picture indices
- //readExe(IDO_MSA_ROOM_PICTURE, buffer, sizeof(buffer));
- //memcpy(_gameStateMickey.iRmPic, buffer, sizeof(_gameStateMickey.iRmPic));
+ _gameStateMickey.oRmTxt[i] = READ_LE_UINT16(&buffer[i * 2]);
// read room menu patch indices
readExe(IDO_MSA_ROOM_MENU_FIX, buffer, sizeof(buffer));
@@ -2276,7 +2246,6 @@ void MickeyEngine::init() {
_gameStateMickey.fHasXtal = true;
_gameStateMickey.nXtals = 9;
_gameStateMickey.fItemUsed[IDI_MSA_ITEM_LETTER] = true;
-
#endif
setFlag(VM_FLAG_SOUND_ON, true); // enable sound
More information about the Scummvm-git-logs
mailing list