kirjavascript / TetrisGYM

nes tetris training rom
Other
197 stars 18 forks source link

Use zero flag and values left in accumulator #57

Closed zohassadar closed 10 months ago

zohassadar commented 11 months ago

These are a few minor optimizations that save a total of 70 bytes.

Comparisons to zero identified with grep -RP 'cm?p[yx]?\s+#\$?0?0\b' ./src

There were a few instances where the comparison was necessary as the zero flag would be unknown at the time of the comparison and were left alone. The remaining instances were either commented out altogether or altered to produce the same result with fewer bytes.

There were also a few instances of values being loaded into the accumulator that were already there, identified with grep -zoRP '(?mi)lda\s+(\w+)\s+cmp\s+\S+\s*$\s+b..\s+\S+\s*$\s+lda \1\s*$\s' src/

Reference: http://forum.6502.org/viewtopic.php?f=12&t=4434#p50991 http://www.6502.org/tutorials/6502opcodes.html

kirjavascript commented 10 months ago

ok looks good, I think! :D