separate logic and init/input ticks; make inputs stack
This commit is contained in:
28
sim/main.lua
28
sim/main.lua
@@ -289,7 +289,9 @@ while 1 do
|
||||
client:send("SINFO\t" .. data[i+1] .. "\t" .. sim.nwires .. "\t" .. sim.ngates .. "\t" .. sim.ninports .. "\t" .. sim.noutports .. "\n")
|
||||
i = i + 1
|
||||
elseif data[i] == "TICK" then
|
||||
Simulation.tick(sim)
|
||||
Simulation.tickinit(sim)
|
||||
Simulation.tickinput(sim)
|
||||
Simulation.ticklogic(sim)
|
||||
ticks = ticks + 1
|
||||
elseif data[i] == "IN" then
|
||||
local gate = Simulation.getgatebyref(sim, tonumber(data[i+1]))
|
||||
@@ -323,20 +325,18 @@ while 1 do
|
||||
if time-lastticktime >= OPT_TICK_TIME then
|
||||
lastticktime = time
|
||||
|
||||
if OPT_TICK_TIME==0 then
|
||||
for i = 1, OPT_TICK_INF do
|
||||
Simulation.tick(sim)
|
||||
Simulation.tickinit(sim)
|
||||
Simulation.tickinput(sim)
|
||||
|
||||
for i = 1, OPT_TICK_MULT, 100 do
|
||||
local ticksthis = math.min(OPT_TICK_MULT-i+1, 100)
|
||||
for j = 1, ticksthis do
|
||||
Simulation.ticklogic(sim)
|
||||
end
|
||||
ticks = ticks+OPT_TICK_INF
|
||||
else
|
||||
for i = 1, OPT_TICK_MULT do
|
||||
Simulation.tick(sim)
|
||||
ticks = ticks+1
|
||||
|
||||
local elapsed = os.clock()-time
|
||||
if elapsed>0.1 then
|
||||
break
|
||||
end
|
||||
ticks = ticks+ticksthis
|
||||
|
||||
if os.clock()-time>0.1 then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user