DeskLib 2.90a:Screen.h


Contents


Introduction and Overview

This header declares a function to read information about the current screen mode, and store it in various global variables. To ensure that the variables are up to date, you should either call Screen_CacheModeInfo before you access them, or call it every time the mode changes.

A handler is provided in the Handler library (Handler_ModeChange) which you can use with the EventMsg system to call the function on every mode change.


Functions


Screen_ReadModeVariable

os_error * Screen_ReadModeVariable(int mode, mode_variable variable, int *value);

This function reads a mode variable for the mode 'mode', or the current screen mode if 'mode' is -1. The value is returned in 'value'.


Screen_CacheModeInfo

BOOL Screen_CacheModeInfo(void );

This function reads various pieces of information about the current screen mode and sets the variables defined by this file appropriately. It should be called before you try to use any of those variables.

It only needs to be called when the mode changes, so you can call it when your program starts and whenever a mode change message is received, or else immediately before you use the variables.

It checks the screenmode, and if it has not changed from the last call, then the variables are not updated. This means it will not be a big problem if you call it more often than strictly necessary (every time you redraw, for example).

This function always returns TRUE.


Types


mode_variable

typedef enum
{
modevar_MODEFLAGS = 0,
modevar_RIGHTCOLUMN,
modevar_BOTTOMROW,
modevar_NCOLOUR,
modevar_XEIGFACTOR,
modevar_YEIGFACTOR,
modevar_LINELENGTH,
modevar_SCREENSIZE,
modevar_YSHIFTFACTOR,
modevar_LOG2BPP,
modevar_LOG2BPC,
modevar_XWINDOWLIMIT,
modevar_YWINDOWLIMIT
} mode_variable;

This gives useful names to the various mode variables you can read with Screen_ReadModeInfo.


screen_modespec

typedef struct
{
unsigned int flags;
unsigned int xres;
unsigned int yres;
unsigned int bpp;
unsigned int framerate;
struct
{
unsigned int index;
unsigned int value;

} vars[1];

} screen_modespec;

Mode specifier


screen_modesprite

typedef struct
{
int istype : 1;
int horz_dpi : 13;
int vert_dpi : 13;
int type : 5;

} screen_modesprite;

Format specifier used for sprites


screen_modeval

typedef union
{
unsigned int screen_mode;
screen_modesprite sprite_mode;
screen_modespec *spec_mode;

} screen_modeval;

RISC OS modes


Variables


screen_mode

extern screen_modeval screen_mode;

This holds the current screen mode.


screen_size

extern wimp_point screen_size;

This holds the current screen size in OS units.


screen_eig

extern wimp_point screen_eig;

Log2(screen_delta)


screen_delta

extern wimp_point screen_delta;

This holds the size of a pixel in OS coordinates for the current mode.


screen_bpp

extern int screen_bpp;

This gives the bits per pixel for the current mode, ie. the colour "depth".