listpage.c
4.48 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
/*
* This is the handler for the list page. It takes controller input
* and provides Sprites as output and also a return value which says
* what the next page should be.
*/
#include <ultra64.h>
#include "uimain.h"
#include "font.h"
/*
* XXX Some test stuff
*/
static int xpos = 10;
static int ypos = 100;
#define NUM_BMS (24*40)
static Bitmap textBoxBmp[NUM_BMS];
static Gfx textBoxDl[NUM_DL(NUM_BMS)];
extern Font tvfont;
static Bitmap pBmp[1];
static Gfx pDl[NUM_DL(1)];
static Sprite letterP = {0, 0, 0, 0, 1.0, 1.0, 0, 0,
SP_TRANSPARENT, 0, 255, 255, 255, 255,
0, 0, NULL, 0, 1, 1, NUM_DL(NUM_BMS),
15, 128, G_IM_FMT_I, G_IM_SIZ_4b,
pBmp, pDl, NULL};
static Bitmap lBmp[1];
static Gfx lDl[NUM_DL(1)];
static Sprite letterL = {0, 0, 0, 0, 1.0, 1.0, 0, 0,
SP_TRANSPARENT, 0, 255, 255, 255, 255,
0, 0, NULL, 0, 1, 1, NUM_DL(NUM_BMS),
15, 128, G_IM_FMT_I, G_IM_SIZ_4b,
lBmp, lDl, NULL};
static Bitmap aBmp[1];
static Gfx aDl[NUM_DL(1)];
static Sprite letterA = {0, 0, 0, 0, 1.0, 1.0, 0, 0,
SP_TRANSPARENT, 0, 255, 255, 255, 255,
0, 0, NULL, 0, 1, 1, NUM_DL(NUM_BMS),
15, 128, G_IM_FMT_I, G_IM_SIZ_4b,
aBmp, aDl, NULL};
static Bitmap yBmp[1];
static Gfx yDl[NUM_DL(1)];
static Sprite letterY = {0, 0, 0, 0, 1.0, 1.0, 0, 0,
SP_TRANSPARENT, 0, 255, 255, 255, 255,
0, 0, NULL, 0, 1, 1, NUM_DL(NUM_BMS),
15, 128, G_IM_FMT_I, G_IM_SIZ_4b,
yBmp, yDl, NULL};
static Sprite listLine0;
static Sprite listLine1;
static Sprite listLine2;
static Sprite listLine3;
static int localTimer = 0;
static Sprite textBox = {
0,0, /* Position: x,y */
0,0, /* Sprite size in texels (x,y) */
1.0,1.0, /* Sprite Scale: x,y */
0,0, /* Explosion (x,y) */
SP_TRANSPARENT, /* Sprite Attributes */
0x1234, /* Sprite Depth: Z */
255,255,255,255, /* Sprite Coloration: RGBA */
0,0,NULL, /* Color LookUp Table: start_index, length, address */
0,1, /* Sprite Bitmap index: start index, step increment */
NUM_BMS, /* Number of bitmaps */
NUM_DL(NUM_BMS), /* Number of display list locations allocated */
15, 128, /* Sprite Bitmap Height: Used_height, physical height */
G_IM_FMT_I, /* Sprite Bitmap Format */
G_IM_SIZ_4b, /* Sprite Bitmap Texel Size */
textBoxBmp, /* Pointer to bitmaps */
textBoxDl, /* Display list memory */
NULL, /* HACK: dynamic_dl pointer */
};
/*
* Called once - can be used to init sprites, so we don't have to write
* letters every time
*/
int listInit()
{
drawString("p", &tvfont, 1, 1, &letterP);
spScale(&letterP, 2.0, 2.0);
spColor(&letterP, 255, 0, 0, 255);
drawString("l", &tvfont, 1, 1, &letterL);
spScale(&letterL, 2.0, 2.0);
spColor(&letterL, 0, 0, 255, 255);
drawString("a", &tvfont, 1, 1, &letterA);
spScale(&letterA, 2.0, 2.0);
spColor(&letterA, 255, 255, 0, 255);
drawString("y", &tvfont, 1, 1, &letterY);
spScale(&letterY, 2.0, 2.0);
spColor(&letterY, 255, 255, 255, 255);
drawString("(B) Back", &tvfont, 9, 1, &textBox);
spColor(&textBox, 0, 255, 255, 255);
spMove(&textBox, 30, 210);
return 0;
}
/*
* Called every frame with controller event
*/
int listPage(u16 cntrl, Sprite **sp)
{
int shift;
int a;
int myTime;
/*
* Counts frames for time
*/
localTimer++;
localTimer = localTimer % 120;
if (localTimer > 60) {
myTime = 120 - localTimer;
} else {
myTime = localTimer;
}
shift = myTime - 30;
a = shift / 4;
spMove(&letterP, 100, 40);
sp[0] = &letterP;
spMove(&letterL, 120, 40 + a - shift);
sp[1] = &letterL;
spMove(&letterA, 140, 40 + a - shift);
sp[2] = &letterA;
spMove(&letterY, 160, 40);
sp[3] = &letterY;
sp[4] = &textBox;
sp[5] = 0;
if (cntrl & CONT_B) {
return 0;
} else {
/*
* Come back to current page
*/
return 1;
}
}