Skip to content

Commit 71ad494

Browse files
author
Dextinfire
committed
Merge pull request #474 from CommitteeOfZero/instruction_dt
Add dt to instruction
2 parents b14985f + 98051a1 commit 71ad494

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/vm/inst_system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ VmInstruction(InstCreateThread) {
5353
newThread->IpOffset = labelAdr;
5454
thread->ScriptParam = newThread->Id;
5555
newThread->ScriptParam = thread->Id;
56-
RunThread(newThread);
56+
RunThread(newThread, dt);
5757
BlockCurrentScriptThread = false;
5858
}
5959
VmInstruction(InstKillThread) {

src/vm/vm.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ void Update(float dt) {
285285

286286
int cnt = 0;
287287
while (ThreadTable[cnt]) {
288-
RunThread(ThreadTable[cnt++]);
288+
RunThread(ThreadTable[cnt++], dt);
289289
}
290290

291291
cnt = 0;
@@ -437,7 +437,7 @@ void ControlThreadGroup(ThreadGroupControlType controlType, uint32_t groupId) {
437437
}
438438
}
439439

440-
void RunThread(Sc3VmThread* thread) {
440+
void RunThread(Sc3VmThread* thread, float dt) {
441441
uint8_t* scrVal;
442442
uint32_t opcodeGrp;
443443
uint32_t opcode;
@@ -490,13 +490,13 @@ void RunThread(Sc3VmThread* thread) {
490490
scriptIp, opcodeGrp1, opcode, thread->ScriptBufferId);
491491

492492
if (opcodeGrp1 == 0x10) {
493-
OpcodeTableUser1[opcode](thread);
493+
OpcodeTableUser1[opcode](thread, dt);
494494
} else if (opcodeGrp1 == 0x02) {
495-
OpcodeTableGraph3D[opcode](thread);
495+
OpcodeTableGraph3D[opcode](thread, dt);
496496
} else if (opcodeGrp1 == 0x01) {
497-
OpcodeTableGraph[opcode](thread);
497+
OpcodeTableGraph[opcode](thread, dt);
498498
} else if (!opcodeGrp1) {
499-
OpcodeTableSystem[opcode](thread);
499+
OpcodeTableSystem[opcode](thread, dt);
500500
} else {
501501
ImpLog(LogLevel::Error, LogChannel::VM,
502502
"Thread CRASH! Unknown opcode. Attempting recovery. Address: "

src/vm/vm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "../io/vfs.h"
66
#include <magic_enum/magic_enum.hpp>
77

8-
#define VmInstruction(name) void name(Sc3VmThread* thread)
8+
#define VmInstruction(name) void name(Sc3VmThread* thread, float dt)
99

1010
namespace Impacto {
1111
namespace Vm {
@@ -22,7 +22,7 @@ enum class InstructionSet : int {
2222
MO8,
2323
CHN,
2424
};
25-
using InstructionProc = auto (*)(Sc3VmThread* thread) -> void;
25+
using InstructionProc = auto (*)(Sc3VmThread* thread, float dt) -> void;
2626

2727
int constexpr MaxLoadedScripts = 16;
2828
int constexpr MaxThreads = 100;
@@ -46,7 +46,7 @@ bool LoadMsb(uint32_t bufferId, uint32_t fileId);
4646
Sc3VmThread* CreateThread(uint32_t groupId);
4747
void ControlThreadGroup(ThreadGroupControlType controlType, uint32_t groupId);
4848
void DestroyThread(Sc3VmThread* thread);
49-
void RunThread(Sc3VmThread* thread);
49+
void RunThread(Sc3VmThread* thread, float dt);
5050

5151
inline std::span<uint8_t> ScriptBuffers[MaxLoadedScripts];
5252
inline std::span<uint8_t> MsbBuffers[MaxLoadedScripts];

0 commit comments

Comments
 (0)