diff --git a/board-package-source/libraries/ArduboyFX/library.properties b/board-package-source/libraries/ArduboyFX/library.properties index 7655a90..3ddb67f 100644 --- a/board-package-source/libraries/ArduboyFX/library.properties +++ b/board-package-source/libraries/ArduboyFX/library.properties @@ -1,5 +1,5 @@ name=ArduboyFX -version=1.0.1 +version=1.0.2 author=Mr.Blinky maintainer=mstr.blinky@gmail.com sentence=The Arduboy FX library. diff --git a/board-package-source/libraries/ArduboyFX/src/ArduboyFX.cpp b/board-package-source/libraries/ArduboyFX/src/ArduboyFX.cpp index 5b6274f..e4f536d 100644 --- a/board-package-source/libraries/ArduboyFX/src/ArduboyFX.cpp +++ b/board-package-source/libraries/ArduboyFX/src/ArduboyFX.cpp @@ -501,14 +501,15 @@ void FX::drawBitmap(int16_t x, int16_t y, uint24_t address, uint8_t frame, uint8 " clc \n" // yshift == 1, clear carry " ror %[mode] \n" // carry to mode dbfExtraRow " \n" - " ldi %[rowmask], 0x02 \n" // rowmask = 0xFF >> (height & 7); - " sbrs %[height], 1 \n" + " ldi %[rowmask], 0x02 \n" // rowmask = 0xFF >> (8 - (height & 7)); + " sbrc %[height], 1 \n" " ldi %[rowmask], 0x08 \n" - " sbrs %[height], 2 \n" + " sbrc %[height], 2 \n" " swap %[rowmask] \n" " sbrs %[height], 0 \n" - " lsl %[rowmask] \n" + " lsr %[rowmask] \n" " dec %[rowmask] \n" + " breq .+4 \n" " cpi %[renderheight], 8 \n" // if (renderheight >= 8) rowmask = 0xFF; " brlt .+2 \n" " ldi %[rowmask], 0xFF \n" @@ -519,7 +520,7 @@ void FX::drawBitmap(int16_t x, int16_t y, uint24_t address, uint8_t frame, uint8 " out %[spdr], r1 \n" // start next read " \n" " sbrc %[mode], %[reverseblack] \n" // test reverse mode - " com r0 \n" // reverse bitmap data + " eor r0, %[rowmask] \n" // reverse bitmap data " mov r24, %[rowmask] \n" // temporary move rowmask " sbrc %[mode], %[whiteblack] \n" // for black and white modes: " mov r24, r0 \n" // rowmask = bitmap @@ -613,7 +614,7 @@ void FX::drawBitmap(int16_t x, int16_t y, uint24_t address, uint8_t frame, uint8 "r24", "r25" ); #else - uint8_t lastmask = bitShiftRightMaskUInt8(height); // mask for bottom most pixels + uint8_t lastmask = bitShiftRightMaskUInt8(8 - height); // mask for bottom most pixels do { seekData(address); @@ -626,7 +627,7 @@ void FX::drawBitmap(int16_t x, int16_t y, uint24_t address, uint8_t frame, uint8 for (uint8_t c = 0; c < renderwidth; c++) { uint8_t bitmapbyte = readUnsafe(); - if (mode & _BV(dbfReverseBlack)) bitmapbyte ^= 0xFF; + if (mode & _BV(dbfReverseBlack)) bitmapbyte ^= rowmask; uint8_t maskbyte = rowmask; if (mode & _BV(dbfWhiteBlack)) maskbyte = bitmapbyte; if (mode & _BV(dbfBlack)) bitmapbyte = 0; diff --git a/board-package-source/libraries/ArduboyFX/src/ArduboyFX.h b/board-package-source/libraries/ArduboyFX/src/ArduboyFX.h index e8c8ab1..25fdefa 100644 --- a/board-package-source/libraries/ArduboyFX/src/ArduboyFX.h +++ b/board-package-source/libraries/ArduboyFX/src/ArduboyFX.h @@ -12,15 +12,15 @@ #endif -//progam data and save data pages(set by PC manager tool) -constexpr uint16_t FX_VECTOR_KEY_VALUE = 0x9518; /* RETI instruction used a magic key */ +// progam data and save data pages(set by PC manager tool) +constexpr uint16_t FX_VECTOR_KEY_VALUE = 0x9518; /* RETI instruction used as magic key */ constexpr uint16_t FX_DATA_VECTOR_KEY_POINTER = 0x0014; /* reserved interrupt vector 5 area */ constexpr uint16_t FX_DATA_VECTOR_PAGE_POINTER = 0x0016; constexpr uint16_t FX_SAVE_VECTOR_KEY_POINTER = 0x0018; /* reserved interrupt vector 6 area */ constexpr uint16_t FX_SAVE_VECTOR_PAGE_POINTER = 0x001A; -//Serial Flash Commands -constexpr uint8_t SFC_JEDEC_ID = 0x9F; +// Serial Flash Commands +constexpr uint8_t SFC_JEDEC_ID = 0x9F; constexpr uint8_t SFC_READSTATUS1 = 0x05; constexpr uint8_t SFC_READSTATUS2 = 0x35; constexpr uint8_t SFC_READSTATUS3 = 0x15; @@ -31,7 +31,7 @@ constexpr uint8_t SFC_ERASE = 0x20; constexpr uint8_t SFC_RELEASE_POWERDOWN = 0xAB; constexpr uint8_t SFC_POWERDOWN = 0xB9; -//drawbitmap bit flags (used by modes below and internally) +// drawbitmap bit flags (used by modes below and internally) constexpr uint8_t dbfWhiteBlack = 0; // bitmap is used as mask constexpr uint8_t dbfInvert = 1; // bitmap is exclusive or-ed with display constexpr uint8_t dbfBlack = 2; // bitmap will be blackened @@ -39,7 +39,7 @@ constexpr uint8_t dbfReverseBlack = 3; // reverses bitmap data constexpr uint8_t dbfMasked = 4; // bitmap contains mask data constexpr uint8_t dbfExtraRow = 7; // ignored (internal use) -//drawBitmap modes with same behaviour as Arduboy library drawBitmap modes +// drawBitmap modes with same behaviour as Arduboy library drawBitmap modes constexpr uint8_t dbmBlack = _BV(dbfReverseBlack) | // white pixels in bitmap will be drawn as black pixels on display _BV(dbfBlack) | // black pixels in bitmap will not change pixels on display _BV(dbfWhiteBlack); // (same as sprites drawErase) @@ -51,7 +51,7 @@ constexpr uint8_t dbmWhite = _BV(dbfWhiteBlack); // white pixels in bitma constexpr uint8_t dbmInvert = _BV(dbfInvert); // when a pixel in bitmap has a different color than on display the // pixel on display will be drawn as white. In all other cases the // pixel will be drawn as black -//additional drawBitmap modes +// additional drawBitmap modes constexpr uint8_t dbmNormal = 0; // White pixels in bitmap will be drawn as white pixels on display constexpr uint8_t dbmOverwrite = 0; // Black pixels in bitmap will be drawn as black pixels on display // (Same as sprites drawOverwrite) @@ -60,7 +60,7 @@ constexpr uint8_t dbmReverse = _BV(dbfReverseBlack); // White pixels in bitma // Black pixels in bitmap will be drawn as white pixels on display constexpr uint8_t dbmMasked = _BV(dbfMasked); // The bitmap contains a mask that will determine which pixels are - // drawn and which will remain + // drawn and which pixels remain unchanged on display // (same as sprites drawPlusMask) // Note above modes may be combined like (dbmMasked | dbmReverse) diff --git a/board-package-source/libraries/ArduboyTones/library.json b/board-package-source/libraries/ArduboyTones/library.json index fb6efee..8abe31b 100644 --- a/board-package-source/libraries/ArduboyTones/library.json +++ b/board-package-source/libraries/ArduboyTones/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/MLXXXp/ArduboyTones.git" }, - "version": "1.0.3", + "version": "1.0.4", "exclude": "extras", "frameworks": "arduino", "platforms": "atmelavr" diff --git a/board-package-source/libraries/ArduboyTones/library.properties b/board-package-source/libraries/ArduboyTones/library.properties index 5cfec80..5b7feb2 100644 --- a/board-package-source/libraries/ArduboyTones/library.properties +++ b/board-package-source/libraries/ArduboyTones/library.properties @@ -1,5 +1,5 @@ name=ArduboyTones -version=1.0.3 +version=1.0.4 author=Scott Allen maintainer=Scott Allen sentence=A library for playing a sequence of tones, intended for use with the Arduboy game system. diff --git a/board-package-source/libraries/ArduboyTones/src/ArduboyTones.cpp b/board-package-source/libraries/ArduboyTones/src/ArduboyTones.cpp index 8b56dde..9d42de8 100644 --- a/board-package-source/libraries/ArduboyTones/src/ArduboyTones.cpp +++ b/board-package-source/libraries/ArduboyTones/src/ArduboyTones.cpp @@ -268,17 +268,18 @@ uint16_t ArduboyTones::getNext() ISR(TIMER3_COMPA_vect) { - if (durationToggleCount != 0) { + long toggleCount = durationToggleCount; + if (toggleCount != 0) { if (!toneSilent) { - *(&TONE_PIN_PORT) ^= TONE_PIN_MASK; // toggle the pin + bitSet(*(&TONE_PIN_PIN), TONE_PIN); // toggle the pin #ifdef TONES_VOLUME_CONTROL if (toneHighVol) { - *(&TONE_PIN2_PORT) ^= TONE_PIN2_MASK; // toggle pin 2 + bitSet(*(&TONE_PIN2_PIN), TONE_PIN2); // toggle pin 2 } #endif } - if (durationToggleCount > 0) { - durationToggleCount--; + if (--toggleCount >= 0) { + durationToggleCount = toggleCount; } } else { diff --git a/board-package-source/libraries/ArduboyTones/src/ArduboyTones.h b/board-package-source/libraries/ArduboyTones/src/ArduboyTones.h index ff32948..9a85bac 100644 --- a/board-package-source/libraries/ArduboyTones/src/ArduboyTones.h +++ b/board-package-source/libraries/ArduboyTones/src/ArduboyTones.h @@ -121,17 +121,20 @@ THE SOFTWARE. #ifndef AB_DEVKIT // Arduboy speaker pin 1 = Arduino pin 5 = ATmega32u4 PC6 + #define TONE_PIN_PIN PINC #define TONE_PIN_PORT PORTC #define TONE_PIN_DDR DDRC #define TONE_PIN PORTC6 #define TONE_PIN_MASK _BV(TONE_PIN) #ifndef AB_ALTERNATE_WIRING // Arduboy speaker pin 2 = Arduino pin 13 = ATmega32u4 PC7 + #define TONE_PIN2_PIN PINC #define TONE_PIN2_PORT PORTC #define TONE_PIN2_DDR DDRC #define TONE_PIN2 PORTC7 #else // Arduboy speaker pin 2 = Pro Micro pin 6 = ATmega32u4 PD7 + #define TONE_PIN2_PIN PIND #define TONE_PIN2_PORT PORTD #define TONE_PIN2_DDR DDRD #define TONE_PIN2 PORTD7