Home  ·  Downloads  ·  Your Account  ·  Submit News
Documentation Homepage
HAMLib reference
Back to HAM Homepage


Sprite Manipulation Functions


Functions

void ham_ResetObj ()
 Reinitialize the complete Obj (Sprite) system.

u8 ham_CreateObjFromGfxSlot (u16 slot, u16 obj_shape, u16 obj_size, u16 obj_mode, u16 col_mode, u16 pal_no,u16 mosaic, u16 hflip, u16 vflip, u16 prio, u16 dbl_size, u16 x, u16 y)
 advanced: create a new OBJ from Existing GFX slot

u8 ham_CreateObj (void *src, u16 obj_shape, u16 obj_size, u16 obj_mode, u16 col_mode, u16 pal_no,u16 mosaic, u16 hflip, u16 vflip, u16 prio, u16 dbl_size, u16 x, u16 y)
 create a new Sprite in HAM

u8 ham_CreateObjFromBg (u8 bgno, u32 bg_tileno_x, u32 bg_tileno_y, u16 obj_shape, u16 obj_size, u32 erase_bg, u32 tileno_filler)
 advanced: create a Sprite from a piece of a BG Map

u16 ham_CreateObjGfx (void *src, u16 obj_shape, u16 obj_size, u16 col_mode)
 advanced: create new sprite GFX in OBJ memory for later use

void ham_DeleteObjGfx (u16 slotno)
 advanced: deallocate previously allocated GFX from a slot

void ham_SetObjBefore (u8 objno, u8 objno_target)
 change the Z Order of Sprites amongst each other

void ham_UpdateObjGfx (u8 objno, void *src)
 replace the graphics of an existing Sprite with new ones

u16 ham_GetObjGfxSlot (u8 objno)
 advanced: retrieve the graphics slot of a sprite

u8 ham_GetObjPal16 (u8 objno)
 retrieve the palette number of a 16col Sprite

void ham_SetObjGfxSlot (u8 objno, u16 slotno, u8 palno)
 advanced: change GFX slot number of sprite to other existing block

void ham_UpdateObjPal16 (u8 objno, u8 pal_no)
 Update palette number of a 16 color sprite

void ham_DeleteObj (u8 entryno)
 Unload and delete an initialized Sprite

u8 ham_CloneObj (u8 objno, u16 x, u16 y)
 Clone an existing Sprite

void ham_SetObjMode (u8 objno, u16 obj_mode)
 Set a Sprites OBJ Mode

void ham_SetObjX (u8 objno, u16 x)
 Set a Sprites X Position on the screen

void ham_SetObjY (u8 objno, u16 y)
 Set a Sprites Y Position on the screen

void ham_SetObjXY (u8 objno, u16 x, u16 y)
 Set a Sprites X and Y Position on the screen

void ham_SetObjMosaic (u8 objno, u8 val)
 Enable Mosaic Mode for a sprite

void ham_SetObjDblSize (u8 objno, u8 val)
 set douvle size Mode for Rotating Sprites

void ham_SetObjHFlip (u8 objno, u8 val)
 apply horizontal flipping for a Sprite

void ham_SetObjVFlip (u8 objno, u8 val)
 apply vertical flipping for a Sprite

void ham_SetObjPrio (u8 objno, u8 val)
 Set the BG priority for a Sprite

void ham_SetObjVisible (u8 objno, u8 val)
 Hide/Display an initialized Sprite

void ham_SetObjRotEnable (u8 objno, u8 val)
 Enable a Sprite for Rotation

void ham_SetObjRotSetSelect (u8 objno, u8 val)
 Assign a Sprite to a Rotation Set

void ham_CopyObjToOAM ()
 Commit all changes in HAM Sprite System to the GBA Hardware

u32 ham_GetObjAvailable ()
 Return the number of available Sprites


Detailed Description

This section is about Sprites in HAMlib. Sprites are little, movable, rectangular screen areas that can be filled with bitmap graphics. The sprite system on the GBA is very advanced, and has lots of features. I have tried to make access to all these features as easy as possible, but it is still a bit hard to get used to.

In HAMlib, sprites are often referred to as OBJ.

The core features of the GBA's Sprite system are:

Most important functions for beginners: ham_CreateObj() , ham_SetObjXY() , ham_CloneObj()

Function Documentation

u8 ham_CloneObj u8    objno,
u16    x,
u16    y
 

Clone an existing Sprite

