Няшная / Говнокод #28088 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
/*
 *  libcaca       Colour ASCII-Art library
 *  Copyright (c) 2002-2010 Sam Hocevar <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c5b6a4a885adaaa6a0b3a4b7ebaba0b1">[email protected]</a>>
 *                All Rights Reserved
 *
 *  This library is free software. It comes without any warranty, to
 *  the extent permitted by applicable law. You can redistribute it
 *  and/or modify it under the terms of the Do What The Fuck You Want
 *  To Public License, Version 2, as published by Sam Hocevar. See
 *  http://sam.zoy.org/wtfpl/COPYING for more details.
 */

/*
 *  This header contains a conio.h reimplementation.
 */

#ifndef __CACA_CONIO_H__
#define __CACA_CONIO_H__

/* Since we're going to redefine standard functions, include these
 * headers first to avoid errors upon later inclusion. */
#if !defined(__KERNEL__)
#   include <stdio.h>
#endif

#include <caca.h>

#if !defined _DOXYGEN_SKIP_ME && !defined __LIBCACA__
#   undef BLINK
#   define BLINK CACA_CONIO_BLINK
#   undef BLACK
#   define BLACK CACA_CONIO_BLACK
#   undef BLUE
#   define BLUE CACA_CONIO_BLUE
#   undef GREEN
#   define GREEN CACA_CONIO_GREEN
#   undef CYAN
#   define CYAN CACA_CONIO_CYAN
#   undef RED
#   define RED CACA_CONIO_RED
#   undef MAGENTA
#   define MAGENTA CACA_CONIO_MAGENTA
#   undef BROWN
#   define BROWN CACA_CONIO_BROWN
#   undef LIGHTGRAY
#   define LIGHTGRAY CACA_CONIO_LIGHTGRAY
#   undef DARKGRAY
#   define DARKGRAY CACA_CONIO_DARKGRAY
#   undef LIGHTBLUE
#   define LIGHTBLUE CACA_CONIO_LIGHTBLUE
#   undef LIGHTGREEN
#   define LIGHTGREEN CACA_CONIO_LIGHTGREEN
#   undef LIGHTCYAN
#   define LIGHTCYAN CACA_CONIO_LIGHTCYAN
#   undef LIGHTRED
#   define LIGHTRED CACA_CONIO_LIGHTRED
#   undef LIGHTMAGENTA
#   define LIGHTMAGENTA CACA_CONIO_LIGHTMAGENTA
#   undef YELLOW
#   define YELLOW CACA_CONIO_YELLOW
#   undef WHITE
#   define WHITE CACA_CONIO_WHITE
#endif

3_dar 3_dar, (Updated )

Комментарии (3, +3)

