Start decomp

This commit is contained in:
PikalaxALT 2017-09-18 08:52:57 -04:00 committed by scnorton
parent 74bda5b680
commit 8604291b0f
8 changed files with 163 additions and 250 deletions

View File

@ -5,242 +5,6 @@
.text .text
thumb_func_start sub_81BF384
sub_81BF384: @ 81BF384
push {r4,lr}
ldr r0, =0x0000ffff
bl DisableInterrupts
movs r0, 0x1
bl EnableInterrupts
bl m4aSoundVSyncOff
movs r0, 0
bl SetVBlankCallback
bl ResetSpriteData
bl ResetTasks
bl remove_some_task
movs r0, 0
movs r1, 0
bl SetGpuReg
ldr r4, =gUnknown_030012B8
movs r0, 0x50
bl AllocZeroed
str r0, [r4]
movs r1, 0
strb r1, [r0]
ldr r1, [r4]
movs r0, 0x6
strb r0, [r1, 0x1]
ldr r0, =sub_81BF3DC
bl SetMainCallback2
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81BF384
thumb_func_start sub_81BF3DC
sub_81BF3DC: @ 81BF3DC
push {r4,r5,lr}
sub sp, 0x4
ldr r1, =gUnknown_030012B8
ldr r0, [r1]
ldrb r0, [r0]
adds r5, r1, 0
cmp r0, 0x7
bls _081BF3EE
b _081BF592
_081BF3EE:
lsls r0, 2
ldr r1, =_081BF400
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_081BF400:
.4byte _081BF420
.4byte _081BF430
.4byte _081BF45C
.4byte _081BF488
.4byte _081BF4BC
.4byte _081BF514
.4byte _081BF552
.4byte _081BF574
_081BF420:
bl sub_81BF5A4
ldr r0, =gUnknown_030012B8
ldr r1, [r0]
movs r0, 0x1
b _081BF590
.pool
_081BF430:
movs r0, 0x5
bl sub_81BF7A4
cmp r0, 0x5
beq _081BF43C
b _081BF592
_081BF43C:
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
movs r0, 0x1
ands r0, r1
cmp r0, 0
bne _081BF44A
b _081BF592
_081BF44A:
ldr r0, =gUnknown_030012B8
ldr r1, [r0]
movs r0, 0x2
b _081BF590
.pool
_081BF45C:
movs r0, 0
bl sub_81BF7A4
cmp r0, 0
beq _081BF468
b _081BF592
_081BF468:
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
movs r0, 0x1
ands r0, r1
cmp r0, 0
bne _081BF476
b _081BF592
_081BF476:
ldr r0, =gUnknown_030012B8
ldr r1, [r0]
movs r0, 0x3
b _081BF590
.pool
_081BF488:
movs r0, 0x1
bl sub_81BF7A4
cmp r0, 0x1
beq _081BF494
b _081BF592
_081BF494:
ldr r4, =gUnknown_030012B8
ldr r0, [r4]
ldr r1, =gUnknown_089A6550
str r1, [r0, 0x2C]
adds r0, 0x4F
movs r5, 0
strb r5, [r0]
ldr r0, [r4]
adds r0, 0x4
bl MultiBootInit
ldr r1, [r4]
strh r5, [r1, 0x2]
movs r0, 0x4
b _081BF590
.pool
_081BF4BC:
adds r4, r5, 0
ldr r0, [r4]
adds r0, 0x4
bl MultiBootMain
ldr r4, [r4]
ldrb r0, [r4, 0x1C]
cmp r0, 0
bne _081BF4D8
ldr r0, [r4, 0x20]
ldr r1, =0x00020200
ands r0, r1
cmp r0, r1
beq _081BF4E4
_081BF4D8:
movs r0, 0
strh r0, [r4, 0x2]
b _081BF592
.pool
_081BF4E4:
ldrh r0, [r4, 0x2]
adds r0, 0x1
strh r0, [r4, 0x2]
lsls r0, 16
lsrs r0, 16
cmp r0, 0xB4
bls _081BF592
adds r0, r4, 0x4
ldr r1, =gMultiBootProgram_BerryGlitchFix_Start
ldr r2, =gMultiBootProgram_BerryGlitchFix_End
subs r2, r1
movs r3, 0x1
str r3, [sp]
movs r3, 0x4
bl MultiBootStartMaster
ldr r1, [r5]
movs r0, 0x5
b _081BF590
.pool
_081BF514:
movs r0, 0x2
bl sub_81BF7A4
adds r4, r0, 0
cmp r4, 0x2
bne _081BF592
ldr r5, =gUnknown_030012B8
ldr r0, [r5]
adds r0, 0x4
bl MultiBootMain
ldr r0, [r5]
adds r0, 0x4
bl MultiBootCheckComplete
cmp r0, 0
beq _081BF540
ldr r1, [r5]
movs r0, 0x6
b _081BF590
.pool
_081BF540:
ldr r1, [r5]
adds r0, r1, 0
adds r0, 0x22
ldrb r0, [r0]
ands r4, r0
cmp r4, 0
bne _081BF592
movs r0, 0x7
b _081BF590
_081BF552:
movs r0, 0x3
bl sub_81BF7A4
cmp r0, 0x3
bne _081BF592
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
movs r0, 0x1
ands r0, r1
cmp r0, 0
beq _081BF592
bl DoSoftReset
b _081BF592
.pool
_081BF574:
movs r0, 0x4
bl sub_81BF7A4
cmp r0, 0x4
bne _081BF592
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
movs r0, 0x1
ands r0, r1
cmp r0, 0
beq _081BF592
ldr r0, =gUnknown_030012B8
ldr r1, [r0]
movs r0, 0x1
_081BF590:
strb r0, [r1]
_081BF592:
add sp, 0x4
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_81BF3DC
thumb_func_start sub_81BF5A4 thumb_func_start sub_81BF5A4
sub_81BF5A4: @ 81BF5A4 sub_81BF5A4: @ 81BF5A4
push {r4-r6,lr} push {r4-r6,lr}

