Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8101 → Rev 8102

/programs/develop/ktcc/trunk/lib/libgb/Makefile
0,0 → 1,9
# gcc not kos32-gcc
all:
gcc -c -O2 -nostdinc -nostdlib -m32 -march=i686 -fomit-frame-pointer -fno-builtin -fno-builtin-printf gb.c
ar -rcs libgb.a gb.o
clean:
rm -f *.o
rm -f *.a
install:
cp libgb.a ../../bin/lib
/programs/develop/ktcc/trunk/lib/libgb/gb.c
0,0 → 1,270
 
#include "gb.h"
 
//=========================
 
void gb_pixel_set(GB_BMP *b, int x, int y, unsigned c)
{
// ïîñòàâèòü òî÷êó
 
unsigned s;
 
if ((x+1 > b->w )||(y+1 > b->h))
return;
 
if ((x < 0)||(y < 0))
return;
 
s = 3*( y*(b->w) + x );
 
*( b -> bmp + s ) = c & 0xff;
*( b -> bmp + s + 1) = (c >> 8) & 0xff;
*( b -> bmp + s + 2) = (c >> 16)& 0xff;
 
}
 
//=========================
 
int gb_pixel_get(GB_BMP *b, int x, int y, unsigned *c)
{
// ïîëó÷èòü òî÷êó
 
unsigned red, green, blue, s;
 
if ((x < 0) || (y < 0))
return 0;
 
if ((x+1 > b->w )||(y+1 > b->h))
return 0;
 
s = 3*( y*(b->w) + x );
 
blue = *( b -> bmp + s );
green = *( b -> bmp + s + 1);
red = *( b -> bmp + s + 2);
 
*c = ((red << 16) & 0xff0000) | ((green << 8) & 0xff00) | (blue & 0xff);
 
return 1;
}
 
//=========================
 
void gb_line(GB_BMP *b, int x1, int y1, int x2, int y2, unsigned c)
{
// ëèíèÿ çàäàííîãî öâåòà ñ èñïîëüçîâàíèåì
// àëãîpèòìà Áðåçåíõýìà
 
int t, dist;
int xerr=0, yerr=0, delta_x, delta_y;
int incx, incy;
 
// âû÷èñëåíèå pàññòîÿíèÿ â îáîèõ íàïpàâëåíèÿõ
delta_x = x2 - x1;
delta_y = y2 - y1;
 
// îïpåäåëåíèå íàïpàâëåíèÿ øàãà,
// øàã âû÷èñëÿåòñÿ ëèáî ïî âåpòèêàëüíîé, ëèáî ãîpèçîíòàëüíîé
// ëèíèè
if (delta_x > 0)
incx = 1;
else
if (0 == delta_x)
incx = 0;
else
incx = -1;
 
if (delta_y > 0)
incy = 1;
else
if ( 0 == delta_y)
incy = 0;
else
incy = -1;
 
// îïpåäåëåíèå íàèáîëüøåãî pàññòîÿíèÿ
if (delta_x < 0)
delta_x *= -1;
if (delta_y < 0)
delta_y *= -1;
 
if (delta_x > delta_y)
dist = delta_x;
else
dist = delta_y;
 
 
// âû÷åp÷èâàíèå ëèíèè
for (t = 0; t <= dist+1; t++)
{
gb_pixel_set(b, x1, y1, c);
xerr+=delta_x;
yerr+=delta_y;
 
if (xerr > dist)
{
xerr -= dist;
x1 += incx;
}
 
if (yerr > dist)
{
yerr -= dist;
y1 += incy;
}
 
}
}
 
//=========================
 
void gb_rect(GB_BMP *b, int x, int y, int w, int h, unsigned c)
{
// ïðÿìîóãîëüíèê
 
gb_line (b, x, y, x+w-1, y, c);
gb_line (b, x, y+h-1, x+w-1, y+h-1, c);
gb_line (b, x, y, x, y+h-1, c);
gb_line (b, x+w-1, y, x+w-1, y+h-1, c);
}
 
//=========================
 
