Main Page | Data Structures | File List | Data Fields | Globals

sprite/sprite.h File Reference

Display manager. More...

#include <stddef.h>
#include <jagdefs.h>
#include <op.h>
#include <memalign.h>
#include <display.h>

Data Structures

struct  animation_chunk
struct  sprite

Defines

#define DISPLAY_DFLT_MAX_SPRITE   256

Functions

spritenew_sprite (int width, int height, int x, int y, depth d, phrase *data)
void set_sprite (sprite *s, int width, int height, int x, int y, depth d, phrase *data)
mblocknew_display (unsigned int max_nb_sprites)
void attach_sprite_to_display_at_layer (sprite *s, display *d, int layer)
void detach_sprite_from_display (sprite *s)
void change_sprite_layer (sprite *s, display *d, int layer)
void sort_display_layer (display *d, int layer, int(*compare)(sprite *s1, sprite *s2))
void display_iter_layer (display *d, int layer, void(*f)(sprite *s))
void display_iter_all_layers (display *d, void(*f)(sprite *s))


Detailed Description

Display manager.


Define Documentation

#define DISPLAY_DFLT_MAX_SPRITE   256
 

Default maximal number of sprites in display.


Function Documentation

void attach_sprite_to_display_at_layer sprite s,
display d,
int  layer
 

Add a sprite to a display at given layer.

Parameters:
s  Address of the sprite
d  Address of the display
layer  Layer where to add the sprite (modulo 16)

void change_sprite_layer sprite s,
display d,
int  layer
 

Change the layer of a sprite in a display.

Parameters:
s  Address of the sprite
d  Address of the display
layer  Layer where to move the sprite (modulo 16)

void detach_sprite_from_display sprite s  ) 
 

Remove a sprite from its display.

Parameters:
s  Address of the sprite

void display_iter_all_layers display d,
void(*)(sprite *s)  f
 

Iterate the given function on every sprite of the display from layer 0 to layer 15.

Parameters:
d  Address of the display
f  Function to iterate

void display_iter_layer display d,
int  layer,
void(*)(sprite *s)  f
 

Iterate the given function on every sprite of the given layer.

Parameters:
d  Address of the display
layer  Layer (modulo 16)
f  Function to iterate

mblock* new_display unsigned int  max_nb_sprites  ) 
 

Creates a new display that can contain at most max_nb_sprites sprite.

The mblock returned has its _mblock::addr pointing to the allocated display.

Parameters:
max_nb_sprites  maximal number of sprites the display can contain. If 0 then the default value of DISPLAY_DFLT_MAX_SPRITE is used.

sprite* new_sprite int  width,
int  height,
int  x,
int  y,
depth  d,
phrase *  data
 

Create a new sprite which is not scaled, not animated, visible and transparent.

Parameters:
width  Width in pixels so that the width in bytes is a multiple of 8
height  Height in pixels
x  X coordinate
y  Y coordinate
d  Depth of the graphical data
data  Address of the graphical data: it should be phrase aligned

void set_sprite sprite s,
int  width,
int  height,
int  x,
int  y,
depth  d,
phrase *  data
 

Initialisation of a sprite.

This can be useful if you want to extend the "class" sprite. It initialises the sprite as function new_sprite.

Parameters:
s  Address of the sprite
width  Width in pixels so that the width in bytes is a multiple of 8
height  Height in pixels
x  X coordinate
y  Y coordinate
d  Depth of the graphical data
data  Address of the graphical data: it should be phrase aligned

void sort_display_layer display d,
int  layer,
int(*)(sprite *s1, sprite *s2)  compare
 

Sort the given layer of the given display according to the given compare function.

The compare function returns a negative (or null) integer if the first sprite is "lesser than or equal to" the second sprite.

The given layer is sorted increasingly. This means that the "least" sprite is displayed first in the layer and the "greatest" one is displayed last.

The sorting algorithm uses O(1) space and O(n log(n)) comparisons (merge sort). It is a stable sort.

Since the sort is made by the 68k while the GPU possibly reads the display, it is safer to make a call to wait_display_refresh before sorting a layer of the current active display.

Parameters:
d  Address of the display
layer  Layer (modulo 16)
compare  Comparison function


Generated on Wed Jan 10 03:11:03 2007 for The Removers Libraries by  doxygen 1.4.4