summaryrefslogtreecommitdiff
path: root/src/heapbar.cpp
blob: 40fefe5f86eb3ffa7c33b0e65787f6b48d528aae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#define GEKKO

#include <common.h>
#include "rvl/mtx.h"
#include "rvl/GXEnum.h"
#include "rvl/GXStruct.h"
#include "rvl/GXTransform.h"
#include "rvl/GXGeometry.h"
#include "rvl/GXDispList.h"
#include "rvl/GXLighting.h"
#include "rvl/GXTev.h"
#include "rvl/GXTexture.h"
#include "rvl/GXCull.h"
#include "rvl/GXPixel.h"
#include "rvl/GXBump.h"
//#include "rvl/GXVert.h"
#include "rvl/vifuncs.h"

extern u32 Global5758;

#define GXPosition3f32(x,y,z) \
	*((volatile float*)0xCC008000) = (x); \
	*((volatile float*)0xCC008000) = (y); \
	*((volatile float*)0xCC008000) = (z);

#define GXColor1u32(x) \
	*((volatile u32*)0xCC008000) = (x);


extern "C" {


void cppGXStart() {
	Mtx44 ortho;
	
	MTXOrtho(ortho, 0, 456, 0, 686, 0.0F, 1.0F);
	GXSetProjection(ortho, GX_ORTHOGRAPHIC);
	
	Mtx identity;
	MTXIdentity(identity);
	
	GXLoadPosMtxImm(identity, GX_PNMTX0);
	
	GXSetNumTevStages(1);
	GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
	GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
	GXSetTevDirect(GX_TEVSTAGE0);
	
	GXSetNumChans(1);
	GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
	
	GXClearVtxDesc();
	GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
	GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
	GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
	GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBX8, 0);
	
	GXSetZMode(GX_TRUE, GX_ALWAYS, GX_TRUE);
}

void cppGXEnd() {
}



float y_positions[] = {
	-1.0f,
	0.0f,
	16.0f,
	32.0f,
};

#define END_AT 48.0f

u32 colours[] = {
	-1,
	0x0000ffff,
	0xff0000ff,
	0xffffffff,
};

u32 col_5758[] = {
	0x00ff00ff,
	0xffff00ff,
	0x00ffffff,
	0xff00ffff
};

void cppProcessHeap(u32 freeSize, u32 heapSize, int heapID, char *name) {
	// get the info needed
	float y_pos = y_positions[heapID];
	u32 colour = colours[heapID];
	
	// width: 686
	
	//OSReport("%s => size %d, free %d\n", name, heapSize, freeSize);
	
	float left = 0;
	float right = ((heapSize - freeSize) * 686.0f) / heapSize;
	float top = y_pos;
	float bottom = y_pos+16;
	
	GXBegin(GX_QUADS, GX_VTXFMT0, 4);
	
	GXPosition3f32(left, top, 0.0);
	GXColor1u32(colour);
	GXPosition3f32(right, top, 0.0);
	GXColor1u32(colour);
	GXPosition3f32(right, bottom, 0.0);
	GXColor1u32(colour);
	GXPosition3f32(left, bottom, 0.0);
	GXColor1u32(colour);
	
	GXEnd();
	
	
	GXBegin(GX_QUADS, GX_VTXFMT0, 16);
	
	for (int i = 0; i < 4; i++) {
		GXPosition3f32(16*i, END_AT, 0.0);
		GXColor1u32(col_5758[i]);
		GXPosition3f32(16*i+16, END_AT, 0.0);
		GXColor1u32(col_5758[i]);
		GXPosition3f32(16*i+16, END_AT+16.0f, 0.0);
		GXColor1u32(col_5758[i]);
		GXPosition3f32(16*i, END_AT+16.0f, 0.0);
		GXColor1u32(col_5758[i]);
	}
	
	GXEnd();
	
	for (int i = 0; i < 4; i++) {
		if (Global5758 & (1 << i)) {
			GXBegin(GX_QUADS, GX_VTXFMT0, 4);
			
			GXPosition3f32(16*i, END_AT+16.0f, 0.0);
			GXColor1u32(0xffffffff);
			GXPosition3f32(16*i+16, END_AT+16.0f, 0.0);
			GXColor1u32(0xffffffff);
			GXPosition3f32(16*i+16, END_AT+24.0f, 0.0);
			GXColor1u32(0xffffffff);
			GXPosition3f32(16*i, END_AT+24.0f, 0.0);
			GXColor1u32(0xffffffff);
			
			GXEnd();
		}
	}
}


};