forked from KolibriOS/kolibrios
Mistakes in functions of work with files and with system calls KolibriOS are corrected.
New functions for work with system calls KolibriOS are added. Functions for format output are added: printf (), fprintf (), sprintf (), snprintf (), vsnprintf (). For material numbers it is meanwhile supported only format output the (%f), and exponential output a (%e) is not realized yet. Functions for format output correctly work only in GCC because TinyC incorrectly works with the functions containing variable number of arguments. git-svn-id: svn://kolibrios.org@647 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
38ed47b73c
commit
16f5992719
@ -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=
|
@ -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)
|
||||
|
195
programs/develop/ktcc/trunk/libc/include/kolibrisys.h
Normal file
195
programs/develop/ktcc/trunk/libc/include/kolibrisys.h
Normal file
@ -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
|
179
programs/develop/ktcc/trunk/libc/include/math.h
Normal file
179
programs/develop/ktcc/trunk/libc/include/math.h
Normal file
@ -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_ */
|
@ -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
|
18
programs/develop/ktcc/trunk/libc/include/stdlib.h
Normal file
18
programs/develop/ktcc/trunk/libc/include/stdlib.h
Normal file
@ -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
|
@ -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
|
@ -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
|
@ -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
|
73
programs/develop/ktcc/trunk/libc/kolibrisys/cofflib.asm
Normal file
73
programs/develop/ktcc/trunk/libc/kolibrisys/cofflib.asm
Normal file
@ -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
|
||||
|
@ -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
|
56
programs/develop/ktcc/trunk/libc/kolibrisys/debug_board.asm
Normal file
56
programs/develop/ktcc/trunk/libc/kolibrisys/debug_board.asm
Normal file
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
40
programs/develop/ktcc/trunk/libc/kolibrisys/event.asm
Normal file
40
programs/develop/ktcc/trunk/libc/kolibrisys/event.asm
Normal file
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
25
programs/develop/ktcc/trunk/libc/kolibrisys/mouse.asm
Normal file
25
programs/develop/ktcc/trunk/libc/kolibrisys/mouse.asm
Normal file
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
13
programs/develop/ktcc/trunk/libc/kolibrisys/skin.asm
Normal file
13
programs/develop/ktcc/trunk/libc/kolibrisys/skin.asm
Normal file
@ -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
|
@ -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
|
@ -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
|
@ -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
|
21
programs/develop/ktcc/trunk/libc/kolibrisys/write_text.asm
Normal file
21
programs/develop/ktcc/trunk/libc/kolibrisys/write_text.asm
Normal file
@ -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
|
@ -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)/*))
|
38
programs/develop/ktcc/trunk/libc/memory/memalloc.asm
Normal file
38
programs/develop/ktcc/trunk/libc/memory/memalloc.asm
Normal file
@ -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
|
@ -1,4 +1,4 @@
|
||||
#include "stdio.h"
|
||||
#include <stdio.h>
|
||||
int fgetpos(FILE* file,fpos_t* pos)
|
||||
{
|
||||
*pos=file->filepos;
|
@ -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;
|
729
programs/develop/ktcc/trunk/libc/stdio/format_print.c
Normal file
729
programs/develop/ktcc/trunk/libc/stdio/format_print.c
Normal file
@ -0,0 +1,729 @@
|
||||
/*
|
||||
function for format output to the string
|
||||
*/
|
||||
|
||||
#include <kolibrisys.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
//#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
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<fmt2;i++)
|
||||
{n=n*10;mul=mul*10;}
|
||||
|
||||
n=n*10;
|
||||
n=ceil(n);
|
||||
intdigit=floor(n);
|
||||
//intdigit=n;
|
||||
intdigit=(intdigit/10);
|
||||
|
||||
pos=0;
|
||||
mul=mul/10;
|
||||
for(i=0;i<fmt2-1;i++)
|
||||
{
|
||||
div=intdigit/mul;
|
||||
buf[pos]=(char)div;
|
||||
pos++;
|
||||
intdigit=intdigit-div*mul;
|
||||
mul=mul/10;
|
||||
if (mul==1) break;
|
||||
}
|
||||
buf[pos]=(char)intdigit;
|
||||
*s='0';s++;
|
||||
*s='.';s++;
|
||||
for(i=0;i<format2;i++)
|
||||
{
|
||||
if ((buf[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<fmt1-1;i++)
|
||||
{
|
||||
div=beforpointdigit/mul;
|
||||
buf[pos]=(char)div;
|
||||
pos++;
|
||||
beforpointdigit=beforpointdigit-div*mul;
|
||||
mul=mul/10;
|
||||
if (mul==1) break;
|
||||
}
|
||||
buf[pos]=(char)beforpointdigit;
|
||||
|
||||
for(i=0;i<fmt1;i++)
|
||||
{
|
||||
if ((buf[i]>=0) && (buf[i]<=9)) {*s='0'+buf[i];}
|
||||
s++;
|
||||
}
|
||||
|
||||
//print part of number after point
|
||||
mul=1;
|
||||
for(i=0;i<fmt2;i++)
|
||||
{nafter=nafter*10;mul=mul*10;}
|
||||
|
||||
nafter=nafter*10;
|
||||
nafter=ceil(nafter);
|
||||
intdigit=floor(nafter);
|
||||
//intdigit=nafter;
|
||||
intdigit=intdigit/10;
|
||||
|
||||
pos=0;
|
||||
mul=mul/10;
|
||||
for(i=0;i<fmt2-1;i++)
|
||||
{
|
||||
div=intdigit/mul;
|
||||
buf[pos]=(char)div;
|
||||
pos++;
|
||||
intdigit=intdigit-div*mul;
|
||||
mul=mul/10;
|
||||
if (mul==1) break;
|
||||
}
|
||||
buf[pos]=(char)intdigit;
|
||||
*s='.';s++;
|
||||
for(i=0;i<format2;i++)
|
||||
{
|
||||
if ((buf[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<fmt-1;i++)
|
||||
{
|
||||
div=digit/mul;
|
||||
buf[pos]=(char)div;
|
||||
pos++;
|
||||
digit=digit-div*mul;
|
||||
mul=mul/10;
|
||||
if (mul==1) break;
|
||||
}
|
||||
buf[pos]=(char)digit;
|
||||
|
||||
if (fmt1>=difference_pos) fmt=fmt1;
|
||||
else
|
||||
fmt=difference_pos;
|
||||
|
||||
for(i=0;i<fmt;i++)
|
||||
{
|
||||
if (i<difference_pos)
|
||||
{
|
||||
if ((buf[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(pos<maxlen)
|
||||
{
|
||||
if (*fmt=='%')
|
||||
{
|
||||
|
||||
if (*(fmt+1)=='%')
|
||||
{
|
||||
*s='%';
|
||||
s++;
|
||||
fmt=fmt+2;
|
||||
pos++;
|
||||
goto exit_check;
|
||||
}
|
||||
//checking to containg format in the string
|
||||
fmtc=fmt;
|
||||
posc=pos;
|
||||
format_flag=0;
|
||||
flag_long=0;
|
||||
flag_unsigned=0;
|
||||
flag_register=0;
|
||||
flag_plus=0;
|
||||
while((*fmtc!='\0') || (*fmtc!=0))
|
||||
{
|
||||
fmtc++;
|
||||
posc++;
|
||||
switch(*fmtc)
|
||||
{
|
||||
case 'c':
|
||||
case 'C':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
case 'i':
|
||||
case 'I':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'e':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'E':
|
||||
format_flag=1;
|
||||
flag_long=1;
|
||||
break;
|
||||
case 'f':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'F':
|
||||
format_flag=1;
|
||||
flag_long=1;
|
||||
break;
|
||||
case 'g':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'G':
|
||||
format_flag=1;
|
||||
flag_long=1;
|
||||
break;
|
||||
case 'l':
|
||||
flag_long=1;
|
||||
break;
|
||||
case 'L':
|
||||
flag_long=2;
|
||||
break;
|
||||
case 'o':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
format_flag=1;
|
||||
flag_unsigned=1;
|
||||
break;
|
||||
case 'x':
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'X':
|
||||
flag_register=1;
|
||||
format_flag=1;
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
format_flag=1;
|
||||
flag_unsigned=1;
|
||||
break;
|
||||
case '+':
|
||||
flag_plus=1;
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
if ((*fmtc=='%') || (*fmtc==' ')) break;
|
||||
if (format_flag==1) break;
|
||||
}
|
||||
|
||||
if (format_flag==0)
|
||||
{
|
||||
*s=*fmt;
|
||||
fmt++;
|
||||
s++;
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((posc-pos)==1)
|
||||
{//simbols % and format simbol near tothere(for example %c )
|
||||
fmt=fmtc+1;
|
||||
switch(*fmtc)
|
||||
{
|
||||
case 'c':
|
||||
case 'C':
|
||||
if ((pos+1)<maxlen)
|
||||
{
|
||||
//*s=(int)va_arg(argp,char*);
|
||||
*s=*((char *)argp);
|
||||
argp=argp+4;
|
||||
*s++;pos++;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
str=va_arg(argp,char*);
|
||||
length=strlen(str);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,str,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
case 'i':
|
||||
case 'I':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
//intdigit=*((long*)argp);
|
||||
//argp=argp+4;
|
||||
if ((intdigit>0) && (flag_plus==1) && (pos+1<maxlen))
|
||||
{
|
||||
*s='+';
|
||||
s++;
|
||||
pos++;
|
||||
}
|
||||
length=formatted_long_to_string(intdigit,0,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
//intdigit=*((long int *)argp);
|
||||
//argp=argp+4;
|
||||
|
||||
length=formatted_octa_to_string(intdigit,0,flag_register,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long int);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
|
||||
if (flag_unsigned==1) {
|
||||
if (intdigit<0) {intdigit=-intdigit;}
|
||||
}
|
||||
|
||||
length=formatted_long_to_string(intdigit,0,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
//intdigit=*((long int *)argp);
|
||||
//argp=argp+4;
|
||||
|
||||
length=formatted_hex_to_string(intdigit,0,flag_register,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
intdigit=va_arg(argp,size_t);
|
||||
|
||||
if (flag_unsigned==1) {
|
||||
if (intdigit<0) {intdigit=-intdigit;}
|
||||
}
|
||||
|
||||
length=formatted_long_to_string(intdigit,0,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt++;
|
||||
flag_point=0;
|
||||
flag_noformat=0;
|
||||
fmt1=0;
|
||||
fmt2=0;
|
||||
j=0;
|
||||
k=0;
|
||||
for(i=pos+1;i<posc;i++)
|
||||
{
|
||||
switch(*fmt)
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (flag_point==0)
|
||||
{
|
||||
buffmt1[j]=*fmt-'0';
|
||||
j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffmt2[k]=*fmt-'0';
|
||||
k++;
|
||||
}
|
||||
break;
|
||||
case '.':
|
||||
flag_point=1;
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
break;
|
||||
case '+':
|
||||
break;
|
||||
default:flag_noformat=1;
|
||||
}
|
||||
if (flag_noformat==1) break;
|
||||
fmt++;
|
||||
}
|
||||
if (flag_noformat==0)
|
||||
{
|
||||
stepen=1;
|
||||
for(i=j-1;i>=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)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
case 'i':
|
||||
case 'I':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
|
||||
if ((intdigit>0) && (flag_plus==1) && (pos+1<maxlen))
|
||||
{
|
||||
*s='+';
|
||||
s++;
|
||||
pos++;
|
||||
}
|
||||
length=formatted_long_to_string(intdigit,fmt1,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
length=formatted_octa_to_string(intdigit,fmt1,flag_register,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long int);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
|
||||
if (flag_unsigned==1) {
|
||||
if (intdigit<0) {intdigit=-intdigit;}
|
||||
}
|
||||
|
||||
length=formatted_long_to_string(intdigit,fmt1,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
if (flag_long==0) {intdigit=va_arg(argp,int);}
|
||||
if (flag_long==1) {intdigit=va_arg(argp,long int);}
|
||||
if (flag_long==2) {intdigit=va_arg(argp,long long);}
|
||||
length=formatted_hex_to_string(intdigit,fmt1,flag_register,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
intdigit=va_arg(argp,size_t);
|
||||
|
||||
if (flag_unsigned==1) {
|
||||
if (intdigit<0) {intdigit=-intdigit;}
|
||||
}
|
||||
|
||||
length=formatted_long_to_string(intdigit,fmt1,buf);
|
||||
if ((pos+length)<maxlen)
|
||||
{
|
||||
memcpy(s,buf,length);
|
||||
s=s+length;pos=pos+length;
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
fmt=fmtc+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*fmt=='\0') {break;}
|
||||
*s=*fmt;
|
||||
fmt++;
|
||||
s++;
|
||||
pos++;
|
||||
}
|
||||
exit_check:;
|
||||
}
|
||||
return(pos);
|
||||
}
|
21
programs/develop/ktcc/trunk/libc/stdio/fprintf.c
Normal file
21
programs/develop/ktcc/trunk/libc/stdio/fprintf.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include "stdio.h"
|
||||
#include <stdio.h>
|
||||
int fputc(int c,FILE* file)
|
||||
{
|
||||
dword res;
|
@ -1,11 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <mesys.h>
|
||||
#include <kolibrisys.h>
|
||||
|
||||
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))
|
@ -1,4 +1,4 @@
|
||||
#include "stdio.h"
|
||||
#include <stdio.h>
|
||||
void skipspaces(FILE* file)
|
||||
{
|
||||
int c;
|
@ -1,4 +1,4 @@
|
||||
#include "stdio.h"
|
||||
#include <stdio.h>
|
||||
int fseek(FILE* file,long offset,int origin)
|
||||
{
|
||||
if (origin==SEEK_CUR)
|
@ -1,4 +1,4 @@
|
||||
#include "stdio.h"
|
||||
#include <stdio.h>
|
||||
int fsetpos(FILE* file,const fpos_t * pos)
|
||||
{
|
||||
if (*pos>=0)
|
@ -1,4 +1,4 @@
|
||||
#include "stdio.h"
|
||||
#include <stdio.h>
|
||||
long ftell(FILE* file)
|
||||
{
|
||||
return file->filepos;
|
@ -1,20 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <mesys.h>
|
||||
#include <kolibrisys.h>
|
||||
|
||||
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
|
75
programs/develop/ktcc/trunk/libc/stdio/printf.c
Normal file
75
programs/develop/ktcc/trunk/libc/stdio/printf.c
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <kolibrisys.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "stdio.h"
|
||||
#include <stdio.h>
|
||||
void rewind(FILE* file)
|
||||
{
|
||||
file->filepos=0;
|
15
programs/develop/ktcc/trunk/libc/stdio/snprintf.c
Normal file
15
programs/develop/ktcc/trunk/libc/stdio/snprintf.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <kolibrisys.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
15
programs/develop/ktcc/trunk/libc/stdio/sprintf.c
Normal file
15
programs/develop/ktcc/trunk/libc/stdio/sprintf.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <kolibrisys.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
15
programs/develop/ktcc/trunk/libc/stdio/vsnprintf.c
Normal file
15
programs/develop/ktcc/trunk/libc/stdio/vsnprintf.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <kolibrisys.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
@ -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);
|
35
programs/develop/ktcc/trunk/libc/string/memmove.asm
Normal file
35
programs/develop/ktcc/trunk/libc/string/memmove.asm
Normal file
@ -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
|
70
programs/develop/ktcc/trunk/samples/console/console.c
Normal file
70
programs/develop/ktcc/trunk/samples/console/console.c
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
// Console dynamic link library. Sample by Ghost
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <kolibrisys.h>
|
||||
|
||||
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");
|
||||
}
|
61
programs/develop/ktcc/trunk/samples/simple/simple.c
Normal file
61
programs/develop/ktcc/trunk/samples/simple/simple.c
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
// simple sample by Ghost
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <kolibrisys.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 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;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user