diff --git a/programs/develop/ktcc/trunk/bin/lib/clayer/loadboxlib.o b/programs/develop/ktcc/trunk/bin/lib/libbox.a similarity index 77% rename from programs/develop/ktcc/trunk/bin/lib/clayer/loadboxlib.o rename to programs/develop/ktcc/trunk/bin/lib/libbox.a index 75bec2187a..23a6a499be 100644 Binary files a/programs/develop/ktcc/trunk/bin/lib/clayer/loadboxlib.o and b/programs/develop/ktcc/trunk/bin/lib/libbox.a differ diff --git a/programs/develop/ktcc/trunk/bin/lib/libbuf2d.a b/programs/develop/ktcc/trunk/bin/lib/libbuf2d.a new file mode 100644 index 0000000000..30a0f85c7f Binary files /dev/null and b/programs/develop/ktcc/trunk/bin/lib/libbuf2d.a differ diff --git a/programs/develop/ktcc/trunk/lib/boxlib/Makefile b/programs/develop/ktcc/trunk/lib/boxlib/Makefile new file mode 100644 index 0000000000..599c114e04 --- /dev/null +++ b/programs/develop/ktcc/trunk/lib/boxlib/Makefile @@ -0,0 +1,10 @@ +all: + fasm boxlib.asm + ar -crs libbox.a boxlib.o + +clean: + rm -f *.a + rm -f *.o + +install: + mv libbox.a ../../bin/lib diff --git a/programs/develop/ktcc/trunk/lib/clayer/loadboxlib.asm b/programs/develop/ktcc/trunk/lib/boxlib/boxlib.asm similarity index 95% rename from programs/develop/ktcc/trunk/lib/clayer/loadboxlib.asm rename to programs/develop/ktcc/trunk/lib/boxlib/boxlib.asm index 95f86b7d48..4138dd1acf 100644 --- a/programs/develop/ktcc/trunk/lib/clayer/loadboxlib.asm +++ b/programs/develop/ktcc/trunk/lib/boxlib/boxlib.asm @@ -1,4 +1,4 @@ -; writed by maxcodehack +; writed by maxñodehack ; adaptation of clayer for ktcc format elf use32 ; Tell compiler to use 32 bit instructions @@ -6,11 +6,11 @@ use32 ; Tell compiler to use 32 bit instructio section '.text' executable -include 'proc32.inc' -include 'macros.inc' +include '../../../../../proc32.inc' +include '../../../../../macros.inc' purge section,mov,add,sub -include 'dll.inc' +include '../../../../../dll.inc' public init_boxlib as 'kolibri_boxlib_init' diff --git a/programs/develop/ktcc/trunk/lib/buf2d/Makefile b/programs/develop/ktcc/trunk/lib/buf2d/Makefile new file mode 100644 index 0000000000..eee026f811 --- /dev/null +++ b/programs/develop/ktcc/trunk/lib/buf2d/Makefile @@ -0,0 +1,10 @@ +all: + fasm buf2d.asm buf2d.o + ar -csr libbuf2d.a buf2d.o + +clean: + rm -f *.a + rm -f *.o + +install: + mv *.a ../../bin/lib diff --git a/programs/develop/ktcc/trunk/lib/buf2d/buf2d.asm b/programs/develop/ktcc/trunk/lib/buf2d/buf2d.asm new file mode 100644 index 0000000000..27a149b0b5 --- /dev/null +++ b/programs/develop/ktcc/trunk/lib/buf2d/buf2d.asm @@ -0,0 +1,90 @@ +format elf +use32 ; Tell compiler to use 32 bit instructions + +section '.text' executable + +include '../../../../../proc32.inc' +include '../../../../../macros.inc' +purge section,mov,add,sub + +include '../../../../../dll.inc' + +;public lib_init as 'kolibri_buf2d_init' +;;; Returns 0 on success. -1 on failure. +public init_buf2d as 'kolibri_buf2d_init' + +proc init_buf2d + pusha + mcall 68,11 + stdcall dll.Load, @IMPORT + popa + ret +endp + +section '.data' writeable + +@IMPORT: +library lib_buf2d, 'buf2d.obj' + +import lib_buf2d, \ + libbuf2d_init, 'lib_init' , \ + buf2d_create, 'buf2d_create' , \ + buf2d_clear, 'buf2d_clear' , \ + buf2d_draw, 'buf2d_draw' , \ + buf2d_delete, 'buf2d_delete', \ + buf2d_rotate, 'buf2d_rotate', \ + buf2d_resize, 'buf2d_resize', \ + buf2d_line, 'buf2d_line', \ + buf2d_line_sm, 'buf2d_line_sm', \ + buf2d_rect_by_size, 'buf2d_rect_by_size', \ + buf2d_filled_rect_by_size, 'buf2d_filled_rect_by_size', \ + buf2d_circle, 'buf2d_circle', \ + buf2d_img_hdiv2, 'buf2d_img_hdiv2', \ + buf2d_img_wdiv2, 'buf2d_img_wdiv2', \ + buf2d_conv_24_to_8, 'buf2d_conv_24_to_8', \ + buf2d_conv_24_to_32, 'buf2d_conv_24_to_32', \ + buf2d_bit_blt, 'buf2d_bit_blt', \ + buf2d_bit_blt_transp, 'buf2d_bit_blt_transp', \ + buf2d_bit_blt_alpha, 'buf2d_bit_blt_alpha', \ + buf2d_curve_bezier, 'buf2d_curve_bezier', \ + buf2d_convert_text_matrix, 'buf2d_convert_text_matrix', \ + buf2d_draw_text, 'buf2d_draw_text', \ + buf2d_crop_color, 'buf2d_crop_color', \ + buf2d_offset_h, 'buf2d_offset_h', \ + buf2d_flood_fill, 'buf2d_flood_fill', \ + buf2d_set_pixel, 'buf2d_set_pixel', \ + buf2d_get_pixel, 'buf2d_get_pixel', \ + buf2d_flip_h, 'buf2d_flip_h', \ + buf2d_flip_v, 'buf2d_flip_v', \ + buf2d_filter_dither, 'buf2d_filter_dither' + +public libbuf2d_init as 'libimg_init' +public buf2d_create as 'buf2d_create_asm' +public buf2d_clear as 'buf2d_clear' +public buf2d_draw as 'buf2d_draw' +public buf2d_delete as 'buf2d_delete' +public buf2d_rotate as 'buf2d_rotate' +public buf2d_resize as 'buf2d_resize' +public buf2d_line as 'buf2d_line' +public buf2d_line_sm as 'buf2d_line_sm' +public buf2d_rect_by_size as 'buf2d_rect_by_size' +public buf2d_filled_rect_by_size as 'buf2d_filled_rect_by_size' +public buf2d_circle as 'buf2d_circle' +public buf2d_img_hdiv2 as 'buf2d_img_hdiv2' +public buf2d_img_wdiv2 as 'buf2d_img_wdiv2' +public buf2d_conv_24_to_8 as 'buf2d_conv_24_to_8' +public buf2d_conv_24_to_32 as 'buf2d_conv_24_to_32' +public buf2d_bit_blt as 'buf2d_bit_blt' +public buf2d_bit_blt_transp as 'buf2d_bit_blt_transp' +public buf2d_bit_blt_alpha as 'buf2d_bit_blt_alpha' +public buf2d_curve_bezier as 'buf2d_curve_bezier_asm' +public buf2d_convert_text_matrix as 'buf2d_convert_text_matrix' +public buf2d_draw_text as 'buf2d_draw_text' +public buf2d_crop_color as 'buf2d_crop_color' +public buf2d_offset_h as 'buf2d_offset_h' +public buf2d_flood_fill as 'buf2d_flood_fill' +public buf2d_set_pixel as 'buf2d_set_pixel' +public buf2d_get_pixel as 'buf2d_get_pixel' +public buf2d_flip_h as 'buf2d_flip_h' +public buf2d_flip_v as 'buf2d_flip_v' +public buf2d_filter_dither as 'buf2d_filter_dither' diff --git a/programs/develop/ktcc/trunk/libc/include/clayer/buf2d.h b/programs/develop/ktcc/trunk/libc/include/clayer/buf2d.h new file mode 100644 index 0000000000..74b986d2b1 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc/include/clayer/buf2d.h @@ -0,0 +1,83 @@ +#ifndef KOLIBRI_BUF2D_H +#define KOLIBRI_BUF2D_H + +#include +/*ToDo + * voxel function + */ + +extern int kolibri_buf2d_init(void); + +typedef struct { + unsigned int *buf_pointer; + uint16_t left; + uint16_t top; + unsigned int width; + unsigned int height; + unsigned int bgcolor; + uint8_t color_bit; +} __attribute__ ((__packed__))buf2d_struct; + +enum BUF2D_ALGORITM_FILTR { + SIERRA_LITE, + FLOYD_STEINBERG, + BURKERS, + HEAVYIRON_MOD, + ATKINSON +}; + +enum BUF2D_OPT_CROP { + BUF2D_OPT_CROP_TOP = 1, + BUF2D_OPT_CROP_LEFT = 2, + BUF2D_OPT_CROP_BOTTOM = 4, + BUF2D_OPT_CROP_RIGHT = 8 +}; + +extern void (*buf2d_create_asm __attribute__((__stdcall__)))(buf2d_struct *); +extern void (*buf2d_curve_bezier_asm __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int); + +buf2d_struct* buf2d_create(uint16_t tlx, uint16_t tly, unsigned int sizex, unsigned int sizey, unsigned int font_bgcolor, uint8_t color_bit) +{ + buf2d_struct *new_buf2d_struct = (buf2d_struct *)malloc(sizeof(buf2d_struct)); + new_buf2d_struct -> left = tlx; + new_buf2d_struct -> top = tly; + new_buf2d_struct -> width = sizex; + new_buf2d_struct -> height = sizey; + new_buf2d_struct -> bgcolor = font_bgcolor; + new_buf2d_struct -> color_bit = color_bit; + buf2d_create_asm(new_buf2d_struct); + return new_buf2d_struct; +} + +void buf2d_curve_bezier(buf2d_struct *buf, unsigned int p0_x, unsigned int p0_y, unsigned int p1_x, unsigned int p1_y, unsigned int p2_x, unsigned int p2_y, unsigned int color) +{ + buf2d_curve_bezier_asm(buf, (p0_x<<16)+p0_y, (p1_x<<16)+p1_y, (p2_x<<16)+p2_y, color); +} + +extern void (*buf2d_draw __attribute__((__stdcall__)))(buf2d_struct *); +extern void (*buf2d_clear __attribute__((__stdcall__)))(buf2d_struct *, unsigned int); +extern void (*buf2d_delete __attribute__((__stdcall__)))(buf2d_struct *); +extern void (*buf2d_rotate __attribute__((__stdcall__)))(buf2d_struct *, unsigned int); +extern void (*buf2d_resize __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int); +extern void (*buf2d_line __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); +extern void (*buf2d_line_sm __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int); +extern void (*buf2d_rect_by_size __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); +extern void (*buf2d_filled_rect_by_size __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); +extern void (*buf2d_circle __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int); +extern void (*buf2d_img_hdiv2 __attribute__((__stdcall__)))(buf2d_struct *); +extern void (*buf2d_img_wdiv2 __attribute__((__stdcall__)))(buf2d_struct *); +extern void (*buf2d_conv_24_to_8 __attribute__((__stdcall__)))(buf2d_struct *, unsigned int); +extern void (*buf2d_conv_24_to_32 __attribute__((__stdcall__)))(buf2d_struct *, unsigned int); +extern void (*buf2d_bit_blt_transp __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, buf2d_struct *); +extern void (*buf2d_bit_blt_alpha __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, buf2d_struct *); +extern void (*buf2d_convert_text_matrix __attribute__((__stdcall__)))(buf2d_struct *); +extern void (*buf2d_draw_text __attribute__((__stdcall__)))(buf2d_struct *, buf2d_struct *, const char *, unsigned int, unsigned int); +extern void (*buf2d_crop_color __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int); +extern void (*buf2d_offset_h __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int); +extern void (*buf2d_flood_fill __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int); +extern void (*buf2d_set_pixel __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int); +extern unsigned int (*buf2d_get_pixel __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int); +extern void (*buf2d_flip_h __attribute__((__stdcall__)))(buf2d_struct *); +extern void (*buf2d_flip_v __attribute__((__stdcall__)))(buf2d_struct *); +extern void (*buf2d_filter_dither __attribute__((__stdcall__)))(buf2d_struct *, unsigned int); +#endif /* KOLIBRI_BUF2D_H */ diff --git a/programs/develop/ktcc/trunk/libc/include/kos/libimg.h b/programs/develop/ktcc/trunk/libc/include/clayer/libimg.h similarity index 100% rename from programs/develop/ktcc/trunk/libc/include/kos/libimg.h rename to programs/develop/ktcc/trunk/libc/include/clayer/libimg.h diff --git a/programs/develop/ktcc/trunk/libc/include/kos/msgbox.h b/programs/develop/ktcc/trunk/libc/include/clayer/msgbox.h similarity index 100% rename from programs/develop/ktcc/trunk/libc/include/kos/msgbox.h rename to programs/develop/ktcc/trunk/libc/include/clayer/msgbox.h diff --git a/programs/develop/ktcc/trunk/libc/include/kos/rasterworks.h b/programs/develop/ktcc/trunk/libc/include/clayer/rasterworks.h similarity index 100% rename from programs/develop/ktcc/trunk/libc/include/kos/rasterworks.h rename to programs/develop/ktcc/trunk/libc/include/clayer/rasterworks.h diff --git a/programs/develop/ktcc/trunk/libc/include/clayer/readme.txt b/programs/develop/ktcc/trunk/libc/include/clayer/readme.txt deleted file mode 100644 index 2ce1b1df89..0000000000 --- a/programs/develop/ktcc/trunk/libc/include/clayer/readme.txt +++ /dev/null @@ -1,29 +0,0 @@ -Adaption of C_Layer wrappers for TCC - -_____________ -TODO -_____________ - -- Add wrappers in boxlib.h for: - - statictext - - filebrowse - - editor - - treelist - -- Port other wrappers from C_Layer - - -_____________ -How to use? -_____________ - -1. Include header to your program: - -#include - -2. Write some program -3. Compile with link to program .o file: - -kos32-tcc sample.c loadboxlib.o -lck -o sample.kex - -(.o files in ktcc/trunk/bin/lib/clayer) \ No newline at end of file diff --git a/programs/develop/ktcc/trunk/samples/build_all.sh b/programs/develop/ktcc/trunk/samples/build_all.sh index 50fda07281..62562b1aed 100644 --- a/programs/develop/ktcc/trunk/samples/build_all.sh +++ b/programs/develop/ktcc/trunk/samples/build_all.sh @@ -5,8 +5,8 @@ ../tcc winbasics.c /kolibrios/develop/tcc/lib/libck.a -o winbasics ../tcc dynamic.c -lconsole -lhttp -linputbox -o dynamic ../tcc load_coff.c -o load_coff -lck -../tcc msgbox.c -lck -lmsgbox -o msgbox +../tcc clayer/msgbox.c -lck -lmsgbox -o msgbox ../tcc graphics.c -lck -lgb -o graphics -../tcc libimgdemo.c -lck -limg -o libimgdemo -../tcc rasterworks.c -lck -lrasterworks -o rasterworks +../tcc clayer/rasterworks.c -lck -lrasterworks -o rasterworks +../tcc clayer/boxlib.c -lck -lbox -o boxlib_ex exit diff --git a/programs/develop/ktcc/trunk/samples/clayer/boxlib.c b/programs/develop/ktcc/trunk/samples/clayer/boxlib.c index 26d4453aae..0b9ab1129d 100644 --- a/programs/develop/ktcc/trunk/samples/clayer/boxlib.c +++ b/programs/develop/ktcc/trunk/samples/clayer/boxlib.c @@ -1,4 +1,3 @@ -// sample writed by maxcodehack #include #include #include diff --git a/programs/develop/ktcc/trunk/samples/msgbox.c b/programs/develop/ktcc/trunk/samples/clayer/msgbox.c similarity index 80% rename from programs/develop/ktcc/trunk/samples/msgbox.c rename to programs/develop/ktcc/trunk/samples/clayer/msgbox.c index 7d34bd2cd8..3042ec19cf 100644 --- a/programs/develop/ktcc/trunk/samples/msgbox.c +++ b/programs/develop/ktcc/trunk/samples/clayer/msgbox.c @@ -1,4 +1,4 @@ -#include +#include int main() { diff --git a/programs/develop/ktcc/trunk/samples/rasterworks.c b/programs/develop/ktcc/trunk/samples/clayer/rasterworks.c similarity index 94% rename from programs/develop/ktcc/trunk/samples/rasterworks.c rename to programs/develop/ktcc/trunk/samples/clayer/rasterworks.c index 40984d7585..ccc186cb8d 100644 --- a/programs/develop/ktcc/trunk/samples/rasterworks.c +++ b/programs/develop/ktcc/trunk/samples/clayer/rasterworks.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include int main() { diff --git a/programs/develop/ktcc/trunk/samples/clayer/readme.txt b/programs/develop/ktcc/trunk/samples/clayer/readme.txt deleted file mode 100644 index cd91889785..0000000000 --- a/programs/develop/ktcc/trunk/samples/clayer/readme.txt +++ /dev/null @@ -1 +0,0 @@ -kos32-tcc boxlib.c loadboxlib.o -lck -o boxlib.kex \ No newline at end of file diff --git a/programs/develop/ktcc/trunk/samples/cxx_price.png b/programs/develop/ktcc/trunk/samples/cxx_price.png deleted file mode 100644 index efc5f9f2c4..0000000000 Binary files a/programs/develop/ktcc/trunk/samples/cxx_price.png and /dev/null differ diff --git a/programs/develop/ktcc/trunk/samples/libimgdemo.c b/programs/develop/ktcc/trunk/samples/libimgdemo.c deleted file mode 100644 index 9565bcd068..0000000000 --- a/programs/develop/ktcc/trunk/samples/libimgdemo.c +++ /dev/null @@ -1,153 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#define BTN_QUIT 1 - -struct kolibri_system_colors sys_color_table; - -char proc_info[1024]; -char temp_path[4096]; -char* image_data_rgb; // decoded image - -/* load file to heap */ -char* load_file_inmem(char* fname, int32_t* read_sz); - -void draw_window() -{ - int win_hight, win_width, i, pos_x = 5, pos_y = get_skin_height(); - - begin_draw(); - - sys_create_window(10, 40, 600, 400, "My window", 0xFFFFFF, 0x13); - - get_proc_info(proc_info); - win_width = *(int*)(proc_info + 0x3E); // client, 2A windows - win_hight = *(int*)(proc_info + 0x42); // client, 2E windows - - draw_bitmap(image_data_rgb, pos_x, pos_y , 400, 600); - draw_bitmap(image_data_rgb, pos_x, pos_y, 16, 16); - - end_draw(); -} - -int main(int argc, char **argv) -{ - int gui_event; - uint32_t pressed_button = 0, mouse_button; - pos_t mouse_pos; - - if (-1 == kolibri_libimg_init()) // png handling - { - debug_board_printf("error loading 'lin_img.obj'\n"); - exit(1); - } - - // load image - const int icon_rgb_size = 2400*2000; // file demo is 2400x2000x8bpp - char *image_data, *filedata; - strcpy(temp_path, "/kolibrios/res/wallpapers/in_the_wind.png"); - debug_board_write_str(temp_path); - - int32_t read_bytes; - filedata = load_file_inmem(temp_path, &read_bytes); - image_data_rgb = malloc(icon_rgb_size * 3); - image_data = img_decode(filedata, read_bytes, 0); - img_to_rgb2(image_data, image_data_rgb); - img_destroy(image_data); - free(filedata); - - - - get_system_colors(&sys_color_table); - set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside - - do /* Start of main activity loop */ - { -// gui_event = wait_for_event(10); // 100 = 1 sec, case you have background work - gui_event = get_os_event(); - switch(gui_event) - { - case KOLIBRI_EVENT_NONE: - // background work - break; - case KOLIBRI_EVENT_REDRAW: - draw_window(); - break; - case KOLIBRI_EVENT_KEY: - // scroll - break; - case KOLIBRI_EVENT_BUTTON: - pressed_button = get_os_button(); - switch (pressed_button) - { - case BTN_QUIT: - return 0; - break; - } - break; - case KOLIBRI_EVENT_MOUSE: - mouse_pos = get_mouse_pos(POS_WINDOW); // window relative - mouse_button = get_mouse_eventstate(); - debug_board_printf("mouse ev (%d,%d)%x\n", mouse_pos.x, mouse_pos.y, mouse_button); - if (mouse_button & (1<<24)) // double click - { - debug_board_printf("double click\n"); - } - // ignore - break; - } - } while(1) ; /* End of main activity loop */ - - return 0; -} - -char* load_file_inmem(char* fname, int32_t* read_sz) -{ - FILE *f = fopen(fname, "rb"); - if (!f) { - debug_board_printf("Can't open file: %s", fname); - exit(1); - } - if (fseek(f, 0, SEEK_END)) { - debug_board_printf("Can't SEEK_END file: %s", fname); - exit(1); - } - int filesize = ftell(f); - rewind(f); - char* fdata = malloc(filesize); - if(!fdata) { - debug_board_printf("No memory for file %s", fname); - exit(1); - } - *read_sz = fread(fdata, 1, filesize, f); - if (ferror(f)) { - debug_board_printf("Error reading file %s", fname); - exit(1); - } - fclose(f); - - return fdata; -} - - -void __attribute__ ((noinline)) debug_board_write_str(const char* str){ - while(*str) - debug_board_write_byte(*str++); -} - -void __attribute__ ((noinline)) debug_board_printf(const char *format,...) -{ - va_list ap; - char log_board[300]; - - va_start (ap, format); - tiny_vsnprintf(log_board, sizeof log_board, format, ap); - va_end(ap); - debug_board_write_str(log_board); - -}