/*
*    DivaPC ARM C source
*
*    SYS.H.FESTATE  - System-wide Front End state
*
*
*    16-02-92 INH  Original
*                  YARMpixels deleted
*    20-03-95      Version numbering system added
*    17-11-95 2.00 GetTextFn replaces PCModeFlags
*    01-08-95 2.02 Activity and VertScroll swapped to fix PC Exchange
*/

#include "sprite.h"


/* FrontEndState structure ------------------------------- */


struct FrontEndState
{
   int current_ver;            /* Current version of structure */
#define FESTATE_CURR_VER 202
   int min_compat_ver;         /* Minimum version # with which this
                                   structure is compatible */
#define FESTATE_MIN_VER 202

/*
*    System Status variables
*
*    SuspendRequest may be set to 'true' by anything which
*    wants to suspend execution.
*
*    QuitRequest may be set 'true' when the application is required to quit.
*    (You must also set SuspendRequest if the CPU is currently running).
*
*    ResetRequest may be set true to cause the CPU to be reset the next time
*    the full-screen or windowed mode is started.
*
*    FreezeRequest may be set true to cause !PC to freeze running in a
*      window, similar to selecting 'freeze' from the menu.
*
*    FullFErunning is 'true' whenever the program is running in full-screen
*    mode, i.e. it is set true just before a StartFE event and false just
*    before a StopFE event.
*
*    WinFErunning is true whenever the program is running in a window (i.e.
*    when said window is open on the screen). It is set just before a
*    StartWinFE event and reset after a StopWinFE event.
*
*
*/

   bool SuspendRequest;  /* Set True to suspend full-screen mode */
   bool QuitRequest;     /* Set True to suspend whole application */
   bool ResetRequest;    /* Set True to reset CPU at next opportunity */
   bool FreezeRequest;   /* Set True to freeze multitasking mode */

   bool FullFErunning;
   bool WinFErunning;
   bool HasInputFocus;

   ModeSpec  WimpMode;    /* Mode in which the Wimp is currently running */

/* Screen information ************/

   int  ArmBottomY;         /* RISCOS Co-ords of ORIGIN of on-screen image */
   int  ArmLeftX;

   int  WinXmin;            /* Bounding box of visible area */
   int  WinXmax;
   int  WinYmin;
   int  WinYmax;

   int  Xratio;             /* RISCOS units per X pixel */
   int  Yratio;             /* RISCOS units per Y pixel */

/* Screen information for windows FE mode ******** */

   int (*GetTextFn) ( char *dest_buf, int dest_len );
                            /* Pointer to fn. to read screen text
   				into a buffer. Called in user mode,
   				dest_buf points to the buffer, dest_len
   				is the length. Returns number of bytes
   				read. Does not terminate it with a 0! */

   int  Xpixels;            /* No. of pixels across */
   int  Ypixels;            /* No. of pixels high in PC image */
   int  PCbpp;              /* Bits per pixel in PC image */

   bool ModeChanged;        /* True if PC mode has been changed */
                            /* should be reset by Front End only */
   sprite_area *s_area;     /* Gives sprite containing PC screen data */
   sprite_id    spriteid;

   bool  PaletteChanged;    /* Set true if you've changed ColourTable,
                               below. Front-end code will reset it when
                               it has dealt with the palette change */
   int   ColourTable[256];  /* Values (of the form 0xBBGGRR00) representing
                               the RGB values for each of the pixels in the
                               PC sprite. Only first 16 entries are
                               significant in 4bpp modes. None are used in
                               16- and 32-bpp modes */

   int  ChgdXmin;           /* Co-ord of screen area which have changed */
   int  ChgdXmax;           /* Given in PC pixels: positive-Y-is-down */
   int  ChgdYmin;           /* If Xmax<Xmin or Ymax<Ymin, nothing is */
   int  ChgdYmax;           /* redrawn */


/* Miscellaneous information **************************************** */

   int  Activity;           /* Used as a measure PC activity; */
                            /* In FE mode, Activity is decremented once */
                            /* every Poll event; when it reaches zero */
                            /* the CPU is suspended */

   int  VertScroll;         /* This is provided as a speed-up for */
                            /* text scrolling up the screen; a positive */
                            /* value in this indicates the number of */
                            /* physical pixels it has moved up */

   int  RedrawDelay;        /* Redraw delay: it is not always a good idea */
                            /* to redraw the window immediately after an */
                            /* area of it has been changed - instead a */
                            /* delay can be set to allow other areas to */
                            /* be changed as well. RedrawDelay is */
                            /* decremented once after each Poll event; */
                            /* when it reaches 0 a redraw of the changed */
                            /* regions is done */

  };


/* Define front end state structure (kept in module space) */

extern struct FrontEndState *SYS_FEState_Ptr;

#define SYS_FEState (*SYS_FEState_Ptr)
