1 /***************************************************************************
2 
3     copyright            : (C) 2006 by mean
4     email                : fixounet@free.fr
5  ***************************************************************************/
6 
7 /***************************************************************************
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  ***************************************************************************/
15 
16 #include "ADM_image.h"
17 #include "ADM_print_priv.h"
18 #define GLYPH_WIDTH  12
19 #define GLYPH_HEIGHT 20
20 
21 // Borrowed from decomb
22 // Borrowed from the author of IT.dll, whose name I
23 // could not determine.
24 /**
25     \fn drawGlyph
26 */
drawGlyph(ADMImage * dst,int x,int y,int num,int offset,int color)27 static void drawGlyph(ADMImage *dst, int x, int y, int num,int offset, int color)
28 {
29 
30 	x = x * GLYPH_WIDTH;
31 	y = y * GLYPH_HEIGHT;
32     uint16_t *glyphLine=font[num];
33 
34 	int pitch = dst->GetPitch(PLANAR_Y);
35     uint8_t *top=dst->GetWritePtr(PLANAR_Y)+(y+offset)*pitch+(x+4+offset);
36 
37     for (int ty = 0; ty < GLYPH_HEIGHT; ty++)
38     {
39         uint16_t glyph=glyphLine[ty];
40 
41         for (int tx = 0; tx < GLYPH_WIDTH; tx++)
42         {
43             if(glyph & 0x8000)
44                         top[tx]=color;
45             glyph<<=1;
46         }
47         top+=pitch;
48     }
49 }
50 
51 
52 /**
53     \fn printString
54 */
printString(uint32_t x,uint32_t y,const char * s)55 bool     ADMImage::printString(uint32_t x,uint32_t y, const char *s)
56 {
57     for (int xx = 0; *s; ++s, ++xx)
58     {
59         if(*s==0x0d || *s==0x0a) continue;
60         if( (x+xx+1)*GLYPH_WIDTH>_width)
61                 break;
62         drawGlyph(this, x + xx, y, *s - ' ',1,0);
63         drawGlyph(this, x + xx, y, *s - ' ',0,0xF0);
64     }
65 
66     return true;
67 }
68 
69