forked from 0xGlitchbyte/TinyNightmare64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.c
52 lines (42 loc) · 1.72 KB
/
helper.c
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
/***************************************************************
helper.c
Contains some convenience functions
***************************************************************/
#include <nusys.h>
#include "config.h"
/*==============================
rcp_init
Initializes the RCP before drawing anything.
==============================*/
void rcp_init()
{
// Set the segment register
gSPSegment(glistp++, 0, 0);
// Initialize the RSP and RDP with a display list
gSPDisplayList(glistp++, OS_K0_TO_PHYSICAL(rspinit_dl));
gSPDisplayList(glistp++, OS_K0_TO_PHYSICAL(rdpinit_dl));
}
/*==============================
fb_clear
Initializes the framebuffer and Z-buffer
@param The red value
@param The green value
@param The blue value
==============================*/
void fb_clear(u8 r, u8 g, u8 b)
{
// Clear the Z-buffer
gDPSetDepthImage(glistp++, OS_K0_TO_PHYSICAL(nuGfxZBuffer));
gDPPipeSync(glistp++);
gDPSetCycleType(glistp++, G_CYC_FILL);
gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b,SCREEN_WD, OS_K0_TO_PHYSICAL(nuGfxZBuffer));
gDPSetFillColor(glistp++,(GPACK_ZDZ(G_MAXFBZ,0) << 16 | GPACK_ZDZ(G_MAXFBZ,0)));
gDPFillRectangle(glistp++, 0, 0, SCREEN_WD-1, SCREEN_HT-1);
gDPPipeSync(glistp++);
// Clear the framebuffer
gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, osVirtualToPhysical(nuGfxCfb_ptr));
gDPSetFillColor(glistp++, (GPACK_RGBA5551(r, g, b, 1) << 16 |
GPACK_RGBA5551(r, g, b, 1)));
gDPFillRectangle(glistp++, 0, 0, SCREEN_WD-1, SCREEN_HT-1);
gDPPipeSync(glistp++);
}