diff options
| author | Roman971 <romanlasnier@hotmail.com> | 2020-03-22 22:19:43 +0100 |
|---|---|---|
| committer | Roman971 <romanlasnier@hotmail.com> | 2020-03-22 22:20:03 +0100 |
| commit | 8cfe7cce9f8d8abea794e67510879e751d373a87 (patch) | |
| tree | c6c46f34d3575f6dc02b98b2b5f5ad88d2b2c64e /src/code/TwoHeadArena.c | |
| parent | 251aea64ab3e6e8cd6f1d9ed34f514e656724777 (diff) | |
Format all src C files
Diffstat (limited to 'src/code/TwoHeadArena.c')
| -rw-r--r-- | src/code/TwoHeadArena.c | 103 |
1 files changed, 36 insertions, 67 deletions
diff --git a/src/code/TwoHeadArena.c b/src/code/TwoHeadArena.c index b46695442..23cfa00f8 100644 --- a/src/code/TwoHeadArena.c +++ b/src/code/TwoHeadArena.c @@ -1,172 +1,141 @@ #include <global.h> -void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, u32 size) -{ +void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, u32 size) { THA_Ct((TwoHeadArena*)thga, start, size); } -void THGA_Dt(TwoHeadGfxArena* thga) -{ +void THGA_Dt(TwoHeadGfxArena* thga) { THA_Dt((TwoHeadArena*)thga); } -u32 THGA_IsCrash(TwoHeadGfxArena* thga) -{ +u32 THGA_IsCrash(TwoHeadGfxArena* thga) { return THA_IsCrash((TwoHeadArena*)thga); } -void THGA_Init(TwoHeadGfxArena* thga) -{ +void THGA_Init(TwoHeadGfxArena* thga) { THA_Init((TwoHeadArena*)thga); } -s32 THGA_GetSize(TwoHeadGfxArena* thga) -{ +s32 THGA_GetSize(TwoHeadGfxArena* thga) { return THA_GetSize((TwoHeadArena*)thga); } -Gfx* THGA_GetHead(TwoHeadGfxArena* thga) -{ +Gfx* THGA_GetHead(TwoHeadGfxArena* thga) { return THA_GetHead((TwoHeadArena*)thga); } -void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* start) -{ +void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* start) { THA_SetHead((TwoHeadArena*)thga, start); } -Gfx* THGA_GetTail(TwoHeadGfxArena* thga) -{ +Gfx* THGA_GetTail(TwoHeadGfxArena* thga) { return THA_GetTail((TwoHeadArena*)thga); } -Gfx* THGA_AllocStartArray8(TwoHeadGfxArena* thga, u32 count) -{ +Gfx* THGA_AllocStartArray8(TwoHeadGfxArena* thga, u32 count) { return THA_AllocStart((TwoHeadArena*)thga, count * 8); } -Gfx* THGA_AllocStart8(TwoHeadGfxArena* thga) -{ +Gfx* THGA_AllocStart8(TwoHeadGfxArena* thga) { return THGA_AllocStartArray8(thga, 1); } -Gfx* THGA_AllocStart8Wrapper(TwoHeadGfxArena* thga) -{ +Gfx* THGA_AllocStart8Wrapper(TwoHeadGfxArena* thga) { return THGA_AllocStart8(thga); } -Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, u32 size) -{ +Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, u32 size) { return THA_AllocEnd((TwoHeadArena*)thga, size); } -Gfx* THGA_AllocEndArray64(TwoHeadGfxArena* thga, u32 count) -{ +Gfx* THGA_AllocEndArray64(TwoHeadGfxArena* thga, u32 count) { return THGA_AllocEnd(thga, count * 0x40); } -Gfx* THGA_AllocEnd64(TwoHeadGfxArena* thga) -{ +Gfx* THGA_AllocEnd64(TwoHeadGfxArena* thga) { return THGA_AllocEnd(thga, 0x40); } -Gfx* THGA_AllocEndArray16(TwoHeadGfxArena* thga, u32 count) -{ +Gfx* THGA_AllocEndArray16(TwoHeadGfxArena* thga, u32 count) { return THGA_AllocEnd(thga, count * 0x10); } -Gfx* THGA_AllocEnd16(TwoHeadGfxArena* thga) -{ +Gfx* THGA_AllocEnd16(TwoHeadGfxArena* thga) { return THGA_AllocEnd(thga, 0x10); } - - - - -void* THA_GetHead(TwoHeadArena* tha) -{ +void* THA_GetHead(TwoHeadArena* tha) { return tha->head; } -void THA_SetHead(TwoHeadArena* tha, void* start) -{ +void THA_SetHead(TwoHeadArena* tha, void* start) { tha->head = start; } -void* THA_GetTail(TwoHeadArena* tha) -{ +void* THA_GetTail(TwoHeadArena* tha) { return tha->tail; } -void* THA_AllocStart(TwoHeadArena* tha, u32 size) -{ +void* THA_AllocStart(TwoHeadArena* tha, u32 size) { void* start = tha->head; tha->head += size; return start; } -void* THA_AllocStart1(TwoHeadArena* tha) -{ +void* THA_AllocStart1(TwoHeadArena* tha) { return THA_AllocStart(tha, 1); } -void* THA_AllocEnd(TwoHeadArena* tha, u32 size) -{ +void* THA_AllocEnd(TwoHeadArena* tha, u32 size) { u32 mask; u32* temp; - if (size == 8) + if (size == 8) { mask = ~7; - else if (size == 4 || size == 12) + } else if (size == 4 || size == 12) { mask = ~3; - else if (size == 2 || size == 6 || size == 10 || size == 12 || size == 14) + } else if (size == 2 || size == 6 || size == 10 || size == 12 || size == 14) { mask = ~1; - else + } else { mask = (size >= 0x10) ? ~0xF : 0; + } temp = (u32*)&tha->tail; // required to match return tha->tail = (void*)(((*temp & mask) - size) & mask); } -void* THA_AllocEndAlign16(TwoHeadArena *tha, u32 size) -{ - void* ret = (void*)(u32)((((u32)tha->tail & ~0xF) - size) & ((~(0xF & 0xFFFFFFFFFFFFFFFF)) & 0xFFFFFFFFu)); // required to match +void* THA_AllocEndAlign16(TwoHeadArena* tha, u32 size) { + void* ret = (void*)(u32)((((u32)tha->tail & ~0xF) - size) & + ((~(0xF & 0xFFFFFFFFFFFFFFFF)) & 0xFFFFFFFFu)); // required to match tha->tail = ret; return ret; } -void* THA_AllocEndAlign(TwoHeadArena* tha, u32 size, u32 mask) -{ +void* THA_AllocEndAlign(TwoHeadArena* tha, u32 size, u32 mask) { void* ret = (void*)((((u32)tha->tail & mask) - size) & mask); tha->tail = ret; return ret; } -s32 THA_GetSize(TwoHeadArena* tha) -{ +s32 THA_GetSize(TwoHeadArena* tha) { return tha->tail - tha->head; } -u32 THA_IsCrash(TwoHeadArena* tha) -{ +u32 THA_IsCrash(TwoHeadArena* tha) { return THA_GetSize(tha) < 0; } -void THA_Init(TwoHeadArena* tha) -{ +void THA_Init(TwoHeadArena* tha) { tha->head = tha->bufp; tha->tail = tha->bufp + tha->size; } -void THA_Ct(TwoHeadArena* tha, void* ptr, u32 size) -{ +void THA_Ct(TwoHeadArena* tha, void* ptr, u32 size) { tha->bufp = ptr; tha->size = size; THA_Init(tha); } -void THA_Dt(TwoHeadArena* tha) -{ +void THA_Dt(TwoHeadArena* tha) { bzero(tha, sizeof(TwoHeadArena)); } |
