Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions game/overlord/jak2/streamlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,20 @@ u32 StreamListThread() {
}
uVar9 = uVar9 + 1;
} while (uVar9 < 4);

SignalSema(EEStreamsList.sema);
RequestedStreamsList.unk2_init0 = 1;
SignalSema(RequestedStreamsList.sema);

WaitSema(EEPlayList.sema);
CheckPlayList(&EEPlayList);
SignalSema(EEPlayList.sema);
WaitSema(LfoList.sema);
CheckLfoList(&LfoList);
SignalSema(LfoList.sema);

// FIXME LfoList hasn't been initialised because of unimplemented
// streamlfo functions.
// WaitSema(LfoList.sema);
// CheckLfoList(&LfoList);
// SignalSema(LfoList.sema);
} while (true);
return 0;
}
Expand Down
16 changes: 15 additions & 1 deletion game/system/IOP_Kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ void IOP_Kernel::DelayThread(u32 usec) {
void IOP_Kernel::SleepThread() {
ASSERT(_currentThread);

_currentThread->state = IopThread::State::Suspend;
if (_currentThread->wakeupCount > 0) {
_currentThread->wakeupCount--;
return;
}

_currentThread->state = IopThread::State::Wait;
_currentThread->waitType = IopThread::Wait::Sleep;

leaveThread();
}

Expand All @@ -116,6 +123,13 @@ void IOP_Kernel::YieldThread() {
*/
void IOP_Kernel::WakeupThread(s32 id) {
ASSERT(id > 0);

auto& thread = threads.at(id);
if (thread.state != IopThread::State::Wait || thread.waitType != IopThread::Wait::Sleep) {
thread.wakeupCount++;
return;
}

threads.at(id).state = IopThread::State::Ready;
}

Expand Down
3 changes: 2 additions & 1 deletion game/system/IOP_Kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct IopThread {
Dormant,
};

enum class Wait { None, Semaphore, Delay, Messagebox, EventFlag };
enum class Wait { None, Sleep, Semaphore, Delay, Messagebox, EventFlag };

IopThread(std::string n, void (*f)(), s32 ID, u32 pri)
: name(std::move(n)), function(f), priority(pri), thID(ID) {
Expand All @@ -71,6 +71,7 @@ struct IopThread {
time_stamp resumeTime = {};
u32 priority = 0;
s32 thID = -1;
s32 wakeupCount = 0;
};

struct Semaphore {
Expand Down
Loading