Rogueadyn / SaintCoinach

A .NET library written in C# for extracting game assets and reading game assets from Final Fantasy XIV: A Realm Reborn.
Do What The F*ck You Want To Public License
70 stars 99 forks source link

[Question] Magic bitwise operations #53

Open nikoTM opened 1 year ago

nikoTM commented 1 year ago

Hi! Any chance you could elaborate on this code: https://github.com/Rogueadyn/SaintCoinach/blob/f969b441584688c02dde2fadac548c4a5aaa3faa/SaintCoinach/Xiv/WeatherRate.cs#L93

I stumbled upon this fascinating piece yesterday, still trying to understand what exactly is being done there:

var calcBase = (totalDays * 0x64) + increment;

var step1 = (calcBase << 0xB) ^ calcBase;
var step2 = (step1 >> 8) ^ step1;

return (int)(step2 % 0x64);

Thanks