mirror of
https://github.com/pret/pmd-red.git
synced 2026-08-09 20:19:07 -05:00
through InitHeapInternal
This commit is contained in:
parent
c418a4585f
commit
48f00a9b91
183
asm/memory.s
183
asm/memory.s
|
|
@ -5,189 +5,6 @@
|
|||
|
||||
.text
|
||||
|
||||
thumb_func_start InitHeap
|
||||
InitHeap:
|
||||
push {lr}
|
||||
bl InitHeapInternal
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end InitHeap
|
||||
|
||||
thumb_func_start MemoryClear8
|
||||
MemoryClear8:
|
||||
push {lr}
|
||||
cmp r1, 0
|
||||
ble _08002EAA
|
||||
movs r2, 0
|
||||
_08002EA0:
|
||||
subs r1, 0x1
|
||||
strb r2, [r0]
|
||||
adds r0, 0x1
|
||||
cmp r1, 0
|
||||
bgt _08002EA0
|
||||
_08002EAA:
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MemoryClear8
|
||||
|
||||
thumb_func_start MemoryClear16
|
||||
MemoryClear16:
|
||||
push {lr}
|
||||
cmp r1, 0
|
||||
ble _08002EC2
|
||||
movs r2, 0
|
||||
_08002EB8:
|
||||
subs r1, 0x2
|
||||
strh r2, [r0]
|
||||
adds r0, 0x2
|
||||
cmp r1, 0
|
||||
bgt _08002EB8
|
||||
_08002EC2:
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MemoryClear16
|
||||
|
||||
thumb_func_start MemoryClear32
|
||||
MemoryClear32:
|
||||
push {lr}
|
||||
bl CpuClear
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MemoryClear32
|
||||
|
||||
thumb_func_start MemoryFill8
|
||||
MemoryFill8:
|
||||
push {lr}
|
||||
lsls r1, 24
|
||||
lsrs r1, 24
|
||||
cmp r2, 0
|
||||
ble _08002EE8
|
||||
_08002EDE:
|
||||
subs r2, 0x1
|
||||
strb r1, [r0]
|
||||
adds r0, 0x1
|
||||
cmp r2, 0
|
||||
bgt _08002EDE
|
||||
_08002EE8:
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MemoryFill8
|
||||
|
||||
thumb_func_start MemoryFill16
|
||||
MemoryFill16:
|
||||
push {lr}
|
||||
lsls r1, 16
|
||||
lsrs r1, 16
|
||||
cmp r2, 0
|
||||
ble _08002F00
|
||||
_08002EF6:
|
||||
subs r2, 0x2
|
||||
strh r1, [r0]
|
||||
adds r0, 0x2
|
||||
cmp r2, 0
|
||||
bgt _08002EF6
|
||||
_08002F00:
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MemoryFill16
|
||||
|
||||
thumb_func_start MemoryFill32
|
||||
MemoryFill32:
|
||||
push {lr}
|
||||
cmp r2, 0
|
||||
ble _08002F12
|
||||
_08002F0A:
|
||||
subs r2, 0x4
|
||||
stm r0!, {r1}
|
||||
cmp r2, 0
|
||||
bgt _08002F0A
|
||||
_08002F12:
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MemoryFill32
|
||||
|
||||
thumb_func_start MemoryCopy8
|
||||
MemoryCopy8:
|
||||
push {lr}
|
||||
adds r3, r0, 0
|
||||
cmp r2, 0
|
||||
ble _08002F2E
|
||||
_08002F20:
|
||||
subs r2, 0x1
|
||||
ldrb r0, [r1]
|
||||
strb r0, [r3]
|
||||
adds r1, 0x1
|
||||
adds r3, 0x1
|
||||
cmp r2, 0
|
||||
bgt _08002F20
|
||||
_08002F2E:
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MemoryCopy8
|
||||
|
||||
thumb_func_start MemoryCopy16
|
||||
MemoryCopy16:
|
||||
push {lr}
|
||||
adds r3, r0, 0
|
||||
cmp r2, 0
|
||||
ble _08002F4A
|
||||
_08002F3C:
|
||||
subs r2, 0x2
|
||||
ldrh r0, [r1]
|
||||
strh r0, [r3]
|
||||
adds r1, 0x2
|
||||
adds r3, 0x2
|
||||
cmp r2, 0
|
||||
bgt _08002F3C
|
||||
_08002F4A:
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MemoryCopy16
|
||||
|
||||
thumb_func_start MemoryCopy32
|
||||
MemoryCopy32:
|
||||
push {lr}
|
||||
adds r3, r0, 0
|
||||
cmp r2, 0
|
||||
ble _08002F62
|
||||
_08002F58:
|
||||
subs r2, 0x4
|
||||
ldm r1!, {r0}
|
||||
stm r3!, {r0}
|
||||
cmp r2, 0
|
||||
bgt _08002F58
|
||||
_08002F62:
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MemoryCopy32
|
||||
|
||||
thumb_func_start InitHeapInternal
|
||||
InitHeapInternal:
|
||||
push {lr}
|
||||
sub sp, 0x8
|
||||
ldr r0, _08002F90
|
||||
str r0, [sp]
|
||||
movs r0, 0x90
|
||||
lsls r0, 10
|
||||
str r0, [sp, 0x4]
|
||||
ldr r1, _08002F94
|
||||
movs r0, 0
|
||||
str r0, [r1]
|
||||
ldr r0, _08002F98
|
||||
ldr r2, _08002F9C
|
||||
mov r1, sp
|
||||
movs r3, 0x20
|
||||
bl DoInitHeap
|
||||
add sp, 0x8
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_08002F90: .4byte gUnknown_20011D0
|
||||
_08002F94: .4byte gUnknown_2000EA8
|
||||
_08002F98: .4byte gUnknown_2000EB0
|
||||
_08002F9C: .4byte gUnknown_2000ED0
|
||||
thumb_func_end InitHeapInternal
|
||||
|
||||
thumb_func_start DoInitHeap
|
||||
DoInitHeap:
|
||||
push {r4-r6,lr}
|
||||
|
|
|
|||
12
include/code_800B540.h
Normal file
12
include/code_800B540.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef GUARD_code_800B540_H
|
||||
#define GUARD_code_800B540_H
|
||||
|
||||
// Exported type declarations
|
||||
|
||||
// Exported RAM declarations
|
||||
|
||||
// Exported ROM declarations
|
||||
|
||||
void CpuClear(u32 *dest, int size);
|
||||
|
||||
#endif //GUARD_code_800B540_H
|
||||
|
|
@ -14,6 +14,7 @@ SECTIONS {
|
|||
tools/agbcc/lib/libgcc.a:fp-bit.o(.bss);
|
||||
. = ALIGN(4);
|
||||
tools/agbcc/lib/libgcc.a:dp-bit.o(.bss);
|
||||
. = ALIGN(8); /* 0x39e18 */
|
||||
<EWRAM2>
|
||||
. = 0x40000;
|
||||
}
|
||||
|
|
@ -37,6 +38,7 @@ SECTIONS {
|
|||
asm/code.o(.text);
|
||||
asm/event_flag.o(.text);
|
||||
asm/code_8002774.o(.text);
|
||||
src/memory.o(.text);
|
||||
asm/memory.o(.text);
|
||||
asm/code_80035F0.o(.text);
|
||||
src/other_random.o(.text);
|
||||
|
|
|
|||
118
src/memory.c
Normal file
118
src/memory.c
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
|
||||
// Includes
|
||||
#include "global.h"
|
||||
#include "code_800B540.h"
|
||||
|
||||
// Static type declarations
|
||||
|
||||
struct HeapInitArgs {
|
||||
void *ptr;
|
||||
u32 size;
|
||||
};
|
||||
|
||||
// Static RAM declarations
|
||||
|
||||
u32 gUnknown_2000EA8 = 0;
|
||||
u8 gUnknown_2000EB0[0x20] = {};
|
||||
u8 gUnknown_2000ED0[0x300] = {};
|
||||
u8 gUnknown_20011D0[0x24000] = {};
|
||||
|
||||
// Static ROM declarations
|
||||
|
||||
// .rodata
|
||||
|
||||
// .text
|
||||
|
||||
void InitHeapInternal(void);
|
||||
void DoInitHeap(void *a0, struct HeapInitArgs *args, void *a2, size_t a3);
|
||||
|
||||
void InitHeap(void)
|
||||
{
|
||||
InitHeapInternal();
|
||||
}
|
||||
|
||||
void MemoryClear8(u8 *dst, int size)
|
||||
{
|
||||
while (size > 0)
|
||||
{
|
||||
size -= 1;
|
||||
*dst++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryClear16(u16 *dst, int size)
|
||||
{
|
||||
while (size > 0)
|
||||
{
|
||||
size -= 2;
|
||||
*dst++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryClear32(u32 *dst, int size)
|
||||
{
|
||||
CpuClear(dst, size);
|
||||
}
|
||||
|
||||
void MemoryFill8(u8 *dst, u8 val, int size)
|
||||
{
|
||||
while (size > 0)
|
||||
{
|
||||
size -= 1;
|
||||
*dst++ = val;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryFill16(u16 *dst, u16 val, int size)
|
||||
{
|
||||
while (size > 0)
|
||||
{
|
||||
size -= 2;
|
||||
*dst++ = val;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryFill32(u32 *dst, u32 val, int size)
|
||||
{
|
||||
while (size > 0)
|
||||
{
|
||||
size -= 4;
|
||||
*dst++ = val;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCopy8(u8 *dst, const u8 *src, int size)
|
||||
{
|
||||
while (size > 0)
|
||||
{
|
||||
size -= 1;
|
||||
*dst++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCopy16(u16 *dst, const u16 *src, int size)
|
||||
{
|
||||
while (size > 0)
|
||||
{
|
||||
size -= 2;
|
||||
*dst++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCopy32(u32 *dst, const u32 *src, int size)
|
||||
{
|
||||
while (size > 0)
|
||||
{
|
||||
size -= 4;
|
||||
*dst++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
void InitHeapInternal(void)
|
||||
{
|
||||
struct HeapInitArgs args;
|
||||
args.ptr = gUnknown_20011D0;
|
||||
args.size = sizeof gUnknown_20011D0;
|
||||
gUnknown_2000EA8 = 0;
|
||||
DoInitHeap(gUnknown_2000EB0, &args, gUnknown_2000ED0, sizeof gUnknown_2000EB0);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user