Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5575 → Rev 5576

/programs/cmm/lib/dll.h
1,5 → 1,25
char a_libdir[43] = "/sys/lib/\0";
 
:inline void error_init(dword text)
{
dword l,ll;
dword TEXT_ERROR = malloc(1024);
#ifdef LANG_RUS
strcpy(TEXT_ERROR,"'Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ `");
#elif LANG_EST
strcpy(TEXT_ERROR,"'Viga teegi laadimisel `");
#else
strcpy(TEXT_ERROR,"'Error while loading library `");
#endif
ll = strlen(TEXT_ERROR);
strcpy(TEXT_ERROR+ll,text);
l = strlen(text);
strncpy(TEXT_ERROR+ll+l,"`' -E",4);
notify(TEXT_ERROR);
free(TEXT_ERROR);
ExitProcess();
}
 
// stdcall with 1 parameter
void dll_Load() {
asm {
213,4 → 233,5
return 0;
@exit01:
return -1;
//error_init(dllname);
}
/programs/cmm/lib/file_system.h
31,8 → 31,9
};
 
 
:void DrawDate(dword x, y, color, dword in_date)
:void DrawDate(dword x, y, color, in_date)
{
//char text[10];
EDI = in_date;
EAX = 47;
EBX = 2<<16;
47,6 → 48,9
EBX = 4<<16;
ECX = EDI.date.year;
$int 0x40;
//sprintf(#text,"%d.%d.%d",EDI.date.day,EDI.date.month,EDI.date.year);
//WriteText(x, y, 0x80, 0x80<<24+color, #text);
}
 
 
297,9 → 301,9
return #absolute_path;
}
 
