diff --git a/programs/develop/metcc/trunk/libc/build.bat b/programs/develop/ktcc/trunk/libc/build.bat similarity index 90% rename from programs/develop/metcc/trunk/libc/build.bat rename to programs/develop/ktcc/trunk/libc/build.bat index 04dc47bc96..73d2afd643 100644 --- a/programs/develop/metcc/trunk/libc/build.bat +++ b/programs/develop/ktcc/trunk/libc/build.bat @@ -4,13 +4,13 @@ echo # Melibc builder # echo # usage: build [clean] # echo #################################################### rem #### CONFIG SECTION #### -set LIBNAME=melibc.a +set LIBNAME=libck.a set INCLUDE=include -set CC=gcc +set CC= set CFLAGS=-c -nostdinc -DGNUC -I"%cd%\%INCLUDE%" -set AR=ar -set ASM=fasm -set dirs=file mem mesys string +set AR= +set ASM= +set dirs=stdio memory kolibrisys string stdlib rem #### END OF CONFIG SECTION #### set objs= diff --git a/programs/develop/metcc/trunk/libc/include/ctype.h b/programs/develop/ktcc/trunk/libc/include/ctype.h similarity index 90% rename from programs/develop/metcc/trunk/libc/include/ctype.h rename to programs/develop/ktcc/trunk/libc/include/ctype.h index 9b4264f5ab..f4b79a0bbf 100644 --- a/programs/develop/metcc/trunk/libc/include/ctype.h +++ b/programs/develop/ktcc/trunk/libc/include/ctype.h @@ -29,3 +29,7 @@ extern char _is[128]; #define isspace(c)(_is[c] & BLANK ) /* HT, LF, VT, FF, CR, ' ' */ #define isupper(c)(_is[c] & UPPER ) /* 'A'-'Z' */ #define isxdigit(c)(_is[c] & XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */ + +#define isascii(c) (!((c)&(~0x7f))) +#define toascii(c) ((c)&0x7f) + diff --git a/programs/develop/ktcc/trunk/libc/include/kolibrisys.h b/programs/develop/ktcc/trunk/libc/include/kolibrisys.h new file mode 100644 index 0000000000..aed4aed79b --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/include/kolibrisys.h @@ -0,0 +1,195 @@ +#ifndef kolibrisys_h +#define kolibrisys_h +/* +#ifdef GNUC +#define stdcall __stdcall +#define cdecl __cdecl +#else +#define stdcall ((__stdcall)) +#define cdecl ((__cdecl)) +#endif +*/ +//#ifdef GNUC +//#define stdcall __stdcall +//#else +#define cdecl __attribute__ ((cdecl)) +#define stdcall __attribute__ ((stdcall)) +//#endif + +typedef unsigned int dword; +typedef unsigned char byte; +typedef unsigned short word; + +typedef unsigned int fpos_t; +typedef unsigned int size_t; + +typedef struct process_table_entry{ + int cpu_usage; //+0 + int window_pos_info; //+4 + short int reserved1; //+8 + char name[12]; //+10 + int memstart; //+22 + int memused; //+26 + int pid; //+30 + int winx_start; //+34 + int winy_start; //+38 + int winx_size; //+42 + int winy_size; //+46 + short int slot_info; //+50 + short int reserved2; //+52 + int clientx; //+54 + int clienty; //+58 + int clientwidth; //+62 + int clientheight; //+66 + unsigned char window_state;//+70 + char reserved3[1024-71]; //+71 +}__attribute__((packed)); + +//----------------------------------------------------------------------------------- +//------------------------KolibriOS system acces to files---------------------------- +//----------------------------------------------------------------------------------- +extern dword stdcall _ksys_get_filesize(char *filename); +extern dword stdcall _ksys_readfile(char *filename,dword pos,dword blocksize,void *data); +extern dword stdcall _ksys_rewritefile(char *filename,dword blocksize,void *data); +extern dword stdcall _ksys_appendtofile(char *filename,dword pos,dword blocksize,void *data); +//----------------------------------------------------------------------------------- + +//----------------------Run program--------------------------------------------------- +extern void stdcall _ksys_run_program(char* filename,char* parameters); +//------------------------------------------------------------------------------------ + +//--------------------Debug output--------------------------------------------------- +extern void stdcall _ksys_debug_out(int c); +extern void stdcall debug_out_str(char* str); +//----------------------------------------------------------------------------------- + +//--------------------------Mouse state---------------------------------------------- +extern int stdcall _ksys_GetMouseXY(void); +extern int stdcall _ksys_GetMouseButtonsState(void); +//----------------------------------------------------------------------------------- + +//--------------------------get skin height------------------------------------------ +extern int stdcall _ksys_get_skin_height(void); +//----------------------------------------------------------------------------------- + +//----------------------------background--------------------------------------------- +extern void stdcall _ksys_set_background_size(int xsize,int ysize); +extern void stdcall _ksys_write_background_mem(int pos,int color); +extern void stdcall _ksys_draw_background(void); +extern void stdcall _ksys_set_background_draw_type(int type); +extern void stdcall _ksys_background_blockmove(void* src,int bgr_pos, int count); +//----------------------------------------------------------------------------------- + +//----------------------------functionf for draw window,lines.bar,etc.--------------- +extern void stdcall _ksys_draw_window(int xcoord,int ycoord, int xsize, + int ysize,int workcolor,int type, + int captioncolor,int windowtype,int bordercolor); +extern void stdcall _ksys_window_redraw(int status); +extern int stdcall _ksys_putpixel(int x,int y,int color); +extern void stdcall _ksys_draw_bar(int x, int y, int xsize, int ysize, int color); +extern void stdcall _ksys_line(int x1,int y1,int x2,int y2,int color); +extern void stdcall _ksys_putimage(int x, int y, int xsize, int ysize, void* image); +//----------------------------------------------------------------------------------- + +//--------------------------write text(system fonts 6x9)----------------------------- +extern void stdcall _ksys_write_text(int x,int y,int color,char* text,int len); +//----------------------------------------------------------------------------------- + +//------------------ get screen size and bytes per pixel--------------------------- +extern int stdcall _ksys_get_screen_size(int* x,int* y); +extern void stdcall _ksys_dga_get_resolution(int* xres, int* yres, int* bpp, int* bpscan); +//----------------------------------------------------------------------------------- + +//-------------------------------craete thread--------------------------------------- +extern void* stdcall _ksys_start_thread(void (* func_ptr)(void),int stack_size,int* pid); +//----------------------------------------------------------------------------------- + +//------------------system button(Old function. Better use libGUI functions.)-------- +extern void stdcall _ksys_make_button(int x, int y, int xsize, int ysize, int id, int color); +extern int stdcall _ksys_get_button_id(void); //get state of system button +//------------------------------------------------------------------------------------ + +//----------------------system clock(in 1/100 sec.) and date-------------------------- +extern int stdcall _ksys_get_system_clock(void); +extern int stdcall _ksys_get_date(void); +//------------------------------------------------------------------------------------ + +//-------------------------system delay(in 1/100 sec.)------------------------------- +extern void stdcall _ksys_delay(int m); +//----------------------------------------------------------------------------------- + +//------------------------system events---------------------------------------------- +extern int stdcall _ksys_wait_for_event_infinite(void); +extern int stdcall _ksys_check_for_event(void); +extern int stdcall _ksys_wait_for_event(int time); +extern void stdcall _ksys_set_wanted_events(int ev); +//----------------------------------------------------------------------------------- + +//----------------------------system exit program------------------------------------ +extern void stdcall _ksys_exit(void); +//----------------------------------------------------------------------------------- + +//-----------------------------system IPC send message------------------------------- +extern void stdcall _ksys_send_message(int pid, void* msg, int size); +//----------------------------------------------------------------------------------- + +//---------------------------system work with IRQ from user mode--------------------- +extern void stdcall _ksys_define_receive_area(void* area, int size); +extern int stdcall _ksys_get_irq_owner(int irq); +extern int stdcall _ksys_get_data_read_by_irq(int irq, int* size, void* data); +extern int stdcall _ksys_send_data_to_device(int port, unsigned char val); +extern int stdcall _ksys_receive_data_from_device(int port,unsigned char* data); +extern void stdcall _ksys_program_irq(void* intrtable, int irq); +extern void stdcall _ksys_reserve_irq(int irq); +extern void stdcall _ksys_free_irq(int irq); +//---------------------------------------------------------------------------------- + +//----------------------------system reserve diapason of ports---------------------- +extern int stdcall _ksys_reserve_port_area(int start,int end); +extern int stdcall _ksys_free_port_area(int start,int end); +//---------------------------------------------------------------------------------- + +//-------------functions get key and set keyboard mode------------------------------ +extern int stdcall _ksys_get_key(void); +extern void stdcall _ksys_set_keyboard_mode(int mode); +//---------------------------------------------------------------------------------- + +//--------------simple work with MPU401 sound device--------------------------------- +extern void stdcall _ksys_midi_reset(void); +extern void stdcall _ksys_midi_send(int data); +//----------------------------------------------------------------------------------- + +//--------------------------acces to PCI BUS from user mode--------------------------- +extern int stdcall _ksys_get_pci_version(void); +extern int stdcall _ksys_get_last_pci_bus(void); +extern int stdcall _ksys_get_pci_access_mechanism(void); +extern int stdcall _ksys_pci_read_config_byte(int bus,int dev,int fn,int reg); +extern int stdcall _ksys_pci_read_config_word(int bus,int dev,int fn,int reg); +extern int stdcall _ksys_pci_read_config_dword(int bus,int dev,int fn,int reg); +extern int stdcall _ksys_pci_write_config_byte(int bus,int dev,int fn,int reg,int value); +extern int stdcall _ksys_pci_write_config_word(int bus,int dev,int fn,int reg,int value); +extern int stdcall _ksys_pci_write_config_value(int bus,int dev,int fn,int reg,int value); +//-------------------------------------------------------------------------------------- + +//------------------------Process information-------------------------------------- +extern int stdcall _ksys_get_process_table(struct process_table_entry *proctab,int pid); //if pid=-1 than get info about him. +//--------------------------------------------------------------------------------- + +//-----------------Old functions for work with sound(Sound Blaster only).--------- +extern void stdcall _ksys_sound_load_block(void* blockptr); +extern void stdcall _ksys_sound_play_block(void); +extern void stdcall _ksys_sound_set_channels(int channels); +extern void stdcall _ksys_sound_set_data_size(int size); +extern void stdcall _ksys_sound_set_frequency(int frequency); +//-------------------------------------------------------------------------------- + +//------------------------------system speaker(integrated speaker)---------------- +extern void stdcall _ksys_sound_speaker_play(void* data); +//-------------------------------------------------------------------------------- + +//------------------function for work with Dinamic Link Librarys(DLL)-------------- +extern dword* stdcall _ksys_cofflib_load(char* name); +extern char* stdcall _ksys_cofflib_getproc(void* exp,char* sz_name); +//--------------------------------------------------------------------------------- + +#endif diff --git a/programs/develop/ktcc/trunk/libc/include/math.h b/programs/develop/ktcc/trunk/libc/include/math.h new file mode 100644 index 0000000000..bc1f9fb319 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/include/math.h @@ -0,0 +1,179 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +extern int stdcall integer(float number); + +extern double acos(double _x); +extern double asin(double _x); +extern double atan(double _x); +extern double atan2(double _y, double _x); +extern double ceil(double _x); +extern double cos(double _x); +extern double cosh(double _x); +extern double exp(double _x); +extern double fabs(double _x); +extern double floor(double _x); +extern double fmod(double _x, double _y); +extern double frexp(double _x, int *_pexp); +extern double ldexp(double _x, int _exp); +extern double log(double _y); +extern double log10(double _x); +extern double modf(double _x, double *_pint); +extern double pow(double _x, double _y); +extern double sin(double _x); +extern double sinh(double _x); +extern double sqrt(double _x); +extern double tan(double _x); +extern double tanh(double _x); + +//#ifndef __STRICT_ANSI__ + +//#ifndef _POSIX_SOURCE + +#define M_E 2.7182818284590452354 +#define M_LOG2E 1.4426950408889634074 +#define M_LOG10E 0.43429448190325182765 +#define M_LN2 0.69314718055994530942 +#define M_LN10 2.30258509299404568402 +#define M_PI 3.14159265358979323846 +#define M_PI_2 1.57079632679489661923 +#define M_PI_4 0.78539816339744830962 +#define M_1_PI 0.31830988618379067154 +#define M_2_PI 0.63661977236758134308 +#define M_2_SQRTPI 1.12837916709551257390 +#define M_SQRT2 1.41421356237309504880 +#define M_SQRT1_2 0.70710678118654752440 +#define PI M_PI +#define PI2 M_PI_2 + +extern double acosh(double); +extern double asinh(double); +extern double atanh(double); +extern double cbrt(double); +extern double exp10(double _x); +extern double exp2(double _x); +extern double expm1(double); +extern double hypot(double, double); +extern double log1p(double); +extern double log2(double _x); +extern long double modfl(long double _x, long double *_pint); +extern double pow10(double _x); +extern double pow2(double _x); +extern double powi(double, int); +extern void sincos(double *, double *, double); + +/* These are in libm.a (Cygnus). You must link -lm to get these */ +/* See libm/math.h for comments */ +/* +#ifndef __cplusplus +struct exception { + int type; + const char *name; + double arg1; + double arg2; + double retval; + int err; +}; +#endif +*/ + +extern double erf(double); +extern double erfc(double); +extern double gamma(double); +extern int isinf(double); +extern int isnan(double); +extern int finite(double); +extern double j0(double); +extern double j1(double); +extern double jn(int, double); +extern double lgamma(double); +extern double nan(void); +extern double y0(double); +extern double y1(double); +extern double yn(int, double); +extern double logb(double); +extern double nextafter(double, double); +extern double remainder(double, double); +extern double scalb(double, double); +//#ifndef __cplusplus +//extern int matherr(struct exception *); +//#endif +extern double significand(double); +extern double copysign(double, double); +extern int ilogb(double); +extern double rint(double); +extern double scalbn(double, int); +extern double drem(double, double); +extern double gamma_r(double, int *); +extern double lgamma_r(double, int *); +extern float acosf(float); +extern float asinf(float); +extern float atanf(float); +extern float atan2f(float, float); +extern float cosf(float); +extern float sinf(float); +extern float tanf(float); +extern float coshf(float); +extern float sinhf(float); +extern float tanhf(float); +extern float expf(float); +extern float frexpf(float, int *); +extern float ldexpf(float, int); +extern float logf(float); +extern float log10f(float); +extern float modff(float, float *); +extern float powf(float, float); +extern float sqrtf(float); +extern float ceilf(float); +extern float fabsf(float); +extern float floorf(float); +extern float fmodf(float, float); +extern float erff(float); +extern float erfcf(float); +extern float gammaf(float); +extern float hypotf(float, float); +extern int isinff(float); +extern int isnanf(float); +extern int finitef(float); +extern float j0f(float); +extern float j1f(float); +extern float jnf(int, float); +extern float lgammaf(float); +extern float nanf(void); +extern float y0f(float); +extern float y1f(float); +extern float ynf(int, float); +extern float acoshf(float); +extern float asinhf(float); +extern float atanhf(float); +extern float cbrtf(float); +extern float logbf(float); +extern float nextafterf(float, float); +extern float remainderf(float, float); +extern float scalbf(float, float); +extern float significandf(float); +extern float copysignf(float, float); +extern int ilogbf(float); +extern float rintf(float); +extern float scalbnf(float, int); +extern float dremf(float, float); +extern float expm1f(float); +extern float log1pf(float); +extern float gammaf_r(float, int *); +extern float lgammaf_r(float, int *); + +//#endif /* !_POSIX_SOURCE */ +//#endif /* !__STRICT_ANSI__ */ +//#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +//#ifndef __dj_ENFORCE_FUNCTION_CALLS +//#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +//#ifdef __cplusplus +//} +//#endif + +//#endif /* _USE_LIBM_MATH_H */ + +//#endif /* !__dj_include_math_h_ */ diff --git a/programs/develop/metcc/trunk/libc/include/stdio.h b/programs/develop/ktcc/trunk/libc/include/stdio.h similarity index 55% rename from programs/develop/metcc/trunk/libc/include/stdio.h rename to programs/develop/ktcc/trunk/libc/include/stdio.h index 4cf4026f6e..b267a09ccf 100644 --- a/programs/develop/metcc/trunk/libc/include/stdio.h +++ b/programs/develop/ktcc/trunk/libc/include/stdio.h @@ -1,7 +1,17 @@ #ifndef stdio_h #define stdio_h -#include "mesys.h" + +#include "kolibrisys.h" + +typedef char *va_list; +#define _roundsize(n) ( (sizeof(n) + 3) & ~3 ) +#define va_start(ap,v) (ap = (va_list)&v+_roundsize(v)) +#define va_arg(ap,t) ( *(t *)((ap += _roundsize(t)) - _roundsize(t)) ) +#define va_end(ap) (ap = (va_list)0) + #define NULL ((void*)0) +//extern int stdcall format_print(char *dest, size_t maxlen, const char *fmt0, va_list argp); + typedef struct { char* buffer; dword buffersize; @@ -10,18 +20,19 @@ typedef struct { char* filename; int mode; } FILE; + #define FILE_OPEN_READ 0 #define FILE_OPEN_WRITE 1 #define FILE_OPEN_APPEND 2 #define FILE_OPEN_TEXT 4 #define FILE_OPEN_PLUS 8 #define EOF -1 + extern FILE* fopen(const char* filename, const char *mode); extern void fclose(FILE* file); extern int feof(FILE* file); extern int fflush(FILE* file); extern int fgetc(FILE* file); -typedef int fpos_t; extern int fgetpos(FILE* file,fpos_t* pos); extern int fsetpos(FILE* file,const fpos_t* pos); extern int fputc(int c,FILE* file); @@ -33,7 +44,14 @@ extern long ftell(FILE* file); #define SEEK_SET 2 extern int fseek(FILE* file,long offset,int origin); extern void rewind(FILE* file); -extern int fprintf(FILE* file, const char* format, ...); -extern int fscanf(FILE* file,const char* format, ...); +extern int cdecl fprintf(FILE* file, const char* format,...); +extern int fscanf(FILE* file,const char* format,...); extern int ungetc(int c,FILE* file); + +extern int cdecl printf(const char *format,...); + +extern int vsnprintf(char *dest, size_t size,const char *format,va_list ap); +extern int cdecl snprintf(char *dest, size_t size, const char *format,...); +extern int cdecl sprintf(char *dest,const char *format,...); + #endif diff --git a/programs/develop/ktcc/trunk/libc/include/stdlib.h b/programs/develop/ktcc/trunk/libc/include/stdlib.h new file mode 100644 index 0000000000..71f2295aae --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/include/stdlib.h @@ -0,0 +1,18 @@ +#ifndef stdlib_h +#define stdlib_h +#include "kolibrisys.h" + +//#define isspace(c) ((c)==' ') +#define abs(i) (((i)<0)?(-(i)):(i)) + +extern int atoib(char *s,int b); +extern int atoi(char *s); +extern unsigned char tolower(unsigned char c); +extern unsigned char toupper(unsigned char c); +extern void itoab(int n,char* s,int b); +extern void itoa(int n,char* s); + +extern void* stdcall malloc(dword size); +extern void stdcall free(void *pointer); +extern void* stdcall realloc(void* pointer,dword size); +#endif \ No newline at end of file diff --git a/programs/develop/metcc/trunk/libc/include/string.h b/programs/develop/ktcc/trunk/libc/include/string.h similarity index 100% rename from programs/develop/metcc/trunk/libc/include/string.h rename to programs/develop/ktcc/trunk/libc/include/string.h diff --git a/programs/develop/metcc/trunk/libc/mesys/_ksys_files_acces.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/_ksys_files_acces.asm similarity index 100% rename from programs/develop/metcc/trunk/libc/mesys/_ksys_files_acces.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/_ksys_files_acces.asm diff --git a/programs/develop/metcc/trunk/libc/mesys/backgr.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/backgr.asm similarity index 73% rename from programs/develop/metcc/trunk/libc/mesys/backgr.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/backgr.asm index d25a1322cf..c65ff0c581 100644 --- a/programs/develop/metcc/trunk/libc/mesys/backgr.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/backgr.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_set_background_size,8 +public_stdcall _ksys_set_background_size,8 ;arg1 - xsize ;arg2 - ysize push ebx @@ -12,7 +12,7 @@ public_stdcall _msys_set_background_size,8 int 0x40 pop ebx ret 8 -public_stdcall _msys_write_background_mem,8 +public_stdcall _ksys_write_background_mem,8 ;arg1 - pos ;arg2 - color push ebx @@ -23,14 +23,14 @@ public_stdcall _msys_write_background_mem,8 int 0x40 pop ebx ret 8 -public_stdcall _msys_draw_background,0 +public_stdcall _ksys_draw_background,0 mov edx,ebx mov eax,15 mov ebx,3 int 0x40 mov ebx,edx ret -public_stdcall _msys_set_background_draw_type,4 +public_stdcall _ksys_set_background_draw_type,4 ;arg1 - type mov edx,ebx mov eax,15 @@ -39,7 +39,7 @@ public_stdcall _msys_set_background_draw_type,4 int 0x40 mov ebx,edx ret 4 -public_stdcall _msys_background_blockmove,12 +public_stdcall _ksys_background_blockmove,12 ;arg1 - source ;arg2 - position in dest ;arg3 - size diff --git a/programs/develop/metcc/trunk/libc/mesys/button.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/button.asm similarity index 82% rename from programs/develop/metcc/trunk/libc/mesys/button.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/button.asm index cc6e3610ab..e6baf0c8d3 100644 --- a/programs/develop/metcc/trunk/libc/mesys/button.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/button.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_make_button,24 +public_stdcall _ksys_make_button,24 ;arg1 - x ;arg2 - y ;arg3 - xsize @@ -22,7 +22,7 @@ public_stdcall _msys_make_button,24 pop esi ebx ret 24 -public_stdcall _msys_get_button_id,0 +public_stdcall _ksys_get_button_id,0 mov eax,17 int 0x40 test al,al diff --git a/programs/develop/metcc/trunk/libc/mesys/clock.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/clock.asm similarity index 56% rename from programs/develop/metcc/trunk/libc/mesys/clock.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/clock.asm index 1ca630e434..7681d6dae4 100644 --- a/programs/develop/metcc/trunk/libc/mesys/clock.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/clock.asm @@ -3,10 +3,10 @@ format ELF include "proc32.inc" section '.text' executable -public _msys_get_system_clock +public _ksys_get_system_clock align 4 -proc _msys_get_system_clock stdcall +proc _ksys_get_system_clock stdcall mov eax,3 int 0x40 diff --git a/programs/develop/ktcc/trunk/libc/kolibrisys/cofflib.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/cofflib.asm new file mode 100644 index 0000000000..bc3e61edc1 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/cofflib.asm @@ -0,0 +1,73 @@ +format ELF +include 'proc32.inc' +section '.text' executable + +public _ksys_cofflib_load +public _ksys_cofflib_getproc + +proc _ksys_cofflib_load stdcall, name:dword + + mov eax, 68 + mov ebx, 19 + mov ecx, [name] + int 0x40 + ret +endp + +proc _ksys_cofflib_getproc stdcall, export:dword,name:dword + + mov ebx,[export] + + next_name_check: + + mov ecx,[ebx] + test ecx,ecx + jz end_export + + ;cmp export string with name + mov esi,[name] + xor edi,edi + next_simbol_check: + + xor eax,eax + mov al,[ecx] + test al,al + jz exit_check_simbol + + xor edx,edx + mov dl,[esi] + cmp al,dl + je simbols_equvalent + add edi,1 + jmp exit_check_simbol + simbols_equvalent: + + ;pushad + + ;mov cl,al + ;mov ebx,1 + ;mov eax,63 + ;int 0x40 + + ;popad + + add ecx,1 + add esi,1 + jmp next_simbol_check + exit_check_simbol: + + test edi,edi + jnz function_not_finded + mov eax,[ebx+4] + jmp end_export + function_not_finded: + + add ebx,8 + + jmp next_name_check + + end_export: + + ret +endp + diff --git a/programs/develop/metcc/trunk/libc/mesys/date.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/date.asm similarity index 72% rename from programs/develop/metcc/trunk/libc/mesys/date.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/date.asm index 4c9c1e9ce3..96e0b5d1b7 100644 --- a/programs/develop/metcc/trunk/libc/mesys/date.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/date.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_get_date,0 +public_stdcall _ksys_get_date,0 mov eax,29 int 0x40 ret \ No newline at end of file diff --git a/programs/develop/ktcc/trunk/libc/kolibrisys/debug_board.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/debug_board.asm new file mode 100644 index 0000000000..b0dbd8eaca --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/debug_board.asm @@ -0,0 +1,56 @@ +format ELF + +include "proc32.inc" + +section '.text' executable + +public _ksys_debug_out +public debug_out_str + +align 4 +proc _ksys_debug_out stdcall, c:dword + + pushad + + xor ecx,ecx + mov cl,byte[c] + mov ebx,1 + mov eax,63 + int 0x40 + + popad + + ret + +endp + +align 4 +proc debug_out_str stdcall, s:dword + + pushad + + mov eax,[s] ;eax=pointer to string + next_simbol_print: + + xor ebx,ebx + mov bl,[eax] + test bl,bl + jz exit_print_str + + cmp bl,10 + jne no_new_line + mov ecx,13 + stdcall _ksys_debug_out, ecx + no_new_line: + + stdcall _ksys_debug_out, ebx + add eax,1 + + jmp next_simbol_print + + exit_print_str: + + popad + + ret +endp diff --git a/programs/develop/metcc/trunk/libc/mesys/delay.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/delay.asm similarity index 81% rename from programs/develop/metcc/trunk/libc/mesys/delay.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/delay.asm index ab637faa91..b94fa14f04 100644 --- a/programs/develop/metcc/trunk/libc/mesys/delay.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/delay.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_delay,4 +public_stdcall _ksys_delay,4 ;arg1 - time mov edx,ebx mov eax,5 diff --git a/programs/develop/metcc/trunk/libc/mesys/dga.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/dga.asm similarity index 86% rename from programs/develop/metcc/trunk/libc/mesys/dga.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/dga.asm index f68cacba58..87ae6ca273 100644 --- a/programs/develop/metcc/trunk/libc/mesys/dga.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/dga.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_dga_get_resolution,16 +public_stdcall _ksys_dga_get_resolution,16 ;arg1 - *xres ;arg2 - *yres ;arg3 - *bpp diff --git a/programs/develop/metcc/trunk/libc/mesys/draw_bar.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/draw_bar.asm similarity index 85% rename from programs/develop/metcc/trunk/libc/mesys/draw_bar.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/draw_bar.asm index b1afef4a00..9c9f73484b 100644 --- a/programs/develop/metcc/trunk/libc/mesys/draw_bar.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/draw_bar.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_draw_bar,20 +public_stdcall _ksys_draw_bar,20 ;arg1 - x ;arg2 - y ;arg3 - xsize diff --git a/programs/develop/metcc/trunk/libc/mesys/draw_image.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/draw_image.asm similarity index 85% rename from programs/develop/metcc/trunk/libc/mesys/draw_image.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/draw_image.asm index 6bca4a7882..5c3af8a078 100644 --- a/programs/develop/metcc/trunk/libc/mesys/draw_image.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/draw_image.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_putimage,20 +public_stdcall _ksys_putimage,20 ;arg1 - x ;arg2 - y ;arg3 - xsize diff --git a/programs/develop/metcc/trunk/libc/mesys/draw_window.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/draw_window.asm similarity index 88% rename from programs/develop/metcc/trunk/libc/mesys/draw_window.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/draw_window.asm index fa3fce4905..ffbff79ba3 100644 --- a/programs/develop/metcc/trunk/libc/mesys/draw_window.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/draw_window.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_draw_window,36 +public_stdcall _ksys_draw_window,36 ;arg1 - xcoord ;arg2 - ycoord ;arg3 - xsize diff --git a/programs/develop/ktcc/trunk/libc/kolibrisys/event.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/event.asm new file mode 100644 index 0000000000..817f6d8c23 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/event.asm @@ -0,0 +1,40 @@ +format ELF + +section '.text' executable + +public _ksys_wait_for_event_infinite +public _ksys_check_for_event +public _ksys_wait_for_event +public _ksys_set_wanted_events + +_ksys_wait_for_event_infinite: + + mov eax,10 + int 0x40 + + ret + +_ksys_check_for_event: + + mov eax,11 + int 0x40 + + ret + +_ksys_wait_for_event: + +;arg1 - time + mov eax,23 + mov ebx,[esp+4] + int 0x40 + + ret 4 + +_ksys_set_wanted_events: + +;arg1 - flags + mov eax,40 + mov ebx,[esp+4] + int 0x40 + + ret 4 \ No newline at end of file diff --git a/programs/develop/metcc/trunk/libc/mesys/exit.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/exit.asm similarity index 76% rename from programs/develop/metcc/trunk/libc/mesys/exit.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/exit.asm index 4541546d80..0dc6def546 100644 --- a/programs/develop/metcc/trunk/libc/mesys/exit.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/exit.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_exit,0 +public_stdcall _ksys_exit,0 xor eax,eax dec eax int 0x40 diff --git a/programs/develop/metcc/trunk/libc/mesys/ipc.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/ipc.asm similarity index 78% rename from programs/develop/metcc/trunk/libc/mesys/ipc.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/ipc.asm index 3a32e0dc29..309c2217b6 100644 --- a/programs/develop/metcc/trunk/libc/mesys/ipc.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/ipc.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_send_message,12 +public_stdcall _ksys_send_message,12 ;arg1 - pid ;arg2 - msg ;arg3 - size @@ -15,7 +15,7 @@ public_stdcall _msys_send_message,12 pop esi ebx ret 12 -public_stdcall _msys_define_receive_area,8 +public_stdcall _ksys_define_receive_area,8 ;arg1 - area ;arg2 - size push ebx diff --git a/programs/develop/metcc/trunk/libc/mesys/irq.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/irq.asm similarity index 76% rename from programs/develop/metcc/trunk/libc/mesys/irq.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/irq.asm index 6d9228c05e..79fc761d8b 100644 --- a/programs/develop/metcc/trunk/libc/mesys/irq.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/irq.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_get_irq_owner,4 +public_stdcall _ksys_get_irq_owner,4 ;arg1 - irq mov edx,ebx mov eax,41 @@ -10,7 +10,7 @@ public_stdcall _msys_get_irq_owner,4 mov ebx,edx ret 4 -public_stdcall _msys_get_data_read_by_irq,12 +public_stdcall _ksys_get_data_read_by_irq,12 ;arg1 - irq ;arg2 - *size ;arg3 - data @@ -36,7 +36,7 @@ public_stdcall _msys_get_data_read_by_irq,12 mov ebx,edx ret -public_stdcall _msys_send_data_to_device,8 +public_stdcall _ksys_send_data_to_device,8 ;arg1 - port ;arg2 - data mov edx,ebx @@ -47,7 +47,7 @@ public_stdcall _msys_send_data_to_device,8 mov ebx,edx ret 8 -public_stdcall _msys_receive_data_from_device,8 +public_stdcall _ksys_receive_data_from_device,8 ;arg1 - port ;arg2 - data mov edx,ebx @@ -60,7 +60,7 @@ public_stdcall _msys_receive_data_from_device,8 mov ebx,edx ret 8 -public_stdcall _msys_program_irq,8 +public_stdcall _ksys_program_irq,8 ;arg1 - intrtable ;arg2 - irq mov edx,ebx @@ -71,7 +71,7 @@ public_stdcall _msys_program_irq,8 mov ebx,edx ret 8 -public_stdcall _msys_reserve_irq,4 +public_stdcall _ksys_reserve_irq,4 ;arg1 - irq mov edx,ebx mov eax,45 @@ -81,7 +81,7 @@ public_stdcall _msys_reserve_irq,4 mov ebx,edx ret 4 -public_stdcall _msys_free_irq,4 +public_stdcall _ksys_free_irq,4 ;arg1 - irq mov edx,ebx mov eax,45 @@ -92,7 +92,7 @@ public_stdcall _msys_free_irq,4 mov ebx,edx ret 4 -public_stdcall _msys_reserve_port_area,8 +public_stdcall _ksys_reserve_port_area,8 ;arg1 - start ;arg2 - end push ebx @@ -104,7 +104,7 @@ public_stdcall _msys_reserve_port_area,8 pop ebx ret 8 -public_stdcall _msys_free_port_area,8 +public_stdcall _ksys_free_port_area,8 ;arg1 - start ;arg2 - end push ebx diff --git a/programs/develop/metcc/trunk/libc/mesys/keyboard.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/keyboard.asm similarity index 59% rename from programs/develop/metcc/trunk/libc/mesys/keyboard.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/keyboard.asm index 15b3daa5b5..bc50099ba6 100644 --- a/programs/develop/metcc/trunk/libc/mesys/keyboard.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/keyboard.asm @@ -4,11 +4,11 @@ include "proc32.inc" section '.text' executable -public _msys_get_key -public _msys_set_keyboard_mode +public _ksys_get_key +public _ksys_set_keyboard_mode align 4 -proc _msys_get_key stdcall +proc _ksys_get_key stdcall mov eax,2 int 0x40 @@ -17,7 +17,7 @@ proc _msys_get_key stdcall endp align 4 -proc _msys_set_keyboard_mode stdcall, mode:dword +proc _ksys_set_keyboard_mode stdcall, mode:dword mov edx,ebx mov eax,66 diff --git a/programs/develop/metcc/trunk/libc/mesys/line.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/line.asm similarity index 86% rename from programs/develop/metcc/trunk/libc/mesys/line.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/line.asm index 4a82f58041..e776ad3698 100644 --- a/programs/develop/metcc/trunk/libc/mesys/line.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/line.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_line,20 +public_stdcall _ksys_line,20 ;arg1 - x1 ;arg2 - y1 ;arg3 - x2 diff --git a/programs/develop/metcc/trunk/libc/mesys/midi.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/midi.asm similarity index 75% rename from programs/develop/metcc/trunk/libc/mesys/midi.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/midi.asm index 6929766a5e..80655e4cc8 100644 --- a/programs/develop/metcc/trunk/libc/mesys/midi.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/midi.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_midi_reset,0 +public_stdcall _ksys_midi_reset,0 mov edx,ebx mov eax,20 xor ebx,ebx @@ -10,7 +10,7 @@ public_stdcall _msys_midi_reset,0 mov ebx,edx ret -public_stdcall _msys_midi_send,4 +public_stdcall _ksys_midi_send,4 ;arg1 - data mov edx,ebx mov eax,20 diff --git a/programs/develop/ktcc/trunk/libc/kolibrisys/mouse.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/mouse.asm new file mode 100644 index 0000000000..f609b8c63c --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/mouse.asm @@ -0,0 +1,25 @@ + +format ELF + +section '.text' executable + +public _ksys_GetMouseXY +public _ksys_GetMouseButtonsState + +align 4 +_ksys_GetMouseXY: + + mov eax,37 + mov ebx,1 + int 0x40 + + ret + +align 4 +_ksys_GetMouseButtonsState: + + mov eax,37 + mov ebx,2 + int 0x40 + + ret diff --git a/programs/develop/metcc/trunk/libc/mesys/pci.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/pci.asm similarity index 77% rename from programs/develop/metcc/trunk/libc/mesys/pci.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/pci.asm index 6f87e23db9..6af5d0db59 100644 --- a/programs/develop/metcc/trunk/libc/mesys/pci.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/pci.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_get_pci_version,0 +public_stdcall _ksys_get_pci_version,0 mov edx,ebx mov eax,62 xor ebx,ebx @@ -10,7 +10,7 @@ public_stdcall _msys_get_pci_version,0 mov ebx,edx ret -public_stdcall _msys_get_last_pci_bus,0 +public_stdcall _ksys_get_last_pci_bus,0 mov edx,ebx mov eax,62 xor ebx,ebx @@ -20,7 +20,7 @@ public_stdcall _msys_get_last_pci_bus,0 mov ebx,edx ret -public_stdcall _msys_get_pci_access_mechanism,0 +public_stdcall _ksys_get_pci_access_mechanism,0 mov edx,ebx mov eax,62 mov ebx,2 @@ -29,7 +29,7 @@ public_stdcall _msys_get_pci_access_mechanism,0 mov ebx,edx ret -public_stdcall _msys_pci_read_config_byte,16 +public_stdcall _ksys_pci_read_config_byte,16 ;arg1 - bus ;arg2 - dev ;arg3 - fn @@ -46,7 +46,7 @@ public_stdcall _msys_pci_read_config_byte,16 mov ebx,edx ret 16 -public_stdcall _msys_pci_read_config_word,16 +public_stdcall _ksys_pci_read_config_word,16 ;arg1 - bus ;arg2 - dev ;arg3 - fn @@ -63,7 +63,7 @@ public_stdcall _msys_pci_read_config_word,16 mov ebx,edx ret 16 -public_stdcall _msys_pci_read_config_dword,16 +public_stdcall _ksys_pci_read_config_dword,16 ;arg1 - bus ;arg2 - dev ;arg3 - fn @@ -80,7 +80,7 @@ public_stdcall _msys_pci_read_config_dword,16 mov ebx,edx ret 16 -public_stdcall _msys_pci_write_config_byte,20 +public_stdcall _ksys_pci_write_config_byte,20 ;arg1 - bus ;arg2 - dev ;arg3 - fn @@ -99,7 +99,7 @@ public_stdcall _msys_pci_write_config_byte,20 pop ebx ret 20 -public_stdcall _msys_pci_write_config_word,20 +public_stdcall _ksys_pci_write_config_word,20 ;arg1 - bus ;arg2 - dev ;arg3 - fn @@ -118,7 +118,7 @@ public_stdcall _msys_pci_write_config_word,20 pop ebx ret 20 -public_stdcall _msys_pci_write_config_dword,20 +public_stdcall _ksys_pci_write_config_dword,20 ;arg1 - bus ;arg2 - dev ;arg3 - fn diff --git a/programs/develop/metcc/trunk/libc/mesys/pixel.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/pixel.asm similarity index 82% rename from programs/develop/metcc/trunk/libc/mesys/pixel.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/pixel.asm index 348b1ddedd..939bf32e00 100644 --- a/programs/develop/metcc/trunk/libc/mesys/pixel.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/pixel.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_putpixel,12 +public_stdcall _ksys_putpixel,12 ;arg1 - x ;arg2 - y ;arg3 - color diff --git a/programs/develop/metcc/trunk/libc/mesys/process.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/process.asm similarity index 57% rename from programs/develop/metcc/trunk/libc/mesys/process.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/process.asm index 95c68ce3b2..cbff86911e 100644 --- a/programs/develop/metcc/trunk/libc/mesys/process.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/process.asm @@ -1,13 +1,16 @@ format ELF -include "public_stdcall.inc" +;include "public_stdcall.inc" + +public _ksys_get_process_table + section '.text' executable -public_stdcall _msys_get_process_table,8 + +_ksys_get_process_table: ;arg1 - pointer to information ;arg2 - pid - mov edx,ebx mov eax,9 mov ebx,[esp+4] mov ecx,[esp+8] int 0x40 - mov ebx,edx + ret 8 \ No newline at end of file diff --git a/programs/develop/metcc/trunk/libc/mesys/screen.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/screen.asm similarity index 81% rename from programs/develop/metcc/trunk/libc/mesys/screen.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/screen.asm index 8e63f2280b..cec12f4e34 100644 --- a/programs/develop/metcc/trunk/libc/mesys/screen.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/screen.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_get_screen_size,8 +public_stdcall _ksys_get_screen_size,8 ;arg1 - x ;arg2 - y mov eax,14 diff --git a/programs/develop/ktcc/trunk/libc/kolibrisys/skin.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/skin.asm new file mode 100644 index 0000000000..fc31bff852 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/skin.asm @@ -0,0 +1,13 @@ +format ELF + +section '.text' executable + +public _ksys_get_skin_height + +_ksys_get_skin_height: + + mov eax,48 + mov ebx,4 + int 0x40 + + ret \ No newline at end of file diff --git a/programs/develop/metcc/trunk/libc/mesys/sound.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/sound.asm similarity index 72% rename from programs/develop/metcc/trunk/libc/mesys/sound.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/sound.asm index 96cb8e3f39..209ba5b23f 100644 --- a/programs/develop/metcc/trunk/libc/mesys/sound.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/sound.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_sound_load_block,4 +public_stdcall _ksy_sound_load_block,4 ;arg1 - blockptr mov edx,ebx mov eax,55 @@ -11,7 +11,7 @@ public_stdcall _msys_sound_load_block,4 mov ebx,edx ret 4 -public_stdcall _msys_sound_play_block,0 +public_stdcall _ksy_sound_play_block,0 mov edx,ebx mov eax,55 xor ebx,ebx @@ -20,7 +20,7 @@ public_stdcall _msys_sound_play_block,0 mov ebx,edx ret -public_stdcall _msys_sound_set_channels,4 +public_stdcall _ksy_sound_set_channels,4 ;arg1 - channels push ebx mov eax,55 @@ -31,7 +31,7 @@ public_stdcall _msys_sound_set_channels,4 pop ebx ret 4 -public_stdcall _msys_sound_set_data_size,4 +public_stdcall _ksy_sound_set_data_size,4 ;arg1 - data size push ebx mov eax,55 @@ -43,7 +43,7 @@ public_stdcall _msys_sound_set_data_size,4 pop ebx ret 4 -public_stdcall _msys_sound_set_frequency,4 +public_stdcall _ksy_sound_set_frequency,4 ;arg1 - frequency push ebx mov eax,55 @@ -54,7 +54,7 @@ public_stdcall _msys_sound_set_frequency,4 pop ebx ret 4 -public_stdcall _msys_sound_speaker_play,4 +public_stdcall _ksy_sound_speaker_play,4 ;arg1 - data mov edx,ebx mov eax,55 diff --git a/programs/develop/metcc/trunk/libc/mesys/thread.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/thread.asm similarity index 88% rename from programs/develop/metcc/trunk/libc/mesys/thread.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/thread.asm index 2e3f546e15..12e1bc3886 100644 --- a/programs/develop/metcc/trunk/libc/mesys/thread.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/thread.asm @@ -2,7 +2,7 @@ format ELF include "public_stdcall.inc" section '.text' executable extrn malloc -public_stdcall _msys_start_thread,12 +public_stdcall _ksys_start_thread,12 ;arg1 - proc ;arg2 - stacksize ;arg3 - pid diff --git a/programs/develop/metcc/trunk/libc/mesys/window_redraw.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/window_redraw.asm similarity index 78% rename from programs/develop/metcc/trunk/libc/mesys/window_redraw.asm rename to programs/develop/ktcc/trunk/libc/kolibrisys/window_redraw.asm index 35981880a8..226ed18585 100644 --- a/programs/develop/metcc/trunk/libc/mesys/window_redraw.asm +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/window_redraw.asm @@ -1,7 +1,7 @@ format ELF include "public_stdcall.inc" section '.text' executable -public_stdcall _msys_window_redraw,4 +public_stdcall _ksys_window_redraw,4 ;arg1 - status mov edx,ebx mov eax,12 diff --git a/programs/develop/ktcc/trunk/libc/kolibrisys/write_text.asm b/programs/develop/ktcc/trunk/libc/kolibrisys/write_text.asm new file mode 100644 index 0000000000..db97c6c4ab --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/kolibrisys/write_text.asm @@ -0,0 +1,21 @@ +format ELF +section '.text' executable +public _ksys_write_text + +_ksys_write_text: +;arg1 - x +;arg2 - y +;arg3 - color +;arg4 - text +;arg5 - len + + mov eax,4 + mov ebx,[esp+4] + shl ebx,16 + mov bx,[esp+8] + mov ecx,[esp+12] + mov edx,[esp+16] + mov esi,[esp+20] + int 0x40 + + ret 20 \ No newline at end of file diff --git a/programs/develop/metcc/trunk/libc/makefile b/programs/develop/ktcc/trunk/libc/makefile similarity index 77% rename from programs/develop/metcc/trunk/libc/makefile rename to programs/develop/ktcc/trunk/libc/makefile index 782eac7055..178c94316c 100644 --- a/programs/develop/metcc/trunk/libc/makefile +++ b/programs/develop/ktcc/trunk/libc/makefile @@ -1,8 +1,9 @@ INCLUDE = include -LIBNAME = melibc.a +LIBSFORBUILD = math +LIBNAME = libck.a CC = gcc -CFLAGS = -I$(INCLUDE) -nostdinc -DGNUC -DIRS := file mesys string mem +CFLAGS = -I$(INCLUDE) -nostdinc -DGNUC -L./ -lm +DIRS := stdio kolibrisys string stdlib memory math ############################################################## #files := $(foreach dir,$(DIRS),$(dir)/$(wildcard $(dir)/*)) diff --git a/programs/develop/ktcc/trunk/libc/memory/memalloc.asm b/programs/develop/ktcc/trunk/libc/memory/memalloc.asm new file mode 100644 index 0000000000..a60cb0dfb0 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/memory/memalloc.asm @@ -0,0 +1,38 @@ +format ELF + +;include "proc32.inc" +section '.text' executable +public malloc +public free +public realloc + +align 4 +malloc: + + mov eax,68 + mov ebx,12 + mov ecx,[esp+4] ;size + int 0x40 + + ret 4 + +align 4 +free: + + mov eax,68 + mov ebx,13 + mov ecx,[esp+4] + int 0x40 + + ret 4 + +align 4 +realloc: + + mov ebx,20 + mov eax,68 + mov ecx,[esp+4] + mov edx,[esp+8] + int 0x40 + + ret 8 diff --git a/programs/develop/metcc/trunk/libc/proc32.inc b/programs/develop/ktcc/trunk/libc/proc32.inc similarity index 100% rename from programs/develop/metcc/trunk/libc/proc32.inc rename to programs/develop/ktcc/trunk/libc/proc32.inc diff --git a/programs/develop/metcc/trunk/libc/public_stdcall.inc b/programs/develop/ktcc/trunk/libc/public_stdcall.inc similarity index 100% rename from programs/develop/metcc/trunk/libc/public_stdcall.inc rename to programs/develop/ktcc/trunk/libc/public_stdcall.inc diff --git a/programs/develop/metcc/trunk/libc/start/debug-fdo.inc b/programs/develop/ktcc/trunk/libc/start/debug-fdo.inc similarity index 100% rename from programs/develop/metcc/trunk/libc/start/debug-fdo.inc rename to programs/develop/ktcc/trunk/libc/start/debug-fdo.inc diff --git a/programs/develop/metcc/trunk/libc/start/macros.inc b/programs/develop/ktcc/trunk/libc/start/macros.inc similarity index 100% rename from programs/develop/metcc/trunk/libc/start/macros.inc rename to programs/develop/ktcc/trunk/libc/start/macros.inc diff --git a/programs/develop/metcc/trunk/libc/start/start.asm b/programs/develop/ktcc/trunk/libc/start/start.asm similarity index 100% rename from programs/develop/metcc/trunk/libc/start/start.asm rename to programs/develop/ktcc/trunk/libc/start/start.asm diff --git a/programs/develop/metcc/trunk/libc/file/fclose.c b/programs/develop/ktcc/trunk/libc/stdio/fclose.c similarity index 100% rename from programs/develop/metcc/trunk/libc/file/fclose.c rename to programs/develop/ktcc/trunk/libc/stdio/fclose.c diff --git a/programs/develop/metcc/trunk/libc/file/feof.c b/programs/develop/ktcc/trunk/libc/stdio/feof.c similarity index 100% rename from programs/develop/metcc/trunk/libc/file/feof.c rename to programs/develop/ktcc/trunk/libc/stdio/feof.c diff --git a/programs/develop/metcc/trunk/libc/file/fflush.c b/programs/develop/ktcc/trunk/libc/stdio/fflush.c similarity index 100% rename from programs/develop/metcc/trunk/libc/file/fflush.c rename to programs/develop/ktcc/trunk/libc/stdio/fflush.c diff --git a/programs/develop/metcc/trunk/libc/file/fgetc.c b/programs/develop/ktcc/trunk/libc/stdio/fgetc.c similarity index 100% rename from programs/develop/metcc/trunk/libc/file/fgetc.c rename to programs/develop/ktcc/trunk/libc/stdio/fgetc.c diff --git a/programs/develop/metcc/trunk/libc/file/fgetpos.c b/programs/develop/ktcc/trunk/libc/stdio/fgetpos.c similarity index 75% rename from programs/develop/metcc/trunk/libc/file/fgetpos.c rename to programs/develop/ktcc/trunk/libc/stdio/fgetpos.c index f0ec1b23f6..c04df6bfb9 100644 --- a/programs/develop/metcc/trunk/libc/file/fgetpos.c +++ b/programs/develop/ktcc/trunk/libc/stdio/fgetpos.c @@ -1,4 +1,4 @@ -#include "stdio.h" +#include int fgetpos(FILE* file,fpos_t* pos) { *pos=file->filepos; diff --git a/programs/develop/metcc/trunk/libc/file/fopen.c b/programs/develop/ktcc/trunk/libc/stdio/fopen.c similarity index 95% rename from programs/develop/metcc/trunk/libc/file/fopen.c rename to programs/develop/ktcc/trunk/libc/stdio/fopen.c index 4a2ab8135e..6697de3c6a 100644 --- a/programs/develop/metcc/trunk/libc/file/fopen.c +++ b/programs/develop/ktcc/trunk/libc/stdio/fopen.c @@ -5,7 +5,7 @@ extern char __argv; extern char __path; -char* getfullpath(const char *path){ +const char* getfullpath(const char *path){ int i,j,relpath_pos,localpath_size; int filename_size; diff --git a/programs/develop/ktcc/trunk/libc/stdio/format_print.c b/programs/develop/ktcc/trunk/libc/stdio/format_print.c new file mode 100644 index 0000000000..7e78b13ecd --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/stdio/format_print.c @@ -0,0 +1,729 @@ +/* + function for format output to the string +*/ + +#include +#include +#include +//#include +#include + +int formatted_double_to_string(long double number,int format1,int format2,char *s) +{ + double n; + double nbefor; + double nafter; + double v,v2; + long intdigit; + long beforpointdigit; + long div; + int i; + int pos; + int size; + int fmt1; + int fmt2; + long mul; + char buf[200]; + + size=(int)s; + n=(double)number; + if (n<0) {*s='-';s++;n=-n;} + + fmt1=format1; + fmt2=format2; + if (fmt2>18) {fmt2=18;} //maximum of size long long type + + //clear array befor output + for(i=0;i<=200;i++) {buf[i]=0;} + + if ((fmt1>=0) && (n<1)) + { //formatted output if 0<=n<1 + mul=1; + for(i=0;i=0) && (buf[i]<=9)) {*s='0'+buf[i];} + else {*s='0';} + s++; + } + } + else + { //if n>=1 + //v=floorf(n+0.00000000000001); + beforpointdigit=floor(n+0.00000000000001); + //beforpointdigit=n; + nbefor=beforpointdigit; + nafter=n-nbefor; + + //print part of number befor point + mul=1; + for(i=0;i<200-2;i++) + { + mul=mul*10; + if ((beforpointdigit/mul)==0) {fmt1=i+1;break;} + } + + pos=0; + mul=mul/10; + for(i=0;i=0) && (buf[i]<=9)) {*s='0'+buf[i];} + s++; + } + + //print part of number after point + mul=1; + for(i=0;i=0) && (buf[i]<=9)) {*s='0'+buf[i];} + else {*s='0';} + s++; + } + + } + size=(int)s-size; + return(size); +} + +int formatted_long_to_string(long long number,int fmt1,char *s) +{ + int i; + int pos; + int fmt; + int size; + int difference_pos; + long digit; + long mul; + long div; + char buf[200]; + + //clear array befor output + for(i=0;i<200;i++) {buf[i]=0;} + digit=number; + + size=(int)s; + if (digit<0) {*s='-';s++;digit=-digit;} + if (digit==0) {*s='0';s++;goto end;} + + mul=1; + for(i=0;i<200-2;i++) + { + mul=mul*10; + if ((digit/mul)==0) {fmt=i+1;break;} + } + + difference_pos=i+1; + + pos=0; + mul=mul/10; + for(i=0;i=difference_pos) fmt=fmt1; + else + fmt=difference_pos; + + for(i=0;i=0) && (buf[i]<=9)) {*s='0'+buf[i];} + } + else + { + *s=' '; + } + s++; + } + end: + size=(int)s-size; + return(size); +} + +int formatted_hex_to_string(long long number,int fmt1,char flag_register,char *s) +{ + long n; + int i,pos; + int fmt; + long size; + int difference_pos; + char xdigs_lower[16]="0123456789abcdef"; + char xdigs_upper[16]="0123456789ABCDEF"; + char buf[200]; + + n=(long)number; + size=(int)s; + if (n<0) {*s='-';s++;n=-n;} + + if (n==0) {*s='0';s++;goto end;} + for(i=0;i<200;i++) {buf[i]=0;} + + i=0; + if (flag_register==0) + { + while (n>0) + { + buf[i]=xdigs_lower[n & 15]; + n=n>>4; + i++; + } + } + else + { + while (n>0) + { + buf[i]=xdigs_upper[n & 15]; + n=n>>4; + i++; + } + } + + pos=i; + difference_pos=i; + + for(i=pos-1;i>=0;i--) + { + *s=buf[i]; + s++; + } + + if (fmt1-difference_pos>0) + { + for(i=difference_pos+1;i<=fmt1;i++) + { + *s=' '; + s++; + } + } + end:size=(int)s-size; + return(size); +} + +int formatted_octa_to_string(long long number,int fmt1,char flag_register,char *s) +{ + long n; + int i,pos; + int fmt; + long size; + int difference_pos; + char xdigs_lower[16]="012345678"; + char buf[200]; + + n=number; + size=(int)s; + if (n<0) {*s='-';s++;n=-n;} + + if (n==0) {*s='0';s++;goto end;} + for(i=0;i<200;i++) {buf[i]=0;} + + i=0; + if (flag_register==0) + { + while (n>0) + { + buf[i]=xdigs_lower[n & 7]; + n=n>>3; + i++; + } + } + + pos=i; + difference_pos=i; + + for(i=pos-1;i>=0;i--) + { + *s=buf[i]; + s++; + } + + if (fmt1-difference_pos>0) + { + for(i=difference_pos+1;i<=fmt1;i++) + { + *s=' '; + s++; + } + } + end:size=(int)s-size; + return(size); +} + +int format_print(char *dest, size_t maxlen,const char *fmt0, va_list argp) +{ + int i,j,k; + int length; + int fmt1,fmt2,stepen; + size_t pos,posc; + long long intdigit; + long double doubledigit; + float floatdigit; + const char *fmt,*fmtc; + char *s; + char *str; + char buffmt1[30]; + char buffmt2[30]; + char buf[1024]; + char format_flag; + char flag_point; + char flag_noformat; + char flag_long; + char flag_unsigned; + char flag_register; + char flag_plus; + + fmt=fmt0; + s=dest; + pos=0; + while(pos0) && (flag_plus==1) && (pos+1=0;i--) + { + fmt1=fmt1+buffmt1[i]*stepen; + stepen=stepen*10; + } + stepen=1; + for(i=k-1;i>=0;i--) + { + fmt2=fmt2+buffmt2[i]*stepen; + stepen=stepen*10; + } + switch(*fmtc) + { + case 'f': + case 'F': + if (flag_long==0) {doubledigit=va_arg(argp,double);} + if (flag_long>=1) {doubledigit=va_arg(argp,long double);} + //doubledigit=*((double *)argp); + //sargp=argp+8; + length=formatted_double_to_string(doubledigit,fmt1,fmt2,buf); + if ((pos+length)0) && (flag_plus==1) && (pos+1 + +int format_print(char *dest, size_t maxlen, const char *fmt,va_list argp); + +int fprintf(FILE* file, const char* format, ...) +{ +va_list arg; +char *buf; +int printed; +//int data[4]; + + va_start (arg, format); + buf=malloc(4096*2); //8kb max + //data[0]=(int)&arg-(int)&format; + + printed=format_print(buf,8191, format,arg); + fwrite(buf,printed,1,file); + free(buf); + + return(printed); +} diff --git a/programs/develop/metcc/trunk/libc/file/fputc.c b/programs/develop/ktcc/trunk/libc/stdio/fputc.c similarity index 93% rename from programs/develop/metcc/trunk/libc/file/fputc.c rename to programs/develop/ktcc/trunk/libc/stdio/fputc.c index dd0c7adda9..db8e02cd1f 100644 --- a/programs/develop/metcc/trunk/libc/file/fputc.c +++ b/programs/develop/ktcc/trunk/libc/stdio/fputc.c @@ -1,4 +1,4 @@ -#include "stdio.h" +#include int fputc(int c,FILE* file) { dword res; diff --git a/programs/develop/metcc/trunk/libc/file/fread.c b/programs/develop/ktcc/trunk/libc/stdio/fread.c similarity index 77% rename from programs/develop/metcc/trunk/libc/file/fread.c rename to programs/develop/ktcc/trunk/libc/stdio/fread.c index 8ac8d97ffe..3d2d2bf82c 100644 --- a/programs/develop/metcc/trunk/libc/file/fread.c +++ b/programs/develop/ktcc/trunk/libc/stdio/fread.c @@ -1,11 +1,12 @@ #include -#include +#include + int fread(void *buffer,int size,int count,FILE* file) { dword res; dword fullsize; - if ((file->mode & 3!=FILE_OPEN_READ) && (file->mode & FILE_OPEN_PLUS==0)) return 0; + if ((file->mode!=FILE_OPEN_READ) || (file->mode==FILE_OPEN_PLUS)) return 0; fullsize=count*size; if ((fullsize+file->filepos)>(file->filesize)) diff --git a/programs/develop/metcc/trunk/libc/file/fscanf.c b/programs/develop/ktcc/trunk/libc/stdio/fscanf.c similarity index 92% rename from programs/develop/metcc/trunk/libc/file/fscanf.c rename to programs/develop/ktcc/trunk/libc/stdio/fscanf.c index 91e3961425..f572f9bc00 100644 --- a/programs/develop/metcc/trunk/libc/file/fscanf.c +++ b/programs/develop/ktcc/trunk/libc/stdio/fscanf.c @@ -1,4 +1,4 @@ -#include "stdio.h" +#include void skipspaces(FILE* file) { int c; diff --git a/programs/develop/metcc/trunk/libc/file/fseek.c b/programs/develop/ktcc/trunk/libc/stdio/fseek.c similarity index 88% rename from programs/develop/metcc/trunk/libc/file/fseek.c rename to programs/develop/ktcc/trunk/libc/stdio/fseek.c index d65a80bcae..1686904b32 100644 --- a/programs/develop/metcc/trunk/libc/file/fseek.c +++ b/programs/develop/ktcc/trunk/libc/stdio/fseek.c @@ -1,4 +1,4 @@ -#include "stdio.h" +#include int fseek(FILE* file,long offset,int origin) { if (origin==SEEK_CUR) diff --git a/programs/develop/metcc/trunk/libc/file/fsetpos.c b/programs/develop/ktcc/trunk/libc/stdio/fsetpos.c similarity index 80% rename from programs/develop/metcc/trunk/libc/file/fsetpos.c rename to programs/develop/ktcc/trunk/libc/stdio/fsetpos.c index 0f08c38dc1..0c2d624e83 100644 --- a/programs/develop/metcc/trunk/libc/file/fsetpos.c +++ b/programs/develop/ktcc/trunk/libc/stdio/fsetpos.c @@ -1,4 +1,4 @@ -#include "stdio.h" +#include int fsetpos(FILE* file,const fpos_t * pos) { if (*pos>=0) diff --git a/programs/develop/metcc/trunk/libc/file/ftell.c b/programs/develop/ktcc/trunk/libc/stdio/ftell.c similarity index 68% rename from programs/develop/metcc/trunk/libc/file/ftell.c rename to programs/develop/ktcc/trunk/libc/stdio/ftell.c index 3553ed829b..20500a9db7 100644 --- a/programs/develop/metcc/trunk/libc/file/ftell.c +++ b/programs/develop/ktcc/trunk/libc/stdio/ftell.c @@ -1,4 +1,4 @@ -#include "stdio.h" +#include long ftell(FILE* file) { return file->filepos; diff --git a/programs/develop/metcc/trunk/libc/file/fwrite.c b/programs/develop/ktcc/trunk/libc/stdio/fwrite.c similarity index 77% rename from programs/develop/metcc/trunk/libc/file/fwrite.c rename to programs/develop/ktcc/trunk/libc/stdio/fwrite.c index e477201330..5d498206cd 100644 --- a/programs/develop/metcc/trunk/libc/file/fwrite.c +++ b/programs/develop/ktcc/trunk/libc/stdio/fwrite.c @@ -1,20 +1,21 @@ #include -#include +#include int fwrite(void *buffer,int size,int count,FILE* file) { dword res; dword fullsize; - if ((file->mode & 3==FILE_OPEN_READ) && (file->mode & FILE_OPEN_PLUS==0)) return 0; + if (file->mode==FILE_OPEN_READ) return 0; - if (file->mode & 3==FILE_OPEN_APPEND) + if (file->mode==FILE_OPEN_APPEND) file->filepos=file->filesize; fullsize=count*size; if ((file->filesize)<(file->filepos+fullsize)) file->filesize=file->filepos+fullsize; - if (file->mode & 3==FILE_OPEN_APPEND) + /* + if (file->mode==FILE_OPEN_APPEND) { file->filepos==file->filesize; res=_ksys_appendtofile(file->filename,file->filepos,fullsize,buffer); @@ -27,8 +28,8 @@ int fwrite(void *buffer,int size,int count,FILE* file) else return(0); } - - if (file->mode & 3==FILE_OPEN_WRITE) + */ + if ((file->mode==FILE_OPEN_WRITE) || (file->mode==FILE_OPEN_APPEND)) { if (file->filepos==0) { //file mot craeted yet diff --git a/programs/develop/ktcc/trunk/libc/stdio/printf.c b/programs/develop/ktcc/trunk/libc/stdio/printf.c new file mode 100644 index 0000000000..da3037b86d --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/stdio/printf.c @@ -0,0 +1,75 @@ + +#include +#include +#include + +char* dllname="/sys/lib/console.obj"; +int console_init_status; + +char* imports[] = {"START","version","con_init","con_write_asciiz","con_printf","con_exit",NULL}; +char* caption = "Console test - colors"; + +dword* dll_ver; +void stdcall (* con_init)(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title); +void stdcall (* con_write_asciiz)(const char* string); +void cdecl (* con_printf)(const char* format,...); +void stdcall (* con_exit)(dword bCloseWindow); + +struct import{ + char *name; + void *data; +}; + +void printf_link(struct import *exp, char** imports){ + + dll_ver = (dword*) + _ksys_cofflib_getproc(exp, imports[1]); + con_init = (void stdcall (*)(dword , dword, dword, dword, const char*)) + _ksys_cofflib_getproc(exp, imports[2]); + con_printf = (void cdecl (*)(const char*,...)) + _ksys_cofflib_getproc(exp, imports[4]); + con_exit = (void stdcall (*)(dword)) + _ksys_cofflib_getproc(exp, imports[5]); +} + +int init_console(void) +{ + struct import * hDll; + + if((hDll = (struct import *)_ksys_cofflib_load(dllname)) == 0){ + debug_out_str("can't load lib\n"); + return 1; + } + printf_link(hDll, imports); + debug_out_str("dll loaded\n"); + + con_init(-1, -1, -1, -1, caption); + return(0); +} + +int printf(const char *format,...) +{ + int i; + int printed_simbols; + va_list arg; + char simbol[]={"%s"}; + char *s; + + va_start(arg,format); + + if (console_init_status==0) + { + i=init_console(); + console_init_status=1; + } + + if (i==0) + { + s=malloc(4096); + printed_simbols=format_print(s,4096,format,arg); + con_printf(simbol,s); + free(s); + } + return(printed_simbols); +} + diff --git a/programs/develop/metcc/trunk/libc/file/rewind.c b/programs/develop/ktcc/trunk/libc/stdio/rewind.c similarity index 66% rename from programs/develop/metcc/trunk/libc/file/rewind.c rename to programs/develop/ktcc/trunk/libc/stdio/rewind.c index 1ae3054570..4b2f4a1eb3 100644 --- a/programs/develop/metcc/trunk/libc/file/rewind.c +++ b/programs/develop/ktcc/trunk/libc/stdio/rewind.c @@ -1,4 +1,4 @@ -#include "stdio.h" +#include void rewind(FILE* file) { file->filepos=0; diff --git a/programs/develop/ktcc/trunk/libc/stdio/snprintf.c b/programs/develop/ktcc/trunk/libc/stdio/snprintf.c new file mode 100644 index 0000000000..5e2e6527dd --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/stdio/snprintf.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int format_print(char *dest, size_t maxlen, const char *fmt,va_list argp); + + +int snprintf(char *dest, size_t size,const char *format,...) +{ + va_list arg; + va_start (arg, format); + return format_print(dest,size, format, arg); +} + + diff --git a/programs/develop/ktcc/trunk/libc/stdio/sprintf.c b/programs/develop/ktcc/trunk/libc/stdio/sprintf.c new file mode 100644 index 0000000000..30ebadf9a2 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/stdio/sprintf.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int format_print(char *dest, size_t maxlen, const char *fmt,va_list argp); + + +int sprintf(char *dest,const char *format,...) +{ + va_list arg; + va_start (arg, format); + return format_print(dest,4096, format, arg); +} + + diff --git a/programs/develop/ktcc/trunk/libc/stdio/vsnprintf.c b/programs/develop/ktcc/trunk/libc/stdio/vsnprintf.c new file mode 100644 index 0000000000..59515649cd --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/stdio/vsnprintf.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int format_print(char *dest, size_t maxlen, const char *fmt, + va_list argp); + + +int vsnprintf(char *dest, size_t size,const char *format,va_list ap) +{ + + return format_print(dest,size, format, ap); +} + + diff --git a/programs/develop/metcc/trunk/libc/string/atoi.c b/programs/develop/ktcc/trunk/libc/stdlib/atoi.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/atoi.c rename to programs/develop/ktcc/trunk/libc/stdlib/atoi.c diff --git a/programs/develop/metcc/trunk/libc/string/atoib.cpp b/programs/develop/ktcc/trunk/libc/stdlib/atoib.cpp similarity index 100% rename from programs/develop/metcc/trunk/libc/string/atoib.cpp rename to programs/develop/ktcc/trunk/libc/stdlib/atoib.cpp diff --git a/programs/develop/metcc/trunk/libc/string/itoa.c b/programs/develop/ktcc/trunk/libc/stdlib/itoa.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/itoa.c rename to programs/develop/ktcc/trunk/libc/stdlib/itoa.c diff --git a/programs/develop/metcc/trunk/libc/string/itoab.c b/programs/develop/ktcc/trunk/libc/stdlib/itoab.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/itoab.c rename to programs/develop/ktcc/trunk/libc/stdlib/itoab.c diff --git a/programs/develop/metcc/trunk/libc/string/tolower.c b/programs/develop/ktcc/trunk/libc/stdlib/tolower.c similarity index 70% rename from programs/develop/metcc/trunk/libc/string/tolower.c rename to programs/develop/ktcc/trunk/libc/stdlib/tolower.c index 17945ad07b..824cd9e06d 100644 --- a/programs/develop/metcc/trunk/libc/string/tolower.c +++ b/programs/develop/ktcc/trunk/libc/stdlib/tolower.c @@ -1,7 +1,7 @@ /* ** return lower-case of c if upper-case, else c */ -char tolower(char c) +unsigned char tolower(unsigned char c) { if(c<='Z' && c>='A') return (c+32); return (c); diff --git a/programs/develop/metcc/trunk/libc/string/toupper.c b/programs/develop/ktcc/trunk/libc/stdlib/toupper.c similarity index 71% rename from programs/develop/metcc/trunk/libc/string/toupper.c rename to programs/develop/ktcc/trunk/libc/stdlib/toupper.c index a8b1becdc6..4139326256 100644 --- a/programs/develop/metcc/trunk/libc/string/toupper.c +++ b/programs/develop/ktcc/trunk/libc/stdlib/toupper.c @@ -1,7 +1,7 @@ /* ** return upper-case of c if it is lower-case, else c */ -char toupper(char c) +unsigned char toupper(unsigned char c) { if(c<='z' && c>='a') return (c-32); return (c); diff --git a/programs/develop/metcc/trunk/libc/string/is.c b/programs/develop/ktcc/trunk/libc/string/is.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/is.c rename to programs/develop/ktcc/trunk/libc/string/is.c diff --git a/programs/develop/metcc/trunk/libc/string/memchr.c b/programs/develop/ktcc/trunk/libc/string/memchr.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/memchr.c rename to programs/develop/ktcc/trunk/libc/string/memchr.c diff --git a/programs/develop/metcc/trunk/libc/string/memcmp.c b/programs/develop/ktcc/trunk/libc/string/memcmp.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/memcmp.c rename to programs/develop/ktcc/trunk/libc/string/memcmp.c diff --git a/programs/develop/ktcc/trunk/libc/string/memmove.asm b/programs/develop/ktcc/trunk/libc/string/memmove.asm new file mode 100644 index 0000000000..f7f25dd344 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/string/memmove.asm @@ -0,0 +1,35 @@ +format ELF + +section '.text' executable +include 'proc32.inc' + +public memcpy +public memmove + +proc memcpy stdcall, to:dword,from:dword,count:dword + + mov ecx,[count] + test ecx,ecx + jz no_copy_block + + mov esi,[from] + mov edi,[to] + rep movsb + no_copy_block: + + ret +endp + +proc memmove stdcall, to:dword,from:dword,count:dword + + mov ecx,[count] + test ecx,ecx + jz no_copy_block_ + + mov esi,[from] + mov edi,[to] + rep movsb + no_copy_block_: + + ret +endp \ No newline at end of file diff --git a/programs/develop/metcc/trunk/libc/string/memset.asm b/programs/develop/ktcc/trunk/libc/string/memset.asm similarity index 100% rename from programs/develop/metcc/trunk/libc/string/memset.asm rename to programs/develop/ktcc/trunk/libc/string/memset.asm diff --git a/programs/develop/metcc/trunk/libc/string/strcat.c b/programs/develop/ktcc/trunk/libc/string/strcat.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strcat.c rename to programs/develop/ktcc/trunk/libc/string/strcat.c diff --git a/programs/develop/metcc/trunk/libc/string/strchr.c b/programs/develop/ktcc/trunk/libc/string/strchr.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strchr.c rename to programs/develop/ktcc/trunk/libc/string/strchr.c diff --git a/programs/develop/metcc/trunk/libc/string/strcmp.c b/programs/develop/ktcc/trunk/libc/string/strcmp.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strcmp.c rename to programs/develop/ktcc/trunk/libc/string/strcmp.c diff --git a/programs/develop/metcc/trunk/libc/string/strcoll.c b/programs/develop/ktcc/trunk/libc/string/strcoll.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strcoll.c rename to programs/develop/ktcc/trunk/libc/string/strcoll.c diff --git a/programs/develop/metcc/trunk/libc/string/strcpy.c b/programs/develop/ktcc/trunk/libc/string/strcpy.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strcpy.c rename to programs/develop/ktcc/trunk/libc/string/strcpy.c diff --git a/programs/develop/metcc/trunk/libc/string/strcspn.c b/programs/develop/ktcc/trunk/libc/string/strcspn.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strcspn.c rename to programs/develop/ktcc/trunk/libc/string/strcspn.c diff --git a/programs/develop/metcc/trunk/libc/string/strdup.c b/programs/develop/ktcc/trunk/libc/string/strdup.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strdup.c rename to programs/develop/ktcc/trunk/libc/string/strdup.c diff --git a/programs/develop/metcc/trunk/libc/string/strerror.c b/programs/develop/ktcc/trunk/libc/string/strerror.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strerror.c rename to programs/develop/ktcc/trunk/libc/string/strerror.c diff --git a/programs/develop/metcc/trunk/libc/string/strlen.c b/programs/develop/ktcc/trunk/libc/string/strlen.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strlen.c rename to programs/develop/ktcc/trunk/libc/string/strlen.c diff --git a/programs/develop/metcc/trunk/libc/string/strnbrk.c b/programs/develop/ktcc/trunk/libc/string/strnbrk.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strnbrk.c rename to programs/develop/ktcc/trunk/libc/string/strnbrk.c diff --git a/programs/develop/metcc/trunk/libc/string/strncat.c b/programs/develop/ktcc/trunk/libc/string/strncat.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strncat.c rename to programs/develop/ktcc/trunk/libc/string/strncat.c diff --git a/programs/develop/metcc/trunk/libc/string/strncmp.c b/programs/develop/ktcc/trunk/libc/string/strncmp.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strncmp.c rename to programs/develop/ktcc/trunk/libc/string/strncmp.c diff --git a/programs/develop/metcc/trunk/libc/string/strncpy.c b/programs/develop/ktcc/trunk/libc/string/strncpy.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strncpy.c rename to programs/develop/ktcc/trunk/libc/string/strncpy.c diff --git a/programs/develop/metcc/trunk/libc/string/strrchr.c b/programs/develop/ktcc/trunk/libc/string/strrchr.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strrchr.c rename to programs/develop/ktcc/trunk/libc/string/strrchr.c diff --git a/programs/develop/metcc/trunk/libc/string/strspn.c b/programs/develop/ktcc/trunk/libc/string/strspn.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strspn.c rename to programs/develop/ktcc/trunk/libc/string/strspn.c diff --git a/programs/develop/metcc/trunk/libc/string/strstr.c b/programs/develop/ktcc/trunk/libc/string/strstr.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strstr.c rename to programs/develop/ktcc/trunk/libc/string/strstr.c diff --git a/programs/develop/metcc/trunk/libc/string/strtok.c b/programs/develop/ktcc/trunk/libc/string/strtok.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strtok.c rename to programs/develop/ktcc/trunk/libc/string/strtok.c diff --git a/programs/develop/metcc/trunk/libc/string/strxfrm.c b/programs/develop/ktcc/trunk/libc/string/strxfrm.c similarity index 100% rename from programs/develop/metcc/trunk/libc/string/strxfrm.c rename to programs/develop/ktcc/trunk/libc/string/strxfrm.c diff --git a/programs/develop/metcc/trunk/readme.txt b/programs/develop/ktcc/trunk/readme.txt similarity index 100% rename from programs/develop/metcc/trunk/readme.txt rename to programs/develop/ktcc/trunk/readme.txt diff --git a/programs/develop/ktcc/trunk/samples/console/console.c b/programs/develop/ktcc/trunk/samples/console/console.c new file mode 100644 index 0000000000..3fb97386e8 --- /dev/null +++ b/programs/develop/ktcc/trunk/samples/console/console.c @@ -0,0 +1,70 @@ + +// Console dynamic link library. Sample by Ghost + +#include +#include +#include + +char* dllname="/sys/lib/console.obj"; +int i; + +char* imports[] = {"START","version","con_init","con_write_asciiz","con_printf","con_exit",NULL}; +char* caption = "Console test - colors"; + +dword (* dll_start)(dword res); +dword* dll_ver; +void stdcall (* con_init)(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title); +void stdcall (* con_write_asciiz)(const char* string); +void cdecl (* con_printf)(const char* format,...); +void stdcall (* con_exit)(dword bCloseWindow); + +struct import{ + char *name; + void *data; +}; + +void link(struct import *exp, char** imports){ + dll_start = (dword (*)(dword)) + _ksys_cofflib_getproc(exp, imports[0]); + dll_ver = (dword*) + _ksys_cofflib_getproc(exp, imports[1]); + con_init = (void stdcall (*)(dword , dword, dword, dword, const char*)) + _ksys_cofflib_getproc(exp, imports[2]); + con_write_asciiz = (void stdcall (*)(const char*)) + _ksys_cofflib_getproc(exp, imports[3]); + con_printf = (void cdecl (*)(const char*,...)) + _ksys_cofflib_getproc(exp, imports[4]); + con_exit = (void stdcall (*)(dword)) + _ksys_cofflib_getproc(exp, imports[5]); +} + +int main(int argc, char **argv){ + + struct import * hDll; + int a,b,c,d; + + if((hDll = (struct import *)_ksys_cofflib_load(dllname)) == 0){ + debug_out_str("can't load lib\n"); + return 1; + } + link(hDll, imports); + debug_out_str("dll loaded\n"); + + if(dll_start(1) == 0){ + debug_out_str("dll_start failed\n"); + return 1; + } + + con_init(-1, -1, -1, -1, caption); + + for(i = 0; i < 256; i++){ + con_printf("Color 0x%02X: ", i); + con_write_asciiz("Text sample."); + + con_printf(" printf %s test %d\n", "small", i); + + } + + con_exit(0); + debug_out_str("all right's ;)\n"); +} \ No newline at end of file diff --git a/programs/develop/metcc/trunk/samples/files/FILES.C b/programs/develop/ktcc/trunk/samples/files/FILES.C similarity index 100% rename from programs/develop/metcc/trunk/samples/files/FILES.C rename to programs/develop/ktcc/trunk/samples/files/FILES.C diff --git a/programs/develop/ktcc/trunk/samples/simple/simple.c b/programs/develop/ktcc/trunk/samples/simple/simple.c new file mode 100644 index 0000000000..63bf266186 --- /dev/null +++ b/programs/develop/ktcc/trunk/samples/simple/simple.c @@ -0,0 +1,61 @@ + +// simple sample by Ghost + +#include +#include +#include + +#define FONT0 0 +#define FONT1 0x10000000 + +#define BT_NORMAL 0 +#define BT_DEL 0x80000000 +#define BT_HIDE 0x40000000 +#define BT_NOFRAME 0x20000000 + +char header[]={" -= C demo programm. Compiled whith KTCC halyavin and andrew_programmer port =- "}; + +void rotate_str(char *str){ + char tmp; + int i; + tmp = str[0]; + for(i = 1; str[i]; i++)str[i - 1] = str[i]; + str[i - 1] = tmp; +} + +void draw_window(){ + static int offs = 0; + static int fcolor = 0; + static int col = 0; + + _ksys_window_redraw(1); + _ksys_draw_window(100, 100, 300, 120, 0xaabbcc, 2, 0x5080d0, 0, 0x5080d0); + _ksys_write_text(6 - offs, 8, fcolor | FONT0, header, strlen(header)); + _ksys_draw_bar(1, 6, 5, 13, 0x05080d0); + _ksys_draw_bar(274, 6, 26, 13, 0x05080d0); + _ksys_make_button(300 - 19, 5, 12, 12, 1 | BT_NORMAL, 0x6688dd); + _ksys_window_redraw(2); + + offs = (offs + 1) % 6; + if(!offs)rotate_str(header); + + fcolor += (col)?-0x80808:0x80808; + if(fcolor > 0xf80000 || fcolor == 0)col = !col; +} + +int main(int argc, char **argv){ + + while(!0){ + switch(_ksys_wait_for_event(10)){ + case 2:return 0; + + case 3: + if(_ksys_get_button_id() == 1)return 0; + break; + + default: + draw_window(); + break; + } + } +} diff --git a/programs/develop/metcc/trunk/source/COPYING b/programs/develop/ktcc/trunk/source/COPYING similarity index 100% rename from programs/develop/metcc/trunk/source/COPYING rename to programs/develop/ktcc/trunk/source/COPYING diff --git a/programs/develop/metcc/trunk/source/Makefile b/programs/develop/ktcc/trunk/source/Makefile similarity index 100% rename from programs/develop/metcc/trunk/source/Makefile rename to programs/develop/ktcc/trunk/source/Makefile diff --git a/programs/develop/metcc/trunk/source/VERSION b/programs/develop/ktcc/trunk/source/VERSION similarity index 100% rename from programs/develop/metcc/trunk/source/VERSION rename to programs/develop/ktcc/trunk/source/VERSION diff --git a/programs/develop/metcc/trunk/source/arm-gen.c b/programs/develop/ktcc/trunk/source/arm-gen.c similarity index 100% rename from programs/develop/metcc/trunk/source/arm-gen.c rename to programs/develop/ktcc/trunk/source/arm-gen.c diff --git a/programs/develop/metcc/trunk/source/bcheck.c b/programs/develop/ktcc/trunk/source/bcheck.c similarity index 100% rename from programs/develop/metcc/trunk/source/bcheck.c rename to programs/develop/ktcc/trunk/source/bcheck.c diff --git a/programs/develop/metcc/trunk/source/boundtest.c b/programs/develop/ktcc/trunk/source/boundtest.c similarity index 100% rename from programs/develop/metcc/trunk/source/boundtest.c rename to programs/develop/ktcc/trunk/source/boundtest.c diff --git a/programs/develop/metcc/trunk/source/c67-gen.c b/programs/develop/ktcc/trunk/source/c67-gen.c similarity index 100% rename from programs/develop/metcc/trunk/source/c67-gen.c rename to programs/develop/ktcc/trunk/source/c67-gen.c diff --git a/programs/develop/metcc/trunk/source/coff.h b/programs/develop/ktcc/trunk/source/coff.h similarity index 100% rename from programs/develop/metcc/trunk/source/coff.h rename to programs/develop/ktcc/trunk/source/coff.h diff --git a/programs/develop/metcc/trunk/source/config.h b/programs/develop/ktcc/trunk/source/config.h similarity index 100% rename from programs/develop/metcc/trunk/source/config.h rename to programs/develop/ktcc/trunk/source/config.h diff --git a/programs/develop/metcc/trunk/source/console.asm b/programs/develop/ktcc/trunk/source/console.asm similarity index 100% rename from programs/develop/metcc/trunk/source/console.asm rename to programs/develop/ktcc/trunk/source/console.asm diff --git a/programs/develop/metcc/trunk/source/elf.h b/programs/develop/ktcc/trunk/source/elf.h similarity index 100% rename from programs/develop/metcc/trunk/source/elf.h rename to programs/develop/ktcc/trunk/source/elf.h diff --git a/programs/develop/metcc/trunk/source/float.h b/programs/develop/ktcc/trunk/source/float.h similarity index 100% rename from programs/develop/metcc/trunk/source/float.h rename to programs/develop/ktcc/trunk/source/float.h diff --git a/programs/develop/metcc/trunk/source/i386-asm.c b/programs/develop/ktcc/trunk/source/i386-asm.c similarity index 100% rename from programs/develop/metcc/trunk/source/i386-asm.c rename to programs/develop/ktcc/trunk/source/i386-asm.c diff --git a/programs/develop/metcc/trunk/source/i386-asm.h b/programs/develop/ktcc/trunk/source/i386-asm.h similarity index 100% rename from programs/develop/metcc/trunk/source/i386-asm.h rename to programs/develop/ktcc/trunk/source/i386-asm.h diff --git a/programs/develop/metcc/trunk/source/i386-gen.c b/programs/develop/ktcc/trunk/source/i386-gen.c similarity index 100% rename from programs/develop/metcc/trunk/source/i386-gen.c rename to programs/develop/ktcc/trunk/source/i386-gen.c diff --git a/programs/develop/metcc/trunk/source/il-gen.c b/programs/develop/ktcc/trunk/source/il-gen.c similarity index 100% rename from programs/develop/metcc/trunk/source/il-gen.c rename to programs/develop/ktcc/trunk/source/il-gen.c diff --git a/programs/develop/metcc/trunk/source/il-opcodes.h b/programs/develop/ktcc/trunk/source/il-opcodes.h similarity index 100% rename from programs/develop/metcc/trunk/source/il-opcodes.h rename to programs/develop/ktcc/trunk/source/il-opcodes.h diff --git a/programs/develop/metcc/trunk/source/libtcc.h b/programs/develop/ktcc/trunk/source/libtcc.h similarity index 100% rename from programs/develop/metcc/trunk/source/libtcc.h rename to programs/develop/ktcc/trunk/source/libtcc.h diff --git a/programs/develop/metcc/trunk/source/libtcc1.c b/programs/develop/ktcc/trunk/source/libtcc1.c similarity index 100% rename from programs/develop/metcc/trunk/source/libtcc1.c rename to programs/develop/ktcc/trunk/source/libtcc1.c diff --git a/programs/develop/metcc/trunk/source/libtcc_test.c b/programs/develop/ktcc/trunk/source/libtcc_test.c similarity index 100% rename from programs/develop/metcc/trunk/source/libtcc_test.c rename to programs/develop/ktcc/trunk/source/libtcc_test.c diff --git a/programs/develop/metcc/trunk/source/stab.def b/programs/develop/ktcc/trunk/source/stab.def similarity index 100% rename from programs/develop/metcc/trunk/source/stab.def rename to programs/develop/ktcc/trunk/source/stab.def diff --git a/programs/develop/metcc/trunk/source/stab.h b/programs/develop/ktcc/trunk/source/stab.h similarity index 100% rename from programs/develop/metcc/trunk/source/stab.h rename to programs/develop/ktcc/trunk/source/stab.h diff --git a/programs/develop/metcc/trunk/source/start.asm b/programs/develop/ktcc/trunk/source/start.asm similarity index 100% rename from programs/develop/metcc/trunk/source/start.asm rename to programs/develop/ktcc/trunk/source/start.asm diff --git a/programs/develop/metcc/trunk/source/stdarg.h b/programs/develop/ktcc/trunk/source/stdarg.h similarity index 100% rename from programs/develop/metcc/trunk/source/stdarg.h rename to programs/develop/ktcc/trunk/source/stdarg.h diff --git a/programs/develop/metcc/trunk/source/stdbool.h b/programs/develop/ktcc/trunk/source/stdbool.h similarity index 100% rename from programs/develop/metcc/trunk/source/stdbool.h rename to programs/develop/ktcc/trunk/source/stdbool.h diff --git a/programs/develop/metcc/trunk/source/stddef.h b/programs/develop/ktcc/trunk/source/stddef.h similarity index 100% rename from programs/develop/metcc/trunk/source/stddef.h rename to programs/develop/ktcc/trunk/source/stddef.h diff --git a/programs/develop/metcc/trunk/source/tcc-doc.html b/programs/develop/ktcc/trunk/source/tcc-doc.html similarity index 100% rename from programs/develop/metcc/trunk/source/tcc-doc.html rename to programs/develop/ktcc/trunk/source/tcc-doc.html diff --git a/programs/develop/metcc/trunk/source/tcc.c b/programs/develop/ktcc/trunk/source/tcc.c similarity index 100% rename from programs/develop/metcc/trunk/source/tcc.c rename to programs/develop/ktcc/trunk/source/tcc.c diff --git a/programs/develop/metcc/trunk/source/tccasm.c b/programs/develop/ktcc/trunk/source/tccasm.c similarity index 100% rename from programs/develop/metcc/trunk/source/tccasm.c rename to programs/develop/ktcc/trunk/source/tccasm.c diff --git a/programs/develop/metcc/trunk/source/tcccoff.c b/programs/develop/ktcc/trunk/source/tcccoff.c similarity index 100% rename from programs/develop/metcc/trunk/source/tcccoff.c rename to programs/develop/ktcc/trunk/source/tcccoff.c diff --git a/programs/develop/metcc/trunk/source/tccelf.c b/programs/develop/ktcc/trunk/source/tccelf.c similarity index 100% rename from programs/develop/metcc/trunk/source/tccelf.c rename to programs/develop/ktcc/trunk/source/tccelf.c diff --git a/programs/develop/metcc/trunk/source/tcclib.h b/programs/develop/ktcc/trunk/source/tcclib.h similarity index 100% rename from programs/develop/metcc/trunk/source/tcclib.h rename to programs/develop/ktcc/trunk/source/tcclib.h diff --git a/programs/develop/metcc/trunk/source/tccmeos.c b/programs/develop/ktcc/trunk/source/tccmeos.c similarity index 100% rename from programs/develop/metcc/trunk/source/tccmeos.c rename to programs/develop/ktcc/trunk/source/tccmeos.c diff --git a/programs/develop/metcc/trunk/source/tccpe.c b/programs/develop/ktcc/trunk/source/tccpe.c similarity index 100% rename from programs/develop/metcc/trunk/source/tccpe.c rename to programs/develop/ktcc/trunk/source/tccpe.c diff --git a/programs/develop/metcc/trunk/source/tcctest.c b/programs/develop/ktcc/trunk/source/tcctest.c similarity index 100% rename from programs/develop/metcc/trunk/source/tcctest.c rename to programs/develop/ktcc/trunk/source/tcctest.c diff --git a/programs/develop/metcc/trunk/source/tcctok.h b/programs/develop/ktcc/trunk/source/tcctok.h similarity index 100% rename from programs/develop/metcc/trunk/source/tcctok.h rename to programs/develop/ktcc/trunk/source/tcctok.h diff --git a/programs/develop/metcc/trunk/source/tiny_impdef.c b/programs/develop/ktcc/trunk/source/tiny_impdef.c similarity index 100% rename from programs/develop/metcc/trunk/source/tiny_impdef.c rename to programs/develop/ktcc/trunk/source/tiny_impdef.c diff --git a/programs/develop/metcc/trunk/source/varargs.h b/programs/develop/ktcc/trunk/source/varargs.h similarity index 100% rename from programs/develop/metcc/trunk/source/varargs.h rename to programs/develop/ktcc/trunk/source/varargs.h diff --git a/programs/develop/metcc/trunk/libc/file/fprintf.c b/programs/develop/metcc/trunk/libc/file/fprintf.c deleted file mode 100644 index c1cd5348be..0000000000 --- a/programs/develop/metcc/trunk/libc/file/fprintf.c +++ /dev/null @@ -1,216 +0,0 @@ -#include "stdio.h" -const char xdigs_lower[16]="0123456789abcdef"; -const char xdigs_upper[16]="0123456789ABCDEF"; -int fprintf(FILE* file, const char* format, ...) -{ - void* arg; - int ispoint; - int beforepoint; - int afterpoint; - int longflag; - int contflag; - int i; - long long number; - char buffer[50]; - char* str; - arg=&format; - arg+=sizeof(const char*); - while (*format!='\0') - { - if (*format!='%') - { - fputc(*format,file); - format++; - continue; - } - ispoint=0; - beforepoint=0; - afterpoint=0; - longflag=0; - contflag=1; - format++; - while (*format && contflag) - { - switch (*format) - { - case '.': - ispoint=1; - format++; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (ispoint) - afterpoint=afterpoint*10+(*format)-'0'; - else - beforepoint=beforepoint*10+(*format)-'0'; - format++; - break; - case 'l': - if (longflag==0) - longflag=1; - else - longflag=2; - format++; - break; - case 'L': - longflag=2; - format++; - break; - case 'f': - case 'd': - case 'x': - case 'X': - case 'c': - case 's': - case '%': - contflag=0; - break; - default: - contflag=0; - } - } - if (contflag) - break; - switch (*format) - { - case '%': - fpuc('%',file); - break; - case 'd': - if (longflag==2) - { - number=*((long long *)arg); - arg+=sizeof(long long); - }else - { - number=*((int*)arg); - arg+=sizeof(int); - } - if (number<0) - { - beforepoint--; - fputc('-',file); - number=-number; - } - i=0; - while (number>0) - { - buffer[i]='0'+number%10; - number=number/10; - i++; - } - while (i0) - { - i--; - fputc(buffer[i],file); - } - break; - case 'c': - fputc(*(char*)arg,file); - arg+=sizeof(char); - break; - case 's': - str=*(char**)arg; - arg+=sizeof(char*); - if (beforepoint==0) - beforepoint--; - while (*str && beforepoint) - { - fputc(*str,file); - beforepoint--; - str++; - } - break; - case 'x': - if (longflag==2) - { - number=*((long long *)arg); - arg+=sizeof(long long); - }else - { - number=*((int*)arg); - arg+=sizeof(int); - } - if (number<0) - { - beforepoint--; - fputc('-',file); - number=-number; - } - i=0; - while (number>0) - { - buffer[i]=xdigs_lower[number & 15]; - number=number>>4; - i++; - } - while (i0) - { - i--; - fputc(buffer[i],file); - } - break; - case 'X': - if (longflag==2) - { - number=*((long long *)arg); - arg+=sizeof(long long); - }else - { - number=*((int*)arg); - arg+=sizeof(int); - } - if (number<0) - { - beforepoint--; - fputc('-',file); - number=-number; - } - i=0; - while (number>0) - { - buffer[i]=xdigs_upper[number & 15]; - number=number>>4; - i++; - } - while (i0) - { - i--; - fputc(buffer[i],file); - } - break; - case 'f': - if (longflag==2) - arg+=10; - else if (longflag==1) - arg+=8; - else - arg+=4; - break; - } - format++; - } -} diff --git a/programs/develop/metcc/trunk/libc/file/ungetc.c b/programs/develop/metcc/trunk/libc/file/ungetc.c deleted file mode 100644 index ef3222755b..0000000000 --- a/programs/develop/metcc/trunk/libc/file/ungetc.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "stdio.h" -int ungetc(int c,FILE* file) -{ - dword res; - - if (c==EOF) - return EOF; - if (file->filepos<=0 || file->filepos>file->filesize) - return EOF; - file->filepos--; - res=_ksys_readfile(file->filename,file->filepos,1,file->buffer); - if (res==0) - { - return(c); - } - else return(EOF); -} diff --git a/programs/develop/metcc/trunk/libc/include/mesys.h b/programs/develop/metcc/trunk/libc/include/mesys.h deleted file mode 100644 index 8eea5e6d09..0000000000 --- a/programs/develop/metcc/trunk/libc/include/mesys.h +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef mesys_h -#define mesys_h -/* -#ifdef GNUC -#define stdcall __stdcall -#define cdecl __cdecl -#else -#define stdcall ((__stdcall)) -#define cdecl ((__cdecl)) -#endif -*/ -//#ifdef GNUC -//#define stdcall __stdcall -//#else -#define stdcall __attribute__ (( )) -//#endif - -typedef unsigned int dword; -typedef unsigned char byte; -typedef unsigned short word; - -extern void stdcall _msys_draw_window(int xcoord,int ycoord, int xsize, - int ysize,int workcolor,int type, - int captioncolor,int windowtype,int bordercolor); - -//----------------------------------------------------------------------------------- -//------------------------KolibriOS system acces to files---------------------------- -//----------------------------------------------------------------------------------- -extern dword stdcall _ksys_get_filesize(char *filename); -extern dword stdcall _ksys_readfile(char *filename,dword pos,dword blocksize,void *data); -extern dword stdcall _ksys_rewritefile(char *filename,dword blocksize,void *data); -extern dword stdcall _ksys_appendtofile(char *filename,dword pos,dword blocksize,void *data); -//----------------------------------------------------------------------------------- - -extern void stdcall _msys_run_program(char* filename,char* parameters); -extern void stdcall _msys_debug_out(int c); -extern void debug_out_str(char* str); -extern void stdcall _msys_set_background_size(int xsize,int ysize); -extern void stdcall _msys_write_background_mem(int pos,int color); -extern void stdcall _msys_draw_background(void); -extern void stdcall _msys_set_background_draw_type(int type); -extern void stdcall _msys_background_blockmove(void* src,int bgr_pos, int count); -extern void stdcall _msys_draw_bar(int x, int y, int xsize, int ysize, int color); -extern void stdcall _msys_make_button(int x, int y, int xsize, int ysize, int id, int color); -extern int stdcall _msys_get_button_id(void); -extern int stdcall _msys_get_system_clock(void); -extern int stdcall _msys_get_date(void); -extern void stdcall _msys_delay(int m); -extern void stdcall _msys_dga_get_resolution(int* xres, int* yres, int* bpp, int* bpscan); -extern int stdcall _msys_wait_for_event_infinite(void); -extern int stdcall _msys_check_for_event(void); -extern int stdcall _msys_wait_for_event(int time); -extern void stdcall _msys_set_wanted_events(int ev); -extern void stdcall _msys_exit(void); -extern void stdcall _msys_putimage(int x, int y, int xsize, int ysize, void* image); -extern void stdcall _msys_send_message(int pid, void* msg, int size); -extern void stdcall _msys_define_receive_area(void* area, int size); -extern int stdcall _msys_get_irq_owner(int irq); -extern int stdcall _msys_get_data_read_by_irq(int irq, int* size, void* data); -extern int stdcall _msys_send_data_to_device(int port, unsigned char val); -extern int stdcall _msys_receive_data_from_device(int port,unsigned char* data); -extern void stdcall _msys_program_irq(void* intrtable, int irq); -extern void stdcall _msys_reserve_irq(int irq); -extern void stdcall _msys_free_irq(int irq); -extern int stdcall _msys_reserve_port_area(int start,int end); -extern int stdcall _msys_free_port_area(int start,int end); -extern int stdcall _msys_get_key(void); -extern void stdcall _msys_set_keyboard_mode(int mode); -extern void stdcall _msys_line(int x1,int y1,int x2,int y2,int color); -extern void stdcall _msys_midi_reset(void); -extern void stdcall _msys_midi_send(int data); -extern int stdcall _msys_get_pci_version(void); -extern int stdcall _msys_get_last_pci_bus(void); -extern int stdcall _msys_get_pci_access_mechanism(void); -extern int stdcall _msys_pci_read_config_byte(int bus,int dev,int fn,int reg); -extern int stdcall _msys_pci_read_config_word(int bus,int dev,int fn,int reg); -extern int stdcall _msys_pci_read_config_dword(int bus,int dev,int fn,int reg); -extern int stdcall _msys_pci_write_config_byte(int bus,int dev,int fn,int reg,int value); -extern int stdcall _msys_pci_write_config_word(int bus,int dev,int fn,int reg,int value); -extern int stdcall _msys_pci_write_config_value(int bus,int dev,int fn,int reg,int value); -extern int stdcall _msys_putpixel(int x,int y,int color); -#pragma pack(push,1) -typedef struct { - int cpu_usage; //+0 - int window_pos_info; //+4 - short int reserved1; //+8 - char name[12]; //+10 - int memstart; //+22 - int memused; //+26 - int pid; //+30 - int winx_start; //+34 - int winy_start; //+38 - int winx_size; //+42 - int winy_size; //+46 - short int slot_info; //+50 - short int reserved2; //+52 - int clientx; //+54 - int clienty; //+58 - int clientwidth; //+62 - int clientheight; //+66 - unsigned char window_state;//+70 - char reserved3[1024-71]; //+71 -} process_table_entry; -#pragma pack(pop) -extern int stdcall _msys_get_process_table(process_table_entry* proctab,int pid); -extern int stdcall _msys_get_screen_size(int* x,int* y); -extern void stdcall _msys_sound_load_block(void* blockptr); -extern void stdcall _msys_sound_play_block(void); -extern void stdcall _msys_sound_set_channels(int channels); -extern void stdcall _msys_sound_set_data_size(int size); -extern void stdcall _msys_sound_set_frequency(int frequency); -extern void stdcall _msys_sound_speaker_play(void* data); -extern void stdcall _msys_write_text(int x,int y,int color,char* text,int len); -extern void* stdcall _msys_start_thread(void (* func_ptr)(void),int stack_size,int* pid); -extern void stdcall _msys_window_redraw(int status); - -extern dword* stdcall _msys_cofflib_load(char* name); -extern char* stdcall _msys_cofflib_getproc(void* exp,char* sz_name); - -#endif diff --git a/programs/develop/metcc/trunk/libc/include/stdlib.h b/programs/develop/metcc/trunk/libc/include/stdlib.h deleted file mode 100644 index fd25a8ecbc..0000000000 --- a/programs/develop/metcc/trunk/libc/include/stdlib.h +++ /dev/null @@ -1,14 +0,0 @@ -#include -//#define isspace(c) ((c)==' ') -#define abs(i) (((i)<0)?(-(i)):(i)) - -extern int atoib(char *s,int b); -extern int atoi(char *s); -extern char tolower(char c); -extern char toupper(char c); -extern void itoab(int n,char* s,int b); -extern void itoa(int n,char* s); - -extern void* malloc(dword size); -extern void free(void *pointer); -extern void* realloc(void* pointer,dword size); \ No newline at end of file diff --git a/programs/develop/metcc/trunk/libc/mem/memalloc.asm b/programs/develop/metcc/trunk/libc/mem/memalloc.asm deleted file mode 100644 index 084785a464..0000000000 --- a/programs/develop/metcc/trunk/libc/mem/memalloc.asm +++ /dev/null @@ -1,41 +0,0 @@ -format ELF - -include "proc32.inc" -section '.text' executable -public malloc -public free -public realloc - -align 4 -proc malloc stdcall, size:dword - - mov eax,68 - mov ebx,12 - mov ecx,[size] - int 0x40 - - ret -endp - -align 4 -proc free stdcall, pointer:dword - - mov eax,68 - mov ebx,13 - mov ecx,[pointer] - int 0x40 - - ret -endp - -align 4 -proc realloc stdcall, pointer:dword, size:dword - - mov ebx,20 - mov eax,68 - mov ecx,[size] - mov edx,[pointer] - int 0x40 - - ret -endp diff --git a/programs/develop/metcc/trunk/libc/mesys/cofflib.asm b/programs/develop/metcc/trunk/libc/mesys/cofflib.asm deleted file mode 100644 index 218ac68acb..0000000000 --- a/programs/develop/metcc/trunk/libc/mesys/cofflib.asm +++ /dev/null @@ -1,64 +0,0 @@ -format ELF -include 'proc32.inc' -section '.text' executable - -;extrn 'malloc' as malloc:dword -extrn 'strncmp' as strncmp:dword -extrn 'debug_out_str' as debug_out_str -;extrn 'free' as free:dword -;extrn 'realloc' as realloc:dword -;extrn 'mf_init' as mf_init:dword - -public _msys_cofflib_load -;public _msys_cofflib_link -public _msys_cofflib_getproc - -proc _msys_cofflib_load stdcall, name:dword - mov eax, 68 - mov ebx, 19 - mov ecx, [name] - int 0x40 - ret -endp - - -;align 4 -;proc _msys_cofflib_link stdcall, exp:dword, imp:dword -; stdcall debug_out_str, szFuncLink -; mov esi, [imp] -; test esi, esi -; jz .done -;.next: -; lodsd -; test eax, eax -; jz .done -; stdcall _msys_cofflib_getproc, [exp], eax -; mov [esi-4], eax -; jmp .next -;.done: -; ret -;endp - -align 4 -proc _msys_cofflib_getproc stdcall, exp:dword, sz_name:dword - stdcall debug_out_str, szFuncGetProc - mov edx, [exp] -.next: - test edx, edx - jz .end - - stdcall strncmp, [edx], [sz_name], 16 - test eax, eax - jz .ok - - add edx,8 - jmp .next -.ok: - mov eax, [edx+4] -.end: - ret -endp - -section '.data' - szFuncGetProc db 'somebody did call GetProc',0x0d, 0x0a,0 - szFuncLink db 'somebody did call Link',0x0d, 0x0a,0 diff --git a/programs/develop/metcc/trunk/libc/mesys/debug_board.asm b/programs/develop/metcc/trunk/libc/mesys/debug_board.asm deleted file mode 100644 index ef338796b7..0000000000 --- a/programs/develop/metcc/trunk/libc/mesys/debug_board.asm +++ /dev/null @@ -1,19 +0,0 @@ -format ELF - -include "proc32.inc" - -section '.text' executable - -public _msys_debug_out - -align 4 -proc _msys_debug_out stdcall, c:byte - - xor ecx,ecx - mov cl,byte[c] - mov ebx,1 - mov eax,63 - int 0x40 - ret - -endp diff --git a/programs/develop/metcc/trunk/libc/mesys/debug_board_.c b/programs/develop/metcc/trunk/libc/mesys/debug_board_.c deleted file mode 100644 index ad5f0d15de..0000000000 --- a/programs/develop/metcc/trunk/libc/mesys/debug_board_.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -void debug_out_str(char* str) -{ - while ((*str!='\0') || (*str!=0)) - { - _msys_debug_out(*str); - str++; - } -} diff --git a/programs/develop/metcc/trunk/libc/mesys/event.asm b/programs/develop/metcc/trunk/libc/mesys/event.asm deleted file mode 100644 index dfac427c88..0000000000 --- a/programs/develop/metcc/trunk/libc/mesys/event.asm +++ /dev/null @@ -1,30 +0,0 @@ -format ELF -include "public_stdcall.inc" -section '.text' executable -public_stdcall _msys_wait_for_event_infinite,0 - mov eax,10 - int 0x40 - ret - -public_stdcall _msys_check_for_event,0 - mov eax,11 - int 0x40 - ret - -public_stdcall _msys_wait_for_event,4 -;arg1 - time - mov edx,ebx - mov eax,23 - mov ebx,[esp+4] - int 0x40 - mov ebx,edx - ret 4 - -public_stdcall _msys_set_wanted_events,4 -;arg1 - flags - mov edx,ebx - mov eax,40 - mov ebx,[esp+4] - int 0x40 - mov ebx,edx - ret 4 \ No newline at end of file diff --git a/programs/develop/metcc/trunk/libc/mesys/write_text.asm b/programs/develop/metcc/trunk/libc/mesys/write_text.asm deleted file mode 100644 index b2c7570ab0..0000000000 --- a/programs/develop/metcc/trunk/libc/mesys/write_text.asm +++ /dev/null @@ -1,20 +0,0 @@ -format ELF -include "public_stdcall.inc" -section '.text' executable -public_stdcall _msys_write_text,20 -;arg1 - x -;arg2 - y -;arg3 - color -;arg4 - text -;arg5 - len - push ebx esi - mov eax,4 - mov ebx,[esp+12] - shl ebx,16 - mov bx,[esp+16] - mov ecx,[esp+20] - mov edx,[esp+24] - mov esi,[esp+28] - int 0x40 - pop esi ebx - ret 20 \ No newline at end of file diff --git a/programs/develop/metcc/trunk/libc/string/memmove.asm b/programs/develop/metcc/trunk/libc/string/memmove.asm deleted file mode 100644 index 60ed097162..0000000000 --- a/programs/develop/metcc/trunk/libc/string/memmove.asm +++ /dev/null @@ -1,16 +0,0 @@ -format ELF -section '.text' executable -public memcpy -public memmove -memcpy: -memmove: - push esi edi - mov edi,[esp+12] - mov esi,[esp+16] - mov ecx,[esp+20] - jecxz .no_copy - cld - rep movsb -.no_copy: - pop edi esi - ret \ No newline at end of file diff --git a/programs/develop/metcc/trunk/samples/console/console.c b/programs/develop/metcc/trunk/samples/console/console.c deleted file mode 100644 index a489a71d43..0000000000 --- a/programs/develop/metcc/trunk/samples/console/console.c +++ /dev/null @@ -1,74 +0,0 @@ - -// Console dynamic link library. Sample by Ghost - -#include "stdio.h" -#include "string.h" -#include "mesys.h" - -char* dllname="/sys/console.obj"; -int i; - -char* imports[] = {"START","version","con_init","con_write_asciiz","con_printf","con_exit",NULL}; -char* caption = "Console test - colors"; - -dword (* dll_start)(dword res); -dword* dll_ver; -void stdcall (* con_init)(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title); -void stdcall (* con_write_asciiz)(dword flags, const char* string); -void cdecl (* con_printf)(dword flags, const char* format, ...); -void stdcall (* con_exit)(dword bCloseWindow); - -struct import{ - char *name; - void *data; -}; - -// в библиотеке есть аналогичная функция _msys_cofflib_getproc, но пока она работает не корректно -void* __msys_cofflib_getproc(struct import *lib, char *name){ - int i; - for(i = 0; lib[i].name && strcmp(name, lib[i].name); i++); - if(lib[i].name)return lib[i].data; - else return NULL; -} - -void link(struct import *exp, char** imports){ - dll_start = (dword (*)(dword)) - __msys_cofflib_getproc(exp, imports[0]); - dll_ver = (dword*) - __msys_cofflib_getproc(exp, imports[1]); - con_init = (void stdcall (*)(dword , dword, dword, dword, const char*)) - __msys_cofflib_getproc(exp, imports[2]); - con_write_asciiz = (void stdcall (*)(dword, const char*)) - __msys_cofflib_getproc(exp, imports[3]); - con_printf = (void cdecl (*)(dword, const char*, ...)) - __msys_cofflib_getproc(exp, imports[4]); - con_exit = (void stdcall (*)(dword)) - __msys_cofflib_getproc(exp, imports[5]); -} - -int main(int argc, char **argv){ - struct import * hDll; - - if((hDll = (struct import *)_msys_cofflib_load(dllname)) == 0){ - debug_out_str("can't load lib\n\r"); - return 1; - } - link(hDll, imports); - debug_out_str("dll loaded\n\r"); - - if(dll_start(1) == 0){ - debug_out_str("dll_start failed\n\r"); - return 1; - } - - con_init(-1, -1, -1, -1, caption); - for(i = 0; i < 256; i++){ - con_printf(7, "Color 0x%02X: ", i); - con_write_asciiz(i, "Text sample."); - - con_printf(i, " printf %s test %d\n", "small", i); - } - - con_exit(0); - debug_out_str("all right's ;)\n\r"); -} \ No newline at end of file diff --git a/programs/develop/metcc/trunk/samples/simple/simple.c b/programs/develop/metcc/trunk/samples/simple/simple.c deleted file mode 100644 index 7188c94156..0000000000 --- a/programs/develop/metcc/trunk/samples/simple/simple.c +++ /dev/null @@ -1,61 +0,0 @@ - -// simple sample by Ghost - -#include "stdio.h" -#include "string.h" -#include "mesys.h" - -#define FONT0 0 -#define FONT1 0x10000000 - -#define BT_NORMAL 0 -#define BT_DEL 0x80000000 -#define BT_HIDE 0x40000000 -#define BT_NOFRAME 0x20000000 - -char header[]={" -= C demo programm. Compiled whith meTCC halyavin port =- "}; - -void rotate_str(char *str){ - char tmp; - int i; - tmp = str[0]; - for(i = 1; str[i]; i++)str[i - 1] = str[i]; - str[i - 1] = tmp; -} - -void draw_window(){ - static int offs = 0; - static int fcolor = 0; - static int col = 0; - - _msys_window_redraw(1); - _msys_draw_window(100, 100, 300, 120, 0xaabbcc, 2, 0x5080d0, 0, 0x5080d0); - _msys_write_text(6 - offs, 8, fcolor | FONT0, header, strlen(header)); - _msys_draw_bar(1, 6, 5, 13, 0x05080d0); - _msys_draw_bar(274, 6, 26, 13, 0x05080d0); - _msys_make_button(300 - 19, 5, 12, 12, 1 | BT_NORMAL, 0x6688dd); - _msys_window_redraw(2); - - offs = (offs + 1) % 6; - if(!offs)rotate_str(header); - - fcolor += (col)?-0x80808:0x80808; - if(fcolor > 0xf80000 || fcolor == 0)col = !col; -} - -int main(int argc, char **argv){ - - while(!0){ - switch(_msys_wait_for_event(10)){ - case 2:return 0; - - case 3: - if(_msys_get_button_id() == 1)return 0; - break; - - default: - draw_window(); - break; - } - } -}