Remove Sprites class constructor parameter

The Sprites class has been given direct access to the screen buffer so it
doesn't need a pointer to been given to it.

Also updated README.md and keywords.txt, and made minor indent changes in
the .h files.
This commit is contained in:
Scott Allen 2016-10-20 13:28:29 -04:00
parent 9d2559c248
commit 40a028e5a1
7 changed files with 44 additions and 39 deletions

View File

@ -38,7 +38,7 @@ Main differences between Arduboy2 and Arduboy V1.1 are:
As of version 2.1.0 functionality from the [Team A.R.G.](http://www.team-arg.org/) *Arglib* library has been added:
- The sprite drawing functions, collision detection functions, and button handling functions that Team A.R.G. incorporated from the [ArduboyExtra](https://github.com/yyyc514/ArduboyExtra) project. The *poll()* function was renamed *pollButtons()* for clarity.
- The sprite drawing functions, collision detection functions, and button handling functions that Team A.R.G. incorporated from the [ArduboyExtra](https://github.com/yyyc514/ArduboyExtra) project. The *poll()* function was renamed *pollButtons()* for clarity. The *Sprites* class doesn't require a parameter for the constructor, whereas in *Arglib* a pointer to an Arduboy class object is required.
- The *drawCompressed()* function, which allows compressed bitmaps to be drawn. Saving bitmaps in compressed form may reduce overall sketch size.
## Start up features
@ -98,6 +98,12 @@ void setup() {
The rest of the Arduboy2 functions will now be available for use.
If you wish to use the Sprites class functions you must create a Sprites object:
```cpp
Sprites sprites;
```
Sample sketches have been included with the library as examples of how to use it. To load an example, for examination and uploading to the Arduboy, using the Arduino IDE menus select:
`File > Examples > Arduboy2`

View File

@ -8,6 +8,7 @@
Arduboy2 KEYWORD1
Arduboy2Base KEYWORD1
Sprites KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
@ -20,6 +21,7 @@ boot KEYWORD2
bootLogo KEYWORD2
buttonsState KEYWORD2
clear KEYWORD2
collide KEYWORD2
cpuLoad KEYWORD2
digitalWriteRGB KEYWORD2
display KEYWORD2
@ -51,12 +53,15 @@ height KEYWORD2
idle KEYWORD2
initRandomSeed KEYWORD2
invert KEYWORD2
justPressed KEYWORD2
justReleased KEYWORD2
nextFrame KEYWORD2
notPressed KEYWORD2
off KEYWORD2
on KEYWORD2
paint8Pixels KEYWORD2
paintScreen KEYWORD2
pollButtons KEYWORD2
pressed KEYWORD2
saveOnOff KEYWORD2
setCursor KEYWORD2
@ -69,6 +74,13 @@ setTextWrap KEYWORD2
systemButtons KEYWORD2
width KEYWORD2
# Sprites class
drawErase KEYWORD2
drawExternalMask KEYWORD2
drawOverwrite KEYWORD2
drawPlusMask KEYWORD2
drawSelfMasked KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################

View File

@ -59,6 +59,8 @@ struct Point
class Arduboy2Base : public ArduboyCore
{
friend class Sprites;
public:
Arduboy2Base();

View File

@ -279,7 +279,6 @@ public:
void static boot();
protected:
/// Safe mode
/**
* Safe Mode is engaged by holding down both the LEFT button and UP button

View File

@ -1,10 +1,5 @@
#include "Sprites.h"
Sprites::Sprites(uint8_t* buffer)
{
sBuffer = buffer;
}
void Sprites::drawExternalMask(int16_t x, int16_t y, const uint8_t *bitmap,
const uint8_t *mask, uint8_t frame, uint8_t mask_frame)
{
@ -145,16 +140,16 @@ void Sprites::drawBitmap(int16_t x, int16_t y,
bitmap_data = pgm_read_byte(bofs) * mul_amt;
if (sRow >= 0) {
data = sBuffer[ofs];
data = Arduboy2Base::sBuffer[ofs];
data &= (uint8_t)(mask_data);
data |= (uint8_t)(bitmap_data);
sBuffer[ofs] = data;
Arduboy2Base::sBuffer[ofs] = data;
}
if (yOffset != 0 && sRow < 7) {
data = sBuffer[ofs + WIDTH];
data = Arduboy2Base::sBuffer[ofs + WIDTH];
data &= (*((unsigned char *) (&mask_data) + 1));
data |= (*((unsigned char *) (&bitmap_data) + 1));
sBuffer[ofs + WIDTH] = data;
Arduboy2Base::sBuffer[ofs + WIDTH] = data;
}
ofs++;
bofs++;
@ -170,10 +165,10 @@ void Sprites::drawBitmap(int16_t x, int16_t y,
for (uint8_t iCol = 0; iCol < rendered_width; iCol++) {
bitmap_data = pgm_read_byte(bofs) * mul_amt;
if (sRow >= 0) {
sBuffer[ofs] |= (uint8_t)(bitmap_data);
Arduboy2Base::sBuffer[ofs] |= (uint8_t)(bitmap_data);
}
if (yOffset != 0 && sRow < 7) {
sBuffer[ofs + WIDTH] |= (*((unsigned char *) (&bitmap_data) + 1));
Arduboy2Base::sBuffer[ofs + WIDTH] |= (*((unsigned char *) (&bitmap_data) + 1));
}
ofs++;
bofs++;
@ -189,10 +184,10 @@ void Sprites::drawBitmap(int16_t x, int16_t y,
for (uint8_t iCol = 0; iCol < rendered_width; iCol++) {
bitmap_data = pgm_read_byte(bofs) * mul_amt;
if (sRow >= 0) {
sBuffer[ofs] &= ~(uint8_t)(bitmap_data);
Arduboy2Base::sBuffer[ofs] &= ~(uint8_t)(bitmap_data);
}
if (yOffset != 0 && sRow < 7) {
sBuffer[ofs + WIDTH] &= ~(*((unsigned char *) (&bitmap_data) + 1));
Arduboy2Base::sBuffer[ofs + WIDTH] &= ~(*((unsigned char *) (&bitmap_data) + 1));
}
ofs++;
bofs++;
@ -218,16 +213,16 @@ void Sprites::drawBitmap(int16_t x, int16_t y,
bitmap_data = pgm_read_byte(bofs) * mul_amt;
if (sRow >= 0) {
data = sBuffer[ofs];
data = Arduboy2Base::sBuffer[ofs];
data &= (uint8_t)(mask_data);
data |= (uint8_t)(bitmap_data);
sBuffer[ofs] = data;
Arduboy2Base::sBuffer[ofs] = data;
}
if (yOffset != 0 && sRow < 7) {
data = sBuffer[ofs + WIDTH];
data = Arduboy2Base::sBuffer[ofs + WIDTH];
data &= (*((unsigned char *) (&mask_data) + 1));
data |= (*((unsigned char *) (&bitmap_data) + 1));
sBuffer[ofs + WIDTH] = data;
Arduboy2Base::sBuffer[ofs + WIDTH] = data;
}
ofs++;
mask_ofs++;
@ -340,8 +335,8 @@ void Sprites::drawBitmap(int16_t x, int16_t y,
[x_count] "r" (rendered_width),
[y_count] "r" (loop_h),
[sprite_ofs] "z" (bofs),
[buffer_ofs] "x" (sBuffer+ofs),
[buffer_page2_ofs] "r" (sBuffer+ofs+WIDTH), // Y pointer
[buffer_ofs] "x" (Arduboy2Base::sBuffer+ofs),
[buffer_page2_ofs] "r" (Arduboy2Base::sBuffer+ofs+WIDTH), // Y pointer
[buffer_ofs_jump] "r" (WIDTH-rendered_width),
[sprite_ofs_jump] "r" ((w-rendered_width)*2),
[yOffset] "r" (yOffset),

View File

@ -14,12 +14,6 @@
class Sprites
{
public:
/// The class constructor.
/// `buffer` is a pointer to the screen buffer where the draw functions
/// will write to.
///
Sprites(uint8_t* buffer);
/// drawExternalMask() uses a separate mask to mask image (MASKED)
///
/// image mask before after
@ -130,9 +124,6 @@ class Sprites
void drawBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, const uint8_t *mask,
int8_t w, int8_t h, uint8_t draw_mode);
private:
unsigned char *sBuffer;
};
#endif