Registrarse

[ASM] E | PID Rerolls (Complete Shiny Odds Editing)

icyred21023

Usuario de plata
PID Rerolling for Encounter Methods 1 and 2
For: Pokemon Emerald 1.0 US


What these routines do is Re-Roll a Pokemon's PID when encountered. The amount of times it rerolls changes with an item as well, in case you want to add an item like a Shiny Charm. I plan on adding a Consumable Item like Mythica Sandwiches that will give a multiplier to these rolls. Both of these values are stored in Temp Vars (8000s). Ultimately giving complete control of the Shiny Rate, without changing any of the Shiny Checking mechanics. So any Shinys that appear will always be an actual Shiny, even when traded to another game due to having PID/TID-SID XOR value of 7 or less. I'll briefly explain the code.

So these routines run right before a Pokemon's PID is generated. The first routine is for Static Encounters, aka Encounter Method 1 (Legendarys, Starters), and the second routine is for standard grass Wild Encounters, aka Encounter Method 2.

So what they both do is run the standard RNG Rolls, generate a PID, then do a quick Shiny check. If the PID is not Shiny, it will Re-Roll a set amount of times. And you can set how many times you want using the temp variables labeled in Disassembled Code. Also, I added an item check, that will increase this amount to a different value, stored in a different temp variable.

Warning, I've only been working on this for a few days, so there may be unforeseen issues. Issues such as abilities that affect encounters. Also there may be a few encounters that won't trigger these routines. For example, I think Fishing uses a different Encounter Mehtod. But anyways they seem to be working great at the moment, so I will share for now and see how it goes.


Default Shiny Odds with these routines:
Standard Rate = 1/4096
Item Boosted Rate = 1/1024

Disassembled Routines and Formula to Customize Shiny Odds is at Bottom


First Routine ( Method 1 Encounters )



01 BC 24 06 24 0E 00 06 00 0E 82 46 38 1C 33 4B 00 F0 56 F8 00 2C 01 D0 31 48 00 47 FF B4 31 48
02 68 91 7A D0 7A 00 02 01 43 10 7B 00 04 01 43 50 7B 00 06 01 43 0A 1C 09 0C 12 04 12 0C 25 4B
25 4C 19 80 22 80 01 20 21 4B 18 80 1D 4B 1F 4D 2B 80 25 48 01 21 00 F0 2F F8 00 28 01 D0 1A 4B
2B 80 FF BC 00 F0 2A F8 04 1C 00 F0 27 F8 24 04 24 0C 00 04 04 43 FF B4 15 4D 16 4E 16 4F 36 88
3F 88 36 04 3E 43 31 1C 22 1C 23 1C 08 0C 17 4A 11 40 48 40 19 0C 48 40 13 40 58 40 07 28 08 D9
28 88 01 30 28 80 09 4A 12 88 82 42 01 D9 FF BC D8 E7 FF BC 0E 48 00 47 0E 4A 10 47 0E 49 08 47
18 47 C0 46 02 00 00 00 08 00 00 00 E6 75 03 02 E4 75 03 02 E0 75 03 02 E2 75 03 02 75 7A 06 08
F3 7B 06 08 90 5D 00 03 71 01 00 00 FF FF 00 00 0B 7C 06 08 6D 9A 09 08 CD F5 06 08



Hook Method 1 : Overwrite 067BDE with: 01 B4 00 48 00 47 XX +1 XX XX XX



Second Routine (Method 2 Encounters)



1B 06 1E 0E 00 06 05 0E FF B4 34 48 02 68 91 7A D0 7A 00 02 01 43 10 7B 00 04 01 43 50 7B 00 06
01 43 0A 1C 09 0C 12 04 12 0C 2A 4B 2A 4C 19 80 22 80 01 20 26 4B 18 80 22 4B 24 4D 2B 80 28 48
01 21 00 F0 3C F8 00 28 01 D0 1F 4B 2B 80 FF BC 00 F0 33 F8 04 1C 00 F0 30 F8 24 04 24 0C 00 04
04 43 20 1C FF B4 1A 4D 1A 4E 1B 4F 36 88 3F 88 36 04 3E 43 31 1C 02 1C 03 1C 00 04 04 0C 08 0C
18 4A 11 40 48 40 19 0C 48 40 13 40 58 40 07 28 08 D9 28 88 01 30 28 80 0C 4A 12 88 82 42 07 D9
FF BC D5 E7 FF BC 00 F0 06 F8 28 1C 0E 49 08 47 FF BC 0E 49 08 47 0E 49 08 47 0E 48 00 47 0E 4A
10 47 C0 46 02 00 00 00 08 00 00 00 E6 75 03 02 E4 75 03 02 E0 75 03 02 E2 75 03 02 90 5D 00 03
71 01 00 00 FF FF 00 00 C9 7E 06 08 C5 7E 06 08 89 D0 06 08 CD F5 06 08 6D 9A 09 08





