From bee1697dab893a82aac0988df033bbff41219774 Mon Sep 17 00:00:00 2001 From: "Mr.Blinky" Date: Fri, 18 Nov 2022 17:26:53 +0100 Subject: [PATCH] update ArduboyFX library --- .../ArduboyFX/examples/chompies/fxdata/fxdata.h | 8 +++++++- .../libraries/ArduboyFX/library.properties | 2 +- .../libraries/ArduboyFX/src/ArduboyFX.cpp | 17 +++++++++++++---- .../libraries/ArduboyFX/src/ArduboyFX.h | 4 +++- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/board-package-source/libraries/ArduboyFX/examples/chompies/fxdata/fxdata.h b/board-package-source/libraries/ArduboyFX/examples/chompies/fxdata/fxdata.h index c995ceb..d825cc2 100644 --- a/board-package-source/libraries/ArduboyFX/examples/chompies/fxdata/fxdata.h +++ b/board-package-source/libraries/ArduboyFX/examples/chompies/fxdata/fxdata.h @@ -1,6 +1,6 @@ #pragma once -/**** FX data header generated by fxdata-build.py tool version 1.01 ****/ +/**** FX data header generated by fxdata-build.py tool version 1.07 ****/ using uint24_t = __uint24; @@ -10,4 +10,10 @@ constexpr uint16_t FX_DATA_PAGE = 0xff65; constexpr uint24_t FX_DATA_BYTES = 39470; constexpr uint24_t mapGfx = 0x000000; +constexpr uint16_t mapGfxWidth = 816; +constexpr uint16_t mapGfxHeight = 368; + constexpr uint24_t whaleGfx = 0x0092A4; +constexpr uint16_t whaleGfxWidth = 107; +constexpr uint16_t whaleGfxHeight = 69; + diff --git a/board-package-source/libraries/ArduboyFX/library.properties b/board-package-source/libraries/ArduboyFX/library.properties index 80f9f06..3912467 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.3 +version=1.0.4 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 87cbde7..fbd9a9e 100644 --- a/board-package-source/libraries/ArduboyFX/src/ArduboyFX.cpp +++ b/board-package-source/libraries/ArduboyFX/src/ArduboyFX.cpp @@ -412,6 +412,15 @@ void FX::writeSavePage(uint16_t page, uint8_t* buffer) disable(); } +void FX::waitWhileBusy() +{ + enable(); + writeByte(SFC_READSTATUS1); + while(readByte() & 1) + ; // wait while BUSY status bit is set + disable(); +} + void FX::drawBitmap(int16_t x, int16_t y, uint24_t address, uint8_t frame, uint8_t mode) { // read bitmap dimensions from flash @@ -443,7 +452,7 @@ void FX::drawBitmap(int16_t x, int16_t y, uint24_t address, uint8_t frame, uint8 { skiptop = -y & -8; // optimized -y / 8 * 8 if (height - skiptop <= HEIGHT) renderheight = height - skiptop; - else renderheight = HEIGHT + (y & 7); + else renderheight = HEIGHT + (-y & 7); skiptop >>= 3;//pixels to displayrows } else @@ -504,11 +513,11 @@ void FX::drawBitmap(int16_t x, int16_t y, uint24_t address, uint8_t frame, uint8 " ror %[mode] \n" // carry to mode dbfExtraRow " \n" " ldi %[rowmask], 0x02 \n" // rowmask = 0xFF >> (8 - (height & 7)); - " sbrc %[height], 1 \n" + " sbrc %[renderheight], 1 \n" " ldi %[rowmask], 0x08 \n" - " sbrc %[height], 2 \n" + " sbrc %[renderheight], 2 \n" " swap %[rowmask] \n" - " sbrs %[height], 0 \n" + " sbrs %[renderheight], 0 \n" " lsr %[rowmask] \n" " dec %[rowmask] \n" " breq .+4 \n" diff --git a/board-package-source/libraries/ArduboyFX/src/ArduboyFX.h b/board-package-source/libraries/ArduboyFX/src/ArduboyFX.h index d4a6815..f6fef45 100644 --- a/board-package-source/libraries/ArduboyFX/src/ArduboyFX.h +++ b/board-package-source/libraries/ArduboyFX/src/ArduboyFX.h @@ -26,7 +26,7 @@ constexpr uint8_t SFC_READSTATUS2 = 0x35; constexpr uint8_t SFC_READSTATUS3 = 0x15; constexpr uint8_t SFC_READ = 0x03; constexpr uint8_t SFC_WRITE_ENABLE = 0x06; -constexpr uint8_t SFC_WRITE = 0x04; +constexpr uint8_t SFC_WRITE = 0x02; constexpr uint8_t SFC_ERASE = 0x20; constexpr uint8_t SFC_RELEASE_POWERDOWN = 0xAB; constexpr uint8_t SFC_POWERDOWN = 0xB9; @@ -254,6 +254,8 @@ class FX static void eraseSaveBlock(uint16_t page); static void writeSavePage(uint16_t page, uint8_t* buffer); + + static void waitWhileBusy(); // wait for outstanding erase or write to finish static void drawBitmap(int16_t x, int16_t y, uint24_t address, uint8_t frame, uint8_t mode) __attribute__((noinline));