summaryrefslogtreecommitdiff
path: root/src/gfx.h
blob: d3f1ec33967bd16b19fee8ef839b1cd8c9e25aff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*

    espec - Sinclair Spectrum emulator

    Copyright (C) 2003  Ian Cowburn (ianc@noddybox.demon.co.uk)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    -------------------------------------------------------------------------

    Wrapper to SDL

*/

#ifndef ESPEC_GFX_H
#define ESPEC_GFX_H "$Id$"

#include "SDL.h"


/* ---------------------------------------- CONSTANTS
*/
#define FONT_UP_ARROW		'\001'
#define FONT_DOWN_ARROW		'\002'
#define FONT_LEFT_ARROW		'\003'
#define FONT_RIGHT_ARROW	'\004'
#define FONT_TICK		'\005'
#define FONT_CROSS		'\006'
#define FONT_CURSOR		'\007'
#define FONT_COPYRIGHT		'\010'


/* ---------------------------------------- INTERFACES
*/

/* Initialise
*/
void		GFXInit(void);


/* Get the SDL_Surface for the screen
*/
SDL_Surface	*GFXGetSurface(void);


/* Get the pixel value for a colour
*/
Uint32		GFXRGB(Uint8 r, Uint8 g, Uint8 b);


/* Clear the screen
*/
void		GFXClear(Uint32 col);


/* Indicate a frame is starting
*/
void		GFXStartFrame(void);


/* Indicate a frame is done and refreshes the screen
   If delay is TRUE, sleeps to implement the frames_per_sec config.
   It's safe to call this multiple times without a matching GFXStartFrame().
*/
void		GFXEndFrame(int delay);


/* Set key repeat
*/
void		GFXKeyRepeat(int repeat);


/* Suck out keyboard events.  Returns NULL if no more keyboard events
*/
SDL_Event	*GFXGetKey(void);


/* Wait for a keypress (key up event)
*/
SDL_Event	*GFXWaitKey(void);


/* Lock the screen for updates
*/
void		GFXLock(void);


/* Unlock the screen following updates
*/
void		GFXUnlock(void);


/*
    Note that no bound checking (except for GFXPrint()) is done - it is the
    callers responsibility to plot onscreen.
*/

/* Plot a point without locking.  GFXLock() and GFXUnlock() MUST surround
   calls to this
*/
void		GFXFastPlot(int x, int y, Uint32 col);


/* Plot a point
*/
void		GFXPlot(int x, int y, Uint32 col);


/* Draw a rectangle
*/
void		GFXRect(int x, int y, int w, int h, Uint32 col, int solid);


/* Draw an horizontal line
*/
void		GFXHLine(int x1, int x2, int y, Uint32 col);


/* Draw a vertical line
*/
void		GFXVLine(int x, int y1, int y2, Uint32 col);


/* Draws text using an internal 8x8 monspaced font.  The only supported
   characters are 32-126 and the special FONT_xxx characters defined
   above.  The routine assumes the environment operates with ASCII.

   The co-ord given is the top left of the first character, and characters
   are drawn transparently.

   Causes undefined behaviour if the generated string from the printf
   format is longer than 256 characters.
*/
void		GFXPrint(int x, int y, Uint32 col, const char *format, ...);


/* As above, but draws text using the supplied background colour, rather
   than transparently.
*/
void		GFXPrintPaper(int x, int y, Uint32 col, Uint32 paper,
			      const char *format, ...);


#endif


/* END OF FILE */