[Scummvm-git-logs] scummvm master -> 8a194ad2e46bff64bdf945a7f89672ca1e977c0b

Strangerke noreply at scummvm.org
Sun Feb 15 19:24:38 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:
76da00d411 M4: Various small cleanups in Platform
8a194ad2e4 M4: Stat reviewing wscript


Commit: 76da00d4114f9444e660ca0fbde49114fd8d4332
    https://github.com/scummvm/scummvm/commit/76da00d4114f9444e660ca0fbde49114fd8d4332
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2026-02-15T20:24:12+01:00

Commit Message:
M4: Various small cleanups in Platform

Changed paths:
    engines/m4/platform/draw.cpp
    engines/m4/platform/draw.h
    engines/m4/platform/events.cpp
    engines/m4/platform/events.h
    engines/m4/platform/sound/digi.cpp
    engines/m4/platform/sound/digi.h
    engines/m4/platform/sound/midi.cpp
    engines/m4/platform/sound/midi.h
    engines/m4/platform/timer.cpp
    engines/m4/platform/timer.h


diff --git a/engines/m4/platform/draw.cpp b/engines/m4/platform/draw.cpp
index 2391118ecd2..c411b910e5a 100644
--- a/engines/m4/platform/draw.cpp
+++ b/engines/m4/platform/draw.cpp
@@ -26,16 +26,15 @@
 namespace M4 {
 
 void RLE8Decode(const uint8 *inBuff, uint8 *outBuff, uint32 pitch) {
-	byte val, count;
-	int line = 0, numY = 0;
+	int line = 0;
 	byte *destP = outBuff;
 
 	for (;;) {
-		count = *inBuff++;
+		byte count = *inBuff++;
 
 		if (count) {
 			// Basic run length
-			val = *inBuff++;
+			byte val = *inBuff++;
 			Common::fill(destP, destP + count, val);
 			destP += count;
 
@@ -59,7 +58,7 @@ void RLE8Decode(const uint8 *inBuff, uint8 *outBuff, uint32 pitch) {
 			} else {
 				// Move down by X, Y amount
 				destP += *inBuff++;		// x amount
-				numY = *inBuff++;		// y amount
+				int numY = *inBuff++;		// y amount
 				line += numY;
 				destP += numY * pitch;
 			}
@@ -67,29 +66,11 @@ void RLE8Decode(const uint8 *inBuff, uint8 *outBuff, uint32 pitch) {
 	}
 }
 
-uint8 *SkipRLE_Lines(uint32 linesToSkip, uint8 *rleData) {
-	while (linesToSkip > 0) {
-		if (*rleData) {
-			// Simple RLE sequence, so skip over count and value
-			rleData += 2;
-
-		} else if (rleData[1] >= 3) {
-			rleData += 2 + rleData[2];
-		} else {
-			rleData += 2;
-			--linesToSkip;
-		}
-	}
-
-	return rleData;
-}
-
 size_t RLE8Decode_Size(byte *src, int pitch) {
-	size_t total = 0, line = 0, y;
-	byte count;
+	size_t total = 0, line = 0;
 
 	for (;;) {
-		count = *src++;
+		byte count = *src++;
 
 		if (count) {
 			total += count;
@@ -113,7 +94,7 @@ size_t RLE8Decode_Size(byte *src, int pitch) {
 			} else {
 				// Move down by X, Y amount
 				total += *src++;	// x amount
-				y = *src++;			// y amount
+				const byte y = *src++;			// y amount
 				line += y;
 				total += y * pitch;
 			}
@@ -127,14 +108,14 @@ void RLE_Draw(Buffer *src, Buffer *dest, int32 x, int32 y) {
 	const byte *srcP = src->data;
 	byte *destData = dest->data + y * dest->w + x;
 	byte *destP = destData;
-	int destWidth = dest->w;
-	byte count, val;
+	const int destWidth = dest->w;
+	byte val;
 	int line = 0;
 
 	assert(x >= 0 && y >= 0 && x < dest->w && y < dest->h);
 
 	for (;;) {
-		count = *srcP++;
+		byte count = *srcP++;
 
 		if (count) {
 			// Basic run length
diff --git a/engines/m4/platform/draw.h b/engines/m4/platform/draw.h
index 1463c953961..3ebf4bf49e4 100644
--- a/engines/m4/platform/draw.h
+++ b/engines/m4/platform/draw.h
@@ -31,14 +31,9 @@ namespace M4 {
  */
 void RLE8Decode(const uint8 *inBuff, uint8 *outBuff, uint32 pitch);
 
-/**
- * Given RLE data, skips over a given number of encoded lines
- */
-uint8 *SkipRLE_Lines(uint32 linesToSkip, uint8 *rleData);
-
 /**
  * Returns the size of an RLE encoded image
- * @param data		RLE data
+ * @param src		RLE data
  * @param pitch		Image pitch
  * @returns			Decoded image's size in bytes
  */
diff --git a/engines/m4/platform/events.cpp b/engines/m4/platform/events.cpp
index f1b9561f1dc..36faf07f157 100644
--- a/engines/m4/platform/events.cpp
+++ b/engines/m4/platform/events.cpp
@@ -217,19 +217,20 @@ bool Events::util_kbd_check(int32 *parm1) {
 	if (!parm1 || _pendingKeys.empty())
 		return false;
 
-	Common::KeyState ks = _pendingKeys.pop();
+	const Common::KeyState ks = _pendingKeys.pop();
 	if (is_mod_key(ks))
 		return false;
 
-	int flags = ks.flags & (Common::KBD_CTRL | Common::KBD_ALT);
-	int key = (ks.ascii >= 32 && ks.ascii <= 127 && !flags) ? ks.ascii : (int)ks.keycode;
+	const int flags = ks.flags & (Common::KBD_CTRL | Common::KBD_ALT);
+	const int key = (ks.ascii >= 32 && ks.ascii <= 127 && !flags) ? ks.ascii : (int)ks.keycode;
 	*parm1 = key | (flags << 16);
 
 	return true;
 }
 
 void Events::delay(uint amount) {
-	uint32 beginTime = g_system->getMillis(), newTime;
+	const uint32 beginTime = g_system->getMillis();
+	uint32 newTime;
 
 	do {
 		krn_pal_game_task();
diff --git a/engines/m4/platform/events.h b/engines/m4/platform/events.h
index 738a72cc32a..07cdd736104 100644
--- a/engines/m4/platform/events.h
+++ b/engines/m4/platform/events.h
@@ -24,7 +24,6 @@
 
 #include "common/queue.h"
 #include "common/events.h"
-#include "m4/m4_types.h"
 
 namespace M4 {
 
diff --git a/engines/m4/platform/sound/digi.cpp b/engines/m4/platform/sound/digi.cpp
index 0cf620a8c96..e293d8d5ef0 100644
--- a/engines/m4/platform/sound/digi.cpp
+++ b/engines/m4/platform/sound/digi.cpp
@@ -163,7 +163,7 @@ void Digi::stop(uint channel, bool calledFromUnload) {
 
 	Channel &c = _channels[channel];
 	if (!c._name.empty()) {
-		Common::String name = c._name;
+		const Common::String name = c._name;
 
 		_mixer->stopHandle(c._soundHandle);
 		c._trigger = -1;
@@ -188,7 +188,7 @@ void Digi::read_another_chunk() {
 
 		// Check if the channel has a sound playing that finished
 		if (c._trigger != -1 && !_mixer->isSoundHandleActive(c._soundHandle)) {
-			int trigger = c._trigger;
+			const int trigger = c._trigger;
 			c._trigger = -1;
 			stop(channel);
 
@@ -208,9 +208,9 @@ void Digi::change_volume(int channel, int vol) {
 
 int32 Digi::ticks_to_play(const char *name, int roomNum) {
 	// Get the file and retrieve it's size
-	Common::String filename = expand_name_2_RAW(name, roomNum);
+	const Common::String filename = expand_name_2_RAW(name, roomNum);
 	SysFile sf(filename);
-	double size = sf.size();
+	const double size = sf.size();
 	sf.close();
 
 	term_message("  digi_ticks_to_play");
diff --git a/engines/m4/platform/sound/digi.h b/engines/m4/platform/sound/digi.h
index d6f38345eb7..cfe4c61d462 100644
--- a/engines/m4/platform/sound/digi.h
+++ b/engines/m4/platform/sound/digi.h
@@ -24,7 +24,6 @@
 #define M4_PLATFORM_SOUND_DIGI_H
 
 #include "audio/mixer.h"
-#include "audio/audiostream.h"
 #include "common/hashmap.h"
 #include "m4/m4_types.h"
 
diff --git a/engines/m4/platform/sound/midi.cpp b/engines/m4/platform/sound/midi.cpp
index cede69aaec4..ac687712247 100644
--- a/engines/m4/platform/sound/midi.cpp
+++ b/engines/m4/platform/sound/midi.cpp
@@ -54,14 +54,11 @@ Midi::~Midi() {
 
 	Common::StackLock lock(_mutex);
 
-	if (_midiParser != nullptr)
-		delete _midiParser;
-	if (_midiData != nullptr)
-		delete[] _midiData;
-	if (_driver != nullptr) {
-		delete _driver;
-		_driver = nullptr;
-	}
+	delete _midiParser;
+	delete[] _midiData;
+	delete _driver;
+
+	_driver = nullptr;
 }
 
 int Midi::open() {
@@ -114,7 +111,7 @@ int Midi::open() {
 	_midiParser->property(MidiParser::mpSendSustainOffOnNotesOff, true);
 
 	// Open the MIDI driver.
-	int returnCode = _driver->open();
+	const int returnCode = _driver->open();
 	if (returnCode != 0)
 		error("Midi::open - Failed to open MIDI music driver - error code %d.", returnCode);
 
@@ -136,8 +133,7 @@ void Midi::load(byte* in, int32 size) {
 
 	_midiParser->unloadMusic();
 
-	if (_midiData != nullptr)
-		delete[] _midiData;
+	delete[] _midiData;
 	_midiData = new byte[size];
 
 	Common::copy(in, in + size, _midiData);
@@ -209,9 +205,9 @@ void Midi::midi_play(const char *name, int volume, bool loop, int trigger, int r
 	_midiEndTrigger = trigger;
 
 	// Load in the resource
-	Common::String fileName = expand_name_2_HMP(name, roomNum);
+	const Common::String fileName = expand_name_2_HMP(name, roomNum);
 	int32 assetSize;
-	MemHandle workHandle = rget(fileName, &assetSize);
+	const MemHandle workHandle = rget(fileName, &assetSize);
 	if (workHandle == nullptr)
 		error("Could not find music - %s", fileName.c_str());
 
@@ -269,7 +265,7 @@ void Midi::loop() {
 }
 
 void Midi::midi_fade_volume(int targetVolume, int duration) {
-	uint16 durationMsec = duration * 1000 / 30;
+	const uint16 durationMsec = duration * 1000 / 30;
 	startFade(durationMsec, targetVolume);
 	// TODO Should this stop playback when fade is completed?
 	// Should this call return after the fade has completed?
diff --git a/engines/m4/platform/sound/midi.h b/engines/m4/platform/sound/midi.h
index f5f8b220c0f..1270356c098 100644
--- a/engines/m4/platform/sound/midi.h
+++ b/engines/m4/platform/sound/midi.h
@@ -23,8 +23,6 @@
 #ifndef M4_SOUND_PLATFORM_MIDI_H
 #define M4_SOUND_PLATFORM_MIDI_H
 
-#include "m4/m4_types.h"
-
 #include "audio/mididrv_ms.h"
 #include "audio/midiparser.h"
 
diff --git a/engines/m4/platform/timer.cpp b/engines/m4/platform/timer.cpp
index 79a3e65a78c..f52eee7e996 100644
--- a/engines/m4/platform/timer.cpp
+++ b/engines/m4/platform/timer.cpp
@@ -25,18 +25,6 @@
 
 namespace M4 {
 
-uint32 timer_read() {
-	return g_system->getMillis() * 60 / 1000;
-}
-
-uint32 timer_read_dos() {
-	return g_system->getMillis() * 60 / 1000;
-}
-
-uint32 timer_read_600() {
-	return g_system->getMillis() * 600 / 1000;
-}
-
 uint32 timer_read_60() {
 	return g_system->getMillis() * 60 / 1000;
 }
diff --git a/engines/m4/platform/timer.h b/engines/m4/platform/timer.h
index e27bf78db80..135d38f3f3b 100644
--- a/engines/m4/platform/timer.h
+++ b/engines/m4/platform/timer.h
@@ -27,9 +27,6 @@
 
 namespace M4 {
 
-uint32 timer_read();
-uint32 timer_read_dos();
-uint32 timer_read_600();
 uint32 timer_read_60();
 
 } // End of namespace M4


Commit: 8a194ad2e46bff64bdf945a7f89672ca1e977c0b
    https://github.com/scummvm/scummvm/commit/8a194ad2e46bff64bdf945a7f89672ca1e977c0b
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2026-02-15T20:24:13+01:00

Commit Message:
M4: Stat reviewing wscript

Changed paths:
    engines/m4/vars.cpp
    engines/m4/wscript/ws_cruncher.cpp
    engines/m4/wscript/ws_hal.cpp
    engines/m4/wscript/ws_hal.h
    engines/m4/wscript/ws_load.cpp
    engines/m4/wscript/ws_load.h
    engines/m4/wscript/ws_machine.cpp
    engines/m4/wscript/ws_machine.h


diff --git a/engines/m4/vars.cpp b/engines/m4/vars.cpp
index ebd77886ffc..51f311fafa5 100644
--- a/engines/m4/vars.cpp
+++ b/engines/m4/vars.cpp
@@ -263,12 +263,10 @@ void Vars::grab_fonts() {
 }
 
 void Vars::create_mouse_watch_dialog() {
-	int x_offset;
-
 	gr_font_set(_font_tiny);
 	_mousePosDialog = DialogCreateAbsolute(0, 380, 200, 480, 3 | SF_GET_MOUSE);
 	_showMousePos = false;
-	x_offset = 64;
+	int x_offset = 64;
 
 	Dialog_Add_Message(_mousePosDialog, 4, 4, "Scene:", 0);
 	Dialog_Add_Message(_mousePosDialog, x_offset, 4, "0", 1);
diff --git a/engines/m4/wscript/ws_cruncher.cpp b/engines/m4/wscript/ws_cruncher.cpp
index 0bd7ba561e7..87320adb962 100644
--- a/engines/m4/wscript/ws_cruncher.cpp
+++ b/engines/m4/wscript/ws_cruncher.cpp
@@ -261,7 +261,7 @@ bool ws_ChangeAnim8Program(machine *m, int32 newSequHash) {
 		return false;
 	}
 
-	// Intialize the Anim8
+	// Initialize the Anim8
 	myAnim8->switchTime = 0;
 	myAnim8->active = true;
 	myAnim8->eosReqOffset = -1;
@@ -297,7 +297,7 @@ void ws_RemoveAnim8FromCruncher(Anim8 *myAnim8) {
 		mem_free_to_stash((void *)tempEOSreq, _GWS(memtypeEOS));
 	}
 
-	// Incase we are in the middle of crunching
+	// In case we are in the middle of crunching
 	if (myAnim8 == _GWS(crunchNext)) {
 		_GWS(crunchNext) = myAnim8->next;
 	}
@@ -398,7 +398,7 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
 			parentAnim8 = myAnim8->myParent;
 
 			// Range check to make sure we don't index off into hyperspace
-			if ((!parentAnim8) || (myIndex >= IDX_COUNT + parentAnim8->numLocalVars)) {
+			if (!parentAnim8 || (myIndex >= IDX_COUNT + parentAnim8->numLocalVars)) {
 				if (!parentAnim8) {
 					ws_LogErrorMsg(FL, "Trying to access a parent register - no parent exists");
 				} else {
@@ -430,7 +430,7 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
 				return false;
 			}
 
-			// Dereferrence the dataHandle, add the offset to find the array of data for this anim8
+			// Dereference the dataHandle, add the offset to find the array of data for this anim8
 			dataArray = (uint32 *)((intptr)*(myAnim8->dataHandle) + myAnim8->dataOffset);
 
 			// Copy the data field into dataArg1, and set myArg1 to point to this location
@@ -967,7 +967,8 @@ static void op_PUSH(Anim8 *myAnim8) {
 	}
 	int32 direction = 1;
 	if (_GWS(myArg2)) {
-		if (*_GWS(myArg2) > 0) numOfArgs = (*_GWS(myArg2)) >> 16;
+		if (*_GWS(myArg2) > 00)
+			numOfArgs = (*_GWS(myArg2)) >> 16;
 		else {
 			numOfArgs = -(int)(*_GWS(myArg2)) >> 16;
 			direction = -1;
@@ -999,7 +1000,8 @@ static void op_POP(Anim8 *myAnim8) {
 	}
 	int32 direction = 1;
 	if (_GWS(myArg2)) {
-		if (*_GWS(myArg2) > 0) numOfArgs = (*_GWS(myArg2)) >> 16;
+		if (*_GWS(myArg2) > 0)
+			numOfArgs = (*_GWS(myArg2)) >> 16;
 		else {
 			numOfArgs = -(int)(*_GWS(myArg2)) >> 16;
 			direction = -1;
@@ -1189,7 +1191,8 @@ static void op_SET_DEPTH(Anim8 *myAnim8) {
 		ws_Error(myAnim8->myMachine, "op_SET_DEPTH() failed - no depth table.");
 	}
 	for (myDepth = 0; myDepth < 15; myDepth++) {
-		if (_GWS(myDepthTable)[myDepth + 1] < (int)(*_GWS(myArg1) >> 16)) break;
+		if (_GWS(myDepthTable)[myDepth + 1] < (int)(*_GWS(myArg1) >> 16))
+			break;
 	}
 	_GWS(dataArg1) = (myAnim8->myRegs[IDX_LAYER] & 0xffffff) + (myDepth << 24);
 	_GWS(myArg1) = &_GWS(dataArg1);
diff --git a/engines/m4/wscript/ws_hal.cpp b/engines/m4/wscript/ws_hal.cpp
index 632ad5c7fdf..1202d3d57c6 100644
--- a/engines/m4/wscript/ws_hal.cpp
+++ b/engines/m4/wscript/ws_hal.cpp
@@ -455,21 +455,11 @@ void GetBezCoeffs(frac16 *ctrlPoints, frac16 *coeffs) {
 	coeffs[3] = y0mult3 - y1mult6 + y2mult3;
 	coeffs[5] = -(int)y0mult3 + y1mult3;
 	coeffs[7] = y0;
-
-	return;
 }
 
 void GetBezPoint(frac16 *x, frac16 *y, frac16 *coeffs, frac16 tVal) {
-
-	*x = coeffs[6] +
-		MulSF16(tVal, (coeffs[4] +
-			MulSF16(tVal, (coeffs[2] +
-				MulSF16(tVal, coeffs[0])))));
-
-	*y = coeffs[7] +
-		MulSF16(tVal, (coeffs[5] +
-			MulSF16(tVal, (coeffs[3] +
-				MulSF16(tVal, coeffs[1])))));
+	*x = coeffs[6] + MulSF16(tVal, (coeffs[4] + MulSF16(tVal, (coeffs[2] + MulSF16(tVal, coeffs[0])))));
+	*y = coeffs[7] + MulSF16(tVal, (coeffs[5] + MulSF16(tVal, (coeffs[3] + MulSF16(tVal, coeffs[1])))));
 }
 
 void InitCCB(CCB *myCCB) {
@@ -502,6 +492,7 @@ void InitCCB(CCB *myCCB) {
 void HideCCB(CCB *myCCB) {
 	if (!myCCB)
 		return;
+
 	myCCB->flags |= CCB_HIDE;
 
 	if ((myCCB->flags & CCB_STREAM) && myCCB->maxArea) {
@@ -558,7 +549,7 @@ void Cel_msr(Anim8 *myAnim8) {
 	}
 
 	CCB *myCCB = myAnim8->myCCB;
-	if ((!myCCB) || (!myCCB->source)) {
+	if (!myCCB || !myCCB->source) {
 		error_show(FL, "myCCB not set");
 	}
 
diff --git a/engines/m4/wscript/ws_hal.h b/engines/m4/wscript/ws_hal.h
index de3486a5fab..7df56bc9ebe 100644
--- a/engines/m4/wscript/ws_hal.h
+++ b/engines/m4/wscript/ws_hal.h
@@ -36,10 +36,6 @@ namespace M4 {
 
 #define CCB_NO_DRAW			(CCB_SKIP | CCB_HIDE)
 
-#define ERR_INTERNAL		0
-#define ERR_SEQU			1
-#define ERR_MACH			2
-
 struct WSHal_Globals {
 	RectList *_deadRectList = nullptr;
 };
@@ -61,9 +57,7 @@ void KillCCB(CCB *myCCB, bool restoreFlag);
 void Cel_msr(Anim8 *myAnim8);
 void ws_OverrideCrunchTime(machine *m);
 
-bool CheckAddr();
 void ws_Error(machine *m, const char *errMsg);
-void ws_DumpMachine(machine *m);
 void ws_LogErrorMsg(const char *sourceFile, uint32 lineNum, const char *fmt, ...);
 
 } // End of namespace M4
diff --git a/engines/m4/wscript/ws_load.cpp b/engines/m4/wscript/ws_load.cpp
index 0d9bf2e73bd..135e599fc53 100644
--- a/engines/m4/wscript/ws_load.cpp
+++ b/engines/m4/wscript/ws_load.cpp
@@ -35,20 +35,15 @@ namespace M4 {
 #define CHUNK_DATA	0x44415441	//'DATA'
 #define CHUNK_CELS	0x43454C53	//'CELS'
 
-#define CHUNK_NECS	0x4E454353	//INTEL 'SCEN'
 #define CHUNK_HCAM	0x4843414D	//INTEL 'MACH'
 #define CHUNK_UQES	0x55514553	//INTEL 'SEQU'
 #define CHUNK_SLEC	0x534C4543	//INTEL 'CELS'
 #define CHUNK_ATAD	0x41544144	//INTEL 'DATA'
 
-#define MACH_NUM_STATES		0
 #define MACH_OFFSETS		1
 
-#define SEQU_NUM_VARS		0
 #define SEQU_SEQU_START		1
 
-#define DATA_REC_COUNT		0
-#define DATA_REC_SIZE		1
 #define DATA_REC_START		2
 
 #define MAX_ASSET_HASH		255
@@ -232,20 +227,44 @@ void ShutdownWSAssets() {
 	ClearWSAssets(_WS_ASSET_DATA, 0, MAX_ASSET_HASH);
 
 	// Deallocate all tables
-	if (_GWS(globalMACHnames)) mem_free(_GWS(globalMACHnames));
-	if (_GWS(globalSEQUnames)) mem_free(_GWS(globalSEQUnames));
-	if (_GWS(globalDATAnames)) mem_free(_GWS(globalDATAnames));
-	if (_GWS(globalCELSnames)) mem_free(_GWS(globalCELSnames));
-
-	if (_GWS(globalMACHHandles)) mem_free(_GWS(globalMACHHandles));
-	if (_GWS(globalMACHoffsets)) mem_free(_GWS(globalMACHoffsets));
-	if (_GWS(globalSEQUHandles)) mem_free(_GWS(globalSEQUHandles));
-	if (_GWS(globalSEQUoffsets)) mem_free(_GWS(globalSEQUoffsets));
-	if (_GWS(globalDATAHandles)) mem_free(_GWS(globalDATAHandles));
-	if (_GWS(globalDATAoffsets)) mem_free(_GWS(globalDATAoffsets));
-	if (_GWS(globalCELSHandles)) mem_free(_GWS(globalCELSHandles));
-	if (_GWS(globalCELSoffsets)) mem_free(_GWS(globalCELSoffsets));
-	if (_GWS(globalCELSPaloffsets)) mem_free(_GWS(globalCELSPaloffsets));
+	if (_GWS(globalMACHnames))
+		mem_free(_GWS(globalMACHnames));
+
+	if (_GWS(globalSEQUnames))
+		mem_free(_GWS(globalSEQUnames));
+
+	if (_GWS(globalDATAnames))
+		mem_free(_GWS(globalDATAnames));
+
+	if (_GWS(globalCELSnames))
+		mem_free(_GWS(globalCELSnames));
+
+	if (_GWS(globalMACHHandles))
+		mem_free(_GWS(globalMACHHandles));
+
+	if (_GWS(globalMACHoffsets))
+		mem_free(_GWS(globalMACHoffsets));
+
+	if (_GWS(globalSEQUHandles))
+		mem_free(_GWS(globalSEQUHandles));
+
+	if (_GWS(globalSEQUoffsets))
+		mem_free(_GWS(globalSEQUoffsets));
+
+	if (_GWS(globalDATAHandles))
+		mem_free(_GWS(globalDATAHandles));
+
+	if (_GWS(globalDATAoffsets))
+		mem_free(_GWS(globalDATAoffsets));
+
+	if (_GWS(globalCELSHandles))
+		mem_free(_GWS(globalCELSHandles));
+
+	if (_GWS(globalCELSoffsets))
+		mem_free(_GWS(globalCELSoffsets));
+
+	if (_GWS(globalCELSPaloffsets))
+		mem_free(_GWS(globalCELSPaloffsets));
 
 	_GWS(wsloaderInitialized) = false;
 }
@@ -462,7 +481,6 @@ bool LoadWSAssets(const char *wsAssetName, RGB8 *myPalette) {
 		default:
 			error_show(FL, "Asset Name: %s, %d bytes into the file.", wsAssetName,
 				(intptr)parseAssetPtr - 12 - (intptr)mainAssetPtr);
-			break;
 		}
 
 		// Read the next chunkType, or signal we are finished
@@ -573,54 +591,6 @@ int32 LoadSpriteSeries(const char *assetName, MemHandle *seriesHandle, int32 *ce
 	return celsSize;
 }
 
-int32 LoadSpriteSeriesDirect(const char *assetName, MemHandle *seriesHandle, int32 *celsOffset, int32 *palOffset, RGB8 *myPalette) {
-	Common::File f;
-	int32 *celsPtr, *palPtr;
-	char *parseAssetPtr;
-
-	// This loads a sprite series into the provided vars, rather than the WS tables.
-	// The WS loader is not involved with this procedure.
-
-	// First open the file
-	if (!f.open(assetName))
-		return -1;
-
-	// Get the file size
-	const uint32 assetSize = f.size();
-
-	// Create a handle big enough to hold the contents of the file
-	const MemHandle workHandle = NewHandle(assetSize, "ss file");
-
-	// Lock the handle and read the contents of the file into it
-	HLock(workHandle);
-	char *mainAssetPtr = (char *)*workHandle;
-	if (f.read(mainAssetPtr, assetSize) < assetSize) {
-		mem_free(workHandle);
-		return -1;
-	}
-
-	// Close the file
-	f.close();
-
-	// Set up some pointers
-	char *endOfAssetBlock = (char *)((intptr)mainAssetPtr + assetSize);
-	parseAssetPtr = mainAssetPtr;
-
-	// Process the SS from the stream file
-	const int32 celsSize = ProcessCELS(assetName, &parseAssetPtr, mainAssetPtr, endOfAssetBlock, &celsPtr, &palPtr, myPalette);
-	if (celsSize < 0) {
-		error_show(FL, "series: %s", assetName);
-	}
-
-	// Store the handle and offsets
-	*seriesHandle = workHandle;
-	*celsOffset = (intptr)celsPtr - (intptr)mainAssetPtr;
-	*palOffset = (intptr)palPtr - (intptr)mainAssetPtr;
-	HUnLock(workHandle);
-
-	return celsSize;
-}
-
 bool ws_GetSSMaxWH(MemHandle ssHandle, int32 ssOffset, int32 *maxW, int32 *maxH) {
 	// Parameter verification
 	if ((!ssHandle) || (!*ssHandle)) {
@@ -694,11 +664,11 @@ int32 AddWSAssetCELS(const char *wsAssetName, int32 hash, RGB8 *myPalette) {
 
 			// Since the SS is already loaded, return the slot
 			return hash;
-		} else {
-			// The series is not already loaded, set up values for the next if statement
-			i = MAX_ASSET_HASH + 1;
-			emptySlot = hash;
 		}
+
+		// The series is not already loaded, set up values for the next if statement
+		i = MAX_ASSET_HASH + 1;
+		emptySlot = hash;
 	}
 
 	// If we've searched the entire table and not found the series, but
@@ -761,12 +731,10 @@ int32 AddWSAssetCELS(const char *wsAssetName, int32 hash, RGB8 *myPalette) {
 
 		// Return the hash number for the series
 		return i;
-	} else {
-		// Else we searched the entire table, it was not already loaded, and there are no empty slots
-		error_show(FL, "Asset Name: %s", wsAssetName);
 	}
 
-	return -1;
+	// Else we searched the entire table, it was not already loaded, and there are no empty slots
+	error_show(FL, "Asset Name: %s", wsAssetName);
 }
 
 static int32 ProcessCELS(const char * /*assetName*/, char **parseAssetPtr, char * /*mainAssetPtr*/, char *endOfAssetBlock,
@@ -1021,91 +989,6 @@ M4sprite *GetWSAssetSprite(char *spriteName, uint32 hash, uint32 index, M4sprite
 	return mySprite;
 }
 
-
-int32 LoadSpriteSeries(const char *assetName, Handle *seriesHandle, int32 *celsOffset, int32 *palOffset, RGB8 *myPalette) {
-	int32 *celsPtr, *palPtr;
-	char *parseAssetPtr;
-	int32 assetSize;
-
-	//This loads a sprite series into the provided vars, rather than the WS tables.
-	//The WS loader is not involved with this procedure.
-
-	// Load in the sprite series
-	const MemHandle workHandle = rget(assetName, &assetSize);
-	if (workHandle == nullptr)
-		error_show(FL, "Sprite series: %s", assetName);
-
-	HLock(workHandle);
-
-	char *mainAssetPtr = (char *)*workHandle;
-	char *endOfAssetBlock = (char *)((intptr)mainAssetPtr + assetSize);
-	parseAssetPtr = mainAssetPtr;
-
-	// Process the SS from the stream file
-	const int32 celsSize = ProcessCELS(assetName, &parseAssetPtr, mainAssetPtr, endOfAssetBlock, &celsPtr, &palPtr, myPalette);
-	if (celsSize < 0) {
-		error_show(FL, "series: %s", assetName);
-	}
-
-	// Store the handle and offsets
-	*seriesHandle = workHandle;
-	*celsOffset = (intptr)celsPtr - (intptr)mainAssetPtr;
-	*palOffset = (intptr)palPtr - (intptr)mainAssetPtr;
-
-	HUnLock(workHandle);
-
-	return celsSize;
-}
-
-int32 LoadSpriteSeriesDirect(const char *assetName, Handle *seriesHandle, int32 *celsOffset, int32 *palOffset, RGB8 *myPalette) {
-	Common::File f;
-	int32 *celsPtr, *palPtr;
-	char *parseAssetPtr;
-
-	// This loads a sprite series into the provided vars, rather than the WS tables.
-	// The WS loader is not involved with this procedure.
-
-	// First open the file
-	if (!f.open(assetName))
-		return -1;
-
-	// Get the size
-	const uint32 assetSize = f.size();
-
-	// Create a handle big enough to hold the contents of the file
-	MemHandle workHandle = NewHandle(assetSize, "ss file");
-
-	// Lock the handle and read the contents of the file intoit
-	HLock(workHandle);
-	char *mainAssetPtr = (char *)*workHandle;
-	if (f.read(mainAssetPtr, assetSize) < assetSize) {
-		f.close();
-		mem_free(workHandle);
-		return -1;
-	}
-
-	// Close the file
-	f.close();
-
-	// Set up some pointers
-	char *endOfAssetBlock = (char *)((intptr)mainAssetPtr + assetSize);
-	parseAssetPtr = mainAssetPtr;
-
-	// Process the SS from the stream file
-	const int32 celsSize = ProcessCELS(assetName, &parseAssetPtr, mainAssetPtr, endOfAssetBlock, &celsPtr, &palPtr, myPalette);
-	if (celsSize < 0) {
-		error_show(FL, "series: %s", assetName);
-	}
-
-	// Store the handle and offsets
-	*seriesHandle = workHandle;
-	*celsOffset = (intptr)celsPtr - (intptr)mainAssetPtr;
-	*palOffset = (intptr)palPtr - (intptr)mainAssetPtr;
-	HUnLock(workHandle);
-
-	return celsSize;
-}
-
 CCB *GetWSAssetCEL(uint32 hash, uint32 index, CCB *myCCB) {
 	bool streamSeries;
 
@@ -1590,7 +1473,7 @@ static int32 GetSSHeaderInfo(SysFile *sysFile, uint32 **data, RGB8 *myPalette) {
 }
 
 bool ws_OpenSSstream(SysFile *sysFile, Anim8 *anim8) {
-	int32 obesest_frame = 0;
+	int32 largest_frame = 0;
 
 	// Verify the parameters
 	if (!sysFile || !anim8 || !anim8->myCCB) {
@@ -1600,10 +1483,10 @@ bool ws_OpenSSstream(SysFile *sysFile, Anim8 *anim8) {
 
 	CCB *myCCB = anim8->myCCB;
 	frac16 *myRegs = anim8->myRegs;
-	int32 ssDataOffset = 0;
 
 	// Read in the SS stream header
-	if ((ssDataOffset = GetSSHeaderInfo(sysFile, &(myCCB->streamSSHeader), &_G(master_palette)[0])) <= 0) {
+	int32 ssDataOffset = GetSSHeaderInfo(sysFile, &(myCCB->streamSSHeader), &_G(master_palette)[0]);
+	if (ssDataOffset <= 0) {
 		return false;
 	}
 
@@ -1626,18 +1509,16 @@ bool ws_OpenSSstream(SysFile *sysFile, Anim8 *anim8) {
 
 		if (offsets[i] > maxFrameSize) {
 			maxFrameSize = offsets[i];
-			obesest_frame = i;
+			largest_frame = i;
 		}
 	}
 
 	// For the last sprite we take the entire chunk size - the chunk header - the offset for that sprite
-	offsets[numSprites - 1] = celsPtr[CELS_SRC_SIZE] -
-		((SS_HEAD_SIZE + celsPtr[CELS_COUNT]) << 2) -
-		offsets[numSprites - 1];
+	offsets[numSprites - 1] = celsPtr[CELS_SRC_SIZE] - ((SS_HEAD_SIZE + celsPtr[CELS_COUNT]) << 2) - offsets[numSprites - 1];
 
 	if (offsets[numSprites - 1] > maxFrameSize) {
 		maxFrameSize = offsets[numSprites - 1];
-		obesest_frame = numSprites - 1;
+		largest_frame = numSprites - 1;
 	}
 
 	// Calculate the maximum size a sprite could be
@@ -1647,7 +1528,7 @@ bool ws_OpenSSstream(SysFile *sysFile, Anim8 *anim8) {
 		myCCB->source = (M4sprite *)mem_alloc(sizeof(M4sprite), "Sprite");
 	}
 
-	term_message("Biggest frame was: %d, size: %d bytes (compressed)", obesest_frame, maxFrameSize);
+	term_message("Biggest frame was: %d, size: %d bytes (compressed)", largest_frame, maxFrameSize);
 
 	// Access the streamer to recognize the new client
 	myCCB->myStream = (void *)f_stream_Open(sysFile, ssDataOffset, maxFrameSize, maxFrameSize << 4, numSprites, (int32 *)offsets, 4, false);
@@ -1720,9 +1601,7 @@ bool ws_GetNextSSstreamCel(Anim8 *anim8) {
 	mySprite->yOffset = FROM_LE_32(myCelSource[CELS_Y]);
 	mySprite->w = FROM_LE_32(myCelSource[CELS_W]);
 	mySprite->h = FROM_LE_32(myCelSource[CELS_H]);
-
 	mySprite->encoding = (uint8)FROM_LE_32(myCelSource[CELS_COMP]);
-
 	mySprite->data = (uint8 *)&myCelSource[CELS_DATA];
 
 	// Initialize the CCB structure
diff --git a/engines/m4/wscript/ws_load.h b/engines/m4/wscript/ws_load.h
index 3a2a020e0b5..cf23225bed9 100644
--- a/engines/m4/wscript/ws_load.h
+++ b/engines/m4/wscript/ws_load.h
@@ -95,12 +95,10 @@ MemHandle ws_GetSEQU(uint32 hash, int32 *numLocalVars, int32 *offset);
 MemHandle ws_GetMACH(uint32 hash, int32 *numStates, int32 *stateTableOffset, int32 *machInstrOffset);
 MemHandle ws_GetDATA(uint32 hash, uint32 index, int32 *rowOffset);
 int32 ws_GetDATACount(uint32 hash);
-int32 GetSSHeaderInfo(Common::SeekableReadStream *stream, uint32 **data, RGB8 *myPalette);
 bool ws_GetSSMaxWH(MemHandle ssHandle, int32 ssOffset, int32 *maxW, int32 *maxH);
 
 // USING SPRITES WITHOUT GOING THROUGH THE WOODSCRIPT TREE
 int32 LoadSpriteSeries(const char *assetName, MemHandle *seriesHandle, int32 *celsOffset, int32 *palOffset, RGB8 *myPalette);
-int32 LoadSpriteSeriesDirect(const char *assetName, MemHandle *seriesHandle, int32 *celsOffset, int32 *palOffset, RGB8 *myPalette);
 M4sprite *CreateSprite(MemHandle resourceHandle, int32 handleOffset, int32 index, M4sprite *mySprite, bool *streamSeries);
 
 // WOODSCRIPT STREAMING API
diff --git a/engines/m4/wscript/ws_machine.cpp b/engines/m4/wscript/ws_machine.cpp
index d68b823c55c..2b8becdce23 100644
--- a/engines/m4/wscript/ws_machine.cpp
+++ b/engines/m4/wscript/ws_machine.cpp
@@ -34,8 +34,6 @@
 
 namespace M4 {
 
-#define COND_FLAG		0x80000000
-#define OP_COUNT		0x00007fff
 #define OP_JUMP			3
 #define OP_KILL			4
 
@@ -368,10 +366,8 @@ static bool op_START_SEQ(machine *m, int32 *pcOffset) {
 		if ((m->myAnim8 = ws_AddAnim8ToCruncher(m, *_GWS(myArg1) >> 16)) == nullptr) {
 			ws_Error(m, "start_seq() failed.");
 		}
-	} else {
-		if (!ws_ChangeAnim8Program(m, *_GWS(myArg1) >> 16)) {
-			ws_Error(m, "start_seq() failed.");
-		}
+	} else if (!ws_ChangeAnim8Program(m, *_GWS(myArg1) >> 16)) {
+		ws_Error(m, "start_seq() failed.");
 	}
 
 	return true;
@@ -633,10 +629,6 @@ void unpauseEngines() {
 	_GWS(enginesPaused) = false;
 }
 
-void addPauseTime(int32 myTime) {
-	_GWS(pauseTime) += myTime;
-}
-
 void cycleEngines(Buffer *cleanBackground, int16 *depth_table, Buffer *screenCodes,
 		uint8 *myPalette, uint8 *ICT, bool updateVideo) {
 	const int32 clockTime = timer_read_60();
@@ -974,7 +966,8 @@ machine *TriggerMachineByHash(int32 myHash, Anim8 *parentAnim8, int32 dataHash,
 	m->machID = _GWS(machineIDCount);
 	m->machName = mem_strdup(machName);
 
-	if ((m->machHandle = ws_GetMACH(myHash, &m->numOfStates, &m->stateTableOffset, &m->machInstrOffset)) == nullptr) {
+	m->machHandle = ws_GetMACH(myHash, &m->numOfStates, &m->stateTableOffset, &m->machInstrOffset);
+	if (m->machHandle == nullptr) {
 		ws_LogErrorMsg(FL, "Trying to trigger hash: %d, name: %s", myHash, machName);
 		return nullptr;
 	}
@@ -982,7 +975,8 @@ machine *TriggerMachineByHash(int32 myHash, Anim8 *parentAnim8, int32 dataHash,
 	// Get the data handle and offset if requested
 	if (dataHash >= 0) {
 		m->dataHash = dataHash;
-		if ((m->dataHandle = ws_GetDATA(dataHash, (uint32)dataRow, &m->dataOffset)) == nullptr) {
+		m->dataHandle = ws_GetDATA(dataHash, (uint32)dataRow, &m->dataOffset);
+		if (m->dataHandle == nullptr) {
 			ws_LogErrorMsg(FL, "Trying to trigger hash: %d, name: %s", myHash, machName);
 			return nullptr;
 		}
diff --git a/engines/m4/wscript/ws_machine.h b/engines/m4/wscript/ws_machine.h
index 681cc241601..a8aaa3dd8b1 100644
--- a/engines/m4/wscript/ws_machine.h
+++ b/engines/m4/wscript/ws_machine.h
@@ -158,7 +158,7 @@ struct machine {
 	uint32 myHash = 0;
 	uint32 machID = 0;
 	char *machName = nullptr;
-	MemHandle machHandle = 0;
+	MemHandle machHandle = nullptr;
 	int32 machInstrOffset = 0;
 	int32 stateTableOffset = 0;
 	int32 curState = 0;
@@ -167,7 +167,7 @@ struct machine {
 	Anim8 *myAnim8 = nullptr;
 	Anim8 *parentAnim8 = nullptr;
 	int32 dataHash = 0;
-	MemHandle dataHandle = 0;
+	MemHandle dataHandle = nullptr;
 	int32 dataOffset = 0;
 	int32 targetCount = 0;
 	struct machine *msgReplyXM = nullptr;
@@ -208,7 +208,6 @@ bool ws_Initialize(frac16 *theGlobals);
 void ws_Shutdown();
 void pauseEngines();
 void unpauseEngines();
-void addPauseTime(int32 myTime);
 
 void cycleEngines(Buffer *cleanBackground, int16 *depth_table, Buffer *screenCodes,
 	uint8 *myPalette, uint8 *ICT, bool updateVideo);




More information about the Scummvm-git-logs mailing list