Subversion Repositories Kolibri OS

Rev

Rev 8535 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8535 superturbo 1
/* Copyright (C) 2019-2021 Logaev Maxim (turbocat2001), GPLv3 */
2
 
3
#include "tinypy.h"
4
#include 
5
 
6
#define GET_NUM_ARG() TP_TYPE(TP_NUMBER).number.val
7
#define GET_STR_ARG() TP_TYPE(TP_STRING).string.val
8
 
9
void debug_write_byte(const char ch){
10
    __asm__ __volatile__(
11
    "int $0x40"
12
    ::"a"(63), "b"(1), "c"(ch)
13
    );
14
}
15
 
16
static tp_obj _debug_print(TP){
17
    tp_obj str = TP_TYPE(TP_STRING);
18
    for(int i=0; i < str.string.len; i++)
19
    {
20
       debug_write_byte(str.string.val[i]);
21
    }
22
    return tp_None;
23
}
24
 
25
static tp_obj _start_draw(TP){
26
    begin_draw();
27
    return tp_None;
28
}
29
 
30
 
31
static tp_obj _end_draw(TP){
32
    end_draw();
33
    return tp_None;
34
}
35
 
36
static tp_obj _create_window(TP){
37
    int x = GET_NUM_ARG();
38
    int y = GET_NUM_ARG();
39
    int w = GET_NUM_ARG();
40
    int h = GET_NUM_ARG();
41
    const char *title= GET_STR_ARG();
42
    unsigned int color = GET_NUM_ARG();
43
    unsigned int style = GET_NUM_ARG();
44
    sys_create_window(x,y,w,h, title, color,style);
45
    return tp_None;
46
}
47
 
48
static tp_obj _create_button(TP){
49
    unsigned int x = GET_NUM_ARG();
50
    unsigned int y = GET_NUM_ARG();
51
    unsigned int h = GET_NUM_ARG();
52
    unsigned int w = GET_NUM_ARG();
53
    unsigned int id = GET_NUM_ARG();
54
    unsigned int color = GET_NUM_ARG();
55
    define_button((x << 16) + w, (y << 16) + h, id, color);
56
    return tp_None;
57
}
58
 
59
static tp_obj _draw_text(TP){
60
    const char *str= GET_STR_ARG();
61
    int x = GET_NUM_ARG();
62
    int y = GET_NUM_ARG();
63
    int len = GET_NUM_ARG();
64
    unsigned color = (unsigned)GET_NUM_ARG();
65
    draw_text_sys(str, x, y, len, color);
66
    return tp_None;
67
}
68
 
69
static tp_obj _get_event(TP){
70
    return tp_number(get_os_event());
71
}
72
 
73
static tp_obj _get_button(TP){
74
    return tp_number(get_os_button());
75
}
76
 
8578 superturbo 77
static tp_obj _get_key(TP){
78
    tp_obj key_obj = tp_dict(tp);
79
    oskey_t key_info = get_key();
80
    tp_set(tp, key_obj, tp_string("code"), tp_number(key_info.code));
81
    tp_set(tp, key_obj, tp_string("ctrl_key"), tp_number(key_info.ctrl_key));
82
    tp_set(tp, key_obj, tp_string("state"), tp_number(key_info.state));
83
    tp_set(tp, key_obj, tp_string("val"), tp_number(key_info.val));
84
    return key_obj;
85
}
86
 
87
static tp_obj _start_app(TP){
88
     const char *prog_name = GET_STR_ARG();
89
     const char *args = GET_STR_ARG();
90
}
91
 
8535 superturbo 92
static tp_obj _get_sys_colors(TP){
93
    tp_obj color_obj = tp_dict(tp);
94
    struct kolibri_system_colors colors;
95
    get_system_colors(&colors);
96
    tp_set(tp, color_obj, tp_string("frame_area"), tp_number(colors.frame_area));
97
    tp_set(tp, color_obj, tp_string("grab_bar"), tp_number(colors.grab_bar));
98
    tp_set(tp, color_obj, tp_string("grab_bar_button)"), tp_number(colors.grab_bar_button));
99
    tp_set(tp, color_obj, tp_string( "grab_button_text)"), tp_number(colors.grab_button_text));
100
    tp_set(tp, color_obj, tp_string("grab_text"), tp_number(colors.grab_text));
101
    tp_set(tp, color_obj, tp_string("work_area"), tp_number(colors.work_area));
102
    tp_set(tp, color_obj, tp_string("work_button"), tp_number(colors.work_button));
103
    tp_set(tp, color_obj, tp_string("work_button_text"), tp_number(colors.work_button_text));
104
    tp_set(tp, color_obj, tp_string("work_graph"), tp_number(colors.work_graph));
105
    tp_set(tp, color_obj, tp_string("work_text"), tp_number(colors.work_text));
106
    return color_obj;
107
}