I have just finished a pretty big experiment. I went through all the Assembly code in NESmaker (yes every line) to look for instances of TXA STA temp or TYA STA temp or similar pieces of code. For a few years I have wondered how much NESmaker could be improved, both in terms of speed and memory usage if code snippets like TXA STA temp were replaced with STX temp, or similarly TYA STA ... STY. Well, now I have the answer. It's hard to give a 100% correct answer because there are several modules and different ways to set up games, but throughout the code there are 184 instances of this code snippet (that I could find). I re-wrote the code slightly to change every instance I could find to STX or STY. Unfortunately the result isn't mind blowing or anything, but since I love to optimize my code I think this is important. I noticed in some modules you can save 1% in bank $1F. The more important thing is the number of cycles saved. Again, it's nothing mind blowing, but it seems like you can save somewhere between 200 to 400 cycles by doing this. That means a tiny bit of improvement in speed.
PS! I have obviously not touched the instances for pushing to and pulling from the stack, or any other instance where TXA or TYA is appropriate.
To make a long story short, use this
Instead of this
whenever possible. Or the equivalent with TYA STA / STY. In the long run you will save some bytes and cycles, and as we know, every little bit helps when it comes to performance. This code snippet can be found in most default input scripts in NESmaker.
This isn't a tutorial or anything like that. I just wanted to share what I found.
If you're not comfortable with assembly language and the NESmaker code base, you should be very careful about changing these files, and always remember to backup before doing something like this. I have done tests on games with every module (using a default NESmaker setup). As far as I can see I haven't made any mistakes, and everything is working like normal. As I said, this isn't a tutorial. It's more like a lab experiment. I just wanted to report what I found. I have attached a text file which shows all the files (and line numbers) where I found and changed this code snippet. The line numbers indicate where something needs to be changed. I have also attached a zip file with pictures that shows the comparison between a ROM file with and without this change. Don't expect anything amazing. Like I said, the improvements are tiny.
Anyway. I hope this was somewhat interesting or useful.