Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix-fps
Browse files Browse the repository at this point in the history
  • Loading branch information
DerelictDrone committed Dec 14, 2023
2 parents b3a4a2f + 1d62172 commit 004a0c5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
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
8 changes: 5 additions & 3 deletions lua/wire/client/hlzasm/hc_codetree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,13 @@ function HCOMP:ReadOperandFromMemory(operands,index)
operands[index] = { MemoryRegister = operands[index].MemoryPointer.Register, Temporary = operands[index].MemoryPointer.Temporary }
return operands[index].Register
elseif operands[index].MemoryPointer.Constant then
if istable(operands[index].MemoryPointer.Constant) then
-- Don't decay a label constant expression into an unusable memory address if possible
for _,item in pairs(operands[index].MemoryPointer.Constant) do
if item.Type == self.TOKEN.IDENT then
operands[index] = { MemoryPointer = operands[index].MemoryPointer.Constant }
return nil
if item.Type == self.TOKEN.IDENT then
operands[index] = { MemoryPointer = operands[index].MemoryPointer.Constant }
return nil
end
end
end
operands[index] = { Memory = operands[index].MemoryPointer.Constant }
Expand Down
13 changes: 12 additions & 1 deletion lua/wire/client/hlzasm/hc_syntax.lua
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,24 @@ function HCOMP:DefineVariable(isFunctionParam,isForwardDecl,isRegisterDecl,isStr
self:PreviousToken() -- LPAREN
self:PreviousToken() -- Func Name
self:PreviousToken() -- Type Name
local ptrlevel = 0
if self:MatchToken(TOKEN.TIMES) then
-- skip back until we're done with the ptr
self:PreviousToken()
while self:MatchToken(TOKEN.TIMES) do
ptrlevel = ptrlevel + 1;
self:PreviousToken()
self:PreviousToken()
end
end
if not self:MatchToken(TOKEN.IDENT) then
self:MatchToken(TOKEN.TYPE) -- If it's not an IDENT (struct/user defined) it should be a generic type
end
local returnType = self.TokenData
self.CurrentToken = self.CurrentToken + ptrlevel -- return to present.
self:MatchToken(TOKEN.IDENT)
local funcName = self.TokenData
self.CurFunction = {Name = funcName, ReturnType = returnType}
self.CurFunction = {Name = funcName, ReturnType = returnType, ReturnPtrLevel = ptrlevel}
self:NextToken()
label.Type = "Pointer"
label.Defined = true
Expand Down
4 changes: 3 additions & 1 deletion lua/wire/zvm/zvm_core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,13 @@ end

--------------------------------------------------------------------------------
-- Emit interrupt call
-- intNo can only be numeric or "$1"
-- intParam can only be numeric or "IDX"
function ZVM:Dyn_EmitInterrupt(intNo,intParam)
self:Dyn_EmitState()
self:Emit("VM.IP = %d",(self.PrecompileIP or 0))
self:Emit("VM.XEIP = %d",(self.PrecompileTrueXEIP or 0))
self:Dyn_Emit("VM:Interrupt(%d,%d)",intNo,intParam)
self:Dyn_Emit("VM:Interrupt(%s,%s)",intNo,intParam)
self:Dyn_EmitBreak()
end

Expand Down
10 changes: 5 additions & 5 deletions lua/wire/zvm/zvm_opcodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ ZVM.OpcodeTable[28] = function(self) --SPG
self:Dyn_Emit("end")
end
ZVM.OpcodeTable[29] = function(self) --CPG
self:Dyn_Emit("$L idx = math.floor($1 / 128)")
self:Dyn_Emit("$L IDX = math.floor($1 / 128)")
self:Dyn_Emit("$L PAGE = VM:GetPageByIndex(IDX)")
self:Dyn_EmitInterruptCheck()

self:Dyn_Emit("if VM.CurrentPage.RunLevel <= VM.Page[idx].RunLevel then")
self:Dyn_Emit("if VM.CurrentPage.RunLevel <= PAGE.RunLevel then")
self:Dyn_Emit("PAGE.Read = 1")
self:Dyn_Emit("PAGE.Write = 1")
self:Dyn_Emit("VM:SetPageByIndex(IDX)")
Expand Down Expand Up @@ -1601,9 +1601,9 @@ 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"
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 + %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_EmitInterruptCheck()

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

0 comments on commit 004a0c5

Please sign in to comment.