fix multi-target commands

This commit is contained in:
jane 2020-11-11 15:44:29 -05:00
parent c5beecba95
commit fdf4e771ac

View file

@ -55,6 +55,10 @@ def rand(target, arg, index):
return (random.randrange(0, 255), index)
def jmp(target, arg, index):
return (target, target)
def jnz(target, arg, index):
if target != 0:
return (target, arg)
@ -80,6 +84,7 @@ def _apply(index, target, arg, func):
def apply(index, targets, args, func):
j = index
for target in range(len(targets)):
if this.values[targets[target]['channel']] != None:
print("target: {}".format(targets[target]['channel']))
@ -88,13 +93,14 @@ def apply(index, targets, args, func):
index, this.values[targets[target]['channel']], args[target], func)
if val != this.values[targets[target]['channel']]:
this.values[targets[target]['channel']] = val
return jump
j = jump
else:
val, jump = _apply(
index, this.values[targets[target]['channel']], 0, func)
if val != this.values[targets[target]['channel']]:
this.values[targets[target]['channel']] = val
return jump
j = jump
return j
this.instructions = {
@ -105,6 +111,7 @@ this.instructions = {
"DIVIDE": div,
"MODULO": mod,
"RANDOM": rand,
"JMP": jmp,
"JNZ": jnz,
"JEZ": jez
}