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
format elf
use32 ; Tell compiler to use 32 bit instructions

View File

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

View File

@ -1,76 +1,71 @@
// WRITED BY MAXCODEHACK
// Need to other sample, this sample is very shitcode)
#include <stdio.h>
// sample writed by maxcodehack
#include <kos32sys1.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "kos32sys1.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];
char proc_info[1024];
char text_line[255];
#define WIN_W 640
#define WIN_H 563
enum BUTTONS
{
BTN_QUIT = 1,
BTN_POP = 10,
BTN_UNLOCK = 11
};
char* title = "Boxlib example";
int win_bg_color = 0x858585;
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};
#define FONT_W 8
#define FONT_H 14
#define LINES 10
void draw_window()
{
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();
void draw_window(){
begin_draw();
sys_create_window(215,100,WIN_W,WIN_H,title,win_bg_color,0x34);
scrollbar_v_draw(&scroll);
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);
set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside
//// EVENTMASK
#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
{
gui_event = get_os_event();
switch(gui_event)
{
case KOLIBRI_EVENT_NONE:
// background work
break;
case KOLIBRI_EVENT_REDRAW:
draw_window();
scrollbar_v_draw(&scroll_ver);
break;
case KOLIBRI_EVENT_KEY:
// scroll
break;
case KOLIBRI_EVENT_BUTTON:
break;
case KOLIBRI_EVENT_MOUSE:
scrollbar_v_mouse(&scroll_ver);
break;
}
} while(1);
return 0;
int main()
{
kolibri_boxlib_init();
set_event_mask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
while(1)
{
switch(get_os_event())
{
case evButton:
if (get_os_button() == 1) exit(0);
break;
case evKey:
get_key();
break;
case evReDraw:
draw_window();
break;
case evMouse:
scrollbar_v_mouse(&scroll);
break;
}
}
}