Могу предоставить полный код0CodErr wrote:right-hearted, ты привёл не весь код, и не известно, что должно было работать, а что — нет. Пока что не понятно, где именно ты предлагаешь искать ошибки.
main.c
Spoiler:
Code: Select all
#include <kos32sys.h>
#include "box_lib.h"
const char *header= "Header";
const char *string= "Super word";
char *screen= "some text";
unsigned int mouse_dd=0;
void drawEditBox(){
edit_box ed_bx= {250,55,34,0x00ffff,0x94AECE,0xffffff,0xffffff,0,sizeof(screen),screen,mouse_dd,2,19,19};
edit_box_draw(ed_bx);
}
void draw_window(void)
{
BeginDraw();
DrawWindow(100,100,500,300,header,0x33FFFFFF,1);
drawEditBox();
EndDraw();
}
int main(void)
{
load_box_lib();
draw_window();
for (;;)
{
switch (check_os_event())
{
case 1:
draw_window();
break;
case 2:
break;
case 3:
// button pressed; we have only one button, close
board_puts("DUMMY: Button pressed \n");
return -1;
}
}
}
Spoiler:
Code: Select all
#include <kos32sys.h>
#include "box_lib.h"
struct_import* lib_load(char *name)
{
struct_import* val;
asm volatile ("int $0x40":"=a"(val):"a"(68), "b"(19), "c"(name));
return val;
}
void* lib_procload (struct_import *imp, char *name)
{
int i;
for (i=0;;i++)
if ( NULL == ((imp+i) -> name))
break;
else
if ( 0 == strcmp(name, (imp+i)->name) )
return (imp+i)->data;
return NULL;
}
void load_box_lib(){
struct_import *k;
k = lib_load("/sys/lib/box_lib.obj");
if (k==NULL){board_puts("DUMMY: Could not load box_lib \n");}
else board_puts(" box_lib successfully loaded\n");
if(lib_procload(k, "edit_box") == NULL){board_puts("DUMMY: procload failed \n");}
else board_puts(" procload success \n");
edit_box_draw = (__stdcall void (*) (edit_box))lib_procload(k, "edit_box");
edit_box_key = (__stdcall void (*) (edit_box))lib_procload(k, "edit_box_key");
edit_box_mouse = (__stdcall void (*) (edit_box))lib_procload(k, "edit_box_mouse");
if (edit_box_draw == NULL || edit_box_key == NULL || edit_box_mouse == NULL)
board_puts(" some of functions cannot be loaded! \n");
}
Spoiler:
Code: Select all
#ifndef __BOX_LIB_H__
#define __BOX_LIB_H__
typedef struct __attribute__((packed))
{
char *name __attribute__((packed));
void *data __attribute__((packed));
} struct_import;
typedef struct edit_box edit_box;
struct edit_box
{
int width;
int left;
int top;
int color;
int shift_color;
int focus_border_color;
int blur_border_color;
int text_color;
int max;
char *text;
int mouse_variable;
int flags;
int size;
int pos;
int offset;
int cl_curs_x;
int cl_curs_y;
int shift;
int shift_old;
};
struct_import* lib_load(char *name);
void* lib_procload (struct_import *imp, char *name);
void load_box_lib();
void (* __stdcall edit_box_draw)(edit_box bx);
void (* __stdcall edit_box_key)(edit_box bx);
void (* __stdcall edit_box_mouse)(edit_box bx);
#endif