DeskLib 2.90a:GFX.h


Contents


Introduction and Overview

A set of fairly low-level graphics manipulation routines and related macros.

For full details of the plot codes and the subtle differences between them you are best off looking for documentation for OS_Plot in the PRMs, Stronghelp manuals, or whatever reference you normally use.


Functions


GFX_Plot

void GFX_Plot(int plotcode, int x, int y);

An assembler veneer for OS_Plot.

'x' and 'y' are the screen coordinates to use. 'plotcode' is one of the many macros, like plot_SPRITE, plot_POINT and similar, bitwise ORed with a modifier to define the exact behaviour.

Modifiers for everything but plot_BLOCK:

plot_MOVECURSORREL, plot_DRAWRELFORE, plot_DRAWRELINVERSE, plot_DRAWRELBACK, plot_MOVECURSORABS, plot_DRAWABSFORE, plot_DRAWABSINVERSE and plot_DRAWABSBACK

Modifiers for plot_BLOCK:

plot_BMOVEREL, plot_BMOVERECTREL, plot_BCOPYRECTREL, plot_BMOVEABS, plot_BMOVERECTABS and plot_BCOPYRECTABS


GFX_Rectangle

void GFX_Rectangle(int x, int y, int w, int h);

This draws a rectangle of width w and height h with the bottom-left hand corner at (x, y).

All values are in OS units.


GFX_CLG

void GFX_CLG(void );

This clears the current graphics window to the current background colour.


GFX_VDU

void GFX_VDU(char ch);

This is a veneer to OS_WriteC. It writes the given ASCII character to the VDU stream.


GFX_Write0

void GFX_Write0(const char *string);

This is a veneer for OS_Write0, which writes the given zero-terminated string to the VDU stream.


GFX_WriteN

void GFX_WriteN(const char *string, int numchars);

This is a veneer for OS_WriteN which writes 'numchars' characters from the given string to the VDU stream.


GFX_Wait

void GFX_Wait(void );

This call does not return until the vertical refresh has finished.

This means that you get control back after the hardware has finshed updating the screen so if you do any drawing immediately after this call it will be done while the screen is not being drawn. This helps reduce flicker.

Calling this procedure in Wimp applications should be used sparingly as overuse will slow down the machine to an unacceptable level. Generally only use by experimentation - write your graphics code, if it flickers too much try putting in a GFX_Wait() and see if it helps. If it does and the update speed isn't adversly affected then leave it in.


GFX_ReadPoint

BOOL GFX_ReadPoint(int x, int y, int *colour, int *tint);

This reads the colour and tint at the screen co-ordinate (x,y). If the point is not on the screen it returns FALSE, otherwise TRUE.

Note that 'colour' and 'tint' may be changed even if this function returns FALSE.


GFX_GetClip

void GFX_GetClip(wimp_rect *rect);

Get the current graphics clip rectangle


GFX_SetClip

void GFX_SetClip(wimp_rect *rect);

Set the current graphics clip rectangle


GFX_SetColour

void GFX_SetColour(unsigned int flags, unsigned int colour);

Set foreground or background colour. This is an interface to OS_SetColour


Function-like macros


GFX_Move

#define GFX_Move(x, y) GFX_Plot(plot_SOLIDBOTH + plot_MOVECURSORABS, x, y)

MACRO: void GFX_Move(int x, int y);

This moves the graphics cursor to the OS coordinates (x, y).


GFX_MoveBy

#define GFX_MoveBy(x, y) GFX_Plot(plot_SOLIDBOTH + plot_MOVECURSORREL, x, y)

MACRO: void GFX_MoveBy(int x, int y);

This moves the graphics cursor by (x, y) OS units relative to its current position.


GFX_PlotPoint

#define GFX_PlotPoint(x, y) GFX_Plot(plot_POINT + plot_DRAWABSFORE, x, y)

MACRO: void GFX_PlotPoint(int x, int y);

This plots a pixel at the OS coordinates (x, y).


GFX_PlotPointBy

#define GFX_PlotPointBy(x, y) GFX_Plot(plot_POINT + plot_DRAWRELFORE, x, y)

MACRO: void GFX_PlotPointBy(int x, int y);

This plots a pixel at the point (x, y) OS units from the current graphics cursor position.


GFX_Draw

#define GFX_Draw(x, y) GFX_Plot(plot_SOLIDBOTH + plot_DRAWABSFORE, x, y)

MACRO: void GFX_Draw(int x, int y);

This draws a line from the current graphics position to the OS coordinates (x, y).


GFX_DrawBy

#define GFX_DrawBy(x, y) GFX_Plot(plot_SOLIDBOTH + plot_DRAWRELFORE, x, y)

MACRO: void GFX_DrawBy(int x, int y);

This draws a line from the current graphics position to a point (x, y) OS units away.


GFX_RectangleFill

#define GFX_RectangleFill(x, y, w, h)                       \
  {                                                         \
    GFX_Move(x, y);                                         \
    GFX_Plot(plot_RECTANGLEFILL + plot_DRAWRELFORE, w, h);  \
  }

MACRO: void GFX_RectangleFill(int x, int y, int w, int h);

This draws a filled rectangle of width w and height h with the bottom-left hand corner at (x, y).

All values are in OS units.


GFX_Circle

