diff --git a/kofu.c b/kofu.c index f9fa0c0..ef8f254 100644 --- a/kofu.c +++ b/kofu.c @@ -298,6 +298,90 @@ void kofu_display_number(int argc, const char **argv) { umka_sys_display_number(is_pointer, base, digits_to_display, is_qword, show_leading_zeros, number_or_pointer, x, y, color, fill_background, font, draw_to_buffer, scale_factor, background_color_or_buffer); } +void kofu_set_window_colors(int argc, const char **argv) { + if (argc != (1 + sizeof(system_colors_t)/4)) { + printf("10 colors required\n"); + return; + } + system_colors_t colors; + colors.frame = strtoul(argv[1], NULL, 16); + colors.grab = strtoul(argv[2], NULL, 16); + colors.work_3d_dark = strtoul(argv[3], NULL, 16); + colors.work_3d_light = strtoul(argv[4], NULL, 16); + colors.grab_text = strtoul(argv[5], NULL, 16); + colors.work = strtoul(argv[6], NULL, 16); + colors.work_button = strtoul(argv[7], NULL, 16); + colors.work_button_text = strtoul(argv[8], NULL, 16); + colors.work_text = strtoul(argv[9], NULL, 16); + colors.work_graph = strtoul(argv[10], NULL, 16); + umka_sys_set_window_colors(&colors); +} + +void kofu_get_window_colors(int argc, const char **argv) { + (void)argc; + (void)argv; + system_colors_t colors; + umka_sys_get_window_colors(&colors); + printf("0x%.8" PRIx32 " frame\n", colors.frame); + printf("0x%.8" PRIx32 " grab\n", colors.grab); + printf("0x%.8" PRIx32 " work_3d_dark\n", colors.work_3d_dark); + printf("0x%.8" PRIx32 " work_3d_light\n", colors.work_3d_light); + printf("0x%.8" PRIx32 " grab_text\n", colors.grab_text); + printf("0x%.8" PRIx32 " work\n", colors.work); + printf("0x%.8" PRIx32 " work_button\n", colors.work_button); + printf("0x%.8" PRIx32 " work_button_text\n", colors.work_button_text); + printf("0x%.8" PRIx32 " work_text\n", colors.work_text); + printf("0x%.8" PRIx32 " work_graph\n", colors.work_graph); +} + +void kofu_get_skin_height(int argc, const char **argv) { + (void)argc; + (void)argv; + uint32_t skin_height = umka_sys_get_skin_height(); + printf("%" PRIu32 "\n", skin_height); +} + +void kofu_get_screen_area(int argc, const char **argv) { + (void)argc; + (void)argv; + rect_t wa; + umka_sys_get_screen_area(&wa); + printf("%" PRIu32 " left\n", wa.left); + printf("%" PRIu32 " top\n", wa.top); + printf("%" PRIu32 " right\n", wa.right); + printf("%" PRIu32 " bottom\n", wa.bottom); +} + +void kofu_set_screen_area(int argc, const char **argv) { + if (argc != 5) { + printf("left top right bottom\n"); + return; + } + rect_t wa; + wa.left = strtoul(argv[1], NULL, 0); + wa.top = strtoul(argv[2], NULL, 0); + wa.right = strtoul(argv[3], NULL, 0); + wa.bottom = strtoul(argv[4], NULL, 0); + umka_sys_set_screen_area(&wa); +} + +void kofu_get_skin_margins(int argc, const char **argv) { + (void)argc; + (void)argv; + rect_t wa; + umka_sys_get_skin_margins(&wa); + printf("%" PRIu32 " left\n", wa.left); + printf("%" PRIu32 " top\n", wa.top); + printf("%" PRIu32 " right\n", wa.right); + printf("%" PRIu32 " bottom\n", wa.bottom); +} + +void kofu_set_button_style(int argc, const char **argv) { + (void)argc; + uint32_t style = strtoul(argv[1], NULL, 0); + umka_sys_set_button_style(style); +} + void kofu_set_skin(int argc, const char **argv) { (void)argc; const char *path = argv[1]; @@ -309,14 +393,27 @@ void kofu_get_font_smoothing(int argc, const char **argv) { (void)argc; (void)argv; const char *names[] = {"off", "anti-aliasing", "subpixel"}; - int type = umka_sys_get_smoothing(); + int type = umka_sys_get_font_smoothing(); printf("font smoothing: %i - %s\n", type, names[type]); } void kofu_set_font_smoothing(int argc, const char **argv) { (void)argc; int type = strtol(argv[1], NULL, 0); - umka_sys_set_smoothing(type); + umka_sys_set_font_smoothing(type); +} + +void kofu_get_font_size(int argc, const char **argv) { + (void)argc; + (void)argv; + size_t size = umka_sys_get_font_size(); + printf("%upx\n", size); +} + +void kofu_set_font_size(int argc, const char **argv) { + (void)argc; + uint32_t size = strtoul(argv[1], NULL, 0); + umka_sys_set_font_size(size); } void kofu_button(int argc, const char **argv) { @@ -718,9 +815,18 @@ func_table_t funcs[] = { { "draw_rect", kofu_draw_rect }, { "draw_line", kofu_draw_line }, { "display_number", kofu_display_number }, + { "set_button_style", kofu_set_button_style }, + { "set_window_colors", kofu_set_window_colors }, + { "get_window_colors", kofu_get_window_colors }, + { "get_skin_height", kofu_get_skin_height }, + { "get_screen_area", kofu_get_screen_area }, + { "set_screen_area", kofu_set_screen_area }, + { "get_skin_margins", kofu_get_skin_margins }, { "set_skin", kofu_set_skin }, { "get_font_smoothing", kofu_get_font_smoothing }, { "set_font_smoothing", kofu_set_font_smoothing }, + { "get_font_size", kofu_get_font_size }, + { "set_font_size", kofu_set_font_size }, { "put_image_palette", kofu_put_image_palette }, { "move_window", kofu_move_window }, { "set_window_caption", kofu_set_window_caption }, diff --git a/kolibri.asm b/kolibri.asm index 6a97594..8170cda 100644 --- a/kolibri.asm +++ b/kolibri.asm @@ -22,6 +22,17 @@ macro int n { end if } +app_tls = 0 +app_code = 0 +app_data = 0 +graph_data = 0 +os_code = 0 + +MAX_PRIORITY = 0 ; highest, used for kernel tasks +USER_PRIORITY = 1 ; default +IDLE_PRIORITY = 2 ; lowest, only IDLE thread goes here +NR_SCHED_QUEUES = 3 ; MUST equal IDLE_PRIORYTY + 1 + purge mov,add,sub purge mov,add,sub section '.text' executable align 32 @@ -32,32 +43,48 @@ coverage_begin: public coverage_begin include 'macros.inc' -macro diff16 blah1,blah2,blah3 { +macro diff16 msg,blah2,blah3 { + if msg eq "end of .data segment" + section '.bss' writeable align 64 + end if } include 'proc32.inc' include 'struct.inc' +macro BOOT_LO a {} +macro BOOT a {} include 'const.inc' -LFB_BASE = lfb_base -SLOT_BASE = os_base + 0x00080000 -window_data = os_base + 0x00001000 -WIN_STACK = os_base + 0x0000C000 -WIN_POS = os_base + 0x0000C400 -KEY_COUNT = os_base + 0x0000F400 -KEY_BUFF = os_base + 0x0000F401 ; 120*2 + 2*2 = 244 bytes, actually 255 bytes -BTN_COUNT = os_base + 0x0000F500 -BTN_BUFF = os_base + 0x0000F501 -BTN_ADDR = os_base + 0x0000FE88 -TASK_BASE = os_base + 0x00003010 -CURRENT_TASK = os_base + 0x00003000 -TASK_COUNT = os_base + 0x00003004 -TASK_BASE = os_base + 0x00003010 -WIN_STACK = os_base + 0x0000C000 -WIN_POS = os_base + 0x0000C400 -HEAP_BASE = os_base + 0x00800000 +purge BOOT_LO,BOOT + +LFB_BASE = lfb_base + +window_data = os_base + 0x00001000 +CURRENT_TASK = os_base + 0x00003000 +TASK_COUNT = os_base + 0x00003004 +TASK_BASE = os_base + 0x00003010 +TASK_DATA = os_base + 0x00003020 +TASK_EVENT = os_base + 0x00003020 +CDDataBuf = os_base + 0x00005000 +idts = os_base + 0x0000B100 +WIN_STACK = os_base + 0x0000C000 +WIN_POS = os_base + 0x0000C400 +FDD_BUFF = os_base + 0x0000D000 +WIN_TEMP_XY = os_base + 0x0000F300 +KEY_COUNT = os_base + 0x0000F400 +KEY_BUFF = os_base + 0x0000F401 ; 120*2 + 2*2 = 244 bytes, actually 255 bytes +BTN_COUNT = os_base + 0x0000F500 +BTN_BUFF = os_base + 0x0000F501 +BTN_ADDR = os_base + 0x0000FE88 +MEM_AMOUNT = os_base + 0x0000FE8C +SYS_SHUTDOWN = os_base + 0x0000FF00 +TASK_ACTIVATE = os_base + 0x0000FF01 +sys_proc = os_base + 0x0006F000 +SLOT_BASE = os_base + 0x00080000 +VGABasePtr = os_base + 0x000A0000 +UPPER_KERNEL_PAGES = os_base + 0x00400000 +HEAP_BASE = os_base + 0x00800000 include 'system.inc' include 'fdo.inc' -; block and fs include 'blkdev/disk.inc' include 'blkdev/disk_cache.inc' include 'fs/fs_lfn.inc' @@ -67,12 +94,14 @@ include 'core/malloc.inc' include 'core/heap.inc' include 'core/dll.inc' include 'core/taskman.inc' +include 'core/clipboard.inc' include 'core/syscall.inc' include 'video/framebuffer.inc' include 'video/vesa20.inc' include 'video/vga.inc' include 'video/blitter.inc' include 'video/cursors.inc' +include 'sound/playnote.inc' include 'unpacker.inc' include 'gui/window.inc' include 'gui/button.inc' @@ -182,7 +211,6 @@ proc kos_time_to_epoch c uses ebx esi edi ebp, _time ret endp - public kos_init proc kos_init c uses ebx esi edi ebp mov edi, endofcode @@ -203,68 +231,86 @@ proc kos_init c uses ebx esi edi ebp call init_kernel_heap call init_malloc + mov [BOOT.bpp], 32 + mov [BOOT.x_res], 400 + mov [BOOT.y_res], 300 + mov [BOOT.pitch], 400*4 + mov [BOOT.lfb], LFB_BASE + call init_video + stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ (unpack.lc+unpack.lp)))*4 mov [unpack.p], eax + call init_events + mov eax, srv.fd-SRV.fd + mov [srv.fd], eax + mov [srv.bk], eax + mov dword[sysdir_name], 'sys' mov dword[sysdir_path], 'RD/1' mov word[sysdir_path+4], 0 + mov dword[CURRENT_TASK], 2 + mov dword[TASK_COUNT], 2 + mov dword[TASK_BASE], CURRENT_TASK + 2*sizeof.TASKDATA + mov [current_slot], SLOT_BASE + 256*2 + + ;call ramdisk_init + mov ebx, SLOT_BASE + 2*256 - mov [current_slot], ebx stdcall kernel_alloc, 0x2000 mov [ebx+APPDATA.process], eax mov word[cur_dir.path], '/' mov [ebx+APPDATA.cur_dir], cur_dir mov [ebx+APPDATA.wnd_clientbox.left], 0 mov [ebx+APPDATA.wnd_clientbox.top], 0 - mov dword[CURRENT_TASK], 2 - mov dword[TASK_COUNT], 2 - mov dword[TASK_BASE], CURRENT_TASK + 2*sizeof.TASKDATA - mov [_display.x], 0 - mov [_display.y], 0 - mov [_display.width], DISPLAY_WIDTH - mov [_display.lfb_pitch], DISPLAY_WIDTH*4 - mov [_display.height], DISPLAY_HEIGHT - mov [PUTPIXEL], Vesa20_putpixel32 - mov [GETPIXEL], Vesa20_getpixel32 - mov [_display.bytes_per_pixel], 4 - mov [_display.bits_per_pixel], 32 - mov [MOUSE_PICTURE], dword mousepointer - call calculate_fast_getting_offset_for_WinMapAddress - call calculate_fast_getting_offset_for_LFB mov [X_UNDER], 500 mov [Y_UNDER], 500 mov word[MOUSE_X], 40 mov word[MOUSE_Y], 30 - mov eax, [_display.width] - mul [_display.height] - mov [_display.win_map_size], eax - - mov [_display.check_mouse], check_mouse_area_for_putpixel_new - mov [_display.check_m_pixel], check_mouse_area_for_getpixel_new - - stdcall kernel_alloc, eax + stdcall kernel_alloc, [_display.win_map_size] mov [_display.win_map], eax +; set background + movi eax, 1 mov [BgrDrawMode], eax mov [BgrDataWidth], eax mov [BgrDataHeight], eax mov [mem_BACKGROUND], 4 mov [img_background], static_background_data +; set clipboard + xor eax, eax + mov [clipboard_slots], eax + mov [clipboard_write_lock], eax + stdcall kernel_alloc, 4096 + test eax, eax + jnz @f + + dec eax +@@: + mov [clipboard_main_list], eax + + + call set_window_defaults + call init_background + call calculatebackground + call init_display + mov eax, [def_cursor] + mov [SLOT_BASE+APPDATA.cursor+256], eax + mov [SLOT_BASE+APPDATA.cursor+256*2], eax + ; from set_variables xor eax, eax mov [BTN_ADDR], dword BUTTON_INFO ; address of button list mov byte [KEY_COUNT], al ; keyboard buffer mov byte [BTN_COUNT], al ; button buffer - call set_window_defaults - mov [skin_data], 0 -; call load_default_skin + ;call load_default_skin +; call stack_init ret endp @@ -454,20 +500,12 @@ proc map_page _one, _two, _three ret endp -app_tls = 0 -app_code = 0 -app_data = 0 -os_code = 0 -USER_PRIORITY = 0 -MAX_PRIORITY = 1 sysfn_terminate: -scheduler_add_thread: kb_write_wait_ack: sys_msg_board_str: protect_from_terminate: unprotect_from_terminate: -change_task: ReadCDWRetr: WaitUnitReady: prevent_medium_removal: @@ -486,6 +524,11 @@ unlock_application_table: get_pg_addr: free_page: map_memEx: +setup_os_slot: +idle_thread: +irq_eoi: +change_task: +scheduler_add_thread: ret sys_getkey: sys_clock: @@ -514,8 +557,6 @@ sys_outport: syscall_reserveportarea: sys_apm: syscall_threads: -sys_clipboard: -sound_interface: sys_pcibios: sys_IPC: sys_gs: @@ -556,25 +597,26 @@ display_height_standard dd 0 do_not_touch_winmap db 0 window_minimize db 0 sound_flag db 0 -timer_ticks dd 0 -;hotkey_buffer rd 120*2 ; buffer for 120 hotkeys PID_lock_input dd 0x0 process_number dd 0 +timer_ticks dd 0 fpu_owner dd ? +public win_stack_addr as 'kos_win_stack' +win_stack_addr dd WIN_STACK +public win_pos_addr as 'kos_win_pos' +win_pos_addr dd WIN_POS +public lfb_base_addr as 'kos_lfb_base' +lfb_base_addr dd lfb_base + +uglobal ;section '.bss' writeable align 16 ;IncludeUGlobals -; crap DiskNumber db ? ChannelNumber db ? DevErrorCode dd ? CDSectorAddress dd ? CDDataBuf_pointer dd ? -;DRIVE_DATA: rb 0x4000 -;cdpos dd ? -;cd_appl_data dd ? -;current_slot dd ? -;pg_data PG_DATA ide_channel1_mutex MUTEX ide_channel2_mutex MUTEX ide_channel3_mutex MUTEX @@ -584,12 +626,7 @@ ide_channel6_mutex MUTEX ide_channel7_mutex MUTEX ide_channel8_mutex MUTEX os_base rb 0x400000 -public win_stack_addr as 'kos_win_stack' -win_stack_addr dd WIN_STACK -public win_pos_addr as 'kos_win_pos' -win_pos_addr dd WIN_POS -public lfb_base_addr as 'kos_lfb_base' -lfb_base_addr dd lfb_base +BOOT boot_data lfb_base rd MAX_SCREEN_WIDTH*MAX_SCREEN_HEIGHT cur_dir: .encoding rb 1 @@ -601,5 +638,6 @@ SB16Buffer rb 65536 SB16Buffer equ BUTTON_INFO rb 64*1024 BUTTON_INFO equ +endg include 'data32.inc' diff --git a/kolibri.h b/kolibri.h index ba0d859..2ec3784 100644 --- a/kolibri.h +++ b/kolibri.h @@ -16,22 +16,27 @@ typedef struct { } box_t; typedef struct { - uint32_t cpu_usage; // +0 - uint16_t window_stack_position; // +4 - uint16_t window_stack_value; // +6 - uint16_t pad; // +8 - char process_name[12]; // +10 - uint32_t memory_start; // +22 - uint32_t used_memory; // +26 - uint32_t pid; // +30 - box_t box; // +34 - uint16_t slot_state; // +50 - uint16_t pad2; // +52 - box_t client_box; // +54 - uint8_t wnd_state; // +70 + uint32_t cpu_usage; + uint16_t window_stack_position; + uint16_t window_stack_value; + uint16_t pad; + char process_name[12]; + uint32_t memory_start; + uint32_t used_memory; + uint32_t pid; + box_t box; + uint16_t slot_state; + uint16_t pad2; + box_t client_box; + uint8_t wnd_state; uint8_t pad3[1024-71]; } __attribute__((packed)) process_information_t; +typedef struct { + uint32_t frame, grab, work_3d_dark, work_3d_light, grab_text, work, + work_button, work_button_text, work_text, work_graph; +} system_colors_t; + enum { DEFAULT, CP866, diff --git a/syscalls.h b/syscalls.h index 9d04d61..1b9346a 100644 --- a/syscalls.h +++ b/syscalls.h @@ -155,6 +155,93 @@ static inline void umka_sys_display_number(int is_pointer, int base, : "memory"); } +static inline void umka_sys_set_button_style(int style) { + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(48), + "b"(1), + "c"(style) + : "memory"); +} + +static inline void umka_sys_set_window_colors(void *colors) { + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(48), + "b"(2), + "c"(colors), + "d"(40) + : "memory"); +} + +static inline void umka_sys_get_window_colors(void *colors) { + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(48), + "b"(3), + "c"(colors), + "d"(40) + : "memory"); +} + +static inline uint32_t umka_sys_get_skin_height() { + uint32_t skin_height; + __asm__ __inline__ __volatile__ ( + "call i40" + : "=a"(skin_height) + : "a"(48), + "b"(4) + : "memory"); + return skin_height; +} + +static inline void umka_sys_get_screen_area(rect_t *wa) { + uint32_t eax, ebx; + __asm__ __inline__ __volatile__ ( + "call i40" + : "=a"(eax), + "=b"(ebx) + : "a"(48), + "b"(5) + : "memory"); + wa->left = eax >> 16; + wa->right = eax & 0xffffu; + wa->top = ebx >> 16; + wa->bottom = ebx & 0xffffu; +} + +static inline void umka_sys_set_screen_area(rect_t *wa) { + uint32_t ecx, edx; + ecx = (wa->left << 16) + wa->right; + edx = (wa->top << 16) + wa->bottom; + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(48), + "b"(6), + "c"(ecx), + "d"(edx) + : "memory"); +} + +static inline void umka_sys_get_skin_margins(rect_t *wa) { + uint32_t eax, ebx; + __asm__ __inline__ __volatile__ ( + "call i40" + : "=a"(eax), + "=b"(ebx) + : "a"(48), + "b"(7) + : "memory"); + wa->left = eax >> 16; + wa->right = eax & 0xffffu; + wa->top = ebx >> 16; + wa->bottom = ebx & 0xffffu; +} + static inline int32_t umka_sys_set_skin(const char *path) { int32_t status; __asm__ __inline__ __volatile__ ( @@ -167,7 +254,7 @@ static inline int32_t umka_sys_set_skin(const char *path) { return status; } -static inline int umka_sys_get_smoothing() { +static inline int umka_sys_get_font_smoothing() { int type; __asm__ __inline__ __volatile__ ( "call i40" @@ -178,7 +265,7 @@ static inline int umka_sys_get_smoothing() { return type; } -static inline void umka_sys_set_smoothing(int type) { +static inline void umka_sys_set_font_smoothing(int type) { __asm__ __inline__ __volatile__ ( "call i40" : @@ -188,6 +275,27 @@ static inline void umka_sys_set_smoothing(int type) { : "memory"); } +static inline int umka_sys_get_font_size() { + uint32_t size; + __asm__ __inline__ __volatile__ ( + "call i40" + : "=a" (size) + : "a"(48), + "b"(11) + : "memory"); + return size; +} + +static inline void umka_sys_set_font_size(uint32_t size) { + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(48), + "b"(12), + "c"(size) + : "memory"); +} + static inline void umka_sys_put_image_palette(void *image, size_t xsize, size_t ysize, size_t x, size_t y, diff --git a/test/016_#f01_draw.t b/test/016_#f01_draw.t index 9a52eec..d5186e9 100644 --- a/test/016_#f01_draw.t +++ b/test/016_#f01_draw.t @@ -10,7 +10,10 @@ draw_rect 60 20 30 20 0x00ff00 put_image chess_image.rgb 8 8 5 15 put_image_palette chess_image.rgb 12 12 5 30 9 0 write_text 10 70 0xffff00 hello 0 0 0 0 0 5 0 +set_button_style 0 button 55 40 5 20 0xc0ffee 0xffffff 1 0 +set_button_style 1 +button 100 40 5 20 0xc1ffee 0xffffff 1 0 display_number 0 10 4 0 0 1234 5 45 0xffff00 1 1 0 0 0x0000ff blit_bitmap chess_image.rgba 20 35 8 8 0 0 8 8 0 0 0 1 32 window_redraw 2 @@ -21,6 +24,9 @@ get_font_smoothing set_font_smoothing 0 get_font_smoothing +get_window_colors +set_window_colors 0 0 0 0 0 0 0 0 0 0 + window_redraw 1 draw_window 0 300 0 200 0x000088 1 1 1 0 1 4 hello set_pixel 0 0 0x0000ff @@ -34,6 +40,15 @@ dump_win_stack 5 dump_win_pos 5 process_info -1 +get_skin_height +get_screen_area +set_screen_area 0 20 350 250 +get_screen_area +get_skin_margins + +get_font_size +set_font_size 16 +get_font_size scrot umka.rgba