Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7285 → Rev 7286

/programs/cmm/lib/collection.h
21,7 → 21,7
void increase_data_size();
};
 
void collection::increase_data_size() {
:void collection::increase_data_size() {
int filled_size;
if (realloc_size<4096) realloc_size = 4096;
if (!data_size) {
34,11 → 34,11
}
}
 
int collection::add(dword in) {
:int collection::add(dword in) {
return addn(in, strlen(in));
}
 
int collection::addn(dword in, len) {
:int collection::addn(dword in, len) {
if (count >= 4000) return 0;
if (element_offset[count]+len+2 > data_size) {
increase_data_size();
51,12 → 51,12
return 1;
}
 
dword collection::get(dword pos) {
:dword collection::get(dword pos) {
if (pos<0) || (pos>=count) return 0;
return data_start + element_offset[pos];
}
 
void collection::drop() {
:void collection::drop() {
if (data_start) free(data_start);
data_size = data_start = element_offset[count] = count = 0;
}
74,10 → 74,12
dword element[4096*3];
int add();
dword get();
dword get_last();
void pop();
void drop();
};
 
int collection_int::add(dword in) {
:int collection_int::add(dword in) {
if (count >= 4096*3) return 0;
element[count] = in;
count++;
84,12 → 86,20
return 1;
}
 
dword collection_int::get(dword pos) {
:dword collection_int::get(dword pos) {
if (pos<0) || (pos>=count) return 0;
return element[pos];
}
 
void collection_int::drop() {
:dword collection_int::get_last() {
return element[count];
}
 
:void collection_int::pop() {
if (count>0) count--;
}
 
:void collection_int::drop() {
element[0] =
count = 0;
}
/programs/cmm/lib/debug.h
40,7 → 40,6
{
debug( EDX);
debugch(10);
debugch(13);
}
 
inline void debugi(dword d_int)
/programs/cmm/lib/kfont.h
13,8 → 13,8
// [Название шрифта:"Times New Roman"]
 
 
#ifndef INCLUDE_LABEL_H
#define INCLUDE_LABEL_H
#ifndef INCLUDE_KFONT_H
#define INCLUDE_KFONT_H
 
#ifndef INCLUDE_MATH_H
#include "../lib/math.h"
33,6 → 33,8
#define KFONT_BPP 4
#endif
 
int kfont_char_width[255];
 
:struct __SIZE
{
dword width,height;
39,7 → 41,7
signed offset_x, offset_y;
byte pt;
};
:struct LABEL
:struct KFONT
{
__SIZE size;
int width,height;
49,7 → 51,6
word block;
dword raw;
dword raw_size;
//dword palette[256];
 
bool init();
bool changeSIZE();
56,6 → 57,7
byte symbol();
byte symbol_size();
dword getsize();
int get_label_width();
 
void ApplySmooth();
int WriteIntoWindow();
65,7 → 67,7
void ShowBufferPart();
} kfont;
 
:bool LABEL::init(dword font_path)
:bool KFONT::init(dword font_path)
{
IO label_io;
if(font)free(font);
81,8 → 83,9
return true;
}
 
:bool LABEL::changeSIZE()
:bool KFONT::changeSIZE()
{
int i;
dword file_size;
dword ofs;
if(size.pt<9) size.pt = 9;
94,15 → 97,20
height = DSBYTE[calc(font+file_size) - 1];
width = DSBYTE[calc(font+file_size) - 2];
block = math.ceil(height*width/32);
for (i=0; i<256; i++) {
kfont_char_width[i] = symbol_size((byte) i);
}
return true;
}
 
:dword LABEL::getsize(byte fontSizePoints, dword text1)
:dword KFONT::getsize(byte fontSizePoints, dword text1)
{
size.height = size.width = 0;
size.offset_x = size.offset_y = -1;
if (size.pt != fontSizePoints) {
size.pt = fontSizePoints;
if(size.pt)if(!changeSIZE())return 0;
if(!changeSIZE())return 0;
}
WHILE(DSBYTE[text1])
{
size.width += symbol_size(DSBYTE[text1]);
115,8 → 123,20
return size.width;
}
 
:byte LABEL::symbol_size(byte s)
//WILL NOT WORK if requested fontSizePoints
//is differ from precalculated kfont_char_width[]
:int KFONT::get_label_width(dword _label)
{
int len=0;
while (ESBYTE[_label]) {
len += kfont_char_width[ ESBYTE[_label] ];
_label++;
}
return len;
}
 
:byte KFONT::symbol_size(byte s)
{
int chaw_width;
chaw_width = symbol(0,0, s, 0);
if(bold) chaw_width += math.ceil(size.pt/17);
123,7 → 143,7
return chaw_width;
}
 
:byte LABEL::symbol(signed x,y; byte s; dword image_raw)
:byte KFONT::symbol(signed x,y; byte s; dword image_raw)
{
dword xi,yi;
dword iii = 0;
190,7 → 210,7
=====================================================================================*/
 
inline fastcall dword b32(EAX) { return DSDWORD[EAX]; }
:void LABEL::ApplySmooth()
:void KFONT::ApplySmooth()
{
dword i,line_w,to,dark_background;
line_w = size.width * KFONT_BPP;
222,11 → 242,10
}
}
 
:void LABEL::WriteIntoBuffer(int x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1)
:void KFONT::WriteIntoBuffer(int x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1)
{
dword new_raw_size;
if(!text1)return;
if(size.pt)if(!changeSIZE())return;
if (size.pt != fontSizePoints) {
getsize(fontSizePoints, text1);
258,7 → 277,7
return;
}
 
:int LABEL::WriteIntoWindow(int x,y; dword _background, _color; byte fontSizePoints; dword text1)
:int KFONT::WriteIntoWindow(int x,y; dword _background, _color; byte fontSizePoints; dword text1)
{
if(!text1)return 0;
getsize(fontSizePoints, text1);
270,19 → 289,19
return size.offset_x + size.width;
}
 
:int LABEL::WriteIntoWindowCenter(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1)
:int KFONT::WriteIntoWindowCenter(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword text1)
{
getsize(fontSizePoints, text1);
return WriteIntoWindow(w-size.width/2+x-1,y, _background, _color, fontSizePoints, text1);
}
 
:void LABEL::ShowBuffer(dword _x, _y)
:void KFONT::ShowBuffer(dword _x, _y)
{
if (4==KFONT_BPP) PutPaletteImage(raw, size.width, size.height, _x, _y, 32, 0);
//if (1==KFONT_BPP) PutPaletteImage(raw, size.width, size.height, _x, _y, 8, #palette);
}
 
:void LABEL::ShowBufferPart(dword _x, _y, _w, _h, _buf_offset)
:void KFONT::ShowBufferPart(dword _x, _y, _w, _h, _buf_offset)
{
if (4==KFONT_BPP) PutPaletteImage(_buf_offset * KFONT_BPP + raw, _w, _h, _x, _y, 32, 0);
//if (1==KFONT_BPP) PutPaletteImage(_buf_offset * KFONT_BPP + raw, _w, _h, _x, _y, 8, #palette);
/programs/cmm/lib/strings.h
180,10 → 180,37
return 0;
}
 
:bool strequ(dword text1, text2) {
if (!strcmp(text1,text2)) return true; else return false;
/*
TODO: rewrite streq() using pure assembliy
 
inline fastcall void strcpy( EDI, ESI)
{
$cld
L2:
$lodsb
$stosb
$test al,al
$jnz L2
}
*/
 
inline fastcall streq(ESI, EDI)
{
loop()
{
if(DSBYTE[ESI]==DSBYTE[EDI])
{
if(DSBYTE[ESI]==0) return true;
}
else {
return false;
}
ESI++;
EDI++;
}
return true;
}
 
/*
signed int strncmp(dword s1, s2, signed n)
unsigned char _s1,_s2;