C Language Development Kit/Functions/WhereX

From OptiWiki

Jump to: navigation, search
Description This function returns the X-coordinate of the current cursor position.
Syntax
int wherex(void);
Arguments None
Returns An integer value representing the current X-coordinate of the cursor position.
Remarks The coordinates of the top left corner of the display are (0,0).
The coordinates of the bottom right corner when using a system font are:
OPH100x PHL1300 PHL1700 PHL2700 DWT7133 OPL97xx DCL153x
Large font (13,7) (15,3) or
(15,4) cursor() with NOICONS
(15,3) (15,3) (15,1) (13,3) (13,3)
Small font (13,15) (15,7) or
(15,9) cursor() with NOICONS
(15,7) (15,7) (13,7) (13,7)
Medium font (17,9) (20,4) (17,4) (17,4)
Tiny font (17,20) (20,9) (17,9) (17,9)
Example
#include "lib.h"
#include <stdio.h>
 
#ifdef DWT
    #define MAXY1
#elif OPH
    #define MAXY7
#else 
    #define MAXY3
#endif
 
void Move( void )
{
    int x,y;
 
    // Move the 'X" one place down and two places to the right.
    x = wherex();
    y = wherey();
    printsymbol(' ');
    x+=2;
    if( x > 15 )
        x = 0;
    if( ++y > MAXY )
        y = 0;
    gotoxy( x, y);
    printsymbol('X');
}
 
void main( void )
{
    cursor( OFF );
    printsymbol('X');
 
    while( 1 )
    {
        if( getchar() == ENT_KEY)
        {
            sound( TSTANDARD, VMEDIUM, SHIGH, 0);
            Move();
        }
    }
}


Views
Personal tools