1 #include <string.h> /* memset() */
7 unsigned char RGBPal
[256][3];
10 //Assign memory to sprite buffer
11 SpriteBuf
= (char *)malloc (64000);
13 //Load graphics data from file
14 SSFFile
= fopen ("Bomber0.ssf", "rb");
15 fread (SpriteBuf
, 7, 1, SSFFile
);
16 fread (SpriteBuf
, 320, 200, SSFFile
);
17 fread (RGBPal
, 3, 256, SSFFile
);
21 for (DAC
= 0; DAC
< 256; DAC
++) {
22 RGBPal
[DAC
][0] <<= 2;
23 RGBPal
[DAC
][1] <<= 2;
24 RGBPal
[DAC
][2] <<= 2;
25 Palette
[DAC
] = (RGBPal
[DAC
][2]) +
26 (RGBPal
[DAC
][1] << 8) +
27 (RGBPal
[DAC
][0] << 16);
35 unsigned char RGBPal
[256][3];
42 //Assign memory to sprite buffer
43 RawBuf
= (char *)malloc (64000);
45 //Load graphics data from file
46 SSFFile
= fopen ("Bomber1.ssf", "rb");
47 fread (RawBuf
, 7, 1, SSFFile
);
48 fread (RawBuf
, 320, 200, SSFFile
);
49 fread (RGBPal
, 3, 256, SSFFile
);
56 for (DAC
= 0; DAC
< 256; DAC
++) {
57 RGBPal
[DAC
][0] <<= 2;
58 RGBPal
[DAC
][1] <<= 2;
59 RGBPal
[DAC
][2] <<= 2;
60 Palette
[DAC
] = (RGBPal
[DAC
][0]) +
61 (RGBPal
[DAC
][1] << 8) +
62 (RGBPal
[DAC
][2] << 16);
67 for (o1
= 0; o1
< 64000; o1
++) {
69 BlocksBuf
[o2
++] = RGBPal
[Pixel
][2];
70 BlocksBuf
[o2
++] = RGBPal
[Pixel
][1];
71 BlocksBuf
[o2
++] = RGBPal
[Pixel
][0];
76 //This reads a pixel from the sprite buffer
77 unsigned char _ReadPixel (int x
, int y
)
79 return SpriteBuf
[(y
<< 8) + (y
<< 6) + x
];
82 void Blit (int x
, int y
, int x1
, int y1
, int w
, int h
)
93 for (yt
= 0; yt
< h
; yt
++)
94 memcpy ((char *)TargetData
+ (y
+ yt
) * WIDTH
+ x
,
95 (char *)BlocksBuf
+ (y1
+ yt
) * 320 + x1
,
100 //This draws a sprite onto the device context
101 void DrawBlock (int x
, int y
, int x1
, int y1
)
105 //Convert coordinates
112 for (yt
= 0; yt
< 16; yt
++)
113 memcpy ((char *)TargetData
+ (y
+ yt
) * WIDTH
+ x
,
114 (char *)BlocksBuf
+ (y1
+ yt
) * 320 + x1
,
118 //This draws a transparent sprite onto the device context
119 void DrawTSprite (int x
, int y
, int x1
, int y1
, int xs
, int ys
)
124 for (xt
= 0; xt
< xs
; xt
++) for (yt
= 0; yt
< ys
; yt
++) {
125 c
= _ReadPixel (x1
+ xt
, y1
+ yt
);
126 if (c
) MainBitmapData
[(y
+ yt
) * WIDTH
+ x
+ xt
] = c
;