4 ms·
This explanation was so confusing that I had to write a program to get it clear in my head. https://gistpreview.github.io/?9b252f267cd1fdf9754059bb73a18487 http
by pjc50 7y ago
This explanation was so confusing that I had to write a program to get it clear in my head. https://gistpreview.github.io/?9b252f267cd1fdf9754059bb73a18487 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.
- HellMood 7y ago(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.
- HellMood 7y agoi included your explanation in the wiki http://www.sizecoding.org/wiki/General_Coding_Tricks#Obtaining_X_and_Y_without_DIV_.28The_Rrrola_Trick.29 http://www.sizecoding.org/wiki/General_Coding_Tricks#Obtaini...