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);
36 unsigned char RGBPal
[256][3];
40 //Assign memory to sprite buffer
41 RawBuf
= (char *)malloc (64000);
43 //Load graphics data from file
44 SSFFile
= fopen ("Bomber1.ssf", "rb");
45 fread (RawBuf
, 7, 1, SSFFile
);
46 fread (RawBuf
, 320, 200, SSFFile
);
47 fread (RGBPal
, 3, 256, SSFFile
);
54 for (DAC
= 0; DAC
< 256; DAC
++) {
55 RGBPal
[DAC
][0] <<= 2;
56 RGBPal
[DAC
][1] <<= 2;
57 RGBPal
[DAC
][2] <<= 2;
58 Palette
[DAC
] = (RGBPal
[DAC
][0]) +
59 (RGBPal
[DAC
][1] << 8) +
60 (RGBPal
[DAC
][2] << 16);
65 for (o1
= 0; o1
< 64000; o1
++) {
67 BlocksBuf
[o2
++] = RGBPal
[Pixel
][2];
68 BlocksBuf
[o2
++] = RGBPal
[Pixel
][1];
69 BlocksBuf
[o2
++] = RGBPal
[Pixel
][0];
74 //This reads a pixel from the sprite buffer
75 unsigned char _ReadPixel (int x
, int y
)
77 return SpriteBuf
[(y
<< 8) + (y
<< 6) + x
];
80 void Blit (int x
, int y
, int x1
, int y1
, int w
, int h
)
91 for (yt
= 0; yt
< h
; yt
++)
92 memcpy ((char *)TargetData
+ (y
+ yt
) * WIDTH
+ x
,
93 (char *)BlocksBuf
+ (y1
+ yt
) * 320 + x1
,
98 //This draws a sprite onto the device context
99 void DrawBlock (int x
, int y
, int x1
, int y1
)
103 //Convert coordinates
110 for (yt
= 0; yt
< 16; yt
++)
111 memcpy ((char *)TargetData
+ (y
+ yt
) * WIDTH
+ x
,
112 (char *)BlocksBuf
+ (y1
+ yt
) * 320 + x1
,
116 //This draws a transparent sprite onto the device context
117 void DrawTSprite (int x
, int y
, int x1
, int y1
, int xs
, int ys
)
122 for (xt
= 0; xt
< xs
; xt
++) for (yt
= 0; yt
< ys
; yt
++) {
123 c
= _ReadPixel (x1
+ xt
, y1
+ yt
);
124 if (c
) MainBitmapData
[(y
+ yt
) * WIDTH
+ x
+ xt
] = c
;