graphics.c
3 KB
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
/*======================================================================*/
/* NuSYS high resolution sample */
/* graphics.c */
/* */
/* Copyright (C) 1997, NINTENDO Co,Ltd. */
/* 97/12/08 Created by Kensaku Ohki(SLANP) */
/*======================================================================*/
#include <nusys.h>
#include <PR/gs2dex.h>
#include "localdef.h"
#define SCREEN_SIZE_LOW 0
#define SCREEN_SIZE_HIGH 1
#define GFX_LIST_NUM 4
#define GFX_LIST_SIZE 2048
NUContData contData[4];
typedef struct st_Display {
u32 width;
u32 high;
} ScreenSize;
ScreenSize screen[] = {
{ 320, 240},
{ 640, 480}
};
Gfx rdpInit_dl[] = {
gsDPPipeSync(),
gsDPPipelineMode(G_PM_1PRIMITIVE),
gsDPSetTextureLOD(G_TL_TILE),
gsDPSetTextureLUT(G_TT_NONE),
gsDPSetTextureDetail(G_TD_CLAMP),
gsDPSetTexturePersp(G_TP_NONE),
gsDPSetTextureFilter(G_TF_BILERP),
gsDPSetTextureConvert(G_TC_FILT),
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
gsDPSetCombineKey(G_CK_NONE),
gsDPSetAlphaCompare(G_AC_NONE),
gsDPSetColorDither(G_CD_DISABLE),
gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0,640, 480),
gsSPEndDisplayList(),
};
Gfx gfxListBuf[GFX_LIST_NUM][GFX_LIST_SIZE];
u32 gfxListCnt = 0;
Gfx* gfxListPtr;
Gfx* gfxListStartPtr;
extern u32 mainNo;
/*----------------------------------------------------------------------*/
/* フレームバッファのクリア */
/* IN: **glist_ptr */
/* screen スクリーンサイズ */
/* SCREEN_SIZE_LOW 0 */
/* SCREEN_SIZE_HIGH 1 */
/* RET: 無し */
/*----------------------------------------------------------------------*/
void gfxClearCfb(u32 size)
{
ScreenSize* screenPtr;
screenPtr = &screen[size];
gSPSegment(gfxListPtr++, 0, 0x0);
gDPSetCycleType(gfxListPtr++, G_CYC_FILL);
/* Zバッファのクリア */
gDPSetDepthImage(gfxListPtr++, OS_K0_TO_PHYSICAL(nuGfxZBuffer));
gDPSetColorImage(gfxListPtr++, G_IM_FMT_RGBA, G_IM_SIZ_16b,
screenPtr->width,
OS_K0_TO_PHYSICAL(nuGfxZBuffer));
gDPSetFillColor(gfxListPtr++,(GPACK_ZDZ(G_MAXFBZ,0) << 16 |
GPACK_ZDZ(G_MAXFBZ,0)));
gDPFillRectangle(gfxListPtr++, 0, 0, screen->width-1, screenPtr->high-1);
gDPPipeSync(gfxListPtr++);
gDPSetColorImage(gfxListPtr++, G_IM_FMT_RGBA, G_IM_SIZ_16b,
screenPtr->width,
OS_K0_TO_PHYSICAL(nuGfxCfb_ptr));
gDPSetFillColor(gfxListPtr++, (GPACK_RGBA5551(0, 0, 0, 1) << 16
| GPACK_RGBA5551(0, 0, 0, 1)));
gDPFillRectangle(gfxListPtr++, 0, 0,
screenPtr->width-1, screenPtr->high - 1);
gDPPipeSync(gfxListPtr++);
}
/*----------------------------------------------------------------------*/
/* ディスプレイリストバッファの変更 */
/* IN: 無し */
/* RET: ディスプレイリストバッファのポインタ */
/*----------------------------------------------------------------------*/
void gfxListBufferChange(void)
{
gfxListStartPtr = &gfxListBuf[gfxListCnt][0];
gfxListPtr = gfxListStartPtr;
gfxListCnt++;
gfxListCnt %= GFX_LIST_NUM;
return;
}