FreeBASIC  0.91.0
io_locate.c
Go to the documentation of this file.
1 /* console LOCATE statement */
2 
3 #include "../fb.h"
4 #include "fb_private_console.h"
5 
6 int fb_ConsoleLocate( int row, int col, int cursor )
7 {
8  int x, y;
9  static int visible = 0x10000;
10 
11  if (!__fb_con.inited)
12  return 0;
13 
14  if ((row <= 0) || (col <= 0))
15  fb_ConsoleGetXY(&x, &y);
16 
17  BG_LOCK();
18 
19  if (col > 0)
20  x = col;
21  if (row > 0)
22  y = row;
23 
25 
26  if (x <= __fb_con.w)
27  __fb_con.cur_x = x;
28  else
29  __fb_con.cur_x = __fb_con.w;
30  if (y <= __fb_con.h)
31  __fb_con.cur_y = y;
32  else
33  __fb_con.cur_y = __fb_con.h;
34  fb_hTermOut(SEQ_LOCATE, x-1, y-1);
35  if (cursor == 0) {
37  visible = 0;
38  }
39  else if (cursor == 1) {
41  visible = 0x10000;
42  }
43 
44  BG_UNLOCK();
45 
46  return (x & 0xFF) | ((y & 0xFF) << 8) | visible;
47 }