Skip to content

Instantly share code, notes, and snippets.

@kamronbatman
Last active April 23, 2017 04:20
Show Gist options
  • Save kamronbatman/594e376ab2c388ea7216bf9b04a76104 to your computer and use it in GitHub Desktop.
Save kamronbatman/594e376ab2c388ea7216bf9b04a76104 to your computer and use it in GitHub Desktop.
Unused Pokemon Generation - PCJP 2003
; =============== S U B R O U T I N E =======================================
pokemon_generation_unused
var_34 = -0x34
var_30 = -0x30
var_2C = -0x2C
var_28 = -0x28
var_24 = -0x24
PUSH {R4-R7,LR}
MOV R7, R10
MOV R6, R9
MOV R5, R8
PUSH {R5-R7}
SUB SP, SP, #0x14
MOVS R7, R1
LDR R1, =0x3005AA0
LDRB R6, [R1,#0xA]
LDRB R0, [R1,#0xB]
LSLS R0, R0, #8
ORRS R6, R0
LDRB R0, [R1,#0xC]
LSLS R0, R0, #0x10
ORRS R6, R0
LDRB R0, [R1,#0xD]
LSLS R0, R0, #0x18
ORRS R6, R0 ; r6 = sidtid
BL rand
MOVS R4, R0
BL rand
LSLS R4, R4, #0x10
ORRS R4, R0
LDR R3, =0xFFFF0000
LSRS R2, R6, #0x10
LDR R0, =0xFFFF
ANDS R0, R6
EORS R2, R0
B loc_201E7C2
; ---------------------------------------------------------------------------
ALIGN 4
dword_201E7B4 DCD 0x3005AA0 ; DATA XREF: pokemon_generation_unused+Er
dword_201E7B8 DCD 0xFFFF0000 ; DATA XREF: pokemon_generation_unused+32r
dword_201E7BC DCD 0xFFFF ; DATA XREF: pokemon_generation_unused+36r
; ---------------------------------------------------------------------------
loc_201E7C0 ; CODE XREF: pokemon_generation_unused+5Aj
ADDS R4, #1
loc_201E7C2 ; CODE XREF: pokemon_generation_unused+3Cj
MOVS R1, R4
ANDS R1, R3
LSRS R0, R1, #0x10
EORS R0, R2
EORS R0, R1
CMP R0, #7
BLS loc_201E7C0
MOVS R0, R7
BL initPartyData
MOVS R5, #0
MOVS R2, #0
LDR R1, =unk_202EA54
LDRH R0, [R1,#(word_202EA56 - 0x202EA54)]
CMP R0, #0
BEQ loc_201E806
loc_201E7E2 ; CODE XREF: pokemon_generation_unused+90j
LSLS R0, R2, #2
ADDS R0, R0, R2
LSLS R0, R0, #2
ADDS R0, R0, R1
LDRH R0, [R0,#2]
ADDS R0, R5, R0
LSLS R0, R0, #0x10
LSRS R5, R0, #0x10
ADDS R0, R2, #1
LSLS R0, R0, #0x18
LSRS R2, R0, #0x18
LSLS R0, R2, #2
ADDS R0, R0, R2
LSLS R0, R0, #2
ADDS R0, R0, R1
LDRH R0, [R0,#2]
CMP R0, #0
BNE loc_201E7E2
loc_201E806 ; CODE XREF: pokemon_generation_unused+6Cj
MOVS R0, R5
BL sub_2019708
LSLS R0, R0, #0x10
LSRS R5, R0, #0x10 ; R5 = R0 >> 16
MOVS R2, #0
LDR R1, =unk_202EA54
LDRH R0, [R1,#(word_202EA56 - 0x202EA54)]
CMP R0, #0
BEQ loc_201E85C
MOV R8, R1
MOV R3, R8
loc_201E81E ; CODE XREF: pokemon_generation_unused+D8j
LSLS R0, R2, #2
ADDS R0, R0, R2
LSLS R0, R0, #2
ADDS R1, R0, R3 ; R1 = R0 + 100 (byte length)
LDRH R0, [R1,#2]
CMP R5, R0
BCS loc_201E834
LDRH R5, [R1,#4]
B loc_201E84E
; ---------------------------------------------------------------------------
off_201E830 DCD unk_202EA54 ; DATA XREF: pokemon_generation_unused+66r
; pokemon_generation_unused+9Er
; ---------------------------------------------------------------------------
loc_201E834 ; CODE XREF: pokemon_generation_unused+B6j
SUBS R0, R5, R0
LSLS R0, R0, #0x10
LSRS R5, R0, #0x10
ADDS R0, R2, #1
LSLS R0, R0, #0x18
LSRS R2, R0, #0x18
LSLS R0, R2, #2
ADDS R0, R0, R2
LSLS R0, R0, #2
ADDS R0, R0, R3
LDRH R0, [R0,#2]
CMP R0, #0
BNE loc_201E81E
loc_201E84E ; CODE XREF: pokemon_generation_unused+BAj
LSLS R0, R2, #2
ADDS R0, R0, R2
LSLS R0, R0, #2
ADD R0, R8
LDRH R0, [R0,#2]
CMP R0, #0
BNE loc_201E85E
loc_201E85C ; CODE XREF: pokemon_generation_unused+A4j
MOVS R2, #0
loc_201E85E ; CODE XREF: pokemon_generation_unused+E6j
LDR R0, =unk_202EA54
MOV R10, R0
LSLS R0, R2, #2
ADDS R0, R0, R2
LSLS R0, R0, #2
MOV R8, R0
MOV R0, R10
ADDS R0, #0x10
ADD R0, R8
LDR R0, [R0]
CMP R0, #0
BEQ loc_201E89C ; Branch if not force shiny
LDR R0, =0xFFFF0000
ANDS R4, R0
MOVS R1, R6
ANDS R1, R0
LSRS R1, R1, #0x10
LDR R0, =0xFFFF
ANDS R0, R6
EORS R1, R0
LSRS R0, R4, #0x10
EORS R1, R0
ORRS R4, R1
MOVS R0, #8
NEGS R0, R0
ANDS R4, R0
BL rand
MOVS R1, #7
ANDS R1, R0
ORRS R4, R1
loc_201E89C ; CODE XREF: pokemon_generation_unused+100j
MOV R0, R8
ADD R0, R10
LDRB R2, [R0]
MOVS R1, #1
MOV R9, R1
STR R1, [SP,#0x34+var_34]
STR R4, [SP,#0x34+var_30]
STR R1, [SP,#0x34+var_2C]
STR R6, [SP,#0x34+var_28]
MOVS R0, R7
MOVS R1, R5
MOVS R3, #0x20
BL buildPkm
LDR R4, =pPkName
LDR R2, [R4]
CMP R2, #0
BEQ loc_201E8D4
MOVS R0, R7
MOVS R1, #7
BL setPartyPkmData
MOVS R2, R4
ADDS R2, #8
MOVS R0, R7
MOVS R1, #0x31
BL setPartyPkmData
loc_201E8D4 ; CODE XREF: pokemon_generation_unused+14Aj
ADD R0, SP, #0x34+var_24
MOVS R4, #0
MOV R1, R9
STRB R1, [R0]
MOVS R0, R7
MOVS R1, #0x2D
ADD R2, SP, #0x34+var_24
BL setPartyPkmData
ADD R1, SP, #0x34+var_24
MOVS R0, #0xFF
STRB R0, [R1]
MOVS R0, R7
MOVS R1, #0x23
ADD R2, SP, #0x34+var_24
BL setPartyPkmData
ADD R0, SP, #0x34+var_24
STRB R4, [R0]
MOVS R0, R7
MOVS R1, #0x24
ADD R2, SP, #0x34+var_24
BL setPartyPkmData
ADD R2, SP, #0x34+var_24
LDR R1, =base_stats
LSLS R0, R5, #3
SUBS R0, R0, R5
LSLS R0, R0, #2
ADDS R0, R0, R1
LDRB R0, [R0,#0x11]
STRB R0, [R2]
MOVS R0, R7
MOVS R1, #0x20
BL setPartyPkmData
ADD R0, SP, #0x34+var_24
MOV R1, R9
STRB R1, [R0]
MOVS R0, R7
MOVS R1, #3
ADD R2, SP, #0x34+var_24
BL setPartyPkmData
MOV R5, R8
MOV R6, R10
ADDS R6, #6
loc_201E932 ; CODE XREF: pokemon_generation_unused+1DAj
LSLS R0, R4, #1
ADDS R0, R0, R5
ADDS R1, R0, R6
LDRH R0, [R1]
CMP R0, #0
BEQ loc_201E946
MOVS R1, R0
MOVS R0, R7
BL sub_201C434
loc_201E946 ; CODE XREF: pokemon_generation_unused+1C8j
ADDS R0, R4, #1
LSLS R0, R0, #0x18
LSRS R4, R0, #0x18
CMP R4, #3
BLS loc_201E932
ADD SP, SP, #0x14
POP {R3-R5}
MOV R8, R3
MOV R9, R4
MOV R10, R5
POP {R4-R7}
POP {R0}
BX R0
; End of function pokemon_generation_unused
/* This file has been generated by the Hex-Rays decompiler.
Copyright (c) 2007-2015 Hex-Rays <[email protected]>
Detected compiler: GNU C++
*/
#include <defs.h>
#include <stdarg.h>
//-------------------------------------------------------------------------
// Function declarations
void __noreturn start_vector();
unsigned int intr_main();
void __noreturn AgbMain();
int sub_201834C();
int sub_2018390();
int sub_20183C4();
int sub_20183E8();
int sub_2018470();
int sub_20184D4();
int __fastcall sub_2018588(int a1);
int sub_20185E8();
int sub_20185F8();
int sub_201864C();
int sub_20186C4();
int sub_2018754();
int __fastcall sub_2018804(int a1);
int sub_2018868();
int sub_2018878();
int __fastcall sub_2018928(int a1);
int sub_201898C();
int __fastcall sub_201899C(void *dest, void *src, int a3);
int sub_20189F0();
int sub_2018A28();
int __fastcall sub_2018A38(void *a1, int a2, unsigned __int16 a3);
int sub_2018A58();
int __fastcall sub_2018A7C(unsigned __int8 a1, unsigned __int8 a2);
int __fastcall sub_2018A98(unsigned __int8 a1);
int __fastcall sub_2018B04(unsigned int i);
int __fastcall sub_2018B4C(unsigned __int8 a1, __int16 a2, __int16 a3, int a4, unsigned __int16 a5, __int16 a6);
int __fastcall sub_2018C18(__int16 a1, __int16 a2, _WORD *a3, unsigned __int16 a4, __int16 a5);
int __fastcall sub_2018CE8(unsigned __int8 a1, int a2, unsigned __int16 a3, unsigned __int16 a4, char a5);
int __fastcall sub_2018E90(unsigned __int8 a1, unsigned __int16 a2, unsigned __int16 a3, char a4);
int setOamDma();
int __fastcall sub_2018EFC(__int16 a1, __int16 a2, __int16 a3);
int keypressUpdate();
int __fastcall sub_2018F58(unsigned __int16 a1);
int __fastcall sub_2019064(unsigned __int16 a1);
int sub_2019158();
int __fastcall sub_2019164(int a1, __int16 a2);
int sub_2019198();
int __fastcall sub_20191B0(int a1, __int16 a2);
signed int __fastcall sub_20191D4(int a1);
int sub_2019204();
int __fastcall sub_2019210(int a1, __int16 a2);
int sub_2019244();
int __fastcall sub_201925C(int a1, __int16 a2);
signed int __fastcall sub_2019280(int a1);
int sub_20192B0();
int sub_201939C();
int __fastcall sub_20194D0(int a1);
int resetDispcntIfForcedBlank();
int sub_201951C();
int __fastcall sub_2019570(signed int a1);
int __fastcall sub_20195C8(signed int a1);
int __fastcall sub_2019624(signed int a1);
int __fastcall sub_2019674(int a1, int a2, int a3, unsigned __int8 a4, unsigned __int8 a5, unsigned __int16 a6, unsigned __int16 a7);
unsigned int __fastcall sub_20196F4(unsigned int a1);
unsigned int __fastcall sub_2019708(unsigned __int16 a1);
int __fastcall sub_2019748(int a1, int a2, int a3);
int __fastcall sub_2019774(int a1, int a2, int a3);
int __fastcall sub_20197A0(_WORD *a1, __int16 a2, int a3);
int __fastcall sub_20197C0(_DWORD *a1, int a2, int a3);
int __fastcall sub_20197D8(void *dest, void *src); // idb
int __fastcall sub_2019858(void *dest, void *src); // idb
int __fastcall sub_20198D8(__int16 a1, int a2, int a3, unsigned __int8 a4);
int __fastcall sub_2019938(int a1, int a2, signed int a3, int a4, int a5, int a6);
int __fastcall sub_201A038(int a1, int a2, signed int a3, int a4, int a5, int a6);
int __fastcall sub_201A758(int a1, int a2, int a3);
int __fastcall sub_201A7D4(int a1, __int16 a2, unsigned __int8 a3, unsigned __int8 a4, unsigned __int8 a5, unsigned __int8 a6, int a7);
int __fastcall sub_201A8A8(int a1, unsigned __int8 a2);
int __fastcall sub_201A8E4(int a1, int a2, int a3, char a4, char a5, unsigned __int8 a6);
int __fastcall sub_201A934(int result);
signed int __fastcall sub_201A93C(int a1);
char *__fastcall sub_201A950(int a1, char a2);
int __fastcall sub_201A964(int a1, __int16 a2);
int __fastcall sub_201A994(int a1);
int __fastcall sub_201A9B8(int a1);
int __fastcall sub_201A9E0(int a1, unsigned __int8 a2, unsigned __int8 a3);
int __fastcall sub_201AA08(int result, char a2, char a3, char a4);
int __fastcall sub_201AA10(int a1, void *a2, int a3);
int __fastcall sub_201AA90(int a1, void *a2);
int __fastcall sub_201AAB8(int a1, void *a2, int a3);
int __fastcall sub_201AB6C(int a1, char *a2);
int __fastcall sub_201AB8C(int a1, void *a2, __int16 a3, int a4);
int __fastcall sub_201AC40(int a1, void *a2, char *a3, int a4);
int __fastcall sub_201AC78(int a1, _BYTE *a2, _BYTE *a3, __int16 a4, unsigned __int16 a5);
int sub_201AD30();
int __fastcall sub_201AD3C(int a1, unsigned __int8 a2, unsigned __int8 a3, unsigned __int8 a4);
int __fastcall sub_201ADA8(int a1, char a2, char a3, __int16 a4, unsigned __int16 a5);
int __fastcall sub_201ADD0(int a1, char a2, char a3, __int16 a4, _BYTE *a5);
int sub_201AE54(int a1, char a2, char a3, __int16 a4, _BYTE *a5, ...);
int sub_201AEE8();
int __fastcall sub_201AF0C(unsigned __int8 a1);
int __fastcall sub_201AF44(unsigned __int8 a1);
int __fastcall sub_201AF6C(unsigned __int8 a1, int a2);
int sub_201AF90();
int sub_201AFA4();
int sub_201AFB4();
int sub_201AFE0();
int sub_201AFEC();
signed int sub_201AFF8();
int sub_201B004();
int sub_201B01C();
int sub_201B028();
int sub_201B06C();
int sub_201B0B4();
int sub_201B0EC();
int sub_201B124();
int sub_201B134();
int __fastcall sub_201B144(int a1);
signed int __fastcall sub_201B24C(unsigned __int8 a1);
signed int __fastcall sub_201B27C(char a1);
bool __fastcall sub_201B2F8(int a1);
signed int sub_201B34C();
int sub_201B39C();
int sub_201B3C0();
signed int __fastcall sub_201B3DC(signed int a1, char a2);
int __fastcall sub_201B440(unsigned __int16 a1, int a2);
int __fastcall sub_201B4DC(unsigned __int16 a1, int a2);
int __fastcall sub_201B5CC(char a1, int *a2, unsigned int a3);
signed int __fastcall sub_201B640(char a1);
signed int __fastcall sub_201B66C(unsigned __int16 a1, int a2);
signed int __fastcall sub_201B6AC(int a1, int a2);
signed int __fastcall sub_201B764(int a1);
signed int __fastcall sub_201B978(unsigned __int8 a1, int a2, unsigned __int16 a3);
signed int __fastcall sub_201B9E4(unsigned __int8 a1);
unsigned int __fastcall sub_201B9FC(int *a1, int a2);
unsigned int rand();
int __fastcall srand(int result);
int __fastcall strlen_xFF(_BYTE *a1);
signed int __fastcall sub_201BA78(int a1, unsigned __int8 a2);
int __fastcall initPkm(int a1);
int __fastcall initPartyData(int a1);
int __fastcall buildPkm(int a1, unsigned __int16 a2, unsigned __int8 a3, unsigned __int8 a4, char a5, unsigned int a6, char a7, unsigned int a8);
int __fastcall makePkmStats(int a1, unsigned __int16 a2, unsigned __int8 a3, unsigned __int8 a4, char a5, unsigned int a6, char a7, unsigned int a8);
int __fastcall pkm_make_checksum(unsigned int *a1);
int __fastcall sub_201C068(int a1);
int __fastcall sub_201C35C(int a1);
unsigned __int8 __fastcall getPkmLv(void *pkm);
int __fastcall sub_201C434(unsigned int *a1, unsigned __int16 a2);
int __fastcall sub_201C448(unsigned int *a1, unsigned __int16 a2);
int __fastcall sub_201C4B8(unsigned int *a1);
void __fastcall pkmAdjustMoves(void *pkm, unsigned __int16 move);
int __fastcall pkmEncrypt(int a1);
int __fastcall pkmDecrypt(int a1);
int __fastcall pkm_block_shuffle(int a1, unsigned int a2, unsigned __int8 a3);
unsigned int __fastcall getPartyPkmData(int a1, void *(*a2)[10], _BYTE *a3);
unsigned int __fastcall getPkmBoxData(unsigned int *a1, signed int a2, _BYTE *a3);
int __fastcall setPartyPkmData(int a1, void *(*a2)[11], int a3);
int __fastcall setBoxPkmData(unsigned int *a1, signed int a2, int a3);
int __fastcall sub_201D904(void *a1, void *a2, unsigned int a3);
int __fastcall sub_201D910(int a1);
signed int __fastcall sub_201D98C(unsigned int *a1);
int __fastcall sub_201D9F4(_BYTE *a1);
int __fastcall sub_201DA28(unsigned __int16 a1, char a2, unsigned __int8 a3);
unsigned int __fastcall getPkmNature(int a1);
unsigned int __fastcall getNature(unsigned int a1);
int __fastcall sub_201DA98(unsigned __int8 a1, unsigned __int16 a2, int a3);
int __fastcall sub_201DAF8(int a1, _WORD *a2);
int __fastcall sub_201DC48(unsigned int *a1);
int __fastcall sub_201DC54(unsigned int *a1);
unsigned int __fastcall sub_201DCB8(unsigned __int16 a1);
unsigned int __fastcall sub_201DD04(unsigned __int16 a1);
int __fastcall sub_201DD50(unsigned __int16 a1);
int sub_201DD74();
int sub_201DD8C();
int __fastcall sub_201DDA0(int a1);
bool __fastcall sub_201DDC8(unsigned __int8 a1);
int __fastcall sub_201DE00(unsigned __int8 a1, unsigned __int8 a2, unsigned __int8 a3);
int __fastcall sub_201DE8C(_BYTE *a1);
int sub_201DEC8();
int sub_201DF28();
int __fastcall sub_201DF34(int a1);
int __fastcall sub_201DF64(int a1);
int __fastcall sub_201DF7C(int a1);
int __fastcall sub_201DF94(int a1);
int __fastcall sub_201DFA8(int a1);
int sub_201E0A8();
int __fastcall sub_201E0BC(_BYTE *a1, int a2, int a3);
int sub_201E140();
int __fastcall sub_201E168(char a1, char a2);
int __fastcall sub_201E17C(int a1, int a2, int a3);
int sub_201E1E4();
int __fastcall sub_201E21C(__int16 a1, char a2, char a3, char a4);
int sub_201E24C();
int __fastcall sub_201E278(int a1);
int __fastcall sub_201E364(int a1);
int __fastcall checkGameCodeSetCallback(int a1);
unsigned int __fastcall sub_201E43C(unsigned int *a1, int a2, _BYTE *a3);
signed int __fastcall sub_201E464(unsigned int *a1, int a2, _BYTE *a3);
signed int sub_201E4A8();
int __fastcall sub_201E4EC(int a1, int a2, _BYTE *a3);
bool __fastcall sub_201E59C(int a1, int a2, _BYTE *a3);
int __fastcall generate_poke(int a1);
int sub_201E6DC();
signed int __fastcall sub_201E6F0(int a1, __int16 a2);
int __fastcall pokemon_generation_unused(int a1, int a2);
int __fastcall sub_201E974(int a1, int a2);
int __fastcall sub_201EB60(int a1, int a2, _BYTE *a3);
int __fastcall sub_201EBC0(int a1);
int __fastcall sub_201EC40(int a1);
int __fastcall ResetRom(int a1, void *a2);
int __fastcall sub_201EC78(int a1);
int __fastcall sub_201EDDC(int a1);
int __fastcall sub_201EDE8(int a1);
int sub_201EE44();
signed int sub_201EEBC();
int __fastcall sub_201F048(int a1);
void __fastcall CpuSet(void *src, void *dest, int len_mode);
void sub_201F074();
void sub_201F078();
void sub_201F07C();
void sub_201F080();
void sub_201F084();
void sub_201F088();
void sub_201F08C();
void sub_201F090();
void wait_for_vblank();
void __fastcall ResetGba(void *a1, void *a2);
int __fastcall sub_201F0B8(int result);
int sub_201F0DC();
int sub_201F178();
signed int __fastcall sub_201F1A0(unsigned __int8 a1, _DWORD *a2);
int __fastcall sub_201F1DC(unsigned __int8 a1);
int sub_201F284();
int __fastcall sub_201F2C8(int a1);
int __fastcall sub_201F2CC(_WORD *a1);
int __fastcall sub_201F30C(_BYTE *a1, _BYTE *a2, int a3);
int __fastcall sub_201F330(int a1, int a2);
_BYTE *__fastcall sub_201F3CC(_BYTE *a1, _BYTE *a2, int a3);
int __fastcall sub_201F3FC(int a1, int a2);
int __fastcall sub_201F494(int a1, int a2);
int __fastcall sub_201F52C(unsigned __int16 a1);
int __fastcall sub_201F570(unsigned __int16 a1);
signed int sub_201F5B8();
int __fastcall sub_201F64C(unsigned __int8 a1, int a2, unsigned __int8 a3);
int sub_201F6EC();
int __fastcall sub_201F760(unsigned __int16 a1);
int __fastcall sub_201F82C(_BYTE *a1, _BYTE *a2);
int __fastcall sub_201F864(unsigned __int16 a1, _BYTE *a2);
int sub_201F908();
int sub_201F920();
int sub_201F938();
int sub_201FA10();
signed int __fastcall sub_201FA94(int a1);
signed int __fastcall sub_201FB60(int a1);
signed int __fastcall sub_201FC08(int a1);
signed int __fastcall sub_201FCB8(int a1);
signed int __fastcall sub_201FD54(int a1);
signed int __fastcall sub_201FE08(int a1);
signed int __fastcall sub_201FEA4(int a1);
int __fastcall sub_201FFD8(int result);
int __fastcall sub_202007C(int result);
int sub_202011C();
int sub_20201A8();
int sub_20201BC();
int __fastcall call_via_r0(_DWORD); // weak
int __fastcall call_via_r1(_DWORD, _DWORD); // weak
int __fastcall call_via_r2(_DWORD); // weak
int __fastcall call_via_r3(_DWORD); // weak
int __fastcall call_via_r5(_DWORD, _DWORD); // weak
int __fastcall call_via_r8(_DWORD); // weak
int __fastcall memcmp(void *mem1, void *mem2, int len);
void __fastcall memcpy(void *dst, void *src, unsigned int size);
_DWORD *__fastcall strcat(_DWORD *a1, _DWORD *a2);
int __fastcall vsprintf(_BYTE *a1, _BYTE *a2, int a3);
signed int __fastcall _sprint(int a1, int a2);
int __fastcall _sbprintf(int a1, _BYTE *a2, int a3);
int __fastcall vfprintf(int a1, _BYTE *a2, int a3);
int __fastcall vfprintf_r(int a1, int a2, _BYTE *a3, int a4);
char *__fastcall cvt(int a1, int a2, int a3, signed int a4, char a5, char *a6, _DWORD *a7, int a8, _DWORD *a9);
int __fastcall exponent(_BYTE *a1, signed int a2, char a3);
signed int __fastcall _swsetup(int a1);
unsigned int __fastcall quorem(int a1, int a2);
char *__fastcall dtoa_r(int a1, int a2, int a3, int a4, signed int a5, _DWORD *a6, _DWORD *a7, int *a8);
int __fastcall fflush(int a1);
int __fastcall std(int result, __int16 a2, __int16 a3, int a4);
int __fastcall _sfmoreglue(_DWORD *a1, int a2);
int __fastcall _sfp(int a1);
int __fastcall cleanup_r(int a1);
int cleanup();
int __fastcall _sinit(int a1);
int __fastcall free_r(int result, int a2);
signed int __fastcall malloc_trim_r(_DWORD *a1, int a2);
signed int __fastcall _sfvwrite(int a1, int a2);
int __fastcall fwalk(int a1);
void *__fastcall setlocale_r(int a1, int a2, _DWORD *a3);
void **localeconv_r();
void *__fastcall setlocale(int a1, _DWORD *a2);
void **localeconv();
int __fastcall _smakebuf(int a1);
void **__fastcall malloc_extend_top(_DWORD *a1, int a2);
void **__fastcall malloc_r(_DWORD *a1, int a2);
signed int __fastcall mbtowc_r(int a1, int *a2, _BYTE *a3, int a4);
_BYTE *__fastcall memchr(_BYTE *a1, unsigned __int8 a2, unsigned int a3);
unsigned int __fastcall memmove(unsigned int a1, unsigned int a2, unsigned int a3);
void __fastcall memset(char *dst, char pattern, int size);
int __fastcall _malloc_lock(_DWORD); // weak
int __fastcall _malloc_unlock(_DWORD); // weak
int __fastcall Balloc(int a1, int a2);
int __fastcall Bfree(int result, int a2);
int __fastcall multadd(int a1, int a2, int a3, int a4);
int __fastcall s2b(int a1, int a2, signed int a3, signed int a4, int a5);
signed int __fastcall hi0bits(int a1);
signed int __fastcall lo0bits(unsigned int *a1);
int __fastcall i2b(int a1, int a2);
int __fastcall multiply(int a1, int a2, int a3);
int __fastcall pow5mult(int a1, int a2, signed int a3);
int __fastcall lshift(int a1, int a2, signed int a3);
int __fastcall _mcmp(int a1, int a2);
int __fastcall _mdiff(int a1, int a2, int a3);
signed int __fastcall ulp(int a1);
__int64 __fastcall b2d(int a1, _DWORD *a2);
int __fastcall d2b(int a1, int a2, int a3, _DWORD *a4, _DWORD *a5);
int __fastcall ratio(int a1, int a2);
int __fastcall mprec_log10(signed int a1);
unsigned int __fastcall isinf(int a1, unsigned int a2);
unsigned int __fastcall isnan(int a1, unsigned int a2);
int __fastcall sbrk_r(_DWORD *a1, int a2);
int __fastcall _sread(int a1, int a2, int a3);
int __fastcall _swrite(int a1, int a2, int a3);
int __fastcall _sseek(int a1, int a2, int a3);
int __fastcall _sclose(int a1);
int __fastcall strcmp(_DWORD *a1, _DWORD *a2);
int __fastcall strlen(_DWORD *a1);
signed int __fastcall findslot(int a1);
int __fastcall remap_handle(int a1);
int initialise_monitor_handles();
int get_errno();
int __fastcall error(int a1);
int __fastcall wrap(int result);
int __fastcall swiread(int a1, int a2, int a3);
int __fastcall read(int a1, int a2, int a3);
signed int __fastcall swilseek(int a1, int a2, int a3);
int __fastcall lseek(int a1, int a2, int a3);
int __fastcall swiwrite(int a1, int a2, int a3);
int __fastcall write(int a1, int a2, int a3);
int __fastcall swiopen(_DWORD *a1, __int16 a2);
int __fastcall open(_DWORD *a1, __int16 a2);
int __fastcall swiclose(int a1);
int __fastcall close(int fd);
void __fastcall exit(int status);
int kill();
signed int getpid();
int __fastcall sbrk(int a1);
int __fastcall fstat(int fd, struct stat *buf);
int __fastcall unlink(const char *name);
int __fastcall gettimeofday(_DWORD *a1, int a2);
int times();
int __fastcall write_r(_DWORD *a1, int a2, int a3, int a4);
int __fastcall calloc_r(_DWORD *a1, int a2, int a3);
int __fastcall close_r(_DWORD *a1, int a2);
int _errno();
int __fastcall fstat_r(_DWORD *a1, int a2, struct stat *a3);
int __noreturn abort();
signed int isatty();
int __fastcall lseek_r(_DWORD *a1, int a2, int a3, int a4);
int __fastcall read_r(_DWORD *a1, int a2, int a3, int a4);
int __fastcall _pack_f(int a1);
int __fastcall _unpack_f(int a1, int a2);
int __fastcall fpadd_parts(int a1, int a2, int a3);
int __fastcall _addsf3(int a1, int a2, int a3, int a4);
int __fastcall _subsf3(int a1, int a2, int a3, int a4);
int __fastcall _mulsf3(int a1, int a2, int a3, int a4);
int __fastcall _divsf3(int a1, int a2, int a3, int a4);
int __fastcall _fpcmp_parts_f(int a1, int a2);
int __fastcall _cmpsf2(int a1, int a2, int a3, int a4);
int __fastcall _eqsf2(int a1, int a2, int a3, int a4);
int __fastcall _nesf2(int a1, int a2, int a3, int a4);
int __fastcall _gtsf2(int a1, int a2, int a3, int a4);
int __fastcall _gesf2(int a1, int a2, int a3, int a4);
int __fastcall _ltsf2(int a1, int a2, int a3, int a4);
int __fastcall _lesf2(int a1, int a2, int a3, int a4);
int __fastcall _floatsisf(__int64 a1);
int __fastcall _fixsfsi(int a1, int a2);
int __fastcall _negsf2(int a1, int a2);
int __fastcall _make_fp(int a1, int a2, int a3, int a4, int a5);
unsigned int __fastcall _extendsfdf2(int a1, int a2);
unsigned int __fastcall _pack_d(int a1);
unsigned int __fastcall _unpack_d(unsigned int *a1, int a2);
int __fastcall fpadd_parts_1(int a1, int a2, int a3);
unsigned int __fastcall _adddf3(int a1, int a2);
unsigned int __fastcall _subdf3(int a1, int a2);
unsigned int __fastcall _muldf3(int a1, int a2);
unsigned int __fastcall _divdf3(int a1, int a2);
int __fastcall _fpcmp_parts_d(int a1, int a2);
int __fastcall _cmpdf2(int a1, int a2);
int __fastcall _eqdf2(int a1, int a2);
int __fastcall _nedf2(int a1, int a2);
int __fastcall _gtdf2(int a1, int a2);
int __fastcall _gedf2(int a1, int a2);
int __fastcall _ltdf2(int a1, int a2);
int __fastcall _ledf2(int a1, int a2);
unsigned int __fastcall _floatsidf(unsigned int a1);
unsigned int __fastcall _fixdfsi(int a1);
unsigned int __fastcall _negdf2(int a1);
unsigned int __fastcall _make_dp(int a1, int a2, int a3, int a4);
int __fastcall _truncdfsf2(int a1);
int __fastcall _lshrdi3(int result, unsigned int a2, int a3);
int __fastcall _negdi2(int a1);
//-------------------------------------------------------------------------
// Data declarations
int dword_201E7B4 = 50354848; // weak
int dword_201E7B8 = 4294901760; // weak
int dword_201E7BC = 65535; // weak
void *off_201E830 = &unk_202EA54; // weak
void *off_201E960 = &unk_202EA54; // weak
int dword_201E964 = 4294901760; // weak
int dword_201E968 = 65535; // weak
void **off_201E96C[2] = { &pPkName, &base_stats }; // weak
void **off_201E970 = &base_stats; // weak
//----- (0201E774) --------------------------------------------------------
int __fastcall pokemon_generation_unused(int a1, int a2)
{
unsigned int *v2; // r7@1
unsigned int v3; // r6@1
unsigned int v4; // r4@1
unsigned int i; // r4@1
int v6; // r5@4
int v7; // r2@4
unsigned int v8; // r5@6
int v9; // r2@6
char *v10; // r1@7
unsigned int v11; // r0@7
_BYTE *v12; // r10@12
int v13; // r8@12
unsigned int v14; // r4@13
void **v15; // r4@14
unsigned int v16; // r4@16
unsigned __int16 *v17; // r1@17
char v19; // [sp+10h] [bp-24h]@16
int v20; // [sp+30h] [bp-4h]@20
v2 = (unsigned int *)a2;
v3 = *(_BYTE *)(dword_201E7B4 + 10) | (*(_BYTE *)(dword_201E7B4 + 11) << 8) | (*(_BYTE *)(dword_201E7B4 + 12) << 16) | (*(_BYTE *)(dword_201E7B4 + 13) << 24);
v4 = rand();
for ( i = (v4 << 16) | rand();
(((i & dword_201E7B8) >> 16) ^ (v3 >> 16) ^ dword_201E7BC & v3 ^ i & dword_201E7B8) <= 7;
++i )
{
;
}
initPartyData((int)v2);
v6 = 0;
v7 = 0;
if ( *((_WORD *)off_201E830 + 1) )
{
do
{
v6 = (v6 + *((_WORD *)off_201E830 + 10 * v7 + 1)) & 0xFFFF;
v7 = (v7 + 1) & 0xFF;
}
while ( *((_WORD *)off_201E830 + 10 * v7 + 1) );
}
v8 = (unsigned __int16)sub_2019708(v6);
v9 = 0;
if ( !*((_WORD *)off_201E830 + 1) )
goto LABEL_23;
while ( 1 )
{
v10 = (char *)off_201E830 + 20 * v9;
v11 = *((_WORD *)v10 + 1);
if ( v8 < v11 )
break;
v8 = (v8 - v11) & 0xFFFF;
v9 = (v9 + 1) & 0xFF;
if ( !*((_WORD *)off_201E830 + 10 * v9 + 1) )
goto LABEL_10;
}
v8 = *((_WORD *)v10 + 2);
LABEL_10:
if ( !*((_WORD *)off_201E830 + 10 * v9 + 1) )
LABEL_23:
v9 = 0;
v12 = off_201E960;
v13 = 20 * v9;
if ( *((_DWORD *)off_201E960 + 5 * v9 + 4) )
{
v14 = (i & dword_201E964 | ((v3 & dword_201E964) >> 16) ^ dword_201E968 & v3 ^ ((i & dword_201E964) >> 16)) & 0xFFFFFFF8;
i = v14 | rand() & 7;
}
buildPkm((int)v2, v8, v12[v13], 0x20u, 1, i, 1, v3);
v15 = off_201E96C[0];
if ( *off_201E96C[0] )
{
setPartyPkmData((int)v2, (void *(*)[11])7, (int)*off_201E96C[0]);
setPartyPkmData((int)v2, (void *(*)[11])0x31, (int)(v15 + 2));
}
v16 = 0;
v19 = 1;
setPartyPkmData((int)v2, (void *(*)[11])0x2D, (int)&v19);
v19 = -1;
setPartyPkmData((int)v2, (void *(*)[11])0x23, (int)&v19);
v19 = 0;
setPartyPkmData((int)v2, (void *(*)[11])0x24, (int)&v19);
v19 = BYTE1(off_201E970[7 * v8 + 4]);
setPartyPkmData((int)v2, (void *(*)[11])0x20, (int)&v19);
v19 = 1;
setPartyPkmData((int)v2, (void *(*)[11])3, (int)&v19);
do
{
v17 = (unsigned __int16 *)(&v12[2 * v16 + 6] + v13);
if ( *v17 )
sub_201C434(v2, *v17);
v16 = (v16 + 1) & 0xFF;
}
while ( v16 <= 3 );
return v20;
}
// 201E7B4: using guessed type int dword_201E7B4;
// 201E7B8: using guessed type int dword_201E7B8;
// 201E7BC: using guessed type int dword_201E7BC;
// 201E830: using guessed type void *off_201E830;
// 201E960: using guessed type void *off_201E960;
// 201E964: using guessed type int dword_201E964;
// 201E968: using guessed type int dword_201E968;
// 201E96C: using guessed type void **off_201E96C[2];
// 201E970: using guessed type void **off_201E970;
// ALL OK, 1 function(s) have been successfully decompiled
; =============== S U B R O U T I N E =======================================
sub_2019708 ; CODE XREF: pokemon_generation_unused+94p
PUSH {R4-R6,LR}
LSLS R0, R0, #0x10
LSRS R0, R0, #0x10
LDR R6, =0x3001544
LDRH R4, [R6]
LSLS R3, R4, #2
LDR R1, =0xFFFF
ANDS R3, R1
ADDS R3, R3, R4
LDR R5, =0x300143C
LDRH R1, [R5]
LSLS R1, R1, #1
LSRS R2, R3, #0x10
ADDS R1, R1, R2
LSRS R2, R1, #0x10
ADDS R4, R4, R2
ADDS R1, R1, R4
STRH R3, [R6]
STRH R1, [R5]
LDRH R1, [R5]
MULS R0, R1
LSRS R0, R0, #0x10
POP {R4-R6}
POP {R1}
BX R1
; End of function sub_2019708
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment