2012-11-15 23:03:43 +01:00
|
|
|
|
//CODED by Veliant, Leency 2008-2012. GNU GPL licence.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall dword strlen( EDI)
|
|
|
|
|
{
|
|
|
|
|
asm {
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
dec ecx
|
|
|
|
|
repne scasb
|
|
|
|
|
sub eax, 2
|
|
|
|
|
sub eax, ecx
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall copystr( ESI,EDI)
|
|
|
|
|
{
|
|
|
|
|
$cld
|
2012-12-15 15:11:03 +01:00
|
|
|
|
L1:
|
2012-11-15 23:03:43 +01:00
|
|
|
|
$lodsb
|
|
|
|
|
$stosb
|
|
|
|
|
$test al,al
|
2012-12-15 15:11:03 +01:00
|
|
|
|
$jnz L1
|
2012-11-15 23:03:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char buffer[11];
|
|
|
|
|
inline fastcall dword IntToStr( ESI)
|
|
|
|
|
{
|
|
|
|
|
$mov edi, #buffer
|
|
|
|
|
$mov ecx, 10
|
|
|
|
|
$test esi, esi
|
2012-12-15 15:11:03 +01:00
|
|
|
|
$jns F1
|
2012-11-15 23:03:43 +01:00
|
|
|
|
$mov al, '-'
|
|
|
|
|
$stosb
|
|
|
|
|
$neg esi
|
2012-12-15 15:11:03 +01:00
|
|
|
|
F1:
|
2012-11-15 23:03:43 +01:00
|
|
|
|
$mov eax, esi
|
|
|
|
|
$push -'0'
|
2012-12-15 15:11:03 +01:00
|
|
|
|
F2:
|
2012-11-15 23:03:43 +01:00
|
|
|
|
$xor edx, edx
|
|
|
|
|
$div ecx
|
|
|
|
|
$push edx
|
|
|
|
|
$test eax, eax
|
2012-12-15 15:11:03 +01:00
|
|
|
|
$jnz F2
|
|
|
|
|
F3:
|
2012-11-15 23:03:43 +01:00
|
|
|
|
$pop eax
|
|
|
|
|
$add al, '0'
|
|
|
|
|
$stosb
|
2012-12-15 15:11:03 +01:00
|
|
|
|
$jnz F3
|
2012-11-15 23:03:43 +01:00
|
|
|
|
$mov eax, #buffer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline fastcall dword StrToInt()
|
|
|
|
|
{
|
|
|
|
|
ESI=EDI=EAX;
|
|
|
|
|
IF(DSBYTE[ESI]=='-')ESI++;
|
|
|
|
|
EAX=0;
|
|
|
|
|
BH=AL;
|
|
|
|
|
do{
|
|
|
|
|
BL=DSBYTE[ESI]-'0';
|
|
|
|
|
EAX=EAX*10+EBX;
|
|
|
|
|
ESI++;
|
|
|
|
|
}while(DSBYTE[ESI]>0);
|
|
|
|
|
IF(DSBYTE[EDI]=='-') -EAX;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dword StrToCol(char* htmlcolor)
|
|
|
|
|
{
|
|
|
|
|
dword j, color=0;
|
|
|
|
|
char ch=0x00;
|
|
|
|
|
|
|
|
|
|
FOR (j=0; j<6; j++)
|
|
|
|
|
{
|
|
|
|
|
ch=ESBYTE[htmlcolor+j];
|
|
|
|
|
IF ((ch>='0') && (ch<='9')) ch -= '0';
|
|
|
|
|
IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
|
|
|
|
|
IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
|
|
|
|
|
color = color*0x10 + ch;
|
|
|
|
|
}
|
2012-11-16 22:56:04 +01:00
|
|
|
|
return color;
|
2012-11-15 23:03:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-16 17:51:04 +01:00
|
|
|
|
inline fastcall signed char strcmp(ESI, EDI)
|
2012-11-15 23:03:43 +01:00
|
|
|
|
{
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
IF (DSBYTE[ESI]<DSBYTE[EDI]) RETURN -1;
|
|
|
|
|
IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
|
|
|
|
|
IF (DSBYTE[ESI]=='\0') RETURN 0;
|
|
|
|
|
ESI++;
|
|
|
|
|
EDI++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-16 22:56:04 +01:00
|
|
|
|
inline fastcall signed int strchr(ESI,BL)
|
2012-11-15 23:03:43 +01:00
|
|
|
|
{
|
|
|
|
|
int jj=0, last=-1;
|
|
|
|
|
do{
|
|
|
|
|
jj++;
|
|
|
|
|
$lodsb
|
|
|
|
|
IF(AL==BL) last=jj;
|
|
|
|
|
} while(AL!=0);
|
|
|
|
|
return last;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall TitleCase( EDX)
|
|
|
|
|
{
|
|
|
|
|
AL=DSBYTE[EDX];
|
|
|
|
|
IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
|
|
|
|
|
IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32; //<2F>-<2D>
|
|
|
|
|
IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80; //<2F>-<2D>
|
|
|
|
|
do{
|
|
|
|
|
EDX++;
|
|
|
|
|
AL=DSBYTE[EDX];
|
|
|
|
|
IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;}
|
|
|
|
|
IF(AL>='<EFBFBD>')&&(AL<='<EFBFBD>')DSBYTE[EDX]=AL|0x20; //<2F>-<2D>
|
|
|
|
|
IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80; //<2F>-<2D>
|
|
|
|
|
}while(AL!=0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall strcpy( EDI, ESI)
|
|
|
|
|
{
|
|
|
|
|
$cld
|
2012-12-15 15:11:03 +01:00
|
|
|
|
L2:
|
2012-11-15 23:03:43 +01:00
|
|
|
|
$lodsb
|
|
|
|
|
$stosb
|
|
|
|
|
$test al,al
|
2012-12-15 15:11:03 +01:00
|
|
|
|
$jnz L2
|
2012-11-15 23:03:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall strcat( EDI, ESI)
|
|
|
|
|
{
|
|
|
|
|
asm {
|
|
|
|
|
mov ebx, edi
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
dec ecx
|
|
|
|
|
repne scasb
|
|
|
|
|
dec edi
|
|
|
|
|
mov edx, edi
|
|
|
|
|
mov edi, esi
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
dec ecx
|
|
|
|
|
repne scasb
|
|
|
|
|
xor ecx, 0ffffffffh
|
|
|
|
|
mov edi, edx
|
|
|
|
|
mov edx, ecx
|
|
|
|
|
mov eax, edi
|
|
|
|
|
shr ecx, 2
|
|
|
|
|
rep movsd
|
|
|
|
|
mov ecx, edx
|
|
|
|
|
and ecx, 3
|
|
|
|
|
rep movsb
|
|
|
|
|
mov eax, ebx
|
|
|
|
|
}
|
2013-02-28 14:52:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline fastcall void chrcat(ESI, BL)
|
|
|
|
|
{
|
|
|
|
|
EDI = strlen(ESI);
|
|
|
|
|
ESBYTE[ESI+EDI] = BL;
|
|
|
|
|
ESBYTE[ESI+EDI+1] = 0;
|
2012-11-15 23:03:43 +01:00
|
|
|
|
}
|