Няшная / Говнокод #28071 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
/*
   xdrv_96_blacklist.ino - Blacklist for Tasmota

   SPDX-FileCopyrightText: 2022 Theo Arends

   SPDX-License-Identifier: GPL-3.0-only
 */
 #define USE_BLACKLIST

 #ifdef USE_BLACKLIST
 /*********************************************************************************************\
  * Blacklist support
  *
  * Check language and user set latitude/longitude against blacklist table
 \*********************************************************************************************/
 #define XDRV_96            96

 typedef struct {
   int16_t latitude_tl;    // - 8999 to 8999
   int16_t longitude_tl;   // -17999 to 17999
   int16_t latitude_br;
   int16_t longitude_br;
   uint16_t lcid;
 } tBlArray;

 //const char BlacklistText[] PROGMEM = "Stop war - Free Ukrain|Stop war - Free Ukrain|";
 const char BlacklistText[] PROGMEM = "Stop war, Free Ukrain";

 //                   lat_tl lon_tl lat_br lon_br lcid
 tBlArray BlArray[] {  5900,  3200,  5300,  4400, 1049,     // Around Moscow
                       5450,  2633,  5280,  2900, 1049      // Around Minsk
                    };

 uint8_t blist_show = 0;

 void BListEverySecond(void) {
   if (Rtc.utc_time < 1648771200) {                         // Only until 2022-04-01
     if (0 == (TasmotaGlobal.uptime % 20)) {                // Only every 20 seconds
       if (TasmotaGlobal.power) {                           // Only if any power on
         uint32_t latitude = Settings->latitude / 10000;
         uint32_t longitude = Settings->longitude / 10000;
         uint32_t count = sizeof(BlArray) / sizeof(tBlArray);
         for (uint32_t i = 0; i < count; i++) {
           // Currently only supports top-right quarter of the earth
           if ((LANGUAGE_LCID == BlArray[i].lcid) &&        // Check language id
               (latitude < BlArray[i].latitude_tl) &&       // Check user set latitude and longitude against table
               (latitude > BlArray[i].latitude_br) &&
               (longitude > BlArray[i].longitude_tl) &&
               (longitude < BlArray[i].longitude_br)) {

 //            char bl_text[100];
 //            snprintf_P(bl_text, sizeof(bl_text), PSTR("Power0 0"));   // Turn all power off - annoying
 //            snprintf_P(bl_text, sizeof(bl_text), PSTR("Restart 1"));  // Restart - more annoying
 //            snprintf_P(bl_text, sizeof(bl_text), PSTR("Reset 1"));    // Reset - disastrous
 //            ExecuteCommand(bl_text, SRC_IGNORE);

 //            char bl_text[100];
 //            AddLog(LOG_LEVEL_NONE, PSTR("**** %s ****"), GetTextIndexed(bl_text, sizeof(bl_text), i, BlacklistText));
             AddLog(LOG_LEVEL_NONE, PSTR("**** %s ****"), BlacklistText);
             blist_show = i +1;                             // Set GUI message id
             break;
           }
         }
       }
     } else if (0 == (TasmotaGlobal.uptime % 10)) {         // Only every 10 seconds
       blist_show = 0;                                      // Reset GUI message id after 10 seconds
     }
   }
 }

 void BListShow(bool json) {
   if (blist_show) {
 //    char bl_text[100];
 //    WSContentSend_PD(PSTR("{s}**** %s ****{m}{e}"), GetTextIndexed(bl_text, sizeof(bl_text), blist_show -1, BlacklistText));
     WSContentSend_P(PSTR("{s}**** %s ****{m}{e}"), BlacklistText);
   }
 }

 /*********************************************************************************************\
  * Interface
 \*********************************************************************************************/

 bool Xdrv96(uint8_t function) {
   bool result = false;

   switch (function) {
     case FUNC_EVERY_SECOND:
       BListEverySecond();
       break;
 #ifdef USE_WEBSERVER
     case FUNC_WEB_SENSOR:
       BListShow(0);
       break;
 #endif  // USE_WEBSERVER
   }

   return result;
 }

https://github.com/arendst/Tasmota/commit/98cbf2587a1a914bbd16996ebb48dd451d3da448

3_dar 3_dar, (Updated )

Комментарии (9, +9)

Няшная / Говнокод #28058 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
#include <stdio.h>

int main(void)
{
	(
		*********************
		**  **     ** ***** *
		* ** * **** ** *** **
		* ** * **** *** * ***
		* ** * **** **** ****
		* ** * **** *** * ***
		* ** **    *** *** **
		*********************
	printf)("pidor");
}

kcalbCube kcalbCube, (Updated )

Комментарии (13, +13)

