[ADD] Temporary binary opcodes [FIX] Reading and writing to non-existing port does not cause interrupt now [FIX] Port bus failure is interrupt #8 now (instead of #10) [FIX] Reading from non-existing port is now #10 instead of #8 [FIX] Increased max CPU frequency [FIX] Fixed bug when setting frequency over limit does not set it to maximum allowed value [FIX] Removed debug message in constant gate [FIX] CPU now sends packets with more bandwidth and speed in SP (bandwidth only in MP). Uploading 70KB now takes 3-5 seconds [TEMP FIX] Multiply "CPU Upload complete" messages
65 lines
1.3 KiB
Lua
65 lines
1.3 KiB
Lua
|
|
AddCSLuaFile( "cl_init.lua" )
|
|
AddCSLuaFile( "shared.lua" )
|
|
|
|
include('shared.lua')
|
|
|
|
ENT.WireDebugName = "Value"
|
|
ENT.OverlayDelay = 0
|
|
|
|
function ENT:Initialize()
|
|
self.Entity:PhysicsInit( SOLID_VPHYSICS )
|
|
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
|
|
self.Entity:SetSolid( SOLID_VPHYSICS )
|
|
|
|
self.Outputs = Wire_CreateOutputs(self.Entity, { "Out" })
|
|
end
|
|
|
|
function ENT:Setup(value)
|
|
|
|
if type(value) != "table" then
|
|
local v = value
|
|
value = {}
|
|
value[1] = tostring(v)
|
|
end
|
|
|
|
local adjoutputs = {}
|
|
for k,v in pairs(value) do
|
|
adjoutputs[k] = "Value"..tostring(k)
|
|
end
|
|
|
|
self.value = value
|
|
//this is where storing the values as strings comes in
|
|
Wire_AdjustOutputs(self.Entity, adjoutputs, value)
|
|
|
|
local txt = ""
|
|
|
|
for k,v in pairs(value) do
|
|
//line break after 4 values
|
|
//if (k == 5) or (k == 9) then txt = txt.."\n" end
|
|
txt = txt .. "1: " .. v
|
|
if (k < #value) then txt = txt .. "\n" end
|
|
Wire_TriggerOutput(self.Entity, adjoutputs[k], tonumber(v))
|
|
end
|
|
|
|
self:SetOverlayText(txt)
|
|
|
|
end
|
|
|
|
|
|
function ENT:ReadCell( Address )
|
|
if (Address >= 0) && (Address < table.Count(self.value)) then
|
|
return self.value[Address+1]
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
|
|
function ENT:WriteCell( Address, value )
|
|
if (Address >= 0) && (Address < table.Count(self.value)) then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|