video_draw.c
2.6 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
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo.
$RCSfile: video_draw.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:27:21 $
*---------------------------------------------------------------------*/
/*
ディスプレイリストを隠蔽する描画関数。
*/
/* pre-process */
#include "hglobals.h"
#include "hvideo.h"
#include "hsp.h"
/* variables */
static s32 video_DLmode;
static Gfx *_pfrom ,*_pdl;
static Gfx *sp_dlb[2];
/* implmentations */
s32
video_setSprite(Sprite *sp ,s32 xpos,s32 ypos)
{
Gfx *dl,*dl2;
#ifdef DEBUG
if( !_pdl || ((_pdl - _pfrom) > ( DL_BUFSIZE - 1024 )) )
{
osSyncPrintf("video_draw alert :DL limit %d \n",(_pdl - _pfrom));
return 0;
}
#endif
if( video_DLmode != VIDEO_DLMODE_SPRITE )
video_startDLMode(VIDEO_DLMODE_SPRITE);
dl = (Gfx *)video_getDL();
if ( dl )
{
sp->rsp_dl_next = _pdl;
spMove( sp, xpos , ypos );
dl2 = spDraw( sp );
if ( dl2 )
{
gSPDisplayList(dl++,dl2);
if ( video_setDL(dl) ) _pdl = sp->rsp_dl_next;
}
}
return -1;
}
void
video_initSprite(void)
{
s32 i;
extern Gfx heap_sp_dlb[][DL_BUFSIZE];
for(i=0;i<2;i++)
{
sp_dlb[i] = heap_sp_dlb[i];
bzero( (void *)sp_dlb[i],DL_BUFSIZE * 8 );
}
video_clearSprite(0);
}
void
video_clearSprite(s32 cur)
{
_pfrom = (Gfx *)(&sp_dlb[cur][0]);
_pdl = _pfrom;
}
void
video_finishDLMode(void)
{
Gfx *dl;
switch(video_DLmode)
{
case VIDEO_DLMODE_SPRITE:
dl = (Gfx *)video_getDL();
if(dl)
{
spFinish(&dl);
dl--;
video_setDL(dl);
video_DLmode = VIDEO_DLMODE_IDLE;
}
break;
default:
break;
}
}
void
video_startDLMode(s32 mode)
{
Gfx *dl;
if ( video_DLmode != VIDEO_DLMODE_IDLE )
video_finishDLMode() ;
switch(mode)
{
case VIDEO_DLMODE_SPRITE:
dl = (Gfx *)video_getDL();
if(dl){
spInit( &dl );
video_setDL(dl);
video_DLmode = VIDEO_DLMODE_SPRITE;
}
break;
default:
break;
}
}
s32
video_getCurrentDLMode(void)
{
return video_DLmode;
}
s32
video_drawRect(s32 x,s32 y,s32 w,s32 h ,u32 rgba)
{
Gfx *dl,*dl2;
if( try_warning( "video_drawrect :DL limit \n" ,
( _pdl && ((_pdl - _pfrom) < ( DL_BUFSIZE - 1024 ))) ) )
return 0;
if( video_DLmode != VIDEO_DLMODE_DRAWRECT )
video_startDLMode( VIDEO_DLMODE_DRAWRECT );
dl = (Gfx *)video_getDL();
if ( dl )
{
dl2 = spFillRect( _pdl , x,y,x + w ,y + h
,PXL32_R(rgba) ,PXL32_G(rgba), PXL32_B(rgba),PXL32_A(rgba) );
gSPDisplayList( dl++ , _pdl );
if ( video_setDL(dl) ) _pdl = dl2;
}
return -1;
}
/*
*/