/programs/bcc32/examples/file_open/file_open_cpp.bat |
---|
2,8 → 2,8 |
Set BCC_DIR=..\..\..\bcc32 |
kos32-bcc -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -I..\..\..\bcc32\include %NAME%.cpp |
echo STACKSIZE equ 102400> kos_make.inc |
echo HEAPSIZE equ 102400>> kos_make.inc |
echo STACKSIZE equ 8192> kos_make.inc |
echo HEAPSIZE equ 0>> kos_make.inc |
echo include "%BCC_DIR%\include\kos_start.inc">> kos_make.inc |
echo include "%BCC_DIR%\include\kos_func.inc">> kos_make.inc |
echo include "%BCC_DIR%\include\kos_heap.inc">> kos_make.inc |
/programs/bcc32/examples/libimg_1/1.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/bcc32/examples/libimg_1/Makefile |
---|
0,0 → 1,19 |
# Path to /programs |
SVN_PROGR:=../../.. |
# Path to /programs/bcc32 |
SVN_BCC32:=$(SVN_PROGR)/bcc32 |
# Path to t2fasm |
T2FASM:=$(SVN_BCC32)/t2fasm |
# Path to include |
INCLUDE:=$(SVN_BCC32)/include |
# Path to Bin folder |
KOS32_BCC:=/home/autobuild/borlandcpp/bin |
# Filename without .cpp |
FILENAME:=libimg_1 |
include $(SVN_BCC32)/Makefile_app |
/programs/bcc32/examples/libimg_1/libimg_1.cpp |
---|
0,0 → 1,81 |
#include <kolibri.h> |
#include <kos_heap.h> |
#include <kos_file.h> |
#include <load_lib.h> |
#include <l_libimg.h> |
using namespace Kolibri; |
const char header[] = "Image"; |
unsigned char* img_d = 0; |
long img_w, img_h; |
char library_path[2048]; |
namespace Kolibri{ |
char CurrentDirectoryPath[2048]; |
} |
bool KolibriOnStart(TStartData &kos_start, TThreadData /*th*/) |
{ |
kos_start.Left = 10; |
kos_start.Top = 40; |
kos_start.Width = 280; |
kos_start.Height = 200; |
kos_start.WinData.WindowColor = 0xFFFFFF; |
kos_start.WinData.WindowType = 0x33; // 0x34 - fixed, 0x33 - not fixed |
kos_start.WinData.Title = header; |
LoadLibrary("libimg.obj", library_path, "/sys/lib/libimg.obj", &import_libimg); |
return true; |
} |
void KolibriOnPaint(void) |
{ |
// If button have ID 1, this is close button |
DrawButton(2,0xf0f0f0, 10,10,50,20); |
DrawText(20,16,0,"Open"); |
if(img_d) PutImage(img_d,10,40,img_w,img_h); |
} |
void KolibriOnButton(long id, TThreadData /*th*/) |
{ |
FileInfoBlock* file; |
long int k; |
switch(id){ |
case 2: |
file = FileOpen("1.png"); |
if (!file){ |
SetWindowCaption("Error open file '1.png'"); |
break; |
} |
k = FileGetLength(file); |
if (k > 0){ |
if(img_d) Free(img_d); |
img_d = (unsigned char*)Alloc(k); |
if (img_d){ |
if (FileRead(file, img_d, k) != k){ |
Free(img_d); img_d = 0; |
} |
else{ |
Image* img; |
img = img_decode(img_d,k,0); |
img_w = img->Width; |
img_h = img->Height; |
img_d = (unsigned char*)ReAlloc(img_d, 3*img_w*img_h); |
//if (!img_d){ ... } |
img_to_rgb2(img,img_d); |
img_destroy(img); |
SetWindowCaption("1.png"); |
Redraw(1); |
} |
} |
} |
FileClose(file); |
//break; |
}; |
} |
bool KolibriOnClose(TThreadData /*th*/) { |
if(img_d) {Free(img_d); img_d = 0;} |
return true; |
} |
/programs/bcc32/examples/libimg_1/libimg_1_cpp.bat |
---|
0,0 → 1,16 |
Set NAME=libimg_1 |
Set BCC_DIR=..\..\..\bcc32 |
kos32-bcc -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -I..\..\..\bcc32\include %NAME%.cpp |
echo STACKSIZE equ 8192> kos_make.inc |
echo HEAPSIZE equ 0>> kos_make.inc |
echo include "%BCC_DIR%\include\kos_start.inc">> kos_make.inc |
echo include "%BCC_DIR%\include\kos_func.inc">> kos_make.inc |
echo include "%BCC_DIR%\include\kos_heap.inc">> kos_make.inc |
echo include "kos_make.inc" > f_%NAME%.asm |
t2fasm < %NAME%.asm >> f_%NAME%.asm |
fasm f_%NAME%.asm %NAME%.kex |
if exist %NAME%.kex kpack %NAME%.kex |
if exist %NAME%.kex del kos_make.inc |
pause |
/programs/bcc32/examples/template/template_cpp.bat |
---|
2,8 → 2,8 |
Set BCC_DIR=..\..\..\bcc32 |
kos32-bcc -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -I..\..\..\bcc32\include %NAME%.cpp |
echo STACKSIZE equ 102400> kos_make.inc |
echo HEAPSIZE equ 102400>> kos_make.inc |
echo STACKSIZE equ 8192> kos_make.inc |
echo HEAPSIZE equ 0>> kos_make.inc |
echo include "%BCC_DIR%\include\kos_start.inc">> kos_make.inc |
echo include "%BCC_DIR%\include\kos_func.inc">> kos_make.inc |
echo include "%BCC_DIR%\include\kos_heap.inc">> kos_make.inc |
/programs/bcc32/examples/window/window_cpp.bat |
---|
2,8 → 2,8 |
Set BCC_DIR=..\..\..\bcc32 |
kos32-bcc -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -I..\..\..\bcc32\include %NAME%.cpp |
echo STACKSIZE equ 102400> kos_make.inc |
echo HEAPSIZE equ 102400>> kos_make.inc |
echo STACKSIZE equ 8192> kos_make.inc |
echo HEAPSIZE equ 0>> kos_make.inc |
echo include "%BCC_DIR%\include\kos_start.inc">> kos_make.inc |
echo include "%BCC_DIR%\include\kos_func.inc">> kos_make.inc |
echo include "%BCC_DIR%\include\kos_heap.inc">> kos_make.inc |
/programs/bcc32/include/kolibri.h |
---|
8,7 → 8,7 |
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace. |
{ |
const char *DebugPrefix = "User program: "; |
char CommandLine[257]; |
char CommandLine[4096]; |
struct TWindowData // Data for drawing a window. |
{ |
135,6 → 135,7 |
//_ of the stack if (stack_end) is zero or (stack_size) is not zero, in this case stack |
//_ will be deleted automaticaly from dynamic memory at the finish of the thread. |
void DrawText(short x, short y, int color, const char* string); |
void PutImage(unsigned char* img_data, long img_l, long img_t, long img_w, long img_h); |
void SetWindowCaption(const char* caption); |
} |
/programs/bcc32/include/kos_func.inc |
---|
77,16 → 77,13 |
mov ebx,esp |
mov ecx,-1 |
int 0x40 |
mov ebx,[esp+26] |
mov edx,[esp+30] |
mov ebx,[esp+process_information.used_memory] |
mov edx,[esp+process_information.PID] |
lea eax,[ebx-0x20] |
add esp,1024 |
cmp esp,eax |
cmova esp,eax |
and esp,not 3 |
if defined @Kolibri@CommandLine |
mov byte [@Kolibri@CommandLine+256], 0 |
end if |
xor eax,eax |
cld |
mov edi,@Kolibri@_ThreadTable |
173,10 → 170,10 |
mov ebx,esp |
mov ecx,-1 |
int 0x40 |
mov eax,[esp+34] |
mov ebx,[esp+38] |
mov ecx,[esp+42] |
mov edx,[esp+46] |
mov eax,[esp+process_information.box.left] |
mov ebx,[esp+process_information.box.top] |
mov ecx,[esp+process_information.box.width] |
mov edx,[esp+process_information.box.height] |
add esp,1024 |
cmp ecx,[esp+KOLIBRI_THREAD_DATA_LAST_SX*4] |
jnz .main_size |
332,15 → 329,6 |
ret |
endp |
macro call func |
{ |
if func eq __chkstk |
sub esp,eax |
else |
call func |
end if |
} |
proc @Kolibri@Redraw$qippv |
push ebp |
mov ebp,[esp+12] |
379,7 → 367,7 |
add ecx,5-1 |
mov edx,[ebp+KOLIBRI_THREAD_DATA_C_WINDOW*4] |
mov edi,[ebp+KOLIBRI_THREAD_DATA_TITLE*4] |
xor eax,eax |
xor eax,eax ;SF_CREATE_WINDOW |
int 0x40 |
.redraw_picture: |
call @@KolibriOnPaint$qv |
420,13 → 408,13 |
mov ecx,-1 |
int 0x40 |
mov esi,eax |
mov edi,[esp+30] |
mov edi,[esp+process_information.PID] |
.exit_process_loop: |
mov eax,SF_THREAD_INFO |
mov ebx,esp |
mov ecx,esi |
int 0x40 |
mov eax,[esp+30] |
mov eax,[esp+process_information.PID] |
cmp eax,edi |
jz .exit_process_continue |
mov ebx,eax |
476,16 → 464,16 |
jmp .exit_process_wait_loop |
endp |
proc @Kolibri@ExitThread$qppv,@Kolibri@ThreadMain$qpvt1 |
proc @Kolibri@ExitThread$qppv |
mov esp,[esp+4] |
jmp Kolibri_main_end |
jmp @Kolibri@ThreadMain$qpvt1.main_end |
endp |
proc @Kolibri@ReturnMessageLoop$qppv,@Kolibri@ThreadMain$qpvt1 |
proc @Kolibri@ReturnMessageLoop$qppv |
mov esp,[esp+4] |
bt dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],30 |
jc Kolibri_main_end |
jmp Kolibri_main_cycle |
jc @Kolibri@ThreadMain$qpvt1.main_end |
jmp @Kolibri@ThreadMain$qpvt1.main_cycle |
endp |
proc @Kolibri@Delay$qui uses ebx |
598,6 → 586,17 |
ret |
endp |
proc @Kolibri@PutImage$qpucllll uses ebx |
mov eax,SF_PUT_IMAGE |
mov ebx,[esp+8] |
mov ecx,[esp+20-2] |
mov cx,[esp+24] |
mov edx,[esp+12-2] |
mov dx,[esp+16] |
int 0x40 |
ret |
endp |
proc @Kolibri@SetWindowCaption$qpxc uses ebx |
mov eax,SF_SET_CAPTION |
mov ebx,2 |
621,7 → 620,7 |
.get_proc_info_no_usecpu: |
or edi,[1024+12+8+esp] |
jz .get_proc_info_no_name |
lea esi,[esp+10] |
lea esi,[esp+process_information.process_name] |
cld |
movsd |
movsd |
631,19 → 630,19 |
.get_proc_info_no_name: |
or edi,[1024+12+12+esp] |
jz .get_proc_info_no_mem |
mov ecx,[esp+26] |
mov ecx,[esp+process_information.used_memory] |
mov [edi],ecx |
xor edi,edi |
.get_proc_info_no_mem: |
or edi,[1024+12+16+esp] |
jz .get_proc_info_no_pid |
mov ecx,[esp+30] |
mov ecx,[esp+process_information.PID] |
mov [edi],ecx |
xor edi,edi |
.get_proc_info_no_pid: |
or edi,[1024+12+20+esp] |
jz .get_proc_info_no_rect |
lea esi,[esp+34] |
lea esi,[esp+process_information.box] |
cld |
movsd |
movsd |
/programs/bcc32/include/kos_start.inc |
---|
6,10 → 6,22 |
dd I_END |
dd U_END+STACKSIZE+HEAPSIZE |
dd U_END+STACKSIZE |
dd @Kolibri@CommandLine,0 |
if defined @Kolibri@CommandLine |
dd @Kolibri@CommandLine |
else |
dd 0 |
end if |
if defined @Kolibri@CurrentDirectoryPath |
dd @Kolibri@CurrentDirectoryPath |
else |
dd 0 |
end if |
include "..\..\..\KOSfuncs.inc" |
include "..\..\..\proc32.inc" |
include "..\..\..\macros.inc" |
include "..\..\..\dll.inc" |
include "..\..\..\load_lib.mac" |
ptr equ |
offset equ |
/programs/bcc32/include/l_libimg.h |
---|
0,0 → 1,53 |
#ifndef __L_LIBIMG_H_INCLUDED_ |
#define __L_LIBIMG_H_INCLUDED_ |
// |
// libimg.obj |
// |
struct Image{ |
long Checksum; // ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far |
long Width; |
long Height; |
long Next; |
long Previous; |
long Type; // one of Image.bppN |
long Data; |
long Palette; // used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i |
long Extended; |
long Flags; // bitfield |
long Delay; // used iff Image.IsAnimated is set in Flags |
}; |
// |
// libimg - import table |
// |
void (__stdcall* import_libimg)() = (void (__stdcall*)())&"lib_init"; |
//"img_is_img"; |
//"img_info"; |
//"img_from_file"; |
//"img_to_file"; |
//"img_from_rgb"; |
//"img_to_rgb"; |
void (__stdcall* img_to_rgb2)(Image* img, unsigned char* out) = (void (__stdcall*)(Image*, unsigned char*))&"img_to_rgb2"; |
//"img_encode"; |
Image* (__stdcall* img_decode)(unsigned char* data, long length, long options) = (Image* (__stdcall*)(unsigned char*, long, long))&"img_decode"; |
Image* (__stdcall* img_create)(long width, long height, long type) = (Image* (__stdcall*)(long, long, long))&"img_create"; |
bool (__stdcall* img_destroy)(Image* img) = (bool (__stdcall*)(Image*))&"img_destroy"; |
//"img_destroy_layer"; |
//"img_count"; |
//"img_lock_bits"; |
//"img_unlock_bits"; |
//"img_flip"; |
//"img_flip_layer"; |
//"img_rotate"; |
//"img_rotate_layer"; |
//"img_draw"; |
//"img_scale"; |
//"img_get_scaled_size"; |
Image* (__stdcall* img_convert)(Image* src, Image* dst, long dst_type, long flags, long param) = (Image* (__stdcall*)(Image*, Image*, long, long, long))&"img_convert"; |
//"img_formats_table"; |
asm{ |
dd 0,0 |
} |
#endif |
/programs/bcc32/include/load_lib.h |
---|
0,0 → 1,18 |
#ifndef __LOAD_LIB_H_LINCLUDED_ |
#define __LOAD_LIB_H_INCLUDED_ |
// macros '@use_library' and 'load_library' defined in file 'load_lib.mac' |
asm{ |
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load |
} |
bool LoadLibrary(const char* lib_name, char* lib_path, const char* system_path, void* myimport) |
{ |
asm{ |
load_library [ebp+8], [ebp+12], [ebp+16], [ebp+20] |
} |
return true; |
} |
#endif |