View File

@ -3,6 +3,7 @@
gUnknown_089A6550:: @ 89A6550 gUnknown_089A6550:: @ 89A6550
.incbin "baserom.gba", 0x9a6550, 0xc0 .incbin "baserom.gba", 0x9a6550, 0xc0
gMultiBootProgram_BerryGlitchFix_Script:: @ 89A6610
gMultiBootProgram_BerryGlitchFix_Start:: @ 89A6610 gMultiBootProgram_BerryGlitchFix_Start:: @ 89A6610
.incbin "baserom.gba", 0x9a6610, 0x3b34 .incbin "baserom.gba", 0x9a6610, 0x3b34
gMultiBootProgram_BerryGlitchFix_End:: gMultiBootProgram_BerryGlitchFix_End::

View File

@ -8,19 +8,19 @@
struct MultiBootParam struct MultiBootParam
{ {
u32 system_work[5]; u32 system_work[5]; // 00
u8 handshake_data; u8 handshake_data; // 14
u8 padding; u8 padding; // 15
u16 handshake_timeout; u16 handshake_timeout; // 16
u8 probe_count; u8 probe_count; // 18
u8 client_data[MULTIBOOT_NCHILD]; u8 client_data[MULTIBOOT_NCHILD]; // 19
u8 palette_data; u8 palette_data; // 1c
u8 response_bit; u8 response_bit; // 1d
u8 client_bit; u8 client_bit; // 1e
u8 reserved1; u8 reserved1; // 1f
u8 *boot_srcp; u8 *boot_srcp; // 20
u8 *boot_endp; u8 *boot_endp; // 24
u8 *masterp; const u8 *masterp;
u8 *reserved2[MULTIBOOT_NCHILD]; u8 *reserved2[MULTIBOOT_NCHILD];
u32 system_work2[4]; u32 system_work2[4];
u8 sendflag; u8 sendflag;

13
include/gpu_regs.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef GUARD_gpu_regs_H
#define GUARD_gpu_regs_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
void DisableInterrupts(u16);
void EnableInterrupts(u16);
void SetGpuReg(u8, u16);
#endif //GUARD_gpu_regs_H

View File

@ -15,7 +15,7 @@
void MultiBootInit(struct MultiBootParam *mp); void MultiBootInit(struct MultiBootParam *mp);
int MultiBootMain(struct MultiBootParam *mp); int MultiBootMain(struct MultiBootParam *mp);
void MultiBootStartProbe(struct MultiBootParam *mp); void MultiBootStartProbe(struct MultiBootParam *mp);
void MultiBootStartMaster(struct MultiBootParam *mp, u8 *srcp, int length, u8 palette_color, s8 palette_speed); void MultiBootStartMaster(struct MultiBootParam *mp, const u8 *srcp, int length, u8 palette_color, s8 palette_speed);
int MultiBootCheckComplete(struct MultiBootParam *mp); int MultiBootCheckComplete(struct MultiBootParam *mp);
#endif // GUARD_MULTIBOOT_H #endif // GUARD_MULTIBOOT_H

11
include/unknown_task.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef GUARD_unknown_task_H
#define GUARD_unknown_task_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
void remove_some_task(void);
#endif //GUARD_unknown_task_H

View File

@ -259,6 +259,7 @@ SECTIONS {
asm/battle_controller_player_partner.o(.text); asm/battle_controller_player_partner.o(.text);
asm/fldeff_groundshake.o(.text); asm/fldeff_groundshake.o(.text);
asm/fossil_specials.o(.text); asm/fossil_specials.o(.text);
src/berry_fix_program.o(.text);
asm/berry_fix_program.o(.text); asm/berry_fix_program.o(.text);
asm/pokemon_summary_screen.o(.text); asm/pokemon_summary_screen.o(.text);
asm/pokenav.o(.text); asm/pokenav.o(.text);

123
src/berry_fix_program.c Normal file
View File

@ -0,0 +1,123 @@
// Includes
#include "global.h"
#include "multiboot.h"
#include "gpu_regs.h"
#include "main.h"
#include "sprite.h"
#include "task.h"
#include "unknown_task.h"
#include "malloc.h"
#include "m4a.h"
// Static type declarations
typedef struct {
u8 state;
u8 unk1;
u16 unk2;
struct MultiBootParam mb;
} berryfix_t;
// Static RAM declarations
extern berryfix_t *gUnknown_030012B8;
// Static ROM declarations
static void sub_81BF3DC(void);
void sub_81BF5A4(void);
u32 sub_81BF7A4(u8);
// .rodata
extern const u8 gUnknown_089A6550[0xC0];
extern const u8 gMultiBootProgram_BerryGlitchFix_Script[0x3b34];
extern const u8 gMultiBootProgram_BerryGlitchFix_Start[];
extern const u8 gMultiBootProgram_BerryGlitchFix_End[];
// .text
void sub_81BF384(void)
{
DisableInterrupts(0xFFFF);
EnableInterrupts(0x0001);
m4aSoundVSyncOff();
SetVBlankCallback(NULL);
ResetSpriteData();
ResetTasks();
remove_some_task();
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
gUnknown_030012B8 = AllocZeroed(0x50);
gUnknown_030012B8->state = 0;
gUnknown_030012B8->unk1 = 6;
SetMainCallback2(sub_81BF3DC);
}
static void sub_81BF3DC(void)
{
switch (gUnknown_030012B8->state)
{
case 0:
sub_81BF5A4();
gUnknown_030012B8->state = 1;
break;
case 1:
if (sub_81BF7A4(5) == 5 && (gMain.newKeys & A_BUTTON))
{
gUnknown_030012B8->state = 2;
}
break;
case 2:
if (sub_81BF7A4(0) == 0 && (gMain.newKeys & A_BUTTON))
{
gUnknown_030012B8->state = 3;
}
break;
case 3:
if (sub_81BF7A4(1) == 1)
{
gUnknown_030012B8->mb.masterp = gUnknown_089A6550;
gUnknown_030012B8->mb.server_type = 0;
MultiBootInit(&gUnknown_030012B8->mb);
gUnknown_030012B8->unk2 = 0;
gUnknown_030012B8->state = 4;
}
break;
case 4:
MultiBootMain(&gUnknown_030012B8->mb);
if (gUnknown_030012B8->mb.probe_count != 0 || (!(gUnknown_030012B8->mb.response_bit & 2) || !(gUnknown_030012B8->mb.client_bit & 2)))
{
gUnknown_030012B8->unk2 = 0;
}
else if (++ gUnknown_030012B8->unk2 > 180)
{
MultiBootStartMaster(&gUnknown_030012B8->mb, gMultiBootProgram_BerryGlitchFix_Start, (u32)(gMultiBootProgram_BerryGlitchFix_End - gMultiBootProgram_BerryGlitchFix_Start), 4, 1);
gUnknown_030012B8->state = 5;
}
break;
case 5:
if (sub_81BF7A4(2) == 2) {
MultiBootMain(&gUnknown_030012B8->mb);
if (MultiBootCheckComplete(&gUnknown_030012B8->mb)) {
gUnknown_030012B8->state = 6;
}
else if (!(gUnknown_030012B8->mb.client_bit & 2)) {
gUnknown_030012B8->state = 7;
}
}
break;
case 6:
if (sub_81BF7A4(3) == 3 && gMain.newKeys & A_BUTTON)
{
DoSoftReset();
}
break;
case 7:
if (sub_81BF7A4(4) == 4 && gMain.newKeys & A_BUTTON)
{
gUnknown_030012B8->state = 1;
}
break;
}
}