v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Member Functions | Static Public Member Functions | List of all members
Sifteo::AssetSlot Class Reference

AssetSlots are numbered containers, in a cube's flash memory, which can hold AssetGroups. More...

#include <sifteo/asset/group.h>

Public Member Functions

 AssetSlot (_SYSAssetSlot sys)
 Explicit conversion from a system object.
 
 AssetSlot (const AssetSlot &other)
 Copy constructor.
 
ALWAYS_INLINE AssetSlot bootstrap (AssetGroup &group) const
 Mark a particular AssetGroup as a "bootstrap" asset for this slot. More...
 
void erase (_SYSCubeIDVector cubes=-1) const
 Erase this slot. More...
 
bool hasRoomFor (const AssetGroup &group, _SYSCubeIDVector cubes=-1) const
 Is there room in this slot to load a particular AssetGroup without erasing the slot? More...
 
 operator const _SYSAssetSlot & () const
 Implicit conversion to system object.
 
unsigned tilesFree (_SYSCubeIDVector cubes=-1) const
 How much space is remaining in this slot, measured in tiles? More...
 

Static Public Member Functions

static ALWAYS_INLINE AssetSlot allocate ()
 Statically allocate a new AssetSlot. More...
 

Detailed Description

AssetSlots are numbered containers, in a cube's flash memory, which can hold AssetGroups.

Slots are allocated statically. Any given game has a fixed number of slots that it requires. At launch or at cube connect-time, those slots are mapped to physical regions of memory on each cube, by the system.

Assets cannot be freely replaced within a slot. You can append a new AssetGroup to a particular slot, and you can erase a slot. Individual groups cannot be removed without erasing the whole slot.

Assets within an AssetSlot are cached between invocations of the game. This means that a "new" AssetSlot may start out with not all tiles free, and any assets already resident in that slot will be marked as installed.

To define a new AssetSlot, use AssetSlot::allocate().

To ensure that AssetSlots used in metadata are constant at compile-time, the preferred allocation pattern is to declare a global variable such as:

AssetSlot MySlot = AssetSlot::allocate()
     .bootstrap(Group1)
     .bootstrap(Group2);

AssetSlots can only be created via allocate(), or copying another AssetSlot. All ID allocation is performed in allocate().

Member Function Documentation

static ALWAYS_INLINE AssetSlot Sifteo::AssetSlot::allocate ( )
inlinestatic

Statically allocate a new AssetSlot.

This function returns a unique ID which is constant at link-time.

ALWAYS_INLINE AssetSlot Sifteo::AssetSlot::bootstrap ( AssetGroup group) const
inline

Mark a particular AssetGroup as a "bootstrap" asset for this slot.

The launcher will ensure that this AssetGroup is installed before the game starts.

This function must be called before the AssetGroup is used for rendering. This is where we update the asset's base address from the system cache.

Returns *this, so that bootstrap() can be chained, especially off of allocate().

void Sifteo::AssetSlot::erase ( _SYSCubeIDVector  cubes = -1) const
inline

Erase this slot.

Any existing AssetGroups loaded into this slot will no longer be loaded, and the slot will be marked as fully empty.

After this call, any AssetGroups that were installed here will now return 'false' from isInstalled(). Any tiles rendered from this AssetGroup will now have undefined contents on-screen.

By default, the slot will be erased on all cubes. A CubeSet may be explicitly specified, to limit the erasure to those cubes.

bool Sifteo::AssetSlot::hasRoomFor ( const AssetGroup group,
_SYSCubeIDVector  cubes = -1 
) const
inline

Is there room in this slot to load a particular AssetGroup without erasing the slot?

This does not check whether the specified group has already been installed.

By default, this checks whether all cubes have room for the group. A CubeSet may be explicitly specified, to limit the check to those cubes.

unsigned Sifteo::AssetSlot::tilesFree ( _SYSCubeIDVector  cubes = -1) const
inline

How much space is remaining in this slot, measured in tiles?

By default, this measures the space remaining on all cubes, and returns the smallest of all results. A CubeSet may be explicitly specified, to limit the measurement to those cubes.


The documentation for this class was generated from the following file: