| version 1.3, 2003/06/27 02:18:30 |
version 1.4, 2003/07/11 11:41:46 |
|
|
| * |
* |
| */ |
*/ |
| |
|
| /* $Platon: games/_shared/my-graph.c,v 1.2 2003/06/22 18:40:34 nepto Exp $ */ |
/* $Platon: games/_shared/my-graph.c,v 1.3 2003/06/27 02:18:30 nepto Exp $ */ |
| |
|
| #include <stdio.h> |
#include <stdio.h> |
| #include <stdlib.h> |
#include <stdlib.h> |
| Line 82 void my_graph_close(void) /* {{{ */ |
|
| Line 82 void my_graph_close(void) /* {{{ */ |
|
| |
|
| #endif /* #if PLATON_SYSTEM_MSDOS || PLATON_SYSTEM_WIN32 */ |
#endif /* #if PLATON_SYSTEM_MSDOS || PLATON_SYSTEM_WIN32 */ |
| |
|
| |
#if ! PLATON_SYSTEM_MSDOS |
| |
|
| |
void putimage_BGI(const int x, const int y, void *image, const int op) /* {{{ */ |
| |
{ |
| |
register short width, height; |
| |
register int linesize, linesize2, linesize4; |
| |
register int i, j, k, mask; |
| |
register unsigned char r, g, b, B; |
| |
register unsigned char *offset; |
| |
static int pow2[] = {1, 2, 4, 8, 16, 32, 64, 128}; |
| |
|
| |
width = ((short *) image)[0]; |
| |
height = ((short *) image)[1]; |
| |
image = (void *) ((short *) image + 2); |
| |
linesize = 4 + ((width / 2) & ~3); |
| |
linesize2 = linesize / 2; |
| |
linesize4 = linesize2 / 2; |
| |
for (j = 0; j < height; j++) { |
| |
offset = (unsigned char *) image + (j * linesize); |
| |
for (i = 0; i < width; offset++) { |
| |
B = *offset; |
| |
r = *(offset + linesize4); |
| |
g = *(offset + linesize2); |
| |
b = *(offset + linesize2 + linesize4); |
| |
for (k = 7; k >= 0 && i < width; k--, i++) { |
| |
mask = pow2[k]; |
| |
putpixel(x + i, y + j, |
| |
(r & mask ? 4 : 0) + |
| |
(g & mask ? 2 : 0) + |
| |
(b & mask ? 1 : 0) + |
| |
(B & mask ? 8 : 0) ); |
| |
#if 0 /* text output */ /* {{{ */ |
| |
putchar('0' |
| |
+ (r & mask ? 4 : 0) |
| |
+ (g & mask ? 2 : 0) |
| |
+ (b & mask ? 1 : 0) |
| |
+ (B & mask ? 8 : 0) |
| |
); |
| |
#endif /* }}} */ |
| |
} |
| |
} |
| |
} |
| |
return; |
| |
} /* }}} */ |
| |
|
| |
#endif |
| |
|
| #if PLATON_SYSTEM_SVGALIB |
#if PLATON_SYSTEM_SVGALIB |
| |
|
| static int svgalib_gmode_initialized = 0; |
static int svgalib_gmode_initialized = 0; |
| Line 416 void getimage(const int x1, const int y1 |
|
| Line 463 void getimage(const int x1, const int y1 |
|
| gl_getbox(x1, y1, x2 - x1 + 1, y2 - y1 + 1, (void *) ((short *) image + 4)); |
gl_getbox(x1, y1, x2 - x1 + 1, y2 - y1 + 1, (void *) ((short *) image + 4)); |
| } /* }}} */ |
} /* }}} */ |
| |
|
| static void putimage_BGI(const int x, const int y, void *image, const int op) /* {{{ */ |
|
| { |
|
| register short width, height; |
|
| register int linesize, linesize2, linesize4; |
|
| register int i, j, k, mask; |
|
| register unsigned char r, g, b, B; |
|
| register unsigned char *offset; |
|
| static int pow2[] = {1, 2, 4, 8, 16, 32, 64, 128}; |
|
| |
|
| width = ((short *) image)[0]; |
|
| height = ((short *) image)[1]; |
|
| image = (void *) ((short *) image + 2); /* (unsigned char *) image + 4; REMOVE ME! */ |
|
| linesize = 4 + ((width / 2) & ~3); |
|
| linesize2 = linesize / 2; |
|
| linesize4 = linesize2 / 2; |
|
| for (j = 0; j < height; j++) { |
|
| offset = (unsigned char *) image + (j * linesize); |
|
| for (i = 0; i < width; offset++) { |
|
| B = *offset; |
|
| r = *(offset + linesize4); |
|
| g = *(offset + linesize2); |
|
| b = *(offset + linesize2 + linesize4); |
|
| for (k = 7; k >= 0 && i < width; k--, i++) { |
|
| mask = pow2[k]; |
|
| gl_setpixel(x + i, y + j, |
|
| (r & mask ? 4 : 0) + |
|
| (g & mask ? 2 : 0) + |
|
| (b & mask ? 1 : 0) + |
|
| (B & mask ? 8 : 0) ); |
|
| #if 0 /* text output */ /* {{{ */ |
|
| putchar('0' |
|
| + (r & mask ? 4 : 0) |
|
| + (g & mask ? 2 : 0) |
|
| + (b & mask ? 1 : 0) |
|
| + (B & mask ? 8 : 0) |
|
| ); |
|
| #endif /* }}} */ |
|
| } |
|
| } |
|
| } |
|
| } /* }}} */ |
|
| |
|
| void putimage(const int x, const int y, void *image, const int op) /* {{{ */ |
void putimage(const int x, const int y, void *image, const int op) /* {{{ */ |
| { |
{ |
| register short width, height; |
register short width, height; |