forked from ps2dev/gsKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbigtex.c
More file actions
120 lines (95 loc) · 2.73 KB
/
Copy pathbigtex.c
File metadata and controls
120 lines (95 loc) · 2.73 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
// ____ ___ | / _____ _____
// | __ | |___/ | |
// |___| ___| | \ __|__ | gsKit Open Source Project.
// ----------------------------------------------------------------------
// Copyright 2004 - Chris "Neovanglist" Gilbert <Neovanglist@LainOS.org>
// Licenced under Academic Free License version 2.0
// Review gsKit README & LICENSE files for further details.
//
// bigtex.c - Example demonstrating gsKit texture operation.
//
#include <gsKit.h>
#include <dmaKit.h>
#include <malloc.h>
#include <gsToolkit.h>
int main(int argc, char *argv[])
{
GSGLOBAL *gsGlobal;
GSTEXTURE bigtex;
u64 Black = GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00);
u64 TexCol = GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00);
float x;
float x2;
int shrinkx;
int shrinkx2;
gsGlobal = gsKit_init_global()
// gsGlobal->DoubleBuffering = GS_SETTING_OFF;
gsGlobal->ZBuffering = GS_SETTING_OFF;
dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
// Initialize the DMAC
dmaKit_chan_init(DMA_CHANNEL_GIF);
gsKit_init_screen(gsGlobal);
bigtex.Width = 640;
bigtex.Height = 480;
bigtex.PSM = GS_PSM_CT24;
bigtex.Filter = GS_FILTER_NEAREST;
bigtex.Delayed = 1;
// gsKit_texture_raw(gsGlobal, &bigtex, "bigtex.raw");
gsKit_texture_bmp(gsGlobal, &bigtex, "bigtex.bmp");
// gsKit_texture_jpeg(gsGlobal, &bigtex, "bigtex.jpg");
x = 0.0f;
x2 = gsGlobal->Width;
shrinkx = 1;
shrinkx2 = 0;
gsKit_mode_switch(gsGlobal, GS_ONESHOT);
while(1)
{
gsKit_clear(gsGlobal, Black);
gsKit_set_clamp(gsGlobal, GS_CMODE_CLAMP);
gsKit_TexManager_bind(gsGlobal, &bigtex);
gsKit_prim_sprite_striped_texture(gsGlobal, &bigtex, x, // X1
// gsKit_prim_sprite_texture(gsGlobal, &bigtex, x, // X1
0.0f, // Y2
0.0f, // U1
0.0f, // V1
x2, // X2
bigtex.Height, // Y2
bigtex.Width, // U2
bigtex.Height, // V2
2,
TexCol);
gsKit_queue_exec(gsGlobal);
gsKit_sync_flip(gsGlobal);
gsKit_TexManager_nextFrame(gsGlobal);
if(shrinkx)
{
if(x < 78.0f)
x += 0.25f;
else
shrinkx = 0;
}
else
{
if(x > 0.0f)
x -= 0.25f;
else
shrinkx = 1;
}
if(shrinkx2)
{
if(x2 < gsGlobal->Width)
x2 += 0.25f;
else
shrinkx2 = 0;
}
else
{
if(x2 > (gsGlobal->Width - 78.0f))
x2 -= 0.25f;
else
shrinkx2 = 1;
}
}
return 0;
}