Hook Method 2 : Overwrite 067EA0 with: 00 4D 28 47 XX+1 XX XX XX


Disassembled Routines and How to Change Odds



Follow these Formulas to Calculate Odds:

To Solve for New Odds, input Rolls:
Odds = 1 - (1 - (1/8192)^Rolls)

To Solve for Rolls, input New Odds:
Rolls = (Log(1 - Odds)) / (Log(1 - 1/8192))

At the bottom of the dissambled code , change the values of the REROLLS (for new standard odds) and REROLLS_ITEMSBOOST (for item boosted odds)


.THUMB
.ALIGN 2

POP {R0}
LSL R4, R4, #0X18
LSR R4, R4, #0X18
LSL R0, R0, #0X18
LSR R0, R0, #0X18
MOV R10, R0
ADD R0, R7, #0X0
LDR R3, = 0X08067A74+1
BL LINKER
CMP R4, #0X0
BEQ FETCH_TID_SID
LDR R0, = 0X08067BF2+1
BX R0

FETCH_TID_SID:
PUSH {R0-R7}
LDR R0, = 0x03005D90
LDR R2, [R0]
LDRB R1, [R2, #0xA]
LDRB R0, [R2, #0xB]
LSL R0, #0x8
ORR R1, R0
LDRB R0, [R2, #0xC]
LSL R0, #0x10
ORR R1, R0
LDRB R0, [R2, #0xD]
LSL R0, #0x18
ORR R1, R0
MOV R2, R1
LSR R1, #0X10
LSL R2, #0X10
LSR R2, #0X10

VARS_SETUP:
LDR R3, UPPER_TID
LDR R4, LOWER_TID
STRH R1, [R3]
STRH R2, [R4]
MOV R0, #0X1
LDR R3, ROLL_COUNTER
STRH R0, [R3]
LDR R3, REROLLS
LDR R5, REROLLS_VAR
STRH R3, [R5]

CHECK_BOOST_ITEM:
LDR R0, = 0x00000171
MOV R1, #1
BL CHECK_ITEM
CMP R0, #0
BEQ CONTINUE
LDR R3, REROLLS_ITEMBOOST
STRH R3, [R5]

CONTINUE:
POP {R0-R7}

PID_ROLL:
BL LINK_RNG
ADD R4, R0, #0X0
BL LINK_RNG
LSL R4, R4, #0X10
LSR R4, R4, #0X10
LSL R0, R0, #0X10
ORR R4, R0

SHINY_CHECK_LOOP:
PUSH {R0-R7}
LDR R5, ROLL_COUNTER
LDR R6, UPPER_TID
LDR R7, LOWER_TID
LDRH R6, [R6]
LDRH R7, [R7]
LSL R6, #0X10
ORR R6, R7
MOV R1, R6
MOV R2, R4
MOV R3, R4
LSR R0, R1, #0X10
LDR R2, = 0XFFFF
AND R1, R2
EOR R0, R1
LSR R1, R3, #0X10
EOR R0, R1
AND R3, R2
EOR R0, R3
CMP R0, #0X07
BLS DONE
LDRH R0, [R5]
ADD R0, #0X1
STRH R0, [R5]
LDR R2, REROLLS_VAR
LDRH R2, [R2]
CMP R2, R0
BLS DONE
POP {R0-R7}
B PID_ROLL

DONATE:
POP {R0-R7}
LDR R0, = 0X08067C0A+1
BX R0


CHECK_ITEM:
LDR R2, = 0x08099a6c+1
BX R2

LINK_RNG:
LDR R1, = 0X0806F5CC+1
BX R1

LINKER:
BX R3



.ALIGN 2

REROLLS:
.word 0x00000002

REROLLS_ITEMBOOST:
.word 0x00000008

REROLLS_VAR:
.word 0x020275D6 + (0x8008 * 2)

ROLL_COUNTER:
.word 0x020275D6 + (0x8007 * 2)

UPPER_TID:
.word 0x020275D6 + (0x8005 * 2)

LOWER_TID:
.word 0x020275D6 + (0x8006 * 2)






.THUMB
.ALIGN 2

LSL R3, R3, #0X18
LSR R6, R3, #0X18
LSL R0, R0, #0X18
LSR R5, R0, #0X18

FETCH_TID_SID:
PUSH {R0-R7}
LDR R0, = 0x03005D90
LDR R2, [R0]
LDRB R1, [R2, #0xA]
LDRB R0, [R2, #0xB]
LSL R0, #0x8
ORR R1, R0
LDRB R0, [R2, #0xC]
LSL R0, #0x10
ORR R1, R0
LDRB R0, [R2, #0xD]
LSL R0, #0x18
ORR R1, R0
MOV R2, R1
LSR R1, #0X10
LSL R2, #0X10
LSR R2, #0X10

VARS_SETUP:
LDR R3, UPPER_TID
LDR R4, LOWER_TID
STRH R1, [R3]
STRH R2, [R4]
MOV R0, #0X1
LDR R3, ROLL_COUNTER
STRH R0, [R3]
LDR R3, REROLLS
LDR R5, REROLLS_VAR
STRH R3, [R5]

CHECK_BOOST_ITEM:
LDR R0, = 0x00000171
MOV R1, #1
BL CHECK_ITEM
CMP R0, #0
BEQ CONTINUE
LDR R3, REROLLS_ITEMBOOST
STRH R3, [R5]

CONTINUE:
POP {R0-R7}

PID_ROLL:
BL LINKER
ADD R4, R0, #0X0
BL LINKER
LSL R4, R4, #0X10
LSR R4, R4, #0X10
LSL R0, R0, #0X10
ORR R4, R0
ADD R0, R4, #0X0

SHINY_CHECK_LOOP:
PUSH {R0-R7}
LDR R5, ROLL_COUNTER
LDR R6, UPPER_TID
LDR R7, LOWER_TID
LDRH R6, [R6]
LDRH R7, [R7]
LSL R6, #0X10
ORR R6, R7
MOV R1, R6
MOV R2, R0
MOV R3, R0
LSL R0, R0, #0X10
LSR R4, R0, #0X10
LSR R0, R1, #0X10
LDR R2, = 0XFFFF
AND R1, R2
EOR R0, R1
LSR R1, R3, #0X10
EOR R0, R1
AND R3, R2
EOR R0, R3
CMP R0, #0X07
BLS SHINY_RETURN
LDRH R0, [R5]
ADD R0, #0X1
STRH R0, [R5]
LDR R2, REROLLS_VAR
LDRH R2, [R2]
CMP R2, R0
BLS NO_MORE_ROLLS
POP {R0-R7}
B PID_ROLL

SHINY_RETURN:
POP {R0-R7}
BL NATURE_FUNC
MOV R0, R5
LDR R1, = 0X08067EC8+1
BX R1

NO_MORE_ROLLS:
POP {R0-R7}
LDR R1, = 0X08067EC4+1
BX R1

NATURE_FUNC:
LDR R1, = 0X0806d088+1
BX R1

LINKER:
LDR R0, = 0X0806F5CC+1
BX R0

CHECK_ITEM:
LDR R2, = 0x08099a6c+1
BX R2

.ALIGN 2

REROLLS:
.word 0x00000002

REROLLS_ITEMBOOST:
.word 0x00000008

REROLLS_VAR:
.word 0x020275D6 + (0x8008 * 2)

ROLL_COUNTER:
.word 0x020275D6 + (0x8007 * 2)

UPPER_TID:
.word 0x020275D6 + (0x8005 * 2)

LOWER_TID:
.word 0x020275D6 + (0x8006 * 2)

 
Arriba