I just got my most complex line of code I've possibly ever written yet working:
thiscpu.interpret(thiscpu.memory[thiscpu.threads[i]].instr, thiscpu.memory[thiscpu.threads[i]].param0, thiscpu.memory[thiscpu.threads[i]].param1, thiscpu.memory[thiscpu.threads[i]].param2);
Remember: more complex != better.

But it is always satisfying getting a fucked up chunk of code working.
Here's my most complex brick of code that I've ever gotten to work:
// big brick of code to find the matching state within the sprite file and match it up with the state to change to; lots of mudkips staring at you
for (i = 0; i < window[game.sprites[object.graphic[1][0]][0] + '_' + game.sprites[object.graphic[1][0]][object.graphic[1][1] + 1][0]].sprite.length - 1; i++) {
if (window[game.sprites[object.graphic[1][0]][0] + '_' + game.sprites[object.graphic[1][0]][object.graphic[1][1] + 1][0]].sprite[i].state == state) {
object.state = window[game.sprites[object.graphic[1][0]][0] + '_' + game.sprites[object.graphic[1][0]][object.graphic[1][1] + 1][0]].sprite[i];
if (object.lastState != object.state.state) {
for (q = 0; q < window[game.sprites[object.graphic[1][0]][0] + '_' + game.sprites[object.graphic[1][0]][object.graphic[1][1] + 1][0]].sprite.length - 1; q++) {
if (window[game.sprites[object.graphic[1][0]][0] + '_' + game.sprites[object.graphic[1][0]][object.graphic[1][1] + 1][0]].sprite[q].state == object.state.state) { // if the sprite state matches
for (s = 0; s < window[game.sprites[object.graphic[1][0]][0] + '_' + game.sprites[object.graphic[1][0]][object.graphic[1][1] + 1][0]].sprite[q].directions.length - 1; s++) {
if (window[game.sprites[object.graphic[1][0]][0] + '_' + game.sprites[object.graphic[1][0]][object.graphic[1][1] + 1][0]].sprite[0].directions[s].direction == object.direction) { // if the sprite direction matches
object.directionInfo = window[game.sprites[object.graphic[1][0]][0] + '_' + game.sprites[object.graphic[1][0]][object.graphic[1][1] + 1][0]].sprite[q].directions[s];
break;
}
}
}
}
object.frame = object.directionInfo.frames[0] + game.sprites[object.graphic[1][0]][object.graphic[1][1] + 1][1];
object.sampler.texture = g_textures[object.frame];
}
object.lastState = object.state.state;
return;
}
}

Fortunately I've since restarted the project using better coding practices.