Parameters:
objno  The OBJ number of which you want to clone
x  X position of the cloned sprite (0..511)
y  Y position of the cloned sprite (0..255)
Will return the number of a new sprite with exactly the same attributes as the OBJ number specified as the source sprite to clone. The cool thing is that this sprite will need NO additional VideoRAM, as it is reusing the graphics that have been allocated for the OBJ number given as the source to clone from. Notice that after cloning, HAM will internally keep track of how many times the VRAM data has been referenced, and only free the VRAM when all sprites using this graphics slot have been deleted by ham_DeleteObj() ( or, more advanced, ham_DeleteObjGfx() )

See also: ham_CreateObj() ham_CreateObjFromGfxSlot() ham_DeleteObj() ham_DeleteObjGfx() ham_CopyObjToOAM()

void ham_CopyObjToOAM  
 

Commit all changes in HAM Sprite System to the GBA Hardware

This function will update all changes made to the HAM Sprite System into the GBA hardware. You will only see your changes if you call this. Usually, you should call this in a vertical blank Interrupt, see ham_StartIntHandler() for more information about this.

See also: ham_CreateObj()

u8 ham_CreateObj void *    src,
u16    obj_shape,
u16    obj_size,
u16    obj_mode,
u16    col_mode,
u16    pal_no,
u16    mosaic,
u16    hflip,
u16    vflip,
u16    prio,
u16    dbl_size,
u16    x,
u16    y
 

create a new Sprite in HAM

Parameters:
src  A pointer to the gfx data that HAM should use when creating the sprite.
obj_shape  determines the shape of the sprite in pixels (see below)
obj_size  determines the size of the sprite in pixels (see below)
    size             0           1          2          3
    ---------+--------------------------------------------
    shape 0  |    8  * 8      16 * 16    32 * 32    64 * 64
          1  |    16 * 8      32 * 8     32 * 16    64 * 32
          2  |    8  * 16     8  * 32    16 * 32    32 * 64
          3  |                prohibited value
    
You can also use the following defines for specifying the shape and size as a single parameter:
  • OBJ_SIZE_8X8
  • OBJ_SIZE_16X16
  • OBJ_SIZE_32X32
  • OBJ_SIZE_64X64
  • OBJ_SIZE_16X8
  • OBJ_SIZE_32X8
  • OBJ_SIZE_32X16
  • OBJ_SIZE_64X32
  • OBJ_SIZE_8X16
  • OBJ_SIZE_8X32
  • OBJ_SIZE_16X32
  • OBJ_SIZE_32X64
Parameters:
obj_mode  The mode the object will be displayed with. This can be:
  • OBJ_MODE_NORMAL (or simply 0): This displays the sprite normally
  • OBJ_MODE_SEMITRANSPARENT : This will apply special fx to the obj, see the special FX functions for more information. (under construction)
  • OBJ_MODE_OBJWINDOW: This will assign this sprite to be a window at all the spots that are non-zero. See ham_CreateWin()
Parameters:
col_mode  The color mode the OBJ will operate with
Parameters:
pal_no  Choose one of the 16 color palettes ( \e0-15 ) when OBJ is in 16 color col_mode , otherwise set to 0
mosaic  Support Mosaic for this OBJ ( 0=off,1=on )
hflip  Turn on horizontal flipping for this OBJ ( 0=off,1=on )
vflip  Turn on vertical flipping for this OBJ ( 0=off,1=on )
prio  sprite priority to background (0-3) 0 is the highest priority, and means that your Sprite is shown in front of the highest prio BG. 3 is the lowest priority, and mean it is shown in front of the BG with priority 3. See also ham_InitBg()
dbl_size  Turn on double size display for this OBJ ( 0=off,1=on ) . This means that when later rotating this sprite, the edges of the sprite will not be cut off, because the sprite has double the display region reserved for it. Note that rendering sprites this way takes double the time.
x  Initial X position of the sprite on GBA display ( 0-511 )
y  Initial Y position of the sprite on GBA display ( 0-255 )
This function returns a handle of a completely operating OBJ (an objno), that can be used in subsequent calls in the HAM sprite system.

Note that this Sprite will not show up on the GBA screen until you run ham_CopyObjToOAM() .

See also: ham_CloneObj() , ham_DeleteObj() , ham_SetObjXY() , ham_GetObjGfxSlot() ham_CopyObjToOAM()

u8 ham_CreateObjFromBg u8    bgno,
u32    bg_tileno_x,
u32    bg_tileno_y,
u16    obj_shape,
u16    obj_size,
u32    erase_bg,
u32    tileno_filler
 

