- Added libdialog.a (proc_lib loader) and sample
- Deleted old console example (replacement: consoleio) - Added RGB struct to kos32sys1.h (applies to ktcc) git-svn-id: svn://kolibrios.org@8426 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
6cb7bf1eb6
commit
826c0501b8
7
programs/develop/ktcc/trunk/lib/proc_lib/Makefile
Normal file
7
programs/develop/ktcc/trunk/lib/proc_lib/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
all:
|
||||
fasm loadproclib.asm
|
||||
ar -csr libdialog.a loadproclib.o
|
||||
install:
|
||||
mv libdialog.a ../../bin/lib
|
||||
clean:
|
||||
rm -f *.o *.a
|
39
programs/develop/ktcc/trunk/lib/proc_lib/loadproclib.asm
Normal file
39
programs/develop/ktcc/trunk/lib/proc_lib/loadproclib.asm
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
format elf
|
||||
use32 ; Tell compiler to use 32 bit instructions
|
||||
|
||||
section '.text' executable ; Keep this line before includes or GCC messes up call addresses
|
||||
|
||||
include '../../../../../proc32.inc'
|
||||
include '../../../../../macros.inc'
|
||||
purge section,mov,add,sub
|
||||
|
||||
include '../../../../../dll.inc'
|
||||
|
||||
public init_proclib as 'kolibri_dialog_init'
|
||||
;;; Returns 0 on success. -1 on failure.
|
||||
|
||||
proc init_proclib
|
||||
pusha
|
||||
mcall 68,11
|
||||
stdcall dll.Load, @IMPORT
|
||||
popa
|
||||
ret
|
||||
endp
|
||||
|
||||
section '.data' writeable
|
||||
|
||||
@IMPORT:
|
||||
library lib_boxlib, 'proc_lib.obj'
|
||||
|
||||
import lib_boxlib, \
|
||||
OpenDialog_init, 'OpenDialog_init' , \
|
||||
OpenDialog_start, 'OpenDialog_start' , \
|
||||
ColorDialog_init, 'ColorDialog_init' , \
|
||||
ColorDialog_start, 'ColorDialog_start'
|
||||
|
||||
public OpenDialog_init as 'OpenDialog_init'
|
||||
public OpenDialog_start as 'OpenDialog_start'
|
||||
|
||||
public ColorDialog_init as 'ColorDialog_init'
|
||||
public ColorDialog_start as 'ColorDialog_start'
|
126
programs/develop/ktcc/trunk/libc/include/clayer/dialog.h
Normal file
126
programs/develop/ktcc/trunk/libc/include/clayer/dialog.h
Normal file
@ -0,0 +1,126 @@
|
||||
#ifndef KOLIBRI_DIALOG_H
|
||||
#define KOLIBRI_DIALOG_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#define NOT_SUCCESS 0
|
||||
#define SUCCESS 1
|
||||
|
||||
char sz_com_area_name[] = "FFFFFFFF_open_dialog";
|
||||
char sz_dir_default_path[] = "/rd/1";
|
||||
char sz_start_path[] = "/rd/1/File managers/opendial";
|
||||
|
||||
char cd_com_area_name[] = "FFFFFFFF_color_dialog";
|
||||
char cd_start_path[] = "/rd/1/colrdial";
|
||||
|
||||
enum open_dialog_mode {
|
||||
OPEN,
|
||||
SAVE,
|
||||
SELECT
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
unsigned int size;
|
||||
unsigned char end;
|
||||
}od_filter __attribute__ ((__packed__));
|
||||
|
||||
typedef struct {
|
||||
unsigned int mode;
|
||||
char* procinfo;
|
||||
char* com_area_name;
|
||||
unsigned int com_area;
|
||||
char* opendir_path;
|
||||
char* dir_default_path;
|
||||
char* start_path;
|
||||
void (*draw_window)();
|
||||
unsigned int status;
|
||||
char* openfile_path;
|
||||
char* filename_area;
|
||||
od_filter* filter_area;
|
||||
unsigned short x_size;
|
||||
unsigned short x_start;
|
||||
unsigned short y_size;
|
||||
unsigned short y_start;
|
||||
}open_dialog __attribute__ ((__packed__));
|
||||
|
||||
|
||||
typedef struct{
|
||||
unsigned int type;
|
||||
char* procinfo;
|
||||
char* com_area_name;
|
||||
unsigned int com_area;
|
||||
char* start_path;
|
||||
void (*draw_window)(void);
|
||||
unsigned int status;
|
||||
unsigned short x_size;
|
||||
unsigned short x_start;
|
||||
unsigned short y_size;
|
||||
unsigned short y_start;
|
||||
unsigned int color_type;
|
||||
unsigned int color;
|
||||
}color_dialog __attribute__ ((__packed__));
|
||||
|
||||
void fake_on_redraw(void) {}
|
||||
|
||||
open_dialog* kolibri_new_open_dialog(unsigned int mode, unsigned short tlx, unsigned short tly, unsigned short x_size, unsigned short y_size)
|
||||
{
|
||||
open_dialog *new_opendialog = (open_dialog *)malloc(sizeof(open_dialog));
|
||||
od_filter *new_od_filter = (od_filter *)malloc(sizeof(od_filter));
|
||||
char *plugin_path = (char *)calloc(4096, sizeof(char));
|
||||
char *openfile_path = (char *)calloc(4096, sizeof(char));
|
||||
char *proc_info = (char *)calloc(1024, sizeof(char));
|
||||
char *filename_area = (char *)calloc(256, sizeof(char));
|
||||
|
||||
new_od_filter -> size = 0;
|
||||
new_od_filter -> end = 0;
|
||||
|
||||
new_opendialog -> mode = mode;
|
||||
new_opendialog -> procinfo = proc_info;
|
||||
new_opendialog -> com_area_name = sz_com_area_name;
|
||||
new_opendialog -> com_area = 0;
|
||||
new_opendialog -> opendir_path = plugin_path;
|
||||
new_opendialog -> dir_default_path = sz_dir_default_path;
|
||||
new_opendialog -> start_path = sz_start_path;
|
||||
new_opendialog -> draw_window = &fake_on_redraw;
|
||||
new_opendialog -> status = 0;
|
||||
new_opendialog -> openfile_path = openfile_path;
|
||||
new_opendialog -> filename_area = filename_area;
|
||||
new_opendialog -> filter_area = new_od_filter;
|
||||
new_opendialog -> x_size = x_size;
|
||||
new_opendialog -> x_start = tlx;
|
||||
new_opendialog -> y_size = y_size;
|
||||
new_opendialog -> y_start = tly;
|
||||
return new_opendialog;
|
||||
}
|
||||
|
||||
void cd_fake_on_redraw(void) {}
|
||||
|
||||
color_dialog* kolibri_new_color_dialog(unsigned int type, unsigned short tlx, unsigned short tly, unsigned short x_size, unsigned short y_size)
|
||||
{
|
||||
color_dialog *new_colordialog = (color_dialog *)malloc(sizeof(color_dialog));
|
||||
char *proc_info = (char *)calloc(1024, sizeof(char));
|
||||
|
||||
new_colordialog -> type = type;
|
||||
new_colordialog -> procinfo = proc_info;
|
||||
new_colordialog -> com_area_name = cd_com_area_name;
|
||||
new_colordialog -> com_area = 0;
|
||||
new_colordialog -> start_path = cd_start_path;
|
||||
new_colordialog -> draw_window = &cd_fake_on_redraw;
|
||||
new_colordialog -> status = 0;
|
||||
new_colordialog -> x_size = x_size;
|
||||
new_colordialog -> x_start = tlx;
|
||||
new_colordialog -> y_size = y_size;
|
||||
new_colordialog -> y_start = tly;
|
||||
new_colordialog -> color_type = 0;
|
||||
new_colordialog -> color = 0;
|
||||
return new_colordialog;
|
||||
}
|
||||
|
||||
extern void kolibri_dialog_init();
|
||||
|
||||
extern void (*OpenDialog_init __attribute__((__stdcall__)))(open_dialog *);
|
||||
extern void (*OpenDialog_start __attribute__((__stdcall__)))(open_dialog *);
|
||||
|
||||
extern void (*ColorDialog_init __attribute__((__stdcall__)))(color_dialog *);
|
||||
extern void (*ColorDialog_start __attribute__((__stdcall__)))(color_dialog *);
|
||||
|
||||
#endif
|
@ -40,6 +40,12 @@ extern "C" {
|
||||
|
||||
//Read/Write data as type (int char, etc.) at address "addr" with offset "offset". eg DATA(int, buff, 8);
|
||||
#define DATA(type, addr, offset) *((type*)((uint8_t*)addr+offset))
|
||||
|
||||
typedef struct {
|
||||
uint8_t blue;
|
||||
uint8_t green;
|
||||
uint8_t red;
|
||||
}RGB;
|
||||
|
||||
typedef unsigned int color_t;
|
||||
|
||||
@ -128,7 +134,7 @@ struct ipc_buffer
|
||||
uint32_t used; // used bytes in buffer
|
||||
struct ipc_message data[0]; // data begin
|
||||
};
|
||||
|
||||
|
||||
static inline void begin_draw(void)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
|
@ -1,24 +1,27 @@
|
||||
CC=../bin/kos32-tcc
|
||||
CFLAGS= -I ../libc/include
|
||||
|
||||
all:
|
||||
../bin/kos32-tcc asm_ex.c -lck -o asm_ex.kex -I ../libc/include
|
||||
../bin/kos32-tcc consoleio.c -lck -o consoleio.kex -I ../libc/include
|
||||
../bin/kos32-tcc files.c -lck -o files.kex -I ../libc/include
|
||||
../bin/kos32-tcc winbasics.c -lck -o winbasics.kex -I ../libc/include
|
||||
../bin/kos32-tcc dynamic.c -lck -lhttp -linputbox -o dynamic.kex -I ../libc/include
|
||||
../bin/kos32-tcc load_coff.c -o load_coff.kex -lck -I ../libc/include
|
||||
../bin/kos32-tcc clayer/msgbox.c -lck -lmsgbox -o clayer/msgbox.kex -I ../libc/include
|
||||
../bin/kos32-tcc graphics.c -lck -lgb -o graphics.kex -I ../libc/include
|
||||
../bin/kos32-tcc clayer/rasterworks.c -lck -lrasterworks -o clayer/rasterworks.kex -I ../libc/include
|
||||
../bin/kos32-tcc clayer/boxlib.c -lck -lbox -o clayer/boxlib.kex -I ../libc/include
|
||||
../bin/kos32-tcc clayer/libimg.c -lck -limg -o clayer/libimg.kex -I ../libc/include
|
||||
../bin/kos32-tcc console/console.c -lck -limg -o console/console.kex -I ../libc/include
|
||||
../bin/kos32-tcc dir_example.c -lck -o dir_example.kex -I ../libc/include
|
||||
../bin/kos32-tcc net/tcpsrv_demo.c -lck -o net/tcpsrv_demo.kex -I ../libc/include
|
||||
../bin/kos32-tcc net/nslookup.c -lck -lnetwork -o net/nslookup.kex -I ../libc/include
|
||||
../bin/kos32-tcc getopt_ex.c -lck -o getopt_ex.kex -I ../libc/include
|
||||
../bin/kos32-tcc tinygl/fps.c tinygl/gears.c -o gears.kex -I ../libc/include -ltinygl -lck
|
||||
$(CC) $(CFLAGS) asm_ex.c -lck -o asm_ex.kex
|
||||
$(CC) $(CFLAGS) consoleio.c -lck -o consoleio.kex
|
||||
$(CC) $(CFLAGS) files.c -lck -o files.kex
|
||||
$(CC) $(CFLAGS) winbasics.c -lck -o winbasics.kex
|
||||
$(CC) $(CFLAGS) dynamic.c -lck -lhttp -linputbox -o dynamic.kex
|
||||
$(CC) $(CFLAGS) load_coff.c -o load_coff.kex -lck
|
||||
$(CC) $(CFLAGS) graphics.c -lck -lgb -o graphics.kex
|
||||
$(CC) $(CFLAGS) dir_example.c -lck -o dir_example.kex
|
||||
$(CC) $(CFLAGS) getopt_ex.c -lck -o getopt_ex.kex
|
||||
|
||||
$(CC) $(CFLAGS) clayer/msgbox.c -lck -lmsgbox -o clayer/msgbox.kex
|
||||
$(CC) $(CFLAGS) clayer/rasterworks.c -lck -lrasterworks -o clayer/rasterworks.kex
|
||||
$(CC) $(CFLAGS) clayer/boxlib.c -lck -lbox -o clayer/boxlib.kex
|
||||
$(CC) $(CFLAGS) clayer/libimg.c -lck -limg -o clayer/libimg.kex
|
||||
$(CC) $(CFLAGS) clayer/dialog.c -lck -ldialog -o clayer/dialog.kex
|
||||
|
||||
$(CC) $(CFLAGS) net/tcpsrv_demo.c -lck -o net/tcpsrv_demo.kex
|
||||
$(CC) $(CFLAGS) net/nslookup.c -lck -lnetwork -o net/nslookup.kex
|
||||
|
||||
$(CC) $(CFLAGS) tinygl/fps.c tinygl/gears.c -o tinygl/gears.kex -ltinygl -lck
|
||||
|
||||
clean:
|
||||
rm *.kex
|
||||
rm clayer/*.kex
|
||||
rm console/*.kex
|
||||
rm net/*.kex
|
||||
rm *.kex clayer/*.kex net/*.kex tinygl/*.kex
|
||||
|
@ -10,6 +10,7 @@
|
||||
../tcc clayer/rasterworks.c -lck -lrasterworks -o /tmp0/1/rasterworks
|
||||
../tcc clayer/boxlib.c -lck -lbox -o /tmp0/1/boxlib_ex
|
||||
../tcc clayer/libimg.c -lck -limg -o /tmp0/1/libimg_ex
|
||||
../tcc clayer/dialog.c -lck -ldialog -o /tmp0/1/dialog_ex
|
||||
../tcc console/console.c -lck -limg -o /tmp0/1/console
|
||||
../tcc dir_example.c -lck -o /tmp0/1/dir_example
|
||||
../tcc net/tcpsrv_demo.c -lck -o /tmp0/1/tcpsrv_demo
|
||||
|
32
programs/develop/ktcc/trunk/samples/clayer/dialog.c
Normal file
32
programs/develop/ktcc/trunk/samples/clayer/dialog.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <kos32sys1.h>
|
||||
#include <clayer/dialog.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
kolibri_dialog_init(); // dialog init
|
||||
open_dialog *dlg_open = kolibri_new_open_dialog(OPEN, 10, 10, 420, 320); // create opendialog struct
|
||||
OpenDialog_init(dlg_open); // Initializing an open dialog box.
|
||||
OpenDialog_start(dlg_open); // Show open dialog box
|
||||
|
||||
color_dialog *color_select = kolibri_new_color_dialog(SELECT, 10, 10,420,320); // create colordialog struct
|
||||
ColorDialog_init(color_select); // Initializing an color dialog box.
|
||||
ColorDialog_start(color_select); // Show color dialog
|
||||
|
||||
if(dlg_open->status == SUCCESS){
|
||||
printf("File selected '%s'\n",dlg_open->openfile_path);
|
||||
}else{
|
||||
puts("No file selected!");
|
||||
}
|
||||
|
||||
if(color_select->status == SUCCESS){
|
||||
printf("Color selected: #%06X\n",color_select->color);
|
||||
RGB color_rgb = (RGB)color_select->color;
|
||||
printf("Red:%d Green:%d Blue:%d", color_rgb.red, color_rgb.green, color_rgb.blue);
|
||||
}else{
|
||||
puts("No color selected!");
|
||||
}
|
||||
|
||||
free(dlg_open);
|
||||
free(color_select);
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
|
||||
// Console dynamic link library. Sample by Ghost
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <kolibrisys.h>
|
||||
|
||||
char* dllname="/sys/lib/console.obj";
|
||||
int i;
|
||||
|
||||
char* imports[] = {"START","version","con_init","con_write_asciiz","con_printf","con_exit",NULL};
|
||||
char* caption = "Console test - colors";
|
||||
|
||||
dword (* dll_start)(dword res);
|
||||
dword* dll_ver;
|
||||
void stdcall (* con_init)(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title);
|
||||
void stdcall (* con_write_asciiz)(const char* string);
|
||||
void cdecl (* con_printf)(const char* format,...);
|
||||
void stdcall (* con_exit)(dword bCloseWindow);
|
||||
|
||||
struct import{
|
||||
char *name;
|
||||
void *data;
|
||||
};
|
||||
|
||||
void link(struct import *exp, char** imports){
|
||||
dll_start = (dword (*)(dword))
|
||||
_ksys_cofflib_getproc(exp, imports[0]);
|
||||
dll_ver = (dword*)
|
||||
_ksys_cofflib_getproc(exp, imports[1]);
|
||||
con_init = (void stdcall (*)(dword , dword, dword, dword, const char*))
|
||||
_ksys_cofflib_getproc(exp, imports[2]);
|
||||
con_write_asciiz = (void stdcall (*)(const char*))
|
||||
_ksys_cofflib_getproc(exp, imports[3]);
|
||||
con_printf = (void cdecl (*)(const char*,...))
|
||||
_ksys_cofflib_getproc(exp, imports[4]);
|
||||
con_exit = (void stdcall (*)(dword))
|
||||
_ksys_cofflib_getproc(exp, imports[5]);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
|
||||
struct import * hDll;
|
||||
int a,b,c,d;
|
||||
|
||||
if((hDll = (struct import *)_ksys_cofflib_load(dllname)) == 0){
|
||||
debug_out_str("can't load lib\n");
|
||||
return 1;
|
||||
}
|
||||
link(hDll, imports);
|
||||
debug_out_str("dll loaded\n");
|
||||
|
||||
if(dll_start(1) == 0){
|
||||
debug_out_str("dll_start failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
con_init(-1, -1, -1, -1, caption);
|
||||
|
||||
for(i = 0; i < 256; i++){
|
||||
con_printf("Color 0x%02X: ", i);
|
||||
con_write_asciiz("Text sample.");
|
||||
|
||||
con_printf(" printf %s test %d\n", "small", i);
|
||||
|
||||
}
|
||||
|
||||
con_exit(0);
|
||||
debug_out_str("all right's ;)\n");
|
||||
}
|
Loading…
Reference in New Issue
Block a user