Talk:Greed Donation Machine

From The Binding of Isaac: Rebirth Wiki
Jump to navigation Jump to search

Formulas & numbers

Here's my evidence for the formula and 99.9% moddded character jam chance. I'm not that well versed in x86 disassembly, but I think it checks out. There's lines I didn't figure out exactly or thought were relevant for the formula itself, but I left them in.

isaac-ng.exe+50549F - call isaac-ng.exe+38D8B0
 ^ Location that calls the calculation function for HUD printing
======
isaac-ng.exe+23E22B - call isaac-ng.exe+38D8B0
 ^ Location that calls the calculation during coin insert
======
isaac-ng.exe+38D8B0 - push ebp
 ^ Start of calculation function
isaac-ng.exe+38D8B1 - mov ebp,esp
isaac-ng.exe+38D8B3 - mov eax,[ecx+0000130C]
 ^ Load player character number
isaac-ng.exe+38D8B9 - sub esp,08 { 8 }
isaac-ng.exe+38D8BC - cmp eax,29 { 41 }
 ^ Checks if the character is modded - if number is less than 41, it's not
isaac-ng.exe+38D8BF - jl isaac-ng.exe+38D8CB
isaac-ng.exe+38D8C1 - fld dword ptr [isaac-ng.exe+76AAF8] { (99.90) }
 ^ Modded, apply a 99.9% jam chance
isaac-ng.exe+38D8C7 - mov esp,ebp
isaac-ng.exe+38D8C9 - pop ebp
isaac-ng.exe+38D8CA - ret 
 ^ Return from function
isaac-ng.exe+38D8CB - mov ecx,[isaac-ng.exe+7FD680] { (16C0E020) }
isaac-ng.exe+38D8D1 - lea eax,[eax+eax*8]
isaac-ng.exe+38D8D4 - shl eax,04 { 4 }
isaac-ng.exe+38D8D7 - add eax,isaac-ng.exe+7C5FE0 { (27) }
isaac-ng.exe+38D8DC - je isaac-ng.exe+38D8E3
isaac-ng.exe+38D8DE - mov eax,[eax+40]
isaac-ng.exe+38D8E1 - jmp isaac-ng.exe+38D8E5
isaac-ng.exe+38D8E3 - xor eax,eax
isaac-ng.exe+38D8E5 - mov eax,[ecx+eax*4+000002CC]
 ^ Loads the coins donated by the character
isaac-ng.exe+38D8EC - xorps xmm0,xmm0
isaac-ng.exe+38D8EF - cvtsi2sd xmm0,eax
 ^ Convert to a floating point
isaac-ng.exe+38D8F3 - shr eax,1F { 31 }
isaac-ng.exe+38D8F6 - addsd xmm0,[eax*8+isaac-ng.exe+76C940]
 ^ This is some kind of a check for a negative value
isaac-ng.exe+38D8FF - cvtpd2ps xmm0,xmm0
isaac-ng.exe+38D903 - mulss xmm0,[isaac-ng.exe+76A23C] { (0.02) }
 ^ Multiply the value by 0.023 -- debugger rounds to 0.02 in the comment
isaac-ng.exe+38D90B - call isaac-ng.exe+31FDB0
 ^ Call a function that calls the exp() math library function
isaac-ng.exe+38D910 - subss xmm0,[isaac-ng.exe+76A614] { (1.00) }
 ^ Subtract 1, shifts the value at 0 coins from 1 to 0
isaac-ng.exe+38D918 - sub esp,08 { 8 }
isaac-ng.exe+38D91B - minss xmm0,[isaac-ng.exe+76AAFC] { (100.00) }
 ^ Bound to a maximum of 100.0
isaac-ng.exe+38D923 - mulss xmm0,[isaac-ng.exe+76A350] { (0.20) }
 ^ Multiply by 0.2
isaac-ng.exe+38D92B - addss xmm0,[isaac-ng.exe+76A480] { (0.50) }
 ^ Add 0.5
isaac-ng.exe+38D933 - movss [ebp-04],xmm0
isaac-ng.exe+38D938 - fld dword ptr [ebp-04]
isaac-ng.exe+38D93B - fstp qword ptr [esp]
isaac-ng.exe+38D93E - call isaac-ng.exe+5EC3B2 { ->->ucrtbase.floor }
 ^ Call the floor() math function, rounding down
