[Scummvm-git-logs] scummvm master -> 094133889eb88a33e59988518fe71c53515549dd

mduggan mgithub at guarana.org
Fri Apr 30 05:25:01 UTC 2021


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

Summary:
f1dc36f999 ULTIMA8: Clean up Kernel, no behavior changes.
3abf2dae38 ULTIMA8: Slow Crusader palette cycle to match original
d9438cd6d7 ULTIMA8: Silence overly-chatty warning
094133889e ULTIMA8: Run deferred terminates within the same tick


Commit: f1dc36f9993944b5b03637b6df533803147b2578
    https://github.com/scummvm/scummvm/commit/f1dc36f9993944b5b03637b6df533803147b2578
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-30T14:24:07+09:00

Commit Message:
ULTIMA8: Clean up Kernel, no behavior changes.

Changed paths:
    engines/ultima/ultima8/kernel/kernel.cpp
    engines/ultima/ultima8/kernel/kernel.h


diff --git a/engines/ultima/ultima8/kernel/kernel.cpp b/engines/ultima/ultima8/kernel/kernel.cpp
index 4f87f0df40..1813d94eaa 100644
--- a/engines/ultima/ultima8/kernel/kernel.cpp
+++ b/engines/ultima/ultima8/kernel/kernel.cpp
@@ -36,16 +36,13 @@ const uint32 Kernel::TICKS_PER_SECOND = 60;
 const uint32 Kernel::FRAMES_PER_SECOND = Kernel::TICKS_PER_SECOND / Kernel::TICKS_PER_FRAME;
 
 
