Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | 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
 
77
static tp_obj _get_sys_colors(TP){
78
    tp_obj color_obj = tp_dict(tp);
79
    struct kolibri_system_colors colors;
80
    get_system_colors(&colors);
81
    tp_set(tp, color_obj, tp_string("frame_area"), tp_number(colors.frame_area));
82
    tp_set(tp, color_obj, tp_string("grab_bar"), tp_number(colors.grab_bar));
83
    tp_set(tp, color_obj, tp_string("grab_bar_button)"), tp_number(colors.grab_bar_button));
84
    tp_set(tp, color_obj, tp_string( "grab_button_text)"), tp_number(colors.grab_button_text));
85
    tp_set(tp, color_obj, tp_string("grab_text"), tp_number(colors.grab_text));
86
    tp_set(tp, color_obj, tp_string("work_area"), tp_number(colors.work_area));
87
    tp_set(tp, color_obj, tp_string("work_button"), tp_number(colors.work_button));
88
    tp_set(tp, color_obj, tp_string("work_button_text"), tp_number(colors.work_button_text));
89
    tp_set(tp, color_obj, tp_string("work_graph"), tp_number(colors.work_graph));
90
    tp_set(tp, color_obj, tp_string("work_text"), tp_number(colors.work_text));
91
    return color_obj;
92
}