Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 8100 → Rev 8101

/programs/develop/ktcc/trunk/bin/lib/libgb.a
Cannot display: file marked as a binary type.
svn:mime-type = application/x-archive
Property changes:
Added: svn:mime-type
+application/x-archive
\ No newline at end of property
/programs/develop/ktcc/trunk/bin/lib/libimg.a
Cannot display: file marked as a binary type.
svn:mime-type = application/x-archive
Property changes:
Added: svn:mime-type
+application/x-archive
\ No newline at end of property
/programs/develop/ktcc/trunk/bin/lib/libmsgbox.a
Cannot display: file marked as a binary type.
svn:mime-type = application/x-archive
Property changes:
Added: svn:mime-type
+application/x-archive
\ No newline at end of property
/programs/develop/ktcc/trunk/bin/lib/librasterworks.a
Cannot display: file marked as a binary type.
svn:mime-type = application/x-archive
Property changes:
Added: svn:mime-type
+application/x-archive
\ No newline at end of property
/programs/develop/ktcc/trunk/lib/msgbox/__lib__.asm
0,0 → 1,9
format ELF
 
include '__lib__.inc'
 
section '.text'
 
public lib_name
 
lib_name db 0x55, 0xAA, lib_name_str, 0
/programs/develop/ktcc/trunk/lib/msgbox/__lib__.inc
0,0 → 1,2
lib_name equ @msgbox.obj
lib_name_str equ '/sys/lib/msgbox.obj'
/programs/develop/ktcc/trunk/lib/msgbox/make.bat
0,0 → 1,7
fasm __lib__.asm
fasm mb_create.asm
fasm mb_reinit.asm
fasm mb_setfunctions.asm
kos32-ar -ru libmsgbox.a *.o
del *.o
pause
/programs/develop/ktcc/trunk/lib/msgbox/makefile
0,0 → 1,8
all:
fasm __lib__.asm
fasm mb_create.asm
fasm mb_reinit.asm
fasm mb_setfunctions.asm
kos32-ar -ru libmsgbox.a *.o
clean:
rm -f *.o
/programs/develop/ktcc/trunk/lib/msgbox/mb_create.asm
0,0 → 1,18
format ELF
 
include "__lib__.inc"
 
fun equ msgbox_create
fun_str equ 'mb_create'
 
section '.text'
 
fun_name db fun_str, 0
 
section '.data'
 
extrn lib_name
public fun
 
fun dd fun_name
lib dd lib_name
/programs/develop/ktcc/trunk/lib/msgbox/mb_reinit.asm
0,0 → 1,18
format ELF
 
include "__lib__.inc"
 
fun equ msgbox_reinit
fun_str equ 'mb_reinit'
 
section '.text'
 
fun_name db fun_str, 0
 
section '.data'
 
extrn lib_name
public fun
 
fun dd fun_name
lib dd lib_name
/programs/develop/ktcc/trunk/lib/msgbox/mb_setfunctions.asm
0,0 → 1,18
format ELF
 
include "__lib__.inc"
 
fun equ msgbox_setfunctions
fun_str equ 'mb_setfunctions'
 
section '.text'
 
fun_name db fun_str, 0
 
section '.data'
 
extrn lib_name
public fun
 
fun dd fun_name
lib dd lib_name
/programs/develop/ktcc/trunk/libc/include/kos/gb.h
0,0 → 1,19
 
#pragma pack(push, 1)
typedef struct
{
int w;
int h;
char *bmp;
char *alpha;
} GB_BMP;
#pragma pack(pop)
 
void gb_pixel_set(GB_BMP *b, int x, int y, unsigned c);
int gb_pixel_get(GB_BMP *b, int x, int y, unsigned *c);
void gb_line(GB_BMP *b, int x1, int y1, int x2, int y2, unsigned c);
void gb_rect(GB_BMP *b, int x, int y, int w, int h, unsigned c);
void gb_bar(GB_BMP *b, int x, int y, int w, int h, unsigned c);
void gb_circle(GB_BMP *b, int x, int y, int r, unsigned c);
void gb_image_set(GB_BMP *b_dest, int x_d, int y_d, GB_BMP *b_src, int x_s, int y_s, int w, int h);
void gb_image_set_t(GB_BMP *b_dest, int x_d, int y_d, GB_BMP *b_src, int x_s, int y_s, int w, int h, unsigned c);
/programs/develop/ktcc/trunk/libc/include/kos/libimg.h
0,0 → 1,64
#ifndef KOLIBRI_LIBIMG_H
#define KOLIBRI_LIBIMG_H
 
