Registrarse

[ASM] E | Shiny Charm with Customizable Odds

icyred21023

Usuario de plata
I have made a new Shiny Odds Routine for Emerald
It works with PID Rerolls instead of changing the games Shiny Check Mechanics. You can use a Shiny Charm with that routine as well. You can replace the routines here with these instead if you like.
Here's the link: https://whackahack.com/foro/threads/e-pid-rerolls-complete-shiny-odds-editing.68276/

_____________​

With these routines you can have a flag set that changes the Shiny Odds.
Also you can pick you're Shiny Rate without the flag set. For example in the game I put this in, the regular odds are 1/255, which increase to 1/100 once you get the Shiny Charm. I'll try to be as thorough in my guide. I'm very new to writing ASM and im sure I couldve made these routines simpler but regardless here we go.

There are 4 routines needed to do this. The reason is because there are 4 different Shiny Checks in the game we must hook our routine to.

These routines are set for 1/255 odds WITHOUT the Charm, and 1/100 odds WITHOUT the Charm. This can be changed! The values to be changed will be color coded. The RED values are for editing the Shiny Charm Odds . The GREEN values are for the Regular Shiny Odds , without the charm.

The Shiny Charm Odds are only activated when a FLAG is set. The Flag can be changed and will be
YELLOW. I used Flag 2A0, which is unused.

All Changes Must be made throughout ALL ROUTINES.

Okay, here's the 1st routine . This is the main one that affects shiny palette in battle.


.THUMB
.ALIGN 2

POP {R0}
EOR R0, R1
AND R3, R2
EOR R0, R3
CMP R3, #0
BEQ POKEDEX

PUSH {R0-R7}
LDR R0, = 0x 02A0 @This is the flag that will trigger the new Shiny Rate for the Charm.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}
LSR R0, R0, #0x2 @This takes the Pokemon's generated Shiny Value (0-65535) and divides by 4. Changing the odds down to about 1/2000
CMP R0, #0x A4 @This value is the denominator of above. Vanilla has this byte at 07. Only one byte is allowed. Change if wanted. Formula = 164(A4) / 16383 = 1 / 100
BLS SHINY

NOT_SHINY:
LDR R2, = 0x0806E770+1
BX R2

NO_CHARM:
POP {R0-R7}
CMP R0, #0x FE @This value gives STANDARD Shiny rate without Charm Flag . Value of FE Gives 1/255 total odds. Vanilla is 07 Formula is 65535/( FE )
BLS SHINY
B NOT_SHINY

POKEDEX:
CMP R0, #0x FE @Match value in NOCHARM above IF changed.
IHB NOT_SHINY

SHINY:
LDR R2, = 0x0806E780+1
BX R2


CHECK_FLAG:
LDR R2, = 0x0809D790+1
BX R2

Código:
01BC484013405840002B0FD0FFB40A48
00F010F8002805D0FFBC8008A42807D9
064A1047FFBCFE2802D9F9E7FE28F7D8
034A1047034A1047A002000071E70608
81E7060891D70908
To hook this Routine, open Rom in hex editor and goto offset 0x06E766 and overwrite with 01 B4 00 48 00 47 XX +1 XX XX XX
Replace the XX's with the pointer made from the offset you put the Routine.

2nd Routine , this one is for the Summary screen to properly show as Shiny.

.THUMB
.ALIGN 2

POP {R0}
LSR R1, R2, #0X10
EOR R0, R1
AND R2, R3
EOR R0, R2

PUSH {R0-R7}
LDR R0, = 0x02A0 @Match value from Main Routine if changed.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}
LSR R0, R0, #0x2
CMP R0, #0xA4 @Match value from Main Routine if changed.

NOT_SHINY:
LDR R1, = 0x0806E7E6+1
BX R1

CHECK_FLAG:
LDR R2, = 0x0809D790+1
BX R2

NO_CHARM:
POP {R0-R7}
CMP R0, #0xFE @Match value from Main Routine if changed.
BLS SHINY
B NOT_SHINY

SHINY:
LDR R1, = 0x0806E7F4+1
BX R1

Enriquecido (Código BB):
01BC110C48401A405040FFB4094800F0
08F8002807D0FFBC8008A42807D90649
0847064A1047FFBCFE2800D9F7E70449
08470000A0020000E7E70608  91D70908
F5E70608
To hook this one goto offset 0x06E7DA and overwrite with 01 B4 00 48 00 47 XX +1 XX XX XX

Make sure you put new pointer from this routine.

3rd routine is for the Summary Screen as well but for the Shiny Frame the Sprite sits in.

.THUMB
.ALIGN 2

