diff --git a/.gitignore b/.gitignore index 065e5883..c31910e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,59 +1,63 @@ -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - -.DS_Store -.AppleDouble -.LSOverride - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk -bin/ -!bin/myevic.bin -*.sh -disasm/ -obj/ -projects/ -*.o -startfiles -driver/*.sys -*.map -genuine/ -wrkspc.txt +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +bin/ +!bin/myevic.bin +*.sh +disasm/ +obj/ +projects/ +*.o +startfiles +driver/*.sys +*.map +genuine/ +wrkspc.txt +!/bin/ +/bin/myevic.elf +/bin/myevic_dec.bin +/nbproject/ \ No newline at end of file diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md old mode 100755 new mode 100644 diff --git a/LICENSE.txt b/LICENSE.txt old mode 100755 new mode 100644 diff --git a/Makefile b/Makefile index 6bf22a09..0c73b20e 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,8 @@ MYEVIC_OBJS := src/myevic.o \ src/storage.o \ src/flappy.o \ src/fbdata.o \ + src/tetris.o \ + src/ttdata.o \ src/fonts.o \ src/display.o \ src/SSD1306.o \ @@ -193,6 +195,9 @@ $(TARGET)_dec.bin: $(OBJS_FIXPATH) $(MYEVIC_OBJS) $(LD) --start-group $(LIBS) $(OBJS_FIXPATH) $(MYEVIC_OBJS) --end-group $(LDFLAGS) -o $(OUTDIR)/$(TARGET).elf $(OBJCOPY) -O binary -j .text -j .data $(OUTDIR)/$(TARGET).elf $(OUTDIR)/$(TARGET)_dec.bin + export LC_ALL=C.UTF-8 + export LANG=C.UTF-8 + $(TARGET).bin: $(TARGET)_dec.bin evic convert $(OUTDIR)/$(TARGET)_dec.bin -o $(OUTDIR)/$(TARGET).bin diff --git a/README_pt_BR.docx b/README_pt_BR.docx old mode 100755 new mode 100644 diff --git a/bin/myevic.bin b/bin/myevic.bin old mode 100755 new mode 100644 index 13217cc6..5c0b03b9 Binary files a/bin/myevic.bin and b/bin/myevic.bin differ diff --git a/inc/dataflash.h b/inc/dataflash.h index 758c8372..4b98fc30 100644 --- a/inc/dataflash.h +++ b/inc/dataflash.h @@ -183,6 +183,8 @@ typedef struct dfParams /* 00E0 */ uint16_t Millis; /* 00E2 */ uint8_t Profile; /* 00E3 */ int8_t BVOffset[4]; +/* 00E7 */ uint16_t TTBest; +/* 00E9 */ uint8_t TTSpeed; } dfParams_t; @@ -349,6 +351,8 @@ extern dfStruct_t DataFlash; #define dfSavedCfgPwr DFP(SavedCfgPwr) #define dfFBBest DFP(FBBest) #define dfFBSpeed DFP(FBSpeed) +#define dfTTBest DFP(TTBest) +#define dfTTSpeed DFP(TTSpeed) #define dfBattPC DFP(BattPC) #define dfContrast DFP(Contrast) #define dfModesSel DFP(ModesSel) diff --git a/inc/display.h b/inc/display.h index 8cf86b48..e606840b 100644 --- a/inc/display.h +++ b/inc/display.h @@ -33,8 +33,8 @@ extern const image_t **Images; extern const image_t const *font0_1306[]; extern const image_t const *font0_1327[]; -extern const image_t const *font1_1306[]; -extern const image_t const *font1_1327[]; +//extern const image_t const *font1_1306[]; +//extern const image_t const *font1_1327[]; //------------------------------------------------------------------------- diff --git a/inc/events.h b/inc/events.h index 09800001..c2a6b453 100644 --- a/inc/events.h +++ b/inc/events.h @@ -78,6 +78,7 @@ extern uint8_t LastEvent; #define EVENT_PROFILE_MENU 118 #define EVENT_NEXT_PROFILE 119 #define EVENT_POWER_CURVE 120 +#define EVENT_TETRIS 121 //============================================================================== @@ -91,6 +92,8 @@ enum CLICK_ACTION_NEXT_MODE, CLICK_ACTION_ON_OFF, CLICK_ACTION_PROFILE, + CLICK_ACTION_TETRIS, + CLICK_ACTION_GAME, CLICK_ACTION_MAX }; diff --git a/inc/myevic.h b/inc/myevic.h index 1657b7b6..04ce93ef 100644 --- a/inc/myevic.h +++ b/inc/myevic.h @@ -148,6 +148,7 @@ typedef struct /* 00200000 */ int fading:1; /* 00400000 */ int led_on:1; /* 00800000 */ int splash:1; +/* 01000000 */ int playing_tt:1; } gFlags_t; diff --git a/inc/screens.h b/inc/screens.h index 7d168d54..f1ae136a 100644 --- a/inc/screens.h +++ b/inc/screens.h @@ -119,6 +119,7 @@ extern const uint8_t String_Right[]; extern const uint8_t String_Left[]; extern const uint8_t String_Logo[]; extern const uint8_t String_Game[]; +extern const uint8_t String_Tetris[]; extern const uint8_t String_Easy[]; extern const uint8_t String_Normal[]; extern const uint8_t String_Hard[]; @@ -299,6 +300,15 @@ extern const uint8_t String_Enable[]; extern const uint8_t String_Reset[]; extern const uint8_t String_Splash[]; +//from display.c +extern const uint8_t String_Sunday[]; +extern const uint8_t String_Monday[]; +extern const uint8_t String_Tuesday[]; +extern const uint8_t String_Wednesday[]; +extern const uint8_t String_Thursday[]; +extern const uint8_t String_Friday[]; +extern const uint8_t String_Saturday[]; +extern const uint8_t String_Survival[]; //============================================================================== diff --git a/inc/tetris.h b/inc/tetris.h new file mode 100644 index 00000000..9fa76fdb --- /dev/null +++ b/inc/tetris.h @@ -0,0 +1,12 @@ +#ifndef __TETRIS_H__ +#define __TETRIS_H__ + +extern void ttInitTimeouts(); +extern void ttSetTimeoutDelay( int ); +extern void ttTickTimeouts(); +extern void ttCallTimeouts(); +extern void ttGame(); +extern void ttStartGame(); + +#endif /* __TETRIS_H__ */ + diff --git a/src/dataflash.c b/src/dataflash.c index c841a7fb..7fa8315a 100644 --- a/src/dataflash.c +++ b/src/dataflash.c @@ -467,6 +467,7 @@ __myevic__ void ResetDataFlash() // dfFBBest = 0; // dfFBSpeed = 0; // dfBattPC = 0; + dfTTBest = 0; dfContrast = 45; // dfModesSel = 0; dfClkRatio = RTC_DEF_CLK_RATIO; diff --git a/src/display.c b/src/display.c index 1c379dd9..69d22f74 100644 --- a/src/display.c +++ b/src/display.c @@ -159,9 +159,9 @@ typedef struct uint8_t sep2offset; } datefmt_t; - + __myevic__ void DrawDate( int x, int y, S_RTC_TIME_DATA_T *rtd, int colors ) -{ +{ const datefmt_t format[] = { { 0xC1, 0, 16, 32, 12, 28 }, @@ -179,6 +179,32 @@ __myevic__ void DrawDate( int x, int y, S_RTC_TIME_DATA_T *rtd, int colors ) if (colors&0x01) DrawValue( x + f->yearoffset, y, rtd->u32Year, 0, 0x0B, 4 ); if (colors&0x08) DrawImage( x + f->sep1offset, y, f->separator ); if (colors&0x02) DrawImage( x + f->sep2offset, y, f->separator ); + + y += 13; + switch ( rtd->u32DayOfWeek ) + { + case 0: + DrawStringCentered( String_Sunday, y ); + break; + case 1: + DrawStringCentered( String_Monday, y ); + break; + case 2: + DrawStringCentered( String_Tuesday, y ); + break; + case 3: + DrawStringCentered( String_Wednesday, y ); + break; + case 4: + DrawStringCentered( String_Thursday, y ); + break; + case 5: + DrawStringCentered( String_Friday, y ); + break; + case 6: + DrawStringCentered( String_Saturday, y ); + break; + } } @@ -668,13 +694,15 @@ __myevic__ void Screen2Bitmap( uint8_t *pu8Bitmap ) //------------------------------------------------------------------------- __myevic__ void DisplaySetFont() { - if ( dfStatus.font ) - { + //if ( dfStatus.font ) + //{ Images = font0_1306; +/* } else { Images = font1_1306; } +*/ } diff --git a/src/eh.c b/src/eh.c index 3c1d89af..93540a09 100644 --- a/src/eh.c +++ b/src/eh.c @@ -10,6 +10,7 @@ #include "meadc.h" #include "atomizer.h" #include "flappy.h" +#include "tetris.h" //========================================================================= // Globals diff --git a/src/events.c b/src/events.c index f8c4385d..aa4aaa4f 100644 --- a/src/events.c +++ b/src/events.c @@ -8,6 +8,7 @@ #include "atomizer.h" #include "battery.h" #include "flappy.h" +#include "tetris.h" #include "timers.h" #include "meusbd.h" @@ -393,6 +394,14 @@ __myevic__ void GetUserInput() case CLICK_ACTION_PROFILE: FireClicksEvent = EVENT_NEXT_PROFILE; // Cycle profile break; + + case CLICK_ACTION_TETRIS: + FireClicksEvent = EVENT_TETRIS; // tetris + break; + + case CLICK_ACTION_GAME: + FireClicksEvent = 41; // Game + break; } if ( dfStatus.off ) { @@ -483,17 +492,28 @@ __myevic__ void GetUserInput() } else if ( !dfStatus.off ) { - if ( !gFlags.playing_fb ) + if ( !gFlags.playing_fb && !gFlags.playing_tt) { Event = EVENT_ENTER_MENUS; } else { + if ( gFlags.playing_fb) + { gFlags.playing_fb = 0; Event = 0; fbInitTimeouts(); MainView(); - } + } + if ( gFlags.playing_tt) + { + gFlags.playing_tt = 0; + Event = 0; + ttInitTimeouts(); + MainView(); + } + + } } } } @@ -1269,7 +1289,21 @@ __myevic__ int CustomEvents() EditModeTimer = 3000; EditItemIndex = 0; break; - + + case 40: + SetScreen( 107, 30 ); + EditModeTimer = 3000; + EditItemIndex = 0; + break; + + case 41: + fbStartGame(); + break; + + case EVENT_TETRIS: + ttStartGame(); + break; + default: vret = 0; break; diff --git a/src/fbdata.c b/src/fbdata.c index 17edab03..40922667 100644 --- a/src/fbdata.c +++ b/src/fbdata.c @@ -5,218 +5,248 @@ // Sprites and font data for Flappy Bird //------------------------------------------------------------------------- -const uint8_t fbColumnBody[] = - { - 0b00011000, 0b00000000, 0b00011000, - 0b01011000, 0b00000000, 0b00011000, - 0b01011000, 0b00000000, 0b00011000, - 0b01011000, 0b00000000, 0b00011000, - 0b00011000, 0b00000000, 0b00011000, - 0b01011000, 0b00000000, 0b00011000, - 0b01011000, 0b00000000, 0b00011000, - 0b00011000, 0b00000000, 0b00011000 - }; +const uint8_t fbColumnBody[] ={ + 0b00011000, 0b00000000, 0b00011000, + 0b01011000, 0b00000000, 0b00011000, + 0b01011000, 0b00000000, 0b00011000, + 0b01011000, 0b00000000, 0b00011000, + 0b00011000, 0b00000000, 0b00011000, + 0b01011000, 0b00000000, 0b00011000, + 0b01011000, 0b00000000, 0b00011000, + 0b00011000, 0b00000000, 0b00011000 +}; + +const uint8_t fbColumnBottom[] ={ + 0b11111110, 0b11111111, 0b01111111, + 0b11111110, 0b11111111, 0b01111111, + 0b00000110, 0b00000000, 0b01100000, + 0b00000110, 0b00000000, 0b01100000, + 0b00000110, 0b00000000, 0b01100000, + 0b11111110, 0b11111111, 0b01111111, + 0b11111110, 0b11111111, 0b01111111, + 0b00000000, 0b00000000, 0b00000000 +}; -const uint8_t fbColumnBottom[] = - { - 0b11111110, 0b11111111, 0b01111111, - 0b11111110, 0b11111111, 0b01111111, - 0b00000110, 0b00000000, 0b01100000, - 0b00000110, 0b00000000, 0b01100000, - 0b00000110, 0b00000000, 0b01100000, - 0b11111110, 0b11111111, 0b01111111, - 0b11111110, 0b11111111, 0b01111111, - 0b00000000, 0b00000000, 0b00000000 - }; +const uint8_t fbColumnTop[] ={ + 0b00000000, 0b00000000, 0b00000000, + 0b11111110, 0b11111111, 0b01111111, + 0b11111110, 0b11111111, 0b01111111, + 0b00000110, 0b00000000, 0b01100000, + 0b00000110, 0b00000000, 0b01100000, + 0b00000110, 0b00000000, 0b01100000, + 0b11111110, 0b11111111, 0b01111111, + 0b11111110, 0b11111111, 0b01111111 +}; -const uint8_t fbColumnTop[] = - { - 0b00000000, 0b00000000, 0b00000000, - 0b11111110, 0b11111111, 0b01111111, - 0b11111110, 0b11111111, 0b01111111, - 0b00000110, 0b00000000, 0b01100000, - 0b00000110, 0b00000000, 0b01100000, - 0b00000110, 0b00000000, 0b01100000, - 0b11111110, 0b11111111, 0b01111111, - 0b11111110, 0b11111111, 0b01111111 - }; +const uint8_t fbBird0[] ={ + 0b00000000, 0b00000000, + 0b11000000, 0b00001111, + 0b00110000, 0b00010010, + 0b00001000, 0b00100001, + 0b00000100, 0b01010001, + 0b00000100, 0b01010001, + 0b01111110, 0b01000010, + 0b01000001, 0b01111100, + 0b00100001, 0b10000010, + 0b00010001, 0b01111101, + 0b00001110, 0b01000010, + 0b00011000, 0b00111100, + 0b11100000, 0b00000011, + 0b00000000, 0b00000000, + 0b00000000, 0b00000000, + 0b00000000, 0b00000000 +}; -const uint8_t fbBird0[] = - { - 0b00000000, 0b00000000, - 0b11000000, 0b00001111, - 0b00110000, 0b00010010, - 0b00001000, 0b00100001, - 0b00000100, 0b01010001, - 0b00000100, 0b01010001, - 0b01111110, 0b01000010, - 0b01000001, 0b01111100, - 0b00100001, 0b10000010, - 0b00010001, 0b01111101, - 0b00001110, 0b01000010, - 0b00011000, 0b00111100, - 0b11100000, 0b00000011, - 0b00000000, 0b00000000, - 0b00000000, 0b00000000, - 0b00000000, 0b00000000 - }; - -const uint8_t fbBird1[] = - { - 0b00000000, 0b00000000, - 0b11000000, 0b00001111, - 0b00110000, 0b00010010, - 0b00001000, 0b00100001, - 0b00000100, 0b01010001, - 0b00111110, 0b01010001, - 0b01000001, 0b01000010, - 0b01000001, 0b01111100, - 0b00111110, 0b10000010, - 0b00000100, 0b01111101, - 0b00000100, 0b01000010, - 0b00011000, 0b00111100, - 0b11100000, 0b00000011, - 0b00000000, 0b00000000, - 0b00000000, 0b00000000, - 0b00000000, 0b00000000 - }; +const uint8_t fbBird1[] ={ + 0b00000000, 0b00000000, + 0b11000000, 0b00001111, + 0b00110000, 0b00010010, + 0b00001000, 0b00100001, + 0b00000100, 0b01010001, + 0b00111110, 0b01010001, + 0b01000001, 0b01000010, + 0b01000001, 0b01111100, + 0b00111110, 0b10000010, + 0b00000100, 0b01111101, + 0b00000100, 0b01000010, + 0b00011000, 0b00111100, + 0b11100000, 0b00000011, + 0b00000000, 0b00000000, + 0b00000000, 0b00000000, + 0b00000000, 0b00000000 +}; -const uint8_t fbBird2[] = - { - 0b00000000, 0b00000000, - 0b11000000, 0b00001111, - 0b00110000, 0b00010010, - 0b00001000, 0b00100001, - 0b00011110, 0b01010001, - 0b00100001, 0b01010001, - 0b01000001, 0b01000010, - 0b01000001, 0b01111100, - 0b01000010, 0b10000010, - 0b00111100, 0b01111101, - 0b00000100, 0b01000010, - 0b00011000, 0b00111100, - 0b11100000, 0b00000011, - 0b00000000, 0b00000000, - 0b00000000, 0b00000000, - 0b00000000, 0b00000000 - }; - -const uint8_t fbBirdDead[] = - { - 0b00000000, 0b00000011, - 0b10000000, 0b00000100, - 0b11100000, 0b00001100, - 0b10010000, 0b00010100, - 0b10010000, 0b00100100, - 0b10001000, 0b00100100, - 0b00001000, 0b01000011, - 0b00001000, 0b01000000, - 0b01001000, 0b01011100, - 0b10101000, 0b01100010, - 0b01010000, 0b01000001, - 0b01010000, 0b01000001, - 0b01010000, 0b00101101, - 0b01010000, 0b00010001, - 0b01100000, 0b00001111, - 0b10000000, 0b00000000 - }; +const uint8_t fbBird2[] ={ + 0b00000000, 0b00000000, + 0b11000000, 0b00001111, + 0b00110000, 0b00010010, + 0b00001000, 0b00100001, + 0b00011110, 0b01010001, + 0b00100001, 0b01010001, + 0b01000001, 0b01000010, + 0b01000001, 0b01111100, + 0b01000010, 0b10000010, + 0b00111100, 0b01111101, + 0b00000100, 0b01000010, + 0b00011000, 0b00111100, + 0b11100000, 0b00000011, + 0b00000000, 0b00000000, + 0b00000000, 0b00000000, + 0b00000000, 0b00000000 +}; -const uint8_t fbFont[95][16] = -{ - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00 }, - { 0x00, 0x48, 0x6C, 0x24, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0x7F, 0x12, 0x12, 0x12, 0x7F, 0x12, 0x12, 0x12, 0x00, 0x00 }, - { 0x00, 0x00, 0x08, 0x1C, 0x2A, 0x2A, 0x0A, 0x0C, 0x18, 0x28, 0x28, 0x2A, 0x2A, 0x1C, 0x08, 0x08 }, - { 0x00, 0x00, 0x00, 0x22, 0x25, 0x15, 0x15, 0x15, 0x2A, 0x58, 0x54, 0x54, 0x54, 0x22, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x0C, 0x12, 0x12, 0x12, 0x0A, 0x76, 0x25, 0x29, 0x11, 0x91, 0x6E, 0x00, 0x00 }, - { 0x00, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x00, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x00 }, - { 0x00, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x02, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x1C, 0x1C, 0x6B, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x7F, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x04, 0x03 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00 }, - { 0x00, 0x00, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x00 }, - { 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x08, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x20, 0x20, 0x10, 0x08, 0x04, 0x42, 0x7E, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x20, 0x18, 0x20, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x20, 0x30, 0x28, 0x24, 0x24, 0x22, 0x22, 0x7E, 0x20, 0x20, 0x78, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x02, 0x1A, 0x26, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x38, 0x24, 0x02, 0x02, 0x1A, 0x26, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x7E, 0x22, 0x22, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x64, 0x58, 0x40, 0x40, 0x24, 0x1C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x04 }, - { 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x46, 0x40, 0x20, 0x10, 0x10, 0x00, 0x18, 0x18, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x5A, 0x55, 0x55, 0x55, 0x55, 0x2D, 0x42, 0x22, 0x1C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x08, 0x08, 0x18, 0x14, 0x14, 0x24, 0x3C, 0x22, 0x42, 0x42, 0xE7, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x1F, 0x22, 0x22, 0x22, 0x1E, 0x22, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x01, 0x01, 0x01, 0x01, 0x01, 0x42, 0x22, 0x1C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x1F, 0x22, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x42, 0x42, 0x3F, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x01, 0x01, 0x01, 0x71, 0x21, 0x22, 0x22, 0x1C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x0F }, - { 0x00, 0x00, 0x00, 0x77, 0x22, 0x12, 0x0A, 0x0E, 0x0A, 0x12, 0x12, 0x22, 0x22, 0x77, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x42, 0x7F, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x77, 0x36, 0x36, 0x36, 0x36, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x6B, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0xE3, 0x46, 0x46, 0x4A, 0x4A, 0x52, 0x52, 0x52, 0x62, 0x62, 0x47, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x42, 0x3E, 0x02, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x4D, 0x53, 0x32, 0x1C, 0x60, 0x00 }, - { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x3E, 0x12, 0x12, 0x22, 0x22, 0x42, 0xC7, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x02, 0x04, 0x18, 0x20, 0x40, 0x42, 0x42, 0x3E, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x7F, 0x49, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x22, 0x24, 0x24, 0x14, 0x14, 0x18, 0x08, 0x08, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x6B, 0x49, 0x49, 0x49, 0x49, 0x55, 0x55, 0x36, 0x22, 0x22, 0x22, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x18, 0x18, 0x18, 0x24, 0x24, 0x42, 0xE7, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x77, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x7E, 0x21, 0x20, 0x10, 0x10, 0x08, 0x04, 0x04, 0x42, 0x42, 0x3F, 0x00, 0x00 }, - { 0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00 }, - { 0x00, 0x00, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40, 0x40 }, - { 0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00 }, - { 0x00, 0x38, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF }, - { 0x00, 0x06, 0x06, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x78, 0x44, 0x42, 0x42, 0xFC, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x1A, 0x26, 0x42, 0x42, 0x42, 0x26, 0x1A, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x02, 0x02, 0x02, 0x44, 0x38, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x60, 0x40, 0x40, 0x40, 0x78, 0x44, 0x42, 0x42, 0x42, 0x64, 0xD8, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x7E, 0x02, 0x02, 0x42, 0x3C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0xF0, 0x88, 0x08, 0x08, 0x7E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x22, 0x22, 0x1C, 0x02, 0x3C, 0x42, 0x42, 0x3C }, - { 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x1E }, - { 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x72, 0x12, 0x0A, 0x16, 0x12, 0x22, 0x77, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x92, 0x92, 0x92, 0x92, 0x92, 0xB7, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x46, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x26, 0x42, 0x42, 0x42, 0x22, 0x1E, 0x02, 0x07 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x44, 0x78, 0x40, 0xE0 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x4C, 0x04, 0x04, 0x04, 0x04, 0x1F, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x02, 0x3C, 0x40, 0x42, 0x3E, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x30, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x42, 0x42, 0x42, 0x42, 0x62, 0xDC, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x14, 0x08, 0x08, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEB, 0x49, 0x49, 0x55, 0x55, 0x22, 0x22, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x24, 0x18, 0x18, 0x18, 0x24, 0x6E, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x14, 0x18, 0x08, 0x08, 0x07 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x22, 0x10, 0x08, 0x08, 0x44, 0x7E, 0x00, 0x00 }, - { 0x00, 0xC0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xC0, 0x00 }, - { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 }, - { 0x00, 0x06, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x00 }, - { 0x0C, 0x32, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +const uint8_t fbBirdDead[] ={ + 0b00000000, 0b00000011, + 0b10000000, 0b00000100, + 0b11100000, 0b00001100, + 0b10010000, 0b00010100, + 0b10010000, 0b00100100, + 0b10001000, 0b00100100, + 0b00001000, 0b01000011, + 0b00001000, 0b01000000, + 0b01001000, 0b01011100, + 0b10101000, 0b01100010, + 0b01010000, 0b01000001, + 0b01010000, 0b01000001, + 0b01010000, 0b00101101, + 0b01010000, 0b00010001, + 0b01100000, 0b00001111, + 0b10000000, 0b00000000 }; +const uint8_t fbFontDigit[10][16] ={ + { 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00}, //0 + { 0x00, 0x00, 0x00, 0x08, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, + { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x20, 0x20, 0x10, 0x08, 0x04, 0x42, 0x7E, 0x00, 0x00}, + { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x20, 0x18, 0x20, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00}, + { 0x00, 0x00, 0x00, 0x20, 0x30, 0x28, 0x24, 0x24, 0x22, 0x22, 0x7E, 0x20, 0x20, 0x78, 0x00, 0x00}, + { 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x02, 0x1A, 0x26, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00}, + { 0x00, 0x00, 0x00, 0x38, 0x24, 0x02, 0x02, 0x1A, 0x26, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00}, + { 0x00, 0x00, 0x00, 0x7E, 0x22, 0x22, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00}, + { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, + { 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x64, 0x58, 0x40, 0x40, 0x24, 0x1C, 0x00, 0x00} //9 +}; + +const uint8_t fbFont[16][16] ={ + { 0 }, + { 0x00, 0x00, 0x00, 0x08, 0x08, 0x18, 0x14, 0x14, 0x24, 0x3C, 0x22, 0x42, 0x42, 0xE7, 0x00, 0x00}, //A 1 + { 0x00, 0x00, 0x00, 0x1F, 0x22, 0x22, 0x22, 0x1E, 0x22, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00}, //B 2 + { 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x01, 0x01, 0x01, 0x01, 0x01, 0x42, 0x22, 0x1C, 0x00, 0x00}, //C 3 + { 0x00, 0x00, 0x00, 0x1F, 0x22, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00}, //D 4 + { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x42, 0x42, 0x3F, 0x00, 0x00}, //E 5 + { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00}, //F 6 + { 0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, //I 7 + { 0x00, 0x00, 0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x42, 0x7F, 0x00, 0x00}, //L 8 + { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1C, 0x00, 0x00}, //O 9 + { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x42, 0x3E, 0x02, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00}, //P 10 + { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x3E, 0x12, 0x12, 0x22, 0x22, 0x42, 0xC7, 0x00, 0x00}, //R 11 + { 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x02, 0x04, 0x18, 0x20, 0x40, 0x42, 0x42, 0x3E, 0x00, 0x00}, //S 12 + { 0x00, 0x00, 0x00, 0x7F, 0x49, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00}, //T 13 + { 0x00, 0x00, 0x00, 0x77, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00}, //Y 14 + { 0 } // 15 +}; + +// ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? +// @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ +// ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ + +/* +const uint8_t fbFont[59][16] = +{ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00 }, + { 0x00, 0x48, 0x6C, 0x24, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0x7F, 0x12, 0x12, 0x12, 0x7F, 0x12, 0x12, 0x12, 0x00, 0x00 }, + { 0x00, 0x00, 0x08, 0x1C, 0x2A, 0x2A, 0x0A, 0x0C, 0x18, 0x28, 0x28, 0x2A, 0x2A, 0x1C, 0x08, 0x08 }, + { 0x00, 0x00, 0x00, 0x22, 0x25, 0x15, 0x15, 0x15, 0x2A, 0x58, 0x54, 0x54, 0x54, 0x22, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x0C, 0x12, 0x12, 0x12, 0x0A, 0x76, 0x25, 0x29, 0x11, 0x91, 0x6E, 0x00, 0x00 }, + { 0x00, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x00 }, + { 0x00, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x02, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x1C, 0x1C, 0x6B, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x7F, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x04, 0x03 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00 }, + { 0x00, 0x00, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x00 }, + { 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x08, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x20, 0x20, 0x10, 0x08, 0x04, 0x42, 0x7E, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x20, 0x18, 0x20, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x20, 0x30, 0x28, 0x24, 0x24, 0x22, 0x22, 0x7E, 0x20, 0x20, 0x78, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x02, 0x1A, 0x26, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x38, 0x24, 0x02, 0x02, 0x1A, 0x26, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x7E, 0x22, 0x22, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x64, 0x58, 0x40, 0x40, 0x24, 0x1C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x04 }, + { 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x46, 0x40, 0x20, 0x10, 0x10, 0x00, 0x18, 0x18, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x5A, 0x55, 0x55, 0x55, 0x55, 0x2D, 0x42, 0x22, 0x1C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x08, 0x08, 0x18, 0x14, 0x14, 0x24, 0x3C, 0x22, 0x42, 0x42, 0xE7, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x1F, 0x22, 0x22, 0x22, 0x1E, 0x22, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x01, 0x01, 0x01, 0x01, 0x01, 0x42, 0x22, 0x1C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x1F, 0x22, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x42, 0x42, 0x3F, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x01, 0x01, 0x01, 0x71, 0x21, 0x22, 0x22, 0x1C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x0F }, + { 0x00, 0x00, 0x00, 0x77, 0x22, 0x12, 0x0A, 0x0E, 0x0A, 0x12, 0x12, 0x22, 0x22, 0x77, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x42, 0x7F, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x77, 0x36, 0x36, 0x36, 0x36, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x6B, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0xE3, 0x46, 0x46, 0x4A, 0x4A, 0x52, 0x52, 0x52, 0x62, 0x62, 0x47, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x42, 0x3E, 0x02, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x4D, 0x53, 0x32, 0x1C, 0x60, 0x00 }, + { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x3E, 0x12, 0x12, 0x22, 0x22, 0x42, 0xC7, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x02, 0x04, 0x18, 0x20, 0x40, 0x42, 0x42, 0x3E, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x7F, 0x49, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x22, 0x24, 0x24, 0x14, 0x14, 0x18, 0x08, 0x08, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x6B, 0x49, 0x49, 0x49, 0x49, 0x55, 0x55, 0x36, 0x22, 0x22, 0x22, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x18, 0x18, 0x18, 0x24, 0x24, 0x42, 0xE7, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x77, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x7E, 0x21, 0x20, 0x10, 0x10, 0x08, 0x04, 0x04, 0x42, 0x42, 0x3F, 0x00, 0x00 } + { 0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00 }, + { 0x00, 0x00, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40, 0x40 }, + { 0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00 }, + { 0x00, 0x38, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF }, + { 0x00, 0x06, 0x06, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x78, 0x44, 0x42, 0x42, 0xFC, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x1A, 0x26, 0x42, 0x42, 0x42, 0x26, 0x1A, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x02, 0x02, 0x02, 0x44, 0x38, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x60, 0x40, 0x40, 0x40, 0x78, 0x44, 0x42, 0x42, 0x42, 0x64, 0xD8, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x7E, 0x02, 0x02, 0x42, 0x3C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0xF0, 0x88, 0x08, 0x08, 0x7E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x22, 0x22, 0x1C, 0x02, 0x3C, 0x42, 0x42, 0x3C }, + { 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x1E }, + { 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x72, 0x12, 0x0A, 0x16, 0x12, 0x22, 0x77, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x92, 0x92, 0x92, 0x92, 0x92, 0xB7, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x46, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x26, 0x42, 0x42, 0x42, 0x22, 0x1E, 0x02, 0x07 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x44, 0x78, 0x40, 0xE0 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x4C, 0x04, 0x04, 0x04, 0x04, 0x1F, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x02, 0x3C, 0x40, 0x42, 0x3E, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x30, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x42, 0x42, 0x42, 0x42, 0x62, 0xDC, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x14, 0x08, 0x08, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEB, 0x49, 0x49, 0x55, 0x55, 0x22, 0x22, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x24, 0x18, 0x18, 0x18, 0x24, 0x6E, 0x00, 0x00 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x14, 0x18, 0x08, 0x08, 0x07 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x22, 0x10, 0x08, 0x08, 0x44, 0x7E, 0x00, 0x00 }, + { 0x00, 0xC0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xC0, 0x00 }, + { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 }, + { 0x00, 0x06, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x00 }, + { 0x0C, 0x32, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } +}; + */ diff --git a/src/flappy.c b/src/flappy.c index 2ec61876..ac6fd416 100644 --- a/src/flappy.c +++ b/src/flappy.c @@ -47,8 +47,8 @@ extern const uint8_t fbBird0[]; extern const uint8_t fbBird1[]; extern const uint8_t fbBird2[]; extern const uint8_t fbBirdDead[]; -extern const uint8_t fbFont[95][16]; - +extern const uint8_t fbFont[16][16]; +extern const uint8_t fbFontDigit[10][16]; //------------------------------------------------------------------------- #define FB_NUM_TIMERS 3 @@ -244,11 +244,15 @@ __myevic__ void fbDrawSprite( int x, int y, int w, int h, const uint8_t bitmap[] //========================================================================= //----- (00007F9C) -------------------------------------------------------- -__myevic__ void fbDrawChar( int x, int y, const char c ) +__myevic__ void fbDrawChar( int x, int y, const uint8_t c ) { - fbDrawSprite( x, y, 8, 16, fbFont[c-32] ); + fbDrawSprite( x, y, 8, 16, fbFont[c] ); } +__myevic__ void fbDrawDigit( int x, int y, const uint8_t c ) +{ + fbDrawSprite( x, y, 8, 16, fbFontDigit[c] ); +} //========================================================================= //----- (00007FB8) -------------------------------------------------------- @@ -281,7 +285,7 @@ __myevic__ void fbDrawNumber( int x, int y, int nd, int v ) break; } - fbDrawChar( x, y, '0' + d ); + fbDrawDigit( x, y, d ); x += 8; } } @@ -289,7 +293,7 @@ __myevic__ void fbDrawNumber( int x, int y, int nd, int v ) //========================================================================= //----- (0000803E) -------------------------------------------------------- -__myevic__ void fbDrawText( int x, int y, const char *s ) +__myevic__ void fbDrawText( int x, int y, const uint8_t *s ) { for ( ; *s ; ++s ) { @@ -486,8 +490,13 @@ __myevic__ void fbDeathScreen() fbDrawColumn( &fbColumn3 ); fbDrawRect( 26, 16, 98, 52, 0, 1 ); fbDrawRect( 26, 16, 98, 52, 1, 0 ); - fbDrawText( 27, 18, "SCORE" ); - fbDrawText( 27, 36, "BEST" ); + //fbDrawText( 27, 18, "SCORE" ); + //fbDrawText( 27, 36, "BEST" ); + const uint8_t Str_BS [] = { 2, 5, 12, 13, 0 }; + const uint8_t Str_SC [] = { 12, 3, 9, 11, 5, 0 }; + fbDrawText( 27, 18, Str_SC ); + fbDrawText( 27, 36, Str_BS ); + fbDrawNumber( 71, 18, fbNumDigits( fbScore ), fbScore ); fbDrawNumber( 71, 36, fbNumDigits( dfFBBest ), dfFBBest ); DisplayRefresh(); @@ -658,7 +667,10 @@ __myevic__ void fbStartScreen() fbAnimStep = 1; } fbSetBirdColumn( 100 ); - fbDrawText( 10, fbBirdLine + 16, "Flappy Bird" ); + //fbDrawText( 10, fbBirdLine + 16, "FLAPPY BIRD" ); + const uint8_t Str_FB [] = { 6, 8, 1, 10, 10, 14, 15, 2, 7, 11, 4, 0 }; + fbDrawText( 10, fbBirdLine + 16, Str_FB ); + fbBirdAnim( fbBirdLine + 16 ); DisplayRefresh(); fbCLSBuf(); @@ -698,7 +710,8 @@ __myevic__ void fbStartGame() fbInitTimeouts(); ClearScreenBuffer(); DisplayRefresh(); - fbBirdAnim( 24 ); + fbAnimStep = 0; + //fbBirdAnim( 24 ); fbCreateTimeout( fbStartScreen + 1 ); } } diff --git a/src/fonts.c b/src/fonts.c index a21e759e..51dc7a0a 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -1,7 +1,7 @@ #include "display.h" #define __block1__ __attribute__((section (".imgblock1"))) -#define __block2__ __attribute__((section (".imgblock2"))) +//#define __block2__ __attribute__((section (".imgblock2"))) const image_t f0img1306_0001 = { 6, 8, { 62, 127, 65, 127, 62, 0 } }; const image_t f0img1306_0002 = { 6, 8, { 0, 2, 127, 127, 0, 0 } }; @@ -223,8 +223,7 @@ const image_t f0img1306_00FB = { 22, 24, { 112, 216, 140, 140, 216, 112, 0, 0, 0 const image_t f0img1306_00FC = { 6, 8, { 0, 8, 8, 62, 8, 8 } }; const image_t f0img1306_00FD = { 6, 8, { 0, 8, 8, 8, 8, 8 } }; const image_t f0img1306_00FE = { 64, 64, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 224, 128, 0, 0, 0, 0, 0, 0, 0, 2, 204, 48, 48, 204, 2, 0, 0, 2, 254, 2, 254, 2, 0, 0, 0, 0, 0, 0, 0, 128, 224, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 6, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 6, 12, 8, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 8, 12, 6, 3, 3, 0, 0, 0, 0, 0, 16, 32, 32, 192, 192, 32, 32, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 64, 64, 64, 64, 64, 64, 64, 224, 58, 17, 17, 16, 16, 17, 17, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 5, 5, 5, 5, 5, 5, 5, 15, 0, 0, 0, 0, 0, 128, 128, 192, 96, 32, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 32, 96, 192, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 96, 0, 0, 0, 0, 0, 0, 128, 128, 128, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 96, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 1, 0, 0, 0, 0, 0, 0, 0, 64, 127, 64, 0, 0, 96, 24, 6, 1, 6, 24, 96, 0, 0, 0, 0, 0, 0, 1, 7, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; -const image_t f0img1306_00FF = { 64, 128, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; - +const image_t f0img1306_00FF = {64,128,{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,16,64,96,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,96,0,0,0,3,0,128,32,0,0,0,0,0,0,0,32,64,64,128,128,0,0,0,0,64,0,160,0,0,0,0,136,0,64,0,0,0,8,0,18,0,0,48,0,0,0,1,2,4,16,32,0,1,0,0,18,240,0,0,0,132,133,0,0,0,128,1,0,4,0,0,0,0,0,0,0,0,0,16,0,34,64,64,0,1,2,36,0,0,160,7,2,0,1,1,0,0,64,64,0,129,128,0,0,0,0,0,192,0,0,1,2,4,64,14,0,12,24,128,96,145,6,48,0,192,32,24,4,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,8,80,18,33,32,65,64,80,96,119,132,128,4,16,0,0,0,32,0,0,13,19,1,0,8,0,64,0,0,72,26,32,96,192,128,0,0,127,0,128,0,19,94,115,48,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,4,16,32,64,2,4,226,17,192,32,34,0,0,0,0,1,6,6,0,72,80,32,64,128,0,96,0,96,48,0,0,0,128,0,0,0,0,2,1,31,1,1,128,224,30,0,1,255,0,192,32,24,4,2,0,0,0,0,128,0,64,64,32,32,2,3,1,0,82,18,4,70,7,4,8,136,80,48,48,80,72,72,132,132,0,0,8,9,95,24,48,32,32,32,34,34,53,48,48,16,16,16,58,252,132,66,227,113,49,11,6,7,75,0,16,16,8,0,4,2,2,1,0,0,0,0,0,0,0,0,0,0,128,2,0,4,32,1,1,128,64,96,48,48,24,12,6,131,77,33,30,52,100,128,0,32,32,32,32,160,160,96,113,26,136,198,98,89,53,255,223,4,130,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,72,10,8,12,12,32,48,8,14,24,18,16,0,0,0,32,4,4,0,16,0,0,0,0,1,10,236,57,56,230,129,192,224,127,51,49,24,24,12,14,7,7,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,128,128,128,128,128,32,32,16,144,144,0,9,136,132,19,224,248,62,31,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,192,192,192,192,224,0,0,0,0,0,0,0,0,0,0,128,192,64,32,144,16,8,4,2,34,33,33,65,1,128,0,64,64,65,65,65,65,1,193,65,65,193,97,67,103,46,60,56,112,224,224,192,128,0,0,0,0,0,0,0,0,0,0,7,255,255,255,255,255,252,248,240,224,128,0,0,0,0,0,2,0,0,32,0,0,16,64,33,17,141,70,34,20,72,41,2,8,12,40,0,1,129,0,0,6,0,2,0,0,128,128,128,128,128,129,129,131,135,14,28,56,112,112,224,192,128,0,240,249,255,255,255,255,255,255,255,255,15,0,0,0,0,0,56,0,0,4,76,0,32,32,0,1,0,128,224,0,16,8,0,4,0,2,2,1,1,1,49,9,5,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,7,15,15,31,31,255,255,127,127,255,231,224,224,192,192,192,224,0,0,1,0,2,3,2,2,20,12,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,71,127,60,0,0,0,1,1,1,3,3,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; const image_t const *font0_1306[] __block1__ = { &f0img1306_0001, @@ -484,6 +483,7 @@ const image_t const *font0_1306[] __block1__ = &f0img1306_00FF }; +/* const image_t f1img1306_0001 = { 6, 8, { 0, 62, 65, 65, 62, 0 } }; const image_t f1img1306_0002 = { 6, 8, { 0, 0, 0, 54, 0, 0 } }; const image_t f1img1306_0003 = { 6, 8, { 0, 48, 73, 73, 6, 0 } }; @@ -923,5 +923,6 @@ const image_t const *font1_1306[] __block1__ = &f1img1306_00FE, &f0img1306_00FF }; +*/ diff --git a/src/main.c b/src/main.c index f0ca9161..a779730e 100644 --- a/src/main.c +++ b/src/main.c @@ -12,6 +12,7 @@ #include "meusbd.h" #include "miscs.h" #include "flappy.h" +#include "tetris.h" //========================================================================= @@ -830,9 +831,32 @@ __myevic__ void Main() gFlags.tick_100hz = 0; ResetWatchDog(); TimedItems(); - SleepIfIdle(); + //SleepIfIdle(); GetUserInput(); - if ( !PE0 ) + //if ( !PE0 ) + // SleepTimer = 3000; + } + if ( gFlags.tick_10hz ) + { + // 10Hz + gFlags.tick_10hz = 0; + DataFlashUpdateTick(); + } + } + + while ( gFlags.playing_tt ) + { + // Tetris game loop + ttCallTimeouts(); + if ( gFlags.tick_100hz ) + { + // 100Hz + gFlags.tick_100hz = 0; + ResetWatchDog(); + TimedItems(); + //SleepIfIdle(); + GetUserInput(); + //if ( !PE0 ) SleepTimer = 3000; } if ( gFlags.tick_10hz ) @@ -842,7 +866,7 @@ __myevic__ void Main() DataFlashUpdateTick(); } } - + if ( gFlags.firing ) { ReadAtoCurrent(); diff --git a/src/mainview.c b/src/mainview.c index ec34eb1d..88909d81 100644 --- a/src/mainview.c +++ b/src/mainview.c @@ -53,25 +53,25 @@ __myevic__ void DrawMode() switch ( dfMode ) { case 0: - DrawString( String_TEMP, 0, 2 ); + DrawString( String_TEMP, 10, 0 ); break; case 1: - DrawString( String_TEMP, 0, 2 ); + DrawString( String_TEMP, 10, 0 ); break; case 2: - DrawString( String_TEMP, 0, 2 ); + DrawString( String_TEMP, 10, 0 ); break; case 3: - DrawString( String_TCR, 0, 2 ); + DrawString( String_TCR, 1, 0 ); break; case 4: - DrawString( String_POWER, 0, 2 ); + DrawStringCentered( String_POWER, 0 ); break; case 5: - DrawString( String_BYPASS, 0, 2 ); + DrawStringCentered( String_BYPASS, 0 ); break; case 6: - DrawString( String_SMART, 13, 4 ); + DrawStringCentered( String_SMART, 0 ); break; default: break; @@ -83,21 +83,21 @@ __myevic__ void DrawMode() switch ( dfMode ) { case 0: - DrawString( String_NI, 32, 2 ); + DrawString( String_NI, 42, 0 ); break; case 1: - DrawString( String_TI, 32, 2 ); + DrawString( String_TI, 42, 0 ); break; case 2: - DrawString( String_SS, 32, 2 ); - DrawImage( 48, 3, 0x04 ); - DrawImage( 54, 3, 0x02 ); - DrawImage( 59, 3, 0x07 ); + DrawString( String_SS, 42 , 0 ); + //DrawImage( 48, 3, 0x04 ); + //DrawImage( 54, 3, 0x02 ); + //DrawImage( 59, 3, 0x07 ); break; case 3: - DrawValue( 25, 2, dfTCRM[dfTCRIndex], 0, 0x0B, 3 ); - DrawImage( 49, 2, 0xA8 ); - DrawValue( 57, 2, dfTCRIndex + 1, 0, 0x0B, 1 ); + DrawValue( 26, 0, dfTCRM[dfTCRIndex], 0, 0x0B, 3 ); + DrawImage( 49, 0, 0xA8 ); + DrawValue( 57, 0, dfTCRIndex + 1, 0, 0x0B, 1 ); break; default: break; @@ -490,7 +490,7 @@ __myevic__ void DrawPower( int pwr ) yp = 13; DrawValue( 5, 13, pwr, 1, 0x48, 2 ); - DrawImage( 45, 18, 0xB9 ); + DrawImage( 46, 19, 0xB9 ); } else { @@ -507,7 +507,7 @@ __myevic__ void DrawPower( int pwr ) // DrawValue( 0, 18, pwr, 1, 0x29, 4 ); } - DrawImage( 54, 26, 0x98 ); + DrawImage( 54, 27, 0x98 ); } if ( ISMODEVW(dfMode) ) @@ -687,22 +687,22 @@ __myevic__ void ShowMainView() anim3d( 1 ); } else if ( dfStatus.clock ) - { + { if ( dfStatus.digclk ) { - DrawDigitClock( 63 ); + DrawDigitClock( 58 ); } else - { - DrawFillRect( 0, 44, 63, 127, 0 ); - DrawClock( 54 ); + { + DrawFillRect( 0, 44, 63, 127, 0 ); + DrawClock( 54 ); } } else { - DrawInfoLines(); - } - } + if ( !dfStatus.logomid || (dfStatus.logomid && HideLogo) ) DrawInfoLines(); + } + } if (( Screen == 1 ) && ( !HideLogo )) { @@ -710,11 +710,14 @@ __myevic__ void ShowMainView() if ( h > 0 ) { + if (dfStatus.clock) DrawFillRect( 0, 48, 63, 106, 0 ); if ( h > 40 ) - { - DrawFillRect( 0, 48, 63, h, 0 ); - } - DrawLOGO( 0, dfStatus.logomid ? 46 : 0 ); + { + + DrawLOGO( 0, dfStatus.logomid ? 50 : 0 ); + } else { + DrawLOGO( 0, dfStatus.logomid ? 56 : 0 ); + } } } } diff --git a/src/megpio.c b/src/megpio.c index 095ca990..8b67bd39 100644 --- a/src/megpio.c +++ b/src/megpio.c @@ -143,7 +143,7 @@ __myevic__ void InitGPIO() } else if ( ISRX300 ) { - SYS->GPF_MFPL &= ~(SYS_GPF_MFPL_PF5MFP_Msk|SYS_GPF_MFPL_PF5MFP_Msk); + SYS->GPF_MFPL &= ~(SYS_GPF_MFPL_PF5MFP_Msk|SYS_GPF_MFPL_PF6MFP_Msk); SYS->GPF_MFPL |= SYS_GPF_MFPL_PF5MFP_GPIO|SYS_GPF_MFPL_PF6MFP_GPIO; PF5 = 0; GPIO_SetMode( PF, GPIO_PIN_PIN5_Msk, GPIO_MODE_OUTPUT ); diff --git a/src/menus.c b/src/menus.c index 65ce7555..db7503c2 100644 --- a/src/menus.c +++ b/src/menus.c @@ -6,6 +6,7 @@ #include "dataflash.h" #include "miscs.h" #include "flappy.h" +#include "tetris.h" #include "meusbd.h" #include "atomizer.h" #include "battery.h" @@ -364,6 +365,14 @@ __myevic__ void ClicksMenuIDraw( int it, int line, int sel ) case CLICK_ACTION_PROFILE: DrawString( String_ProfPlus, 20, line+2 ); break; + + case CLICK_ACTION_GAME: + DrawString( String_Game, 20, line+2 ); + break; + + case CLICK_ACTION_TETRIS: + DrawString( String_Tetris, 20, line+2 ); + break; } } @@ -461,15 +470,15 @@ __myevic__ void IFMenuIDraw( int it, int line, int sel ) DrawString( dfStatus.wakeonpm ? String_On : String_Off, 44, line+2 ); break; - case 3: // Font - DrawImage( 44, line+2, dfStatus.font ? 0x9D : 0x9C ); - break; + //case 3: // Font + // DrawImage( 44, line+2, dfStatus.font ? 0x9D : 0x9C ); + // break; - case 4: // Temp + case 3: // Temp DrawImage( 44, line+2, dfIsCelsius ? 0xC9 : 0xC8 ); break; - case 5: // TDom + case 4: // TDom DrawString( dfStatus.priopwr ? String_On : String_Off, 44, line+2 ); break; @@ -508,12 +517,12 @@ __myevic__ void IFMenuOnClick() dfStatus.wakeonpm ^= 1; break; - case 3: // Font - dfStatus.font ^= 1; - DisplaySetFont(); - break; + //case 3: // Font + // dfStatus.font ^= 1; + // DisplaySetFont(); + // break; - case 4: // Temp + case 3: // Temp dfIsCelsius ^= 1; if ( dfIsCelsius ) { @@ -532,7 +541,7 @@ __myevic__ void IFMenuOnClick() } break; - case 5: // TDom + case 4: // TDom dfStatus.priopwr ^= 1; break; @@ -659,6 +668,7 @@ __myevic__ int PreheatMEvent( int event ) if ( dfPreheatPwr > MaxPower ) dfPreheatPwr = MaxPower; if ( dfPreheatPwr < 10 ) dfPreheatPwr = 10; } + gFlags.edit_value = 1; } gFlags.edit_value ^= 1; UpdateDFTimer = 50; @@ -1133,6 +1143,22 @@ __myevic__ void GameIClick() fbStartGame(); } +__myevic__ void GameTtMEnter() +{ + CurrentMenuItem = dfTTSpeed; +} + +__myevic__ void GameTtISelect() +{ + dfTTSpeed = CurrentMenuItem; + UpdateDFTimer = 50; +} + +__myevic__ void GameTtIClick() +{ + ttStartGame(); +} + //----------------------------------------------------------------------------- __myevic__ void ModesMEnter() @@ -1489,7 +1515,23 @@ const menu_t GameMenu = { String_Back, 0, EVENT_PARENT_MENU, 0 } } }; - +const menu_t GameTtMenu = +{ + String_Tetris, + &MiscsMenu, + GameTtMEnter+1, + 0, + GameTtISelect+1, + GameTtIClick+1, + 0, + 4, + { + { String_Easy, 0, 0, 0 }, + { String_Normal, 0, 0, 0 }, + { String_Survival, 0, 0, 0 }, + { String_Back, 0, EVENT_PARENT_MENU, 0 } + } +}; const menu_t ModesMenu = { String_Modes, @@ -1795,9 +1837,10 @@ const menu_t MiscsMenu = 0, 0, 0, - 4, + 5, { { String_Game, &GameMenu, 0, MACTION_SUBMENU }, + { String_Tetris, &GameTtMenu, 0, MACTION_SUBMENU }, { String_Led, &LedMenu, 0, MACTION_SUBMENU }, { String_3D, &Object3DMenu, 0, MACTION_SUBMENU }, { String_Back, 0, EVENT_PARENT_MENU, 0 } @@ -2063,12 +2106,12 @@ const menu_t IFMenu = 0, IFMenuOnClick+1, 0, - 8, + 7, { { String_1Watt, 0, 0, 0 }, { String_1C5F, 0, 0, 0 }, { String_WakeMP, 0, 0, 0 }, - { String_Font, 0, 0, 0 }, + // { String_Font, 0, 0, 0 }, { String_Temp, 0, 0, 0 }, { String_PPwr, 0, 0, 0 }, { String_Clicks, &ClicksMenu, 0, MACTION_SUBMENU }, diff --git a/src/myrtc.c b/src/myrtc.c index 2c75dcaa..4530237e 100644 --- a/src/myrtc.c +++ b/src/myrtc.c @@ -58,7 +58,7 @@ __myevic__ time_t time_to_epoch ( const struct tm *ltm, int utcdiff ) tyears = ltm->tm_year - 70 ; // tm->tm_year is from 1900. leaps = (tyears + 2) / 4; // no of next two lines until year 2100. - //i = (ltm->tm_year – 100) / 100; + //i = (ltm->tm_year � 100) / 100; //leaps -= ( (i/4)*3 + i%4 ); tdays = 0; for (i=0; i < ltm->tm_mon; i++) tdays += mon_days[i]; @@ -123,7 +123,7 @@ __myevic__ void RTCTimeToEpoch( time_t *t, const S_RTC_TIME_DATA_T *d ) s.tm_min = d->u32Minute; s.tm_sec = d->u32Second; s.tm_yday = 0; - s.tm_wday = 0; + s.tm_wday = d->u32DayOfWeek; s.tm_isdst = 0; *t = time_to_epoch( &s, 0 ); diff --git a/src/strings.c b/src/strings.c index 471735f5..b25d9ada 100644 --- a/src/strings.c +++ b/src/strings.c @@ -28,6 +28,7 @@ __string__ String_Right [] = { 0xAD, 0x8A, 0x88, 0x89, 0x95, 0 }; // "Right" __string__ String_Left [] = { 0xA7, 0x86, 0x87, 0x95, 0 }; // "Left" __string__ String_Logo [] = { 0xA7, 0x90, 0x88, 0x90, 0 }; // "Logo" __string__ String_Game [] = { 0xA2, 0x82, 0x8E, 0x86, 0 }; // "Game" +__string__ String_Tetris [] = { 0xAF, 0x86, 0x95, 0x93, 0x8A, 0x94, 0 }; // "Tetris" __string__ String_Easy [] = { 0xA0, 0x82, 0x94, 0x9A, 0 }; // "Easy" __string__ String_Normal [] = { 0xA9, 0x90, 0x93, 0x8E, 0x82, 0x8D, 0 }; // "Normal" __string__ String_Hard [] = { 0xA3, 0x82, 0x93, 0x85, 0 }; // "Hard" @@ -196,4 +197,13 @@ __string__ String_ProfPlus [] = { 0xAB, 0x93, 0x90, 0x87, 0xC1, 0xBD, 0xD4, 0xD4 __string__ String_Curve [] = { 0x9E, 0x96, 0x93, 0x97, 0x86, 0 }; __string__ String_Enable [] = { 0xA0, 0x8F, 0x82, 0x83, 0x8D, 0x86, 0 }; __string__ String_Reset [] = { 0xAD, 0x86, 0x94, 0x86, 0x95, 0 }; -__string__ String_Splash [] = { 0xAE, 0x91, 0x8D, 0x82, 0x94, 0x89, 0 }; +__string__ String_Splash [] = { 0xAE, 0x91, 0x8D, 0x82, 0x94, 0x89, 0 }; +__string__ String_Sunday [] = { 0xAE, 0x7C, 0x75, 0x6B, 0x68, 0x80, 0 }; +__string__ String_Monday [] = { 0xA8, 0x76, 0x75, 0x6B, 0x68, 0x80, 0 }; +__string__ String_Tuesday [] = { 0xAF, 0x7C, 0x6C, 0x7A, 0x6B, 0x68, 0x80, 0 }; +__string__ String_Wednesday [] = { 0xB2, 0x6C, 0x6B, 0x75, 0x6C, 0x7A, 0x6B, 0x68, 0x80, 0 }; +__string__ String_Thursday [] = { 0xAF, 0x6F, 0x7C, 0x79, 0x7A, 0x6B, 0x68, 0x80, 0 }; +__string__ String_Friday [] = { 0xA1, 0x79, 0x70, 0x6B, 0x68, 0x80, 0 }; +__string__ String_Saturday [] = { 0xAE, 0x68, 0x7B, 0x7C, 0x79, 0x6B, 0x68, 0x80, 0 }; +__string__ String_Survival [] = { 0xAE, 0x96, 0x93, 0x97, 0x8A, 0x97, 0x82, 0x8D, 0 }; + \ No newline at end of file diff --git a/src/tetris.c b/src/tetris.c new file mode 100644 index 00000000..650d806a --- /dev/null +++ b/src/tetris.c @@ -0,0 +1,866 @@ +#include "myevic.h" +#include "dataflash.h" +#include "display.h" +#include "screens.h" +#include "events.h" +#include "miscs.h" +#include "timers.h" +#include "battery.h" +#include "tetris.h" + +//used: +//http://colinfahey.com/tetris/tetris.html +//https://github.com/AJRussell/Tiny-Tetris +//flappy bird game from Ferox myevic + +extern const uint8_t Blocks[7][2]; + +typedef struct { + uint8_t curBlock[4][4]; //r c + int Row; + int Col; + uint8_t nextBlock[4][4]; +} +PieceSpace; +PieceSpace currentPiece = {0}; +PieceSpace oldPiece = {0}; + +int tetrisScreen[14][24] = { + {1}, + {1} +}; + +uint8_t ttTetrisLine = 14; +uint8_t ttAnimStep = 0; +//uint8_t ttAnimTimer = 0; +uint16_t ttScore; +int levellineCount = 0; +//uint8_t score = 0; +uint8_t ttTimeoutMask = 0; +uint8_t ttCurrentTimeout = 0; +uint8_t ttUsedTimeouts = 0; +uint8_t gameOver; +uint8_t countdown; +uint8_t level; +uint8_t CurPieceNumber; +uint8_t NextPieceNumber; +uint8_t nSZ = 3; //for rotate + +uint8_t ttKeyDown = 0; +uint8_t ttFireDown = 0; +uint8_t ttLongFireDown = 0; +uint16_t ttKeyTick = 0; +//uint16_t ttKeyPressTime = 0; +uint8_t pause = 0; +uint8_t ScrFlip; +int bto; +uint8_t FastMove = 0; //for score +uint8_t noShift = 1; +uint8_t noRotate = 1; + +//------------------------------------------------------------------------- + +#define TT_NUM_TIMERS 3 + +typedef void (TT_TIMEOUT_FUNC(void)); + +typedef struct ttTimeout_s { + uint8_t delay; + TT_TIMEOUT_FUNC *function; +} +ttTimeout_t; +ttTimeout_t ttTimeoutsTable[TT_NUM_TIMERS]; + +void ttInitTimeouts() { + ttCurrentTimeout = 0; + ttUsedTimeouts = 0; + + for (int i = 0; i < TT_NUM_TIMERS; ++i) { + ttTimeoutsTable[i].delay = 0; + ttTimeoutsTable[i].function = 0; + } +} + +void ttTickTimeouts() { + for (int i = 0; i < TT_NUM_TIMERS; ++i) { + if (ttTimeoutsTable[i].delay) { + --ttTimeoutsTable[i].delay; + } + } +} + +void ttDeleteTimeout(int to) { + ttUsedTimeouts &= ~(1 << to); + ttTimeoutsTable[to].delay = 0; +} + +void ttSetTimeoutDelay(int v) { + ttTimeoutsTable[ttCurrentTimeout].delay = v; +} + +void ttCallTimeouts() { + ttTimeoutMask = 1; + + for (ttCurrentTimeout = 0; ttCurrentTimeout < TT_NUM_TIMERS; ++ttCurrentTimeout) { + if (ttUsedTimeouts & ttTimeoutMask) { + if (!ttTimeoutsTable[ttCurrentTimeout].delay) { + ttTimeoutsTable[ttCurrentTimeout].function(); + } + } + ttTimeoutMask <<= 1; + } +} + +int ttCreateTimeout(TT_TIMEOUT_FUNC f) { + uint8_t mask = 1; + + for (int i = 0; i < TT_NUM_TIMERS; ++i) { + if (!(mask & ttUsedTimeouts)) { + ttUsedTimeouts |= mask; + ttTimeoutsTable[i].function = f; + return i; + } + mask <<= 1; + } + return -1; +} + +void ttCLSBuf() { + MemClear2(0, ScreenBuffer, SCREEN_BUFFER_SIZE); +} + +void LoadPiece(uint8_t BlockFlag, uint8_t pieceNumber, int col, int row) { + + uint8_t r = 0, c = 0; + // uint8_t pieceRow = 0; + // uint8_t pieceColoum = 0; + + for (uint8_t i = 0; i < 2; i++) { + + //iterate through bit mask + for (uint8_t mask = 1; mask; mask <<= 1) { + + if (BlockFlag == 0) { //current + + if (mask & Blocks[pieceNumber][i]) { + //0b 0110 0000, 0b 0000 1100 Z + // c 3210 3210 + // r 1 0 3 2 + // 0123 + // 0 0000 + // 1 0110 + // 2 0011 + // 3 0000 + currentPiece.curBlock[r][c] = 1; + + } else { + currentPiece.curBlock[r][c] = 0; + + } + } else { //next + + if (mask & Blocks[pieceNumber][i]) { + + currentPiece.nextBlock[r][c] = 1; + + } else { + currentPiece.nextBlock[r][c] = 0; + + } + } + + c++; //c + if (c >= 4) { + c = 0; + r++; //r + } + } + } + + if (BlockFlag == 0) { //current + currentPiece.Row = row; + currentPiece.Col = col; + CurPieceNumber = pieceNumber; + + //if (loadScreen == 1) { + oldPiece = currentPiece; + + /* + for (int r = row; r < row - 4; r--) { + for (int c = col; c < col + 4; c++) { + + if (currentPiece.curBlock[pieceRow][pieceColoum]) { + tetrisScreen[c][r] = 2; + + // DrawValue(10, 50, c, 0, 1, 3); + // DrawValue(34, 50, r, 0, 1, 3); + } + pieceColoum++; + } + pieceColoum = 0; + pieceRow++; + } + */ + //} + } else { + NextPieceNumber = pieceNumber; + } +} + +void fillTetrisArray() { + //+2 for border + // x 0 1 (2 3 4 5 6 7 8 9 A B) C D + // + for (uint8_t r = 0; r < 24; r++) { + for (uint8_t c = 0; c < 14; c++) { + tetrisScreen[c][r] = 1; + } + } +} + +void fillTetrisScreen(uint8_t value) { + + for (uint8_t r = 2; r < 22; r++) { + for (uint8_t c = 2; c < 12; c++) { + tetrisScreen[c][r] = value; + } + } +} + +int oledX(int x) { + int ox; + ox = (x - 2) * 6 + 2; //start x = 2 + return ox; +} + +int oledY(int y) { + int oy; + oy = 122 - (y - 2) * 6; //121 + return oy; +} + +void DrawPiece(int X, int Y, uint8_t draw) { + // 0000 + // 01*0 + // 0011 + // 0000 + + X = oledX(X); + Y = oledY(Y); + + for (int r = 0; r < 4; r++) { + for (int c = 0; c < 4; c++) { + + int x1 = c * 6 + X; + int y1 = r * 6 + Y; + int x2 = x1 + 4; + int y2 = y1 + 4; + + if (!draw) { + if (oldPiece.curBlock[r][c]) { + DrawFillRect(x1, y1, x2, y2, draw); + } + } else if (currentPiece.curBlock[r][c]) { + DrawFillRect(x1, y1, x2, y2, draw); + } + } + } + DisplayRefresh(); +} + +void DrawNext(int X, int Y) { + + for (int r = 0; r < 3; r++) { + for (int c = 0; c < 4; c++) { + int x1 = c * 4 + X; + int y1 = r * 4 + Y; + int x2 = x1 + 2; + int y2 = y1 + 2; + DrawFillRect(x1, y1, x2, y2, currentPiece.nextBlock[r][c]); + } + } + DisplayRefresh(); +} + +void DrawDot(int X, int Y, uint8_t dot) { + X = oledX(X); + Y = oledY(Y); + DrawFillRect(X, Y, X + 4, Y + 4, dot); +} + +void DrawHole(int X, int Y) { + X = oledX(X); + Y = oledY(Y); + DrawFillRect(X + 1, Y + 1, X + 3, Y + 3, 0); +} + +void DrawBoard() { + //21 + // . 0..3 + // . .*** + // 4 ...* + // 3 3... + // 2 3 4 ... 11 + for (int r = 2; r < 22; r++) { + for (int c = 2; c < 12; c++) { + if (tetrisScreen[c][r] == 3) tetrisScreen[c][r] = 0; + if (tetrisScreen[c][r] == 1) { + //if (tetrisScreen[c][r]) { + DrawDot(c, r, 1); + } else + DrawDot(c, r, 0); + } + } +} + +void DrawTTCup() { + //DrawHLine( const int x1, const int y, const int x2, const int color ) + DrawHLine(0, 127, 62, 1); + //DrawVLine( const int x, const int y1, const int y2, const int color ) + DrawVLine(0, 8, 127, 1); + DrawVLine(62, 8, 127, 1); +} + +int CheckCollision() { + + uint8_t pieceRow = 0; + uint8_t pieceCol = 0; + int Col = currentPiece.Col; + int Row = currentPiece.Row; + + for (int r = Row; r > Row - 4; r--) { + for (int c = Col; c < Col + 4; c++) { + + if (currentPiece.curBlock[pieceRow][pieceCol]) { + if (tetrisScreen[c][r] == 1) { + return 1; + } + } + pieceCol++; + } + pieceCol = 0; + pieceRow++; + } + return 0; +} + +void RotatePiece() { + + uint8_t c; + uint8_t r; + uint8_t i; + uint8_t Fig[4][4] = {0}; + + if (CurPieceNumber == 0) { + return; // O + } + + oldPiece = currentPiece; + + if (CurPieceNumber == 1) { + // I + for (r = 0; r < 4; ++r) { + for (c = 0; c < 4; ++c) { + Fig[r][c] = currentPiece.curBlock[3 - c][3 - r]; + } + } + MemCpy(currentPiece.curBlock, Fig, 16); + + } else if (CurPieceNumber == 2 || CurPieceNumber == 3) { + // S Z + nSZ = nSZ == 1 ? 3 : 1; + + for (i = 0; i < nSZ; ++i) { + + for (r = 0; r < 4; ++r) { + for (c = 1; c < 4; ++c) { + Fig[r][c] = currentPiece.curBlock[c - 1][3 - r]; + } + } + MemCpy(currentPiece.curBlock, Fig, 16); + } + } else { // L J T + for (r = 0; r < 4; ++r) { + for (c = 1; c < 4; ++c) { + Fig[r][c] = currentPiece.curBlock[c - 1][3 - r]; + } + } + MemCpy(currentPiece.curBlock, Fig, 16); + } + + if (CheckCollision()) { + currentPiece = oldPiece; + + } else { + DrawPiece(oldPiece.Col, oldPiece.Row, 0); + DrawPiece(currentPiece.Col, currentPiece.Row, 1); + //DisplayRefresh(); + } +} + +void movePieceLeft() { + + oldPiece = currentPiece; + currentPiece.Col = currentPiece.Col - 1; + + if (CheckCollision()) { + currentPiece = oldPiece; + } else { + DrawPiece(oldPiece.Col, oldPiece.Row, 0); + DrawPiece(currentPiece.Col, currentPiece.Row, 1); + // DisplayRefresh(); + } +} + +void movePieceRight() { + oldPiece = currentPiece; + currentPiece.Col = currentPiece.Col + 1; + + if (CheckCollision()) { + currentPiece = oldPiece; + } else { + DrawPiece(oldPiece.Col, oldPiece.Row, 0); + DrawPiece(currentPiece.Col, currentPiece.Row, 1); + // DisplayRefresh(); + } +} + +void setScore(uint16_t score, uint8_t show) { + //DrawValue(x, y, value, dot_pos, font, num_digits); + if (show) { + DrawValue(34, 0, score, 0, 1, 5); + } else { + DrawFillRect(34, 0, 63, 6, 0); + } +} + +void setLevel(uint16_t lvl, uint8_t show) { + //DrawValue(x, y, value, dot_pos, font, num_digits); + if (show) { + DrawValue(1, 0, lvl, 0, 1, 2); + } else { + DrawFillRect(1, 0, 12, 6, 0); + } +} + +void CompletedLines() { + + //int rowCheck = 0; + //int coloumCheck = 0; + uint8_t fullLine = 0; + uint8_t noLine = 1; + uint8_t linesProcessed = 0; + uint8_t clearedLines = 0; + uint8_t topRow = 0; + int bottomRow = 0; + //int currentRow = 0; + uint16_t AmountScored = 0; + + if (currentPiece.Row > 5) bottomRow = currentPiece.Row - 4; + else bottomRow = 1; + + if (currentPiece.Row == 22) topRow = 21; + else topRow = currentPiece.Row; + + for (int rowCheck = topRow; rowCheck > bottomRow; rowCheck--) { + + fullLine = 1; + for (int colCheck = 2; colCheck < 12; colCheck++) { + if (tetrisScreen[colCheck][rowCheck] == 0) { + fullLine = 0; + break; + } + } + + if (fullLine) { + //make line values 3's and render + for (int c = 2; c < 12; c++) { + tetrisScreen[c][rowCheck] = 3; //to del + DrawHole(c, rowCheck); + DisplayRefresh(); + } + // bottomRow = rowCheck - 1; ? + linesProcessed++; + // animation + } + DrawBoard(); + } + + if (linesProcessed) { + + clearedLines = linesProcessed; + + while (clearedLines) { + for (int currentRow = 2; currentRow < 22; currentRow++) { + noLine = 1; + for (int c = 2; c < 12; c++) { + if (tetrisScreen[c][currentRow]) noLine = 0; + } + if (noLine) { + //move all lines down + for (int r = currentRow + 1; r < 22; r++) { + for (int c = 2; c < 12; c++) { + if (tetrisScreen[c][r]) tetrisScreen[c][r - 1] = 2; + else tetrisScreen[c][r - 1] = 3; + } + } + } + } + + //make the 2's 1's + for (int r = 2; r < 22; r++) { + for (int c = 2; c < 12; c++) { + if (tetrisScreen[c][r] == 2) tetrisScreen[c][r] = 1; + } + } + clearedLines--; + DrawBoard(); + } + + + //process score + switch (linesProcessed) { + case 1: + AmountScored = 10; + break; + case 2: + AmountScored = 30; + break; + case 3: + AmountScored = 70; + break; + case 4: + AmountScored = 150; + //do 4 line affect + break; + } + + fullLine = 1; + for (int colCheck = 2; colCheck < 12; colCheck++) { + if (tetrisScreen[colCheck][2]) { + fullLine = 0; + break; + } + } + if (fullLine) AmountScored += 150; //empty board + + FastMove /= 10; + AmountScored += FastMove; // fast drop count + noTouch + noRotate + FastMove = 0; + AmountScored *= level; + + ttScore += AmountScored; + setScore(ttScore, 1); + + //update level line count & level + levellineCount += linesProcessed; + if (levellineCount > 10) { + level++; + levellineCount = 0; + //do level up affect + } + if (dfTTSpeed != 2) { + if (level > 10) gameOver = 1; + } + setLevel(level, 1); + + } + + //make the 2's 1's ? + /* + for (int r = bottomRow; r <= topRow; r++) { + for (int c = 2; c < 12; c++) { + if (tetrisScreen[c][r]) { + tetrisScreen[c][r] = 1; + } + } + } + */ +} + +void DrawLandedPiece() { + // Landed pieces are 1 + uint8_t pieceRow = 0; + uint8_t pieceColoum = 0; + + int Col = currentPiece.Col; + int Row = currentPiece.Row; + + for (int r = Row; r > Row - 4; r--) { + for (int c = Col; c < Col + 4; c++) { + + if (currentPiece.curBlock[pieceRow][pieceColoum]) tetrisScreen[c][r] = 1; + pieceColoum++; + } + pieceColoum = 0; + pieceRow++; + } + + if (CurPieceNumber) FastMove += noRotate * 10; //score bonus + FastMove += noShift * 20; + noRotate = 1; + noShift = 1; + + CompletedLines(); +} + +void movePieceDown() { + uint8_t pieceLanded = 0; + + oldPiece = currentPiece; + currentPiece.Row = currentPiece.Row - 1; + + if (CheckCollision()) { + currentPiece = oldPiece; + + DrawLandedPiece(); + pieceLanded = 1; + + } else { + DrawPiece(oldPiece.Col, oldPiece.Row, 0); + DrawPiece(currentPiece.Col, currentPiece.Row, 1); + //DisplayRefresh(); + } + + if (pieceLanded) { + MemCpy(currentPiece.curBlock, currentPiece.nextBlock, 16); + currentPiece.Row = 22; + currentPiece.Col = 5; + CurPieceNumber = NextPieceNumber; + DrawPiece(currentPiece.Col, currentPiece.Row, 1); + //DisplayRefresh(); + + if (CheckCollision()) { + gameOver = 1; + } else { + //next piece + LoadPiece(1, (uint8_t) Random() % 7, 0, 0); + DrawNext(16, -4); + // DisplayRefresh(); + } + } +} + +void CheckButtons() { + + + if (gameOver) { + ttDeleteTimeout(ttCurrentTimeout); + return; + } + + if (!ttKeyDown) { + + if (!PE0 && (!PD2 || !PD3)) { + ttKeyDown = 0; + return; + } + + if (!PD2 && !PD3) { + pause = pause == 0 ? 1 : 0; + ttKeyDown = 0; + ttSetTimeoutDelay(100); + return; + } + + if (pause) return; + + if (!PD2) { + if (ScrFlip) movePieceLeft(); + else movePieceRight(); + noShift = 0; + ttKeyDown = 1; + ttFireDown = 0; + ttSetTimeoutDelay(bto); + return; + + } else if (!PD3) { + if (ScrFlip) movePieceRight(); + else movePieceLeft(); + noShift = 0; + ttKeyDown = 1; + ttFireDown = 0; + ttSetTimeoutDelay(bto); + return; + + } else if (!PE0) { + if ((!ttFireDown) && (!ttLongFireDown)) { + ttFireDown = 1; + ttSetTimeoutDelay(bto); + } + if (ttKeyTick > 5) { + ttLongFireDown = 1; + //long press + movePieceDown(); + FastMove += 1; + ttSetTimeoutDelay(bto); + } + ++ttKeyTick; + ttKeyDown = 0; + ttSetTimeoutDelay(bto); + return; + } + } + + if (ttFireDown) { + //fire up + if (ttLongFireDown) { + ttLongFireDown = 0; + } else { + // click + RotatePiece(); + noRotate = 0; + ttSetTimeoutDelay(bto); + } + } + + if (PD2 && PD3 && PE0) { + ttKeyDown = 0; + ttFireDown = 0; + ttKeyTick = 0; + ttLongFireDown = 0; + ttSetTimeoutDelay(bto); //for no l-r shift after k_up + } +} + +void ttStartScreen() { + + const uint8_t strVaping[] = {0x7D, 0x68, 0x77, 0x70, 0x75, 0x6E, 0x00}; + const uint8_t strTetris[] = {0xAF, 0xA0, 0xAF, 0xAD, 0xA4, 0xAE, 0x00}; + const uint8_t strBestScore[] = {0x69, 0x6C, 0x7A, 0x7B, 0x00}; + const uint8_t strLastScore[] = {0x8D, 0x82, 0x94, 0x95, 0x00}; + + ttSetTimeoutDelay(10); + if (!PE0 && (PD2 && PD3)) { + + gameOver = 0; + ttScore = 0; + level = 1; + pause = 0; + FastMove = 0; + noRotate = 1; + noShift = 1; + SetRandSeed(TMR1Counter); + ttCLSBuf(); + + fillTetrisArray(); //+2 border + fillTetrisScreen(0); //2-11 x 2-21 + + DrawTTCup(); + setLevel(level, 1); + setScore(0, 1); + + //rnd 0-6 + nSZ = 3; //for rotate + LoadPiece(0, (uint8_t) (Random() % 7), 5, 22); + DrawPiece(currentPiece.Col, currentPiece.Row, 1); + //CheckCollision(); + LoadPiece(1, (uint8_t) Random() % 7, 0, 0); //get next piece + DrawNext(16, -4); + //DisplayRefresh(); + + //KeyUpTimer = 0; + //ttKeyTick = 0; + //ttFireDown = 0; + //ttLongFireDown = 0; + ttKeyDown = 1; + + ttDeleteTimeout(ttCurrentTimeout); + + ttSetTimeoutDelay(100); + ttCreateTimeout(ttGame); + ttCreateTimeout(CheckButtons); + + } else { + + DrawFillRect(0, 18, 63, 84, 0); //erase + + if (ttAnimStep) { + if (++ttTetrisLine == 16) + ttAnimStep = 0; + } else { + --ttTetrisLine; + if (ttTetrisLine == 0) + ttAnimStep = 1; + } + + DrawString(strVaping, 12, ttTetrisLine + 20); + DrawString(strTetris, 12, ttTetrisLine + 30); + + DrawString(strBestScore, 4, 60); + DrawString(strLastScore, 4, 70); + DrawValue(29, 61, dfTTBest, 0, 1, 5); + DrawValue(29, 71, ttScore, 0, 1, 5); + + DrawTTCup(); + DisplayRefresh(); + ttSetTimeoutDelay(10); + //ttCLSBuf(); + } +} + +void ttGame() { + + if (pause) return; + + if (gameOver) { + //ttCLSBuf(); + + if (!PE0) return; + + if (dfTTBest < ttScore) { + dfTTBest = ttScore; + ttSetTimeoutDelay(4); + UpdateDFTimer = 50; + } + + //ClearScreenBuffer(); + //DisplayRefresh(); + ttDeleteTimeout(ttCurrentTimeout); + ttCreateTimeout(ttStartScreen + 1); + + } + + if (dfTTSpeed != 2) countdown = 5 * (11 - level); + ttSetTimeoutDelay(countdown); + + movePieceDown(); +} + +void ttStartGame() { + + UpdateDataFlash(); + if (dfTTSpeed <= 2) { + + if (dfTTBest < ttScore) { + dfTTBest = ttScore; + ttSetTimeoutDelay(4); + UpdateDFTimer = 50; //survive + } + + if (dfTTSpeed == 2) { + bto = 5; + countdown = 50; + } else if (dfTTSpeed == 1) { + bto = 5; + } else { + bto = 3; + } + + ScrFlip = dfStatus.flipped; + gFlags.playing_tt = 1; + Screen = 0; + gFlags.user_idle = 1; //0 + gFlags.refresh_display = 1; + + NoEventTimer = 0; + SleepTimer = 0; + + ttInitTimeouts(); + ClearScreenBuffer(); + DisplayRefresh(); + + ttSetTimeoutDelay(20); + ttCreateTimeout(ttStartScreen + 1); + } +} \ No newline at end of file diff --git a/src/timers.c b/src/timers.c index 79188bf1..3d21a035 100644 --- a/src/timers.c +++ b/src/timers.c @@ -6,6 +6,7 @@ #include "battery.h" #include "atomizer.h" #include "flappy.h" +#include "tetris.h" #include "display.h" #include "miscs.h" @@ -120,6 +121,15 @@ __myevic__ void TMR2_IRQHandler() fbTickTimeouts(); } } + if ( gFlags.playing_tt ) + { + if ( (!(TMR2Counter % 20) && dfTTSpeed == 0) + || (!(TMR2Counter % 10) && (dfTTSpeed == 1 || dfTTSpeed == 2))) + // || (!(TMR2Counter % 5) && dfTTSpeed == 2) ) //5 10 15 + { + ttTickTimeouts(); + } + } } } diff --git a/src/ttdata.c b/src/ttdata.c new file mode 100644 index 00000000..82a024ee --- /dev/null +++ b/src/ttdata.c @@ -0,0 +1,13 @@ +#include +#include + +const uint8_t Blocks[7][2] ={ + { 0b01100000, 0b00000110}, //O + { 0b11110000, 0b00000000}, //I + { 0b11000000, 0b00000110}, //S + { 0b01100000, 0b00001100}, //Z + { 0b11100000, 0b00000010}, //L + { 0b11100000, 0b00001000}, //J + { 0b11100000, 0b00000100} //T + +};