diff --git a/programs/cmm/examples/collections.c b/programs/cmm/examples/collections.c index 59eef2a7b0..72c6ebe06c 100644 --- a/programs/cmm/examples/collections.c +++ b/programs/cmm/examples/collections.c @@ -3,7 +3,6 @@ #include "../lib/io.h" #include "../lib/collection.h" -collection s; void main() { @@ -12,7 +11,9 @@ void main() test2(); } -void test1() { +void test1() + collection s; + { s.add("Hello"); s.add("World!"); debugln(s.get(0)); //-> Hello @@ -21,16 +22,17 @@ void test1() { } void test2() -{ - int i; - s.add("0"); - s.add("1"); - s.add("2"); - s.add("3"); - for (i=0; i 0 1 2 3 - s.count--; - s.count--; - s.add("4"); - for (i=0; i 0 1 4 - s.drop(); + collection_int ci; + int i; + { + ci.add(0); + ci.add(1); + ci.add(2); + ci.add(3); + for (i=0; i 0 1 2 3 + ci.count--; + ci.count--; + ci.add(4); + for (i=0; i 0 1 4 + ci.drop(); } \ No newline at end of file diff --git a/programs/cmm/lib/collection.h b/programs/cmm/lib/collection.h index 2ce4cdec54..be6da96313 100644 --- a/programs/cmm/lib/collection.h +++ b/programs/cmm/lib/collection.h @@ -2,6 +2,12 @@ #define INCLUDE_COLLECTION_H #print "[include ]\n" +/*======================================================== += = += String = += = +========================================================*/ + struct collection { int realloc_size, count; @@ -50,4 +56,37 @@ void collection::drop() { data_size = data_start = element_offset[count] = count = 0; } + +/*======================================================== += = += Integer = += = +========================================================*/ + +struct collection_int +{ + int count; + dword element[4096*3]; + int add(); + dword get(); + void drop(); +}; + +int collection_int::add(dword in) { + if (count >= 4096*3) return 0; + element[count] = in; + count++; + return 1; +} + +dword collection_int::get(dword pos) { + if (pos<0) || (pos>=count) return 0; + return element[pos]; +} + +void collection_int::drop() { + element[0] = + count = 0; +} + #endif \ No newline at end of file diff --git a/programs/cmm/lib/keyboard.h b/programs/cmm/lib/keyboard.h new file mode 100644 index 0000000000..6b1bb6a51d --- /dev/null +++ b/programs/cmm/lib/keyboard.h @@ -0,0 +1,101 @@ +#ifndef INCLUDE_KEYBOARD_H +#define INCLUDE_KEYBOARD_H +#print "[include ]\n" + +//ASCII KEYS +#define ASCII_KEY_BS 008 +#define ASCII_KEY_TAB 009 +#define ASCII_KEY_ENTER 013 +#define ASCII_KEY_ESC 027 +#define ASCII_KEY_DEL 182 +#define ASCII_KEY_INS 185 +#define ASCII_KEY_SPACE 032 + +#define ASCII_KEY_LEFT 176 +#define ASCII_KEY_RIGHT 179 +#define ASCII_KEY_DOWN 177 +#define ASCII_KEY_UP 178 +#define ASCII_KEY_HOME 180 +#define ASCII_KEY_END 181 +#define ASCII_KEY_PGDN 183 +#define ASCII_KEY_PGUP 184 + +//SCAN CODE KEYS +#define SCAN_CODE_BS 014 +#define SCAN_CODE_TAB 015 +#define SCAN_CODE_ENTER 028 +#define SCAN_CODE_ESC 001 +#define SCAN_CODE_DEL 083 +#define SCAN_CODE_INS 082 +#define SCAN_CODE_SPACE 057 + +#define SCAN_CODE_LEFT 075 +#define SCAN_CODE_RIGHT 077 +#define SCAN_CODE_DOWN 080 +#define SCAN_CODE_UP 072 +#define SCAN_CODE_HOME 071 +#define SCAN_CODE_END 079 +#define SCAN_CODE_PGDN 081 +#define SCAN_CODE_PGUP 073 + +#define KEY_LSHIFT 00000000001b +#define KEY_RSHIFT 00000000010b +#define KEY_LCTRL 00000000100b +#define KEY_RCTRL 00000001000b +#define KEY_LALT 00000010000b +#define KEY_RALT 00000100000b +#define KEY_CAPSLOCK 00001000000b +#define KEY_NUMLOCK 00010000000b +#define KEY_SCROLLLOCK 00100000000b +#define KEY_LWIN 01000000000b +#define KEY_RWIN 10000000000b + +dword calc(EAX) { return EAX; } + +inline fastcall word GetKey() //+Gluk fix +{ + $push edx +GETKEY: + $mov eax,2 + $int 0x40 + $cmp eax,1 + $jne GETKEYI + $mov ah,dh + $jmp GETKEYII //jz? +GETKEYI: + $mov dh,ah + $jmp GETKEY +GETKEYII: + $pop edx + $shr eax,8 +} + + +unsigned char key_ascii; +dword key_scancode, key_modifier; +int GetKeys() +{ + $push edx +GETKEY: + $mov eax,2 + $int 0x40 + $cmp eax,1 + $jne GETKEYI + $mov eax,edx + $jmp GETKEYII +GETKEYI: + $mov edx,eax + $jmp GETKEY +GETKEYII: + $pop edx + key_ascii = AH; + $shr eax,16 + key_scancode = AL; + //get alt/shift/ctrl key status + $mov eax,66 + $mov ebx,3 + $int 0x40 + key_modifier = EAX; +} + +#endif \ No newline at end of file diff --git a/programs/cmm/lib/kolibri.h b/programs/cmm/lib/kolibri.h index 1e6fa3a98b..9f902a7cb2 100644 --- a/programs/cmm/lib/kolibri.h +++ b/programs/cmm/lib/kolibri.h @@ -48,102 +48,6 @@ char program_path[4096]; #define BT_HIDE 0x40000000 #define BT_NOFRAME 0x20000000 -//ASCII KEYS -#define ASCII_KEY_BS 008 -#define ASCII_KEY_TAB 009 -#define ASCII_KEY_ENTER 013 -#define ASCII_KEY_ESC 027 -#define ASCII_KEY_DEL 182 -#define ASCII_KEY_INS 185 -#define ASCII_KEY_SPACE 032 - -#define ASCII_KEY_LEFT 176 -#define ASCII_KEY_RIGHT 179 -#define ASCII_KEY_DOWN 177 -#define ASCII_KEY_UP 178 -#define ASCII_KEY_HOME 180 -#define ASCII_KEY_END 181 -#define ASCII_KEY_PGDN 183 -#define ASCII_KEY_PGUP 184 - -//SCAN CODE KEYS -#define SCAN_CODE_BS 014 -#define SCAN_CODE_TAB 015 -#define SCAN_CODE_ENTER 028 -#define SCAN_CODE_ESC 001 -#define SCAN_CODE_DEL 083 -#define SCAN_CODE_INS 082 -#define SCAN_CODE_SPACE 057 - -#define SCAN_CODE_LEFT 075 -#define SCAN_CODE_RIGHT 077 -#define SCAN_CODE_DOWN 080 -#define SCAN_CODE_UP 072 -#define SCAN_CODE_HOME 071 -#define SCAN_CODE_END 079 -#define SCAN_CODE_PGDN 081 -#define SCAN_CODE_PGUP 073 - -#define KEY_LSHIFT 00000000001b -#define KEY_RSHIFT 00000000010b -#define KEY_LCTRL 00000000100b -#define KEY_RCTRL 00000001000b -#define KEY_LALT 00000010000b -#define KEY_RALT 00000100000b -#define KEY_CAPSLOCK 00001000000b -#define KEY_NUMLOCK 00010000000b -#define KEY_SCROLLLOCK 00100000000b -#define KEY_LWIN 01000000000b -#define KEY_RWIN 10000000000b - -dword calc(EAX) { return EAX; } - -inline fastcall word GetKey() //+Gluk fix -{ - $push edx -GETKEY: - $mov eax,2 - $int 0x40 - $cmp eax,1 - $jne GETKEYI - $mov ah,dh - $jmp GETKEYII //jz? -GETKEYI: - $mov dh,ah - $jmp GETKEY -GETKEYII: - $pop edx - $shr eax,8 -} - - -unsigned char key_ascii; -dword key_scancode, key_modifier; -int GetKeys() -{ - $push edx -GETKEY: - $mov eax,2 - $int 0x40 - $cmp eax,1 - $jne GETKEYI - $mov eax,edx - $jmp GETKEYII -GETKEYI: - $mov edx,eax - $jmp GETKEY -GETKEYII: - $pop edx - key_ascii = AH; - $shr eax,16 - key_scancode = AL; - //get alt/shift/ctrl key status - $mov eax,66 - $mov ebx,3 - $int 0x40 - key_modifier = EAX; -} - //allow event mask #define EVENT_MASK_REDRAW 000000001b #define EVENT_MASK_KEYBOARD 000000010b @@ -158,20 +62,14 @@ GETKEYII: #define END_ARGS 0xFF00FF //------------------------------------------------------------------------- -#ifndef INCLUDE_SYSTEM_H #include "../lib/system.h" -#endif - -#ifndef INCLUDE_MOUSE_H #include "../lib/mouse.h" -#endif +#include "../lib/keyboard.h" :struct raw_image { dword w, h, data; }; - - //------------------------------------------------------------------------------ :dword wait_event_code; inline fastcall dword WaitEvent() @@ -223,18 +121,6 @@ inline fastcall dword GetFreeRAM() //return eax = размер свободной памяти в килобайтах } -inline void draw_line(dword x1,y1,x2,y2,color) -{ - x2--;y2--;y1--; - $mov EAX,38 - EBX = x1<<16; - EBX |= x2; - ECX = y1<<16; - ECX |= y2; - $mov EDX,color - $int 0x40 -} - inline fastcall dword LoadDriver(ECX) //ECX - имя драйвера { $mov eax, 68 @@ -416,7 +302,6 @@ inline fastcall int GetClientHeight() $mov eax, ebx } - inline fastcall dword LoadLibrary( ECX) { $mov eax, 68 @@ -430,13 +315,6 @@ inline fastcall int TestBit( EAX, CL) $and eax,1 } -inline fastcall int PlaySpeaker( ESI) -{ - $mov eax, 55 - $mov ebx, 55 - $int 0x40 -} - //------------------------------------------------------------------------------ void DefineAndDrawWindow(dword x, y, size_w, size_h, byte WindowType,dword WindowAreaColor, EDI, ESI) @@ -579,20 +457,6 @@ inline RefreshWindow(dword ID_REFRESH,ID_ACTIVE) $int 0x40 } -inline getIPC(ECX,EDX) -{ - $mov EAX,60 - $mov EBX,2 - $int 0x40 -} - -inline sendIPC(ECX,EDX,ESI) -{ - $mov EAX,60 - $mov EBX,1 - $int 0x40 -} - void UnsafeDefineButton(dword x,y,w,h,EDX,ESI) { EAX = 8; @@ -635,29 +499,18 @@ inline fastcall dword GetStartTime() CreateThread(#_EventRedrawWindow,#REDRAW_BUFF_EVENT_+4092); } -:dword ALERT_TEXT; -:void dialog_alert() +:struct obj { - byte id; - loop()switch(WaitEvent()) - { - case evReDraw: - DefineAndDrawWindow(215,100,250,200,0x34,0xFFFFFF,"Alert"); - WriteTextB(5,5,0x90,0x0,ALERT_TEXT); - break; - case evKey: - case evButton: - id=GetButtonID(); - if (id==1) ExitProcess(); - break; - } -} -:dword alert(dword text) + dword x,y,w,h; + void size(); +}; + +:void obj::size(dword _x, _y, _w, _h) { - dword mem = malloc(4096); - ALERT_TEXT = text; - CreateThread(#dialog_alert,mem+4092); - return mem; + x=_x; + y=_y; + w=_w; + h=_h; } :struct _screen @@ -669,7 +522,6 @@ inline fastcall dword GetStartTime() :void DrawDate(dword x, y, color, in_date) { - //char text[15]; EDI = in_date; EAX = 47; EBX = 2<<16; @@ -677,17 +529,15 @@ inline fastcall dword GetStartTime() ESI = 0x90<<24+color; ECX = EDI.date.day; $int 0x40; - EDX += 18<<16; + EDX += 20<<16; ECX = EDI.date.month; $int 0x40; - EDX += 18<<16; + EDX += 20<<16; EBX = 4<<16; ECX = EDI.date.year; $int 0x40; - PutPixel(x+14,y+6,color); - PutPixel(x+32,y+6,color); - //sprintf(#text,"%d",EDI.date.year); - //WriteText(x, y, 0x80, 0x000000, #text); + DrawBar(x+17,y+10,2,2,color); + DrawBar(x+37,y+10,2,2,color); } :void __path_name__(dword BUF,PATH)