POP {R0}
EOR R2, R0
AND R1, R3
EOR R2, R1

PUSH {R0-R7}
LDR R0, = 0x02A0 @Match value from Main Routine if changed.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}
LSR R2, R2, #0x2
CMP R2, #0xA4 @Match value from Main Routine if changed.
BLS SHINY

NOT_SHINY:
LDR R1, = 0x0806EBEA+1
BX R1

CHECK_FLAG:
LDR R2, = 0x0809D790+1
BX R2

NO_CHARM:
POP {R0-R7}
CMP R2, #0xFE @Match value from Main Routine if changed.
BLS SHINY
B NOT_SHINY

SHINY:
LDR R1, = 0x0806EBE8+1
BX R1

Código:
01BC424019404A40FFB4094800F008F8
002807D0FFBC9208A42A07D905490847
054A1047FFBCFE2A00D9F7E703490847
A0020000EBEB060891D70908E9EB0608
To hook this one goto offset 0x06EBDE and overwrite with 01 B4 00 48 00 47 XX +1 XX XX XX


4th and LAST Routine. This one is for the Sparkle Effect that appears when Pokemon is sent into battle.

.THUMB
.ALIGN 2

POP {R0}
LSR R1, R4, #0x10
EOR R0, R1
AND R4, R7
EOR R0, R4

PUSH {R0-R7}
LDR R0, = 0x02A0 @Match value in Main Routine if changed.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}
LSR R0, R0, #0x2
CMP R0, #0xA4 @Match value in Main Routine if changed.
BLS SHINY

NOT_SHINY:
LDR R0, = 0x08172F4E+1
BX R0

CHECK_FLAG:
LDR R2, = 0x0809D790+1
BX R2

NO_CHARM:
POP {R0-R7}
CMP R0, #0xFE @Match value in Main Routine if changed.
BLS SHINY
B NOT_SHINY

SHINY:
LDR R0, = 0x08172F4A+1
BX R0

Código:
01BC210C48403C406040FFB4094800F0
08F8002807D0FFBC8008A42807D90648
0047064A1047FFBCFE2800D9F7E70448
00470000A00200004F2F170891D70908
4B2F1708

To hook goto offset 0x172F3E and overwrite with 01 B4 00 48 00 47 XX +1 XX XX XX


Next is to add in the Shiny Charm Item. I will post more detailed instructions soon, but for now I attached a sprite I made, which can be imported on UNLZ. This sprite was made from the Gold Teeth sprite, which was listed somewhere around 2300. Once on Gold Teeth in UNLZ, click import, select the Sprite below, and then hit Write to Rom. Make sure Abort if Bigger is on, and also to Import the Palette as well. It should overwrite fine.

After this I used LSA to change name and description of Gold Teeth.

Once all that's done, all that's left to do is write a script in XSE to give the item, and set the flag in routine, 2A0 if you didn't change.
 

Adjuntos

Última edición:

Draizehn

Retired.
Miembro del equipo
Moderador/a
You are great, friend, good contribution!
Keep it up. Sorry for my bad English, I don't speak it haha
 

eMMe97

Usuario de platino
Great! But I read this
”How does the Shiny Charm work? Once you have the Shiny Charm, your odds of finding a shiny Pokémon will automatically increase from the base of 1/4,096 down to 1/1,365.”
In this case the shiny charm is an item, why you use a flag? You can use in your routine a check item.

Edit. In emerald I think the check item routine is 0x0809DE8C and probably works like fire red (r0 = item id, r1 = quantity, r2 = routine check item)
 
Última edición:

icyred21023

Usuario de plata
Great! But I read this
”How does the Shiny Charm work? Once you have the Shiny Charm, your odds of finding a shiny Pokémon will automatically increase from the base of 1/4,096 down to 1/1,365.”
In this case the shiny charm is an item, why you use a flag? You can use in your routine a check item.

Edit. In emerald I think the check item routine is 0x0809DE8C and probably works like fire red (r0 = item id, r1 = quantity, r2 = routine check item)
Honestly I didn't know you could checkitem lol what's the address , r0 in and out? But I used a flag thinking it would get set in an xse script when it was given
 

eMMe97

Usuario de platino
For example the first routine:

PUSH {R0-R7}
LDR R0, = 0x02A0 @This is the flag that will trigger the new Shiny Rate for the Charm.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}

CHECK_FLAG:
LDR R2, = 0x0809D790+1
BX R2


becomes:


PUSH {R0-R7}
LDR R0, = 0x... @Item ID of Shiny Charm.
MOV R1, #1 @item quantity
BL CHECK_ITEM
CMP R0, #0
BEQ NO_ITEM
POP {R0-R7}

