diff --git a/contrib/C_Layer/buf2d/kolibri_buf2d.h b/contrib/C_Layer/buf2d/kolibri_buf2d.h new file mode 100644 index 0000000000..b27e459908 --- /dev/null +++ b/contrib/C_Layer/buf2d/kolibri_buf2d.h @@ -0,0 +1,90 @@ +#ifndef KOLIBRI_BUF2D_H +#define KOLIBRI_BUF2D_H + +/*ToDo + * buf_curve_bezier + * voxel function + */ + +extern int init_buf2d_asm(void); + +int kolibri_buf2d_init(void) +{ + int asm_init_status = init_buf2d_asm(); + + /* just return asm_init_status? or return init_boxlib_asm() ?*/ + + if(asm_init_status == 0) + return 0; + else + return 1; +} + + +struct buf2d_struct { + unsigned int *buf_pointer; + uint16_t left; + uint16_t top; + unsigned int width; + unsigned int height; + unsigned int bgcolor; + uint8_t color_bit; +}; + +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)(struct buf2d_struct *) __attribute__((__stdcall__)); + +struct buf2d_struct* buf2d_create(uint16_t tlx, uint16_t tly, unsigned int sizex, unsigned int sizey, unsigned int font_bgcolor, uint8_t color_bit) +{ + struct buf2d_struct *new_buf2d_struct = (struct buf2d_struct *)malloc(sizeof(struct 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; +} + +extern void (*buf2d_draw)(struct buf2d_struct *) __attribute__((__stdcall__)); +extern void (*buf2d_clear)(struct buf2d_struct *, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_delete)(struct buf2d_struct *) __attribute__((__stdcall__)); +extern void (*buf2d_rotate)(struct buf2d_struct *, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_resize)(struct buf2d_struct *, unsigned int, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_line)(struct buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_line_sm)(struct buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_rect_by_size)(struct buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_filled_rect_by_size)(struct buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_circle)(struct buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_img_hdiv2)(struct buf2d_struct *) __attribute__((__stdcall__)); +extern void (*buf2d_img_wdiv2)(struct buf2d_struct *) __attribute__((__stdcall__)); +extern void (*buf2d_conv_24_to_8)(struct buf2d_struct *, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_conv_24_to_32)(struct buf2d_struct *, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_bit_blt_transp)(struct buf2d_struct *, unsigned int, unsigned int, struct buf2d_struct *) __attribute__((__stdcall__)); +extern void (*buf2d_bit_blt_alpha)(struct buf2d_struct *, unsigned int, unsigned int, struct buf2d_struct *) __attribute__((__stdcall__)); +extern void (*buf2d_convert_text_matrix)(struct buf2d_struct *) __attribute__((__stdcall__)); +extern void (*buf2d_draw_text)(struct buf2d_struct *, struct buf2d_struct *, const char *, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_crop_color)(struct buf2d_struct *, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_offset_h)(struct buf2d_struct *, unsigned int, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_flood_fill)(struct buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_set_pixel)(struct buf2d_struct *, unsigned int, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern unsigned int (*buf2d_get_pixel)(struct buf2d_struct *, unsigned int, unsigned int) __attribute__((__stdcall__)); +extern void (*buf2d_flip_h)(struct buf2d_struct *) __attribute__((__stdcall__)); +extern void (*buf2d_flip_v)(struct buf2d_struct *) __attribute__((__stdcall__)); +extern void (*buf2d_filter_dither)(struct buf2d_struct *, unsigned int) __attribute__((__stdcall__)); +#endif /* KOLIBRI_BUF2D_H */ diff --git a/contrib/C_Layer/buf2d/loadbuf2d.asm b/contrib/C_Layer/buf2d/loadbuf2d.asm new file mode 100644 index 0000000000..6bc2cf1dc1 --- /dev/null +++ b/contrib/C_Layer/buf2d/loadbuf2d.asm @@ -0,0 +1,94 @@ + +format coff +use32 ; Tell compiler to use 32 bit instructions + +section '.init' code ; Keep this line before includes or GCC messes up call addresses + +include '../../../programs/proc32.inc' +include '../../../programs/macros.inc' +purge section,mov,add,sub + +include '../../../programs/dll.inc' + +public init_buf2d as '_init_buf2d_asm' +;;; Returns 0 on success. -1 on failure. + +proc init_buf2d + + mcall 68,11 + + stdcall dll.Load, @IMPORT + test eax, eax + jnz error + + mov eax, 0 + ret + +error: + mov eax, -1 + ret +endp + +@IMPORT: +library lib_buf2d, 'buf2d.obj' + +import lib_buf2d, \ + 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 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'