Subversion Repositories Kolibri OS

Rev

Rev 6524 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6470 siemargl 1
#ifndef KOLIBRI_STATICTEXT_H
2
#define KOLIBRI_STATICTEXT_H
3
 
4
typedef enum {
5
	cp866,  // 6x9
6
	CP866,  // 8x16
7
	UTF16,
8
	UTF8
9
} encoding_t;
10
 
11
typedef struct {
12
	uint32_t start_xy;
13
	char *text;
14
	uint32_t color_flags;
15
	uint32_t bg_color;
16
}statictext;
17
 
18
typedef struct {
19
	uint32_t start_xy;
20
	int32_t number;
21
	uint32_t color_flags;
22
	uint32_t bg_color;
23
	uint16_t width;
24
}staticnum;
25
 
26
statictext* kolibri_statictext(statictext* st, uint32_t xy, char *text, encoding_t enc, int size, color_t font, color_t bg)
27
{
28
    st->start_xy = xy;
29
    st->text = text;
30
    st->color_flags = 0x80000000; // asciiz
31
    st->bg_color = bg;
32
    if(bg & 0xFFFFFF) st->color_flags |= 0x40000000;// use background
33
    st->color_flags |= ((enc & 1) << 4) | (size & 7) << 24;
34
    st->color_flags |= font & 0xFFFFFF;
35
 
36
    return st;
37
}
38
 
39
statictext* kolibri_statictext_def(statictext* st, uint32_t xy, char *text)
40
{
41
    return kolibri_statictext(st, xy, text, 0, 0, kolibri_color_table.color_work_text, 0);
42
}
43
 
44
statictext* kolibri_new_statictext(uint32_t xy, char *text, encoding_t enc, int size, color_t font, color_t bg)
45
{
46
    statictext *st = (statictext*)malloc(sizeof(statictext));
47
 
48
    return kolibri_statictext(st, xy, text, enc, size, font, bg);
49
}
50
 
51
statictext* kolibri_new_statictext_def(uint32_t xy, char *text)
52
{
53
    return kolibri_new_statictext(xy, text, 0, 0, kolibri_color_table.color_work_text, 0);
54
}
55
 
56
__attribute__((__stdcall__))
57
void statictext_draw(statictext *st)
58
{
59
    __asm__ __volatile__(
60
    "int $0x40"
61
    ::"a"(4),
62
      "b"(st->start_xy),
63
      "c"(st->color_flags),
64
      "d"(st->text),
65
      "D"(st->bg_color)
66
    :);
67
}
68
 
69
staticnum* kolibri_staticnum(staticnum* st, uint32_t xy, int32_t width, int16_t number, encoding_t enc, int size, color_t font, color_t bg)
70
{
71
    st->start_xy = xy;
72
    st->number = number;
73
    st->color_flags = 0;
74
    st->bg_color = bg;
75
    if(bg & 0xFFFFFF) st->color_flags |= 0x40000000;// use background
76
    st->color_flags |= ((enc & 1) << 4) | (size & 7) << 24;
77
    st->color_flags |= font & 0xFFFFFF;
78
    st->width = width;
79
 
80
    return st;
81
}
82
 
83
staticnum* kolibri_staticnum_def(staticnum* st, uint32_t xy, int16_t width, int32_t number)
84
{
85
    return kolibri_staticnum(st, xy, width, number, 0, 0, kolibri_color_table.color_work_text, 0);
86
}
87
 
88
staticnum* kolibri_new_staticnum(uint32_t xy, int32_t width, int32_t number, encoding_t enc, int size, color_t font, color_t bg)
89
{
90
    staticnum *st = (staticnum*)malloc(sizeof(staticnum));
91
 
92
    return kolibri_staticnum(st, xy, width, number, enc, size, font, bg);
93
}
94
 
95
staticnum* kolibri_new_staticnum_def(uint32_t xy, int32_t width, int32_t number)
96
{
97
    return kolibri_new_staticnum(xy, width, number, cp866, 0, kolibri_color_table.color_work_text, 0);
98
}
99
 
100
__attribute__((__stdcall__))
101
void staticnum_draw(staticnum *st)
102
{
103
    register uint32_t fmt;
104
    if (st->width < 0)
105
        fmt = (-st->width << 16); // leading zeros, decimal
106
    else
107
        fmt = (st->width << 16) | 0x80000000; // no leading zeros, decimal
108
 
109
    __asm__ __volatile__(
110
    "int $0x40"
111
    ::"a"(47),
112
      "b"(fmt),
113
      "c"(st->number),
114
      "d"(st->start_xy),
115
      "S"(st->color_flags),
116
      "D"(st->bg_color)
117
    :);
118
}
119
 
120
 
121
#endif /* KOLIBRI_STATICTEXT_H */