[Scummvm-git-logs] scummvm master -> 54fb44e34d5bb30885fe9cb0ec44029385b0d53a

dreammaster noreply at scummvm.org
Fri May 15 06:21:12 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
54fb44e34d MADS: PHANTOM: Remainder of anim_timer and support functions


Commit: 54fb44e34d5bb30885fe9cb0ec44029385b0d53a
    https://github.com/scummvm/scummvm/commit/54fb44e34d5bb30885fe9cb0ec44029385b0d53a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-05-15T16:21:06+10:00

Commit Message:
MADS: PHANTOM: Remainder of anim_timer and support functions

Changed paths:
    engines/mads/madsv2/animview/anim_timer.cpp
    engines/mads/madsv2/animview/animview.cpp
    engines/mads/madsv2/animview/animview.h
    engines/mads/madsv2/animview/functions.cpp
    engines/mads/madsv2/animview/functions.h


diff --git a/engines/mads/madsv2/animview/anim_timer.cpp b/engines/mads/madsv2/animview/anim_timer.cpp
index f371a411a2e..aa04ec07f07 100644
--- a/engines/mads/madsv2/animview/anim_timer.cpp
+++ b/engines/mads/madsv2/animview/anim_timer.cpp
@@ -43,7 +43,8 @@ static int messageHandle[MESSAGES_COUNT];
 static int paletteHandle;
 static int palIndex1, palIndex2;
 static int matteId;
-static int normalTimer1, messageCount;
+static int normalTimer1, imageCount;
+static int messageCount;
 static int frameViewX, frameViewY;
 static int currentViewX, currentViewY;
 
