CMM: update libraries

New lib: lexer.h

git-svn-id: svn://kolibrios.org@5598 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2015-07-22 18:32:54 +00:00
parent f6a101596a
commit 4e9602a915
33 changed files with 738 additions and 320 deletions

View File

@ -95,7 +95,7 @@ void GetSystemDiscs()
strncpy(#disk_list[disc_num].Item, #sys_discs,l); strncpy(#disk_list[disc_num].Item, #sys_discs,l);
disc_num++; disc_num++;
} }
if (strncmp(#sys_discs, "/rd/1/",6)==0) if (!strncmp(#sys_discs, "/rd/1/",6))
{ {
if (isdir("/kolibrios")) if (isdir("/kolibrios"))
{ {

View File

@ -1,8 +1,5 @@
#define MEMSIZE 0x3E80 #define MEMSIZE 0x3E80
#include "..\lib\kolibri.h"
#include "..\lib\strings.h" #include "..\lib\strings.h"
#include "..\lib\mem.h"
#include "..\lib\file_system.h"
void main() void main()
{ {
@ -19,7 +16,7 @@ void main()
case evKey: case evKey:
key = GetKey(); key = GetKey();
IF (key==013){ //Enter if (key==013){ //Enter
WriteText(50,90,0x80,0xFF00FF,"Pressed Enter"); WriteText(50,90,0x80,0xFF00FF,"Pressed Enter");
} }
break; break;

View File

@ -1,8 +1,8 @@
#define MEMSIZE 0xFFFFF #define MEMSIZE 0xFFFFF
#include "..\lib\kolibri.h" #include "../lib/kolibri.h"
#include "..\lib\strings.h" #include "../lib/strings.h"
#include "..\lib\mem.h" #include "../lib/mem.h"
#include "..\lib\gui.h" #include "../lib/gui.h"
#ifndef AUTOBUILD #ifndef AUTOBUILD
#include "lang.h--" #include "lang.h--"

View File

@ -1,10 +1,10 @@
#define MEMSIZE 397113 #define MEMSIZE 397113
#include "..\lib\kolibri.h" #include "../lib/kolibri.h"
#include "..\lib\strings.h" #include "../lib/strings.h"
#include "..\lib\mem.h" #include "../lib/mem.h"
#include "..\lib\file_system.h" #include "../lib/file_system.h"
#include "..\lib\dll.h" #include "../lib/dll.h"
#include "..\lib\obj\truetype.h" #include "../lib/obj/truetype.h"
proc_info Form; proc_info Form;
dword font_data; dword font_data;

View File

@ -1,5 +1,4 @@
#define MEMSIZE 0x9000 #define MEMSIZE 0x9000
#include "..\lib\kolibri.h"
#include "..\lib\strings.h" #include "..\lib\strings.h"
#include "..\lib\mem.h" #include "..\lib\mem.h"
#include "..\lib\file_system.h" #include "..\lib\file_system.h"

View File

@ -1,3 +1,10 @@
#ifndef INCLUDE_CLIPBOARD_H
#define INCLUDE_CLIPBOARD_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
struct buffer_data struct buffer_data
{ {
dword size; dword size;
@ -49,4 +56,6 @@ dword Clipboard::ResetBlockingBuffer()
$mov eax, 54 $mov eax, 54
$mov ebx, 3 $mov ebx, 3
$int 0x40 $int 0x40
} }
#endif

View File

@ -1,4 +1,10 @@
//copyf - copy file or folder with content //copyf - copy file or folder with content
#ifndef INCLUDE_COPYF_H
#define INCLUDE_COPYF_H
#ifndef INCLUDE_FILESYSTEM_H
#include "../lib/file_system.h"
#endif
:int copyf(dword from1, in1) :int copyf(dword from1, in1)
{ {
@ -75,16 +81,12 @@
for (i=0; i<fcount; i++) for (i=0; i<fcount; i++)
{ {
filename = i*304+dirbuf+72; filename = i*304+dirbuf+72;
strcpy(#copy_from2, from2); sprintf(#copy_from2,"%s/%s",from2,filename);
chrcat(#copy_from2, '/'); sprintf(#copy_in2,"%s/%s",in2,filename);
strcat(#copy_from2, filename);
strcpy(#copy_in2, in2);
chrcat(#copy_in2, '/');
strcat(#copy_in2, filename);
if ( TestBit(ESDWORD[filename-40], 4) ) //isdir? if ( TestBit(ESDWORD[filename-40], 4) ) //isdir?
{ {
if ( (!strcmp(filename, ".")) || (!strcmp(filename, "..")) ) continue; if ( (!strncmp(filename, ".",1)) || (!strncmp(filename, "..",2)) ) continue;
CopyFolder(#copy_from2, #copy_in2); CopyFolder(#copy_from2, #copy_in2);
} }
else else
@ -145,15 +147,8 @@
{ {
char error[256]; char error[256];
N = fabs(N); N = fabs(N);
if (N<=33) if (N<=33) strcpy(#error, ERROR_TEXT[N]);
{ else sprintf(#error,"%d%s",N," - Unknown error number O_o");
strcpy(#error, ERROR_TEXT[N]);
}
else
{
strcpy(#error, itoa(N));
strcat(#error, " - Unknown error number O_o");
}
return #error; return #error;
} }
@ -161,4 +156,6 @@
{ {
if (path) debugln(path); if (path) debugln(path);
debugln(get_error(error_number)); debugln(get_error(error_number));
} }
#endif

View File

@ -1,4 +1,10 @@
// cursor file should be 32x32 in default MS Windows .cur format // cursor file should be 32x32 in default MS Windows .cur format
#ifndef INCLUDE_CURSOR_H
#define INCLUDE_CURSOR_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
struct CustomCursor struct CustomCursor
{ {
@ -43,3 +49,5 @@ void CustomCursor::Delete()
ECX = CursorPointer; ECX = CursorPointer;
$int 0x40 $int 0x40
} }
#endif

View File

@ -1,3 +1,6 @@
#ifndef INCLUDE_DLL_H
#define INCLUDE_DLL_H
char a_libdir[43] = "/sys/lib/\0"; char a_libdir[43] = "/sys/lib/\0";
:inline void error_init(dword text) :inline void error_init(dword text)
@ -65,7 +68,7 @@ asm {
add esi, 8 add esi, 8
jmp next_lib jmp next_lib
@exit: @exit:
xor eax, eax xor eax, eax
leave leave
ret 4 ret 4
@ -234,4 +237,7 @@ int load_dll2(dword dllname, import_table, byte need_init)
@exit01: @exit01:
return -1; return -1;
//error_init(dllname); //error_init(dllname);
} }
#endif

View File

@ -1,3 +1,9 @@
#ifndef INCLUDE_DRAW_BUF_H
#define INCLUDE_DRAW_BUF_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
dword buf_data; dword buf_data;
dword zbuf_data; dword zbuf_data;
@ -149,3 +155,5 @@ void DrawBufer::Show()
PutPaletteImage(zbuf_data+8, zbufw, zbufh, zbufx, zbufy, 32, 0); PutPaletteImage(zbuf_data+8, zbufw, zbufh, zbufx, zbufy, 32, 0);
} }
} }
#endif

View File

@ -1,26 +1,32 @@
#ifndef INCLUDE_ENCODING_H
#define INCLUDE_ENCODING_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
inline fastcall void wintodos( ESI) inline fastcall void wintodos( ESI)
{ {
while (BL=ESBYTE[ESI]) while (BL=ESBYTE[ESI])
{ {
IF (BL>=192) if (BL>=192)
{ {
IF (BL>=240) ESBYTE[ESI] = BL - 16; if (BL>=240) ESBYTE[ESI] = BL - 16;
ELSE ESBYTE[ESI] = BL - 64; else ESBYTE[ESI] = BL - 64;
} }
ELSE else
{ {
IF (BL==178) ESBYTE[ESI] = 73; //I if (BL==178) ESBYTE[ESI] = 73; //I
IF (BL==179) ESBYTE[ESI] = 105; //i if (BL==179) ESBYTE[ESI] = 105; //i
IF (BL==175) ESBYTE[ESI] = 244; //J if (BL==175) ESBYTE[ESI] = 244; //J
IF (BL==191) ESBYTE[ESI] = 245; //j if (BL==191) ESBYTE[ESI] = 245; //j
IF (BL==170) ESBYTE[ESI] = 242; //E if (BL==170) ESBYTE[ESI] = 242; //E
IF (BL==186) ESBYTE[ESI] = 243; //e if (BL==186) ESBYTE[ESI] = 243; //e
IF (BL==168) ESBYTE[ESI] = 240; //ð if (BL==168) ESBYTE[ESI] = 240; //ð
IF (BL==184) ESBYTE[ESI] = 'e'; //e if (BL==184) ESBYTE[ESI] = 'e'; //e
IF (BL==180) ESBYTE[ESI] = 254; //ã if (BL==180) ESBYTE[ESI] = 254; //ã
IF ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34; if ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34;
IF ((BL==150) || (BL==151)) ESBYTE[ESI] = 45; if ((BL==150) || (BL==151)) ESBYTE[ESI] = 45;
} }
ESI++; ESI++;
} }
@ -30,14 +36,14 @@ inline fastcall void wintodos( ESI)
byte mas[66] = "椥ä£å¨©ª«¬­®¯ïàáâ㦢ìë§èíéçꞀ<EFBFBD>„…”ƒ•ˆ‰ŠŒ<EFBFBD>Ž<EFBFBD>Ÿ<EFBFBD>“†œ˜<EFBFBD>™—š"; byte mas[66] = "椥ä£å¨©ª«¬­®¯ïàáâ㦢ìë§èíéçꞀ<EFBFBD>„…”ƒ•ˆ‰ŠŒ<EFBFBD>Ž<EFBFBD>Ÿ<EFBFBD>“†œ˜<EFBFBD>™—š";
inline fastcall void koitodos( EDI) inline fastcall void koitodos( EDI)
{ {
WHILE (BL=ESBYTE[EDI]) while (BL=ESBYTE[EDI])
{ {
IF (BL >= 0xC0) if (BL >= 0xC0)
{ {
BL -= 0xC0; BL -= 0xC0;
ESBYTE[EDI] = mas[BL]; ESBYTE[EDI] = mas[BL];
} }
//IF (ESBYTE[EDI]=='\244') ESBYTE[EDI]='i'; //if (ESBYTE[EDI]=='\244') ESBYTE[EDI]='i';
EDI++; EDI++;
} }
} }
@ -49,27 +55,27 @@ inline fastcall void utf8rutodos( ESI)
EDI=ESI; EDI=ESI;
while (BL=ESBYTE[ESI]) while (BL=ESBYTE[ESI])
{ {
IF (BL == 0xD0) || (BL == 0xD1) EDI--; if (BL == 0xD0) || (BL == 0xD1) EDI--;
else IF (BL == 0x81) && (ESBYTE[ESI-1]==0xD0) ESBYTE[EDI] = 0xF0; //ø else if (BL == 0x81) && (ESBYTE[ESI-1]==0xD0) ESBYTE[EDI] = 0xF0; //ø
else IF (BL == 0x91) && (ESBYTE[ESI-1]==0xD1) ESBYTE[EDI] = 0xF1; //ì else if (BL == 0x91) && (ESBYTE[ESI-1]==0xD1) ESBYTE[EDI] = 0xF1; //ì
//0xE2 0x80 - ñãðóïïèðîâàòü //0xE2 0x80 - ñãðóïïèðîâàòü
else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80) else if (BL == 0xE2) && (ESBYTE[ESI+1]==0x80)
SWITCH (ESBYTE[ESI+2]) switch (ESBYTE[ESI+2])
{ {
case 0x93: //long defis case 0x93: //long defis
CASE 0x94: case 0x94:
{ {
ESBYTE[EDI] = '-'; ESBYTE[EDI] = '-';
ESI+=2; ESI+=2;
BREAK; break;
} }
CASE 0xA2: //central point case 0xA2: //central point
{ {
ESBYTE[EDI] = '*'; ESBYTE[EDI] = '*';
ESI+=2; ESI+=2;
BREAK; break;
} }
CASE 0xA6: //ìíîãîòî÷èå case 0xA6: //ìíîãîòî÷èå
{ {
ESBYTE[EDI] = ESBYTE[EDI+1] = ESBYTE[EDI+2] = '.'; ESBYTE[EDI] = ESBYTE[EDI+1] = ESBYTE[EDI+2] = '.';
EDI+=2; EDI+=2;
@ -78,67 +84,67 @@ inline fastcall void utf8rutodos( ESI)
} }
} }
else IF (BL == 0xC2) //òàáëèöó ïåðåêîäèðîâîê? else if (BL == 0xC2) //òàáëèöó ïåðåêîäèðîâîê?
SWITCH(ESBYTE[ESI+1]) { switch(ESBYTE[ESI+1]) {
case 0xAB: //" case 0xAB: //"
CASE 0xBB: //" case 0xBB: //"
{ {
ESBYTE[EDI] = '\"'; ESBYTE[EDI] = '\"';
ESI++; ESI++;
BREAK; break;
} }
CASE 0xB7: // _ case 0xB7: // _
{ {
ESBYTE[EDI] = '_'; ESBYTE[EDI] = '_';
ESI++; ESI++;
BREAK; break;
} }
CASE 0xA0: // Alt+160 - íåðàçáèâàþùèé ïðîáåë case 0xA0: // Alt+160 - íåðàçáèâàþùèé ïðîáåë
{ {
ESBYTE[EDI] = ' '; ESBYTE[EDI] = ' ';
ESI++; ESI++;
BREAK; break;
} }
CASE 0xB0: // ãðàäóñ case 0xB0: // ãðàäóñ
{ {
ESBYTE[EDI] = '\29'; ESBYTE[EDI] = '\29';
ESI++; ESI++;
BREAK; break;
} }
CASE 0xA9: // (c) --- âûëåò Î_î case 0xA9: // (c) --- âûëåò Î_î
{ {
ESBYTE[EDI] = 'c'; ESBYTE[EDI] = 'c';
ESI++; ESI++;
BREAK; break;
} }
CASE 0xAE: // (r) case 0xAE: // (r)
{ {
ESBYTE[EDI] = 'r'; ESBYTE[EDI] = 'r';
ESI++; ESI++;
BREAK; break;
} }
} }
ELSE IF (BL >= 0x90) && (BL <= 0xAF) else if (BL >= 0x90) && (BL <= 0xAF)
{ {
BL -= 0x10; BL -= 0x10;
ESBYTE[EDI] = BL; ESBYTE[EDI] = BL;
} }
ELSE IF (BL >= 0x80) && (BL <= 0x8F) else if (BL >= 0x80) && (BL <= 0x8F)
{ {
BL += 0x60; BL += 0x60;
ESBYTE[EDI] = BL; ESBYTE[EDI] = BL;
} }
ELSE IF (BL >= 0xB0) && (BL <= 0xBF) else if (BL >= 0xB0) && (BL <= 0xBF)
{ {
BL -= 0x10; BL -= 0x10;
ESBYTE[EDI] = BL; ESBYTE[EDI] = BL;
} }
ELSE ESBYTE[EDI] = BL; else ESBYTE[EDI] = BL;
ESI++; ESI++;
EDI++; EDI++;
} }
WHILE (EDI<ESI) while (EDI<ESI)
{ {
ESBYTE[EDI] = ' '; ESBYTE[EDI] = ' ';
EDI++; EDI++;
@ -151,13 +157,13 @@ inline fastcall void utf8rutodos( ESI)
{ {
dword j=0, symbol=0; dword j=0, symbol=0;
char ch=0x00; char ch=0x00;
FOR (;j<2;j++) for (;j<2;j++)
{ {
ch=ESBYTE[htmlcolor+j]; ch=ESBYTE[htmlcolor+j];
IF (ch==0x0d) || (ch=='\9') RETURN 0; if (ch==0x0d) || (ch=='\9') RETURN 0;
IF ((ch>='0') && (ch<='9')) ch -= '0'; if ((ch>='0') && (ch<='9')) ch -= '0';
IF ((ch>='A') && (ch<='F')) ch -= 'A'-10; if ((ch>='A') && (ch<='F')) ch -= 'A'-10;
IF ((ch>='a') && (ch<='f')) ch -= 'a'-10; if ((ch>='a') && (ch<='f')) ch -= 'a'-10;
symbol = symbol*0x10 + ch; symbol = symbol*0x10 + ch;
} }
wintodos(#symbol); wintodos(#symbol);
@ -165,3 +171,4 @@ inline fastcall void utf8rutodos( ESI)
} }
#endif

View File

@ -1,3 +1,13 @@
#ifndef INCLUDE_FILESYSTEM_H
#define INCLUDE_FILESYSTEM_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_STRING_H
#include "../lib/strings.h"
#endif
:struct f70{ :struct f70{
dword func; dword func;
dword param1; dword param1;
@ -326,4 +336,5 @@ enum
strcat(#size, " Kb"); strcat(#size, " Kb");
return #size; return #size;
} }
#endif

View File

@ -1,4 +1,13 @@
//#include "strings.h" #ifndef INCLUDE_GUI_H
#define INCLUDE_GUI_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_STRING_H
#include "../lib/strings.h"
#endif
:void DrawRectangle(dword x,y,w,h,color1) :void DrawRectangle(dword x,y,w,h,color1)
{ {
@ -168,4 +177,6 @@
col = strength * DSBYTE[color_image] / 10; col = strength * DSBYTE[color_image] / 10;
DSBYTE[color_image] = col; DSBYTE[color_image] = col;
} }
} }
#endif

View File

@ -1,5 +1,5 @@
//CODED by Veliant, Leency, Nable. GNU GPL licence. //CODED by Veliant, Leency, Nable. GNU GPL licence.
#ifndef INCLUDE_KOLIBRI_H
#define INCLUDE_KOLIBRI_H #define INCLUDE_KOLIBRI_H
#startaddress 0 #startaddress 0
@ -877,4 +877,6 @@ void load_init_main()
__generator = GetStartTime(); __generator = GetStartTime();
//mem_Init(); //mem_Init();
main(); main();
} }
#endif

232
programs/cmm/lib/lexer.h Normal file
View File

@ -0,0 +1,232 @@
#ifndef INCLUDE_LEXER_H
#define INCLUDE_LEXER_H
#ifndef INCLUDE_STRING_H
#include "../lib/strings.h"
#endif
/** Splits text into tokens
* Author :Pavel Yakovlev
* Homepage:https://vk.com/pavelyakov39
*/
/** Example:
* lexer lex;
* lex.load("var a=123;");
* lex.next();
* lex.token; //TOKEN == 'var'
* lex.type ; //TYPE == LEX_VAR
*
* lex.next();
* lex.token; //TOKEN == 'a'
* lex.type ; //TYPE == LEX_VAR
*
* lex.next();
* lex.token; //TOKEN == '='
* lex.type ; //TYPE == LEX_IND
*
* lex.next();
* lex.token; //TOKEN == '123'
* lex.type ; //TYPE == LEX_DEC
*
* lex.next();
* lex.token; //TOKEN == ';'
* lex.type ; //TYPE == LEX_IND
*
* lex.next();
* lex.token; //TOKEN == ''
* lex.type ; //TYPE == LEX_END
*/
#define LEX_END 1
#define LEX_STR 2
#define LEX_DEC 3
#define LEX_VAR 4
#define LEX_FNC 5
#define LEX_IND 6
#define LEX_NUL 0
:char const_token_lexer[1024];
:struct lexer
{
byte cmd;
dword token,text;
byte type;
char quote;
signed count,length;
dword next(void);
dword back(void);
void load(dword _text);
void expected(dword _text);
};
:void expected(dword _text)
{
notify(_text);
ExitProcess();
}
:void lexer::load(dword _text)
{
text = _text;
}
:dword lexer::next(void)
{
char s;
dword pos,in;
pos = #const_token_lexer;
in = text;
NEXT_TOKEN:
length = 0;
loop()
{
s = DSBYTE[in];
if(s!=9)&&(s!=10)&&(s!=13)&&(s!=32)break;
in++;
text++;
}
if(s==0){type=LEX_END;DSBYTE[pos]=0;token="";return token;}
if(s=='/')
{
in++;
s = DSBYTE[in];
// Line comments
if(s=='/')
{
loop()
{
in++;
s = DSBYTE[in];
if(s==10)||(s==13)||(s==0)goto NEXT_TOKEN;
/* Add comments*/
}
}
if(s=='*')
{
loop()
{
in++;
s = DSBYTE[in];
if(s=='*')if(DSBYTE[in+1]=='/')
{
in+=2;
goto NEXT_TOKEN;
}
}
}
}
if (strchr("=<>!~&|#",s))
{
loop()
{
if (!strchr("=<>!~&|#",s)) break;
DSBYTE[pos] = s;
pos++;
in++;
s = DSBYTE[in];
}
type = LEX_IND;
}
else if (strchr(";(,)}{[]+-.*/:^%?$@№`",s))
{
DSBYTE[pos] = s;
pos++;
type = LEX_IND;
in++;
}
else if(s>='0')&&(s<='9')
{
loop()
{
if(s<'0')||(s>'9')if(s!='.')break;
DSBYTE[pos] = s;
pos++;
in++;
s = DSBYTE[in];
}
type = LEX_DEC;
}
else if(s>='A')&&(s<='z')&&(!strchr("[]\\^`",s))
{
loop()
{
if(s<'A')||(s>'z')if(s<'0')||(s>'9')break;
if(strchr("[]\\^`",s))break;
DSBYTE[pos] = s;
pos++;
in++;
s = DSBYTE[in];
}
loop()
{
s = DSBYTE[in];
if(s!=9)if(s!=10)if(s!=13)if(s!=32)break;
in++;
text++;
}
type = LEX_VAR;
if(s=='(')type = LEX_FNC;
}
else if(s=='"')||(s=='\'')
{
quote = s;
in++;
s = DSBYTE[in];
loop()
{
if(s=='\\')
{
in++;
s = DSBYTE[in];
if(!s){type = LEX_STR;goto GOTO_LEX_END;}
if(!cmd)switch(s)
{
case 'n':s='\n';break;
case 'r':s='\r';break;
case 't':s='\t';break;
}
else {
DSBYTE[pos] = '\\';
pos++;
}
goto LEX_STEP_1;
}
if(!s){type = LEX_STR;goto GOTO_LEX_END;}
else if(s==quote)break;
LEX_STEP_1:
DSBYTE[pos] = s;
pos++;
in++;
s = DSBYTE[in];
}
in++;
type = LEX_STR;
}
else {
in++;
type = LEX_NUL;
DSBYTE[pos] = s;
pos++;
}
GOTO_LEX_END:
length = in-text;
text = in;
DSBYTE[pos] = 0;
token = #const_token_lexer;
return token;
}
#endif

View File

@ -1,4 +1,10 @@
//list_box //list_box
#ifndef INCLUDE_LIST_BOX_H
#define INCLUDE_LIST_BOX_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
struct llist struct llist
{ {
@ -150,4 +156,6 @@ int llist::KeyEnd()
current=count-1; current=count-1;
first=count-visible; first=count-visible;
return 1; return 1;
} }
#endif

View File

@ -1,7 +1,9 @@
#ifndef INCLUDE_MEM_H
#define INCLUDE_MEM_H
dword mem_init() dword mem_init()
{ {
$push ebx $push ebx
$mov eax, 68 $mov eax, 68
$mov ebx, 11 $mov ebx, 11
$int 0x40 $int 0x40
@ -96,99 +98,4 @@ L2:
#define mem_Free free #define mem_Free free
#define mem_Init mem_init #define mem_Init mem_init
/*:void fastcall memsetz( EDI, ECX) #endif
{
asm {
XOR EAX, EAX
MOV EDX, ECX
SHR ECX, 2
REP STOSD
MOV ECX, EDX
AND ECX, 3
REP STOSB
}
}
:void fastcall memset( EDI, ECX, AL) //copy AL to EDI of ECX num (void *dest, size_t, char c )
{
asm {
MOV AH, AL
MOVZX EDX, AX
SHL EAX, 16
OR EAX, EDX
MOV EDX, ECX
SHR ECX, 2
REP STOSD
MOV ECX, EDX
AND ECX, 3
REP STOSB
}
}
:void fastcall memsetd( EDI, ECX, EAX)
{
asm {
REP STOSD
}
}
:void fastcall memcpyd( EDI, ESI, ECX)
{
asm {
REP MOVSD
}
}
:void fastcall memmov( EDI, ESI, ECX)
{
asm {
MOV EAX, ECX
CMP EDI, ESI
JG L1
JE L2
SAR ECX, 2
JS L2
REP MOVSD
MOV ECX, EAX
AND ECX, 3
REP MOVSB
JMP SHORT L2
L1: LEA ESI, DSDWORD[ ESI+ECX-4]
LEA EDI, DSDWORD[ EDI+ECX-4]
SAR ECX, 2
JS L2
STD
REP MOVSD
MOV ECX, EAX
AND ECX, 3
ADD ESI, 3
ADD EDI, 3
REP MOVSB
CLD
L2:
}
}
:long fastcall memcmp( ESI, EDI, ECX)
{
asm {
MOV EAX, ECX
SHR ECX, 2
REPE CMPSD
MOV ECX, EAX
AND ECX, 3
REPE CMPSB
XOR EAX, EAX
XOR ECX, ECX
MOV AL, DSBYTE[ ESI-1]
MOV CL, DSBYTE[ EDI-1]
SUB EAX, ECX
}
}*/
/*#define memzset memsetz
#define memset0 memsetz
#define mem0set memsetz
#define memset32 memsetd
#define memcpy32 memcpyd*/

View File

@ -1,4 +1,15 @@
//BOX_LIB - Asper //BOX_LIB - Asper
#ifndef INCLUDE_BOX_LIB_H
#define INCLUDE_BOX_LIB_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword boxlib = #aEdit_box_lib; dword boxlib = #aEdit_box_lib;
char aEdit_box_lib[]="/sys/lib/box_lib.obj"; char aEdit_box_lib[]="/sys/lib/box_lib.obj";
@ -169,4 +180,6 @@ struct frame
dword font_size_y; dword font_size_y;
dword font_color; dword font_color;
dword font_backgr_color; dword font_backgr_color;
}; };
#endif

View File

@ -1,4 +1,14 @@
//HTTP library //HTTP library
#ifndef INCLUDE_LIBHTTP_H
#define INCLUDE_LIBHTTP_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword libHTTP = #alibHTTP; dword libHTTP = #alibHTTP;
char alibHTTP[23] = "/sys/lib/http.obj\0"; char alibHTTP[23] = "/sys/lib/http.obj\0";
@ -65,4 +75,6 @@ struct http_msg{
:dword file_get_contents(dword url,...) :dword file_get_contents(dword url,...)
{ {
http_get(url,FLAG_HTTP11,""); http_get(url,FLAG_HTTP11,"");
} }
#endif

View File

@ -1,4 +1,14 @@
//convert text characters //convert text characters
#ifndef INCLUDE_LIBICONV_H
#define INCLUDE_LIBICONV_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword iconv_lib = #a_iconv_lib; dword iconv_lib = #a_iconv_lib;
char a_iconv_lib[19]="/sys/lib/iconv.obj\0"; char a_iconv_lib[19]="/sys/lib/iconv.obj\0";
@ -56,4 +66,6 @@ enum {
CH_CP1252, CH_CP1252,
CH_ISO8859_5, CH_ISO8859_5,
CH_CP866 CH_CP866
}; };
#endif

View File

@ -1,4 +1,24 @@
//Asper //Asper
#ifndef INCLUDE_LIBIMG_H
#define INCLUDE_LIBIMG_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_MEM_H
#include "../lib/mem.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
#ifndef INCLUDE_LIBIO_H
#include "../lib/obj/libio_lib.h"
#endif
:byte init_imglib_check;
//library //library
dword libimg = #alibimg; dword libimg = #alibimg;
@ -100,3 +120,5 @@ dword load_image(dword filename)
$stc $stc
return 0; return 0;
} }
#endif

View File

@ -1,3 +1,14 @@
#ifndef INCLUDE_LIBINI_H
#define INCLUDE_LIBINI_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword libini = #alibini; dword libini = #alibini;
char alibini[] = "/sys/lib/libini.obj"; char alibini[] = "/sys/lib/libini.obj";
@ -23,3 +34,5 @@ char aini_set_int[] = "ini_set_int";
//char aini_get_shortcut[] = "ini_get_shortcut"; //char aini_get_shortcut[] = "ini_get_shortcut";
char aini_get_color[] = "ini_get_color"; char aini_get_color[] = "ini_get_color";
//char aini_set_color[] = "ini_set_color"; //char aini_set_color[] = "ini_set_color";
#endif

View File

@ -1,4 +1,14 @@
//Asper //Asper
#ifndef INCLUDE_LIBIO_H
#define INCLUDE_LIBIO_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
//library //library
dword libio = #alibio; dword libio = #alibio;
@ -32,3 +42,5 @@ char afile_close[12] = "file_close\0";
#define SEEK_SET 0 #define SEEK_SET 0
#define SEEK_CUR 1 #define SEEK_CUR 1
#define SEEK_END 2 #define SEEK_END 2
#endif

View File

@ -1,5 +1,14 @@
//Network library //Network library
#ifndef INCLUDE_NETCODE_H
#define INCLUDE_NETCODE_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword netcode_lib = #a_netcode_lib; dword netcode_lib = #a_netcode_lib;
char a_netcode_lib[21]="/sys/lib/netcode.obj\0"; char a_netcode_lib[21]="/sys/lib/netcode.obj\0";
@ -16,4 +25,6 @@ char aQp_decode[10] = "qp_decode\0";
Кодирование массива inp длиной len в массив outp (строку с '\0'). Функция возвращает длину outp. Кодирование массива inp длиной len в массив outp (строку с '\0'). Функция возвращает длину outp.
int base64_decode(char inp[], char outp[], int len); int base64_decode(char inp[], char outp[], int len);
Декодирование массива inp длиной len в массив outp (строку с '\0'). Функция возвращает длину outp.*/ Декодирование массива inp длиной len в массив outp (строку с '\0'). Функция возвращает длину outp.*/
#endif

View File

@ -1,5 +1,14 @@
//Network library //Network library
#ifndef INCLUDE_NETWORK_H
#define INCLUDE_NETWORK_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword network_lib = #a_network_lib; dword network_lib = #a_network_lib;
char a_network_lib[21]="/sys/lib/network.obj\0"; char a_network_lib[21]="/sys/lib/network.obj\0";
@ -61,3 +70,5 @@ struct addrinfo {
struct addrinfo *ai_next; struct addrinfo *ai_next;
}; };
*/ */
#endif

View File

@ -1,3 +1,13 @@
#ifndef INCLUDE_PROCLIB_H
#define INCLUDE_PROCLIB_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword Proc_lib = #aProc_lib; dword Proc_lib = #aProc_lib;
char aProc_lib[] = "/sys/lib/proc_lib.obj"; char aProc_lib[] = "/sys/lib/proc_lib.obj";
@ -31,3 +41,4 @@ struct opendialog
word y_start; word y_start;
}; };
#endif

View File

@ -1,5 +1,14 @@
// Truetype library // Truetype library
#ifndef INCLUDE_LIBTRUETYPE_H
#define INCLUDE_LIBTRUETYPE_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword libtruetype = #att_libtruetype; dword libtruetype = #att_libtruetype;
char att_libtruetype[22] = "/sys/lib/truetype.obj\0"; char att_libtruetype[22] = "/sys/lib/truetype.obj\0";
@ -35,3 +44,5 @@ struct stbtt_fontinfo
int index_map; // a cmap mapping for our chosen character encoding int index_map; // a cmap mapping for our chosen character encoding
int indexToLocFormat; // format needed to map from glyph index to glyph int indexToLocFormat; // format needed to map from glyph index to glyph
}; };
#endif

View File

@ -1,3 +1,13 @@
#ifndef INCLUDE_LIBXML_H
#define INCLUDE_LIBXML_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword XML = #aXML_lib; dword XML = #aXML_lib;
char aXML_lib[] = "/sys/lib/xml.obj"; char aXML_lib[] = "/sys/lib/xml.obj";
@ -123,4 +133,6 @@ struct AXParseContext
dword strict; // (int) dword strict; // (int)
dword reserved1; // (int) dword reserved1; // (int)
AXElement reserved2; // (AXElement) AXElement reserved2; // (AXElement)
}; };
#endif

View File

@ -1,3 +1,10 @@
#ifndef INCLUDE_LIBIMG_LOAD_SKIN_H
#define INCLUDE_LIBIMG_LOAD_SKIN_H
#ifndef INCLUDE_LIBIMG_H
#include "../lib/obj/libimg_lib.h"
#endif
struct libimg_image { struct libimg_image {
dword image, w, h; dword image, w, h;
}; };
@ -18,4 +25,6 @@ struct libimg_image {
image_data = ESDWORD[struct_pointer + 24]; image_data = ESDWORD[struct_pointer + 24];
max_i = w * h * 4 + image_data; max_i = w * h * 4 + image_data;
for (i = image_data; i < max_i; i += 4) if (DSDWORD[i]==0) DSDWORD[i] = new_transparent_color; for (i = image_data; i < max_i; i += 4) if (DSDWORD[i]==0) DSDWORD[i] = new_transparent_color;
} }
#endif

View File

@ -1,3 +1,10 @@
#ifndef INCLUDE_RESTART_PROCESS_H
#define INCLUDE_RESTART_PROCESS_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
enum { enum {
MULTIPLE, MULTIPLE,
SINGLE SINGLE
@ -16,4 +23,6 @@ void RestartProcessByName(dword proc_name, byte multiple) {
} }
} }
RunProgram(proc_name, ""); RunProgram(proc_name, "");
} }
#endif

View File

@ -1,23 +1,10 @@
/******************************************************************************* #ifndef INCLUDE_RANDOM_H
#define INCLUDE_RANDOM_H
MenuetOS MineSweeper #ifndef INCLUDE_KOLIBRI_H
Copyright (C) 2003 Ivan Poddubny #include "../lib/kolibri.h"
#endif
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
#define MASK_RAND 123456789 #define MASK_RAND 123456789
#define IQ_RAND 12773 #define IQ_RAND 12773
#define IA_RAND 16807 #define IA_RAND 16807
@ -93,3 +80,4 @@ inline fastcall randomize()
__generator = EAX; __generator = EAX;
} }
#endif

View File

@ -1,96 +1,106 @@
#define SOCK_STREAM 1 #ifndef INCLUDE_SOCKET_H
#define SOCK_DGRAM 2 #define INCLUDE_SOCKET_H
#define AF_INET4 2 #ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#define MSG_PEEK 0x02 #endif
#define MSG_DONTWAIT 0x40
#define SOCK_STREAM 1
dword errorcode; #define SOCK_DGRAM 2
struct sockaddr_in{ #define AF_INET4 2
word sin_family;
word sin_port; #define MSG_PEEK 0x02
dword sin_addr; #define MSG_DONTWAIT 0x40
char padding[8];
}; dword errorcode;
inline fastcall dword Socket(ECX, EDX, ESI) struct sockaddr_in
{ {
$push ebx word sin_family;
$mov eax, 75 word sin_port;
$mov ebx, 0 dword sin_addr;
$int 0x40 char padding[8];
errorcode = EBX; };
$pop ebx
} inline fastcall dword Socket(ECX, EDX, ESI)
{
inline fastcall dword Close(ECX) $push ebx
{ $mov eax, 75
$push ebx $mov ebx, 0
$mov eax, 75 $int 0x40
$mov ebx, 1 errorcode = EBX;
$int 0x40 $pop ebx
errorcode = EBX; }
$pop ebx
} inline fastcall dword Close(ECX)
{
inline fastcall dword Bind(ECX, EDX, ESI) $push ebx
{ $mov eax, 75
$push ebx $mov ebx, 1
$mov eax, 75 $int 0x40
$mov ebx, 2 errorcode = EBX;
$int 0x40 $pop ebx
errorcode = EBX; }
$pop ebx
} inline fastcall dword Bind(ECX, EDX, ESI)
{
inline fastcall dword Listen(ECX, EDX) $push ebx
{ $mov eax, 75
$push ebx $mov ebx, 2
$mov eax, 75 $int 0x40
$mov ebx, 3 errorcode = EBX;
$int 0x40 $pop ebx
errorcode = EBX; }
$pop ebx
} inline fastcall dword Listen(ECX, EDX)
{
inline fastcall dword Connect(ECX, EDX, ESI) $push ebx
{ $mov eax, 75
$push ebx $mov ebx, 3
$mov eax, 75 $int 0x40
$mov ebx, 4 errorcode = EBX;
$int 0x40 $pop ebx
errorcode = EBX; }
$pop ebx
} inline fastcall dword Connect(ECX, EDX, ESI)
{
inline fastcall dword Accept(ECX, EDX, ESI) $push ebx
{ $mov eax, 75
$push ebx $mov ebx, 4
$mov eax, 75 $int 0x40
$mov ebx, 5 errorcode = EBX;
$int 0x40 $pop ebx
errorcode = EBX; }
$pop ebx
} inline fastcall dword Accept(ECX, EDX, ESI)
{
inline fastcall dword Send(ECX, EDX, ESI, EDI) $push ebx
{ $mov eax, 75
$push ebx $mov ebx, 5
$mov eax, 75 $int 0x40
$mov ebx, 6 errorcode = EBX;
$int 0x40 $pop ebx
errorcode = EBX; }
$pop ebx
} inline fastcall dword Send(ECX, EDX, ESI, EDI)
{
inline fastcall dword Receive(ECX, EDX, ESI, EDI) $push ebx
{ $mov eax, 75
$push ebx $mov ebx, 6
$mov eax, 75 $int 0x40
$mov ebx, 7 errorcode = EBX;
$int 0x40 $pop ebx
errorcode = EBX; }
$pop ebx
} inline fastcall dword Receive(ECX, EDX, ESI, EDI)
{
$push ebx
$mov eax, 75
$mov ebx, 7
$int 0x40
errorcode = EBX;
$pop ebx
}
#endif

View File

@ -1,3 +1,14 @@
#ifndef INCLUDE_STRING_H
#define INCLUDE_STRING_H
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_MEM_H
#include "../lib/mem.h"
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// strspn(dword text1,text2) --- example: strspn("12 year","1234567890") -> return 2 // strspn(dword text1,text2) --- example: strspn("12 year","1234567890") -> return 2
// strpbrk(dword text1,text2) --- example: strpbrk("this test", " ckfi") -> return "is test" // strpbrk(dword text1,text2) --- example: strpbrk("this test", " ckfi") -> return "is test"
@ -39,6 +50,8 @@ inline fastcall signed int strcmp( ESI, EDI)
} }
*/ */
inline int strspn(dword text1,text2) inline int strspn(dword text1,text2)
{ {
dword beg; dword beg;
@ -376,7 +389,7 @@ inline fastcall void chrcat(ESI, BL)
} }
inline fastcall signed int strchr( ESI,BL) /*inline fastcall signed int strchr( ESI,BL)
{ {
int jj=0; int jj=0;
do{ do{
@ -385,8 +398,19 @@ inline fastcall signed int strchr( ESI,BL)
IF(AL==BL) return jj; IF(AL==BL) return jj;
} while(AL!=0); } while(AL!=0);
return 0; return 0;
} }*/
inline dword strchr(dword shb;char s)
{
char ss;
loop()
{
ss = DSBYTE[shb];
if(!ss)return 0;
if(ss==s)return shb;
shb++;
}
}
inline fastcall signed int strrchr( ESI,BL) inline fastcall signed int strrchr( ESI,BL)
{ {
@ -732,28 +756,50 @@ inline dword hexdec(dword text)
{ {
char s; char s;
dword ret,l; dword ret,l;
//l = strlen(text);
ret = 0; ret = 0;
s = DSBYTE[text]; s = DSBYTE[text];
//if(l==6)
while(s) while(s)
{ {
ret <<= 4; ret <<= 4;
if(s>='A')&&(s<='F')ret |= s-'A'+10; if(s>='A')&&(s<='F')ret |= s-'A'+10;
else if(s>='a')&&(s<='f')ret |= s-'a'+10; else if(s>='a')&&(s<='f')ret |= s-'a'+10;
else if(s>='0')&&(s<='9')ret |= s-'a'+10; else if(s>='0')&&(s<='9')ret |= s-'0';
text++; text++;
s = DSBYTE[text]; s = DSBYTE[text];
} }
/*else if(l==3) while(s) return ret;
}
inline signed csshexdec(dword text)
{
char s;
dword ret,l;
byte tmp;
l = strlen(text);
ret = 0;
s = DSBYTE[text];
tmp = 0;
if(l==6) while(s)
{ {
ret <<= 4; ret <<= 4;
if(s>='A')&&(s<='F')ret |= s-'A'+10; if(s>='A')&&(s<='F')ret |= s-'A'+10;
else if(s>='a')&&(s<='f')ret |= s-'a'+10; else if(s>='a')&&(s<='f')ret |= s-'a'+10;
else if(s>='0')&&(s<='9')ret |= s-'a'+10; else if(s>='0')&&(s<='9')ret |= s-'0';
text++; text++;
s = DSBYTE[text]; s = DSBYTE[text];
}*/ }
else if(l==3) while(s)
{
ret |= tmp;
ret <<= 4;
ret |= tmp;
ret <<= 4;
if(s>='A')&&(s<='F')tmp = s-'A'+10;
else if(s>='a')&&(s<='f')tmp = s-'a'+10;
else if(s>='0')&&(s<='9')tmp = s-'0';
text++;
s = DSBYTE[text];
}
return ret; return ret;
} }
@ -841,6 +887,19 @@ inline cdecl int sprintf(dword buf, format,...)
return buf-ret; return buf-ret;
} }
inline signed strcoll(dword text1,text2)
{
char s,ss;
loop()
{
s = DSBYTE[text2];
ss=strchr(text1,s);
if(ss)return ss;
text2++;
}
return 0;
}
inline void debugi(dword d_int) inline void debugi(dword d_int)
{ {
char tmpch[12]; char tmpch[12];
@ -854,3 +913,4 @@ inline void debugi(dword d_int)
#define stricmp strcmpi #define stricmp strcmpi
#define strcmpn strncmp #define strcmpn strncmp
#endif