1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
23 /* ========================================================================= */
24 /* exported variables */
25 /* ========================================================================= */
30 /* ========================================================================= */
32 /* ========================================================================= */
34 void InitFontInfo(Bitmap bitmap_big, Bitmap bitmap_medium,
37 font.bitmap_big = bitmap_big;
38 font.bitmap_medium = bitmap_medium;
39 font.bitmap_small = bitmap_small;
42 int getFontWidth(int font_size, int font_type)
44 return (font_size == FS_BIG ? FONT1_XSIZE :
45 font_size == FS_MEDIUM ? FONT6_XSIZE :
46 font_type == FC_SPECIAL1 ? FONT3_XSIZE :
47 font_type == FC_SPECIAL2 ? FONT4_XSIZE :
48 font_type == FC_SPECIAL3 ? FONT5_XSIZE :
52 int getFontHeight(int font_size, int font_type)
54 return (font_size == FS_BIG ? FONT1_YSIZE :
55 font_size == FS_MEDIUM ? FONT6_YSIZE :
56 font_type == FC_SPECIAL1 ? FONT3_YSIZE :
57 font_type == FC_SPECIAL2 ? FONT4_YSIZE :
58 font_type == FC_SPECIAL3 ? FONT5_YSIZE :
62 void DrawInitText(char *text, int ypos, int color)
64 if (window && font.bitmap_small)
66 ClearRectangle(window, 0, ypos, video.width, FONT2_YSIZE);
67 DrawTextExt(window, (video.width - strlen(text) * FONT2_XSIZE)/2,
68 ypos, text, FS_SMALL, color);
73 void DrawTextFCentered(int y, int font_type, char *format, ...)
75 char buffer[MAX_OUTPUT_LINESIZE + 1];
76 int font_width = getFontWidth(FS_SMALL, font_type);
80 vsprintf(buffer, format, ap);
83 DrawText(playfield.sx + (playfield.sxsize - strlen(buffer) * font_width) / 2,
84 playfield.sy + y, buffer, FS_SMALL, font_type);
87 void DrawTextF(int x, int y, int font_type, char *format, ...)
89 char buffer[MAX_OUTPUT_LINESIZE + 1];
93 vsprintf(buffer, format, ap);
96 DrawText(playfield.sx + x, playfield.sy + y, buffer, FS_SMALL, font_type);
99 void DrawText(int x, int y, char *text, int font_size, int font_type)
101 DrawTextExt(drawto, x, y, text, font_size, font_type);
103 if (x < playfield.dx)
104 redraw_mask |= REDRAW_FIELD;
105 else if (y < playfield.vy)
106 redraw_mask |= REDRAW_DOOR_1;
109 void DrawTextExt(DrawBuffer bitmap, int x, int y,
110 char *text, int font_size, int font_type)
113 int font_width, font_height, font_start;
114 boolean print_inverse = FALSE;
116 if (font_size != FS_SMALL && font_size != FS_BIG && font_size != FS_MEDIUM)
117 font_size = FS_SMALL;
118 if (font_type < FC_RED || font_type > FC_SPECIAL3)
121 font_width = getFontWidth(font_size, font_type);
122 font_height = getFontHeight(font_size, font_type);
124 font_bitmap = (font_size == FS_BIG ? font.bitmap_big :
125 font_size == FS_MEDIUM ? font.bitmap_medium :
127 font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE :
128 font_size == FS_MEDIUM ? FONT6_YSIZE :
130 FONT_LINES_PER_FONT);
132 if (font_type == FC_SPECIAL3)
133 font_start += (FONT4_YSIZE - FONT2_YSIZE) * FONT_LINES_PER_FONT;
139 if (c == '~' && font_size == FS_SMALL)
141 print_inverse = TRUE;
145 if (c >= 'a' && c <= 'z')
147 else if (c == 'ä' || c == 'Ä')
149 else if (c == 'ö' || c == 'Ö')
151 else if (c == 'ü' || c == 'Ü')
154 if (c >= 32 && c <= 95)
156 int src_x = ((c - 32) % FONT_CHARS_PER_LINE) * font_width;
157 int src_y = ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start;
158 int dest_x = x, dest_y = y;
162 BlitBitmap(font_bitmap, bitmap,
163 FONT_CHARS_PER_LINE * font_width,
164 3 * font_height + font_start,
165 font_width, font_height, x, y);
167 SetClipOrigin(font_bitmap, font_bitmap->stored_clip_gc,
168 dest_x - src_x, dest_y - src_y);
169 BlitBitmapMasked(font_bitmap, bitmap,
170 0, 0, font_width, font_height, dest_x, dest_y);
173 BlitBitmap(font_bitmap, bitmap,
174 src_x, src_y, font_width, font_height, dest_x, dest_y);