advanced: create a Sprite from a piece of a BG Map

Parameters:
bgno  The BG number (0-3) where we want to retrieve the Sprite Gfx from.
bg_tileno_x  The X offset in tiles (8 pixel chunks) where we want to start grabbing the sprite
bg_tileno_y  The Y offset in tiles (8 pixel chunks) where we want to start grabbing the sprite
obj_shape  determines the shape of the sprite in pixels (see below)
obj_size  determines the size of the sprite in pixels (see below)
    size             0           1          2          3
    ---------+--------------------------------------------
    shape 0  |    8  * 8      16 * 16    32 * 32    64 * 64
          1  |    16 * 8      32 * 8     32 * 16    64 * 32
          2  |    8  * 16     8  * 32    16 * 32    32 * 64
          3  |                prohibited value
    
You can also use the following defines for specifying the shape and size as a single parameter:
  • OBJ_SIZE_8X8
  • OBJ_SIZE_16X16
  • OBJ_SIZE_32X32
  • OBJ_SIZE_64X64
  • OBJ_SIZE_16X8
  • OBJ_SIZE_32X8
  • OBJ_SIZE_32X16
  • OBJ_SIZE_64X32
  • OBJ_SIZE_8X16
  • OBJ_SIZE_8X32
  • OBJ_SIZE_16X32
  • OBJ_SIZE_32X64
Parameters:
erase_bg  Set this to 1 if you want the map to be filled with a specific tile. If you do not want the BG to change, leave it at 0
tileno_filler  If you set erase_bg to 1, this parameter contains the tile number you want to set on the map instead of the original tiles. Does not do anything if erase_bg is 0.
This function will create a new Sprite from a section of a BG. It will then copy the relevant BG data into the sprite VRAM and initialize a new Sprite. It will then return it's number, like ham_CreateObj()

WARNING: This function currently assumes that your BG and OBJ palette are the same. It currently does NOT support automatic palette switching/altering. This means, if you have different palettes in OBJ and BG, your graphics might look weird after creating a sprite with this function.

See also: ham_CreateObjFromGfxSlot() , ham_SetObjGfxSlot() , ham_GetObjGfxSlot() , ham_DeleteObjGfx()

u8 ham_CreateObjFromGfxSlot u16    slot,
u16    obj_shape,
u16    obj_size,
u16    obj_mode,
u16    col_mode,
u16    pal_no,
u16    mosaic,
u16    hflip,
u16    vflip,
u16    prio,
u16    dbl_size,
u16    x,
u16    y
 

advanced: create a new OBJ from Existing GFX slot

Parameters:
slot  The gfx slot previously retrieved from another OBJ using ham_GetObjGfxSlot()
obj_shape  determines the shape of the sprite in pixels (see below)
obj_size  determines the size of the sprite in pixels (see below)
    size             0           1          2          3
    ---------+--------------------------------------------
    shape 0  |    8  * 8      16 * 16    32 * 32    64 * 64
          1  |    16 * 8      32 * 8     32 * 16    64 * 32
          2  |    8  * 16     8  * 32    16 * 32    32 * 64
          3  |                prohibited value
    
obj_mode  The mode the object will be displayed with. This can be:
  • OBJ_MODE_NORMAL (or simply 0): This displays the sprite normally
  • OBJ_MODE_SEMITRANSPARENT : This will apply special fx to the obj, see the special FX functions for more information. (under construction)
  • OBJ_MODE_OBJWINDOW: This will assign this sprite to be a window at all the spots that are non-zero. See ham_CreateWin()
Parameters:
col_mode  The color mode the OBJ will operate with
Parameters:
pal_no  Choose one of the 16 color palettes ( \e0-15 ) when OBJ is in 16 color col_mode , otherwise set to 0
mosaic  Support Mosaic for this OBJ ( 0=off,1=on )
hflip  Turn on horizontal flipping for this OBJ ( 0=off,1=on )
vflip  Turn on vertical flipping for this OBJ ( 0=off,1=on )
prio  sprite priority to background (0-3) 0 is the highest priority, and means that your Sprite is shown in front of the highest prio BG. 3 is the lowest priority, and mean it is shown in front of the BG with priority 3. See also ham_InitBg()
dbl_size  Turn on double size display for this OBJ ( 0=off,1=on ) . This means that when later rotating this sprite, the edges of the sprite will not be cut off, because the sprite has double the display region reserved for it. Note that rendering sprites this way takes double the time.
x  Initial X position of the sprite on GBA display ( 0-511 )
y  Initial Y position of the sprite on GBA display ( 0-255 )
This is a pretty advanced function and should only be used with great care. What it basically does is to create a new OBJ without creating new graphics along with it. It is in a sense similar to cloning an OBJ (see ham_CloneObj() ) , but has much more flexibility. You first need to know the exact graphics slot (which is basically the position of the graphics data in OBJ VRAM) that your OBJ will use. You can either get the location of an existing sprite by calling ham_GetObjGfxSlot() , or use ham_CreateObjGfx() to create just a set of graphics data before, and feed this function with the slot number.

