Subversion Repositories Kolibri OS

Rev

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

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