![]() |
| Blogs | |
| Recent Entries | Best Entries |
| Best Blogs | Blog List |
| Search Blogs | |
| Tag Search | |
| Advanced Search | |
|
|
|
| |||||||
| Go to Page... |
|
I've recently been working on how abilities work, and I came across the reason why that ability only works on Castform.
Abilities are checked a bit on a "as need goes" format, meaning there is no single "ability routine". They are spread out across the code, sometime grouping together (like volt absorb and water absorb), other times being repeated in several locations (hustle is present on the "attack up" routine and in the "accuracy down" routine). Forecast, however, works like this: The chekc for the forecast byte is done at 0x0801A182, then proceeding to call a specific function to check which form will be used. They are numbered 0-4. I'm still looking how to expand that number, but for now, this is all we got. This piece of code is located at 0x08019DAC, and is a long and boring checklist for possible outcomes. the first being "pokemon not a castform", at bold: ROM:08019DAC Form_switch ; CODE XREF: ROM:0801A342p ROM:08019DAC ; ROM:0801A3B6p ... ROM:08019DAC ROM:08019DAC var_14 = -0x14 ROM:08019DAC ROM:08019DAC PUSH {R4-R6,LR} ROM:08019DAE SUB SP, SP, #4 ROM:08019DB0 LSL R0, R0, #0x18 ROM:08019DB2 LSR R6, R0, #0x18 ROM:08019DB4 MOV R5, #0 ROM:08019DB6 LDR R1, =0x2023BE4 ROM:08019DB8 MOV R0, #0x58 ROM:08019DBA MUL R0, R6 ROM:08019DBC ADD R4, R0, R1 ROM:08019DBE LDRH R1, [R4] ROM:08019DC0 LDR R0, =0x181 ROM:08019DC2 CMP R1, R0 ROM:08019DC4 BNE loc_8019E50 ;if not castform, quit ROM:08019DC6 ADD R0, R4, #0 ROM:08019DC8 ADD R0, #0x20 ROM:08019DCA LDRB R0, [R0] ROM:08019DCC CMP R0, #0x3B ROM:08019DCE BNE loc_8019E50 ROM:08019DD0 LDRH R0, [R4,#0x28] ROM:08019DD2 CMP R0, #0 ROM:08019DD4 BEQ loc_8019E50 ROM:08019DD6 STR R5, [SP,#0x14+var_14] ROM:08019DD8 MOV R0, #0x13 ROM:08019DDA MOV R1, #0 ROM:08019DDC MOV R2, #0xD ROM:08019DDE MOV R3, #0 ROM:08019DE0 BL test_abilities ROM:08019DE4 LSL R0, R0, #0x18 ROM:08019DE6 CMP R0, #0 ROM:08019DE8 BNE loc_8019DFE ROM:08019DEA STR R5, [SP,#0x14+var_14] ROM:08019DEC MOV R0, #0x13 ROM:08019DEE MOV R1, #0 ROM:08019DF0 MOV R2, #0x4D ROM:08019DF2 MOV R3, #0 ROM:08019DF4 BL test_abilities ROM:08019DF8 LSL R0, R0, #0x18 ROM:08019DFA CMP R0, #0 ROM:08019DFC BEQ loc_8019E24 ROM:08019DFE ROM:08019DFE loc_8019DFE ; CODE XREF: Form_switch+3Cj ROM:08019DFE ADD R2, R4, #0 ROM:08019E00 ADD R2, #0x21 ROM:08019E02 LDRB R0, [R2] ROM:08019E04 CMP R0, #0 ROM:08019E06 BEQ loc_8019E24 ROM:08019E08 ADD R1, R4, #0 ROM:08019E0A ADD R1, #0x22 ROM:08019E0C LDRB R0, [R1] ROM:08019E0E CMP R0, #0 ROM:08019E10 BEQ loc_8019E24 ROM:08019E12 STRB R5, [R2] ROM:08019E14 STRB R5, [R1] ROM:08019E16 MOV R0, #1 ROM:08019E18 B loc_8019F08 ROM:08019E18 ; --------------------------------------------------------------------------- ROM:08019E1A DCB 0 ROM:08019E1B DCB 0 ROM:08019E1C dword_8019E1C DCD 0x2023BE4 ; DATA XREF: Form_switch+Ar ROM:08019E20 dword_8019E20 DCD 0x181 ; DATA XREF: Form_switch+14r ROM:08019E24 ; --------------------------------------------------------------------------- ROM:08019E24 ROM:08019E24 loc_8019E24 ; CODE XREF: Form_switch+50j ROM:08019E24 ; Form_switch+5Aj ... ROM:08019E24 MOV R0, #0 ROM:08019E26 STR R0, [SP,#0x14+var_14] ROM:08019E28 MOV R0, #0x13 ROM:08019E2A MOV R1, #0 ROM:08019E2C MOV R2, #0xD ROM:08019E2E MOV R3, #0 ROM:08019E30 BL test_abilities ROM:08019E34 LSL R0, R0, #0x18 ROM:08019E36 LSR R0, R0, #0x18 ROM:08019E38 CMP R0, #0 ROM:08019E3A BNE loc_8019E50 ROM:08019E3C STR R0, [SP,#0x14+var_14] ROM:08019E3E MOV R0, #0x13 ROM:08019E40 MOV R1, #0 ROM:08019E42 MOV R2, #0x4D ROM:08019E44 MOV R3, #0 ROM:08019E46 BL test_abilities ROM:08019E4A LSL R0, R0, #0x18 ROM:08019E4C CMP R0, #0 ROM:08019E4E BEQ loc_8019E54 ROM:08019E50 ROM:08019E50 loc_8019E50 ; CODE XREF: Form_switch+18j ROM:08019E50 ; Form_switch+22j ... ROM:08019E50 MOV R0, #0 ROM:08019E52 B loc_8019F08 ROM:08019E54 ; --------------------------------------------------------------------------- ROM:08019E54 ROM:08019E54 loc_8019E54 ; CODE XREF: Form_switch+A2j ROM:08019E54 LDR R1, =0x2023F1C ROM:08019E56 LDRH R0, [R1] ROM:08019E58 MOV R2, #0xE7 ROM:08019E5A AND R2, R0 ROM:08019E5C ADD R4, R1, #0 ROM:08019E5E CMP R2, #0 ROM:08019E60 BNE loc_8019E82 ROM:08019E62 LDR R1, =0x2023BE4 ROM:08019E64 MOV R0, #0x58 ROM:08019E66 MUL R0, R6 ROM:08019E68 ADD R1, R0, R1 ROM:08019E6A ADD R3, R1, #0 ROM:08019E6C ADD R3, #0x21 ROM:08019E6E LDRB R0, [R3] ROM:08019E70 CMP R0, #0 ROM:08019E72 BEQ loc_8019E82 ROM:08019E74 ADD R1, #0x22 ROM:08019E76 LDRB R0, [R1] ROM:08019E78 CMP R0, #0 ROM:08019E7A BEQ loc_8019E82 ROM:08019E7C STRB R2, [R3] ROM:08019E7E STRB R2, [R1] ROM:08019E80 MOV R5, #1 ROM:08019E82 ROM:08019E82 loc_8019E82 ; CODE XREF: Form_switch+B4j ROM:08019E82 ; Form_switch+C6j ... ROM:08019E82 LDRH R1, [R4] ROM:08019E84 MOV R0, #0x60 ROM:08019E86 AND R0, R1 ROM:08019E88 CMP R0, #0 ROM:08019E8A BEQ loc_8019EAE ROM:08019E8C LDR R1, =0x2023BE4 ROM:08019E8E MOV R0, #0x58 ROM:08019E90 MUL R0, R6 ROM:08019E92 ADD R1, R0, R1 ROM:08019E94 ADD R2, R1, #0 ROM:08019E96 ADD R2, #0x21 ROM:08019E98 LDRB R0, [R2] ROM:08019E9A CMP R0, #0xA ROM:08019E9C BEQ loc_8019EAE ROM:08019E9E ADD R1, #0x22 ROM:08019EA0 LDRB R0, [R1] ROM:08019EA2 CMP R0, #0xA ROM:08019EA4 BEQ loc_8019EAE ROM:08019EA6 MOV R0, #0xA ROM:08019EA8 STRB R0, [R2] ROM:08019EAA STRB R0, [R1] ROM:08019EAC MOV R5, #2 ROM:08019EAE ROM:08019EAE loc_8019EAE ; CODE XREF: Form_switch+DEj ROM:08019EAE ; Form_switch+F0j ... ROM:08019EAE LDRH R1, [R4] ROM:08019EB0 MOV R0, #7 ROM:08019EB2 AND R0, R1 ROM:08019EB4 CMP R0, #0 ROM:08019EB6 BEQ loc_8019EDA ROM:08019EB8 LDR R1, =0x2023BE4 ROM:08019EBA MOV R0, #0x58 ROM:08019EBC MUL R0, R6 ROM:08019EBE ADD R1, R0, R1 ROM:08019EC0 ADD R2, R1, #0 ROM:08019EC2 ADD R2, #0x21 ROM:08019EC4 LDRB R0, [R2] ROM:08019EC6 CMP R0, #0xB ROM:08019EC8 BEQ loc_8019EDA ROM:08019ECA ADD R1, #0x22 ROM:08019ECC LDRB R0, [R1] ROM:08019ECE CMP R0, #0xB ROM:08019ED0 BEQ loc_8019EDA ROM:08019ED2 MOV R0, #0xB ROM:08019ED4 STRB R0, [R2] ROM:08019ED6 STRB R0, [R1] ROM:08019ED8 MOV R5, #3 ROM:08019EDA ROM:08019EDA loc_8019EDA ; CODE XREF: Form_switch+10Aj ROM:08019EDA ; Form_switch+11Cj ... ROM:08019EDA LDRH R1, [R4] ROM:08019EDC MOV R0, #0x80 ROM:08019EDE AND R0, R1 ROM:08019EE0 CMP R0, #0 ROM:08019EE2 BEQ loc_8019F06 ROM:08019EE4 LDR R1, =0x2023BE4 ROM:08019EE6 MOV R0, #0x58 ROM:08019EE8 MUL R0, R6 ROM:08019EEA ADD R1, R0, R1 ROM:08019EEC ADD R2, R1, #0 ROM:08019EEE ADD R2, #0x21 ROM:08019EF0 LDRB R0, [R2] ROM:08019EF2 CMP R0, #0xF ROM:08019EF4 BEQ loc_8019F06 ROM:08019EF6 ADD R1, #0x22 ROM:08019EF8 LDRB R0, [R1] ROM:08019EFA CMP R0, #0xF ROM:08019EFC BEQ loc_8019F06 ROM:08019EFE MOV R0, #0xF ROM:08019F00 STRB R0, [R2] ROM:08019F02 STRB R0, [R1] ROM:08019F04 MOV R5, #4 ROM:08019F06 ROM:08019F06 loc_8019F06 ; CODE XREF: Form_switch+136j ROM:08019F06 ; Form_switch+148j ... ROM:08019F06 ADD R0, R5, #0 ROM:08019F08 ROM:08019F08 loc_8019F08 ; CODE XREF: Form_switch+6Cj ROM:08019F08 ; Form_switch+A6j ROM:08019F08 ADD SP, SP, #4 ROM:08019F0A POP {R4-R6} ROM:08019F0C POP {R1} ROM:08019F0E BX R1 ROM:08019F0E ; End of function Form_switch The other code checks for weather conditions, rechecks the ability and the current form. the "test_abilities" function (located right below at 0x08019F18) is a very large function that acts as a switch for all ability testing, including contact-based effects and a selection of sound moves. To make this work with any pokemon, simply fill with zeros the area from 08019DC0 to 08019DC5. In this way, any pokemon with the forecast ability can turn into a new form. I have tested this with a bulbasaur that had the deoxys forms, and it works as long as the palette has an entry for each picture, in the same format as Castform's. |


