clayer TinyC

- Add new sample
- Fix bug: 'Unexpected stack end'

git-svn-id: svn://kolibrios.org@8106 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
maxcodehack 2020-10-17 16:30:47 +00:00
parent 0e3c6b922f
commit 6154138ea6
3 changed files with 87 additions and 92 deletions

View File

@ -1,4 +1,4 @@
; writed by maxñodehack ; writed by maxcodehack
; adaptation of clayer for ktcc ; adaptation of clayer for ktcc
format elf format elf
use32 ; Tell compiler to use 32 bit instructions use32 ; Tell compiler to use 32 bit instructions

View File

@ -36,10 +36,10 @@ typedef struct {
uint32_t ar_offset; uint32_t ar_offset;
} __attribute__ ((__packed__)) scrollbar; } __attribute__ ((__packed__)) scrollbar;
extern void (*scrollbar_h_draw)(scrollbar*) __attribute__((__stdcall__)); extern void (*scrollbar_h_draw __attribute__((__stdcall__)))(scrollbar*);
extern void (*scrollbar_h_mouse)(scrollbar*) __attribute__((__stdcall__)); extern void (*scrollbar_h_mouse __attribute__((__stdcall__)))(scrollbar*);
extern void (*scrollbar_v_draw)(scrollbar*) __attribute__((__stdcall__)); extern void (*scrollbar_v_draw __attribute__((__stdcall__)))(scrollbar*);
extern void (*scrollbar_v_mouse)(scrollbar*) __attribute__((__stdcall__)); extern void (*scrollbar_v_mouse __attribute__((__stdcall__)))(scrollbar*);
// CHECKBOX // CHECKBOX
typedef struct { typedef struct {
@ -56,9 +56,9 @@ typedef struct {
unsigned int size_of_str; unsigned int size_of_str;
}check_box; }check_box;
extern void (*check_box_draw2)(check_box *) __attribute__((__stdcall__)); extern void (*check_box_draw2 __attribute__((__stdcall__)))(check_box *);
extern void (*check_box_mouse2)(check_box *)__attribute__((__stdcall__)); extern void (*check_box_mouse2 __attribute__((__stdcall__)))(check_box *);
extern void (*init_checkbox2)(check_box *)__attribute__((__stdcall__)); extern void (*init_checkbox2 __attribute__((__stdcall__)))(check_box *);
// DBUTTON // DBUTTON
typedef struct { typedef struct {
@ -78,8 +78,8 @@ typedef struct {
uint32_t click; // clicked - 1, zero it after tested uint32_t click; // clicked - 1, zero it after tested
} pict_button; } pict_button;
extern void (*dynamic_button_draw)(pict_button *) __attribute__((__stdcall__)); extern void (*dynamic_button_draw __attribute__((__stdcall__)))(pict_button *);
extern void (*dynamic_button_mouse)(pict_button *) __attribute__((__stdcall__)); extern void (*dynamic_button_mouse __attribute__((__stdcall__)))(pict_button *);
// EDITBOX // EDITBOX
@ -109,10 +109,10 @@ typedef struct edit_box_t {
unsigned int char_width; unsigned int char_width;
}edit_box; }edit_box;
extern void (*edit_box_draw)(edit_box *) __attribute__((__stdcall__)); extern void (*edit_box_draw __attribute__((__stdcall__)))(edit_box *);
extern void (*edit_box_key)(edit_box *) __attribute__((__stdcall__)); extern void (*edit_box_key __attribute__((__stdcall__)))(edit_box *);
extern void (*edit_box_mouse)(edit_box *) __attribute__((__stdcall__)); extern void (*edit_box_mouse __attribute__((__stdcall__)))(edit_box *);
extern void (*edit_box_set_text)(edit_box *, char *) __attribute__((__stdcall__)); extern void (*edit_box_set_text __attribute__((__stdcall__)))(edit_box *, char *);
extern volatile unsigned press_key; extern volatile unsigned press_key;
// FRAME // FRAME
@ -131,7 +131,7 @@ typedef struct {
color_t font_bg_color; color_t font_bg_color;
}frame; }frame;
extern void (*frame_draw)(frame *) __attribute__((__stdcall__)); extern void (*frame_draw)(frame *);
// MENUBAR // MENUBAR
typedef struct typedef struct
@ -172,12 +172,12 @@ typedef struct
uint32_t get_mouse_flag; uint32_t get_mouse_flag;
} menubar; } menubar;
extern void (*menu_bar_draw)(menubar *) __attribute__((__stdcall__)); extern void (*menu_bar_draw)(menubar *);
extern void (*menu_bar_mouse)(menubar *) __attribute__((__stdcall__)); extern void (*menu_bar_mouse)(menubar *);
extern void (*menu_bar_activate)(menubar *) __attribute__((__stdcall__)); extern void (*menu_bar_activate)(menubar *);
// OPTIONBOX // OPTIONBOX
typedef struct __attribute__ ((__packed__)) option_box_t { typedef struct option_box_t {
struct option_box_t **selected; struct option_box_t **selected;
uint16_t posx; uint16_t posx;
uint16_t posy; uint16_t posy;
@ -189,10 +189,10 @@ typedef struct __attribute__ ((__packed__)) option_box_t {
char *text; char *text;
uint32_t text_len; uint32_t text_len;
uint32_t flags; uint32_t flags;
}option_box; } __attribute__ ((__packed__)) option_box;
extern void (*option_box_draw)(option_box **) __attribute__((__stdcall__)); extern void (*option_box_draw __attribute__((__stdcall__)))(option_box **);
extern void (*option_box_mouse)(option_box **)__attribute__((__stdcall__)); extern void (*option_box_mouse __attribute__((__stdcall__)))(option_box **);
// PATHSHOW // PATHSHOW
typedef struct { typedef struct {
@ -209,8 +209,8 @@ typedef struct {
uint32_t temp_text_length; uint32_t temp_text_length;
} __attribute__ ((__packed__)) pathview; } __attribute__ ((__packed__)) pathview;
extern void (*path_show_prepare)(pathview *) __attribute__((__stdcall__)); extern void (*path_show_prepare __attribute__((__stdcall__)))(pathview *);
extern void (*path_show_draw)(pathview *) __attribute__((__stdcall__)); extern void (*path_show_draw __attribute__((__stdcall__)))(pathview *);
// PROGRESSBAR // PROGRESSBAR
typedef struct { typedef struct {
@ -227,8 +227,8 @@ typedef struct {
unsigned int frame_color; unsigned int frame_color;
} progressbar; } progressbar;
extern void (*progressbar_draw)(progressbar *) __attribute__((__stdcall__)); extern void (*progressbar_draw __attribute__((__stdcall__)))(progressbar *);
extern void (*progressbar_progress)(progressbar *) __attribute__((__stdcall__)); extern void (*progressbar_progress __attribute__((__stdcall__)))(progressbar *);
#endif /* KOLIBRI_BOXLIB_H */ #endif /* KOLIBRI_BOXLIB_H */

View File

@ -1,76 +1,71 @@
// WRITED BY MAXCODEHACK // sample writed by maxcodehack
// Need to other sample, this sample is very shitcode) #include <kos32sys1.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "kos32sys1.h"
#include <clayer/boxlib.h> #include <clayer/boxlib.h>
struct kolibri_system_colors sys_color_table; #define evReDraw 1
#define evKey 2
#define evButton 3
#define evExit 4
#define evDesktop 5
#define evMouse 6
#define evIPC 7
#define evNetwork 8
#define evDebug 9
char statusbar[255]; #define WIN_W 640
char proc_info[1024]; #define WIN_H 563
char text_line[255];
enum BUTTONS char* title = "Boxlib example";
{ int win_bg_color = 0x858585;
BTN_QUIT = 1, scrollbar scroll = {15, WIN_W - 26, WIN_H - 29, 0, 0, 2, 115, 15, 0,0x707070,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
BTN_POP = 10,
BTN_UNLOCK = 11
};
#define FONT_W 8 void draw_window(){
#define FONT_H 14 begin_draw();
#define LINES 10 sys_create_window(215,100,WIN_W,WIN_H,title,win_bg_color,0x34);
scrollbar_v_draw(&scroll);
void draw_window() end_draw();
{
int win_hight, win_width, i, pos_y = get_skin_height() + 36; // 60 == 24+36
// start redraw
begin_draw();
// define&draw window
sys_create_window(10, 40, 600, 400, "My window", /*sys_color_table.work_area*/0xFFFFFF, 0x13);
// end redraw
end_draw();
} }
scrollbar scroll_ver = {15, 100 - 26, 100 - 29, 0, 0, 2 /* type */, 115, 15, 0,0x353B47,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
int main()
{
kolibri_boxlib_init();
int gui_event;
uint32_t pressed_button = 0, mouse_button;
pos_t mouse_pos;
get_system_colors(&sys_color_table); //// EVENTMASK
set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside #define EVM_REDRAW 1
#define EVM_KEY 2
#define EVM_BUTTON 4
#define EVM_EXIT 8
#define EVM_BACKGROUND 16
#define EVM_MOUSE 32
#define EVM_IPC 64
#define EVM_STACK 128
#define EVM_DEBUG 256
#define EVM_STACK2 512
#define EVM_MOUSE_FILTER 0x80000000
#define EVM_CURSOR_FILTER 0x40000000
//// EVENTMASK
do
{ int main()
gui_event = get_os_event(); {
switch(gui_event) kolibri_boxlib_init();
{
case KOLIBRI_EVENT_NONE: set_event_mask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
// background work while(1)
break; {
case KOLIBRI_EVENT_REDRAW: switch(get_os_event())
draw_window(); {
scrollbar_v_draw(&scroll_ver); case evButton:
break; if (get_os_button() == 1) exit(0);
case KOLIBRI_EVENT_KEY: break;
// scroll
break; case evKey:
case KOLIBRI_EVENT_BUTTON: get_key();
break;
break;
case KOLIBRI_EVENT_MOUSE: case evReDraw:
scrollbar_v_mouse(&scroll_ver); draw_window();
break; break;
} case evMouse:
} while(1); scrollbar_v_mouse(&scroll);
break;
return 0; }
}
} }