Skip to content

Commit

Permalink
Change HCOMP to use editor's file location
Browse files Browse the repository at this point in the history
  • Loading branch information
DerelictDrone committed Aug 23, 2024
1 parent b81ca65 commit a303554
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lua/wire/client/hlzasm/hc_compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ function HCOMP:SetSpecialLabels()
self:SetLabel("__DATE_MINUTE__",tonumber(os.date("%M")))
self:SetLabel("__DATE_SECOND__",tonumber(os.date("%S")))

if self.Settings.CurrentPlatform == "GPU" then
if string.match(self.Settings.CurrentPlatform, "GPU$") then
self:SetLabel("regClk", 65535)
self:SetLabel("regReset", 65534)
self:SetLabel("regHWClear", 65533)
Expand Down
4 changes: 2 additions & 2 deletions lua/wire/client/hlzasm/hc_preprocess.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
--------------------------------------------------------------------------------
-- Load file
function HCOMP:LoadFile(filename)
return file.Read("data/"..self.Settings.CurrentPlatform.."Chip/"..filename, "GAME") -- So we also get /addons/wire/data/
return file.Read("data/"..self.Location.."/"..filename, "GAME") -- So we also get /addons/wire/data/
end

-- Save file
function HCOMP:SaveFile(filename,text)
file.Write(self.Settings.CurrentPlatform.."Chip/"..filename,text)
file.Write(self.Location.."/"..filename,text)
end

-- Trim spaces at string sides
Expand Down
5 changes: 3 additions & 2 deletions lua/wire/cpulib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if CLIENT or TESTING then

------------------------------------------------------------------------------
-- Request compiling specific sourcecode
function CPULib.Compile(source,fileName,successCallback,errorCallback,targetPlatform)
function CPULib.Compile(source,fileName,successCallback,errorCallback,targetPlatform,sourceDirectory)
-- Stop any compile/upload process that is running right now
timer.Remove("cpulib_compile")
timer.Remove("cpulib_upload")
Expand All @@ -72,6 +72,7 @@ if CLIENT or TESTING then

-- Start compiling the sourcecode
HCOMP.Settings.CurrentPlatform = targetPlatform or "CPU"
HCOMP.Location = sourceDirectory or HCOMP.Settings.CurrentPlatform .. "chip"
print("=== HL-ZASM High Level Assembly Compiler Output ==")

-- Initialize callbacks
Expand Down Expand Up @@ -144,7 +145,7 @@ if CLIENT or TESTING then
end

editor.C.Val:Update({{message = issue, line = line, char = char}}, nil, issue, Color(128, 20, 50))
end,editor.EditorType)
end,editor.EditorType,editor.Location)
end

------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lua/wire/stools/cpu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ if CLIENT then
------------------------------------------------------------------------------
function ZCPU_RequestCode()
if ZCPU_Editor then
CPULib.Compile(ZCPU_Editor:GetCode(),ZCPU_Editor:GetChosenFile(),compile_success,compile_error)
CPULib.Compile(ZCPU_Editor:GetCode(),ZCPU_Editor:GetChosenFile(),compile_success,compile_error,"CPU",ZCPU_Editor.Location)
end
end
net.Receive("ZCPU_RequestCode", ZCPU_RequestCode)
Expand Down
2 changes: 1 addition & 1 deletion lua/wire/stools/gpu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ if CLIENT then
function ZGPU_RequestCode()
if ZGPU_Editor then
CPULib.Debugger.SourceTab = ZGPU_Editor:GetActiveTab()
CPULib.Compile(ZGPU_Editor:GetCode(),ZGPU_Editor:GetChosenFile(),compile_success,compile_error,"GPU")
CPULib.Compile(ZGPU_Editor:GetCode(),ZGPU_Editor:GetChosenFile(),compile_success,compile_error,"GPU",ZGPU_Editor.Location)
end
end
net.Receive("ZGPU_RequestCode", ZGPU_RequestCode)
Expand Down
2 changes: 1 addition & 1 deletion lua/wire/stools/spu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if CLIENT then
function ZSPU_RequestCode()
if ZSPU_Editor then
CPULib.Debugger.SourceTab = ZSPU_Editor:GetActiveTab()
CPULib.Compile(ZSPU_Editor:GetCode(),ZSPU_Editor:GetChosenFile(),compile_success,compile_error)
CPULib.Compile(ZSPU_Editor:GetCode(),ZSPU_Editor:GetChosenFile(),compile_success,compile_error,"SPU",ZSPU_Editor.Location)
end
end
net.Receive("ZSPU_RequestCode", ZSPU_RequestCode)
Expand Down

0 comments on commit a303554

Please sign in to comment.