Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. unsigned long cur_color;
  2. class TKlbrGraphDraw : public TGraphDraw
  3. {
  4. public:
  5.         virtual int SetColor(unsigned long c) {cur_color=c;return 1;}
  6.         virtual int DrawLine(int x0, int y0, int x1, int y1);
  7.         virtual int DrawText(int x0, int y0, char* text);
  8.         virtual int IsDraw(void) {return 1;}
  9.         virtual int DrawClear();
  10.         virtual unsigned long CreateColor(unsigned short red,
  11.                         unsigned short green, unsigned short blue);
  12.         virtual void GetSize(int &w, int &h);
  13.         virtual int GetTextH(const char *s) {return 10;}
  14.         virtual int GetTextW(const char *s) {return 6 * strlen(s);}
  15.         virtual void Quit(int q = 1) {CloseWindow();}
  16. };
  17. int TKlbrGraphDraw::DrawLine(int x0, int y0, int x1, int y1)
  18. {
  19.         asm     mov     ebx, x0
  20.         asm     shl     ebx, 16
  21.         asm     add     ebx, x1
  22.         asm     mov     ecx, y0
  23.         asm     shl     ecx, 16
  24.         asm     add     ecx, y1
  25.         asm     mov     edx, [cur_color]
  26.         asm     push    38
  27.         asm     pop     eax
  28.         asm     int     40h
  29.         return 1;
  30. }
  31. int TKlbrGraphDraw::DrawText(int x0, int y0, char* text)
  32. {
  33.         asm     mov     ebx, x0
  34.         asm     shl     ebx, 16
  35.         asm     add     ebx, y0
  36.         asm     mov     ecx, [cur_color]
  37.         asm     or      ecx, 0xC0000000
  38.         asm     mov     edx, text
  39.         asm     mov     edi, 0xFFFFFF
  40.         asm     push    4
  41.         asm     pop     eax
  42.         asm     int     40h
  43.         return 1;
  44. }
  45. int TKlbrGraphDraw::DrawClear(void)
  46. {
  47.         int w,h;
  48.         GetSize(w,h);
  49.         asm     mov     ebx, w
  50.         asm     mov     ecx, h
  51.         asm     mov     edx, 0xFFFFFF
  52.         asm     push    13
  53.         asm     pop     eax
  54.         asm     int     40h
  55.         return 1;
  56. }
  57. unsigned long TKlbrGraphDraw::CreateColor(unsigned short red,
  58.                           unsigned short green, unsigned short blue)
  59. {
  60.   return (unsigned long)(blue >> 8) + ((unsigned long)(green >> 8) << 8) +
  61.          ((unsigned long)(red >> 8) << 16);
  62. }
  63. void TKlbrGraphDraw::GetSize(int &w, int &h)
  64. {
  65.         int width, height;
  66.         asm     sub     esp, 1024
  67.         asm     mov     ebx, esp
  68.         asm     or      ecx, -1
  69.         asm     push    9
  70.         asm     pop     eax
  71.         asm     int     40h
  72.         asm     mov     eax, [esp+62]
  73.         asm     mov     width, eax
  74.         asm     mov     eax, [esp+66]
  75.         asm     mov     height, eax
  76.         asm     add     esp, 1024
  77.         w = width;
  78.         h = height;
  79. }
  80.