FreeBASIC  0.91.0
gfx_readxy.c
Go to the documentation of this file.
1 /* implementation of SCREEN function for graphics mode */
2 
3 #include "fb_gfx.h"
4 
5 
6 /*:::::*/
7 unsigned int fb_GfxReadXY( int col, int row, int colorflag )
8 {
10  GFX_CHAR_CELL *cell;
11 
12  if( __fb_gfx==NULL )
13  return 0;
14 
15  if( col < 1 || col > __fb_gfx->text_w
16  || row < 1 || row > __fb_gfx->text_h )
17  return 0;
18 
19  cell =
20  __fb_gfx->con_pages[ context->work_page ]
21  + (row - 1) * __fb_gfx->text_w
22  + col - 1;
23  if( colorflag == 0 ) {
24  return cell->ch;
25  }
26 
27  if( __fb_gfx->depth <= 4 ) {
28  return cell->fg + (cell->bg << 4);
29  } else if( __fb_gfx->depth <= 8 ) {
30  return cell->fg + (cell->bg << 8);
31  } else if( __fb_gfx->depth == 16 ) {
32  unsigned c;
33  if( colorflag == 2 )
34  c = cell->bg;
35  else
36  c = cell->fg;
37  return (((c & 0x001F) << 3) | ((c >> 2) & 0x7) |
38  ((c & 0x07E0) << 5) | ((c >> 1) & 0x300) |
39  ((c & 0xF800) << 8) | ((c << 3) & 0x70000) | 0xff000000);
40  } else {
41  if( colorflag == 2 )
42  return cell->bg;
43  return cell->fg;
44  }
45 }