An example where this would be useful is when you have a puzzle game that has 3 different colored gems, that are used a lot of times. You could then upload the GFX for these three gems, and create sprites from these GFX without the need of reloading them. You could in addition change the color of the gem by pointing it to new GFX later using ham_SetObjGfxSlot() . Confused? :-)

This function returns a handle of a completely operating OBJ (an objno), that can be used in subsequent calls in the HAM sprite system.

See also: ham_CreateObj() , ham_CloneObj() , ham_CreateObjGfx() , ham_SetObjGfxSlot() , ham_GetObjGfxSlot() , ham_DeleteObjGfx() ham_CopyObjToOAM()

u16 ham_CreateObjGfx void *    src,
u16    obj_shape,
u16    obj_size,
u16    col_mode
 

advanced: create new sprite GFX in OBJ memory for later use

Parameters:
src  A pointer to the gfx data that HAM should use for copying the sprite data into OBJ VRAM.
obj_shape  determines the shape of the sprite in pixels (see below)
obj_size  determines the size of the sprite in pixels (see below)
    size             0           1          2          3
    ---------+--------------------------------------------
    shape 0  |    8  * 8      16 * 16    32 * 32    64 * 64
          1  |    16 * 8      32 * 8     32 * 16    64 * 32
          2  |    8  * 16     8  * 32    16 * 32    32 * 64
          3  |                prohibited value
    
col_mode  The color mode the OBJ will operate with
This function will allocate a graphics slot in OBJ VRAM for the sprite specified in the parameters, and copy these graphics into the slot. It will then return the slot for later use with functions such as ham_CreateObjFromGfxSlot() or ham_SetObjGfxSlot() . This is a rather advanced function, please make sure you know what you are doing when uploading sprite gfx without creating actual sprites.

See also: ham_CreateObjFromGfxSlot() , ham_SetObjGfxSlot() , ham_GetObjGfxSlot() , ham_DeleteObjGfx() ham_CopyObjToOAM()

void ham_DeleteObj u8    entryno
 

Unload and delete an initialized Sprite

Parameters:
entryno  The OBJ number of which you want to delete
Delete a Sprite previously created by a call to ham_CreateObj() , ham_CloneObj() or similar calls. Attention: if multiple Sprites use the same graphics (for example when cloning the sprite 10 times and then only deleting 1) the graphics will not get freed, but the sprite number supplied will be available for new OBJ creation again.

See also: ham_CreateObj() ham_CreateObjFromGfxSlot() ham_CloneObj()

void ham_DeleteObjGfx u16    slotno
 

advanced: deallocate previously allocated GFX from a slot

Parameters:
slotno  The GFX Slot Number previously retrieved by a ham_CreateObjGfx() or similar call
This function will, despite its name, not neccessarily delete the graphics and make that memory available for new sprites, but it will check if other sprites are still using this slot. If the slot is unused, the memory will be freed and the function returns. If sprites are still using the slot, the reference count for that slot will decrease.

be very careful: calling this function when sprites are still using the gfx is dangerous, and calling it multiple times for a block can result in the sprite graphics getting deleted before all sprites are finished using it.

This is a rather advanced function, please make sure you know what you are doing when deleting sprite gfx without deleting actual sprites.

See also: ham_CreateObjFromGfxSlot() , ham_SetObjGfxSlot() , ham_GetObjGfxSlot() , ham_DeleteObjGfx()

u32 ham_GetObjAvailable  
 

Return the number of available Sprites

This function will return the number of sprites that are currently available (not yet used).

See also: ham_CreateObj()

u16 ham_GetObjGfxSlot u8    objno
 

advanced: retrieve the graphics slot of a sprite

Parameters:
objno  The OBJ number of which you want to retrieve the graphics slot
In order to relink sprites with existing graphics data from other sprites after they have both been created, you need a way to get the location of the GFX in OBJ VRAM. This function gives you this information. It can then be used in other functions like ham_SetObjGfxSlot() or ham_CreateObjFromGfxSlot()

