gfx.c
3.45 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
#include <assert.h>
#include "gfx.h"
#include "viewer.h"
#include "pagetop.h"
#include "pagegame.h"
#include "pagebind.h"
#include "pagecontrol.h"
#include "pagegpak.h"
#include "pagecpak.h"
#include "status.h"
extern OSMesgQueue *gpSchedCmdQ;
extern GFXInfo gpGfxInfo[];
void initGFX(void)
{
gpGfxInfo[0].msg.gen.type = OS_SC_DONE_MSG;
gpGfxInfo[0].cfb = cfb_16_a;
gpGfxInfo[1].msg.gen.type = OS_SC_DONE_MSG;
gpGfxInfo[1].cfb = cfb_16_b;
/* The Vi manager was started by scheduler by this point in time */
osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON);
}
void createGfxTask(GFXInfo *i)
{
Dynamic *pDynamic;
OSScTask *t;
pDynamic = &i->dp;
gpGfxList = i->dp.glist;
assert((void *)gpGfxList < (void *)&i->msg);
gSPDisplayList(gpGfxList++, rdpinit_dl);
gSPDisplayList(gpGfxList++, rspinit_dl);
gDPPipeSync(gpGfxList++);
gDPSetCycleType(gpGfxList++, G_CYC_FILL);
if (osViGetCurrentMode()==OS_VI_NTSC_HAF1) {
gDPSetColorImage(gpGfxList++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD,
osVirtualToPhysical(i->cfb));
} else if (osViGetCurrentMode()==OS_VI_NTSC_LAN1) {
gDPSetColorImage(gpGfxList++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD/2,
osVirtualToPhysical(i->cfb));
}
gDPSetFillColor(gpGfxList++, (GPACK_RGBA5551(0, 0, 0, 1) << 16 |
GPACK_RGBA5551(0, 0, 0, 1)));
gDPFillRectangle(gpGfxList++, 0, 0, SCREEN_WD-1, SCREEN_HT-1);
gDPPipeSync(gpGfxList++);
switch (gPageNo) {
case PAGE_TOP:
doPageTop();
break;
case PAGE_GAME:
doPageGame();
break;
case PAGE_BIND:
doPageBind();
break;
case PAGE_CONTROL:
doPageControl();
break;
#ifdef PAK_COPY
case PAGE_GPAK:
doPageGpak();
break;
case PAGE_CPAK:
doPageCpak();
break;
#endif
default:
break;
};
/**** Put an end on the top-level display list ****/
gDPFullSync(gpGfxList++);
gSPEndDisplayList(gpGfxList++);
/* Flush the dynamic segment */
osWritebackDCache(&i->dp, (s32)gpGfxList - (s32)&i->dp);
/* build graphics task */
t = &i->task;
t->list.t.data_ptr = (u64 *) pDynamic->glist;
t->list.t.data_size = (s32)(gpGfxList - pDynamic->glist) * sizeof (Gfx);
t->list.t.type = M_GFXTASK;
t->list.t.flags = 0x0;
t->list.t.ucode_boot = (u64 *)rspbootTextStart;
t->list.t.ucode_boot_size = ((s32) rspbootTextEnd - (s32) rspbootTextStart);
t->list.t.ucode = (u64 *) gspFast3DTextStart;
t->list.t.ucode_data = (u64 *) gspFast3DDataStart;
t->list.t.ucode_data_size = SP_UCODE_DATA_SIZE;
t->list.t.dram_stack = (u64 *) dram_stack;
t->list.t.dram_stack_size = SP_DRAM_STACK_SIZE8;
t->list.t.output_buff = (u64 *) 0x0;
t->list.t.output_buff_size = (u64 *) 0x0;
t->list.t.yield_data_ptr = (u64 *) gfxYieldBuf;
t->list.t.yield_data_size = OS_YIELD_DATA_SIZE;
t->next = 0; /* paranoia */
t->flags = (OS_SC_NEEDS_RSP | OS_SC_NEEDS_RDP | OS_SC_LAST_TASK |
OS_SC_SWAPBUFFER);
t->msgQ = &gGfxFrameMsgQ; /* reply to when finished */
t->msg = (OSMesg)&i->msg; /* reply with this message */
t->framebuffer = (void *)i->cfb;
#ifndef _FINALROM
t->totalTime = 0;
#endif
osSendMesg(gpSchedCmdQ, (OSMesg) t, OS_MESG_BLOCK);
}