Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
JAUStreamAramMgr.h
Go to the documentation of this file.
1#ifndef JAUSTREAMSTATICARAMMGR_H
2#define JAUSTREAMSTATICARAMMGR_H
3
8#include "bitset.h"
9#include <stdint.h>
10
15template <size_t A0>
17public:
19 for (int i = 0; i < A0; i++) {
21 }
22 }
24 bool isStreamUsingAram() { return field_0x4.any(); }
26 JUT_ASSERT(38, ! isStreamUsingAram());
27 for (int i = 0; i < A0; i++) {
28 if (mHeaps[i].isAllocated()) {
29 JASHeap* heap = &mHeaps[0]; // should probably be mHeaps[i] but that doesn't match
30 heap->free();
31 if (!heap) {
32 JUT_ASSERT(47, FALSE);
33 }
34 }
35 }
36 }
37
38protected:
41};
42
47template <size_t MAX_CHUNKS_>
49public:
51 virtual void* newStreamAram(u32* param_0) {
52 for (u32 i = 0; i < field_0x4c; i++) {
53 if (this->field_0x4.test(i)) {
54 continue;
55 }
56 this->field_0x4.set(i, true);
57 *param_0 = this->mHeaps[i].getSize();
58 return this->mHeaps[i].getBase();
59 }
60 return NULL;
61 }
62 virtual bool deleteStreamAram(u32 param_0) {
63 for (u32 i = 0; i < field_0x4c; i++) {
64 if (!this->field_0x4.test(i)) {
65 continue;
66 }
67 if ((uintptr_t)this->mHeaps[i].getBase() != param_0) {
68 continue;
69 }
70 this->field_0x4.reset(i);
71 return true;
72 }
73 return false;
74 }
75 bool isAramReserved() const { return field_0x4c; }
76 void reserveAram(JASHeap* heap, int numReserve, u32 param_2) {
77 JUT_ASSERT(72, ! isAramReserved());
79 if (!heap) {
81 }
82 if (numReserve <= 0) {
83 numReserve = 1;
84 }
85 JUT_ASSERT(83, numReserve <= MAX_CHUNKS);
86 int r27 = param_2 * JASAramStream::getBlockSize();
87 for (int i = 0; i < numReserve; i++) {
88 if (!this->mHeaps[i].alloc(heap, r27)) {
89 break;
90 }
91 field_0x4c = i + 1;
92 }
93 }
94
95private:
96 static const size_t MAX_CHUNKS = MAX_CHUNKS_;
97
99};
100
101#endif /* JAUSTREAMSTATICARAMMGR_H */
static u32 getBlockSize()
Definition JASAramStream.h:129
Definition JASHeapCtrl.h:18
bool free()
Definition JASHeapCtrl.cpp:98
void * getBase()
Definition JASHeapCtrl.h:30
u32 getSize() const
Definition JASHeapCtrl.h:32
Definition JAUStreamAramMgr.h:16
JASHeap mHeaps[A0]
Definition JAUStreamAramMgr.h:40
bool isStreamUsingAram()
Definition JAUStreamAramMgr.h:24
JAUStreamAramMgrBase_()
Definition JAUStreamAramMgr.h:18
std::bitset< A0 > field_0x4
Definition JAUStreamAramMgr.h:39
void releaseAram_JAUStreamAramMgrBase_()
Definition JAUStreamAramMgr.h:25
~JAUStreamAramMgrBase_()
Definition JAUStreamAramMgr.h:23
Definition JAUStreamAramMgr.h:48
bool isAramReserved() const
Definition JAUStreamAramMgr.h:75
void reserveAram(JASHeap *heap, int numReserve, u32 param_2)
Definition JAUStreamAramMgr.h:76
virtual bool deleteStreamAram(u32 param_0)
Definition JAUStreamAramMgr.h:62
static const size_t MAX_CHUNKS
Definition JAUStreamAramMgr.h:96
int field_0x4c
Definition JAUStreamAramMgr.h:98
virtual void * newStreamAram(u32 *param_0)
Definition JAUStreamAramMgr.h:51
JAUStreamStaticAramMgr_()
Definition JAUStreamAramMgr.h:50
Definition bitset.h:84
bool any() const
Definition bitset.h:108
bool test(size_t pos) const
Definition bitset.h:102
void set(size_t pos, bool val)
Definition bitset.h:90
void reset(size_t pos)
Definition bitset.h:96
unsigned long u32
Definition types.h:12
int i
Definition e_pow.c:165
JASHeap * getAramHeap()
Definition JASHeapCtrl.cpp:267
Definition JAIStreamDataMgr.h:19