See also: ham_SetObjGfxSlot() , ham_CreateObjFromGfxSlot() ham_CopyObjToOAM()

u8 ham_GetObjPal16 u8    objno
 

retrieve the palette number of a 16col Sprite

Parameters:
objno  The OBJ number of which you want to retrieve palette number
This function returns the currently used Palette Number (0-15) of a 16 color sprite.

See also: ham_SetObjPal16()

void ham_ResetObj  
 

Reinitialize the complete Obj (Sprite) system.

This function will reset the Sprite system of HAMlib to its initial state. It will clear all sprite graphics, remove all sprite assignments and commit the changes to the hardware. Calling this results in the initial state of the OBJ system.

See also: ham_CreateObj() ham_DeleteObj() ham_ResetBg()

void ham_SetObjBefore u8    objno,
u8    objno_target
 

change the Z Order of Sprites amongst each other

Parameters:
objno  The OBJ number you want to move in front of another one
objno_target  The Target OBJ number our OBJ is to be set in front of
This function is used to modify the order of Sprites (OBJ's). By default, the sprites are sorted by time of creation, so if you create Sprite A, then Sprite B, Sprite A will be shown in front of Sprite A. The OBJs number is the value returned by ham_CreateObj() , and is not strictly related to the priority of the sprite. So, in order to make Sprite B show before sprite A, call this function like ham_SetObjBefore(B,A)

See also: ham_SetObjXY() , ham_SetObjPrio()

void ham_SetObjDblSize u8    objno,
u8    val
 

set douvle size Mode for Rotating Sprites

Parameters:
objno  The OBJ number of which you want to modify
val  0 = no double size 1 = activate double size
Enables or disables the extra space around a sprite to avoid clipping.

See also: ham_CreateObj() ham_SetObjVFlip() ham_CopyObjToOAM()

void ham_SetObjGfxSlot u8    objno,
u16    slotno,
u8    palno
 

advanced: change GFX slot number of sprite to other existing block

Parameters:
objno  The OBJ number of which you want to change the GFX slot number
slotno  The new slot number the Sprite should use for its GFX slot
palno  In case the GFX is 16colors, you can specify the palette number here, otherwise set to 0
Sets the OBJ to a new GFX slot. Using this funciton , you can assign a sprite the GFX data from another existing sprite. You can get the Slot Number from any existing Sprite with ham_GetObjGfxSlot().

See also: ham_GetObjGfxSlot()

void ham_SetObjHFlip u8    objno,
u8    val
 

apply horizontal flipping for a Sprite

Parameters:
objno  The OBJ number of which you want to modify
val  0 = no flip 1 = flip
Enables or disables the horizontal flipping of the specified Sprite.

See also: ham_CreateObj() ham_SetObjVFlip() ham_CopyObjToOAM()

void ham_SetObjMode u8    objno,
u16    obj_mode
 

Set a Sprites OBJ Mode

Parameters:
objno  The OBJ number of which you want to modify
obj_mode  - OBJ_MODE_NORMAL (or simply 0): This displays the sprite normally
  • OBJ_MODE_SEMITRANSPARENT : This will apply special fx to the obj, see the special FX functions for more information. (under construction)
  • OBJ_MODE_OBJWINDOW: This will assign this sprite to be a window at all the spots that are non-zero. See ham_CreateWin()
See also: ham_CreateObj()

void ham_SetObjMosaic u8    objno,
u8    val
 

Enable Mosaic Mode for a sprite

Parameters:
objno  The OBJ number of which you want to modify
val  0 = no mosaic 1 = mosaic enable
Enables or disables the mosaic mode of the specified Sprite.

See also: ham_CreateObj() ham_CopyObjToOAM()

void ham_SetObjPrio u8    objno,
u8    val
 

Set the BG priority for a Sprite

Parameters:
objno  The OBJ number of which you want to modify
val  Specify the priority against the BGs (0..3)
  • 0 = in front of all layers (topmost)
  • 1 = in front of BG layers priority = 0
  • 2 = in front of BG layers with priority < 1
  • 3 = in front of BG layers with priority < 2
will place the Sprite in a certain layer, in order to hide an object behind a BG layer for example. you can Set this to 0 - 3, where 0 is in front of everything else, and 3 in front of the lowest priority BG layer. putting sprites behind all 4 BG layers is not supported.

See also: ham_CreateObj() ham_InitBg() ham_CopyObjToOAM()

void ham_SetObjRotEnable u8    objno,
u8    val
 

Enable a Sprite for Rotation

Parameters:
objno  The OBJ number of which you want to modify
val  0 = object is not in rotation mode 1 = object will be in rotation mode using the rotation set specified by the ham_SetObjRotSetSelect() function
Will enable Rotation and Scaling for a Sprite. You need to specify one of the 32 available (0..31) Rotation Sets this sprite will use (also together with other Sprites using the same set) using ham_SetObjRotSetSelect() in order to assign the sprite. After that, you can use ham_RotObjDefineSet() to modify the angle and zooming of the sprites assigned to the Rotation Set.

See also: ham_SetObjRotSetSelect() ham_CopyObjToOAM()

void ham_SetObjRotSetSelect u8    objno,
u8    val
 

Assign a Sprite to a Rotation Set

Parameters:
objno  The OBJ number of which you want to assign to a Rotation Set
val  number of the Rotation Set (0..31)
This will assign the Rotation Set the Srpite specified should use from now on. For more information, see the documentation of ham_SetObjRotEnable()

See also: ham_SetObjRotEnable() ham_RotObjDefineSet()

void ham_SetObjVFlip u8    objno,
u8    val
 

apply vertical flipping for a Sprite

Parameters:
objno  The OBJ number of which you want to modify
val  0 = no flip 1 = flip
Enables or disables the vertical flipping of the specified Sprite.

See also: ham_CreateObj() ham_SetObjHFlip() ham_CopyObjToOAM()

void ham_SetObjVisible u8    objno,
u8    val
 

Hide/Display an initialized Sprite

Parameters:
objno  The OBJ number of which you want to modify
val  0 = object will no more be visible 1 = object is visible (default)
See also: ham_CreateObj() ham_CopyObjToOAM()

void ham_SetObjX u8    objno,
u16    x
 

Set a Sprites X Position on the screen

Parameters:
objno  The OBJ number of which you want to position
x  The desired X value (0..511)
Sets the sprite specified by objno to the X coordinate specified. Note if you set it very far right, it will roll back in on the left side of the display.

See also: ham_SetObjXY() ham_SetObjY() ham_CopyObjToOAM()

void ham_SetObjXY u8    objno,
u16    x,
u16    y
 

Set a Sprites X and Y Position on the screen

Parameters:
objno  The OBJ number of which you want to position
x  The desired X value (0..511)
y  The desired Y value (0..255)
Sets the sprite specified by objno to the X and Y coordinate specified. See the functions below for more information.

See also: ham_SetObjXY() ham_SetObjY() ham_CopyObjToOAM()

void ham_SetObjY u8    objno,
u16    y
 

Set a Sprites Y Position on the screen

Parameters:
objno  The OBJ number of which you want to position
y  The desired Y value (0..255)
Sets the sprite specified by objno to the Y coordinate specified. Note if you set it very far down, it will roll back in on the top of the display.

See also: ham_SetObjXY() ham_SetObjX() ham_CopyObjToOAM()

void ham_UpdateObjGfx u8    objno,
void *    src
 

replace the graphics of an existing Sprite with new ones

Parameters:
objno  The OBJ number of which you want to reload the graphics data
src  a pointer to the source of the new graphics data
This function lets you reload an existing OBJ with new graphics data. The data src points to needs to have the same attributes (same color mode, same shape/size etc) as the original sprite, or it will not work.

If you need to be more flexible or have performance issues with continously reloading Gfx for many sprites, consider using ham_CreateObjGfx() and ham_SetObjGfxSlot() instead, which is much cooler, but more dangerous... :)

See also: ham_CreateObj() , ham_CloneObj() ham_CopyObjToOAM()

void ham_UpdateObjPal16 u8    objno,
u8    pal_no
 

Update palette number of a 16 color sprite

Parameters:
objno  The OBJ number of which you want to change the palette number
pal_no  The number of the 16 color OBJ palette you want to assign to the sprite
This function will assign the given 16 color OBJ palette to the OBJ number specified. The OBJ number is the number returned by a ham_CreateObj() , ham_CloneObj() or similar calls. Make sure you load the correct Sprite palette first using calls like ham_SetObjPal16()

See also: ham_CreateObj() ham_SetObjPal16() ham_CopyObjToOAM()



Documentation Homepage | HAMLib reference | Back to HAM Homepage
documentation created with Doxygen