cursor.c 1.07 KB
#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;
}