Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLOOKAT and DWRITEFMT fixed #36

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions lua/entities/gmod_wire_gpu/cl_gpuvm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,7 @@ VM.OpcodeTable[246] = function(self) --DWRITEFMT string.format(
self:Dyn_Emit("text = string.sub(text,2,65536)")

self:Dyn_Emit("if (inparam == false) then")
self:Dyn_Emit("if (chr == \"%\") then")
self:Dyn_Emit("if (chr == \"%%%%\") then")
self:Dyn_Emit("inparam = true")
self:Dyn_Emit("else")
self:Dyn_Emit("finaltext = finaltext .. chr")
Expand Down Expand Up @@ -2091,13 +2091,13 @@ VM.OpcodeTable[246] = function(self) --DWRITEFMT string.format(
self:Dyn_Emit("inparam = false")
self:Dyn_Emit("lengthmod = nil")
self:Dyn_Emit("elseif (chr == \"t\") then")
self:Dyn_Emit("while (string.len(finaltext) % (lengthmod or 6) != 0) do")
self:Dyn_Emit("while (math.mod(string.len(finaltext),(lengthmod or 6)) != 0) do")
self:Dyn_Emit("finaltext = finaltext..\" \"")
self:Dyn_Emit("end")
self:Dyn_Emit("inparam = false")
self:Dyn_Emit("lengthmod = nil")
self:Dyn_Emit("elseif (chr == \"%\") then")
self:Dyn_Emit("finaltext = finaltext .. \"%\"")
self:Dyn_Emit("elseif (chr == \"%%%%\") then")
self:Dyn_Emit("finaltext = finaltext .. \"%%%%\"")
self:Dyn_Emit("inparam = false")
self:Dyn_Emit("lengthmod = nil")
self:Dyn_Emit("end")
Expand Down
6 changes: 3 additions & 3 deletions lua/wire/zvm/zvm_opcodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@
--------------------------------------------------------------------------------
ZVM.OpcodeTable[70] = function(self) --EXTINT
self:Dyn_EmitState()
self:Emit("VM.IP = %d",(self.PrecompileIP or 0))

Check warning on line 461 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
self:Emit("VM.XEIP = %d",(self.PrecompileTrueXEIP or 0))

Check warning on line 462 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
self:Dyn_Emit("VM:ExternalInterrupt(math.floor($1))")
self:Dyn_EmitBreak()
self.PrecompileBreak = true
Expand Down Expand Up @@ -687,7 +687,7 @@
self:Dyn_Emit("end")
end
ZVM.OpcodeTable[98] = function(self) --TIMER
self:Dyn_EmitOperand("(VM.TIMER+%d*VM.TimerDT)",(self.PrecompileInstruction or 0))

Check warning on line 690 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
end
ZVM.OpcodeTable[99] = function(self) --LIDTR
self:Dyn_Emit("VM.IDTR = $1")
Expand Down Expand Up @@ -1046,7 +1046,7 @@
ZVM.OpcodeTable[126] = function(self) --LEA
local emitText = self.OperandEffectiveAddress[self.EmitOperandRM[2]] or "0"
emitText = string.gsub(emitText,"$BYTE",self.EmitOperandByte[2] or "0")
emitText = string.format(string.gsub(emitText,"$SEG","VM[%q]",(self.EmitOperandSegment[2] or "DS")))

Check warning on line 1049 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
self:Dyn_EmitOperand(emitText)
end
ZVM.OpcodeTable[127] = function(self) --BLOCK
Expand Down Expand Up @@ -1188,7 +1188,7 @@
self:Dyn_Emit("V = VM:Pop()") -- IRET EIP
self:Dyn_EmitInterruptCheck()

for i=0,31 do

Check warning on line 1191 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
self:Dyn_Emit("V = VM:Pop()") self:Dyn_EmitInterruptCheck() self:Dyn_Emit("VM.R%d = V")
end

Expand Down Expand Up @@ -1575,10 +1575,10 @@
end
ZVM.OpcodeTable[267] = function(self) --MLOOKAT
local seg1code = self.EmitOperandSegment[1] and "0" or "VM.DS"
local seg2code = self.EmitOperandSegment[2] and "0" or "VM.DS"

Check warning on line 1578 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: seg2code
self:Dyn_Emit("$L EYE = VM:ReadVector3f($2 + %s+0",seg2code)
self:Dyn_Emit("$L CENTER = VM:ReadVector3f($2 + %s+3",seg2code)
self:Dyn_Emit("$L UP = VM:ReadVector3f($2 + %s+6",seg2code)
self:Dyn_Emit("$L EYE = VM:ReadVector3f($2 + VM."..(self.EmitOperandSegment[2] or "DS").."+0)")

Check warning on line 1579 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 1579 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace after ')'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can still use %s right?

Copy link
Member Author

@DerelictDrone DerelictDrone Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually yeah, that was how I fixed it initially(just adding the right parenthesis), I think I copy & pasted the original lines to test if the behavior was the same and forgot to put the fixed ones that use seg2code back, thank you for spotting that

self:Dyn_Emit("$L CENTER = VM:ReadVector3f($2 + VM."..(self.EmitOperandSegment[2] or "DS").."+3)")

Check warning on line 1580 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 1580 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace after ')'
self:Dyn_Emit("$L UP = VM:ReadVector3f($2 + VM."..(self.EmitOperandSegment[2] or "DS").."+6)")
self:Dyn_EmitInterruptCheck()

self:Dyn_Emit("$L X = { 0, 0, 0 }")
Expand Down
Loading