extern int kolibri_libimg_init(void);
 
//list of format id's
#define LIBIMG_FORMAT_BMP 1
#define LIBIMG_FORMAT_ICO 2
#define LIBIMG_FORMAT_CUR 3
#define LIBIMG_FORMAT_GIF 4
#define LIBIMG_FORMAT_PNG 5
#define LIBIMG_FORMAT_JPEG 6
#define LIBIMG_FORMAT_TGA 7
#define LIBIMG_FORMAT_PCX 8
#define LIBIMG_FORMAT_XCF 9
#define LIBIMG_FORMAT_TIFF 10
#define LIBIMG_FORMAT_PNM 11
#define LIBIMG_FORMAT_WBMP 12
#define LIBIMG_FORMAT_XBM 13
#define LIBIMG_FORMAT_Z80 14
 
//error codes
#define LIBIMG_ERROR_OUT_OF_MEMORY 1
#define LIBIMG_ERROR_FORMAT 2
#define LIBIMG_ERROR_CONDITIONS 3
#define LIBIMG_ERROR_BIT_DEPTH 4
#define LIBIMG_ERROR_ENCODER 5
#define LIBIMG_ERROR_SRC_TYPE 6
#define LIBIMG_ERROR_SCALE 7
#define LIBIMG_ERROR_INTER 8
#define LIBIMG_ERROR_NOT_INPLEMENTED 9
#define LIBIMG_ERROR_INVALID_INPUT 10
 
//encode flags (byte 0x02 of _common option)
#define LIBIMG_ENCODE_STRICT_SPECIFIC 0x01
#define LIBIMG_ENCODE_STRICT_BIT_DEPTH 0x02
#define LIBIMG_ENCODE_DELETE_ALPHA 0x08
#define LIBIMG_ENCODE_FLUSH_ALPHA 0x10
 
 
#define FLIP_VERTICAL 0x01
#define FLIP_HORIZONTAL 0x02
 
#define ROTATE_90_CW 0x01
#define ROTATE_180 0x02
#define ROTATE_270_CW 0x03
#define ROTATE_90_CCW ROTATE_270_CW
#define ROTATE_270_CCW ROTATE_90_CW
 
extern void* (*img_decode __attribute__((__stdcall__)))(void *, uint32_t, uint32_t);
extern void* (*img_encode __attribute__((__stdcall__)))(void *, uint32_t, uint32_t);
extern void* (*img_create __attribute__((__stdcall__)))(uint32_t, uint32_t, uint32_t);
extern void (*img_to_rgb2 __attribute__((__stdcall__)))(void *, void *);
extern void* (*img_to_rgb __attribute__((__stdcall__)))(void *);
extern uint32_t (*img_flip __attribute__((__stdcall__)))(void *, uint32_t);
extern uint32_t (*img_flip_layer __attribute__((__stdcall__)))(void *, uint32_t);
extern uint32_t (*img_rotate __attribute__((__stdcall__)))(void *, uint32_t);
extern uint32_t (*img_rotate_layer __attribute__((__stdcall__)))(void *, uint32_t);
extern void (*img_draw __attribute__((__stdcall__)))(void *, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t );
extern uint32_t (*img_count __attribute__((__stdcall__)))(void *);
extern uint32_t (*img_destroy __attribute__((__stdcall__)))(void *) ;
extern uint32_t (*img_destroy_layer __attribute__((__stdcall__)))(void *);
 
#endif /* KOLIBRI_LIBIMG_H */
/programs/develop/ktcc/trunk/libc/include/kos/msgbox.h
16,9 → 16,9
 
typedef void (*msgbox_callback)(void);
 
extern void (*msgbox_create)(msgbox *, void *thread) __attribute__((__stdcall__)); // clears callbacks, ! if fix lib, we can return eax as of Fn51
extern void (*msgbox_setfunctions)(msgbox_callback*) __attribute__((__stdcall__)); // must be called immediately after create, zero-ended array
extern void (*msgbox_reinit)(msgbox *) __attribute__((__stdcall__)); // recalc sizes when structure changes, called auto when MsgBoxCreate
extern void (*msgbox_create __attribute__((__stdcall__)))(msgbox *, void *thread); // clears callbacks, ! if fix lib, we can return eax as of Fn51
extern void (*msgbox_setfunctions __attribute__((__stdcall__)))(msgbox_callback*); // must be called immediately after create, zero-ended array
extern void (*msgbox_reinit __attribute__((__stdcall__)))(msgbox *) ; // recalc sizes when structure changes, called auto when MsgBoxCreate
 
