Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This explanation was so confusing that I had to write a program to get it clear in my head. https://gistpreview.github.io/?9b252f267cd1fdf9754059bb73a18...

More clearly: DI = (y * 320) + x

Multiply by 0xCCCD => (y * 0x1000040) + (x * 0xcccd)

Take top byte is equivalent to divide by 0x1000000. So that gives you Y. The next lower (third) byte is then (x * 0xcccd / 0x10000) == (x * 52429 / 65536) =~ (x * 256/320). And the lower two bytes are noise.



(author here) you're right (about confusing), i wasn't expecting more than a few people to actually read this ;) at least i quickly repaired the float/fixed thing.





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

Search: