Hacker News new | past | comments | ask | show | jobs | submit login
Stupid NES Tricks – Screen Wrap Detection (dustmop.io)
50 points by dustmop on May 20, 2015 | hide | past | favorite | 4 comments



> However, the carry flag produces false positives because nearly any negative delta will cause a carry to happen.

Correct me if I'm wrong, but I think that when going to the right, the carry flag indicates that it wrapped, while when going to the left, the carry flag indicates that it didn't wrap. So the flag is still usable when going to the left, just interpret it the opposite way. Do you think that's correct?


That would work, but that means branching to handle the left/right difference. The author mentioned that he wants to avoid branching to maximize performance.

Avoiding branching is still relevant on modern machines when optimizing hotspots, and even moreso as cpu instruction pipelines get longer.


That's correct, however that would involve some branching. In theory you could do a bit masking trick to use the same code, but that would end up much more complicated and slower than the presented eor hack. That being said, I'm pretty sure that your idea could easily be done on a more modern processor.


Depends on the semantics of the processor's carry flag. That sounds plausible. But if you have to know whether the delta is positive or negative, you'd lose much of the speed benefit of the hack.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: