1 /* $Header: /home/yav/xpx/RCS/nbn.c,v 1.3 1996/04/24 23:08:27 yav Exp $
2  * NBN file access routine for xpx
3  * written by yav (UHD98984@pcvan.or.jp)
4  *
5  *
6  * WARNING:
7  *
8  * Permission to use and distribute this source is granted without fee.
9  * But, It is not permitted to analyze this source without license.
10  *
11  *
12  */
13 
14 #include <X11/Xlib.h>
15 
16 #include "xpx.h"
17 #include "headers.h"
18 #include "work.h"
19 #define PUBLIC_NBN_C
20 #include "extern.h"
21 
22 
23 char rcsid_nbn[] = "$Id: nbn.c,v 1.3 1996/04/24 23:08:27 yav Exp $";
24 
25 /*
26  * NBN - Tokimeki Memorial  None header Beta VRAM image
27  *
28  * Not complieted, Cannot to read any *.nbn file.
29  * This is only experimental route.
30  *
31  */
rd_nbn(fp)32 int rd_nbn(fp)
33      FILE *fp;
34 {
35   int c, i, x, y, y0;
36   int w, h;
37   COL *cp;
38 
39   w = imgfilew;			/* for image size hint */
40   h = imgfileh;			/* use imgfilew,h */
41   if (!w || !h)
42     w = h = 256;		/* size 0 -> 256x256 default */
43   if (w < 128)
44     w = 128;
45   if (h < 128)
46     h = 128;
47   /* read pixel */
48   for (y0 = 0; y0 < h; y0 += 128) {
49     for (x = 0; x < w; x += 128) {
50       for (y = y0; y < y0+128; y++)
51 	fread(imgdata+y*imgmaxw+x, 1, 128, fp);
52     }
53   }
54   imgfiledepth = 8;
55   /* read color */
56   free_color_all();
57   cp = color_buf;
58   for (i = 0; i < 256; i++) {
59     c = readleshort(fp);
60     cp->rgb.red = (c & 0x1f) << 3;
61     cp->rgb.green = ((c >> 5) & 0x1f) << 3;
62     cp->rgb.blue = ((c >> 10) & 0x1f) << 3;
63     cp++;
64   }
65   get_color(color_buf, 256);
66   get_requested_colors();
67   imgupdate(w, h);
68   return 0;
69 }
70 
71 /* End of file */
72