cursor.c
1.07 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
#include <ultra64.h>
#include <ultralog.h>
#include <assert.h>
#include "cursor.h"
#include "crsr_sprite.h"
static CrsrObj cursor;
extern Gfx *glistp;
void
Crsr_Init (void)
{
cursor.x = kCursorOrigin_x;
cursor.y = kCursorOrigin_y;
cursor.sprite = &crsr_sprite;
cursor.sprite->rsp_dl_next = cursor.sprite->rsp_dl; /* This is being done in spgame app. */
}
void
Crsr_Draw (Dynamic *pDynamic)
{
Gfx *dl;
cursor.sprite->rsp_dl_next = cursor.sprite->rsp_dl;
spMove (cursor.sprite, cursor.x, cursor.y);
dl = spDraw (cursor.sprite);
gSPDisplayList (glistp++, dl);
}
void
Crsr_SetDeltaCoords (int dX, int dY)
{
/*PRINTF("x:%d dX:%d y:%d dY:%d\n", cursor.x, dX, cursor.y, dY);*/
cursor.x += dX;
if (cursor.x >= SCREEN_WD-20)
cursor.x = SCREEN_WD -21;
if (cursor.x < 0)
cursor.x = 0;
cursor.y += dY;
if (cursor.y >= SCREEN_HT-20)
cursor.y = SCREEN_HT - 21;
if (cursor.y < 0)
cursor.y = 0;
}
void
Crsr_GetCoords (int *pX, int *pY)
{
*pX = cursor.x;
*pY = cursor.y;
}