isaac-ng.exe+38D943 - mov eax,[isaac-ng.exe+7FD65C] { (17DF5020) }
isaac-ng.exe+38D948 - add esp,08 { 8 }
isaac-ng.exe+38D94B - fstp dword ptr [ebp-04]
isaac-ng.exe+38D94E - movss xmm1,[ebp-04]
isaac-ng.exe+38D953 - movss [ebp-04],xmm1
isaac-ng.exe+38D958 - cmp dword ptr [eax+00243624],03 { 3 }
 ^ Check if greedier mode
isaac-ng.exe+38D95F - jne isaac-ng.exe+38D972
isaac-ng.exe+38D961 - movss xmm0,[isaac-ng.exe+76A614] { (1.00) }
isaac-ng.exe+38D969 - minss xmm0,xmm1
 ^ Bound to 1
isaac-ng.exe+38D96D - movss [ebp-04],xmm0
isaac-ng.exe+38D972 - fld dword ptr [ebp-04]
isaac-ng.exe+38D975 - mov esp,ebp
isaac-ng.exe+38D977 - pop ebp
isaac-ng.exe+38D978 - ret 
 ^ End function
======
 v Return during HUD printing
isaac-ng.exe+5054A4 - fadd dword ptr [isaac-ng.exe+76A480] { (0.50) }
 ^ Add a hidden 0.5% to the result -- results in standard rounding during conversion to integer, but might affect results?
isaac-ng.exe+5054AA - fstp dword ptr [ebp-000000E0]
isaac-ng.exe+5054B0 - cvttss2si eax,[ebp-000000E0]
 ^ Convert to integer
isaac-ng.exe+5054B8 - push eax
isaac-ng.exe+5054B9 - push isaac-ng.exe+74E788 { ("%d%%") }
isaac-ng.exe+5054BE - push 10 { 16 }
isaac-ng.exe+5054C0 - push isaac-ng.exe+8070FC { (805320240) }
isaac-ng.exe+5054C5 - call isaac-ng.exe+18980
 ^ Print to hud
======
 v Return during coin insertion
isaac-ng.exe+23E230 - cmp dword ptr [edi+00000360],03 { 3 }
isaac-ng.exe+23E237 - fstp dword ptr [ebp-14]
isaac-ng.exe+23E23A - je isaac-ng.exe+23E3FE
isaac-ng.exe+23E240 - mov ecx,ebx
isaac-ng.exe+23E242 - call isaac-ng.exe+3A7DB0
 ^ Call RNG, guess: generates the jam check value, float 0-1
isaac-ng.exe+23E247 - fmul dword ptr [isaac-ng.exe+76AAFC] { (100.00) }
 ^ Multiplies it by 100
isaac-ng.exe+23E24D - movss xmm0,[ebp-14]
isaac-ng.exe+23E252 - fstp dword ptr [ebp-78]
isaac-ng.exe+23E255 - comiss xmm0,[ebp-78]
isaac-ng.exe+23E259 - jbe isaac-ng.exe+23E3FE
 ^ Guess: performs the jam check vs. the calculated percentage
 ^ the "jbe" means "if below or equal" suggesting the check is "randomPercent <= jamPercent", that means having 0% jam chance would still result in a 1% chance of jamming if randomPercent is 0
 v Start performing animations/state changes accordingly, play sound, etc...
isaac-ng.exe+23E25F - push 00 { 0 }
isaac-ng.exe+23E261 - call isaac-ng.exe+239170
isaac-ng.exe+23E266 - push eax
isaac-ng.exe+23E267 - lea ecx,[edi+3C]
isaac-ng.exe+23E26A - call isaac-ng.exe+54F0
isaac-ng.exe+23E26F - push 01 { 1 }
isaac-ng.exe+23E271 - push 22 { 34 }
isaac-ng.exe+23E273 - jmp isaac-ng.exe+23DD8D
isaac-ng.exe+23E278 - push isaac-ng.exe+7468F8 { ("CoinInsert") }
isaac-ng.exe+23E27D - lea ecx,[edi+3C]
isaac-ng.exe+23E280 - call isaac-ng.exe+19B50
 ...
--Frionil (talk) 17:34, 25 September 2023 (UTC)