DEADSOFTWARE

fully move highter level rendering code in separate file
[flatwaifu.git] / src / fx.c
index a6b3f06f040cac5979b851cd75e363630f750864..2af618046ee74b2a76b8f923ddc749d00d7a5be7 100644 (file)
--- a/src/fx.c
+++ b/src/fx.c
@@ -1,7 +1,6 @@
 /*
    Copyright (C) Prikol Software 1996-1997
    Copyright (C) Aleksey Volynskov 1996-1997
-   Copyright (C) <ARembo@gmail.com> 2011
 
    This file is part of the Doom2D:Rembo project.
 
 */
 
 #include "glob.h"
-//#include <io.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "vga.h"
-#include "error.h"
 #include "view.h"
 #include "fx.h"
 #include "misc.h"
+#include "my.h"
 
 enum{NONE,TFOG,IFOG,BUBL};
 
-#pragma pack(1)
-typedef struct{
-  int x,y,xv,yv;
-  char t,s;
-}fx_t;
-#pragma pack()
+fx_t fx[MAXFX];
 
-static void *spr[15],*bsnd[2];
-static char sprd[15];
-static fx_t fx[MAXFX];
+static void *bsnd[2];
 static char bubsn;
 static int last;
 
@@ -107,26 +98,40 @@ static void init_fx1sin(void) {
   }
 }
 
-void FX_savegame(FILE* h) {
-  int i,n;
-
-  for(i=n=0;i<MAXFX;++i) if(fx[i].t) ++n;
-  myfwrite(&n,1,4,h);
-  for(i=0;i<MAXFX;++i) if(fx[i].t) myfwrite(&fx[i],1,sizeof(fx_t),h);
+void FX_savegame (FILE *h) {
+  int i, n;
+  for (i = n = 0; i < MAXFX; ++i) {
+    if (fx[i].t) {
+      ++n;
+    }
+  }
+  myfwrite32(n, h);
+  for (i = 0; i < MAXFX; ++i) {
+    if (fx[i].t) {
+      myfwrite32(fx[i].x, h);
+      myfwrite32(fx[i].y, h);
+      myfwrite32(fx[i].xv, h);
+      myfwrite32(fx[i].yv, h);
+      myfwrite8(fx[i].t, h);
+      myfwrite8(fx[i].s, h);
+    }
+  }
 }
 
-void FX_loadgame(FILE* h) {
-  int n;
-
-  myfread(&n,1,4,h);
-  myfread(fx,1,n*sizeof(fx_t),h);
+void FX_loadgame (FILE *h) {
+  int i, n;
+  n = myfread32(h);
+  for (i = 0; i < n; i++) {
+    fx[i].x = myfread32(h);
+    fx[i].y = myfread32(h);
+    fx[i].xv = myfread32(h);
+    fx[i].yv = myfread32(h);
+    fx[i].t = myfread8(h);
+    fx[i].s = myfread8(h);
+  }
 }
 
 void FX_alloc(void) {
-  int i;
-
-  for(i=0;i<10;++i) spr[i]=Z_getspr("TFOG",i,0,sprd+i);
-  for(;i<15;++i) spr[i]=Z_getspr("IFOG",i-10,0,sprd+i);
   bsnd[0]=Z_getsnd("BUBL1");
   bsnd[1]=Z_getsnd("BUBL2");
   init_fx1sin();
@@ -162,22 +167,6 @@ void FX_act(void) {
   }
 }
 
-void FX_draw(void) {
-  int i,s;
-
-  for(i=0;i<MAXFX;++i) {
-    s=-1;
-    switch(fx[i].t) {
-      case TFOG: s=fx[i].s/2;break;
-         case IFOG: s=fx[i].s/2+10;break;
-         case BUBL:
-               V_dot((fx[i].x>>8)-w_x+WD/2,(fx[i].y>>8)-w_y+HT/2+1+w_o,0xC0+fx[i].s);//V_dot((fx[i].x>>8)-w_x+100,(fx[i].y>>8)-w_y+50+w_o,0xC0+fx[i].s);
-               continue;
-    }
-    if(s>=0) Z_drawspr(fx[i].x,fx[i].y,spr[s],sprd[s]);
-  }
-}
-
 static int findfree(void) {
   int i;