From f657cc8f9bc0020e2f8f0fe2b5ba11f6e8465501 Mon Sep 17 00:00:00 2001 From: Albom Date: Wed, 27 Jun 2012 15:43:51 +0000 Subject: [PATCH] kolibri.c improvements. + changes in shell, e80, console15, donkey, mcities, piton git-svn-id: svn://kolibrios.org@2829 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/emulator/e80/trunk/e80.c | 5 +- programs/emulator/e80/trunk/system/kolibri.c | 181 ++++++++++--------- programs/emulator/e80/trunk/system/kolibri.h | 18 +- programs/games/console15/system/kolibri.c | 175 +++++++++--------- programs/games/console15/system/kolibri.h | 16 +- programs/games/donkey/c_code.c | 3 +- programs/games/donkey/system/kolibri.c | 175 +++++++++--------- programs/games/donkey/system/kolibri.h | 16 +- programs/games/mcities/system/kolibri.c | 155 ++++++++-------- programs/games/mcities/system/kolibri.h | 2 +- programs/games/piton/c_code.c | 3 +- programs/games/piton/system/kolibri.c | 175 +++++++++--------- programs/games/piton/system/kolibri.h | 16 +- programs/system/shell/cmd/cmd_memory.c | 18 -- programs/system/shell/system/kolibri.c | 155 ++++++++-------- programs/system/shell/system/kolibri.h | 2 +- 16 files changed, 572 insertions(+), 543 deletions(-) delete mode 100644 programs/system/shell/cmd/cmd_memory.c diff --git a/programs/emulator/e80/trunk/e80.c b/programs/emulator/e80/trunk/e80.c index 1b68e8dc49..4cd8026719 100644 --- a/programs/emulator/e80/trunk/e80.c +++ b/programs/emulator/e80/trunk/e80.c @@ -379,8 +379,7 @@ kol_file_70(&file); void wnd_draw() { kol_paint_start(); -kol_wnd_define( (screen_w-540)/2, (screen_h-440)/2, 540, 440, 0x34b0b0b0); -kol_wnd_caption(WND_CAPTION); +kol_wnd_define( (screen_w-540)/2, (screen_h-440)/2, 540, 440, 0x34b0b0b0, 0x34b0b0b0, WND_CAPTION); screen_print(&spectrumZ80); kol_paint_image((540 - screen_a_w)/2-5, (440 - screen_a_h-kol_skin_height())/2, @@ -439,7 +438,7 @@ for (;;) { // event = kol_event_check(); - event = kol_event_wait_time(1); + event = kol_event_wait_time(5); switch (event) { diff --git a/programs/emulator/e80/trunk/system/kolibri.c b/programs/emulator/e80/trunk/system/kolibri.c index c5a8deb4ca..9e0f52a1e9 100644 --- a/programs/emulator/e80/trunk/system/kolibri.c +++ b/programs/emulator/e80/trunk/system/kolibri.c @@ -10,193 +10,183 @@ extern char KOL_DIR[256]; void kol_exit() { -asm ("int $0x40"::"a"(-1)); +asm volatile ("int $0x40"::"a"(-1)); } void kol_sleep(unsigned d) { -asm ("int $0x40"::"a"(5), "b"(d)); +asm volatile ("int $0x40"::"a"(5), "b"(d)); } -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) +// define a window +// x, y - position; w, h - size; cs - color and style; c - caption; b - boder +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t) { -asm ("nop"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); -asm ("movl $0xffffff, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) ); } void kol_wnd_move(unsigned x, unsigned y) { -asm ("nop"::"a"(67), "b"(x), "c"(y)); -asm ("movl $-1, %edx \n movl $-1, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(67), "b"(x), "c"(y), "d"(-1), "S"(-1)); } void kol_event_mask(unsigned e) { -asm ("int $0x40"::"a"(40), "b"(e)); +asm volatile ("int $0x40"::"a"(40), "b"(e)); } -unsigned kol_event_wait() +unsigned kol_event_wait() { -asm ("int $0x40"::"a"(10)); +asm volatile ("int $0x40"::"a"(10)); } unsigned kol_event_wait_time(unsigned time) { -asm ("int $0x40"::"a"(23), "b"(time)); +asm volatile ("int $0x40"::"a"(23), "b"(time)); } unsigned kol_event_check() { -asm ("int $0x40"::"a"(11)); +asm volatile ("int $0x40"::"a"(11)); } -void kol_paint_start() +void __attribute__((__always_inline__)) kol_paint_start() { -asm ("int $0x40"::"a"(12), "b"(1)); +asm volatile ("int $0x40"::"a"(12), "b"(1)); } -void kol_paint_end() +void __attribute__((__always_inline__)) kol_paint_end() { -asm ("int $0x40"::"a"(12), "b"(2)); +asm volatile ("int $0x40"::"a"(12), "b"(2)); } void kol_paint_pixel(unsigned x, unsigned y, unsigned c) { -asm ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); +asm volatile ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); } void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) { -asm ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); +asm volatile ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); } void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c) { -asm ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); +asm volatile ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); } void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c) { -asm ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); +asm volatile ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); } void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d) { -asm ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); +asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); } void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette) { -asm ("nop"::"c"(w*65536+h), "d"(x*65536+y), "b"(d)); -asm ("nop"::"a"(palette)); -asm ("movl %eax, %edi"); -asm ("xor %eax, %eax"); -asm ("movl %eax, %ebp"); -asm ("pushl $8"); -asm ("popl %esi"); -asm ("int $0x40"::"a"(65)); +asm volatile ("int $0x40"::"a"(65), "b"(d), "c"(w*65536+h), "d"(x*65536+y), "D"(palette), "S"(8)); } unsigned kol_key_get() { -asm ("int $0x40"::"a"(2)); +asm volatile ("int $0x40"::"a"(2)); } unsigned kol_key_control() { -asm ("int $0x40"::"a"(66), "b"(3)); +asm volatile ("int $0x40"::"a"(66), "b"(3)); } void kol_key_lang_set(unsigned lang) { -asm ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); +asm volatile ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); } unsigned kol_key_lang_get() { -asm ("int $0x40"::"a"(26), "b"(2), "c"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(2), "c"(9)); } void kol_key_mode_set(unsigned mode) { -asm ("int $0x40"::"a"(66), "b"(1), "c"(mode)); +asm volatile ("int $0x40"::"a"(66), "b"(1), "c"(mode)); } unsigned kol_key_mode_get() { -asm ("int $0x40"::"a"(66), "b"(2)); +asm volatile ("int $0x40"::"a"(66), "b"(2)); } unsigned kol_btn_get() { -asm ("int $0x40"::"a"(17)); +asm volatile ("int $0x40"::"a"(17)); } void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c) { -asm ("nop"::"b"(x*65536+w), "c"(y*65536+h), "d"(d)); -asm ("nop"::"a"(c)); -asm ("movl %eax, %esi"); -asm ("int $0x40"::"a"(8)); +asm volatile ("int $0x40"::"a"(8), "b"(x*65536+w), "c"(y*65536+h), "d"(d), "S"(c)); } void kol_btn_type(unsigned t) { -asm ("int $0x40"::"a"(48), "b"(1), "c"(t)); +asm volatile ("int $0x40"::"a"(48), "b"(1), "c"(t)); } void kol_wnd_caption(char *s) { -asm ("int $0x40"::"a"(71), "b"(1), "c"(s)); +asm volatile ("int $0x40"::"a"(71), "b"(1), "c"(s)); } unsigned kol_mouse_pos() { -asm ("int $0x40"::"a"(37), "b"(0)); +asm volatile ("int $0x40"::"a"(37), "b"(0)); } unsigned kol_mouse_posw() { -asm ("int $0x40"::"a"(37), "b"(1)); +asm volatile ("int $0x40"::"a"(37), "b"(1)); } unsigned kol_mouse_btn() { -asm ("int $0x40"::"a"(37), "b"(2)); +asm volatile ("int $0x40"::"a"(37), "b"(2)); } void kol_board_putc(char c) { -asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); } @@ -206,7 +196,7 @@ unsigned i; i = 0; while (*(s+i)) { - asm ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); + asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); i++; } } @@ -215,26 +205,25 @@ while (*(s+i)) void kol_board_puti(int n) { char c; -int i = 0; -do - { - c = n % 10 + '0'; - asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); - i++; - } - while ((n /= 10) > 0); + +if ( n > 1 ) + kol_board_puti(n / 10); + +c = n % 10 + '0'; +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); + } int kol_file_70(kol_struct70 *k) { -asm ("int $0x40"::"a"(70), "b"(k)); +asm volatile ("int $0x40"::"a"(70), "b"(k)); } kol_struct_import* kol_cofflib_load(char *name) { -asm ("int $0x40"::"a"(68), "b"(19), "c"(name)); +asm volatile ("int $0x40"::"a"(68), "b"(19), "c"(name)); } @@ -285,37 +274,37 @@ for (i=0;;i++) unsigned kol_system_cpufreq() { -asm ("int $0x40"::"a"(18), "b"(5)); +asm volatile ("int $0x40"::"a"(18), "b"(5)); } unsigned kol_system_mem() { -asm ("int $0x40"::"a"(18), "b"(17)); +asm volatile ("int $0x40"::"a"(18), "b"(17)); } unsigned kol_system_memfree() { -asm ("int $0x40"::"a"(18), "b"(16)); +asm volatile ("int $0x40"::"a"(18), "b"(16)); } unsigned kol_system_time_get() { -asm ("int $0x40"::"a"(3)); +asm volatile ("int $0x40"::"a"(3)); } unsigned kol_system_date_get() { -asm ("int $0x40"::"a"(29)); +asm volatile ("int $0x40"::"a"(29)); } unsigned kol_system_end(unsigned param) { -asm ("int $0x40"::"a"(18), "b"(9), "c"(param)); +asm volatile ("int $0x40"::"a"(18), "b"(9), "c"(param)); } @@ -337,30 +326,30 @@ void kol_path_full(char *full, char *fname) char temp[256]; switch (*fname) -{ + { -case '/': - strncpy(temp, fname+1, 2); - temp[2]=0; - if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) - strcpy (full, fname); - break; + case '/': + strncpy(temp, fname+1, 2); + temp[2]=0; + if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) + strcpy (full, fname); + break; -case '.': - break; + case '.': + break; -default: - break; + default: + break; -}; + }; } -void kol_screen_wait_rr() +void __attribute__((__always_inline__)) kol_screen_wait_rr() { -asm ("int $0x40"::"a"(18), "b"(14)); +asm volatile ("int $0x40"::"a"(18), "b"(14)); } @@ -368,7 +357,7 @@ asm ("int $0x40"::"a"(18), "b"(14)); void kol_screen_get_size(unsigned *w, unsigned *h) { unsigned size; -asm ("int $0x40":"=a"(size):"a"(14)); +asm volatile ("int $0x40":"=a"(size):"a"(14)); *w = size / 65536; *h = size % 65536; } @@ -377,36 +366,58 @@ asm ("int $0x40":"=a"(size):"a"(14)); unsigned kol_skin_height() { -asm ("int $0x40"::"a"(48), "b"(4)); +asm volatile ("int $0x40"::"a"(48), "b"(4)); } unsigned kol_thread_start(unsigned start, unsigned stack) { -asm ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); +asm volatile ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); } unsigned kol_time_tick() { -asm ("int $0x40"::"a"(26), "b"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(9)); } unsigned kol_sound_speaker(char data[]) { -asm ("movl %0, %%esi"::"a"(data)); -asm ("int $0x40"::"a"(55), "b"(55)); +asm volatile ("movl %0, %%esi"::"a"(data)); +asm volatile ("int $0x40"::"a"(55), "b"(55)); } unsigned kol_process_info(unsigned slot, char buf1k[]) { -asm ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); +asm volatile ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); } int kol_process_kill_pid(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(18), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(18), "c"(process)); +} + +int kol_kill_process(unsigned process) +{ +asm volatile ("int $0x40"::"a"(18), "b"(2), "c"(process)); +} + +void kol_get_kernel_ver(char buff16b[]) +{ +asm volatile ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); +} + +int kol_buffer_open(char name[], int mode, int size, char **buf) +{ +int error; +asm volatile ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); +return error; +} + +void kol_buffer_close(char name[]) +{ +asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name)); } diff --git a/programs/emulator/e80/trunk/system/kolibri.h b/programs/emulator/e80/trunk/system/kolibri.h index 53575d1a72..ae3cd2ebc5 100644 --- a/programs/emulator/e80/trunk/system/kolibri.h +++ b/programs/emulator/e80/trunk/system/kolibri.h @@ -1,6 +1,18 @@ #define NULL ((void*)0) +#define SHM_OPEN 0 +#define SHM_OPEN_ALWAYS 0x04 +#define SHM_CREATE 0x08 +#define SHM_READ 0x00 +#define SHM_WRITE 0x01 + +#define E_NOTFOUND 5 +#define E_ACCESS 10 +#define E_NOMEM 30 +#define E_PARAM 33 + + typedef struct { unsigned p00 __attribute__((packed)); @@ -37,7 +49,7 @@ void *data __attribute__((packed)); void kol_exit(); void kol_sleep(unsigned d); -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c); +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t); void kol_wnd_move(unsigned x, unsigned y); void kol_wnd_caption(char *s); void kol_event_mask(unsigned e); @@ -88,3 +100,7 @@ unsigned kol_time_tick(); unsigned kol_sound_speaker(char data[]); unsigned kol_process_info(unsigned slot, char buf1k[]); int kol_process_kill_pid(unsigned process); +void kol_get_kernel_ver(char buff16b[]); +int kol_kill_process(unsigned process); +int kol_buffer_open(char name[], int mode, int size, char **buf); +void kol_buffer_close(char name[]); diff --git a/programs/games/console15/system/kolibri.c b/programs/games/console15/system/kolibri.c index 56328796a6..9e0f52a1e9 100644 --- a/programs/games/console15/system/kolibri.c +++ b/programs/games/console15/system/kolibri.c @@ -10,193 +10,183 @@ extern char KOL_DIR[256]; void kol_exit() { -asm ("int $0x40"::"a"(-1)); +asm volatile ("int $0x40"::"a"(-1)); } void kol_sleep(unsigned d) { -asm ("int $0x40"::"a"(5), "b"(d)); +asm volatile ("int $0x40"::"a"(5), "b"(d)); } -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) +// define a window +// x, y - position; w, h - size; cs - color and style; c - caption; b - boder +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t) { -asm ("nop"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); -asm ("movl $0xffffff, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) ); } void kol_wnd_move(unsigned x, unsigned y) { -asm ("nop"::"a"(67), "b"(x), "c"(y)); -asm ("movl $-1, %edx \n movl $-1, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(67), "b"(x), "c"(y), "d"(-1), "S"(-1)); } void kol_event_mask(unsigned e) { -asm ("int $0x40"::"a"(40), "b"(e)); +asm volatile ("int $0x40"::"a"(40), "b"(e)); } -unsigned kol_event_wait() +unsigned kol_event_wait() { -asm ("int $0x40"::"a"(10)); +asm volatile ("int $0x40"::"a"(10)); } unsigned kol_event_wait_time(unsigned time) { -asm ("int $0x40"::"a"(23), "b"(time)); +asm volatile ("int $0x40"::"a"(23), "b"(time)); } unsigned kol_event_check() { -asm ("int $0x40"::"a"(11)); +asm volatile ("int $0x40"::"a"(11)); } -void kol_paint_start() +void __attribute__((__always_inline__)) kol_paint_start() { -asm ("int $0x40"::"a"(12), "b"(1)); +asm volatile ("int $0x40"::"a"(12), "b"(1)); } -void kol_paint_end() +void __attribute__((__always_inline__)) kol_paint_end() { -asm ("int $0x40"::"a"(12), "b"(2)); +asm volatile ("int $0x40"::"a"(12), "b"(2)); } void kol_paint_pixel(unsigned x, unsigned y, unsigned c) { -asm ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); +asm volatile ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); } void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) { -asm ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); +asm volatile ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); } void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c) { -asm ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); +asm volatile ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); } void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c) { -asm ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); +asm volatile ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); } void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d) { -asm ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); +asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); } void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette) { -asm ("nop"::"c"(w*65536+h), "d"(x*65536+y), "b"(d)); -asm ("nop"::"a"(palette)); -asm ("movl %eax, %edi"); -asm ("xor %eax, %eax"); -asm ("movl %eax, %ebp"); -asm ("pushl $8"); -asm ("popl %esi"); -asm ("int $0x40"::"a"(65)); +asm volatile ("int $0x40"::"a"(65), "b"(d), "c"(w*65536+h), "d"(x*65536+y), "D"(palette), "S"(8)); } unsigned kol_key_get() { -asm ("int $0x40"::"a"(2)); +asm volatile ("int $0x40"::"a"(2)); } unsigned kol_key_control() { -asm ("int $0x40"::"a"(66), "b"(3)); +asm volatile ("int $0x40"::"a"(66), "b"(3)); } void kol_key_lang_set(unsigned lang) { -asm ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); +asm volatile ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); } unsigned kol_key_lang_get() { -asm ("int $0x40"::"a"(26), "b"(2), "c"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(2), "c"(9)); } void kol_key_mode_set(unsigned mode) { -asm ("int $0x40"::"a"(66), "b"(1), "c"(mode)); +asm volatile ("int $0x40"::"a"(66), "b"(1), "c"(mode)); } unsigned kol_key_mode_get() { -asm ("int $0x40"::"a"(66), "b"(2)); +asm volatile ("int $0x40"::"a"(66), "b"(2)); } unsigned kol_btn_get() { -asm ("int $0x40"::"a"(17)); +asm volatile ("int $0x40"::"a"(17)); } void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c) { -asm ("nop"::"b"(x*65536+w), "c"(y*65536+h), "d"(d)); -asm ("nop"::"a"(c)); -asm ("movl %eax, %esi"); -asm ("int $0x40"::"a"(8)); +asm volatile ("int $0x40"::"a"(8), "b"(x*65536+w), "c"(y*65536+h), "d"(d), "S"(c)); } void kol_btn_type(unsigned t) { -asm ("int $0x40"::"a"(48), "b"(1), "c"(t)); +asm volatile ("int $0x40"::"a"(48), "b"(1), "c"(t)); } void kol_wnd_caption(char *s) { -asm ("int $0x40"::"a"(71), "b"(1), "c"(s)); +asm volatile ("int $0x40"::"a"(71), "b"(1), "c"(s)); } unsigned kol_mouse_pos() { -asm ("int $0x40"::"a"(37), "b"(0)); +asm volatile ("int $0x40"::"a"(37), "b"(0)); } unsigned kol_mouse_posw() { -asm ("int $0x40"::"a"(37), "b"(1)); +asm volatile ("int $0x40"::"a"(37), "b"(1)); } unsigned kol_mouse_btn() { -asm ("int $0x40"::"a"(37), "b"(2)); +asm volatile ("int $0x40"::"a"(37), "b"(2)); } void kol_board_putc(char c) { -asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); } @@ -206,7 +196,7 @@ unsigned i; i = 0; while (*(s+i)) { - asm ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); + asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); i++; } } @@ -215,26 +205,25 @@ while (*(s+i)) void kol_board_puti(int n) { char c; -int i = 0; -do - { - c = n % 10 + '0'; - asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); - i++; - } - while ((n /= 10) > 0); + +if ( n > 1 ) + kol_board_puti(n / 10); + +c = n % 10 + '0'; +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); + } int kol_file_70(kol_struct70 *k) { -asm ("int $0x40"::"a"(70), "b"(k)); +asm volatile ("int $0x40"::"a"(70), "b"(k)); } kol_struct_import* kol_cofflib_load(char *name) { -asm ("int $0x40"::"a"(68), "b"(19), "c"(name)); +asm volatile ("int $0x40"::"a"(68), "b"(19), "c"(name)); } @@ -285,37 +274,37 @@ for (i=0;;i++) unsigned kol_system_cpufreq() { -asm ("int $0x40"::"a"(18), "b"(5)); +asm volatile ("int $0x40"::"a"(18), "b"(5)); } unsigned kol_system_mem() { -asm ("int $0x40"::"a"(18), "b"(17)); +asm volatile ("int $0x40"::"a"(18), "b"(17)); } unsigned kol_system_memfree() { -asm ("int $0x40"::"a"(18), "b"(16)); +asm volatile ("int $0x40"::"a"(18), "b"(16)); } unsigned kol_system_time_get() { -asm ("int $0x40"::"a"(3)); +asm volatile ("int $0x40"::"a"(3)); } unsigned kol_system_date_get() { -asm ("int $0x40"::"a"(29)); +asm volatile ("int $0x40"::"a"(29)); } unsigned kol_system_end(unsigned param) { -asm ("int $0x40"::"a"(18), "b"(9), "c"(param)); +asm volatile ("int $0x40"::"a"(18), "b"(9), "c"(param)); } @@ -337,30 +326,30 @@ void kol_path_full(char *full, char *fname) char temp[256]; switch (*fname) -{ + { -case '/': - strncpy(temp, fname+1, 2); - temp[2]=0; - if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) - strcpy (full, fname); - break; + case '/': + strncpy(temp, fname+1, 2); + temp[2]=0; + if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) + strcpy (full, fname); + break; -case '.': - break; + case '.': + break; -default: - break; + default: + break; -}; + }; } -void kol_screen_wait_rr() +void __attribute__((__always_inline__)) kol_screen_wait_rr() { -asm ("int $0x40"::"a"(18), "b"(14)); +asm volatile ("int $0x40"::"a"(18), "b"(14)); } @@ -368,7 +357,7 @@ asm ("int $0x40"::"a"(18), "b"(14)); void kol_screen_get_size(unsigned *w, unsigned *h) { unsigned size; -asm ("int $0x40":"=a"(size):"a"(14)); +asm volatile ("int $0x40":"=a"(size):"a"(14)); *w = size / 65536; *h = size % 65536; } @@ -377,46 +366,58 @@ asm ("int $0x40":"=a"(size):"a"(14)); unsigned kol_skin_height() { -asm ("int $0x40"::"a"(48), "b"(4)); +asm volatile ("int $0x40"::"a"(48), "b"(4)); } unsigned kol_thread_start(unsigned start, unsigned stack) { -asm ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); +asm volatile ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); } unsigned kol_time_tick() { -asm ("int $0x40"::"a"(26), "b"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(9)); } unsigned kol_sound_speaker(char data[]) { -asm ("movl %0, %%esi"::"a"(data)); -asm ("int $0x40"::"a"(55), "b"(55)); +asm volatile ("movl %0, %%esi"::"a"(data)); +asm volatile ("int $0x40"::"a"(55), "b"(55)); } unsigned kol_process_info(unsigned slot, char buf1k[]) { -asm ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); +asm volatile ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); } int kol_process_kill_pid(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(18), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(18), "c"(process)); } int kol_kill_process(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(2), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(2), "c"(process)); } void kol_get_kernel_ver(char buff16b[]) { -asm ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); +asm volatile ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); +} + +int kol_buffer_open(char name[], int mode, int size, char **buf) +{ +int error; +asm volatile ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); +return error; +} + +void kol_buffer_close(char name[]) +{ +asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name)); } diff --git a/programs/games/console15/system/kolibri.h b/programs/games/console15/system/kolibri.h index ed9ded54c4..ae3cd2ebc5 100644 --- a/programs/games/console15/system/kolibri.h +++ b/programs/games/console15/system/kolibri.h @@ -1,6 +1,18 @@ #define NULL ((void*)0) +#define SHM_OPEN 0 +#define SHM_OPEN_ALWAYS 0x04 +#define SHM_CREATE 0x08 +#define SHM_READ 0x00 +#define SHM_WRITE 0x01 + +#define E_NOTFOUND 5 +#define E_ACCESS 10 +#define E_NOMEM 30 +#define E_PARAM 33 + + typedef struct { unsigned p00 __attribute__((packed)); @@ -37,7 +49,7 @@ void *data __attribute__((packed)); void kol_exit(); void kol_sleep(unsigned d); -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c); +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t); void kol_wnd_move(unsigned x, unsigned y); void kol_wnd_caption(char *s); void kol_event_mask(unsigned e); @@ -90,3 +102,5 @@ unsigned kol_process_info(unsigned slot, char buf1k[]); int kol_process_kill_pid(unsigned process); void kol_get_kernel_ver(char buff16b[]); int kol_kill_process(unsigned process); +int kol_buffer_open(char name[], int mode, int size, char **buf); +void kol_buffer_close(char name[]); diff --git a/programs/games/donkey/c_code.c b/programs/games/donkey/c_code.c index 921271d904..3a670d833e 100644 --- a/programs/games/donkey/c_code.c +++ b/programs/games/donkey/c_code.c @@ -241,8 +241,7 @@ kol_paint_image(0, 0, 320, 200, screen.bmp); void wnd_draw() { kol_paint_start(); -kol_wnd_define(280, 200, 328, 204+kol_skin_height(), 0x34888888); -kol_wnd_caption(STR_DONKEY); +kol_wnd_define(280, 200, 328, 204+kol_skin_height(), 0x34888888, 0x34888888, STR_DONKEY); screen_draw(); kol_paint_end(); } diff --git a/programs/games/donkey/system/kolibri.c b/programs/games/donkey/system/kolibri.c index 56328796a6..9e0f52a1e9 100644 --- a/programs/games/donkey/system/kolibri.c +++ b/programs/games/donkey/system/kolibri.c @@ -10,193 +10,183 @@ extern char KOL_DIR[256]; void kol_exit() { -asm ("int $0x40"::"a"(-1)); +asm volatile ("int $0x40"::"a"(-1)); } void kol_sleep(unsigned d) { -asm ("int $0x40"::"a"(5), "b"(d)); +asm volatile ("int $0x40"::"a"(5), "b"(d)); } -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) +// define a window +// x, y - position; w, h - size; cs - color and style; c - caption; b - boder +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t) { -asm ("nop"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); -asm ("movl $0xffffff, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) ); } void kol_wnd_move(unsigned x, unsigned y) { -asm ("nop"::"a"(67), "b"(x), "c"(y)); -asm ("movl $-1, %edx \n movl $-1, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(67), "b"(x), "c"(y), "d"(-1), "S"(-1)); } void kol_event_mask(unsigned e) { -asm ("int $0x40"::"a"(40), "b"(e)); +asm volatile ("int $0x40"::"a"(40), "b"(e)); } -unsigned kol_event_wait() +unsigned kol_event_wait() { -asm ("int $0x40"::"a"(10)); +asm volatile ("int $0x40"::"a"(10)); } unsigned kol_event_wait_time(unsigned time) { -asm ("int $0x40"::"a"(23), "b"(time)); +asm volatile ("int $0x40"::"a"(23), "b"(time)); } unsigned kol_event_check() { -asm ("int $0x40"::"a"(11)); +asm volatile ("int $0x40"::"a"(11)); } -void kol_paint_start() +void __attribute__((__always_inline__)) kol_paint_start() { -asm ("int $0x40"::"a"(12), "b"(1)); +asm volatile ("int $0x40"::"a"(12), "b"(1)); } -void kol_paint_end() +void __attribute__((__always_inline__)) kol_paint_end() { -asm ("int $0x40"::"a"(12), "b"(2)); +asm volatile ("int $0x40"::"a"(12), "b"(2)); } void kol_paint_pixel(unsigned x, unsigned y, unsigned c) { -asm ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); +asm volatile ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); } void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) { -asm ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); +asm volatile ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); } void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c) { -asm ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); +asm volatile ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); } void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c) { -asm ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); +asm volatile ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); } void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d) { -asm ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); +asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); } void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette) { -asm ("nop"::"c"(w*65536+h), "d"(x*65536+y), "b"(d)); -asm ("nop"::"a"(palette)); -asm ("movl %eax, %edi"); -asm ("xor %eax, %eax"); -asm ("movl %eax, %ebp"); -asm ("pushl $8"); -asm ("popl %esi"); -asm ("int $0x40"::"a"(65)); +asm volatile ("int $0x40"::"a"(65), "b"(d), "c"(w*65536+h), "d"(x*65536+y), "D"(palette), "S"(8)); } unsigned kol_key_get() { -asm ("int $0x40"::"a"(2)); +asm volatile ("int $0x40"::"a"(2)); } unsigned kol_key_control() { -asm ("int $0x40"::"a"(66), "b"(3)); +asm volatile ("int $0x40"::"a"(66), "b"(3)); } void kol_key_lang_set(unsigned lang) { -asm ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); +asm volatile ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); } unsigned kol_key_lang_get() { -asm ("int $0x40"::"a"(26), "b"(2), "c"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(2), "c"(9)); } void kol_key_mode_set(unsigned mode) { -asm ("int $0x40"::"a"(66), "b"(1), "c"(mode)); +asm volatile ("int $0x40"::"a"(66), "b"(1), "c"(mode)); } unsigned kol_key_mode_get() { -asm ("int $0x40"::"a"(66), "b"(2)); +asm volatile ("int $0x40"::"a"(66), "b"(2)); } unsigned kol_btn_get() { -asm ("int $0x40"::"a"(17)); +asm volatile ("int $0x40"::"a"(17)); } void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c) { -asm ("nop"::"b"(x*65536+w), "c"(y*65536+h), "d"(d)); -asm ("nop"::"a"(c)); -asm ("movl %eax, %esi"); -asm ("int $0x40"::"a"(8)); +asm volatile ("int $0x40"::"a"(8), "b"(x*65536+w), "c"(y*65536+h), "d"(d), "S"(c)); } void kol_btn_type(unsigned t) { -asm ("int $0x40"::"a"(48), "b"(1), "c"(t)); +asm volatile ("int $0x40"::"a"(48), "b"(1), "c"(t)); } void kol_wnd_caption(char *s) { -asm ("int $0x40"::"a"(71), "b"(1), "c"(s)); +asm volatile ("int $0x40"::"a"(71), "b"(1), "c"(s)); } unsigned kol_mouse_pos() { -asm ("int $0x40"::"a"(37), "b"(0)); +asm volatile ("int $0x40"::"a"(37), "b"(0)); } unsigned kol_mouse_posw() { -asm ("int $0x40"::"a"(37), "b"(1)); +asm volatile ("int $0x40"::"a"(37), "b"(1)); } unsigned kol_mouse_btn() { -asm ("int $0x40"::"a"(37), "b"(2)); +asm volatile ("int $0x40"::"a"(37), "b"(2)); } void kol_board_putc(char c) { -asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); } @@ -206,7 +196,7 @@ unsigned i; i = 0; while (*(s+i)) { - asm ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); + asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); i++; } } @@ -215,26 +205,25 @@ while (*(s+i)) void kol_board_puti(int n) { char c; -int i = 0; -do - { - c = n % 10 + '0'; - asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); - i++; - } - while ((n /= 10) > 0); + +if ( n > 1 ) + kol_board_puti(n / 10); + +c = n % 10 + '0'; +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); + } int kol_file_70(kol_struct70 *k) { -asm ("int $0x40"::"a"(70), "b"(k)); +asm volatile ("int $0x40"::"a"(70), "b"(k)); } kol_struct_import* kol_cofflib_load(char *name) { -asm ("int $0x40"::"a"(68), "b"(19), "c"(name)); +asm volatile ("int $0x40"::"a"(68), "b"(19), "c"(name)); } @@ -285,37 +274,37 @@ for (i=0;;i++) unsigned kol_system_cpufreq() { -asm ("int $0x40"::"a"(18), "b"(5)); +asm volatile ("int $0x40"::"a"(18), "b"(5)); } unsigned kol_system_mem() { -asm ("int $0x40"::"a"(18), "b"(17)); +asm volatile ("int $0x40"::"a"(18), "b"(17)); } unsigned kol_system_memfree() { -asm ("int $0x40"::"a"(18), "b"(16)); +asm volatile ("int $0x40"::"a"(18), "b"(16)); } unsigned kol_system_time_get() { -asm ("int $0x40"::"a"(3)); +asm volatile ("int $0x40"::"a"(3)); } unsigned kol_system_date_get() { -asm ("int $0x40"::"a"(29)); +asm volatile ("int $0x40"::"a"(29)); } unsigned kol_system_end(unsigned param) { -asm ("int $0x40"::"a"(18), "b"(9), "c"(param)); +asm volatile ("int $0x40"::"a"(18), "b"(9), "c"(param)); } @@ -337,30 +326,30 @@ void kol_path_full(char *full, char *fname) char temp[256]; switch (*fname) -{ + { -case '/': - strncpy(temp, fname+1, 2); - temp[2]=0; - if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) - strcpy (full, fname); - break; + case '/': + strncpy(temp, fname+1, 2); + temp[2]=0; + if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) + strcpy (full, fname); + break; -case '.': - break; + case '.': + break; -default: - break; + default: + break; -}; + }; } -void kol_screen_wait_rr() +void __attribute__((__always_inline__)) kol_screen_wait_rr() { -asm ("int $0x40"::"a"(18), "b"(14)); +asm volatile ("int $0x40"::"a"(18), "b"(14)); } @@ -368,7 +357,7 @@ asm ("int $0x40"::"a"(18), "b"(14)); void kol_screen_get_size(unsigned *w, unsigned *h) { unsigned size; -asm ("int $0x40":"=a"(size):"a"(14)); +asm volatile ("int $0x40":"=a"(size):"a"(14)); *w = size / 65536; *h = size % 65536; } @@ -377,46 +366,58 @@ asm ("int $0x40":"=a"(size):"a"(14)); unsigned kol_skin_height() { -asm ("int $0x40"::"a"(48), "b"(4)); +asm volatile ("int $0x40"::"a"(48), "b"(4)); } unsigned kol_thread_start(unsigned start, unsigned stack) { -asm ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); +asm volatile ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); } unsigned kol_time_tick() { -asm ("int $0x40"::"a"(26), "b"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(9)); } unsigned kol_sound_speaker(char data[]) { -asm ("movl %0, %%esi"::"a"(data)); -asm ("int $0x40"::"a"(55), "b"(55)); +asm volatile ("movl %0, %%esi"::"a"(data)); +asm volatile ("int $0x40"::"a"(55), "b"(55)); } unsigned kol_process_info(unsigned slot, char buf1k[]) { -asm ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); +asm volatile ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); } int kol_process_kill_pid(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(18), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(18), "c"(process)); } int kol_kill_process(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(2), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(2), "c"(process)); } void kol_get_kernel_ver(char buff16b[]) { -asm ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); +asm volatile ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); +} + +int kol_buffer_open(char name[], int mode, int size, char **buf) +{ +int error; +asm volatile ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); +return error; +} + +void kol_buffer_close(char name[]) +{ +asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name)); } diff --git a/programs/games/donkey/system/kolibri.h b/programs/games/donkey/system/kolibri.h index ed9ded54c4..ae3cd2ebc5 100644 --- a/programs/games/donkey/system/kolibri.h +++ b/programs/games/donkey/system/kolibri.h @@ -1,6 +1,18 @@ #define NULL ((void*)0) +#define SHM_OPEN 0 +#define SHM_OPEN_ALWAYS 0x04 +#define SHM_CREATE 0x08 +#define SHM_READ 0x00 +#define SHM_WRITE 0x01 + +#define E_NOTFOUND 5 +#define E_ACCESS 10 +#define E_NOMEM 30 +#define E_PARAM 33 + + typedef struct { unsigned p00 __attribute__((packed)); @@ -37,7 +49,7 @@ void *data __attribute__((packed)); void kol_exit(); void kol_sleep(unsigned d); -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c); +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t); void kol_wnd_move(unsigned x, unsigned y); void kol_wnd_caption(char *s); void kol_event_mask(unsigned e); @@ -90,3 +102,5 @@ unsigned kol_process_info(unsigned slot, char buf1k[]); int kol_process_kill_pid(unsigned process); void kol_get_kernel_ver(char buff16b[]); int kol_kill_process(unsigned process); +int kol_buffer_open(char name[], int mode, int size, char **buf); +void kol_buffer_close(char name[]); diff --git a/programs/games/mcities/system/kolibri.c b/programs/games/mcities/system/kolibri.c index c77835e960..9e0f52a1e9 100644 --- a/programs/games/mcities/system/kolibri.c +++ b/programs/games/mcities/system/kolibri.c @@ -10,193 +10,183 @@ extern char KOL_DIR[256]; void kol_exit() { -asm ("int $0x40"::"a"(-1)); +asm volatile ("int $0x40"::"a"(-1)); } void kol_sleep(unsigned d) { -asm ("int $0x40"::"a"(5), "b"(d)); +asm volatile ("int $0x40"::"a"(5), "b"(d)); } -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) +// define a window +// x, y - position; w, h - size; cs - color and style; c - caption; b - boder +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t) { -asm ("nop"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); -asm ("movl $0xffffff, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) ); } void kol_wnd_move(unsigned x, unsigned y) { -asm ("nop"::"a"(67), "b"(x), "c"(y)); -asm ("movl $-1, %edx \n movl $-1, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(67), "b"(x), "c"(y), "d"(-1), "S"(-1)); } void kol_event_mask(unsigned e) { -asm ("int $0x40"::"a"(40), "b"(e)); +asm volatile ("int $0x40"::"a"(40), "b"(e)); } -unsigned kol_event_wait() +unsigned kol_event_wait() { -asm ("int $0x40"::"a"(10)); +asm volatile ("int $0x40"::"a"(10)); } unsigned kol_event_wait_time(unsigned time) { -asm ("int $0x40"::"a"(23), "b"(time)); +asm volatile ("int $0x40"::"a"(23), "b"(time)); } unsigned kol_event_check() { -asm ("int $0x40"::"a"(11)); +asm volatile ("int $0x40"::"a"(11)); } -void kol_paint_start() +void __attribute__((__always_inline__)) kol_paint_start() { -asm ("int $0x40"::"a"(12), "b"(1)); +asm volatile ("int $0x40"::"a"(12), "b"(1)); } -void kol_paint_end() +void __attribute__((__always_inline__)) kol_paint_end() { -asm ("int $0x40"::"a"(12), "b"(2)); +asm volatile ("int $0x40"::"a"(12), "b"(2)); } void kol_paint_pixel(unsigned x, unsigned y, unsigned c) { -asm ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); +asm volatile ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); } void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) { -asm ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); +asm volatile ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); } void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c) { -asm ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); +asm volatile ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); } void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c) { -asm ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); +asm volatile ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); } void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d) { -asm ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); +asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); } void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette) { -asm ("nop"::"c"(w*65536+h), "d"(x*65536+y), "b"(d)); -asm ("nop"::"a"(palette)); -asm ("movl %eax, %edi"); -asm ("xor %eax, %eax"); -asm ("movl %eax, %ebp"); -asm ("pushl $8"); -asm ("popl %esi"); -asm ("int $0x40"::"a"(65)); +asm volatile ("int $0x40"::"a"(65), "b"(d), "c"(w*65536+h), "d"(x*65536+y), "D"(palette), "S"(8)); } unsigned kol_key_get() { -asm ("int $0x40"::"a"(2)); +asm volatile ("int $0x40"::"a"(2)); } unsigned kol_key_control() { -asm ("int $0x40"::"a"(66), "b"(3)); +asm volatile ("int $0x40"::"a"(66), "b"(3)); } void kol_key_lang_set(unsigned lang) { -asm ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); +asm volatile ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); } unsigned kol_key_lang_get() { -asm ("int $0x40"::"a"(26), "b"(2), "c"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(2), "c"(9)); } void kol_key_mode_set(unsigned mode) { -asm ("int $0x40"::"a"(66), "b"(1), "c"(mode)); +asm volatile ("int $0x40"::"a"(66), "b"(1), "c"(mode)); } unsigned kol_key_mode_get() { -asm ("int $0x40"::"a"(66), "b"(2)); +asm volatile ("int $0x40"::"a"(66), "b"(2)); } unsigned kol_btn_get() { -asm ("int $0x40"::"a"(17)); +asm volatile ("int $0x40"::"a"(17)); } void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c) { -asm ("nop"::"b"(x*65536+w), "c"(y*65536+h), "d"(d)); -asm ("nop"::"a"(c)); -asm ("movl %eax, %esi"); -asm ("int $0x40"::"a"(8)); +asm volatile ("int $0x40"::"a"(8), "b"(x*65536+w), "c"(y*65536+h), "d"(d), "S"(c)); } void kol_btn_type(unsigned t) { -asm ("int $0x40"::"a"(48), "b"(1), "c"(t)); +asm volatile ("int $0x40"::"a"(48), "b"(1), "c"(t)); } void kol_wnd_caption(char *s) { -asm ("int $0x40"::"a"(71), "b"(1), "c"(s)); +asm volatile ("int $0x40"::"a"(71), "b"(1), "c"(s)); } unsigned kol_mouse_pos() { -asm ("int $0x40"::"a"(37), "b"(0)); +asm volatile ("int $0x40"::"a"(37), "b"(0)); } unsigned kol_mouse_posw() { -asm ("int $0x40"::"a"(37), "b"(1)); +asm volatile ("int $0x40"::"a"(37), "b"(1)); } unsigned kol_mouse_btn() { -asm ("int $0x40"::"a"(37), "b"(2)); +asm volatile ("int $0x40"::"a"(37), "b"(2)); } void kol_board_putc(char c) { -asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); } @@ -206,7 +196,7 @@ unsigned i; i = 0; while (*(s+i)) { - asm ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); + asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); i++; } } @@ -220,20 +210,20 @@ if ( n > 1 ) kol_board_puti(n / 10); c = n % 10 + '0'; -asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); } int kol_file_70(kol_struct70 *k) { -asm ("int $0x40"::"a"(70), "b"(k)); +asm volatile ("int $0x40"::"a"(70), "b"(k)); } kol_struct_import* kol_cofflib_load(char *name) { -asm ("int $0x40"::"a"(68), "b"(19), "c"(name)); +asm volatile ("int $0x40"::"a"(68), "b"(19), "c"(name)); } @@ -284,37 +274,37 @@ for (i=0;;i++) unsigned kol_system_cpufreq() { -asm ("int $0x40"::"a"(18), "b"(5)); +asm volatile ("int $0x40"::"a"(18), "b"(5)); } unsigned kol_system_mem() { -asm ("int $0x40"::"a"(18), "b"(17)); +asm volatile ("int $0x40"::"a"(18), "b"(17)); } unsigned kol_system_memfree() { -asm ("int $0x40"::"a"(18), "b"(16)); +asm volatile ("int $0x40"::"a"(18), "b"(16)); } unsigned kol_system_time_get() { -asm ("int $0x40"::"a"(3)); +asm volatile ("int $0x40"::"a"(3)); } unsigned kol_system_date_get() { -asm ("int $0x40"::"a"(29)); +asm volatile ("int $0x40"::"a"(29)); } unsigned kol_system_end(unsigned param) { -asm ("int $0x40"::"a"(18), "b"(9), "c"(param)); +asm volatile ("int $0x40"::"a"(18), "b"(9), "c"(param)); } @@ -336,30 +326,30 @@ void kol_path_full(char *full, char *fname) char temp[256]; switch (*fname) -{ + { -case '/': - strncpy(temp, fname+1, 2); - temp[2]=0; - if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) - strcpy (full, fname); - break; + case '/': + strncpy(temp, fname+1, 2); + temp[2]=0; + if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) + strcpy (full, fname); + break; -case '.': - break; + case '.': + break; -default: - break; + default: + break; -}; + }; } -void kol_screen_wait_rr() +void __attribute__((__always_inline__)) kol_screen_wait_rr() { -asm ("int $0x40"::"a"(18), "b"(14)); +asm volatile ("int $0x40"::"a"(18), "b"(14)); } @@ -367,7 +357,7 @@ asm ("int $0x40"::"a"(18), "b"(14)); void kol_screen_get_size(unsigned *w, unsigned *h) { unsigned size; -asm ("int $0x40":"=a"(size):"a"(14)); +asm volatile ("int $0x40":"=a"(size):"a"(14)); *w = size / 65536; *h = size % 65536; } @@ -376,59 +366,58 @@ asm ("int $0x40":"=a"(size):"a"(14)); unsigned kol_skin_height() { -asm ("int $0x40"::"a"(48), "b"(4)); +asm volatile ("int $0x40"::"a"(48), "b"(4)); } unsigned kol_thread_start(unsigned start, unsigned stack) { -asm ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); +asm volatile ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); } unsigned kol_time_tick() { -asm ("int $0x40"::"a"(26), "b"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(9)); } unsigned kol_sound_speaker(char data[]) { -asm ("movl %0, %%esi"::"a"(data)); -asm ("int $0x40"::"a"(55), "b"(55)); +asm volatile ("movl %0, %%esi"::"a"(data)); +asm volatile ("int $0x40"::"a"(55), "b"(55)); } unsigned kol_process_info(unsigned slot, char buf1k[]) { -asm ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); +asm volatile ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); } int kol_process_kill_pid(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(18), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(18), "c"(process)); } int kol_kill_process(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(2), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(2), "c"(process)); } void kol_get_kernel_ver(char buff16b[]) { -asm ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); +asm volatile ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); } int kol_buffer_open(char name[], int mode, int size, char **buf) { int error; -asm ("movl %0, %%esi"::"r"(mode)); -asm ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size)); +asm volatile ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); return error; } void kol_buffer_close(char name[]) { -asm ("int $0x40"::"a"(68), "b"(23), "c"(name)); +asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name)); } diff --git a/programs/games/mcities/system/kolibri.h b/programs/games/mcities/system/kolibri.h index d9595a2bc7..ae3cd2ebc5 100644 --- a/programs/games/mcities/system/kolibri.h +++ b/programs/games/mcities/system/kolibri.h @@ -49,7 +49,7 @@ void *data __attribute__((packed)); void kol_exit(); void kol_sleep(unsigned d); -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c); +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t); void kol_wnd_move(unsigned x, unsigned y); void kol_wnd_caption(char *s); void kol_event_mask(unsigned e); diff --git a/programs/games/piton/c_code.c b/programs/games/piton/c_code.c index 7906be7b1c..7e8e44aa57 100644 --- a/programs/games/piton/c_code.c +++ b/programs/games/piton/c_code.c @@ -219,8 +219,7 @@ kol_paint_image(0, 0, scrw, scrh, screen.bmp); void wnd_draw() { kol_paint_start(); -kol_wnd_define(280, 30, scrw+8, scrh+kol_skin_height()+4, 0x34888888); -kol_wnd_caption(STR_TITLE); +kol_wnd_define(280, 30, scrw+8, scrh+kol_skin_height()+4, 0x34888888, 0x34888888, STR_TITLE); screen_draw(); kol_paint_end(); } diff --git a/programs/games/piton/system/kolibri.c b/programs/games/piton/system/kolibri.c index 56328796a6..9e0f52a1e9 100644 --- a/programs/games/piton/system/kolibri.c +++ b/programs/games/piton/system/kolibri.c @@ -10,193 +10,183 @@ extern char KOL_DIR[256]; void kol_exit() { -asm ("int $0x40"::"a"(-1)); +asm volatile ("int $0x40"::"a"(-1)); } void kol_sleep(unsigned d) { -asm ("int $0x40"::"a"(5), "b"(d)); +asm volatile ("int $0x40"::"a"(5), "b"(d)); } -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) +// define a window +// x, y - position; w, h - size; cs - color and style; c - caption; b - boder +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t) { -asm ("nop"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); -asm ("movl $0xffffff, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) ); } void kol_wnd_move(unsigned x, unsigned y) { -asm ("nop"::"a"(67), "b"(x), "c"(y)); -asm ("movl $-1, %edx \n movl $-1, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(67), "b"(x), "c"(y), "d"(-1), "S"(-1)); } void kol_event_mask(unsigned e) { -asm ("int $0x40"::"a"(40), "b"(e)); +asm volatile ("int $0x40"::"a"(40), "b"(e)); } -unsigned kol_event_wait() +unsigned kol_event_wait() { -asm ("int $0x40"::"a"(10)); +asm volatile ("int $0x40"::"a"(10)); } unsigned kol_event_wait_time(unsigned time) { -asm ("int $0x40"::"a"(23), "b"(time)); +asm volatile ("int $0x40"::"a"(23), "b"(time)); } unsigned kol_event_check() { -asm ("int $0x40"::"a"(11)); +asm volatile ("int $0x40"::"a"(11)); } -void kol_paint_start() +void __attribute__((__always_inline__)) kol_paint_start() { -asm ("int $0x40"::"a"(12), "b"(1)); +asm volatile ("int $0x40"::"a"(12), "b"(1)); } -void kol_paint_end() +void __attribute__((__always_inline__)) kol_paint_end() { -asm ("int $0x40"::"a"(12), "b"(2)); +asm volatile ("int $0x40"::"a"(12), "b"(2)); } void kol_paint_pixel(unsigned x, unsigned y, unsigned c) { -asm ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); +asm volatile ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); } void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) { -asm ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); +asm volatile ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); } void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c) { -asm ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); +asm volatile ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); } void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c) { -asm ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); +asm volatile ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); } void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d) { -asm ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); +asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); } void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette) { -asm ("nop"::"c"(w*65536+h), "d"(x*65536+y), "b"(d)); -asm ("nop"::"a"(palette)); -asm ("movl %eax, %edi"); -asm ("xor %eax, %eax"); -asm ("movl %eax, %ebp"); -asm ("pushl $8"); -asm ("popl %esi"); -asm ("int $0x40"::"a"(65)); +asm volatile ("int $0x40"::"a"(65), "b"(d), "c"(w*65536+h), "d"(x*65536+y), "D"(palette), "S"(8)); } unsigned kol_key_get() { -asm ("int $0x40"::"a"(2)); +asm volatile ("int $0x40"::"a"(2)); } unsigned kol_key_control() { -asm ("int $0x40"::"a"(66), "b"(3)); +asm volatile ("int $0x40"::"a"(66), "b"(3)); } void kol_key_lang_set(unsigned lang) { -asm ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); +asm volatile ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); } unsigned kol_key_lang_get() { -asm ("int $0x40"::"a"(26), "b"(2), "c"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(2), "c"(9)); } void kol_key_mode_set(unsigned mode) { -asm ("int $0x40"::"a"(66), "b"(1), "c"(mode)); +asm volatile ("int $0x40"::"a"(66), "b"(1), "c"(mode)); } unsigned kol_key_mode_get() { -asm ("int $0x40"::"a"(66), "b"(2)); +asm volatile ("int $0x40"::"a"(66), "b"(2)); } unsigned kol_btn_get() { -asm ("int $0x40"::"a"(17)); +asm volatile ("int $0x40"::"a"(17)); } void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c) { -asm ("nop"::"b"(x*65536+w), "c"(y*65536+h), "d"(d)); -asm ("nop"::"a"(c)); -asm ("movl %eax, %esi"); -asm ("int $0x40"::"a"(8)); +asm volatile ("int $0x40"::"a"(8), "b"(x*65536+w), "c"(y*65536+h), "d"(d), "S"(c)); } void kol_btn_type(unsigned t) { -asm ("int $0x40"::"a"(48), "b"(1), "c"(t)); +asm volatile ("int $0x40"::"a"(48), "b"(1), "c"(t)); } void kol_wnd_caption(char *s) { -asm ("int $0x40"::"a"(71), "b"(1), "c"(s)); +asm volatile ("int $0x40"::"a"(71), "b"(1), "c"(s)); } unsigned kol_mouse_pos() { -asm ("int $0x40"::"a"(37), "b"(0)); +asm volatile ("int $0x40"::"a"(37), "b"(0)); } unsigned kol_mouse_posw() { -asm ("int $0x40"::"a"(37), "b"(1)); +asm volatile ("int $0x40"::"a"(37), "b"(1)); } unsigned kol_mouse_btn() { -asm ("int $0x40"::"a"(37), "b"(2)); +asm volatile ("int $0x40"::"a"(37), "b"(2)); } void kol_board_putc(char c) { -asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); } @@ -206,7 +196,7 @@ unsigned i; i = 0; while (*(s+i)) { - asm ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); + asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); i++; } } @@ -215,26 +205,25 @@ while (*(s+i)) void kol_board_puti(int n) { char c; -int i = 0; -do - { - c = n % 10 + '0'; - asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); - i++; - } - while ((n /= 10) > 0); + +if ( n > 1 ) + kol_board_puti(n / 10); + +c = n % 10 + '0'; +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); + } int kol_file_70(kol_struct70 *k) { -asm ("int $0x40"::"a"(70), "b"(k)); +asm volatile ("int $0x40"::"a"(70), "b"(k)); } kol_struct_import* kol_cofflib_load(char *name) { -asm ("int $0x40"::"a"(68), "b"(19), "c"(name)); +asm volatile ("int $0x40"::"a"(68), "b"(19), "c"(name)); } @@ -285,37 +274,37 @@ for (i=0;;i++) unsigned kol_system_cpufreq() { -asm ("int $0x40"::"a"(18), "b"(5)); +asm volatile ("int $0x40"::"a"(18), "b"(5)); } unsigned kol_system_mem() { -asm ("int $0x40"::"a"(18), "b"(17)); +asm volatile ("int $0x40"::"a"(18), "b"(17)); } unsigned kol_system_memfree() { -asm ("int $0x40"::"a"(18), "b"(16)); +asm volatile ("int $0x40"::"a"(18), "b"(16)); } unsigned kol_system_time_get() { -asm ("int $0x40"::"a"(3)); +asm volatile ("int $0x40"::"a"(3)); } unsigned kol_system_date_get() { -asm ("int $0x40"::"a"(29)); +asm volatile ("int $0x40"::"a"(29)); } unsigned kol_system_end(unsigned param) { -asm ("int $0x40"::"a"(18), "b"(9), "c"(param)); +asm volatile ("int $0x40"::"a"(18), "b"(9), "c"(param)); } @@ -337,30 +326,30 @@ void kol_path_full(char *full, char *fname) char temp[256]; switch (*fname) -{ + { -case '/': - strncpy(temp, fname+1, 2); - temp[2]=0; - if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) - strcpy (full, fname); - break; + case '/': + strncpy(temp, fname+1, 2); + temp[2]=0; + if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) + strcpy (full, fname); + break; -case '.': - break; + case '.': + break; -default: - break; + default: + break; -}; + }; } -void kol_screen_wait_rr() +void __attribute__((__always_inline__)) kol_screen_wait_rr() { -asm ("int $0x40"::"a"(18), "b"(14)); +asm volatile ("int $0x40"::"a"(18), "b"(14)); } @@ -368,7 +357,7 @@ asm ("int $0x40"::"a"(18), "b"(14)); void kol_screen_get_size(unsigned *w, unsigned *h) { unsigned size; -asm ("int $0x40":"=a"(size):"a"(14)); +asm volatile ("int $0x40":"=a"(size):"a"(14)); *w = size / 65536; *h = size % 65536; } @@ -377,46 +366,58 @@ asm ("int $0x40":"=a"(size):"a"(14)); unsigned kol_skin_height() { -asm ("int $0x40"::"a"(48), "b"(4)); +asm volatile ("int $0x40"::"a"(48), "b"(4)); } unsigned kol_thread_start(unsigned start, unsigned stack) { -asm ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); +asm volatile ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); } unsigned kol_time_tick() { -asm ("int $0x40"::"a"(26), "b"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(9)); } unsigned kol_sound_speaker(char data[]) { -asm ("movl %0, %%esi"::"a"(data)); -asm ("int $0x40"::"a"(55), "b"(55)); +asm volatile ("movl %0, %%esi"::"a"(data)); +asm volatile ("int $0x40"::"a"(55), "b"(55)); } unsigned kol_process_info(unsigned slot, char buf1k[]) { -asm ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); +asm volatile ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); } int kol_process_kill_pid(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(18), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(18), "c"(process)); } int kol_kill_process(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(2), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(2), "c"(process)); } void kol_get_kernel_ver(char buff16b[]) { -asm ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); +asm volatile ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); +} + +int kol_buffer_open(char name[], int mode, int size, char **buf) +{ +int error; +asm volatile ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); +return error; +} + +void kol_buffer_close(char name[]) +{ +asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name)); } diff --git a/programs/games/piton/system/kolibri.h b/programs/games/piton/system/kolibri.h index ed9ded54c4..ae3cd2ebc5 100644 --- a/programs/games/piton/system/kolibri.h +++ b/programs/games/piton/system/kolibri.h @@ -1,6 +1,18 @@ #define NULL ((void*)0) +#define SHM_OPEN 0 +#define SHM_OPEN_ALWAYS 0x04 +#define SHM_CREATE 0x08 +#define SHM_READ 0x00 +#define SHM_WRITE 0x01 + +#define E_NOTFOUND 5 +#define E_ACCESS 10 +#define E_NOMEM 30 +#define E_PARAM 33 + + typedef struct { unsigned p00 __attribute__((packed)); @@ -37,7 +49,7 @@ void *data __attribute__((packed)); void kol_exit(); void kol_sleep(unsigned d); -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c); +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t); void kol_wnd_move(unsigned x, unsigned y); void kol_wnd_caption(char *s); void kol_event_mask(unsigned e); @@ -90,3 +102,5 @@ unsigned kol_process_info(unsigned slot, char buf1k[]); int kol_process_kill_pid(unsigned process); void kol_get_kernel_ver(char buff16b[]); int kol_kill_process(unsigned process); +int kol_buffer_open(char name[], int mode, int size, char **buf); +void kol_buffer_close(char name[]); diff --git a/programs/system/shell/cmd/cmd_memory.c b/programs/system/shell/cmd/cmd_memory.c deleted file mode 100644 index 3f3d1434c3..0000000000 --- a/programs/system/shell/cmd/cmd_memory.c +++ /dev/null @@ -1,18 +0,0 @@ - -int cmd_memory(char param[]) -{ -unsigned total, free, used; - -total = kol_system_mem(); -free = kol_system_memfree(); -used = total - free; - -#if LANG_ENG - printf (" Total [kB / MB / %%]: %-7d / %-5d / 100\n\r Free [kB / MB / %%]: %-7d / %-5d / %d\n\r Used [kB / MB / %%]: %-7d / %-5d / %d\n\r", -#elif LANG_RUS - printf (" Всего [КБ / МБ / %%]: %-7d / %-5d / 100\n\r Свободно [КБ / МБ / %%]: %-7d / %-5d / %d\n\r Используется [КБ / МБ / %%]: %-7d / %-5d / %d\n\r", -#endif - total, total/1024, free, free/1024, (free*100)/total, used, total/1024-free/1024, 100-(free*100)/total ); - -return TRUE; -} diff --git a/programs/system/shell/system/kolibri.c b/programs/system/shell/system/kolibri.c index c77835e960..9e0f52a1e9 100644 --- a/programs/system/shell/system/kolibri.c +++ b/programs/system/shell/system/kolibri.c @@ -10,193 +10,183 @@ extern char KOL_DIR[256]; void kol_exit() { -asm ("int $0x40"::"a"(-1)); +asm volatile ("int $0x40"::"a"(-1)); } void kol_sleep(unsigned d) { -asm ("int $0x40"::"a"(5), "b"(d)); +asm volatile ("int $0x40"::"a"(5), "b"(d)); } -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) +// define a window +// x, y - position; w, h - size; cs - color and style; c - caption; b - boder +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t) { -asm ("nop"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); -asm ("movl $0xffffff, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) ); } void kol_wnd_move(unsigned x, unsigned y) { -asm ("nop"::"a"(67), "b"(x), "c"(y)); -asm ("movl $-1, %edx \n movl $-1, %esi \n int $0x40"); +asm volatile ("int $0x40"::"a"(67), "b"(x), "c"(y), "d"(-1), "S"(-1)); } void kol_event_mask(unsigned e) { -asm ("int $0x40"::"a"(40), "b"(e)); +asm volatile ("int $0x40"::"a"(40), "b"(e)); } -unsigned kol_event_wait() +unsigned kol_event_wait() { -asm ("int $0x40"::"a"(10)); +asm volatile ("int $0x40"::"a"(10)); } unsigned kol_event_wait_time(unsigned time) { -asm ("int $0x40"::"a"(23), "b"(time)); +asm volatile ("int $0x40"::"a"(23), "b"(time)); } unsigned kol_event_check() { -asm ("int $0x40"::"a"(11)); +asm volatile ("int $0x40"::"a"(11)); } -void kol_paint_start() +void __attribute__((__always_inline__)) kol_paint_start() { -asm ("int $0x40"::"a"(12), "b"(1)); +asm volatile ("int $0x40"::"a"(12), "b"(1)); } -void kol_paint_end() +void __attribute__((__always_inline__)) kol_paint_end() { -asm ("int $0x40"::"a"(12), "b"(2)); +asm volatile ("int $0x40"::"a"(12), "b"(2)); } void kol_paint_pixel(unsigned x, unsigned y, unsigned c) { -asm ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); +asm volatile ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); } void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) { -asm ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); +asm volatile ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); } void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c) { -asm ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); +asm volatile ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); } void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c) { -asm ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); +asm volatile ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); } void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d) { -asm ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); +asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); } void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette) { -asm ("nop"::"c"(w*65536+h), "d"(x*65536+y), "b"(d)); -asm ("nop"::"a"(palette)); -asm ("movl %eax, %edi"); -asm ("xor %eax, %eax"); -asm ("movl %eax, %ebp"); -asm ("pushl $8"); -asm ("popl %esi"); -asm ("int $0x40"::"a"(65)); +asm volatile ("int $0x40"::"a"(65), "b"(d), "c"(w*65536+h), "d"(x*65536+y), "D"(palette), "S"(8)); } unsigned kol_key_get() { -asm ("int $0x40"::"a"(2)); +asm volatile ("int $0x40"::"a"(2)); } unsigned kol_key_control() { -asm ("int $0x40"::"a"(66), "b"(3)); +asm volatile ("int $0x40"::"a"(66), "b"(3)); } void kol_key_lang_set(unsigned lang) { -asm ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); +asm volatile ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); } unsigned kol_key_lang_get() { -asm ("int $0x40"::"a"(26), "b"(2), "c"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(2), "c"(9)); } void kol_key_mode_set(unsigned mode) { -asm ("int $0x40"::"a"(66), "b"(1), "c"(mode)); +asm volatile ("int $0x40"::"a"(66), "b"(1), "c"(mode)); } unsigned kol_key_mode_get() { -asm ("int $0x40"::"a"(66), "b"(2)); +asm volatile ("int $0x40"::"a"(66), "b"(2)); } unsigned kol_btn_get() { -asm ("int $0x40"::"a"(17)); +asm volatile ("int $0x40"::"a"(17)); } void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c) { -asm ("nop"::"b"(x*65536+w), "c"(y*65536+h), "d"(d)); -asm ("nop"::"a"(c)); -asm ("movl %eax, %esi"); -asm ("int $0x40"::"a"(8)); +asm volatile ("int $0x40"::"a"(8), "b"(x*65536+w), "c"(y*65536+h), "d"(d), "S"(c)); } void kol_btn_type(unsigned t) { -asm ("int $0x40"::"a"(48), "b"(1), "c"(t)); +asm volatile ("int $0x40"::"a"(48), "b"(1), "c"(t)); } void kol_wnd_caption(char *s) { -asm ("int $0x40"::"a"(71), "b"(1), "c"(s)); +asm volatile ("int $0x40"::"a"(71), "b"(1), "c"(s)); } unsigned kol_mouse_pos() { -asm ("int $0x40"::"a"(37), "b"(0)); +asm volatile ("int $0x40"::"a"(37), "b"(0)); } unsigned kol_mouse_posw() { -asm ("int $0x40"::"a"(37), "b"(1)); +asm volatile ("int $0x40"::"a"(37), "b"(1)); } unsigned kol_mouse_btn() { -asm ("int $0x40"::"a"(37), "b"(2)); +asm volatile ("int $0x40"::"a"(37), "b"(2)); } void kol_board_putc(char c) { -asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); } @@ -206,7 +196,7 @@ unsigned i; i = 0; while (*(s+i)) { - asm ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); + asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); i++; } } @@ -220,20 +210,20 @@ if ( n > 1 ) kol_board_puti(n / 10); c = n % 10 + '0'; -asm ("int $0x40"::"a"(63), "b"(1), "c"(c)); +asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); } int kol_file_70(kol_struct70 *k) { -asm ("int $0x40"::"a"(70), "b"(k)); +asm volatile ("int $0x40"::"a"(70), "b"(k)); } kol_struct_import* kol_cofflib_load(char *name) { -asm ("int $0x40"::"a"(68), "b"(19), "c"(name)); +asm volatile ("int $0x40"::"a"(68), "b"(19), "c"(name)); } @@ -284,37 +274,37 @@ for (i=0;;i++) unsigned kol_system_cpufreq() { -asm ("int $0x40"::"a"(18), "b"(5)); +asm volatile ("int $0x40"::"a"(18), "b"(5)); } unsigned kol_system_mem() { -asm ("int $0x40"::"a"(18), "b"(17)); +asm volatile ("int $0x40"::"a"(18), "b"(17)); } unsigned kol_system_memfree() { -asm ("int $0x40"::"a"(18), "b"(16)); +asm volatile ("int $0x40"::"a"(18), "b"(16)); } unsigned kol_system_time_get() { -asm ("int $0x40"::"a"(3)); +asm volatile ("int $0x40"::"a"(3)); } unsigned kol_system_date_get() { -asm ("int $0x40"::"a"(29)); +asm volatile ("int $0x40"::"a"(29)); } unsigned kol_system_end(unsigned param) { -asm ("int $0x40"::"a"(18), "b"(9), "c"(param)); +asm volatile ("int $0x40"::"a"(18), "b"(9), "c"(param)); } @@ -336,30 +326,30 @@ void kol_path_full(char *full, char *fname) char temp[256]; switch (*fname) -{ + { -case '/': - strncpy(temp, fname+1, 2); - temp[2]=0; - if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) - strcpy (full, fname); - break; + case '/': + strncpy(temp, fname+1, 2); + temp[2]=0; + if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) + strcpy (full, fname); + break; -case '.': - break; + case '.': + break; -default: - break; + default: + break; -}; + }; } -void kol_screen_wait_rr() +void __attribute__((__always_inline__)) kol_screen_wait_rr() { -asm ("int $0x40"::"a"(18), "b"(14)); +asm volatile ("int $0x40"::"a"(18), "b"(14)); } @@ -367,7 +357,7 @@ asm ("int $0x40"::"a"(18), "b"(14)); void kol_screen_get_size(unsigned *w, unsigned *h) { unsigned size; -asm ("int $0x40":"=a"(size):"a"(14)); +asm volatile ("int $0x40":"=a"(size):"a"(14)); *w = size / 65536; *h = size % 65536; } @@ -376,59 +366,58 @@ asm ("int $0x40":"=a"(size):"a"(14)); unsigned kol_skin_height() { -asm ("int $0x40"::"a"(48), "b"(4)); +asm volatile ("int $0x40"::"a"(48), "b"(4)); } unsigned kol_thread_start(unsigned start, unsigned stack) { -asm ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); +asm volatile ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); } unsigned kol_time_tick() { -asm ("int $0x40"::"a"(26), "b"(9)); +asm volatile ("int $0x40"::"a"(26), "b"(9)); } unsigned kol_sound_speaker(char data[]) { -asm ("movl %0, %%esi"::"a"(data)); -asm ("int $0x40"::"a"(55), "b"(55)); +asm volatile ("movl %0, %%esi"::"a"(data)); +asm volatile ("int $0x40"::"a"(55), "b"(55)); } unsigned kol_process_info(unsigned slot, char buf1k[]) { -asm ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); +asm volatile ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); } int kol_process_kill_pid(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(18), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(18), "c"(process)); } int kol_kill_process(unsigned process) { -asm ("int $0x40"::"a"(18), "b"(2), "c"(process)); +asm volatile ("int $0x40"::"a"(18), "b"(2), "c"(process)); } void kol_get_kernel_ver(char buff16b[]) { -asm ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); +asm volatile ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); } int kol_buffer_open(char name[], int mode, int size, char **buf) { int error; -asm ("movl %0, %%esi"::"r"(mode)); -asm ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size)); +asm volatile ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); return error; } void kol_buffer_close(char name[]) { -asm ("int $0x40"::"a"(68), "b"(23), "c"(name)); +asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name)); } diff --git a/programs/system/shell/system/kolibri.h b/programs/system/shell/system/kolibri.h index d9595a2bc7..ae3cd2ebc5 100644 --- a/programs/system/shell/system/kolibri.h +++ b/programs/system/shell/system/kolibri.h @@ -49,7 +49,7 @@ void *data __attribute__((packed)); void kol_exit(); void kol_sleep(unsigned d); -void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c); +void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t); void kol_wnd_move(unsigned x, unsigned y); void kol_wnd_caption(char *s); void kol_event_mask(unsigned e);