Subversion Repositories Kolibri OS

Rev

Rev 4008 | Blame | Last modification | View Log | Download | RSS feed

  1. //notify 0.8
  2. //SoUrcerer 2010, Leency 2012-2013, GNU GPLv2
  3.  
  4. #define MEMSIZE 0x2F00
  5. #include "..\lib\kolibri.h"
  6. #include "..\lib\strings.h"
  7. #include "..\lib\mem.h"
  8. #include "..\lib\figures.h"
  9.  
  10. dword shadow_buf_24, shadow_buf_32, lighter_pixel1, lighter_pixel2;
  11.  
  12. ?define PADDING 15;
  13.  
  14. int SCREEN_SIZE_X,
  15.     SCREEN_SIZE_Y;
  16.  
  17. int WIN_X,
  18.         WIN_Y,
  19.     WIN_SIZE_X=256,
  20.     WIN_SIZE_Y=28;
  21.  
  22. int TEXT_X=PADDING,
  23.         TEXT_Y;
  24.  
  25. int delay = 400;
  26.  
  27. #ifndef AUTOBUILD
  28.         #include "lang.h--"
  29. #endif
  30.  
  31. #ifdef LANG_RUS
  32.         ?define DEFAULT_TEXT "â  ¯à®£à ¬¬  ¯®ª §ë¢ ¥â 㢥¤®¬«¥­¨ï.";
  33. #else
  34.         ?define DEFAULT_TEXT "This program shows notices. Open it with params.";
  35. #endif
  36.  
  37. void PutText(dword x, y) {
  38.         WriteBufText(x,y, 0x88, 0, #param, shadow_buf_32);
  39. }
  40.  
  41. void Text()
  42. {
  43.         PutText(TEXT_X-1,TEXT_Y+1);
  44.         PutText(TEXT_X-1,TEXT_Y-1);
  45.         PutText(TEXT_X-1,TEXT_Y  );
  46.         PutText(TEXT_X+1,TEXT_Y-1);
  47.         PutText(TEXT_X+1,TEXT_Y  );
  48.         PutText(TEXT_X+1,TEXT_Y+1);
  49.         PutText(TEXT_X,  TEXT_Y+1);
  50.         PutText(TEXT_X,  TEXT_Y-1);
  51.         WriteBufText(TEXT_X, TEXT_Y, 0x88, 0xFFFfff, #param, shadow_buf_32);
  52. }
  53.  
  54. inline fastcall int GetClientTop()
  55. {
  56.         $mov eax, 48
  57.         $mov ebx, 5
  58.         $int 0x40
  59.     $mov eax, ebx
  60.     $shr eax, 16
  61. }
  62.  
  63. void from24to32(dword src, dst, Width, Height)
  64. {
  65. conv24to32:
  66.         $mov esi, src
  67.         $mov edi, dst
  68.                
  69.         $mov eax, Width
  70.         //$mul ESDWORD[Height]
  71.         $mul Height
  72.         $mov ecx, eax
  73.         $xor al, al
  74. _next: 
  75.         $movsw
  76.         $movsb
  77.         $stosb  
  78.         $loop _next
  79. }
  80.  
  81. void DrawBackground()
  82. {
  83.         PutPaletteImage(shadow_buf_32+8,WIN_SIZE_X,WIN_SIZE_Y,0,0,32,0);
  84.         PutPixel(0,0,ESDWORD[lighter_pixel1]);
  85.         PutPixel(0,WIN_SIZE_Y-1,ESDWORD[lighter_pixel2]);      
  86. }
  87.  
  88. void GetBackground()
  89. {
  90.         int i;
  91.         static int was_once;
  92.  
  93.         if (was_once)
  94.         {
  95.                 DrawBackground();
  96.                 return;
  97.         }
  98.         for (i=1; i<=6; i++)
  99.         {
  100.                 was_once = 1;
  101.                 ShadowImage(shadow_buf_24, WIN_SIZE_X, WIN_SIZE_Y, 1);
  102.                 if (i%2 == 0) ShadowImage(lighter_pixel1, 1, 1, 1);
  103.                 if (i%2 == 0) ShadowImage(lighter_pixel2, 1, 1, 1);
  104.                 from24to32(shadow_buf_24, shadow_buf_32+8, WIN_SIZE_X, WIN_SIZE_Y);
  105.                 Text();
  106.                 DrawBackground();
  107.                 pause(5);
  108.         }
  109. }
  110.  
  111. void Exit()
  112. {
  113.         ExitProcess();
  114. }
  115.  
  116.  
  117. void main()
  118. {      
  119.         if (!param)     strcpy(#param, DEFAULT_TEXT);
  120.         if (strlen(#param)*6>WIN_SIZE_X)
  121.         {
  122.                 WIN_SIZE_X=strlen(#param)*6+PADDING;
  123.                 delay = strlen(#param)*10;
  124.         }
  125.  
  126.         SCREEN_SIZE_X=GetScreenWidth()+1;      
  127.         WIN_X = SCREEN_SIZE_X-WIN_SIZE_X-1;
  128.         WIN_Y = GetClientTop();
  129.         TEXT_X = -6*strlen(#param)+WIN_SIZE_X/2+1;
  130.         TEXT_Y = WIN_SIZE_Y/2-4;
  131.        
  132.         //emulate multithread :)
  133.         while (GetPixelColor(SCREEN_SIZE_X-1, SCREEN_SIZE_X, WIN_Y)==0x333333) WIN_Y+=WIN_SIZE_Y+17;
  134.  
  135.         mem_Init();
  136.         shadow_buf_24 = malloc(WIN_SIZE_X*WIN_SIZE_Y*3);
  137.         shadow_buf_32 = malloc(WIN_SIZE_X*WIN_SIZE_Y*4+8);
  138.         lighter_pixel1 = malloc(3);
  139.         lighter_pixel2 = malloc(3);
  140.         CopyScreen(shadow_buf_24, WIN_X, WIN_Y, WIN_SIZE_X, WIN_SIZE_Y);
  141.         CopyScreen(lighter_pixel1, WIN_X, WIN_Y, 1, 1);
  142.         CopyScreen(lighter_pixel2, WIN_X, WIN_Y+WIN_SIZE_Y, 1, 1);
  143.         ESDWORD[shadow_buf_32] = WIN_SIZE_X;
  144.         ESDWORD[shadow_buf_32+4] = WIN_SIZE_Y;
  145.  
  146.         loop()
  147.         {
  148.                 WaitEventTimeout(delay);
  149.                 switch(EAX & 0xFF)
  150.                 {
  151.                 case evButton:
  152.                         Exit();
  153.                         break;
  154.          
  155.                 case evReDraw:
  156.                         DefineAndDrawWindow(WIN_X+1,WIN_Y,WIN_SIZE_X, WIN_SIZE_Y-1, 0x01, 0, 0, 0x01fffFFF);
  157.                         DrawBar(WIN_SIZE_X,0, 1, WIN_SIZE_Y, 0x333333);
  158.                         DefineButton(0,0, WIN_SIZE_X, WIN_SIZE_Y, 1+BT_HIDE+BT_NOFRAME, 0);
  159.                         GetBackground();
  160.                         break;
  161.  
  162.                 default:
  163.                         Exit();
  164.       }
  165.    }
  166. }
  167.  
  168.  
  169. stop:
  170.