diff --git a/src/scripts/interpreter.ts b/src/scripts/interpreter.ts index 235f2ec..dfb338a 100644 --- a/src/scripts/interpreter.ts +++ b/src/scripts/interpreter.ts @@ -224,14 +224,8 @@ const commands: {[k: string]: (o: ProgramState) => void} = { }, 'g': (o) => { let [y, x] = [o.number_implementation.toIndex(pop(o)), o.number_implementation.toIndex(pop(o))]; - if (x < 0) { - x = 0; - } - if (y < 0) { - y = 0; - } - - if (y < o.program.length && x < o.program[y].length) { + + if (x >= 0 && y >= 0 && y < o.program.length && x < o.program[y].length) { push( o, o.program[y][x] @@ -307,4 +301,4 @@ export function step(o: AnyTypeProgramState) { } else { _step(o) } -} \ No newline at end of file +}