- make vga buildable on msvc.
[reactos.git] / reactos / drivers / video / displays / vga / vgavideo / vgavideo.c
index 98dca55..3ad965f 100644 (file)
@@ -1,9 +1,23 @@
-#include <ddk/ntddk.h>
-#include <ddk/ntddvdeo.h>
-#include <ddk/winddi.h>
+#define _WINBASE_
+#define _WINDOWS_H
+#include <stdarg.h>
+#include <windef.h>
+#include <guiddef.h>
+#include <wingdi.h>
+#include <winddi.h>
+#include <winioctl.h>
+#include <ntddvdeo.h>
 #include <stdlib.h>
 #include "vgavideo.h"
 
+#define DDKAPI __stdcall
+#define DDKFASTAPI __fastcall
+#define FASTCALL __fastcall
+#define DDKCDECLAPI __cdecl
+
+VOID DDKAPI WRITE_PORT_UCHAR(IN PUCHAR  Port, IN UCHAR  Value);
+VOID DDKAPI WRITE_PORT_USHORT(IN PUSHORT  Port, IN USHORT  Value);
+
 UCHAR PreCalcReverseByte[256];
 int maskbit[640];
 int y80[480];
@@ -21,36 +35,6 @@ static unsigned char rightMask;
 #define READ_REGISTER_UCHAR(p) (*((volatile UCHAR *)(p)))
 #define WRITE_REGISTER_UCHAR(p,c) (*((volatile CHAR *)(p))) = (c)
 
-INT abs(INT nm)
-{
-  if(nm<0)
-  {
-    return nm * -1;
-  } else
-  {
-    return nm;
-  }
-}
-
-div_t div(int num, int denom)
-{
-  div_t r;
-  if (num > 0 && denom < 0) {
-    num = -num;
-    denom = -denom;
-  }
-  r.quot = num / denom;
-  r.rem = num % denom;
-  if (num < 0 && denom > 0)
-  {
-    if (r.rem > 0)
-    {
-      r.quot++;
-      r.rem -= denom;
-    }
-  }
-  return r;
-}
 
 /*int mod(int num, int denom)
 {
@@ -266,7 +250,7 @@ BOOL vgaHLine(INT x, INT y, INT len, UCHAR c)
   UCHAR a;
   ULONG pre1;
   ULONG orgpre1, orgx, midpre1;
-  ULONG ileftpix, imidpix, irightpix;
+  LONG ileftpix, imidpix, irightpix;
 
   orgx = x;
 
@@ -341,7 +325,7 @@ BOOL vgaHLine(INT x, INT y, INT len, UCHAR c)
 
 BOOL vgaVLine(INT x, INT y, INT len, UCHAR c)
 {
-  ULONG offset, i;
+  INT offset, i;
   UCHAR a;
 
   offset = xconv[x]+y80[y];
@@ -391,9 +375,9 @@ void DIB_BltFromVGA(int x, int y, int w, int h, void *b, int Dest_lDelta)
   ULONG left = x >> 3;
   ULONG shift = x - (x & ~0x7);
   UCHAR pixel, nextpixel;
-  ULONG rightcount;
-  ULONG i, j;
-  ULONG stride = w >> 3;
+  LONG rightcount;
+  INT i, j;
+  LONG stride = w >> 3;
 
   /* Calculate the number of rightmost bytes not in a dword block. */
   if (w >= 8)
@@ -409,7 +393,7 @@ void DIB_BltFromVGA(int x, int y, int w, int h, void *b, int Dest_lDelta)
   /* Reset the destination. */
   for (j = 0; j < h; j++)
     {
-      memset(b + (j * Dest_lDelta), 0, abs(Dest_lDelta));
+      memset((PVOID)((ULONG_PTR)b + (j * Dest_lDelta)), 0, abs(Dest_lDelta));
     }
 
   for (plane = 0; plane < 4; plane++)
@@ -528,9 +512,9 @@ void DIB_BltFromVGA(int x, int y, int w, int h, void *b, int Dest_lDelta)
 void DIB_BltToVGA(int x, int y, int w, int h, void *b, int Source_lDelta, int StartMod)
 {
   PBYTE pb, opb = b;
-  ULONG i, j;
-  ULONG x2 = x + w;
-  ULONG y2 = y + h;
+  LONG i, j;
+  LONG x2 = x + w;
+  LONG y2 = y + h;
   ULONG offset;
   UCHAR a;
 
@@ -986,7 +970,7 @@ void DFB_BltToDIB(int x, int y, int w, int h, void *b, int bw, void *bdib, int d
   int i, j, dib_shift;
 
   bpX = b;
-  dib = bdib + y * dibw + (x / 2);
+  dib = (unsigned char *)bdib + y * dibw + (x / 2);
 
   for (i=w; i>0; i--) {
 
@@ -1015,7 +999,7 @@ void DIB_BltToDFB(int x, int y, int w, int h, void *b, int bw, void *bdib, int d
   int i, j, dib_shift, dib_and;
 
   bpX = b;
-  dib = bdib + y * dibw + (x / 2);
+  dib = (unsigned char *)bdib + y * dibw + (x / 2);
 
   for (i=w; i>0; i--) {