@@ -54,13 +55,14 @@ void anim_timer_init() {
 	normalTimer1 = messageCount = 0;
 	frameViewX = frameViewY = 0;
 	currentViewX = currentViewY = 0;
-	normalTimer1 = 0;
+	normalTimer1 = imageCount = 0;
 }
 
 void anim_timer() {
 	bool flag = false;
 	uint32 currTimer = g_system->getMillis();
 	Speech *speech;
+	Frame *frame;
 	int sound, count;
 
 	if (current_error_code || speechStream)
@@ -75,8 +77,10 @@ void anim_timer() {
 		flag = g_engine->isSpeechPlaying();
 		goto block1;
 	}
+
+	++runCtr1;
 	if (normalTimer1)
-		goto block2;
+		goto block3;
 
 	if (runFx == 0) {
 		if (peelFlag && timer2 >= currTimer && timer1 <= currTimer) {
@@ -112,7 +116,7 @@ void anim_timer() {
 		(speech->display_condition & 0x800) &&
 		(speech->resource_id >= 0);
 
-	if (speech->sound && (!flag || sound_var1 == 49)) {
+	if (speech->sound /*&& (!flag || sound_var1 == 49)*/) {
 		g_engine->_soundManager->command(speech->sound);
 	}
 
@@ -175,8 +179,111 @@ block2:
 		}
 	}
 
-	// TODO: More block 2 stuff
-	warning("TODO: block2");
+	imageCount = image_marker;
+	while (imageFrame < current_anim->num_images) {
+		Image *img = &current_anim->image[imageFrame];
+
+		if (img->flags > currentFrame)
+			break;
+		if (img->flags != currentFrame)
+			continue;
+
+		bool found = false;
+		for (count = 0; !found && count < imageCount; ++count) {
+			Image *img2 = &image_list[count];
+
+			found = img->series_id == img2->series_id &&
+				img->sprite_id == img2->sprite_id &&
+				img->x == img2->x &&
+				img->y == img2->y &&
+				img->depth == img2->depth &&
+				img->scale == img2->scale;
+			if (found)
+				img2->flags = 0;
+		}
+
+		if (!found) {
+			image_list[image_marker] = *img;
+			Series *series = series_list[img->series_id];
+			series->delta_series = (series->delta_series == 0) ? 1 : -4;
+			++image_marker;
+		}
+	}
+
+	if (currentFrame == 0)
+		anim_setup_cycle(runFx);
+
+	frame = &current_anim->frame[currentFrame];
+	if (frame->yank_x) {
+		buffer_peel_horiz(&scr_work, frame->yank_x);
+		matte_refresh_work();
+	}
+	if (frame->yank_y) {
+		buffer_peel_vert(&scr_work, frame->yank_y, scr_inter_orig.data, 320 * 200);
+		matte_refresh_work();
+	}
+
+	matte_frame(runFx, 0);
+
+block3:
+	if (runFx) {
+		currTimer = g_system->getMillis();
+		if (currTimer < timer1) {
+			normalTimer1 = -1;
+			goto done;
+		}
+
+		frame = &current_anim->frame[currentFrame];
+		if (frame->sound) {
+			g_engine->_soundManager->command(frame->sound);
+			timer1 = currTimer;
+		}
+
+		timer2 = currTimer + current_anim->misc_peel_rate;
+		cycling_active = has_cycles;
+	}
+
+	normalTimer1 = 0;
+
+	if (current_anim->misc_no_catchup || !resync_timer1 || runVal7 ||
+			(currentFrame == 0 && resync_timer2))
+		timer1 = currTimer;
+
+	runFx = 0;
+	runVal7 = 0;
+	runCtr1 = 0;
+
+	if (++currentFrame < maxFrame) {
+		frame = &current_anim->frame[currentFrame];
+		timer1 += frame->ticks;
+	}
+
+	if (speechIndex == -1)
+		goto done;
+	speech = &current_anim->speech[speechIndex];
+	if (speech->last_frame >= currentFrame)
+		goto done;
+	if (++runVal6 < speechLoops) {
+		if (runVal6 == maxFrame) {
+			frame = &current_anim->frame[runVal6 - 1];
+			timer1 += frame->ticks;
+		}
+
+		currentFrame = speech->first_frame;
+		imageFrame = speech->first_image;
+	} else {
+		speechIndex = -1;
+
+		if (runVal8) {
+			matte_clear_message(matteId);
+			pal_deallocate(paletteHandle);
+			runVal8 = 0;
+
+			for (count = 0; count < messageCount; ++count)
+				matte_clear_message(messageHandle[count]);
+			messageCount = 0;
+		}
+	}
 
 done:
 	cycle_colors();
diff --git a/engines/mads/madsv2/animview/animview.cpp b/engines/mads/madsv2/animview/animview.cpp
index 88ab83bf4e7..7dda9a44256 100644
--- a/engines/mads/madsv2/animview/animview.cpp
+++ b/engines/mads/madsv2/animview/animview.cpp
@@ -21,7 +21,6 @@
 
 #include "audio/audiostream.h"
 #include "common/file.h"
-#include "mads/madsv2/core/cycle.h"
 #include "mads/madsv2/core/env.h"
 #include "mads/madsv2/core/himem.h"
 #include "mads/madsv2/core/matte.h"
@@ -64,6 +63,9 @@ int speechIndex;
 int speechLoops;
 int runVal6, runVal7, runVal8;
 int loadFontFlag;
+int imageFrame;
+CycleList anim_cycle_list;
+bool has_cycles;
 
 static const byte FX_TIMES[16] = {
 	0, 110, 110, 64, 64, 64, 64, 64, 64, 64, 64, 0, 0, 0
@@ -74,10 +76,8 @@ static bool has_sound_file;
 static char sound_file_name[80];
 static TileMapHeader picture_map, depth_map;
 static TileResource picture_res, depth_res;
-static CycleList cycle_list;
 static Buffer scr_work_orig;
 static Room *room;
-static bool has_cycles;
 static int viewing_at_y2;
 constexpr int SPEECH_LINES_COUNT = 10;
 static Audio::AudioStream *speech_lines[SPEECH_LINES_COUNT];
@@ -108,7 +108,7 @@ static void init_globals() {
 	memset(&depth_map, 0, sizeof(TileMapHeader));
 	memset(&picture_res, 0, sizeof(TileResource));
 	memset(&depth_res, 0, sizeof(TileResource));
-	memset(&cycle_list, 0, sizeof(CycleList));
+	memset(&anim_cycle_list, 0, sizeof(CycleList));
 	memset(&scr_work_orig, 0, sizeof(Buffer));
 	room = nullptr;
 	current_anim = nullptr;
@@ -144,6 +144,7 @@ static void init_globals() {
 	error_code = current_error_code = 0;
 	wait_for_music_at_end = false;
 	exit_immediately_at_end = false;
+	imageFrame = 0;
 }
 
 /**
@@ -435,7 +436,7 @@ static void animate() {
 		int loadFlags = anim_list[count].bg_load_status ? ANIM_LOAD_BACKGROUND : 0;
 		current_anim = anim_load(buf, &scr_work, &scr_depth,
 			&picture_map, &depth_map, &picture_res, &depth_res, &room,
-			&cycle_list, loadFlags);
+			&anim_cycle_list, loadFlags);
 		scr_work_orig = scr_work;
 
 		if (!current_anim)
@@ -453,7 +454,7 @@ static void animate() {
 			animSeries->arena = nullptr;
 		}
 
-		has_cycles = cycle_list.num_cycles > 0;
+		has_cycles = anim_cycle_list.num_cycles > 0;
 		current_anim_inter = (AnimInterPtr)current_anim;
 
 		int height = (scr_work.y == 200) ? 200 : 156;
diff --git a/engines/mads/madsv2/animview/animview.h b/engines/mads/madsv2/animview/animview.h
index 3cff1643c13..643609b6e2a 100644
--- a/engines/mads/madsv2/animview/animview.h
+++ b/engines/mads/madsv2/animview/animview.h
@@ -24,6 +24,7 @@
 
 #include "audio/audiostream.h"
 #include "mads/madsv2/core/anim.h"
+#include "mads/madsv2/core/cycle.h"
 
 namespace MADS {
 namespace MADSV2 {
@@ -47,6 +48,9 @@ extern int speechIndex;
 extern int speechLoops;
 extern int runVal6, runVal7, runVal8;
 extern int loadFontFlag;
+extern int imageFrame;
+extern CycleList anim_cycle_list;
+extern bool has_cycles;
 
 
 // Main animview function
diff --git a/engines/mads/madsv2/animview/functions.cpp b/engines/mads/madsv2/animview/functions.cpp
index d9e21bf58c8..9037270c841 100644
--- a/engines/mads/madsv2/animview/functions.cpp
+++ b/engines/mads/madsv2/animview/functions.cpp
@@ -22,7 +22,10 @@
 #include "common/textconsole.h"
 #include "mads/madsv2/animview/functions.h"
 #include "mads/madsv2/animview/animview.h"
+#include "mads/madsv2/core/cycle.h"
 #include "mads/madsv2/core/matte.h"
+#include "mads/madsv2/core/mcga.h"
+#include "mads/madsv2/core/pal.h"
 
 namespace MADS {
 namespace MADSV2 {
@@ -179,6 +182,16 @@ void anim_peel() {
 	}
 }
 
+void anim_setup_cycle(int fx) {
+	cycling_active = false;
+	memcpy(cycling_palette, master_palette, sizeof(Palette));
+
+	if (fx)
+		mcga_setpal(&master_palette);
+
+	cycle_init(&anim_cycle_list, has_cycles && !fx);
+}
+
 } // namespace AnimView
 } // namespace MADSV2
 } // namespace MADS
diff --git a/engines/mads/madsv2/animview/functions.h b/engines/mads/madsv2/animview/functions.h
index 9119b39aae6..fcfa9ba7c3c 100644
--- a/engines/mads/madsv2/animview/functions.h
+++ b/engines/mads/madsv2/animview/functions.h
@@ -71,6 +71,8 @@ extern void read_resource(Common::SeekableReadStream *src);
 
 extern void anim_peel();
 
+void anim_setup_cycle(int fx);
+
 } // namespace AnimView
 } // namespace MADSV2
 } // namespace MADS




More information about the Scummvm-git-logs mailing list