-Kernel::Kernel() : _loading(false) {
+Kernel::Kernel() : _loading(false), _tickNum(0), _paused(0),
+		_runningProcess(nullptr), _frameByFrame(false) {
 	debugN(MM_INFO, "Creating Kernel...\n");
 
 	_kernel = this;
 	_pIDs = new idMan(1, 32766, 128);
-	current_process = _processes.end();
-	_tickNum = 0;
-	_paused = 0;
-	_runningProcess = nullptr;
-	_frameByFrame = false;
+	_currentProcess = _processes.end();
 }
 
 Kernel::~Kernel() {
@@ -64,7 +61,7 @@ void Kernel::reset() {
 		delete(*it);
 	}
 	_processes.clear();
-	current_process = _processes.begin();
+	_currentProcess = _processes.begin();
 
 	_pIDs->clearAll();
 
@@ -132,47 +129,18 @@ ProcId Kernel::addProcessExec(Process *proc) {
 	return proc->_pid;
 }
 
-void Kernel::removeProcess(Process *proc) {
-	//! the way to remove processes has to be thought over sometime
-	//! we probably want to flag them as terminated before actually
-	//! removing/deleting it or something
-	//! also have to look out for deleting processes while iterating
-	//! over the list. (Hence the special 'erase' in runProcs below, which
-	//! is very Std::list-specific, incidentally)
-
-	for (ProcessIterator it = _processes.begin(); it != _processes.end(); ++it) {
-		if (*it == proc) {
-			proc->_flags &= ~Process::PROC_ACTIVE;
-
-			perr << "[Kernel] Removing process " << proc << Std::endl;
-
-			_processes.erase(it);
-
-			// Clear pid
-			_pIDs->clearID(proc->_pid);
-
-			return;
-		}
-	}
-}
-
-
 void Kernel::runProcesses() {
 	if (!_paused)
 		_tickNum++;
 
 	if (_processes.size() == 0) {
+		warning("Process queue is empty?! Aborting.");
 		return;
-		/*
-		perr << "Process queue is empty?! Aborting.\n";
-
-		//! do this in a cleaner way
-		exit(0);
-		*/
 	}
-	current_process = _processes.begin();
-	while (current_process != _processes.end()) {
-		Process *p = *current_process;
+
+	_currentProcess = _processes.begin();
+	while (_currentProcess != _processes.end()) {
+		Process *p = *_currentProcess;
 
 		if (!_paused && ((p->_flags & (Process::PROC_TERMINATED |
 		                             Process::PROC_TERM_DEFERRED))
@@ -192,22 +160,23 @@ void Kernel::runProcesses() {
 		}
 		if (!_paused && (p->_flags & Process::PROC_TERMINATED)) {
 			// process is killed, so remove it from the list
-			current_process = _processes.erase(current_process);
+			_currentProcess = _processes.erase(_currentProcess);
 
 			// Clear pid
 			_pIDs->clearID(p->_pid);
 
 			//! is this the right place to delete processes?
 			delete p;
-		} else
-			++current_process;
+		} else {
+			++_currentProcess;
+		}
 	}
 
 	if (!_paused && _frameByFrame) pause();
 }
 
 void Kernel::setNextProcess(Process *proc) {
-	if (current_process != _processes.end() && *current_process == proc) return;
+	if (_currentProcess != _processes.end() && *_currentProcess == proc) return;
 
 	if (proc->_flags & Process::PROC_ACTIVE) {
 		for (ProcessIterator it = _processes.begin();
@@ -221,10 +190,10 @@ void Kernel::setNextProcess(Process *proc) {
 		proc->_flags |= Process::PROC_ACTIVE;
 	}
 
-	if (current_process == _processes.end()) {
+	if (_currentProcess == _processes.end()) {
 		_processes.push_front(proc);
 	} else {
-		ProcessIterator t = current_process;
+		ProcessIterator t = _currentProcess;
 		++t;
 
 		_processes.insert(t, proc);
diff --git a/engines/ultima/ultima8/kernel/kernel.h b/engines/ultima/ultima8/kernel/kernel.h
index d039a3e1e6..94e6bc5f7a 100644
--- a/engines/ultima/ultima8/kernel/kernel.h
+++ b/engines/ultima/ultima8/kernel/kernel.h
@@ -56,7 +56,6 @@ public:
 	//! \return pid of process
 	ProcId addProcessExec(Process *proc);
 
-	void removeProcess(Process *proc);
 	void runProcesses();
 	Process *getProcess(ProcId pid);
 
@@ -140,7 +139,7 @@ private:
 	Std::list<Process *> _processes;
 	idMan   *_pIDs;
 
-	Std::list<Process *>::iterator current_process;
+	Std::list<Process *>::iterator _currentProcess;
 
 	Std::map<Common::String, ProcessLoadFunc> _processLoaders;
 


Commit: 3abf2dae381b0e62044e5449fe687b86fd498f21
    https://github.com/scummvm/scummvm/commit/3abf2dae381b0e62044e5449fe687b86fd498f21
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-30T14:24:07+09:00

Commit Message:
ULTIMA8: Slow Crusader palette cycle to match original

Changed paths:
    engines/ultima/ultima8/graphics/cycle_process.cpp


diff --git a/engines/ultima/ultima8/graphics/cycle_process.cpp b/engines/ultima/ultima8/graphics/cycle_process.cpp
index 4970ad761d..2653e12ac1 100644
--- a/engines/ultima/ultima8/graphics/cycle_process.cpp
+++ b/engines/ultima/ultima8/graphics/cycle_process.cpp
@@ -56,6 +56,7 @@ static inline void copyColor(uint8 *dst, const uint8 *src) {
 
 CycleProcess::CycleProcess() : Process(), _running(1) {
 	_instance = this;
+	_ticksPerRun = 2;
 	for (int i = 0; i < 7; i++) {
 		copyColor(_cycleColData[i], CYCLE_INIT_COLS[i]);
 	}


Commit: d9438cd6d76840d61a21c7b5936f692f0002eb2b
    https://github.com/scummvm/scummvm/commit/d9438cd6d76840d61a21c7b5936f692f0002eb2b
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-30T14:24:07+09:00

Commit Message:
ULTIMA8: Silence overly-chatty warning

Changed paths:
    engines/ultima/ultima8/kernel/process.cpp


diff --git a/engines/ultima/ultima8/kernel/process.cpp b/engines/ultima/ultima8/kernel/process.cpp
index b91540ef24..b400e6ce47 100644
--- a/engines/ultima/ultima8/kernel/process.cpp
+++ b/engines/ultima/ultima8/kernel/process.cpp
@@ -81,7 +81,7 @@ void Process::waitFor(ProcId pid) {
 		Process *p = kernel->getProcess(pid);
 		assert(p);
 		if (p->getProcessFlags() & PROC_TERMINATED) {
-			warning("Proc %d wait for proc %d which is already terminated", _pid, pid);
+			//warning("Proc %d wait for proc %d which is already terminated", _pid, pid);
 			return;
 		}
 		p->_waiting.push_back(_pid);


Commit: 094133889eb88a33e59988518fe71c53515549dd
    https://github.com/scummvm/scummvm/commit/094133889eb88a33e59988518fe71c53515549dd
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-30T14:24:07+09:00

Commit Message:
ULTIMA8: Run deferred terminates within the same tick

This is the second part of fixing Crusader elevator speeds after e3ee65.  With
this change they move at the same speed as the original (completing their
travel in ~0.6s)

Previously, UC process return would defer termination to the next clock tick,
so waiting processes would be delayed by an extra tick.  The elevator platform
speeds in Crusader show that waiters should be executed on the *same* clock
tick as the process returns.

However, if we terminate and schedule waiters immediately then other things
don't work (eg, the door does not open for the first Thermatron).

This suggests that the correct (to original game) behavior is to defer
termination until the end of the current process list, then wake and execute
waiting processes.

Only apply this to Crusader - it *doesn't* get the right speed on U8, where NPC
moves execute too quickly with this change.  With just e3ee65, U8 NPC moves are
exactly right.

Changed paths:
    engines/ultima/ultima8/kernel/kernel.cpp


diff --git a/engines/ultima/ultima8/kernel/kernel.cpp b/engines/ultima/ultima8/kernel/kernel.cpp
index 1813d94eaa..f10ffb6b96 100644
--- a/engines/ultima/ultima8/kernel/kernel.cpp
+++ b/engines/ultima/ultima8/kernel/kernel.cpp
@@ -167,6 +167,17 @@ void Kernel::runProcesses() {
 
 			//! is this the right place to delete processes?
 			delete p;
+		} else if (!_paused && (p->_flags & Process::PROC_TERM_DEFERRED) && GAME_IS_CRUSADER) {
+			//
+			// In Crusader, move term deferred processes to the end to clean up after
+			// others have run.  This gets the right speed on ELEVAT (which should
+			// execute one movement per tick)
+			//
+			// In U8, frame-count comparison for Devon turning at the start shows this
+			// *shouldn't* be used, and the process should be cleaned up next tick.
+			//
+			_processes.push_back(p);
+			_currentProcess = _processes.erase(_currentProcess);
 		} else {
 			++_currentProcess;
 		}
@@ -191,6 +202,7 @@ void Kernel::setNextProcess(Process *proc) {
 	}
 
 	if (_currentProcess == _processes.end()) {
+		// Not currently running processes, add to the start of the next run.
 		_processes.push_front(proc);
 	} else {
 		ProcessIterator t = _currentProcess;




More information about the Scummvm-git-logs mailing list