graphics.c
6.09 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*======================================================================*/
/* 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}
};
uObjBg objBgH = {
0, 640<<2, 0, 640<<2,
0, 480<<2, 0, 480<<2,
(u64*)NULL,
G_BGLT_LOADTILE, /* imageLoad */
G_IM_FMT_RGBA, /* imageFmt */
G_IM_SIZ_16b, /* imageSiz */
0, /* imagePal */
0 /* imageFlip */
};
uObjBg objBgL = {
0, 320<<2, 0, 320<<2,
0, 240<<2, 0, 240<<2,
(u64*)NULL,
G_BGLT_LOADTILE, /* imageLoad */
G_IM_FMT_RGBA, /* imageFmt */
G_IM_SIZ_16b, /* imageSiz */
0, /* imagePal */
0 /* imageFlip */
};
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 spriteInit_dl[] = {
gsDPPipeSync(),
gsDPSetTexturePersp(G_TP_NONE),
gsDPSetTextureLOD(G_TL_TILE),
gsDPSetTextureLUT(G_TT_NONE),
gsDPSetTextureConvert(G_TC_FILT),
gsDPSetAlphaCompare(G_AC_THRESHOLD),
gsDPSetBlendColor(0, 0, 0, 0x01),
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
gsSPEndDisplayList(),
};
Gfx gfxListBuf[GFX_LIST_NUM][GFX_LIST_SIZE];
u32 gfxListCnt = 0;
Gfx* gfxListPtr;
Gfx* gfxListStartPtr;
u32 hireso;
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;
}
/*----------------------------------------------------------------------*/
/* ハイレゾ表示 */
/* IN: taskNum タスク残り数 */
/* RET: 無し */
/*----------------------------------------------------------------------*/
void graphic(u32 taskNum)
{
uObjBg* objBgPtr;
/* タスクが終了していない場合は,処理しない */
if(nuGfxTaskSpool) return;
/* ディスプレイリストバッファをセット */
gfxListBufferChange();
gSPDisplayList(gfxListPtr++, rdpInit_dl);
/* 画面のクリアー */
gfxClearCfb(hireso);
/* end top-level display list */
gDPFullSync(gfxListPtr++);
gSPEndDisplayList(gfxListPtr++);
nuGfxTaskStart(gfxListStartPtr, gfxListPtr - gfxListStartPtr,
NU_GFX_UCODE_S2DEX,NU_SC_NOSWAPBUFFER);
gfxListBufferChange();
gSPDisplayList(gfxListPtr++, rdpInit_dl);
gSPDisplayList(gfxListPtr++, spriteInit_dl);
gDPSetRenderMode(gfxListPtr++, G_RM_SPRITE, G_RM_SPRITE2);
gDPSetCycleType(gfxListPtr++, G_CYC_COPY);
gDPSetTextureFilter(gfxListPtr++, G_TF_POINT);
if(hireso == 0){
objBgPtr = &objBgL;
} else {
objBgPtr = &objBgH;
}
objBgPtr->b.imagePtr = (u64*)_codeSegmentEnd;
guS2DInitBg(objBgPtr);
objBgPtr->s.frameX = 1<<2;
objBgPtr->s.frameY = 1<<2;
gSPBgRectCopy(gfxListPtr++, objBgPtr);
/* end top-level display list */
gDPFullSync(gfxListPtr++);
gSPEndDisplayList(gfxListPtr++);
nuGfxTaskStart(gfxListStartPtr, gfxListPtr - gfxListStartPtr,
NU_GFX_UCODE_S2DEX,NU_SC_NOSWAPBUFFER);
gfxListBufferChange();
nuDebConDisp(NU_SC_NOSWAPBUFFER);
nuDebTaskPerfBar1(1, 210*(hireso+1), NU_SC_SWAPBUFFER);
/* コントローラデータの読み込み */
nuContDataGetExAll(contData);
if(contData[0].trigger & A_BUTTON){
nuGfxFuncRemove();
if(hireso == 0){
mainNo = 0;
} else {
mainNo = 1;
}
}
}