Subversion Repositories Kolibri OS

Rev

Rev 4005 | Go to most recent revision | 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.  
  82. void GetBackground()
  83. {
  84.         int i;
  85.  
  86.         for (i=1; i<=6; i++)
  87.         {
  88.                 ShadowImage(shadow_buf_24, WIN_SIZE_X, WIN_SIZE_Y, 1);
  89.                 if (i%2 == 0) ShadowImage(lighter_pixel1, 1, 1, 1);
  90.                 if (i%2 == 0) ShadowImage(lighter_pixel2, 1, 1, 1);
  91.                 from24to32(shadow_buf_24, shadow_buf_32+8, WIN_SIZE_X, WIN_SIZE_Y);
  92.                 Text();
  93.                 PutPaletteImage(shadow_buf_32+8,WIN_SIZE_X,WIN_SIZE_Y,0,0,32,0);
  94.                 PutPixel(0,0,ESDWORD[lighter_pixel1]);
  95.                 PutPixel(0,WIN_SIZE_Y-1,ESDWORD[lighter_pixel2]);
  96.                 pause(5);
  97.         }
  98. }
  99.  
  100. void Exit()
  101. {
  102.         ExitProcess();
  103. }
  104.  
  105.  
  106. void main()
  107. {      
  108.         if (!param)     strcpy(#param, DEFAULT_TEXT);
  109.         if (strlen(#param)*6>WIN_SIZE_X)
  110.         {
  111.                 WIN_SIZE_X=strlen(#param)*6+PADDING;
  112.                 delay = strlen(#param)*10;
  113.         }
  114.  
  115.         SCREEN_SIZE_X=GetScreenWidth()+1;      
  116.         WIN_X = SCREEN_SIZE_X-WIN_SIZE_X-1;
  117.         WIN_Y = GetClientTop();
  118.         TEXT_X = -6*strlen(#param)+WIN_SIZE_X/2+1;
  119.         TEXT_Y = WIN_SIZE_Y/2-4;
  120.        
  121.         //emulate multithread :)
  122.         while (GetPixelColor(SCREEN_SIZE_X-1, SCREEN_SIZE_X, WIN_Y)==0x333333) WIN_Y+=WIN_SIZE_Y+17;
  123.  
  124.         mem_Init();
  125.         shadow_buf_24 = malloc(WIN_SIZE_X*WIN_SIZE_Y*3);
  126.         shadow_buf_32 = malloc(WIN_SIZE_X*WIN_SIZE_Y*4+8);
  127.         lighter_pixel1 = malloc(3);
  128.         lighter_pixel2 = malloc(3);
  129.         CopyScreen(shadow_buf_24, WIN_X, WIN_Y, WIN_SIZE_X, WIN_SIZE_Y);
  130.         CopyScreen(lighter_pixel1, WIN_X, WIN_Y, 1, 1);
  131.         CopyScreen(lighter_pixel2, WIN_X, WIN_Y+WIN_SIZE_Y, 1, 1);
  132.         ESDWORD[shadow_buf_32] = WIN_SIZE_X;
  133.         ESDWORD[shadow_buf_32+4] = WIN_SIZE_Y;
  134.  
  135.         loop()
  136.         {
  137.                 WaitEventTimeout(delay);
  138.                 switch(EAX & 0xFF)
  139.                 {
  140.                 case evButton:
  141.                         Exit();
  142.                         break;
  143.          
  144.                 case evReDraw:
  145.                         DefineAndDrawWindow(WIN_X+1,WIN_Y,WIN_SIZE_X, WIN_SIZE_Y-1, 0x01, 0, 0, 0x01fffFFF);
  146.                         DrawBar(WIN_SIZE_X,0, 1, WIN_SIZE_Y, 0x333333);
  147.                         DefineButton(0,0, WIN_SIZE_X, WIN_SIZE_Y, 1+BT_HIDE+BT_NOFRAME, 0);
  148.                         GetBackground();
  149.                         break;
  150.  
  151.                 default:
  152.                         Exit();
  153.       }
  154.    }
  155. }
  156.  
  157.  
  158. stop:
  159.