OSDN Git Service

Nazghul-0.7.1
[nazghul-jp/nazghul-jp.git] / src / ascii.h
1 //
2 // nazghul - an old-school RPG engine
3 // Copyright (C) 2002, 2003 Gordon McNutt
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 2 of the License, or (at your option)
8 // any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13 // more details.
14 //
15 // You should have received a copy of the GNU General Public License along with
16 // this program; if not, write to the Free Foundation, Inc., 59 Temple Place,
17 // Suite 330, Boston, MA 02111-1307 USA
18 //
19 // Gordon McNutt
20 // gmcnutt@users.sourceforge.net
21 //
22 #ifndef ascii_h
23 #define ascii_h
24
25 #include "macros.h"
26
27 #include <SDL.h>
28
29 BEGIN_DECL
30
31 extern int asciiInit(void);
32
33 /**
34  * Print a character using a build-in font and color. In the usual case this
35  * prints the character to the surface using the current font and color. In the
36  * general case, 'c' may be part of a control sequence, where the format is:
37  *
38  *       <SEQ> := ^c<CMD><COLOR>
39  *     <COLOR> := B|w|r|g|b|c|y|m|G|!
40  *       <CMD> := +|-|<NIL>
41  *       <NIL> :=
42  *
43  * The '+' CMD pushes the current color before setting the new color. The '-'
44  * CMD pops the last pushed color and makes it the new color.
45  *
46  * The color codes:
47  *
48  *   w White
49  *   B Black
50  *   r Red
51  *   g Green
52  *   b Blue
53  *   y Yellow
54  *   c Cyan
55  *   m Magenta
56  *   G Gray
57  *
58  * @param c is either a character to print or part of a control sequence.
59  * @param x is the pixel x-coord of the upper left corner to paint to.
60  * @param y is the pixel y-coord of the upper left corner to paint to.
61  * @param surface is the surface to paint to.
62  * @returns 1 if a character was painted, 0 if it was part of a control
63  * sequence
64  */
65 extern int asciiPaint(char c, int x, int y, SDL_Surface * surface);
66
67 /**
68  * Get the length of a string NOT including the font and color control
69  * characters. This is useful for determining how much screen space the string
70  * will take when printed with asciiPaint().
71  *
72  * The function assumes that the string applies to the current internal state
73  * of the ascii painting engine. This is only important if the last character
74  * to asciiPaint was part of an unfinished control sequence. In that case,
75  * asciiStrlen() assumes that this string continues where that one left off.
76  *
77  * @param s is the null-terminated string to check.
78  * @returns strlen(s) minus the number of control characters
79  */
80 extern int asciiStrlen(char *s);
81
82 END_DECL
83
84 #endif