Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. //#define KOLIBRI_PE
  3.  
  4. #include "types.h"
  5. #include "system.h"
  6.  
  7. #include "pixlib.h"
  8.  
  9. static clip_t   scrn_clip;
  10. static pixmap_t scrn_pixmap;
  11.  
  12. static u32_t srv_hw2d;
  13.  
  14. #define HS_HORIZONTAL     0
  15. #define HS_VERTICAL       1
  16. #define HS_FDIAGONAL      2
  17. #define HS_BDIAGONAL      3
  18. #define HS_CROSS          4
  19. #define HS_DIAGCROSS      5
  20.  
  21.  
  22. static u32_t hatches[HATCH_MAX*2] =
  23.             { 0xFF000000, 0xFF000000,     /*  HORIZONTAL */
  24.               0x22222222, 0x22222222,     /*  VERTICAL   */
  25.               0x11224488, 0x11224488,     /*  FDIAGONAL  */
  26.               0x44221188, 0x44221188,     /*  BDIAGONAL  */
  27.               0xFF111111, 0xFF111111,     /*  CROSS      */
  28.               0x10284482, 0x01824428      /*  DCROSS     */
  29.             };
  30.  
  31.  
  32. typedef struct {
  33.   int available;            /**< Count of available items in this slab. */
  34.   void *start;              /**< Start address of first item. */
  35.   void *nextavail;          /**< The index of next available item. */
  36. } slab_t;
  37.  
  38. static brush_t  brushes[256];
  39. static pixmap_t pixmaps[64];
  40. static slab_t   br_slab;
  41. static slab_t   px_slab;
  42.  
  43. int __stdcall start(int state)
  44. {
  45.      int p;
  46.      int i;
  47.  
  48.      int scrnsize;
  49.      int scrnbpp;
  50.      int scrnpitch;
  51.  
  52.      if( !test_mmx())
  53.         return FALSE;
  54.  
  55.      if( (scrnbpp = GetScreenBpp()) != 32)
  56.         return FALSE;
  57.  
  58.      scrnsize  = GetScreenSize();
  59.      scrnpitch = GetScreenPitch();
  60.  
  61.      scrn_clip.xmin = 0;
  62.      scrn_clip.ymin = 0;
  63.      scrn_clip.xmax = (scrnsize >> 16) - 1;
  64.      scrn_clip.ymax = (scrnsize & 0xFFFF) - 1;
  65.  
  66.      scrn_pixmap.width   = scrnsize >> 16;
  67.      scrn_pixmap.height  = scrnsize & 0xFFFF;
  68.      scrn_pixmap.format  = PICT_a8r8g8b8;
  69.      scrn_pixmap.flags   = PX_MEM_LOCAL;
  70.      scrn_pixmap.pitch   = scrnpitch;
  71.      scrn_pixmap.mapped  = (void*)LFB_BASE;
  72.  
  73.      br_slab.available = 256;
  74.      br_slab.start = brushes;
  75.      br_slab.nextavail = brushes;
  76.  
  77.      for (i = 0, p = (int)br_slab.start; i < 256; i++)
  78.      {
  79.        *(int *)p = p+sizeof(brush_t);
  80.        p = p+sizeof(brush_t);
  81.      };
  82.  
  83.      px_slab.available = 64;
  84.      px_slab.start = pixmaps;
  85.      px_slab.nextavail = pixmaps;
  86.  
  87.      for (i = 0, p = (int)px_slab.start; i < 64; i++)
  88.      {
  89.        *(int *)p = p+sizeof(pixmap_t);
  90.        p = p+sizeof(pixmap_t);
  91.      };
  92.  
  93.      srv_hw2d = get_service("HDRAW");
  94.        if(srv_hw2d == 0)
  95.          srv_hw2d = load_service("/rd/1/drivers/ati2d.drv");
  96.  
  97.      return TRUE;
  98. };
  99.  
  100.  
  101. #include "clip.inc"
  102. #include "pixmap.inc"
  103. #include "brush.inc"
  104. #include "draw.inc"
  105.  
  106. typedef struct
  107. {
  108.   char *name;
  109.   void *f;
  110. }export_t;
  111.  
  112. char szStart[]           = "START";
  113. char szVersion[]         = "version";
  114.  
  115. //char szBlockClip[]       = "BlockClip";
  116. //char szLineClip[]        = "LineClip";
  117.  
  118. char szCreatePixmap[]    = "CreatePixmap";
  119. char szDestroyPixmap[]   = "DestroyPixmap";
  120. char szLockPixmap[]      = "LockPixmap";
  121. char szUnlockPixmap[]    = "UnlockPixmap";
  122. char szGetPixmapPitch[]  = "GetPixmapPitch";
  123.  
  124. char szCreateHatch[]     = "CreateHatch";
  125. char szCreateMonoBrush[] = "CreateMonoBrush";
  126. char szDestroyBrush[]    = "DestroyBrush";
  127.  
  128. char szClearPixmap[]     = "ClearPixmap";
  129. char szLine[]            = "Line";
  130. char szDrawRect[]        = "DrawRect";
  131. char szFillRect[]        = "FillRect";
  132. char szBlit[]            = "Blit";
  133. char szTransparentBlit[] = "TransparentBlit";
  134. char szBlitAlpha[]       = "BlitAlpha";
  135.  
  136.  
  137. export_t EXPORTS[] __asm__("EXPORTS") =
  138.          {
  139.            { szStart,           start },
  140.            { szVersion,         (void*)0x00010001 },
  141.  
  142.         //   { szBlockClip,       BlockClip },
  143.         //   { szLineClip,        LineClip },
  144.  
  145.            { szCreatePixmap,    CreatePixmap    },
  146.            { szDestroyPixmap,   DestroyPixmap   },
  147.            { szLockPixmap,      LockPixmap      },
  148.            { szUnlockPixmap,    UnlockPixmap    },
  149.            { szGetPixmapPitch,  GetPixmapPitch  },
  150.  
  151.            { szCreateHatch,     CreateHatch     },
  152.            { szCreateMonoBrush, CreateMonoBrush },
  153.            { szDestroyBrush,    DestroyBrush    },
  154.  
  155.            { szClearPixmap,     ClearPixmap     },
  156.            { szLine,            Line            },
  157.            { szDrawRect,        DrawRect        },
  158.            { szFillRect,        FillRect        },
  159.            { szBlit,            Blit            },
  160.            { szTransparentBlit, TransparentBlit },
  161.            { szBlitAlpha,       BlitAlpha       },
  162.  
  163.            { NULL, NULL },
  164.          };
  165.  
  166.  
  167.