http://rafb.net/p/JpDMq557.html
I was bored and decided to perform some optimizations on smwedit's code. Assuming this is called up to 16 times per frame (more?) you need to make this as fast as possible. I'm sure there's other ways to make this faster but SMW is not the game I hack so oh well.
The biggest optimization you'll notice is the loop-unrolling. Loops can be very costly the longer they have to run in order to complete. My "loop" mechanism takes 3 cycles on failure whereas his takes 6. Also the lots of NOPs every call is a big no-no, I can't emphasize that enough. Why complain about having a slow CPU when you're wasting time with it? That's 2 cycles a NOP, which adds up!
I was bored and decided to perform some optimizations on smwedit's code. Assuming this is called up to 16 times per frame (more?) you need to make this as fast as possible. I'm sure there's other ways to make this faster but SMW is not the game I hack so oh well.
The biggest optimization you'll notice is the loop-unrolling. Loops can be very costly the longer they have to run in order to complete. My "loop" mechanism takes 3 cycles on failure whereas his takes 6. Also the lots of NOPs every call is a big no-no, I can't emphasize that enough. Why complain about having a slow CPU when you're wasting time with it? That's 2 cycles a NOP, which adds up!