Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sprite support and improved 4MAW framework
- Loading branch information
Showing
5 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef FMAW_H | ||
#define FMAW_H | ||
|
||
#include "./sprite.h" | ||
#include "./debug.h" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#ifndef FMAW_DEBUG_H | ||
#define FMAW_DEBUG_H | ||
|
||
#include "./debug.h" | ||
|
||
namespace FMAW { | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <nds.h> | ||
#include <nds/debug.h> | ||
|
||
#include "./sprite.h" | ||
|
||
namespace FMAW { | ||
|
||
void clearAllSprites(void) { | ||
for ( sprite_id id = 0; id < TOTAL_SPRITES; id++ ) | ||
disableSprite( id ); | ||
} | ||
|
||
void disableSprite( sprite_id id ) { | ||
sprites[id].attr0 = ATTR0_DISABLED; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef FMAW_SPRITE_H | ||
#define FMAW_SPRITE_H | ||
|
||
namespace FMAW { | ||
|
||
// Access to sprites' memory, in an array-like way. | ||
#define sprites (reinterpret_cast<FMAW::spriteEntry*>OAM) | ||
|
||
#define TOTAL_SPRITES 128 // Total amount of sprites that can be rendered. | ||
|
||
// Low-level data structure to work with NDS libraries. | ||
typedef struct t_spriteEntry { | ||
uint16 attr0; | ||
uint16 attr1; | ||
uint16 attr2; | ||
uint16 affine_data; | ||
} spriteEntry; | ||
|
||
typedef uint8 sprite_id; | ||
|
||
/** | ||
* Clears all the sprites. | ||
*/ | ||
void clearAllSprites(void); | ||
|
||
/** | ||
* Disables given sprite (it won't be rendered and no CPU cycles will be wasted | ||
* on it). | ||
*/ | ||
void disableSprite( sprite_id id ); | ||
|
||
} | ||
|
||
#endif |