CHECK_ITEM:
LDR R2, = 0x0809DE8C+1
BX R2
 
Última edición:

icyred21023

Usuario de plata
For example the first routine:

PUSH {R0-R7}
LDR R0, = 0x02A0 @This is the flag that will trigger the new Shiny Rate for the Charm.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}

CHECK_FLAG:
LDR R2, = 0x0809D790+1
BX R2


becomes:


PUSH {R0-R7}
LDR R0, = 0x... @Item ID of Shiny Charm.
MOV R1, #1 @item quantity
BL CHECK_ITEM
CMP R0, #0
BEQ NO_ITEM
POP {R0-R7}

CHECK_ITEM:
LDR R2, = 0x0809DE8C+1
BX R2
Very good to know. Thank you 🙏
 

Versekr Dark

Usuario mítico
FR:

Si hay algún error haganmelo saber

Flag red color: A0 02 = 02A0

0x04411A: 01 B4 00 48 00 47 XX +1 XX XX XX

01 BC 48 40 13 40 58 40 00 2B 0F D0 FF B4 0A 48 00 F0 10 F8 00 28 05 D0 FF BC 80 08 A4 28 07 D9 06 4A 10 47 FF BC FE 28 02 D9 F9 E7 FE 28 F7 D8 03 4A 10 47 03 4A 10 47 A0 02 00 00 25 41 04 08 35 41 04 08 D1 E6 06 08

0x04418E: 01 B4 00 48 00 47 XX +1 XX XX XX

01 BC 11 0C 48 40 1A 40 50 40 FF B4 09 48 00 F0 08 F8 00 28 07 D0 FF BC 80 08 A4 28 07 D9 06 49 08 47 06 4A 10 47 FF BC FE 28 00 D9 F7 E7 04 49 08 47 00 00 A0 02 00 00 9B 41 04 08 D1 E6 06 08 A9 41 04 08

0x0444AA: 01 B4 00 48 00 47 XX +1 XX XX XX

01 BC 42 40 19 40 4A 40 FF B4 09 48 00 F0 08 F8 00 28 07 D0 FF BC 92 08 A4 2A 07 D9 05 49 08 47 05 4A 10 47 FF BC FE 2A 00 D9 F7 E7 03 49 08 47 A0 02 00 00 B7 44 04 08 D1 E6 06 08 B5 44 04 08

0x0F176E: 01 B4 00 48 00 47 XX +1 XX XX XX

01 BC 21 0C 48 40 3C 40 60 40 FF B4 09 48 00 F0 08 F8 00 28 07 D0 FF BC 80 08 A4 28 07 D9 06 48 00 47 06 4A 10 47 FF BC FE 28 00 D9 F7 E7 04 48 00 47 00 00 A0 02 00 00 7F 17 0F 08 D1 E6 06 08 7B 17 0F 08

[#]
0x04411A: 01 B4 00 48 00 47 XX +1 XX XX XX
.THUMB
.ALIGN 2

POP {R0}
EOR R0, R1
AND R3, R2
EOR R0, R3
CMP R3, #0
BEQ POKEDEX

PUSH {R0-R7}
LDR R0, = 0x02A0 @This is the flag that will trigger the new Shiny Rate for the Charm.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}
LSR R0, R0, #0x2 @This takes the Pokemon's generated Shiny Value (0-65535) and divides by 4. Changing the odds down to about 1/2000
CMP R0, #0xA4 @This value is the denominator of above. Vanilla has this byte at 07. Only one byte is allowed. Change if wanted. Formula = 164(A4) / 16383 = 1 / 100
BLS SHINY

NOT_SHINY:
LDR R2, = 0x08044124+1
BX R2

NO_CHARM:
POP {R0-R7}
CMP R0, #0xFE @This value gives STANDARD Shiny rate without Charm Flag . Value of FE Gives 1/255 total odds. Vanilla is 07 Formula is 65535/(FE)
BLS SHINY
B NOT_SHINY

POKEDEX:
CMP R0, #0xFE @Match value in NOCHARM above IF changed.
IHB NOT_SHINY

SHINY:
LDR R2, = 0x08044134+1
BX R2


CHECK_FLAG:
LDR R2, = 0x0806e6d0+1
BX R2

@
01 BC 48 40 13 40 58 40 00 2B 0F D0 FF B4 0A 48 00 F0 10 F8 00 28 05 D0 FF BC 80 08 A4 28 07 D9 06 4A 10 47 FF BC FE 28 02 D9 F9 E7 FE 28 F7 D8 03 4A 10 47 03 4A 10 47 A0 02 00 00 25 41 04 08 35 41 04 08 D1 E6 06 08

