mirror of
https://github.com/pret/pmd-red.git
synced 2026-08-28 03:34:22 -05:00
Merge pull request #279 from DizzyEggg/DoFree
Some checks failed
GithubCI / build (push) Has been cancelled
Some checks failed
GithubCI / build (push) Has been cancelled
This commit is contained in:
122
asm/memory_1.s
122
asm/memory_1.s
@@ -1,122 +0,0 @@
|
||||
#include "asm/constants/gba_constants.inc"
|
||||
#include "asm/macros.inc"
|
||||
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start DoFree
|
||||
DoFree:
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
adds r4, r0, 0
|
||||
cmp r4, 0
|
||||
bne _0800352E
|
||||
ldr r4, =gMainHeapDescriptor
|
||||
_0800352E:
|
||||
cmp r1, 0
|
||||
beq _080035E4
|
||||
movs r0, 0
|
||||
mov r8, r0
|
||||
ldr r3, [r4, 0x8]
|
||||
mov r12, r3
|
||||
ldr r3, [r4, 0xC]
|
||||
cmp r8, r3
|
||||
bge _080035E4
|
||||
movs r2, 0
|
||||
_08003542:
|
||||
mov r5, r12
|
||||
ldr r0, [r5, 0xC]
|
||||
cmp r0, r1
|
||||
bne _080035D8
|
||||
str r2, [r5]
|
||||
str r2, [r5, 0x4]
|
||||
str r2, [r5, 0x14]
|
||||
str r2, [r5, 0x8]
|
||||
ldr r0, [r4, 0xC]
|
||||
subs r0, 0x1
|
||||
cmp r8, r0
|
||||
bge _08003592
|
||||
mov r2, r12
|
||||
adds r2, 0x18
|
||||
ldr r0, [r2, 0x4]
|
||||
cmp r0, 0
|
||||
bne _08003592
|
||||
ldr r0, [r5, 0x10]
|
||||
ldr r1, [r2, 0x10]
|
||||
adds r0, r1
|
||||
str r0, [r5, 0x10]
|
||||
ldr r0, [r4, 0xC]
|
||||
subs r0, 0x1
|
||||
str r0, [r4, 0xC]
|
||||
mov r3, r8
|
||||
adds r3, 0x1
|
||||
cmp r3, r0
|
||||
bge _08003592
|
||||
_0800357A:
|
||||
adds r0, r2, 0
|
||||
adds r1, r2, 0
|
||||
adds r1, 0x18
|
||||
ldm r1!, {r5-r7}
|
||||
stm r0!, {r5-r7}
|
||||
ldm r1!, {r5-r7}
|
||||
stm r0!, {r5-r7}
|
||||
adds r3, 0x1
|
||||
adds r2, 0x18
|
||||
ldr r0, [r4, 0xC]
|
||||
cmp r3, r0
|
||||
blt _0800357A
|
||||
_08003592:
|
||||
mov r6, r8
|
||||
cmp r6, 0
|
||||
ble _080035E4
|
||||
mov r2, r12
|
||||
subs r2, 0x18
|
||||
ldr r0, [r2, 0x4]
|
||||
cmp r0, 0
|
||||
bne _080035E4
|
||||
ldr r0, [r2, 0x10]
|
||||
mov r7, r12
|
||||
ldr r1, [r7, 0x10]
|
||||
adds r0, r1
|
||||
str r0, [r2, 0x10]
|
||||
ldr r0, [r4, 0xC]
|
||||
subs r0, 0x1
|
||||
str r0, [r4, 0xC]
|
||||
mov r2, r12
|
||||
mov r3, r8
|
||||
cmp r3, r0
|
||||
bge _080035E4
|
||||
_080035BA:
|
||||
adds r0, r2, 0
|
||||
adds r1, r2, 0
|
||||
adds r1, 0x18
|
||||
ldm r1!, {r5-r7}
|
||||
stm r0!, {r5-r7}
|
||||
ldm r1!, {r5-r7}
|
||||
stm r0!, {r5-r7}
|
||||
adds r3, 0x1
|
||||
adds r2, 0x18
|
||||
ldr r0, [r4, 0xC]
|
||||
cmp r3, r0
|
||||
blt _080035BA
|
||||
b _080035E4
|
||||
.align 2, 0
|
||||
.pool
|
||||
_080035D8:
|
||||
movs r0, 0x1
|
||||
add r8, r0
|
||||
movs r5, 0x18
|
||||
add r12, r5
|
||||
cmp r8, r3
|
||||
blt _08003542
|
||||
_080035E4:
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end DoFree
|
||||
|
||||
.align 2,0
|
||||
@@ -54,8 +54,6 @@ SECTIONS {
|
||||
src/memory.o(.text);
|
||||
asm/memory.o(.text);
|
||||
src/memory_mid.o(.text);
|
||||
asm/memory_1.o(.text);
|
||||
src/memory1.o(.text);
|
||||
asm/code_80035F0.o(.text);
|
||||
src/other_random.o(.text);
|
||||
src/util.o(.text);
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#include "global.h"
|
||||
|
||||
void nullsub_141(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void nullsub_142(void)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -138,3 +138,64 @@ void *DoAlloc(struct HeapDescriptor *heap, s32 size, u32 a2)
|
||||
{
|
||||
return _LocateSet(heap, size, a2 | 0x100);
|
||||
}
|
||||
|
||||
void DoFree(struct HeapDescriptor *heapDescriptior, void *ptrToFree)
|
||||
{
|
||||
struct HeapFreeListElement *curr;
|
||||
struct HeapFreeListElement *next;
|
||||
struct HeapFreeListElement *prev;
|
||||
s32 i;
|
||||
|
||||
if (heapDescriptior == NULL)
|
||||
heapDescriptior = &gMainHeapDescriptor;
|
||||
|
||||
if (ptrToFree == NULL)
|
||||
return;
|
||||
|
||||
i = 0;
|
||||
curr = &heapDescriptior->freeList[0];
|
||||
for (; i < heapDescriptior->freeCount; i++, curr++) {
|
||||
if (curr->block.start == (u8 *)ptrToFree) {
|
||||
curr->unk_atb = 0;
|
||||
curr->atb = 0;
|
||||
curr->block.allocatedSize = 0;
|
||||
curr->grp = 0;
|
||||
|
||||
if (i < heapDescriptior->freeCount - 1) {
|
||||
s32 j;
|
||||
|
||||
next = curr + 1;
|
||||
if (next->atb == 0) {
|
||||
curr->block.size += next->block.size;
|
||||
heapDescriptior->freeCount--;
|
||||
for (j = i + 1; j < heapDescriptior->freeCount; j++, next++)
|
||||
next[0] = next[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= 1) {
|
||||
s32 j;
|
||||
prev = curr - 1;
|
||||
if (prev->atb == 0) {
|
||||
prev->block.size += curr->block.size;
|
||||
heapDescriptior->freeCount--;
|
||||
prev = curr;
|
||||
for (j = i; j < heapDescriptior->freeCount; j++, prev++)
|
||||
prev[0] = prev[1];
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nullsub_141(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void nullsub_142(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user