DEADSOFTWARE

mostly remove game dependency on low level part of render
[flatwaifu.git] / src / vga.c
index f2e5b44079941a7db71016564543efc4f664f44c..21e8b4c363c99b63bb81b169c79fd59aa9ce8cdb 100644 (file)
--- a/src/vga.c
+++ b/src/vga.c
@@ -47,6 +47,16 @@ int cx1,cx2,cy1,cy2;
 
 char fullscreen = OFF;
 
+byte bright[256];
+byte mixmap[256][256];
+byte clrmap[256*12];
+
+static byte flametab[16] = {
+  0xBC,0xBA,0xB8,0xB6,0xB4,0xB2,0xB0,0xD5,0xD6,0xD7,0xA1,0xA0,0xE3,0xE2,0xE1,0xE0
+};
+
+extern void *walp[256];
+
 #define HQ 2
 
 vgaimg *V_getvgaimg (int id) {
@@ -211,11 +221,6 @@ void V_dot(short x,short y, unsigned char c)
     putpixel(x,y,c);
 }
 
-
-extern byte bright[256];
-extern byte flametab[16];
-extern byte mixmap[256][256];
-
 void smoke_sprf(int x, int y, byte c)
 {
     byte t = getpixel(x,y);
@@ -318,34 +323,26 @@ void V_remap_rect(int x,int y,int w,int h,byte *cmap)
             mappixel(cx,cy,cmap);
 }
 
-extern void *walp[256];
-extern byte clrmap[256*12];
-
-void Z_drawfld(byte *fld, int bg)
+void Z_drawfld (byte *fld, int bg)
 {
     byte *p = fld;
-    int x,y;
-    for (y=0; y<FLDH; y++)
-    {
-        for (x=0; x<FLDW; x++)
-        {
-            int sx = x*CELW-w_x+WD/2;
-            int sy = y*CELH-w_y+HT/2+1+w_o;
-
-
+    int x, y;
+    for (y = 0; y < FLDH; y++) {
+        for (x = 0; x < FLDW; x++) {
+            int sx = x * CELW - w_x + WD / 2;
+            int sy = y * CELH - w_y + HT / 2 + 1 + w_o;
             if (*p) {
-                 vgaimg *pic = walp[*p];
-                if ((int)pic <= 3) {
-                    if (!bg) {
-                        byte *cmap = clrmap + ((int)pic+7)*256;
-                        V_remap_rect(sx, sy, CELW, CELH, cmap);
-                    }
-                }
-                else {
-                    V_pic(sx, sy, pic);
+              vgaimg *pic = walp[*p];
+              // special pointer value setted for _WATER_* in view.c
+              if ((intptr_t)pic <= 3) {
+                if (!bg) {
+                  byte *cmap = clrmap + ((intptr_t)pic+7)*256;
+                  V_remap_rect(sx, sy, CELW, CELH, cmap);
                 }
+              } else {
+                V_pic(sx, sy, pic);
+              }
             }
-
             p++;
         }
     }