:dword ConvertSize(unsigned int bytes)
:dword ConvertSize(dword bytes)
{
unsigned char size_prefix[8], size_nm[4];
byte size_prefix[8], size_nm[4];
if (bytes>=1073741824) strcpy(#size_nm, " Gb");
else if (bytes>=1048576) strcpy(#size_nm, " Mb");
else if (bytes>=1024) strcpy(#size_nm, " Kb");
307,6 → 311,7
while (bytes>1023) bytes/=1024;
itoa_(#size_prefix, bytes);
strcat(#size_prefix, #size_nm);
//sprintf(#size_prefix,"%s","123");
return #size_prefix;
}
 
/programs/cmm/lib/kolibri.h
1,5 → 1,7
//CODED by Veliant, Leency, Nable. GNU GPL licence.
 
#define LIB_KOLIBRI_H
 
#startaddress 0
#code32 TRUE
 
23,10 → 25,12
#define evReDraw 1
#define evKey 2
#define evButton 3
#define evDesktop 5
#define evMouse 6
#define evIPC 7
#define evNetwork 8
#define evDebug 9
 
 
//Button options
#define BT_DEL 0x80000000
#define BT_HIDE 0x40000000
35,6 → 39,7
//Button mouse
#define MOUSE_LEFT 001b
#define MOUSE_RIGHT 010b
#define MOUSE_LR 011b
#define MOUSE_CENTER 100b
 
//ASCII KEYS
55,7 → 60,18
#define ASCII_KEY_PGDN 183
#define ASCII_KEY_PGUP 184
 
//allow event mask
#define EVENT_MASK_REDRAW 000000001b
#define EVENT_MASK_KEYBOARD 000000010b
#define EVENT_MASK_BUTTONS 000000100b
#define EVENT_MASK_DESKTOP 000010000b
#define EVENT_MASK_MOUSE 000100000b
#define EVENT_MASK_IPC 001000000b
#define EVENT_MASK_NETWORK 010000000b
#define EVENT_MASK_DEBUG 100000000b
 
//ARGS FUNCTION
#define END_ARGS 0xFF00FF
//-------------------------------------------------------------------------
 
:struct raw_image {
82,10 → 98,82
dword __TMP_TIME,MOUSE_TIME;
:struct mouse
{
signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick;
signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick,left,top;
dword handle,_;
byte cmd;
void clearTime();
void get();
void set();
void center();
dword hide();
void slider();
void show();
};
:void mouse::clearTime()
{
tmp_time = GetStartTime()+MOUSE_TIME;
}
:void mouse::show()
{
if(!handle)return;
ECX = handle;
EAX = 37;
EBX = 5;
$int 0x40;
}
:dword mouse::hide()
{
if(!_)
{
EAX = 68;
EBX = 12;
ECX = 32*32*4;
$int 0x40
ECX = EAX;
_ = EAX;
} else ECX = _;
EAX = 37;
EBX = 4;
DX = 2;
$int 0x40;
handle = EAX;
ECX = EAX;
EAX = 37;
EBX = 5;
$int 0x40;
handle = EAX;
}
 
//set new attributes mouse
:void mouse::set()
{
if((xx!=x)||(yy!=y))
{
EAX = 18;
EBX = 19;
ECX = 4;
EDX = (x<<16)+y;
$int 0x40
//move = true;
}
if((key)||(lkm|mkm|pkm))&&(down|up|click|dblclick|move)
{
if(lkm|mkm|pkm)key=(lkm)|(pkm<<1)|(2<<mkm);
EAX = 18;
EBX = 19;
ECX = key;
EDX = (x<<16)+y;
$int 0x40
}
}
 
:void mouse::center()
{
EAX = 18;
EBX = 15;
$int 0x40
}
 
//get new attributes mouse
:void mouse::get()
{
115,12 → 203,14
mkm = ECX;
//when you release the mouse button
if((down)&&!(key)){
// Mouse Up Event
if((cmd)&&!(key)){
up = true;
down = false;
if(!move) click = true;
move = false;
__TMP_TIME = GetStartTime();
if(__TMP_TIME-tmp_time<=MOUSE_TIME) dblclick = true;
if(__TMP_TIME-tmp_time<=MOUSE_TIME){ dblclick = true;click = false; }
tmp_time = __TMP_TIME;
//returns the key code
key = tmp;
129,25 → 219,25
pkm >>= 1;
mkm = 4&tmp;
mkm >>= 2;
cmd = false;
}
//when you press the mouse button
// Mouse Down Event/Move Event
else {
up = false;
click = false;
dblclick = false;
if(key)
down = false;
// Mouse Move Event
if((xx!=x)||(yy!=y))
{
down = true;
tmp = key;
}
else down = false;
if((xx!=x)||(yy!=y)){
move = true;
xx = x;
yy = y;
}
else move = false;
if(key)if(!cmd) {down = true;cmd = true;tmp=key;}
}
//scroll
161,7 → 251,34
vert = EBX;
}
 
:void mouse::slider()
{
signed _x,_y;
if(!handle)hide();
get();
_x = x;_y = y;
pause(5);
get();
left = _x - x;
top = _y - y;
center();
get();
_x = x;_y = y;
pause(5);
}
 
:struct keyboard
{
signed key;
byte down,up,press;
void get(void);
};
 
:void keyboard::get(void)
{
}
 
:struct system_colors
{
dword frame,grab,grab_button,grab_button_text,grab_text,
179,11 → 296,12
}
 
//------------------------------------------------------------------------------
 
dword wait_event_code;
inline fastcall dword WaitEvent()
{
$mov eax,10
$int 0x40
wait_event_code = EAX;
}
 
inline fastcall dword CheckEvent()
522,9 → 640,10
EBX = 1;
$int 0x40
EAX = 0;
$xor EAX,EAX
EBX = x << 16 + size_w;
ECX = y << 16 + size_h;
 
EDX = WindowType << 24 | WindowAreaColor;
$int 0x40
 
664,12 → 783,40
$int 0x40
}
 
:dword ALERT_TEXT;
:void dialog_alert()
{
byte id;
loop()switch(WaitEvent())
{
case evReDraw:
DefineAndDrawWindow(215,100,250,200,0x34,0xFFFFFF,"Alert");
WriteTextB(5,5,0x90,0x0,ALERT_TEXT);
break;
case evButton:
id=GetButtonID();
if (id==1) ExitProcess();
break;
}
}
 
:dword alert(dword text)
{
dword mem = malloc(4096);
ALERT_TEXT = text;
CreateThread(#dialog_alert,mem+4092);
return mem;
}
 
dword __generator; // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
 
dword program_path_length;
 
//The initialization of the initial data before running
void load_init_main()
{
MOUSE_TIME = 50; //Default 50 ms.
//program_path_length = strlen(program_path);
MOUSE_TIME = 50; //Default 500 ms.
__generator = GetStartTime();
main();
}
/programs/cmm/lib/obj/http.h
60,4 → 60,9
dword content_length;
dword content_received;
char http_header;
};
};
 
:dword file_get_contents(dword url,...)
{
http_get(url,FLAG_HTTP11,"");
}
/programs/cmm/lib/random.h
18,6 → 18,12
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
*******************************************************************************/
#define MASK_RAND 123456789
#define IQ_RAND 12773
#define IA_RAND 16807
#define IR_RAND 2836
#define IM_RAND 2147483647
#define AM_RAND (1./2147483647)
 
inline fastcall int random( ECX)
// get pseudo-random number - ïîëó÷èòü ïñåâäîñëó÷àéíîå ÷èñëî
40,6 → 46,40
$pop ebx
}
 
:inline long unirand0(void)
{
long k,ans,tmp,save;
save = __generator;
__generator^=MASK_RAND; /* avoid __generator==0 */
k=__generator/IQ_RAND;
tmp=__generator-k*IQ_RAND;
__generator*=IA_RAND*tmp;
__generator-=IR_RAND*k;
if(__generator<0) __generator+=IM_RAND;
if(save == __generator) return unirand0();
ans=__generator;
__generator^=MASK_RAND; /* restore unmasked dummy */
return ans;
}
 
:long RAND_A,RAND_C,RAND_TMP;
:inline long rand(signed long x1,x2)
{
long tmp,xx;
RAND_A = __generator;
__generator = RAND_A*__generator+RAND_C;
RAND_C = __generator^RAND_A;
RAND_C>>=1;
RAND_A<<=1;
__generator^=RAND_A;
xx=x2;
if(x1<0)xx+=-x1;
tmp = __generator%xx;
if(tmp<0)tmp=-tmp;
tmp+=x1;
return tmp;
}
 
inline fastcall randomize()
// initialize random number __generator - èíèöèàëèçèðîâàòü ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
{
49,6 → 89,7
int 0x40
ror eax,16
}
//if(EAX == __generator)return randomize();
__generator = EAX;
}
 
/programs/cmm/lib/strings.h
178,24 → 178,31
$jnz L2
}
 
inline dword strncpy(dword text1, text2, signed len)
:inline dword strncpy(dword text1, text2, signed len)
signed o1,o2;
{
if(!text1)||(!len) return text1;
if(len<4)
{
o2 = len;
goto RUN_BYTE;
}
o1 = len/4;
o2 = len-4*o1;
while(o1){
ESDWORD[text1] = ESDWORD[text2];
DSDWORD[text1] = DSDWORD[text2];
text1 += 4;
text2 += 4;
$dec o1
}
RUN_BYTE:
while(o2){
ESBYTE[text1] = ESBYTE[text2];
DSBYTE[text1] = DSBYTE[text2];
$inc text1
$inc text2
$dec o2
}
ESBYTE[text1] = 0;
DSBYTE[text1] = 0;
return text1;
}
 
339,25 → 346,26
signed o1,o2;
char s;
{
s = ESBYTE[text1];
s = DSBYTE[text1];
while(s){
$inc text1
s = ESBYTE[text1];
s = DSBYTE[text1];
}
o1 = len/4;
o2 = len-4*o1;
while(o1){
ESDWORD[text1] = ESDWORD[text2];
DSDWORD[text1] = DSDWORD[text2];
text1 += 4;
text2 += 4;
$dec o1
}
while(o2){
ESBYTE[text1] = ESBYTE[text2];
DSBYTE[text1] = DSBYTE[text2];
$inc text1
$inc text2
$dec o2
}
DSBYTE[text1] = 0;
}
 
inline fastcall void chrcat(ESI, BL)
614,22 → 622,23
inline dword itoa(signed long number)
{
unsigned char buf[11];
dword ret;
dword ret,p;
byte cmd;
long mask,tmp;
mask = 1000000000;
cmd = true;
p = #buf;
if(!number){
ESBYTE[buf] = '0';
ESBYTE[buf+1] = 0;
return buf;
ESBYTE[p] = '0';
ESBYTE[p+1] = 0;
return p;
}
ret = buf;
ret = p;
if(number<0)
{
$neg number
ESBYTE[buf] = '-';
$inc buf
ESBYTE[p] = '-';
$inc p
}
while(mask)
{
638,22 → 647,22
if(cmd){
if(tmp){
ESBYTE[buf] = tmp + '0';
$inc buf
ESBYTE[p] = tmp + '0';
$inc p
cmd = false;
}
}
else {
ESBYTE[buf] = tmp + '0';
$inc buf
ESBYTE[p] = tmp + '0';
$inc p
}
mask /= 10;
}
ESBYTE[buf] = 0;
ESBYTE[p] = 0;
return ret;
}
inline fastcall itoa_(signed int EDI, ESI)
:inline fastcall itoa_(signed int EDI, ESI)
{
$pusha
EBX = EDI;
686,15 → 695,27
return EBX;
}
 
inline dword strdup(dword text)
:inline dword memchr(dword s,int c,signed len)
{
if(!len) return NULL;
do {
if(DSBYTE[s] == c) return s;
$inc s
$dec len
} while(len);
return NULL;
}
 
:inline dword strdup(dword text)
{
dword l = strlen(text);
dword ret = malloc(l+1);
if(!ret) return NULL;
strncpy(ret,text,l);
return ret;
}
 
inline dword strndup(dword str, signed maxlen)
:inline dword strndup(dword str, signed maxlen)
{
dword copy,len;
 
702,12 → 723,96
copy = malloc(len + 1);
if (copy != NULL)
{
memcpy(copy, str, len);
strncpy(copy, str, len);
DSBYTE[len+copy] = '\0';
}
return copy;
}
 
:inline cdecl int sprintf(dword buf, format,...)
{
byte s;
char X[10];
dword ret, tmp, l;
dword arg = #format;
ret = buf;
s = DSBYTE[format];
while(s){
if(s=='%'){
arg+=4;
tmp = DSDWORD[arg];
if(tmp==END_ARGS)goto END_FUNC_SPRINTF;
$inc format
s = DSBYTE[format];
if(!s)goto END_FUNC_SPRINTF;
switch(s)
{
case 's':
l = tmp;
s = DSBYTE[tmp];
while(s)
{
DSBYTE[buf] = s;
$inc tmp
$inc buf
s = DSBYTE[tmp];
}
break;
case 'c':
DSBYTE[buf] = tmp;
$inc buf
break;
case 'u': //if(tmp<0)return ret;
case 'd':
case 'i':
tmp = itoa(tmp);
if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
l = strlen(tmp);
strncpy(buf,tmp,l);
buf += l;
break;
case 'a':
case 'A':
strncpy(buf,"0x00000000",10);
buf+=10;
l=buf;
while(tmp)
{
$dec buf
s=tmp&0xF;
if(s>9)DSBYTE[buf]='A'+s-10;
else DSBYTE[buf]='0'+s;
tmp>>=4;
}
buf=l;
break;
case 'p':
tmp = itoa(#tmp);
if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
l = strlen(tmp);
strncpy(buf,tmp,l);
buf += l;
break;
case '%':
DSBYTE[buf] = '%';
$inc buf
break;
default:
goto END_FUNC_SPRINTF;
}
}
else {
DSBYTE[buf] = s;
$inc buf
}
$inc format
s = DSBYTE[format];
}
END_FUNC_SPRINTF:
DSBYTE[buf] = 0;
return buf-ret;
}
 
void debugi(dword d_int)
{
char tmpch[12];