diff --git a/lua/entities/gmod_wire_gpu/cl_gpuvm.lua b/lua/entities/gmod_wire_gpu/cl_gpuvm.lua index a630e4c..67d3c0b 100644 --- a/lua/entities/gmod_wire_gpu/cl_gpuvm.lua +++ b/lua/entities/gmod_wire_gpu/cl_gpuvm.lua @@ -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") @@ -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") diff --git a/lua/wire/client/hlzasm/hc_codetree.lua b/lua/wire/client/hlzasm/hc_codetree.lua index e0e28f6..dbf4a92 100644 --- a/lua/wire/client/hlzasm/hc_codetree.lua +++ b/lua/wire/client/hlzasm/hc_codetree.lua @@ -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 } diff --git a/lua/wire/client/hlzasm/hc_syntax.lua b/lua/wire/client/hlzasm/hc_syntax.lua index e238152..9318e00 100644 --- a/lua/wire/client/hlzasm/hc_syntax.lua +++ b/lua/wire/client/hlzasm/hc_syntax.lua @@ -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 diff --git a/lua/wire/zvm/zvm_core.lua b/lua/wire/zvm/zvm_core.lua index 915ded5..2292586 100644 --- a/lua/wire/zvm/zvm_core.lua +++ b/lua/wire/zvm/zvm_core.lua @@ -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 diff --git a/lua/wire/zvm/zvm_opcodes.lua b/lua/wire/zvm/zvm_opcodes.lua index 7045c7a..99f7572 100644 --- a/lua/wire/zvm/zvm_opcodes.lua +++ b/lua/wire/zvm/zvm_opcodes.lua @@ -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)") @@ -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 }")