[#]
0x04418E: 01 B4 00 48 00 47 XX +1 XX XX XX
.THUMB
.ALIGN 2

POP {R0}
LSR R1, R2, #0X10
EOR R0, R1
AND R2, R3
EOR R0, R2

PUSH {R0-R7}
LDR R0, = 0x02A0 @Match value from Main Routine if changed.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}
LSR R0, R0, #0x2
CMP R0, #0xA4 @Match value from Main Routine if changed.

NOT_SHINY:
LDR R1, = 0x0804419A+1
BX R1

CHECK_FLAG:
LDR R2, = 0x0806e6d0+1
BX R2

NO_CHARM:
POP {R0-R7}
CMP R0, #0xFE @Match value from Main Routine if changed.
BLS SHINY
B NOT_SHINY

SHINY:
LDR R1, = 0x080441A8+1
BX R1

@
01 BC 11 0C 48 40 1A 40 50 40 FF B4 09 48 00 F0 08 F8 00 28 07 D0 FF BC 80 08 A4 28 07 D9 06 49 08 47 06 4A 10 47 FF BC FE 28 00 D9 F7 E7 04 49 08 47 00 00 A0 02 00 00 9B 41 04 08 D1 E6 06 08 A9 41 04 08

[#]
0x0444AA: 01 B4 00 48 00 47 XX +1 XX XX XX
.THUMB
.ALIGN 2

POP {R0}
EOR R2, R0
AND R1, R3
EOR R2, R1

PUSH {R0-R7}
LDR R0, = 0x02A0 @Match value from Main Routine if changed.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}
LSR R2, R2, #0x2
CMP R2, #0xA4 @Match value from Main Routine if changed.
BLS SHINY

NOT_SHINY:
LDR R1, = 0x080444B6+1
BX R1

CHECK_FLAG:
LDR R2, = 0x0806e6d0+1
BX R2

NO_CHARM:
POP {R0-R7}
CMP R2, #0xFE @Match value from Main Routine if changed.
BLS SHINY
B NOT_SHINY

SHINY:
LDR R1, = 0x080444B4+1
BX R1

@

01 BC 42 40 19 40 4A 40 FF B4 09 48 00 F0 08 F8 00 28 07 D0 FF BC 92 08 A4 2A 07 D9 05 49 08 47 05 4A 10 47 FF BC FE 2A 00 D9 F7 E7 03 49 08 47 A0 02 00 00 B7 44 04 08 D1 E6 06 08 B5 44 04 08

[#]
0x0F176E: 01 B4 00 48 00 47 XX +1 XX XX XX
.THUMB
.ALIGN 2

POP {R0}
LSR R1, R4, #0x10
EOR R0, R1
AND R4, R7
EOR R0, R4

PUSH {R0-R7}
LDR R0, = 0x02A0 @Match value in Main Routine if changed.
BL CHECK_FLAG
CMP R0, #0
BEQ NO_CHARM
POP {R0-R7}
LSR R0, R0, #0x2
CMP R0, #0xA4 @Match value in Main Routine if changed.
BLS SHINY

NOT_SHINY:
LDR R0, = 0x080F177E+1
BX R0

CHECK_FLAG:
LDR R2, = 0x0806e6d0+1
BX R2

NO_CHARM:
POP {R0-R7}
CMP R0, #0xFE @Match value in Main Routine if changed.
BLS SHINY
B NOT_SHINY

SHINY:
LDR R0, = 0x080F177A+1
BX R0

@

01 BC 21 0C 48 40 3C 40 60 40 FF B4 09 48 00 F0 08 F8 00 28 07 D0 FF BC 80 08 A4 28 07 D9 06 48 00 47 06 4A 10 47 FF BC FE 28 00 D9 F7 E7 04 48 00 47 00 00 A0 02 00 00 7F 17 0F 08 D1 E6 06 08 7B 17 0F 08

1695307625885.png
 
Última edición:

icyred21023

Usuario de plata
Great! But I read this
”How does the Shiny Charm work? Once you have the Shiny Charm, your odds of finding a shiny Pokémon will automatically increase from the base of 1/4,096 down to 1/1,365.”
In this case the shiny charm is an item, why you use a flag? You can use in your routine a check item.

Edit. In emerald I think the check item routine is 0x0809DE8C and probably works like fire red (r0 = item id, r1 = quantity, r2 = routine check item)
No, the routine as is changes odds to 1/255 without Charm, down to 1/100 with the charm. To change the odds to 1/4096 and 1/1365, change the green values across all routines to 0xF , and change the red value across all routines to 0xB. You can change it in the assembled code too. Once I get to a desktop I'll add it to this reply
 
Arriba