#define GFX_Circle(x, y, r)                                 \
  {                                                         \
    GFX_Move(x, y);                                         \
    GFX_Plot(plot_CIRCLE + plot_DRAWRELFORE, (r), 0);       \
  }

MACRO: void GFX_Circle(int x, int y, int r);

This draws a circle outline of radius r, with its centre at (x, y).

All values are in OS units.


GFX_CircleFill

#define GFX_CircleFill(x, y, r)                             \
  {                                                         \
    GFX_Move(x, y);                                         \
    GFX_Plot(plot_CIRCLEFILL + plot_DRAWRELFORE, (r), 0);   \
  }

MACRO: void GFX_Circle(int x, int y, int r);

This draws a filled circle of radius r, with its centre at (x, y).

All values are in OS units.


VDU

#define VDU(C) GFX_VDU(C)

MACRO: void VDU(char ch);

This is an alias for GFX_VDU, which is a veneer to OS_WriteC. It writes the given ASCII character to the VDU stream.


GFX_GCOL

#define GFX_GCOL(A,C) {GFX_VDU(18); GFX_VDU(A); GFX_VDU(C);}

MACRO: void GFX_GCOL(int action, int colour);

This sets the current graphics colour and action through a VDU sequence.


GFX_Mode

#define GFX_Mode(M) {GFX_VDU(22); GFX_VDU(M);}

MACRO: void GFX_Mode(int mode);

Sets the screen mode to the given mode number.

Don't do this in the desktop.


GFX_SetOrigin

#define GFX_SetOrigin(x,y) {short a=(x),b=(y); GFX_VDU(29); \
                            GFX_VDU(a & 0xff); GFX_VDU((a>>8) & 0xff); \
                            GFX_VDU(b & 0xff); GFX_VDU((b>>8) & 0xff);}

MACRO: void GFX_SetOrigin(short x, short y);

This sets the graphics origin to (x, y) in OS coordinates.


Macros


plot_SOLIDBOTH

#define  plot_SOLIDBOTH       0x00

plot_SOLIDEXFINAL

#define  plot_SOLIDEXFINAL    0x08

plot_DOTTEDBOTH

#define  plot_DOTTEDBOTH      0x10

plot_DOTTEDEXFINAL

#define  plot_DOTTEDEXFINAL   0x18

plot_SOLIDEXINIT

#define  plot_SOLIDEXINIT     0x20

plot_SOLIDEXBOTH

#define  plot_SOLIDEXBOTH     0x28

plot_DOTTEDEXINIT

#define  plot_DOTTEDEXINIT    0x30

plot_DOTTEDEXBOTH

#define  plot_DOTTEDEXBOTH    0x38

plot_POINT

#define  plot_POINT           0x40

plot_HHORZLINEFILLNB

#define  plot_HHORZLINEFILLNB 0x48

plot_TRIANGLEFILL

#define  plot_TRIANGLEFILL    0x50

plot_HORIZLINEFILLB

#define  plot_HORIZLINEFILLB  0x58

plot_RECTANGLEFILL

#define  plot_RECTANGLEFILL   0x60

plot_HORIZLINEFILLF

#define  plot_HORIZLINEFILLF  0x68

plot_PARALLELFILL

#define  plot_PARALLELFILL    0x70

plot_HORIZLINEFILLNF

#define  plot_HORIZLINEFILLNF 0x78

plot_FLOODTOBACK

#define  plot_FLOODTOBACK     0x80

plot_FLOODTOFORE

#define  plot_FLOODTOFORE     0x88

plot_CIRCLE

#define  plot_CIRCLE          0x90

plot_CIRCLEFILL

#define  plot_CIRCLEFILL      0x98

plot_CIRCLEARC

#define  plot_CIRCLEARC       0xA0

plot_SEGMENT

#define  plot_SEGMENT         0xA8

plot_SECTOR

#define  plot_SECTOR          0xB0

plot_BLOCK

#define  plot_BLOCK           0xB8

plot_ELLIPSE

#define  plot_ELLIPSE         0xC0

plot_ELLIPSEFILL

#define  plot_ELLIPSEFILL     0xC8

plot_GRAPHICSCHAR

#define  plot_GRAPHICSCHAR    0xD0

plot_SPRITE

#define  plot_SPRITE          0xE8

plot_MOVECURSORREL

#define  plot_MOVECURSORREL   0

Within each block of eight the offset from the base number means:


plot_DRAWRELFORE

#define  plot_DRAWRELFORE     1

plot_DRAWRELINVERSE

#define  plot_DRAWRELINVERSE  2

plot_DRAWRELBACK

#define  plot_DRAWRELBACK     3

plot_MOVECURSORABS

#define  plot_MOVECURSORABS   4

plot_DRAWABSFORE

#define  plot_DRAWABSFORE     5

plot_DRAWABSINVERSE

#define  plot_DRAWABSINVERSE  6

plot_DRAWABSBACK

#define  plot_DRAWABSBACK     7

plot_BMOVEREL

#define  plot_BMOVEREL        0

The above applies except for plot_BLOCK where the codes are as follows:


plot_BMOVERECTREL

#define  plot_BMOVERECTREL    1

plot_BCOPYRECTREL

#define  plot_BCOPYRECTREL    2

plot_BMOVEABS

#define  plot_BMOVEABS        4

plot_BMOVERECTABS

#define  plot_BMOVERECTABS    5

plot_BCOPYRECTABS

#define  plot_BCOPYRECTABS    6