Няшная / Говнокод #28056 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
static char *cast_table[][11] = {
  // i8   i16     i32     i64     u8     u16     u32     u64     f32     f64     f80
  {NULL,  NULL,   NULL,   i32i64, i32u8, i32u16, NULL,   i32i64, i32f32, i32f64, i32f80}, // i8
  {i32i8, NULL,   NULL,   i32i64, i32u8, i32u16, NULL,   i32i64, i32f32, i32f64, i32f80}, // i16
  {i32i8, i32i16, NULL,   i32i64, i32u8, i32u16, NULL,   i32i64, i32f32, i32f64, i32f80}, // i32
  {i32i8, i32i16, NULL,   NULL,   i32u8, i32u16, NULL,   NULL,   i64f32, i64f64, i64f80}, // i64

  {i32i8, NULL,   NULL,   i32i64, NULL,  NULL,   NULL,   i32i64, i32f32, i32f64, i32f80}, // u8
  {i32i8, i32i16, NULL,   i32i64, i32u8, NULL,   NULL,   i32i64, i32f32, i32f64, i32f80}, // u16
  {i32i8, i32i16, NULL,   u32i64, i32u8, i32u16, NULL,   u32i64, u32f32, u32f64, u32f80}, // u32
  {i32i8, i32i16, NULL,   NULL,   i32u8, i32u16, NULL,   NULL,   u64f32, u64f64, u64f80}, // u64

  {f32i8, f32i16, f32i32, f32i64, f32u8, f32u16, f32u32, f32u64, NULL,   f32f64, f32f80}, // f32
  {f64i8, f64i16, f64i32, f64i64, f64u8, f64u16, f64u32, f64u64, f64f32, NULL,   f64f80}, // f64
  {f80i8, f80i16, f80i32, f80i64, f80u8, f80u16, f80u32, f80u64, f80f32, f80f64, NULL},   // f80
};

красивое

kcalbCube kcalbCube, (Updated )

Комментарии (2, +2)

Няшная / Говнокод #28055 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
// Takes a printf-style format string and returns a formatted string.
char *format(char *fmt, ...) {
  char *buf;
  size_t buflen;
  FILE *out = open_memstream(&buf, &buflen);

  va_list ap;
  va_start(ap, fmt);
  vfprintf(out, fmt, ap);
  va_end(ap);
  fclose(out);
  return buf;
}

kcalbCube kcalbCube, (Updated )

Комментарии (6, +6)

Няшная / Говнокод #28054 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
typedef enum {
  FILE_NONE, FILE_C, FILE_ASM, FILE_OBJ, FILE_AR, FILE_DSO,
} FileType;

StringArray include_paths;
bool opt_fcommon = true;
bool opt_fpic;

static FileType opt_x;
static StringArray opt_include;
static bool opt_E;
static bool opt_M;
static bool opt_MD;
static bool opt_MMD;
static bool opt_MP;
static bool opt_S;
static bool opt_c;
static bool opt_cc1;
static bool opt_hash_hash_hash;
static bool opt_static;
static bool opt_shared;
static char *opt_MF;
static char *opt_MT;
static char *opt_o;

static StringArray ld_extra_args;
static StringArray std_include_paths;

char *base_file;
static char *output_file;

static StringArray input_paths;
static StringArray tmpfiles;

благо поиск по проекту работает

kcalbCube kcalbCube, (Updated )

Комментарии (23, +23)

Няшная / Говнокод #28041 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
void pong_game(void)
   {
      /*Set the first random direction the ball will be traviling*/
      direction=random_direction();
      
      /*Play the game while the ESC key is not pressed*/
      while(!key[KEY_ESC]) {
         /*Move the Ball*/
         move_ball();
         /*Respond to the input*/
         key_respond();
         
         /*Put the information on the Screen*/
         textout(buffer,pong_datafile[pong_text].dat,"Player 1 Score:",
                 150,0,254);
         textout(buffer,pong_datafile[pong_text].dat,itoa(score_p1,NULL,10),
                 text_length(pong_datafile[pong_text].dat,
                 "Player 1 Score:")+150,0,10);
         textout(buffer,pong_datafile[pong_text].dat,"Player 2 Score:",
                 350,0,254);
         textout(buffer,pong_datafile[pong_text].dat,itoa(score_p2,NULL,10),
                 text_length(pong_datafile[pong_text].dat,
                             "Player 2 Score:")+350,0,10);
         textout(buffer,pong_datafile[pong_text].dat,"keyboard",0,0,255);
         textout(buffer,pong_datafile[pong_text].dat,"joystick",
                 640-text_length(pong_datafile[pong_text].dat,"joystick"),
                 0,255);
         /*Draw a line to set the boundries*/
         line(buffer,0,30,640,30,10);
         
         /*Put the buffer screen on the screen*/
         blit(buffer,screen,0,0,0,0,640,480);
         
         /*Clear the buffer*/
         clear(buffer);
      }
      return;
   }

помните?

kcalbCube kcalbCube, (Updated )

Комментарии (6, +6)