void gb_circle(GB_BMP *b, int x, int y, int r, unsigned c)
{
 
int _x;
int _y;
int d;
 
_x = 0;
_y = r;
d = 3-2*r;
while( _y >= _x)
{
gb_pixel_set(b, _x + x, _y + y, c);
gb_pixel_set(b, _x + x, -_y + y, c);
gb_pixel_set(b, -_x + x, _y + y, c);
gb_pixel_set(b, -_x + x, -_y + y, c);
gb_pixel_set(b, _y + x, _x + y, c);
gb_pixel_set(b, _y + x, -_x + y, c);
gb_pixel_set(b, -_y + x, _x + y, c);
gb_pixel_set(b, -_y + x, -_x + y, c);
if( d<0 )
d = d+4*_x+6;
else
{
d = d+4*(_x-_y)+10;
_y--;
}
_x++;
}
 
}
 
//=========================
 
void gb_bar(GB_BMP *b, int x, int y, int w, int h, unsigned c)
{
// çàêðàøåííûé ïðÿìîóãîëüíèê
 
unsigned s;
int i, j;
 
if ((x > b->w)||(y > b->h))
return;
 
for (j = 0; j < w; j++)
for (i = 0; i < h; i++)
// gb_pixel_set(b, x+j, y+i, c);
{
s = 3*( (y+i)*(b->w) + x + j );
 
*( b -> bmp + s ) = c & 0xff;
*( b -> bmp + s + 1) = (c >> 8) & 0xff;
*( b -> bmp + s + 2) = (c >> 16)& 0xff;
 
}
}
 
//=========================
 
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)
{
// âûâîä èçîáðàæåíèÿ
 
int x, y;
unsigned d;
 
if ((x_d > b_dest->w)||(y_d > b_dest->h))
return;
 
if ((x_s > b_src->w)||(y_s > b_src->h))
return;
 
for (y = 0; y < h; y++)
for (x = 0; x < w; x++)
if ( gb_pixel_get(b_src, x_s+x, y_s+y, &d) )
gb_pixel_set(b_dest, x_d+x, y_d+y, d);
 
 
}
 
//=========================
 
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)
{
// âûâîä èçîáðàæåíèÿ ñ ïðîçðà÷íûì öâåòîì
 
int x, y;
unsigned d;
 
if ((x_d > b_dest->w)||(y_d > b_dest->h))
return;
 
if ((x_s > b_src->w)||(y_s > b_src->h))
return;
 
for (y = 0; y < h; y++)
for (x = 0; x < w; x++)
if ( gb_pixel_get(b_src, x_s+x, y_s+y, &d) )
if (c != d)
gb_pixel_set(b_dest, x_d+x, y_d+y, d);
 
 
}
 
//=========================
 
#define NULL ((void*)0)
 
typedef struct
{
void *name;
void *function;
} export_t;
 
//=========================
 
char szGb_pixel_set[] = "gb_pixel_set";
char szGb_pixel_get[] = "gb_pixel_get";
char szGb_line[] = "gb_line";
char szGb_rect[] = "gb_rect";
char szGb_bar[] = "gb_bar";
char szGb_circle[] = "gb_circle";
char szGb_image_set[] = "gb_image_set";
char szGb_image_set_t[] = "gb_image_set_t";
 
export_t EXPORTS[] =
{
{ szGb_pixel_set, (void*) gb_pixel_set},
{ szGb_pixel_get, (void*) gb_pixel_get},
{ szGb_line, (void*) gb_line},
{ szGb_rect, (void*) gb_rect},
{ szGb_bar, (void*) gb_bar},
{ szGb_circle, (void*) gb_circle},
{ szGb_image_set, (void*) gb_image_set},
{ szGb_image_set_t, (void*) gb_image_set_t},
{ NULL, NULL },
};
 
/programs/develop/ktcc/trunk/lib/libgb/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/lib/libimg/Makefile
0,0 → 1,5
all:
fasm loadlibimg.asm
ar -csr libimg.a loadlibimg.o
clean:
rm -f *.o *.a
/programs/develop/ktcc/trunk/lib/libimg/loadlibimg.asm
0,0 → 1,87
format elf
use32 ; Tell compiler to use 32 bit instructions
 
