mirror of
https://github.com/pret/pmd-red.git
synced 2026-08-25 18:25:00 -05:00
sub_803E9D0
This commit is contained in:
@@ -5,205 +5,7 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_803E874
|
||||
sub_803E874:
|
||||
push {r4-r7,lr}
|
||||
mov r7, r10
|
||||
mov r6, r9
|
||||
mov r5, r8
|
||||
push {r5-r7}
|
||||
sub sp, 0x8
|
||||
mov r9, r1
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
mov r10, r0
|
||||
ldr r0, _0803E9A4
|
||||
ldr r0, [r0]
|
||||
ldr r5, [r0, 0x4]
|
||||
ldr r1, _0803E9A8
|
||||
ldr r0, _0803E9AC
|
||||
ldr r2, [r0]
|
||||
ldr r0, _0803E9B0
|
||||
ldr r3, [r0]
|
||||
movs r0, 0xBE
|
||||
lsls r0, 1
|
||||
adds r3, r0
|
||||
movs r0, 0
|
||||
bl SetBGPaletteBufferColorRGB
|
||||
adds r5, 0x4
|
||||
movs r6, 0x1
|
||||
movs r4, 0x9F
|
||||
_0803E8AA:
|
||||
ldr r1, _0803E9AC
|
||||
mov r8, r1
|
||||
ldr r2, [r1]
|
||||
ldr r7, _0803E9B0
|
||||
ldr r3, [r7]
|
||||
movs r0, 0xBE
|
||||
lsls r0, 1
|
||||
adds r3, r0
|
||||
adds r0, r6, 0
|
||||
adds r1, r5, 0
|
||||
bl SetBGPaletteBufferColorRGB
|
||||
adds r5, 0x4
|
||||
adds r6, 0x1
|
||||
subs r4, 0x1
|
||||
cmp r4, 0
|
||||
bne _0803E8AA
|
||||
ldr r3, [r7]
|
||||
ldr r1, _0803E9B4
|
||||
adds r0, r3, r1
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
beq _0803E8E2
|
||||
ldr r2, _0803E9B8
|
||||
adds r0, r3, r2
|
||||
ldr r0, [r0]
|
||||
cmp r0, 0x3
|
||||
bne _0803E8FC
|
||||
_0803E8E2:
|
||||
ldr r1, _0803E9BC
|
||||
mov r2, r8
|
||||
ldr r0, [r2]
|
||||
str r0, [sp]
|
||||
movs r2, 0xBE
|
||||
lsls r2, 1
|
||||
adds r0, r3, r2
|
||||
str r0, [sp, 0x4]
|
||||
movs r0, 0x1
|
||||
movs r2, 0xA0
|
||||
movs r3, 0x20
|
||||
bl sub_8004AF0
|
||||
_0803E8FC:
|
||||
adds r6, 0x20
|
||||
ldr r5, _0803E9C0
|
||||
movs r4, 0x20
|
||||
_0803E902:
|
||||
ldr r0, _0803E9AC
|
||||
ldr r2, [r0]
|
||||
ldr r0, _0803E9B0
|
||||
ldr r3, [r0]
|
||||
movs r0, 0xBE
|
||||
lsls r0, 1
|
||||
adds r3, r0
|
||||
adds r0, r6, 0
|
||||
adds r1, r5, 0
|
||||
bl SetBGPaletteBufferColorRGB
|
||||
adds r5, 0x4
|
||||
adds r6, 0x1
|
||||
subs r4, 0x1
|
||||
cmp r4, 0
|
||||
bne _0803E902
|
||||
mov r1, r10
|
||||
cmp r1, 0
|
||||
beq _0803E948
|
||||
movs r6, 0xE0
|
||||
ldr r0, _0803E9C4
|
||||
ldr r0, [r0]
|
||||
ldr r5, [r0, 0x4]
|
||||
movs r4, 0x10
|
||||
_0803E932:
|
||||
adds r0, r6, 0
|
||||
adds r1, r5, 0
|
||||
mov r2, r9
|
||||
movs r3, 0
|
||||
bl SetBGPaletteBufferColorRGB
|
||||
adds r5, 0x4
|
||||
adds r6, 0x1
|
||||
subs r4, 0x1
|
||||
cmp r4, 0
|
||||
bne _0803E932
|
||||
_0803E948:
|
||||
ldr r1, _0803E9C8
|
||||
ldr r4, _0803E9AC
|
||||
ldr r2, [r4]
|
||||
movs r0, 0xF8
|
||||
movs r3, 0
|
||||
bl SetBGPaletteBufferColorRGB
|
||||
ldr r0, _0803E9B0
|
||||
ldr r0, [r0]
|
||||
ldr r2, _0803E9CC
|
||||
adds r0, r2
|
||||
ldr r0, [r0]
|
||||
ldr r5, [r0, 0x4]
|
||||
movs r6, 0x80
|
||||
lsls r6, 1
|
||||
adds r7, r4, 0
|
||||
movs r4, 0xD0
|
||||
_0803E96A:
|
||||
ldr r2, [r7]
|
||||
ldr r0, _0803E9B0
|
||||
ldr r3, [r0]
|
||||
movs r0, 0xBE
|
||||
lsls r0, 1
|
||||
adds r3, r0
|
||||
adds r0, r6, 0
|
||||
adds r1, r5, 0
|
||||
bl SetBGPaletteBufferColorRGB
|
||||
ldr r2, [r7]
|
||||
adds r0, r6, 0
|
||||
adds r1, r5, 0
|
||||
movs r3, 0
|
||||
bl nullsub_4
|
||||
adds r5, 0x4
|
||||
adds r6, 0x1
|
||||
subs r4, 0x1
|
||||
cmp r4, 0
|
||||
bne _0803E96A
|
||||
add sp, 0x8
|
||||
pop {r3-r5}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
mov r10, r5
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0803E9A4: .4byte gDungeonPaletteFile
|
||||
_0803E9A8: .4byte gUnknown_80F62AC
|
||||
_0803E9AC: .4byte gUnknown_202EDC8
|
||||
_0803E9B0: .4byte gDungeon
|
||||
_0803E9B4: .4byte 0x00018215
|
||||
_0803E9B8: .4byte 0x0001c06c
|
||||
_0803E9BC: .4byte gUnknown_202EE8C
|
||||
_0803E9C0: .4byte gUnknown_202ECA4
|
||||
_0803E9C4: .4byte gDungeonNameBannerPalette
|
||||
_0803E9C8: .4byte gUnknown_202D058
|
||||
_0803E9CC: .4byte 0x000181e4
|
||||
thumb_func_end sub_803E874
|
||||
|
||||
thumb_func_start sub_803E9D0
|
||||
sub_803E9D0:
|
||||
push {r4-r7,lr}
|
||||
ldr r0, _0803EA04
|
||||
ldr r0, [r0]
|
||||
ldr r1, _0803EA08
|
||||
adds r0, r1
|
||||
ldr r0, [r0]
|
||||
ldr r4, [r0, 0x4]
|
||||
movs r6, 0x80
|
||||
lsls r6, 1
|
||||
ldr r7, _0803EA0C
|
||||
movs r5, 0xD0
|
||||
_0803E9E6:
|
||||
ldr r2, [r7]
|
||||
adds r0, r6, 0
|
||||
adds r1, r4, 0
|
||||
movs r3, 0
|
||||
bl nullsub_4
|
||||
adds r4, 0x4
|
||||
adds r6, 0x1
|
||||
subs r5, 0x1
|
||||
cmp r5, 0
|
||||
bne _0803E9E6
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0803EA04: .4byte gDungeon
|
||||
_0803EA08: .4byte 0x000181e4
|
||||
_0803EA0C: .4byte gUnknown_202EDC8
|
||||
thumb_func_end sub_803E9D0
|
||||
|
||||
thumb_func_start sub_803EA10
|
||||
sub_803EA10:
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
#define GUARD_BG_PALETTE_BUFFER_H
|
||||
|
||||
void InitBGPaletteBuffer(void);
|
||||
void nullsub_4(s32 index, u8 *colorArray, s32, u8 *);
|
||||
void nullsub_4(s32 index, const u8 *colorArray, s32, u8 *);
|
||||
void nullsub_5(void);
|
||||
void SetBGPaletteBufferColorArray(s32 index, u8 *colorArray);
|
||||
void SetBGPaletteBufferColorRGB(s32 index, u8 *colorArray, s32, u8 *);
|
||||
void SetBGPaletteBufferColorArray(s32 index, const u8 *colorArray);
|
||||
void SetBGPaletteBufferColorRGB(s32 index, const u8 *colorArray, s32, u8 *);
|
||||
void TransferBGPaletteBuffer(void);
|
||||
|
||||
#endif // GUARD_BG_PALETTE_BUFFER_H
|
||||
#endif // GUARD_BG_PALETTE_BUFFER_H
|
||||
|
||||
@@ -208,6 +208,7 @@ SECTIONS {
|
||||
src/code_803D110.o(.text);
|
||||
asm/code_803D110.o(.text);
|
||||
src/code_803E46C.o(.text);
|
||||
src/code_803E724.o(.text);
|
||||
asm/code_803E724.o(.text);
|
||||
src/code_8040094.o(.text);
|
||||
asm/code_8040094.o(.text);
|
||||
|
||||
@@ -22,7 +22,7 @@ void InitBGPaletteBuffer(void)
|
||||
}
|
||||
|
||||
// 99.48% (r3/r4 regswap) https://decomp.me/scratch/7Yc8i
|
||||
void SetBGPaletteBufferColorRGB(s32 index, u8 *colorArray, s32 a1, u8 *a2)
|
||||
void SetBGPaletteBufferColorRGB(s32 index, const u8 *colorArray, s32 a1, u8 *a2)
|
||||
{
|
||||
#ifdef NONMATCHING
|
||||
s32 var;
|
||||
@@ -43,7 +43,7 @@ void SetBGPaletteBufferColorRGB(s32 index, u8 *colorArray, s32 a1, u8 *a2)
|
||||
sBGPaletteBuffer[index] = var = ((a2[4 * colorArray[2] + 2] * a1 / 256 & 0x1F) << 10) | ((a2[4 * colorArray[1] + 1] * a1 / 256 & 0x1F) << 5) | (a2[4 * colorArray[0]] * a1 / 256 & 0x1F);
|
||||
}
|
||||
|
||||
void SetBGPaletteBufferColorArray(s32 index, u8 *colorArray)
|
||||
void SetBGPaletteBufferColorArray(s32 index, const u8 *colorArray)
|
||||
{
|
||||
sBGPaletteUsed[index / BG_PALETTE_BUFFER_CHUNK_SIZE] = TRUE;
|
||||
sBGPaletteBuffer[index] = (colorArray[2] >> 3) << 10 | (colorArray[1] >> 3) << 5 | colorArray[0] >> 3;
|
||||
@@ -55,7 +55,7 @@ void SetBGPaletteBufferColor(s32 index, u16 *color)
|
||||
sBGPaletteBuffer[index] = *color;
|
||||
}
|
||||
|
||||
void nullsub_4(s32 index, u8 *colorArray, s32 a1, u8 *a2)
|
||||
void nullsub_4(s32 index, const u8 *colorArray, s32 a1, u8 *a2)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
87
src/code_803E724.c
Normal file
87
src/code_803E724.c
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "global.h"
|
||||
#include "dungeon.h"
|
||||
#include "bg_palette_buffer.h"
|
||||
#include "code_8004AA0.h"
|
||||
|
||||
extern s32 gUnknown_202EDC8;
|
||||
|
||||
struct DungeonPalFile
|
||||
{
|
||||
void *unk0;
|
||||
const void *unk4;
|
||||
};
|
||||
|
||||
extern struct DungeonPalFile *gDungeonPaletteFile;
|
||||
extern struct DungeonPalFile *gDungeonNameBannerPalette;
|
||||
extern u8 gUnknown_202ECA4[];
|
||||
extern u8 gUnknown_202D058[];
|
||||
|
||||
extern const u8 gUnknown_80F62AC[];
|
||||
|
||||
void sub_803E874(bool8 r10, s32 r9)
|
||||
{
|
||||
s32 i, index, count;
|
||||
const u8 *colorArray;
|
||||
|
||||
colorArray = gDungeonPaletteFile->unk4;
|
||||
SetBGPaletteBufferColorRGB(0, gUnknown_80F62AC, gUnknown_202EDC8, (void *) &gDungeon->unk17C);
|
||||
colorArray += 4;
|
||||
index = 1;
|
||||
count = 159;
|
||||
for (i = 0; i < count; i++) {
|
||||
SetBGPaletteBufferColorRGB(index, colorArray, gUnknown_202EDC8, (void *) &gDungeon->unk17C);
|
||||
colorArray += 4;
|
||||
index++;
|
||||
}
|
||||
|
||||
if (gDungeon->unk181e8.unk18215 == 0 || gDungeon->unk1C06C == 3) {
|
||||
sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, (void *) &gDungeon->unk17C);
|
||||
}
|
||||
|
||||
index += 32;
|
||||
colorArray = gUnknown_202ECA4;
|
||||
count = 32;
|
||||
for (i = 0; i < count; i++) {
|
||||
SetBGPaletteBufferColorRGB(index, colorArray, gUnknown_202EDC8, (void *) &gDungeon->unk17C);
|
||||
colorArray += 4;
|
||||
index++;
|
||||
}
|
||||
|
||||
if (r10) {
|
||||
index = 224;
|
||||
colorArray = gDungeonNameBannerPalette->unk4;
|
||||
count = 16;
|
||||
for (i = 0; i < count; i++) {
|
||||
SetBGPaletteBufferColorRGB(index, colorArray, r9, NULL);
|
||||
colorArray += 4;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
SetBGPaletteBufferColorRGB(248, gUnknown_202D058, gUnknown_202EDC8, NULL);
|
||||
|
||||
colorArray = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4;
|
||||
index = 256;
|
||||
count = 208;
|
||||
for (i = 0; i < count; i++) {
|
||||
SetBGPaletteBufferColorRGB(index, colorArray, gUnknown_202EDC8, (void *) &gDungeon->unk17C);
|
||||
nullsub_4(index, colorArray, gUnknown_202EDC8, NULL);
|
||||
colorArray += 4;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_803E9D0(void)
|
||||
{
|
||||
s32 i, index, count;
|
||||
const u8 *colorArray;
|
||||
|
||||
colorArray = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4;
|
||||
index = 256;
|
||||
count = 208;
|
||||
for (i = 0; i < count; i++) {
|
||||
nullsub_4(index, colorArray, gUnknown_202EDC8, NULL);
|
||||
colorArray += 4;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user