static inline msgbox* kolibri_new_msgbox(char* title, char* text, int def_but, ...)
/// text can be multilined by code 13 = "\r"
/programs/develop/ktcc/trunk/libc/include/kos/rasterworks.h
0,0 → 1,11
#ifndef KOLIBRI_RASTERWORKS_H
#define KOLIBRI_RASTERWORKS_H
 
//extern int kolibri_rasterworks_init(void);
 
extern void (*drawText __attribute__((__stdcall__)))(void *canvas, int x, int y, const char *string, int charQuantity, int fontColor, int params);
extern int (*countUTF8Z __attribute__((__stdcall__)))(const char *string, int byteQuantity);
extern int (*charsFit __attribute__((__stdcall__)))(int areaWidth, int charHeight);
extern int (*strWidth __attribute__((__stdcall__)))(int charQuantity, int charHeight);
 
#endif /* KOLIBRI_RASTERWORKS_H */
/programs/develop/ktcc/trunk/samples/build_all.sh
6,4 → 6,7
../tcc dynamic.c -lconsole -lhttp -linputbox -o dynamic
../tcc load_coff.c -o load_coff -lck
../tcc 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
exit
/programs/develop/ktcc/trunk/samples/cxx_price.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes:
Added: svn:mime-type
+image/png
\ No newline at end of property
/programs/develop/ktcc/trunk/samples/graphics.c
0,0 → 1,53
#include <kos32sys1.h>
#include <stdlib.h>
#include <string.h>
#include <kos/gb.h>
 
/// ===========================================================
 
int main()
{
GB_BMP b;
unsigned event;
 
b.w = 300;
b.h = 200;
b.bmp = malloc (300*200*3);
 
gb_bar (&b, 4, 8, 4, 12, 0xff0000); // red
gb_bar (&b, 10, 8, 4, 12, 0x00ff00); // green
gb_bar (&b, 16, 8, 4, 12, 0x0000ff); // blue
 
gb_line(&b, 4, 30, 50, 30, 0xffffff); // white line
gb_line(&b, 55, 4, 120, 60, 0xf0f033); // another line
 
gb_rect(&b, 65, 24, 100, 60, 0x2065ff); // rectangle
 
gb_circle(&b, 55, 95, 40, 0x20ff20); // circle
 
for (;;)
{
event = get_os_event();
switch (event)
{
case 1:
begin_draw();
sys_create_window(50, 50, 310, 230, "testlibgb" ,0x34f0f0f0, 0x14);
draw_bitmap(b.bmp, 5, 25, 300, 200);
end_draw();
break;
case 2:
get_key();
break;
 
case 3:
if (1==get_os_button())
{
exit(0);
}
break;
};
}
exit(0);
}
/// ===========================================================
/programs/develop/ktcc/trunk/samples/libimgdemo.c
0,0 → 1,153
#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);
 
}
/programs/develop/ktcc/trunk/samples/rasterworks.c
0,0 → 1,45
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <kos32sys1.h>
#include <kos/rasterworks.h>
 
int main()
{
unsigned int event;
int ln_str = countUTF8Z("Example", -1);
void *buffi = malloc(768*256*3 * sizeof(char));
*((int*)buffi) = 768;
*((int*)buffi+1) = 256;
memset((char*)buffi+8, (char)-1, 768*256*3);
drawText(buffi, 0, 0, "Example", ln_str, 0xFF000000, 0x30C18);
drawText(buffi, 0, 32, "Example", ln_str, 0xFF000000, 0x1030C18);
drawText(buffi, 0, 64, "Example", ln_str, 0xFF000000, 0x2030C18);
drawText(buffi, 0, 96, "Example", ln_str, 0xFF000000, 0x4030C18);
drawText(buffi, 0, 128, "Example", ln_str, 0xFF000000, 0x8030C18);
drawText(buffi, 0, 160, "Example", ln_str, 0xFF000000, 0x0F031428);
for (;;){
event = get_os_event();
switch (event)
{
case 1:
begin_draw();
sys_create_window(50, 50, 800, 300, "rasterworks example" ,0x34f0f0f0, 0x14);
draw_bitmap(buffi, 5, 25, 768, 256);
end_draw();
break;
 
case 2:
get_key();
break;
 
case 3:
if (1==get_os_button())
{
exit(0);
}
break;
};
}
exit(0);
}