RAM_ARM9:0202053C ; void __fastcall pokerusHandler(void *pPartyBlk) RAM_ARM9:0202053C pokerusHandler RAM_ARM9:0202053C RAM_ARM9:0202053C num2 = -0x20 RAM_ARM9:0202053C var_18 = -0x18 RAM_ARM9:0202053C RAM_ARM9:0202053C 78 B5 PUSH {R3-R6,LR} RAM_ARM9:0202053E 83 B0 SUB SP, SP, #0xC RAM_ARM9:02020540 06 1C MOVS R6, R0 RAM_ARM9:02020542 FF F7 6F FC BL getPartySize RAM_ARM9:02020546 00 90 STR R0, [SP,#0x20+num2] RAM_ARM9:02020548 23 F0 06 FD BL mersenneTwisterHandler RAM_ARM9:0202054C 00 21 MOVS R1, #0 RAM_ARM9:0202054E 00 0C LSRS R0, R0, #0x10 RAM_ARM9:02020550 09 04 LSLS R1, R1, #0x10 RAM_ARM9:02020552 01 43 ORRS R1, R0 RAM_ARM9:02020554 08 04 LSLS R0, R1, #0x10 RAM_ARM9:02020556 04 0C LSRS R4, R0, #0x10 RAM_ARM9:02020558 30 1C MOVS R0, R6 ; pPartyBlk RAM_ARM9:0202055A 00 F0 E3 F8 BL pokerusBitmaskForPartyPKM RAM_ARM9:0202055E 02 90 STR R0, [SP,#0x20+var_18] RAM_ARM9:02020560 01 20 80 03 MOVS R0, 0x4000 RAM_ARM9:02020564 84 42 CMP R4, R0 RAM_ARM9:02020566 06 D0 BEQ loc_2020576 RAM_ARM9:02020568 40 00 LSLS R0, R0, #1 RAM_ARM9:0202056A 84 42 CMP R4, R0 RAM_ARM9:0202056C 03 D0 BEQ loc_2020576 RAM_ARM9:0202056E 03 20 80 03 MOVS R0, 0xC000 RAM_ARM9:02020572 84 42 CMP R4, R0 RAM_ARM9:02020574 43 D1 BNE loc_20205FE RAM_ARM9:02020576 RAM_ARM9:02020576 loc_2020576 ; CODE XREF: pokerusHandler+2Aj RAM_ARM9:02020576 ; pokerusHandler+30j RAM_ARM9:02020576 00 20 MOVS R0, #0 RAM_ARM9:02020578 01 90 STR R0, [SP,#0x20+num2+4] RAM_ARM9:0202057A RAM_ARM9:0202057A loc_202057A ; CODE XREF: pokerusHandler+6Aj RAM_ARM9:0202057A ; pokerusHandler+78j RAM_ARM9:0202057A 23 F0 ED FC BL mersenneTwisterHandler RAM_ARM9:0202057E 00 99 LDR R1, [SP,#0x20+num2] RAM_ARM9:02020580 05 1C MOVS R5, R0 RAM_ARM9:02020582 00 29 CMP R1, #0 RAM_ARM9:02020584 05 D0 BEQ loc_2020592 RAM_ARM9:02020586 00 9A LDR R2, [SP,#0x20+num2] ; num2 RAM_ARM9:02020588 01 9B LDR R3, [SP,#0x20+num2+4] RAM_ARM9:0202058A 00 21 MOVS R1, #0 RAM_ARM9:0202058C 6D F0 54 E8 BLX mul64 ; (u64)mt32 * (u64)partyCount >> 32 (there's not really a right-shift, we just use what's in r1. shh!) RAM_ARM9:02020590 0D 1C ADDS R5, R1, #0 ; pick poke to give pokerus RAM_ARM9:02020592 RAM_ARM9:02020592 loc_2020592 ; CODE XREF: pokerusHandler+48j RAM_ARM9:02020592 30 1C MOVS R0, R6 ; pPartyBlk RAM_ARM9:02020594 29 1C MOVS R1, R5 ; slot RAM_ARM9:02020596 FF F7 CD FC BL getPartyPkmEncAdr ; get address of encrypted portion of pkm RAM_ARM9:0202059A 05 21 MOVS R1, #5 ; field RAM_ARM9:0202059C 00 22 MOVS R2, #0 ; data RAM_ARM9:0202059E 04 1C MOVS R4, R0 RAM_ARM9:020205A0 FC F7 C0 FB BL getPKMStat ; species RAM_ARM9:020205A4 00 28 CMP R0, #0 ; if the species is 0, things are fucked because we already randomly picked from the current party size. try again. RAM_ARM9:020205A6 E8 D0 BEQ loc_202057A RAM_ARM9:020205A8 20 1C MOVS R0, R4 ; pPKMBlock RAM_ARM9:020205AA 4C 21 MOVS R1, #0x4C ; 'L' ; field RAM_ARM9:020205AC 00 22 MOVS R2, #0 ; data RAM_ARM9:020205AE FC F7 B9 FB BL getPKMStat ; isEgg RAM_ARM9:020205B2 00 28 CMP R0, #0 RAM_ARM9:020205B4 E1 D1 BNE loc_202057A ; try again if it's an egg RAM_ARM9:020205B6 01 21 MOVS R1, #1 RAM_ARM9:020205B8 A9 40 LSLS R1, R5 RAM_ARM9:020205BA 02 98 LDR R0, [SP,#0x20+var_18] ; this is the result of the party bitmask to see if it already has pokerus RAM_ARM9:020205BC 08 42 TST R0, R1 ; partyBitmask & (1 << slotNum) RAM_ARM9:020205BE 1E D1 BNE loc_20205FE ; if it's not 0(equal), then there was a hit and it already has pokerus. go to the end. RAM_ARM9:020205C0 00 25 MOVS R5, #0 RAM_ARM9:020205C2 07 26 MOVS R6, #7 RAM_ARM9:020205C4 RAM_ARM9:020205C4 loc_20205C4 ; CODE XREF: pokerusHandler+9Aj RAM_ARM9:020205C4 23 F0 C8 FC BL mersenneTwisterHandler RAM_ARM9:020205C8 00 0E LSRS R0, R0, #0x18 ; mt32 >> 24 RAM_ARM9:020205CA 29 02 LSLS R1, R5, #8 ; r1 = r5 << 8, but r5= 0 if we're this far. wtf? RAM_ARM9:020205CC 01 43 ORRS R1, R0 ; mt32 >> 24 | 0x0 RAM_ARM9:020205CE 08 06 LSLS R0, R1, #0x18 RAM_ARM9:020205D0 00 0E LSRS R0, R0, #0x18 ; junk RAM_ARM9:020205D2 02 1C MOVS R2, R0 ; move result of (mt32 >> 24 | 0) << 24 >> 24 (wtf?!) to r2 RAM_ARM9:020205D4 32 40 ANDS R2, R6 ; (mt32 >> 24) & 7 RAM_ARM9:020205D6 F5 D0 BEQ loc_20205C4 ; if bits 24-26 of the mt32 are unset, try again for duration and such. r5 still never gets touched. RAM_ARM9:020205D8 F0 21 MOVS R1, #0xF0 ; '=' ; is the strain non-zero RAM_ARM9:020205DA 01 42 TST R1, R0 RAM_ARM9:020205DC 00 D0 BEQ loc_20205E0 RAM_ARM9:020205DE 10 1C ADDS R0, R2, #0 ; if the strain is indeed non-zero, continue with that mt32 >> 24 RAM_ARM9:020205E0 RAM_ARM9:020205E0 loc_20205E0 ; CODE XREF: pokerusHandler+A0j RAM_ARM9:020205E0 01 07 LSLS R1, R0, #0x1C ; (mt32 >> 24) << 28 (trim the top 4 bits, the strain) RAM_ARM9:020205E2 03 1C MOVS R3, R0 ; save mt32 >> 24 to r3 RAM_ARM9:020205E4 09 0E LSRS R1, R1, #0x18 ; duration is now strain(wtf?) RAM_ARM9:020205E6 0B 43 ORRS R3, R1 ; (mt32 >> 24) | ((duration << 4) & 0xFF) - this is why it can't be 8x RAM_ARM9:020205E8 F3 22 MOVS R2, #0xF3 ; '=' RAM_ARM9:020205EA 1A 40 ANDS R2, R3 ; ((mt32 >> 24) | ((duration << 4) & 0xFF)) & F3 RAM_ARM9:020205EC 12 06 LSLS R2, R2, #0x18 ; typecast to u8 RAM_ARM9:020205EE 12 0E LSRS R2, R2, #0x18 RAM_ARM9:020205F0 52 1C ADDS R2, R2, #1 ; (((mt32 >> 24) | ((duration << 4) & 0xFF)) & F3) + 1 RAM_ARM9:020205F2 12 06 LSLS R2, R2, #0x18 ; typecast again to u8. jesus christ. RAM_ARM9:020205F4 20 1C MOVS R0, R4 ; pPkm RAM_ARM9:020205F6 97 21 MOVS R1, #0x97 ; 'รน' ; field RAM_ARM9:020205F8 12 0E LSRS R2, R2, #0x18 RAM_ARM9:020205FA FC F7 A5 FB BL setPKMStat RAM_ARM9:020205FE RAM_ARM9:020205FE loc_20205FE ; CODE XREF: pokerusHandler+38j RAM_ARM9:020205FE ; pokerusHandler+82j RAM_ARM9:020205FE 03 B0 ADD SP, SP, #0xC RAM_ARM9:02020600 78 BD POP {R3-R6,PC} RAM_ARM9:02020600 ; End of function pokerusHandler RAM_ARM9:02020600