mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Decompiled 2 functions, unable to decompile 1.
sub_81C795C could not be decompiled due to register naming issues. However, its structure was correctly matched, so I have left the C code and a comment explaining the issue.
This commit is contained in:
parent
34b16e9e78
commit
a8d920cc45
149
asm/pokenav.s
149
asm/pokenav.s
@ -5,115 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start atk47_cmd47
|
||||
atk47_cmd47: @ 81C78D4
|
||||
push {lr}
|
||||
cmp r0, 0x1
|
||||
beq _081C78EA
|
||||
cmp r0, 0x1
|
||||
bgt _081C78E4
|
||||
cmp r0, 0
|
||||
beq _081C78EA
|
||||
b _081C7914
|
||||
_081C78E4:
|
||||
cmp r0, 0x2
|
||||
beq _081C78EE
|
||||
b _081C7914
|
||||
_081C78EA:
|
||||
movs r0, 0
|
||||
b _081C7916
|
||||
_081C78EE:
|
||||
movs r1, 0xC0
|
||||
lsls r1, 1
|
||||
movs r0, 0
|
||||
movs r2, 0x1
|
||||
bl ChangeBgY
|
||||
ldr r1, =0x00001fff
|
||||
cmp r0, r1
|
||||
bhi _081C7908
|
||||
movs r0, 0x2
|
||||
b _081C7916
|
||||
.pool
|
||||
_081C7908:
|
||||
movs r1, 0x80
|
||||
lsls r1, 6
|
||||
movs r0, 0
|
||||
movs r2, 0
|
||||
bl ChangeBgY
|
||||
_081C7914:
|
||||
movs r0, 0x4
|
||||
_081C7916:
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end atk47_cmd47
|
||||
|
||||
thumb_func_start sub_81C791C
|
||||
sub_81C791C: @ 81C791C
|
||||
push {lr}
|
||||
movs r1, 0xC0
|
||||
lsls r1, 1
|
||||
movs r0, 0
|
||||
movs r2, 0x2
|
||||
bl ChangeBgY
|
||||
cmp r0, 0
|
||||
ble _081C7932
|
||||
movs r0, 0x2
|
||||
b _081C793E
|
||||
_081C7932:
|
||||
movs r0, 0
|
||||
movs r1, 0
|
||||
movs r2, 0
|
||||
bl ChangeBgY
|
||||
movs r0, 0x4
|
||||
_081C793E:
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_81C791C
|
||||
|
||||
thumb_func_start sub_81C7944
|
||||
sub_81C7944: @ 81C7944
|
||||
push {lr}
|
||||
lsls r1, 1
|
||||
ldr r3, =gPlttBufferUnfaded
|
||||
adds r1, r3
|
||||
lsls r2, 10
|
||||
lsrs r2, 11
|
||||
bl CpuSet
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_81C7944
|
||||
|
||||
thumb_func_start sub_81C795C
|
||||
sub_81C795C: @ 81C795C
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
b _081C7974
|
||||
_081C7962:
|
||||
lsls r0, r1, 4
|
||||
movs r2, 0x80
|
||||
lsls r2, 1
|
||||
adds r1, r0, r2
|
||||
ldr r0, [r4]
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
adds r4, 0x8
|
||||
_081C7974:
|
||||
ldr r0, [r4]
|
||||
cmp r0, 0
|
||||
beq _081C7988
|
||||
ldrh r0, [r4, 0x4]
|
||||
bl AllocSpritePalette
|
||||
lsls r0, 24
|
||||
lsrs r1, r0, 24
|
||||
cmp r1, 0xFF
|
||||
bne _081C7962
|
||||
_081C7988:
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_81C795C
|
||||
|
||||
thumb_func_start sub_81C7990
|
||||
sub_81C7990: @ 81C7990
|
||||
push {lr}
|
||||
@ -4401,7 +4292,7 @@ _081C9A5C:
|
||||
ldr r0, =gPokenavMessageBox_Pal
|
||||
movs r1, 0x10
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
movs r0, 0x1
|
||||
movs r1, 0
|
||||
movs r2, 0
|
||||
@ -4454,7 +4345,7 @@ _081C9AFA:
|
||||
ldr r0, =gUnknown_0861FD4C
|
||||
movs r1, 0x20
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
b _081C9AD6
|
||||
.pool
|
||||
_081C9B30:
|
||||
@ -4481,7 +4372,7 @@ _081C9B3E:
|
||||
ldr r0, =gUnknown_0861FC78
|
||||
movs r1, 0x30
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
bl sub_81C9894
|
||||
cmp r0, 0x3
|
||||
beq _081C9B76
|
||||
@ -6152,7 +6043,7 @@ sub_81CA850: @ 81CA850
|
||||
ldr r0, =gUnknown_0861FC78 + 0xE
|
||||
movs r1, 0x31
|
||||
movs r2, 0x4
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
@ -7636,7 +7527,7 @@ _081CB368:
|
||||
ldr r0, =gUnknown_08622510
|
||||
movs r1, 0x20
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
movs r0, 0x2
|
||||
b _081CB418
|
||||
.pool
|
||||
@ -7669,7 +7560,7 @@ _081CB3E0:
|
||||
ldr r0, =gUnknown_086226E0
|
||||
movs r1, 0x10
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
movs r0, 0x1
|
||||
_081CB418:
|
||||
bl CopyBgTilemapBufferToVram
|
||||
@ -7693,11 +7584,11 @@ _081CB424:
|
||||
ldr r0, =gUnknown_08622700
|
||||
movs r1, 0x30
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
ldr r0, =gUnknown_08622720
|
||||
movs r1, 0x50
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
movs r0, 0
|
||||
b _081CB506
|
||||
.pool
|
||||
@ -10555,11 +10446,11 @@ sub_81CCA1C: @ 81CCA1C
|
||||
ldr r0, =gUnknown_08622868
|
||||
movs r1, 0x10
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
ldr r0, =gHoennMapZoomIcons_Pal
|
||||
movs r1, 0x30
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
bl sub_8124658
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
@ -13180,11 +13071,11 @@ _081CDFF2:
|
||||
ldr r0, =gPokenavCondition_Pal
|
||||
movs r1, 0x10
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
ldr r0, =gUnknown_08623208
|
||||
movs r1, 0xF0
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
ldr r0, =0x00001814
|
||||
adds r1, r5, r0
|
||||
ldr r0, =0x0000ffb0
|
||||
@ -13211,7 +13102,7 @@ _081CE03C:
|
||||
ldr r0, =gUnknown_086231E8
|
||||
movs r1, 0x30
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
movs r0, 0x2
|
||||
bl sub_81D21DC
|
||||
b _081CDFB0
|
||||
@ -15659,7 +15550,7 @@ _081CF454:
|
||||
ldr r0, =gUnknown_086233C4
|
||||
movs r1, 0x10
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
movs r0, 0x1
|
||||
bl CopyBgTilemapBufferToVram
|
||||
_081CF498:
|
||||
@ -15683,7 +15574,7 @@ _081CF4C0:
|
||||
ldr r0, =gUnknown_08623570
|
||||
movs r1, 0x20
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
bl sub_81CF88C
|
||||
b _081CF498
|
||||
.pool
|
||||
@ -17043,7 +16934,7 @@ _081CFEF4:
|
||||
ldr r0, =gUnknown_086235E4
|
||||
movs r1, 0x10
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
movs r0, 0x1
|
||||
bl CopyBgTilemapBufferToVram
|
||||
_081CFF32:
|
||||
@ -17077,7 +16968,7 @@ _081CFF76:
|
||||
ldr r0, =gUnknown_08623790
|
||||
movs r1, 0x20
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
bl sub_81D0304
|
||||
b _081CFF32
|
||||
.pool
|
||||
@ -18580,7 +18471,7 @@ _081D0AB8:
|
||||
ldr r0, =gUnknown_08DDE010
|
||||
movs r1, 0x10
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
b _081D0BBA
|
||||
.pool
|
||||
_081D0B04:
|
||||
@ -18618,11 +18509,11 @@ _081D0B12:
|
||||
ldr r0, =gUnknown_08623FF8
|
||||
movs r1, 0x20
|
||||
movs r2, 0xA0
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
ldr r0, =gUnknown_08624098
|
||||
movs r1, 0xA0
|
||||
movs r2, 0x20
|
||||
bl sub_81C7944
|
||||
bl CopyPaletteIntoBufferUnfaded
|
||||
movs r0, 0x1
|
||||
b _081D0BBC
|
||||
.pool
|
||||
|
@ -13,9 +13,15 @@
|
||||
#include "bg.h"
|
||||
#include "menu.h"
|
||||
#include "graphics.h"
|
||||
#include "gba/macro.h"
|
||||
|
||||
#define UNKNOWN_OFFSET 100000
|
||||
|
||||
struct PaletteDescriptor {
|
||||
void *palette;
|
||||
u16 tag;
|
||||
};
|
||||
|
||||
struct UnknownStruct_0203CF40 {
|
||||
u32 (*field0)(void);
|
||||
u32 field4;
|
||||
@ -49,14 +55,12 @@ extern void sub_81CAADC(void);
|
||||
extern void sub_81C99D4(void);
|
||||
extern void sub_81C7C94(void);
|
||||
extern void sub_8199D98(void);
|
||||
extern void sub_81C7944(void* palette, u32 a1, u32 a2);
|
||||
extern void sub_81C7B74(void);
|
||||
extern void sub_81C7C28(void);
|
||||
extern void sub_81C7D28(void);
|
||||
extern u32 atk47_cmd47(s32 a0);
|
||||
extern u32 sub_81C791C(s32 a0);
|
||||
|
||||
|
||||
u32 sub_81C791C(s32 a0);
|
||||
bool32 sub_81C756C(u32 a0);
|
||||
bool32 sub_81C76C4(void);
|
||||
u32 AnyMonHasRibbon(void);
|
||||
@ -65,7 +69,9 @@ u32 sub_81C75D4(void);
|
||||
u32 sub_81C76FC(void);
|
||||
u32 sub_81C786C(void);
|
||||
u32 sub_81C7764(s32 a0);
|
||||
u32 atk47_cmd47(s32 a0);
|
||||
bool32 sub_81C7738(void);
|
||||
void CopyPaletteIntoBufferUnfaded(void *palette, u32 a1, u32 a2);
|
||||
void sub_81C7834(u32 (*a0)(void), u32(*a1)(void));
|
||||
void sub_81C7360(struct UnknownStruct_0203CF40 *a0);
|
||||
void sub_81C7650(u32 index);
|
||||
@ -493,7 +499,7 @@ u32 sub_81C7764(s32 a0) {
|
||||
decompress_and_copy_tile_data_to_vram(0, &gPokenavHeader_Gfx, 0, 0, 0);
|
||||
SetBgTilemapBuffer(0, &v1->data[11]);
|
||||
CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0);
|
||||
sub_81C7944(&gPokenavHeader_Pal, 0, 0x20);
|
||||
CopyPaletteIntoBufferUnfaded(&gPokenavHeader_Pal, 0, 0x20);
|
||||
CopyBgTilemapBufferToVram(0);
|
||||
return 0;
|
||||
case 2:
|
||||
@ -566,4 +572,89 @@ bool32 sub_81C78C0(void) {
|
||||
|
||||
v1 = sub_81C763C(0);
|
||||
return sub_81C70D8(v1->fieldC);
|
||||
}
|
||||
|
||||
u32 atk47_cmd47(s32 a0) {
|
||||
switch (a0) {
|
||||
default:
|
||||
return 4;
|
||||
case 1:
|
||||
return 0;
|
||||
case 0:
|
||||
return 0;
|
||||
case 2:
|
||||
if ((u32)ChangeBgY(0, 384, 1) >= 0x2000) {
|
||||
ChangeBgY(0, 0x2000, 0);
|
||||
return 4;
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 sub_81C791C(s32 a0) {
|
||||
if (ChangeBgY(0, 384, 2) <= 0) {
|
||||
ChangeBgY(0, 0, 0);
|
||||
return 4;
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
void CopyPaletteIntoBufferUnfaded(void *palette, u32 bufferOffset, u32 size) {
|
||||
CpuCopy16(palette, gPlttBufferUnfaded + bufferOffset, size);
|
||||
}
|
||||
|
||||
__attribute__((naked))
|
||||
void sub_81C795C(struct PaletteDescriptor *palettes) {
|
||||
// This code matches the assembly almost exactly; however, gcc chooses
|
||||
// to store `index` in r0 instead of r1.
|
||||
#ifdef NONMATCHING
|
||||
struct PaletteDescriptor *current;
|
||||
u32 offset;
|
||||
u32 index;
|
||||
|
||||
current = palettes;
|
||||
for (;;) {
|
||||
if (current->palette == NULL) {
|
||||
break;
|
||||
}
|
||||
index = AllocSpritePalette(current->tag);
|
||||
if (index == 0xFF) {
|
||||
break;
|
||||
}
|
||||
offset = (index * 16) + 0x100;
|
||||
CopyPaletteIntoBufferUnfaded(current->palette, offset, 0x20);
|
||||
current++;
|
||||
}
|
||||
#else // NONMATCHING
|
||||
asm(".syntax unified\n\
|
||||
push {r4,lr}\n\
|
||||
adds r4, r0, 0\n\
|
||||
b _081C7974\n\
|
||||
_081C7962:\n\
|
||||
lsls r0, r1, 4\n\
|
||||
movs r2, 0x80\n\
|
||||
lsls r2, 1\n\
|
||||
adds r1, r0, r2\n\
|
||||
ldr r0, [r4]\n\
|
||||
movs r2, 0x20\n\
|
||||
bl CopyPaletteIntoBufferUnfaded\n\
|
||||
adds r4, 0x8\n\
|
||||
_081C7974:\n\
|
||||
ldr r0, [r4]\n\
|
||||
cmp r0, 0\n\
|
||||
beq _081C7988\n\
|
||||
ldrh r0, [r4, 0x4]\n\
|
||||
bl AllocSpritePalette\n\
|
||||
lsls r0, 24\n\
|
||||
lsrs r1, r0, 24\n\
|
||||
cmp r1, 0xFF\n\
|
||||
bne _081C7962\n\
|
||||
_081C7988:\n\
|
||||
pop {r4}\n\
|
||||
pop {r0}\n\
|
||||
bx r0\n\
|
||||
.syntax divided");
|
||||
#endif // NONMATCHING
|
||||
}
|
Loading…
Reference in New Issue
Block a user