view sprite.h @ 122:5219bf3d5e71

title_draw
author e085768
date Mon, 27 Jun 2011 19:44:46 +0900
parents 0b65ca27f113
children
line wrap: on
line source

#define FRAME_ANGLE_NORMAL           0
#define FRAME_ANGLE_REVERSE_HORIZON  1
#define FRAME_ANGLE_REVERSE_VERTICAL 2
#define FRAME_ANGLE_ROTATE_180       3

// defines for visible of sprite
#define UNVISIBLE 0
#define VISIBLE   1

#if 0
typedef struct sprite_frame {
    int x;
    int y;
    int w;
    int h;
    int offset_x;
    int offset_y;
    int angle;
    int visible;
    TEXTURE *texture;
} SPRITE_FRAME;

typedef struct sprite_polygon {
    FVECTOR xyz;
    FVECTOR angle;
    int polygon_w;
    int polygon_h;
    int texture_w;
    int texture_h;
    int offset_x;
    int offset_y;
    int r,g,b,a;
    int visible;
    ps2_giftag giftag;
    ps2_dmatag *packet;
} SPRITE_POLYGON;

typedef struct sprite_polygon_head {
    int all_number;
    TEXTURE *texture;
    SPRITE_POLYGON *sprites;  // SPRITE_POLYGON
    char *free_sprites;       // SPRITE_POLYGON
    char *free_packets;
} SPRITE_POLYGON_HEAD;

// sprite_frame's functions
SPRITE_FRAME *create_sprite_frame(int number, TEXTURE *tex);
int draw_sprite_frame(int number, SPRITE_FRAME *sprite);
#define free_sprite_frame free

// sprite_polygon's functions
SPRITE_POLYGON_HEAD *create_sprite_polygon(int number, TEXTURE *tex);
int draw_sprite_polygon(int number, SPRITE_POLYGON_HEAD *sprite);
void free_sprite_polygon(SPRITE_POLYGON_HEAD *s);
int set_packet_sprite_polygon(int number, SPRITE_POLYGON_HEAD *head);
ps2_giftag *get_giftag_sprite_polygon(int number, SPRITE_POLYGON_HEAD *head);
void sprite_polygon_Set_world( void );
#endif

typedef struct {
  /* __u64 rgbaq;
    __u64 rgbaq_addr;
    __u64 st;
    __u64 st_addr;
    __u64 xyz;
    __u64 xyz_addr;
  */
  int x;
} GsPrim;


/*!  
    \ref GS primitive data of a sprite.
    PS2 doesn't have sprite method, so we have to implement it with using 
    a substitute method. Fortunately, PS2 has some powerful methods.
    Then, we use the TRIANGLE_STRIP drawing option.

    TRIANGLE_STRIP takes 4 GsPrim.
*/


typedef struct {
  //ps2_giftag giftag;
  //__u64 prim;
  //__u64 prim_addr;
  GsPrim primData[4];
} GsSpritePacket;


/*!
    \ref sprite's GS packet.
    gs_packet (\ref GsSpritePacket) is an address of head of GS primitive data 
    which contains some sprites.  then, free_add is an address to free gs_packet. 
    gs_packet (\ref ) is aligned at 16byte memory border, bacause GS treats this
    packet data as that unit. so, we have to manage a real address after aligned.
*/
typedef struct {
    GsSpritePacket* gs_packet;
    void* free_addr;
    unsigned char enable_offset;
    unsigned char enable_num;
} SpritePacketHeader;