2015-08-17 03:16:17 +03:00
|
|
|
#ifndef INCLUDE_FONT_H
|
|
|
|
#define INCLUDE_FONT_H
|
|
|
|
|
|
|
|
#ifndef INCLUDE_MATH_H
|
|
|
|
#include "../lib/math.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INCLUDE_IO_H
|
|
|
|
#include "../lib/io.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
:struct FONT
|
|
|
|
{
|
2015-08-18 04:45:23 +03:00
|
|
|
byte width,height,offsetLine,r,g,b;
|
|
|
|
word width_buffer;
|
2015-08-17 19:21:51 +03:00
|
|
|
dword file_size;
|
2015-08-18 04:45:23 +03:00
|
|
|
dword buffer;
|
2015-08-18 12:13:34 +03:00
|
|
|
dword buffer_size;
|
2015-08-17 03:16:17 +03:00
|
|
|
word block;
|
|
|
|
dword data;
|
2015-08-17 19:21:51 +03:00
|
|
|
dword begin;
|
2015-08-17 03:16:17 +03:00
|
|
|
dword size_file;
|
|
|
|
byte load(...);
|
2015-08-18 04:45:23 +03:00
|
|
|
byte symbol(word x;byte s;dword c);
|
2015-08-17 19:21:51 +03:00
|
|
|
dword text(word x,y;dword text,c;byte size);
|
|
|
|
dword textarea(word x,y;dword text,c;byte size);
|
|
|
|
byte changeSIZE(byte size);
|
2015-08-18 04:45:23 +03:00
|
|
|
void PixelRGB(word x,y);
|
|
|
|
dword tmp_y,tmp_height,tmp_x;
|
2015-08-17 03:16:17 +03:00
|
|
|
};
|
|
|
|
FONT font = 0;
|
2015-08-18 04:45:23 +03:00
|
|
|
|
|
|
|
:void FONT::PixelRGB(dword x,y)
|
|
|
|
{
|
|
|
|
dword tmp;
|
|
|
|
tmp = y*width_buffer*3;
|
|
|
|
tmp += x*3;
|
|
|
|
tmp += buffer;
|
|
|
|
|
|
|
|
DSBYTE[tmp] = r;
|
|
|
|
tmp++;
|
|
|
|
DSBYTE[tmp] = g;
|
|
|
|
tmp++;
|
|
|
|
DSBYTE[tmp] = b;
|
|
|
|
}
|
2015-08-17 19:21:51 +03:00
|
|
|
:byte FONT::changeSIZE(byte size)
|
|
|
|
{
|
|
|
|
dword TMP_DATA;
|
|
|
|
dword ofs;
|
|
|
|
byte s;
|
|
|
|
IF(size<9) size = 8;
|
|
|
|
IF(size>45)size = 45;
|
|
|
|
s = size-8;
|
|
|
|
data = begin;
|
|
|
|
TMP_DATA = data;
|
|
|
|
TMP_DATA +=s*4;
|
|
|
|
ofs = DSDWORD[TMP_DATA];
|
|
|
|
IF(ofs==-1)return false;
|
|
|
|
data += ofs;
|
|
|
|
data += 156;
|
|
|
|
TMP_DATA = data;
|
|
|
|
file_size = DSDWORD[TMP_DATA];
|
|
|
|
TMP_DATA += file_size;
|
|
|
|
TMP_DATA--;
|
|
|
|
height = DSBYTE[TMP_DATA];
|
|
|
|
TMP_DATA--;
|
|
|
|
width = DSBYTE[TMP_DATA];
|
|
|
|
block = math.ceil(height*width/32);
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-18 04:45:23 +03:00
|
|
|
:proc_info Form_SELF_FONTS;
|
2015-08-18 12:13:34 +03:00
|
|
|
|
2015-08-17 19:21:51 +03:00
|
|
|
:dword FONT::text(word x,y;dword text1,c;byte size)
|
2015-08-17 03:16:17 +03:00
|
|
|
{
|
|
|
|
dword len=0;
|
2015-08-18 12:13:34 +03:00
|
|
|
IF(size)IF(!changeSIZE(size))return 0;
|
2015-08-18 04:45:23 +03:00
|
|
|
GetProcessInfo(#Form_SELF_FONTS, SelfInfo);
|
2015-08-18 12:13:34 +03:00
|
|
|
IF(y>Form_SELF_FONTS.cheight) return 0;
|
|
|
|
IF(x>Form_SELF_FONTS.cwidth) return 0;
|
|
|
|
tmp_y = y;
|
2015-08-18 04:45:23 +03:00
|
|
|
AX = c;
|
|
|
|
r = AL;
|
|
|
|
g = AH;
|
|
|
|
c>>=16;
|
|
|
|
AX = c;
|
|
|
|
b = AL;
|
|
|
|
width_buffer = width;
|
|
|
|
width_buffer *= strlen(text1);
|
2015-08-18 12:13:34 +03:00
|
|
|
IF(!buffer_size)buffer = malloc(width_buffer*height);
|
|
|
|
ELSE IF(buffer_size<width_buffer*height)buffer = realloc(width_buffer*height);
|
2015-08-18 04:45:23 +03:00
|
|
|
width_buffer /= 3;
|
|
|
|
CopyScreen(buffer,x+Form_SELF_FONTS.left+5,y+Form_SELF_FONTS.top+GetSkinHeight(),width_buffer,height);
|
2015-08-17 19:21:51 +03:00
|
|
|
|
2015-08-17 03:16:17 +03:00
|
|
|
WHILE(DSBYTE[text1])
|
|
|
|
{
|
2015-08-18 04:45:23 +03:00
|
|
|
len += symbol(len,DSBYTE[text1],c);
|
2015-08-17 03:16:17 +03:00
|
|
|
text1++;
|
|
|
|
}
|
2015-08-18 04:45:23 +03:00
|
|
|
_PutImage(x,y,width_buffer,height,buffer);
|
2015-08-17 03:16:17 +03:00
|
|
|
return len;
|
|
|
|
}
|
2015-08-17 19:21:51 +03:00
|
|
|
:dword FONT::textarea(word x,y;dword text1,c;byte size)
|
2015-08-17 03:16:17 +03:00
|
|
|
{
|
2015-08-18 04:45:23 +03:00
|
|
|
|
2015-08-17 03:16:17 +03:00
|
|
|
}
|
2015-08-18 04:45:23 +03:00
|
|
|
:byte FONT::symbol(signed x;byte s;dword c)
|
2015-08-17 03:16:17 +03:00
|
|
|
{
|
2015-08-17 19:21:51 +03:00
|
|
|
dword xi,yi;
|
|
|
|
dword tmp,_;
|
|
|
|
dword iii;
|
2015-08-18 12:13:34 +03:00
|
|
|
dword ___x;
|
2015-08-17 19:21:51 +03:00
|
|
|
byte rw=0;
|
|
|
|
IF(s==32)return width/4;
|
|
|
|
IF(s==9)return width;
|
|
|
|
yi = 0;
|
|
|
|
iii = 0;
|
|
|
|
tmp = 4*block*s;
|
|
|
|
tmp +=data;
|
2015-08-18 12:13:34 +03:00
|
|
|
while(yi<height)
|
2015-08-17 19:21:51 +03:00
|
|
|
{
|
|
|
|
xi = 0;
|
|
|
|
WHILE(xi<width)
|
|
|
|
{
|
2015-08-18 04:45:23 +03:00
|
|
|
IF(iii%32) _ >>= 1;
|
|
|
|
ELSE
|
|
|
|
{
|
2015-08-17 19:21:51 +03:00
|
|
|
tmp += 4;
|
|
|
|
_ = DSDWORD[tmp];
|
|
|
|
}
|
|
|
|
IF(_&1)
|
|
|
|
{
|
|
|
|
IF(xi>rw)rw=xi;
|
2015-08-18 12:13:34 +03:00
|
|
|
___x = x+xi;
|
|
|
|
IF(___x<Form_SELF_FONTS.cwidth)&&(tmp_y+yi<Form_SELF_FONTS.cheight)PixelRGB(x+xi,yi);
|
2015-08-17 19:21:51 +03:00
|
|
|
}
|
|
|
|
xi++;
|
|
|
|
iii++;
|
|
|
|
}
|
|
|
|
yi++;
|
|
|
|
}
|
|
|
|
return rw;
|
2015-08-17 03:16:17 +03:00
|
|
|
}
|
|
|
|
:byte FONT::load(dword path)
|
|
|
|
{
|
|
|
|
dword tmp;
|
|
|
|
IF(data)free(data);
|
|
|
|
tmp = io.read(path);
|
|
|
|
data = tmp;
|
2015-08-17 19:21:51 +03:00
|
|
|
begin = data;
|
2015-08-17 03:16:17 +03:00
|
|
|
size_file = io.FILES_SIZE;
|
|
|
|
tmp +=size_file;
|
|
|
|
tmp--;
|
|
|
|
height = DSBYTE[tmp];
|
|
|
|
tmp--;
|
|
|
|
width = DSBYTE[tmp];
|
|
|
|
block = math.ceil(height*width/32);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|