- Added libbox.a and libbuf2d.a to TinyC.

- The structure of the header files has been reorganized.

git-svn-id: svn://kolibrios.org@8107 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
superturbocat2001 2020-10-17 17:31:09 +00:00
parent 6154138ea6
commit 6d98726351
18 changed files with 202 additions and 193 deletions

Binary file not shown.

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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'

View File

@ -0,0 +1,83 @@
#ifndef KOLIBRI_BUF2D_H
#define KOLIBRI_BUF2D_H
#include <stdint.h>
/*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 */

View File

@ -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 <clayer/boxlib.h>
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)

View File

@ -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

View File

@ -1,4 +1,3 @@
// sample writed by maxcodehack
#include <kos32sys1.h>
#include <stdlib.h>
#include <clayer/boxlib.h>

View File

@ -1,4 +1,4 @@
#include <kos/msgbox.h>
#include <clayer/msgbox.h>
int main()
{

View File

@ -2,7 +2,7 @@
#include <string.h>
#include <stdio.h>
#include <kos32sys1.h>
#include <kos/rasterworks.h>
#include <clayer/rasterworks.h>
int main()
{

View File

@ -1 +0,0 @@
kos32-tcc boxlib.c loadboxlib.o -lck -o boxlib.kex

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

View File

@ -1,153 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <kos/libimg.h>
#include <kos32sys1.h>
#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);
}