Subversion Repositories Kolibri OS

Rev

Rev 6746 | Rev 7628 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //Generated with Lev's C-- pack for HiAsm, www.hiasm.com
  2.  
  3. #define MEMSIZE 4096*400
  4.  
  5. #include "../lib/kolibri.h"
  6. #include "../lib/gui.h"
  7.  
  8. /*========================================================
  9. =                                                        =
  10. =                          DATA                          =
  11. =                                                        =
  12. ========================================================*/
  13.  
  14. _rgb image[256*256];
  15.  
  16. #define fw 256+167
  17. #define fh 290
  18.  
  19. enum {
  20.         DRAW1_BTN=10,
  21.         DRAW2_BTN,
  22.         SETBG_BTN
  23. };
  24.  
  25. /*========================================================
  26. =                                                        =
  27. =                       MAIN CYCLE                       =
  28. =                                                        =
  29. ========================================================*/
  30.  
  31. void main()
  32. int id;
  33. {
  34.   loop() switch(WaitEvent())
  35.   {
  36.         case evButton:
  37.                 id=GetButtonID();
  38.                 if (id==1) ExitProcess();
  39.                 if (id==DRAW1_BTN) EventDraw1();
  40.                 if (id==DRAW2_BTN) EventDraw2();
  41.                 if (id==SETBG_BTN) EventSetBackground(#image,256,256);
  42.                 break;
  43.         case evKey:
  44.                 if (GetKey()==27) ExitProcess();
  45.                 break;
  46.         case evReDraw:
  47.                 system.color.get();
  48.                 DefineAndDrawWindow(screen.width-fw/2,screen.height-fh/2,fw,fh+skin_height,0x33,0xE0DFE3,"Rainbow (rgb test)",0);
  49.                 _PutImage(0,0,256,256,#image);
  50.                 DrawCaptButton(280,20, 110,30,DRAW1_BTN,system.color.work_button,system.color.work_button_text,"Draw 1");
  51.                 DrawCaptButton(280,60, 110,30,DRAW2_BTN,system.color.work_button,system.color.work_button_text,"Draw 2");
  52.                 DrawCaptButton(280,100,110,30,SETBG_BTN,system.color.work_button,system.color.work_button_text,"Background");
  53.   }
  54. }
  55.  
  56. /*========================================================
  57. =                                                        =
  58. =              Background system functions               =
  59. =                                                        =
  60. ========================================================*/
  61.  
  62. inline fastcall void BG_PaintMode( ECX)
  63. {
  64.         $mov eax, 15
  65.         $mov ebx, 4
  66.         $int  0x40
  67. }
  68.  
  69. inline fastcall void BG_SetImageSize( ECX, EDX)
  70. {
  71.         $mov eax, 15
  72.         $mov ebx, 1
  73.         $int  0x40
  74. }
  75.  
  76. inline fastcall void BG_PutPixels( ECX, EDX, ESI)
  77. {
  78.         $mov eax, 15
  79.         $mov ebx, 5
  80.         $int  0x40
  81. }
  82.  
  83. inline fastcall void BG_Redraw()
  84. {
  85.         $mov eax, 15
  86.         $mov ebx, 3
  87.         $int  0x40
  88. }
  89.  
  90. /*========================================================
  91. =                                                        =
  92. =                       EVENTS                           =
  93. =                                                        =
  94. ========================================================*/
  95.  
  96. void EventDraw1()
  97. {
  98. int i1;
  99. int i4;
  100. int pos;
  101.   for(i4 = 0; i4 < 256; i4++) {
  102.         for(i1 = 0; i1 < 256; i1++) {
  103.           pos = i1 * 256 + i4;
  104.           image[pos].b = i1;
  105.           image[pos].r = 0;
  106.           image[pos].g = 0;
  107.         }
  108.   }
  109.   _PutImage(0,0,256,256,#image);
  110. }
  111.  
  112. void EventDraw2()
  113. {
  114. int i1;
  115. int i4;
  116. int t2;
  117.   for(i4 = 0; i4 < 256; i4++) {
  118.         for(i1 = 0; i1 < 256; i1++) {
  119.           t2 = i1 * 256 + i4;
  120.           image[t2].r = i4;
  121.           image[t2].g = i1;
  122.           image[t2].b = 0;
  123.         }
  124.   }
  125.   _PutImage(0,0,256,256,#image);
  126. }
  127.  
  128. void EventSetBackground(dword img_pointer, w,h)
  129. {
  130.         BG_PaintMode(2); //1-tile,2-stratch
  131.         BG_SetImageSize(w,h);
  132.         BG_PutPixels(img_pointer, 0, 3*w*h);
  133.         BG_Redraw();   
  134. }
  135.  
  136. stop:
  137.