; ELF section
section '.text' executable
 
 
include '../../../../../proc32.inc'
include '../../../../../macros.inc'
purge section,mov,add,sub
include '../../../../../dll.inc'
 
public init_libimg as 'kolibri_libimg_init'
;;; Returns 0 on success. -1 on failure.
 
proc init_libimg
local retval dd ?
mov [retval], eax
pusha
mcall 68, 11
test eax, eax
jnz @f
mov [retval], -1
jmp exit_init_libimg
@@:
stdcall dll.Load, @IMPORT
test eax, eax
jz exit_init_libimg
mov [retval], -1
exit_init_libimg:
popa
mov eax, [retval]
ret
endp
 
; ELF section
section '.data' writeable
 
@IMPORT:
library lib_libimg, 'libimg.obj'
 
import lib_libimg, \
libimg_init, 'lib_init' , \
img_is_img, 'img_is_img' , \
img_info, 'img_info' , \
img_from_file, 'img_from_file', \
img_to_file, 'img_to_file', \
img_from_rgb, 'img_from_rgb', \
img_to_rgb, 'img_to_rgb', \
img_to_rgb2, 'img_to_rgb2', \
img_decode, 'img_decode', \
img_encode, 'img_encode', \
img_create, 'img_create', \
img_destroy, 'img_destroy', \
img_destroy_layer, 'img_destroy_layer', \
img_count, 'img_count', \
img_lock_bits, 'img_lock_bits', \
img_unlock_bits, 'img_unlock_bits', \
img_flip, 'img_flip', \
img_flip_layer, 'img_flip_layer', \
img_rotate, 'img_rotate', \
img_rotate_layer, 'img_rotate_layer', \
img_draw, 'img_draw'
public libimg_init as 'libimg_init'
; public img_is_img as '_img_is_img'
;public img_info as '_img_info'
;public img_from_file as '_img_from_file'
;public img_to_file as '_img_to_file'
;public img_from_rgb as '_img_from_rgb'
public img_to_rgb as 'img_to_rgb'
public img_to_rgb2 as 'img_to_rgb2'
public img_decode as 'img_decode'
public img_encode as 'img_encode'
public img_create as 'img_create'
public img_destroy as 'img_destroy'
public img_destroy_layer as 'img_destroy_layer'
public img_count as 'img_count'
;public img_lock_bits as '_img_lock_bits'
;public img_unlock_bits as '_img_unlock_bits'
public img_flip as 'img_flip'
public img_flip_layer as 'img_flip_layer'
public img_rotate as 'img_rotate'
public img_rotate_layer as 'img_rotate_layer'
public img_draw as 'img_draw'
/programs/develop/ktcc/trunk/lib/librasterworks/__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/librasterworks/__lib__.inc
0,0 → 1,2
lib_name equ @RASTERWORKS.OBJ
lib_name_str equ '/sys/lib/RASTERWORKS.OBJ'
/programs/develop/ktcc/trunk/lib/librasterworks/charsFit.asm
0,0 → 1,18
format ELF
 
include "__lib__.inc"
 
fun equ charsFit
fun_str equ 'charsFit'
 
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/librasterworks/cntUTF-8.asm
0,0 → 1,18
format ELF
 
include "__lib__.inc"
 
fun equ countUTF8Z
fun_str equ 'cntUTF-8'
 
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/librasterworks/drawText.asm
0,0 → 1,18
format ELF
 
include "__lib__.inc"
 
fun equ drawText
fun_str equ 'drawText'
 
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/librasterworks/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/librasterworks/makefile
0,0 → 1,9
all:
fasm __lib__.asm
fasm charsFit.asm
fasm cntUTF-8.asm
fasm drawText.asm
fasm strWidth.asm
ar -crs librasterworks.a *.o
clean:
rm -f *.o
/programs/develop/ktcc/trunk/lib/librasterworks/strWidth.asm
0,0 → 1,18
format ELF
 
include "__lib__.inc"
 
fun equ strWidth
fun_str equ 'strWidth'
 
section '.text'
 
fun_name db fun_str, 0
 
section '.data'
 
extrn lib_name
public fun
 
fun dd fun_name
lib dd lib_name