From 3e6513d51dc6304e9767db02e03ff9219b8375ff Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Fri, 9 Mar 2012 08:20:02 +0000 Subject: [PATCH] enumerate CPU's and start AP. git-svn-id: svn://kolibrios.org@2439 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/Kolibri-acpi/const.inc | 1 + kernel/branches/Kolibri-acpi/core/apic.inc | 211 +++--- kernel/branches/Kolibri-acpi/gui/font.inc | 44 +- kernel/branches/Kolibri-acpi/gui/skincode.inc | 176 +++-- kernel/branches/Kolibri-acpi/gui/window.inc | 676 +++++++++++------- kernel/branches/Kolibri-acpi/init.inc | 54 +- kernel/branches/Kolibri-acpi/kernel.asm | 98 +-- kernel/branches/Kolibri-acpi/memmap.inc | 2 +- .../branches/Kolibri-acpi/video/cursors.inc | 13 + kernel/branches/Kolibri-acpi/video/vesa20.inc | 294 +++++++- kernel/branches/Kolibri-acpi/video/vga.inc | 193 +++-- 11 files changed, 1187 insertions(+), 575 deletions(-) diff --git a/kernel/branches/Kolibri-acpi/const.inc b/kernel/branches/Kolibri-acpi/const.inc index 42c761b8db..a874f0eb85 100644 --- a/kernel/branches/Kolibri-acpi/const.inc +++ b/kernel/branches/Kolibri-acpi/const.inc @@ -189,6 +189,7 @@ TASK_BASE equ (OS_BASE+0x0003010) TASK_DATA equ (OS_BASE+0x0003020) TASK_EVENT equ (OS_BASE+0x0003020) +d_width_calc_area equ (OS_BASE+0x0005000) mouseunder equ (OS_BASE+0x0006900) CDDataBuf equ (OS_BASE+0x0007000) FLOPPY_BUFF equ (OS_BASE+0x0008000) diff --git a/kernel/branches/Kolibri-acpi/core/apic.inc b/kernel/branches/Kolibri-acpi/core/apic.inc index 5be484b923..a24ec34605 100644 --- a/kernel/branches/Kolibri-acpi/core/apic.inc +++ b/kernel/branches/Kolibri-acpi/core/apic.inc @@ -41,7 +41,8 @@ IOAPIC_VER equ 0x1 IOAPIC_ARB equ 0x2 IOAPIC_REDTBL equ 0x10 -IPI_INIT equ (0x6 shl 8) +IPI_INIT equ (0x5 shl 8) +IPI_START equ (0x6 shl 8) IPI_LEVEL_ASSERT equ (0x1 shl 14) SHORTHAND_ALL_EXCL equ (0x3 shl 18) @@ -72,11 +73,11 @@ APIC_init: stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SW mov [IOAPIC_base], eax - mov eax, IOAPIC_VER + mov eax, IOAPIC_VER call IOAPIC_read shr eax, 16 inc al - movzx eax, al + movzx eax, al cmp al, IRQ_RESERVED jbe @f @@ -129,15 +130,9 @@ APIC_init: ;=========================================================== align 4 LAPIC_init: - ; Check MSR support - ;.... - ; Get LAPIC base address - ;mov ecx, 0x1b - ;rdmsr ; it may be replaced to - ;and ax, 0xf000 ; mov eax, 0xfee00000 - mov [acpi_lapic_base], 0xfee00000 - ; xchg bx, bx + cmp [LAPIC_BASE], 0 + jne .done stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW mov [LAPIC_BASE], eax @@ -211,32 +206,8 @@ LAPIC_init: ; Start (every 0.01 sec) ; mov dword[esi + APIC_LVT_timer], 0x30020; periodic int 0x20 ; mov dword[esi + APIC_timer_init], eax - xchg bx, bx - -; mov al, 0x0F -; out 0x70, al -; mov al, 0x0A -; out 0x71, al - -; mov [OS_BASE+0x469], word (__ap_start_16) shr 4 -; mov [OS_BASE+0x469], word 0 - - mov [esi+APIC_ICRH], dword 0 - mov [esi+APIC_ICRL], dword 0xc4500 - - mov ecx, 1000 -@@: - loop @B - - mov [esi+APIC_ICRH], dword 0 - mov [esi+APIC_ICRL], dword 0xC4600+((0x10000+__ap_start_16) shr 12) -; mov [esi+APIC_ICRL], dword 0xC4612 - -; mov [esi+APIC_ICRH], dword 0 -; mov [esi+APIC_ICRL], dword CMD_IPI_INIT+IPI_LEVEL_ASSERT+16 - - +.done: ret ;=========================================================== @@ -245,11 +216,11 @@ align 4 IOAPIC_read: ; in : EAX - IOAPIC register ; out: EAX - readed value - push esi - mov esi, [IOAPIC_base] - mov [esi], eax - mov eax, [esi + 0x10] - pop esi + push esi + mov esi, [IOAPIC_base] + mov [esi], eax + mov eax, [esi + 0x10] + pop esi ret align 4 @@ -257,11 +228,11 @@ IOAPIC_write: ; in : EAX - IOAPIC register ; EBX - value ; out: none - push esi - mov esi, [IOAPIC_base] - mov [esi], eax - mov [esi + 0x10], ebx - pop esi + push esi + mov esi, [IOAPIC_base] + mov [esi], eax + mov [esi + 0x10], ebx + pop esi ret ;=========================================================== ; Remap all IRQ to 0x20+ Vectors @@ -287,7 +258,7 @@ PIC_init: out 0x21, al out 0xA1, al - call IRQ_mask_all + call IRQ_mask_all ; mov dword[irq_type_to_set], IRQ_TYPE_PIC ret @@ -306,8 +277,8 @@ PIT_init: ; ----------------------------------------- align 4 unmask_timer: - cmp [irq_mode], IRQ_APIC - je @f + cmp [irq_mode], IRQ_APIC + je @f stdcall enable_irq, 0 ret @@ -326,36 +297,36 @@ unmask_timer: ; ret ; use LAPIC timer - mov esi, [LAPIC_BASE] - mov eax, [esi + APIC_LVT_timer] - and eax, 0xfffeffff - mov [esi + APIC_LVT_timer], eax + mov esi, [LAPIC_BASE] + mov eax, [esi + APIC_LVT_timer] + and eax, 0xfffeffff + mov [esi + APIC_LVT_timer], eax ret ; ----------------------------------------- ; Disable all IRQ align 4 IRQ_mask_all: - cmp [irq_mode], IRQ_APIC - je .APIC + cmp [irq_mode], IRQ_APIC + je .APIC - mov al, 0xFF - out 0x21, al - out 0xA1, al + mov al, 0xFF + out 0x21, al + out 0xA1, al mov ecx, 0x1000 ret .APIC: - mov ecx, [IRQ_COUNT] - mov eax, 0x10 + mov ecx, [IRQ_COUNT] + mov eax, 0x10 @@: - mov ebx, eax - call IOAPIC_read + mov ebx, eax + call IOAPIC_read or eax, 0x10000; bit 16 - xchg eax, ebx - call IOAPIC_write - inc eax - inc eax - loop @b + xchg eax, ebx + call IOAPIC_write + inc eax + inc eax + loop @b ret ; ----------------------------------------- @@ -363,19 +334,19 @@ IRQ_mask_all: ; cl - IRQ number align 4 irq_eoi: ; __fastcall - cmp [irq_mode], IRQ_APIC - je .APIC + cmp [irq_mode], IRQ_APIC + je .APIC - cmp cl, 8 - mov al, 0x20 - jb @f - out 0xa0, al + cmp cl, 8 + mov al, 0x20 + jb @f + out 0xa0, al @@: - out 0x20, al + out 0x20, al ret .APIC: - mov eax, [LAPIC_BASE] + mov eax, [LAPIC_BASE] mov dword [eax + APIC_EOI], 0; EOI ret @@ -383,71 +354,99 @@ irq_eoi: ; __fastcall ; from dll.inc align 4 proc enable_irq stdcall, irq_line:dword - mov ebx, [irq_line] - cmp [irq_mode], IRQ_APIC - je .APIC + mov ebx, [irq_line] + cmp [irq_mode], IRQ_APIC + je .APIC - mov edx, 0x21 - cmp ebx, 8 - jb @F + mov edx, 0x21 + cmp ebx, 8 + jb @F - mov edx, 0xA1 + mov edx, 0xA1 sub ebx, 8 @@: in al, dx - btr eax, ebx - out dx, al + btr eax, ebx + out dx, al ret .APIC: - shl ebx, 1 - add ebx, 0x10 - mov eax, ebx - call IOAPIC_read + shl ebx, 1 + add ebx, 0x10 + mov eax, ebx + call IOAPIC_read and eax, 0xfffeffff; bit 16 - xchg eax, ebx - call IOAPIC_write + xchg eax, ebx + call IOAPIC_write ret endp align 4 pci_irq_fixup: - push ebp + push ebp - mov esi, [acpi_dev_data] - mov ebx, [acpi_dev_size] + mov esi, [acpi_dev_data] + mov ebx, [acpi_dev_size] - lea edi, [esi+ebx] + lea edi, [esi+ebx] .iterate: - cmp esi, edi - jae .done + cmp esi, edi + jae .done - mov eax, [esi] + mov eax, [esi] - cmp eax, -1 - je .done + cmp eax, -1 + je .done - movzx ebx, al - movzx ebp, ah + movzx ebx, al + movzx ebp, ah stdcall pci_read32, ebp, ebx, 0 - cmp eax, [esi+4] - jne .skip + cmp eax, [esi+4] + jne .skip - mov eax, [esi+8] + mov eax, [esi+8] stdcall pci_write8, ebp, ebx, 0x3C, eax .skip: - add esi, 16 - jmp .iterate + add esi, 16 + jmp .iterate .done: .fail: pop ebp ret +align 4 +start_ap: +;eax= cpu id + +; xchg bx, bx + + test eax, eax ;do not start self + jz .exit + + cmp eax, [cpu_count] + ja .exit + + mov eax, [smpt+eax*4] + shl eax, 24 + + mov [esi+APIC_ICRH], eax + mov [esi+APIC_ICRL], dword (IPI_INIT+IPI_LEVEL_ASSERT) + + mov ecx, 10000 +@@: + loop @B + +CMD_IPI_START equ (IPI_START+IPI_LEVEL_ASSERT)+((0x10000+__ap_start_16) shr 12) + + mov [esi+APIC_ICRH], eax + mov [esi+APIC_ICRL], dword CMD_IPI_START +.exit: + ret diff --git a/kernel/branches/Kolibri-acpi/gui/font.inc b/kernel/branches/Kolibri-acpi/gui/font.inc index 0a23a21ad1..48e3c91768 100644 --- a/kernel/branches/Kolibri-acpi/gui/font.inc +++ b/kernel/branches/Kolibri-acpi/gui/font.inc @@ -7,15 +7,14 @@ $Revision$ -; // Alver 22.06.2008 // { +;------------------------------------------------------------------------------ align 4 dtext_asciiz_esi: ; for skins title out push eax xor eax, eax inc eax jmp dtext.1 -; } \\ Alver \\ - +;------------------------------------------------------------------------------ align 4 dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) ; ebx x & y @@ -26,12 +25,11 @@ dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) ; B = 1 <=> fill background with color eax ; edx start of text ; edi 1 force - -; // Alver 22.06.2008 // { push eax xor eax, eax +;-------------------------------------- +align 4 .1: -; } \\ Alver \\ pushad movsx eax, bx ; eax=y sar ebx, 16 ; ebx=x @@ -39,21 +37,26 @@ dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) cmp esi, 255 jb .loop mov esi, 255 +;-------------------------------------- +align 4 .loop: test ecx, ecx js .test_asciiz dec esi js .end jmp @f +;-------------------------------------- +align 4 .test_asciiz: cmp byte [edx], 0 jz .end -; // Alver 22.06.2008 // { + cmp byte [esp+28], 1 jne @f dec esi js .end -; } \\ Alver \\ +;-------------------------------------- +align 4 @@: inc edx pushad @@ -62,9 +65,13 @@ dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) jnz .font2 mov esi, 9 lea ebp, [FONT_I+8*edx+edx] +;-------------------------------------- +align 4 .symloop1: mov dl, byte [ebp] or dl, 1 shl 6 +;-------------------------------------- +align 4 .pixloop1: shr dl, 1 jz .pixloop1end @@ -72,6 +79,8 @@ dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area call [putpixel] jmp .pixloop1cont +;-------------------------------------- +align 4 .nopix: test ecx, 0x40000000 jz .pixloop1cont @@ -80,9 +89,13 @@ dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area call [putpixel] pop ecx +;-------------------------------------- +align 4 .pixloop1cont: inc eax jmp .pixloop1 +;-------------------------------------- +align 4 .pixloop1end: sub eax, 6 inc ebx @@ -92,20 +105,28 @@ dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) popad add eax, 6 jmp .loop +;-------------------------------------- +align 4 .font2: add edx, edx lea ebp, [FONT_II+4*edx+edx+1] push 9 movzx esi, byte [ebp-1] +;-------------------------------------- +align 4 .symloop2: mov dl, byte [ebp] push esi +;-------------------------------------- +align 4 .pixloop2: shr dl, 1 jnc .nopix2 and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area call [putpixel] jmp .pixloop2cont +;-------------------------------------- +align 4 .nopix2: test ecx, 0x40000000 jz .pixloop2cont @@ -114,6 +135,8 @@ dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area call [putpixel] pop ecx +;-------------------------------------- +align 4 .pixloop2cont: inc eax dec esi @@ -128,7 +151,10 @@ dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) add dword [esp+28], esi popad jmp .loop +;-------------------------------------- +align 4 .end: popad - pop eax ; << // Alver 22.06.2008 // << + pop eax ret +;------------------------------------------------------------------------------ diff --git a/kernel/branches/Kolibri-acpi/gui/skincode.inc b/kernel/branches/Kolibri-acpi/gui/skincode.inc index 8b71afb2fb..4128a1a4b7 100644 --- a/kernel/branches/Kolibri-acpi/gui/skincode.inc +++ b/kernel/branches/Kolibri-acpi/gui/skincode.inc @@ -11,7 +11,8 @@ $Revision$ include "skindata.inc" ;skin_data = 0x00778000 - +;------------------------------------------------------------------------------ +align 4 read_skin_file: stdcall load_file, ebx test eax, eax @@ -21,6 +22,8 @@ read_skin_file: cmp ebx, 32*1024 jb @f mov ebx, 32*1024 +;-------------------------------------- +align 4 @@: lea ecx, [ebx+3] shr ecx, 2 @@ -32,16 +35,20 @@ read_skin_file: call parse_skin_data xor eax, eax ret +;-------------------------------------- +align 4 .notfound: xor eax, eax inc eax ret +;-------------------------------------- +align 4 .noskin: stdcall kernel_free, eax push 2 pop eax ret - +;------------------------------------------------------------------------------ struct SKIN_HEADER ident dd ? version dd ? @@ -81,13 +88,15 @@ struct SKIN_BITMAPS type dw ? data dd ? ends - +;------------------------------------------------------------------------------ +align 4 load_default_skin: mov [_skinh], 22 mov ebx, _skin_file_default call read_skin_file ret - +;------------------------------------------------------------------------------ +align 4 parse_skin_data: mov ebp, skin_data cmp [ebp+SKIN_HEADER.ident], 'SKIN' @@ -127,7 +136,9 @@ parse_skin_data: mov ebx, [ebp+SKIN_HEADER.bitmaps] add ebx, skin_data - .lp1: +;-------------------------------------- +align 4 +.lp1: cmp dword[ebx], 0 je .end_bitmaps movzx eax, [ebx+SKIN_BITMAPS.kind] @@ -139,9 +150,13 @@ parse_skin_data: or ecx, ecx jnz @f mov edx, skin_inactive.left.data - @@: +;-------------------------------------- +align 4 +@@: jmp .next_bitmap - .not_left: +;-------------------------------------- +align 4 +.not_left: dec eax jnz .not_oper mov esi, [ebx+SKIN_BITMAPS.data] @@ -152,9 +167,13 @@ parse_skin_data: or ecx, ecx jnz @f mov edx, skin_inactive.oper.data - @@: +;-------------------------------------- +align 4 +@@: jmp .next_bitmap - .not_oper: +;-------------------------------------- +align 4 +.not_oper: dec eax jnz .not_base mov eax, [skin_active.left.width] @@ -163,12 +182,18 @@ parse_skin_data: jnz @f mov eax, [skin_inactive.left.width] mov edx, skin_inactive.base.data - @@: +;-------------------------------------- +align 4 +@@: jmp .next_bitmap - .not_base: +;-------------------------------------- +align 4 +.not_base: add ebx, 8 jmp .lp1 - .next_bitmap: +;-------------------------------------- +align 4 +.next_bitmap: mov ecx, [ebx+SKIN_BITMAPS.data] add ecx, skin_data mov [edx+4], eax @@ -178,11 +203,14 @@ parse_skin_data: mov [edx+0], ecx add ebx, 8 jmp .lp1 - .end_bitmaps: - +;-------------------------------------- +align 4 +.end_bitmaps: mov ebx, [ebp+SKIN_HEADER.buttons] add ebx, skin_data - .lp2: +;-------------------------------------- +align 4 +.lp2: cmp dword[ebx], 0 je .end_buttons mov eax, [ebx+SKIN_BUTTONS.type] @@ -190,15 +218,21 @@ parse_skin_data: jnz .not_close mov edx, skin_btn_close jmp .next_button - .not_close: +;-------------------------------------- +align 4 +.not_close: dec eax jnz .not_minimize mov edx, skin_btn_minimize jmp .next_button - .not_minimize: +;-------------------------------------- +align 4 +.not_minimize: add ebx, 12 jmp .lp2 - .next_button: +;-------------------------------------- +align 4 +.next_button: movsx eax, [ebx+SKIN_BUTTONS.left] mov [edx+SKIN_BUTTON.left], eax movsx eax, [ebx+SKIN_BUTTONS.top] @@ -209,26 +243,22 @@ parse_skin_data: mov [edx+SKIN_BUTTON.height], eax add ebx, 12 jmp .lp2 - .end_buttons: - - .exit: +;-------------------------------------- +align 4 +.end_buttons: +.exit: ret - -sys_putimage_with_check: - or ebx, ebx - jz @f - call sys_putimage.forced - @@: - ret - +;------------------------------------------------------------------------------ +align 4 drawwindow_IV_caption: mov ebp, skin_active or al, al jnz @f mov ebp, skin_inactive - @@: - +;-------------------------------------- +align 4 +@@: mov esi, [esp+4] mov eax, [esi+WDATA.box.width] ; window width mov edx, [ebp+SKIN_DATA.left.left] @@ -238,8 +268,12 @@ drawwindow_IV_caption: add ecx, [_skinh] mov ebx, [ebp+SKIN_DATA.left.data] - call sys_putimage_with_check - + or ebx, ebx + jz @f + call sys_putimage.forced +;-------------------------------------- +align 4 +@@: mov esi, [esp+4] mov eax, [esi+WDATA.box.width] sub eax, [ebp+SKIN_DATA.left.width] @@ -260,18 +294,28 @@ drawwindow_IV_caption: mov edx, [ebp+SKIN_DATA.base.left] sub edx, [ebp+SKIN_DATA.base.width] shl edx, 16 - .baseskinloop: +;-------------------------------------- +align 4 +.baseskinloop: shr edx, 16 add edx, [ebp+SKIN_DATA.base.width] shl edx, 16 push eax ebx ecx edx - call sys_putimage_with_check + + or ebx, ebx + jz @f + call sys_putimage.forced +;-------------------------------------- +align 4 +@@: pop edx ecx ebx eax dec eax jnz .baseskinloop - .non_base: +;-------------------------------------- +align 4 +.non_base: mov esi, [esp+4] mov edx, [esi+WDATA.box.width] @@ -283,16 +327,18 @@ drawwindow_IV_caption: mov ecx, [ebp+SKIN_DATA.oper.width] shl ecx, 16 add ecx, [_skinh] - call sys_putimage_with_check + or ebx, ebx + jz @f + call sys_putimage.forced +;-------------------------------------- +align 4 +@@: ret - -;//mike.dld, 2006-08-02 ] - - +;------------------------------------------------------------------------------ +align 4 drawwindow_IV: ;param1 - aw_yes - pusha push edx @@ -303,8 +349,9 @@ drawwindow_IV: cmp byte [esp+32+4+4], 0 jne @f mov ebp, skin_inactive - @@: - +;-------------------------------------- +align 4 +@@: mov eax, [edi+WDATA.box.left] shl eax, 16 mov ax, word [edi+WDATA.box.left] @@ -313,9 +360,6 @@ drawwindow_IV: shl ebx, 16 mov bx, word [edi+WDATA.box.top] add bx, word [edi+WDATA.box.height] -; mov esi,[edi+24] -; shr esi,1 -; and esi,0x007f7f7f mov esi, [ebp+SKIN_DATA.colors.outer] or esi, 1 shl 25 ; 0x02000000 used for draw_rectangle without top line ror ebx, 16 @@ -324,7 +368,9 @@ drawwindow_IV: rol ebx, 16 call draw_rectangle mov ecx, 3 - _dw3l: +;-------------------------------------- +align 4 +_dw3l: add eax, 1*65536-1 add ebx, 0*65536-1 test ax, ax @@ -357,13 +403,14 @@ drawwindow_IV: mov edi, [common_colours+4]; standard grab color call [drawbar] jmp draw_clientbar - @@: - +;-------------------------------------- +align 4 +@@: mov al, [esp+32+4+4] call drawwindow_IV_caption - - draw_clientbar: - +;-------------------------------------- +align 4 +draw_clientbar: mov esi, [esp] mov edx, [esi+WDATA.box.top] ; WORK AREA @@ -382,11 +429,11 @@ drawwindow_IV: test edi, 0x40000000 jnz _noinside2 call [drawbar] - _noinside2: - +;-------------------------------------- +align 4 +_noinside2: cmp dword[skin_data], 'SKIN' jne no_skin_add_button - ;* close button mov edi, [BTN_ADDR] movzx eax, word [edi] @@ -411,7 +458,9 @@ drawwindow_IV: mov ebx, [esp] mov ebx, [ebx+WDATA.box.width] inc ebx - _bCx_at_right: +;-------------------------------------- +align 4 +_bCx_at_right: add ebx, [skin_btn_close.left] mov [eax], bx add eax, 2 ; x size @@ -425,7 +474,6 @@ drawwindow_IV: mov ebx, [skin_btn_close.height] dec ebx mov [eax], bx - ;* minimize button mov edi, [BTN_ADDR] movzx eax, word [edi] @@ -450,7 +498,9 @@ drawwindow_IV: mov ebx, [esp] mov ebx, [ebx+WDATA.box.width] inc ebx - _bMx_at_right: +;-------------------------------------- +align 4 +_bMx_at_right: add ebx, [skin_btn_minimize.left] mov [eax], bx add eax, 2 ; x size @@ -464,10 +514,10 @@ drawwindow_IV: mov ebx, [skin_btn_minimize.height] dec ebx mov [eax], bx - - no_skin_add_button: +;-------------------------------------- +align 4 +no_skin_add_button: pop edi popa - ret 4 - +;------------------------------------------------------------------------------ diff --git a/kernel/branches/Kolibri-acpi/gui/window.inc b/kernel/branches/Kolibri-acpi/gui/window.inc index 4265a3bf30..270eaf58e1 100644 --- a/kernel/branches/Kolibri-acpi/gui/window.inc +++ b/kernel/branches/Kolibri-acpi/gui/window.inc @@ -52,17 +52,19 @@ syscall_draw_window: ;///// system function 0 ///////////////////////////////// ; type I - original style call drawwindow_I jmp window._.draw_window_caption.2 - - @@: +;-------------------------------------- +align 4 +@@: dec al jnz @f ; type II - only reserve area, no draw - call sys_window_mouse +; call sys_window_mouse call [draw_pointer] jmp .exit - - @@: +;-------------------------------------- +align 4 +@@: dec al jnz @f @@ -71,7 +73,9 @@ syscall_draw_window: ;///// system function 0 ///////////////////////////////// jmp window._.draw_window_caption.2 ; type IV & V - skinned window (resizable & not) - @@: +;-------------------------------------- +align 4 +@@: mov eax, [TASK_COUNT] movzx eax, word[WIN_POS + eax * 2] cmp eax, [CURRENT_TASK] @@ -80,10 +84,11 @@ syscall_draw_window: ;///// system function 0 ///////////////////////////////// push eax call drawwindow_IV jmp window._.draw_window_caption.2 - - .exit: +;-------------------------------------- +align 4 +.exit: ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ syscall_display_settings: ;///// system function 48 /////////////////////////// @@ -132,10 +137,11 @@ syscall_display_settings: ;///// system function 48 /////////////////////////// cmp ebx, .sizeof.ftable / 4 ja @f jmp [.ftable + ebx * 4] - @@: +;-------------------------------------- +align 4 +@@: ret - - +;------------------------------------------------------------------------------ align 4 syscall_display_settings.00: xor eax, eax @@ -145,10 +151,11 @@ syscall_display_settings.00: mov [windowtypechanged], eax jmp syscall_display_settings._.redraw_whole_screen - - .exit: +;-------------------------------------- +align 4 +.exit: ret - +;------------------------------------------------------------------------------ align 4 syscall_display_settings.01: and ecx, 1 @@ -156,10 +163,11 @@ syscall_display_settings.01: je .exit mov [buttontype], ecx mov [windowtypechanged], ebx - +;-------------------------------------- +align 4 .exit: ret - +;------------------------------------------------------------------------------ align 4 syscall_display_settings.02: dec ebx @@ -170,7 +178,7 @@ syscall_display_settings.02: rep movsb mov [windowtypechanged], ebx ret - +;------------------------------------------------------------------------------ align 4 syscall_display_settings.03: mov edi, ecx @@ -179,13 +187,13 @@ syscall_display_settings.03: mov ecx, edx rep movsb ret - +;------------------------------------------------------------------------------ align 4 syscall_display_settings.04: mov eax, [_skinh] mov [esp + 32], eax ret - +;------------------------------------------------------------------------------ align 4 syscall_display_settings.05: mov eax, [screen_workarea.left - 2] @@ -195,7 +203,7 @@ syscall_display_settings.05: mov ax, word[screen_workarea.bottom] mov [esp + 20], eax ret - +;------------------------------------------------------------------------------ align 4 syscall_display_settings.06: xor esi, esi @@ -210,15 +218,20 @@ syscall_display_settings.06: or eax, eax jge @f xor eax, eax - @@: +;-------------------------------------- +align 4 +@@: mov [screen_workarea.left], eax cmp ebx, edi jle @f mov ebx, edi - @@: +;-------------------------------------- +align 4 +@@: mov [screen_workarea.right], ebx - - .check_horizontal: +;-------------------------------------- +align 4 +.check_horizontal: mov edi, [Screen_Max_Y] mov eax, edx movsx ebx, ax @@ -229,24 +242,30 @@ syscall_display_settings.06: or eax, eax jge @f xor eax, eax - @@: +;-------------------------------------- +align 4 +@@: mov [screen_workarea.top], eax cmp ebx, edi jle @f mov ebx, edi - @@: +;-------------------------------------- +align 4 +@@: mov [screen_workarea.bottom], ebx - - .check_if_redraw_needed: +;-------------------------------------- +align 4 +.check_if_redraw_needed: or esi, esi jz .exit call repos_windows jmp syscall_display_settings._.calculate_whole_screen - - .exit: +;-------------------------------------- +align 4 +.exit: ret - +;------------------------------------------------------------------------------ align 4 syscall_display_settings.07: mov eax, [_skinmargins + 0] @@ -254,7 +273,7 @@ syscall_display_settings.07: mov eax, [_skinmargins + 4] mov [esp + 20], eax ret - +;------------------------------------------------------------------------------ align 4 syscall_display_settings.08: mov ebx, ecx @@ -265,17 +284,20 @@ syscall_display_settings.08: call syscall_display_settings._.calculate_whole_screen jmp syscall_display_settings._.redraw_whole_screen - - .exit: +;-------------------------------------- +align 4 +.exit: ret - +;------------------------------------------------------------------------------ +align 4 syscall_display_settings._.calculate_whole_screen: xor eax, eax xor ebx, ebx mov ecx, [Screen_Max_X] mov edx, [Screen_Max_Y] jmp calculatescreen - +;------------------------------------------------------------------------------ +align 4 syscall_display_settings._.redraw_whole_screen: xor eax, eax mov [draw_limits.left], eax @@ -286,7 +308,7 @@ syscall_display_settings._.redraw_whole_screen: mov [draw_limits.bottom], eax mov eax, window_data jmp redrawscreen - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ syscall_set_window_shape: ;///// system function 50 /////////////////////////// @@ -304,15 +326,17 @@ syscall_set_window_shape: ;///// system function 50 /////////////////////////// test ebx, ebx jne .shape_scale mov [edi + APPDATA.wnd_shape], ecx - - .shape_scale: +;-------------------------------------- +align 4 +.shape_scale: dec ebx jnz .exit mov [edi + APPDATA.wnd_shape_scale], ecx - - .exit: +;-------------------------------------- +align 4 +.exit: ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ syscall_move_window: ;///// system function 67 //////////////////////////////// @@ -332,20 +356,27 @@ syscall_move_window: ;///// system function 67 //////////////////////////////// cmp ebx, -1 jne @f mov ebx, [edi + WDATA.box.left] - @@: +;-------------------------------------- +align 4 +@@: cmp ecx, -1 jne @f mov ecx, [edi + WDATA.box.top] - @@: +;-------------------------------------- +align 4 +@@: cmp edx, -1 jne @f mov edx, [edi + WDATA.box.width] - @@: +;-------------------------------------- +align 4 +@@: cmp esi, -1 jne @f mov esi, [edi + WDATA.box.height] - - @@: +;-------------------------------------- +align 4 +@@: push esi edx ecx ebx mov eax, esp mov bl, [edi + WDATA.fl_wstate] @@ -359,10 +390,11 @@ syscall_move_window: ;///// system function 67 //////////////////////////////// ; NOTE: do we really need this? to be reworked ; call [draw_pointer] - - .exit: +;-------------------------------------- +align 4 +.exit: ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ syscall_window_settings: ;///// system function 71 ///////////////////////////// @@ -391,12 +423,13 @@ syscall_window_settings: ;///// system function 71 ///////////////////////////// ; jnz .exit_fail ; not implemented yet - - .exit_fail: +;-------------------------------------- +align 4 +.exit_fail: xor eax, eax inc eax ; eax = 1 (fail) ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ set_window_defaults: ;///////////////////////////////////////////////////////// @@ -407,7 +440,9 @@ set_window_defaults: ;///////////////////////////////////////////////////////// push eax ecx xor eax, eax mov ecx, WIN_STACK - @@: +;-------------------------------------- +align 4 +@@: inc eax add ecx, 2 ; process no @@ -418,7 +453,7 @@ set_window_defaults: ;///////////////////////////////////////////////////////// jne @b pop ecx eax ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ calculatescreen: ;///////////////////////////////////////////////////////////// @@ -445,8 +480,9 @@ calculatescreen: ;///////////////////////////////////////////////////////////// jbe .exit push edx ecx ebx eax - - .next_window: +;-------------------------------------- +align 4 +.next_window: movzx edi, word[WIN_POS + esi * 2] shl edi, 5 @@ -475,39 +511,48 @@ calculatescreen: ;///////////////////////////////////////////////////////////// cmp eax, [esp + RECT.left] jae @f mov eax, [esp + RECT.left] - @@: +;-------------------------------------- +align 4 +@@: cmp ebx, [esp + RECT.top] jae @f mov ebx, [esp + RECT.top] - @@: +;-------------------------------------- +align 4 +@@: cmp ecx, [esp + RECT.right] jbe @f mov ecx, [esp + RECT.right] - @@: +;-------------------------------------- +align 4 +@@: cmp edx, [esp + RECT.bottom] jbe @f mov edx, [esp + RECT.bottom] - - @@: +;-------------------------------------- +align 4 +@@: push esi movzx esi, word[WIN_POS + esi * 2] call window._.set_screen pop esi - - .skip_window: +;-------------------------------------- +align 4 +.skip_window: inc esi dec ebp jnz .next_window pop eax ebx ecx edx - - .exit: +;-------------------------------------- +align 4 +.exit: pop ebp inc [_display.mask_seqno] popfd pop esi ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ repos_windows: ;/////////////////////////////////////////////////////////////// @@ -519,8 +564,9 @@ repos_windows: ;/////////////////////////////////////////////////////////////// call force_redraw_background dec ecx jle .exit - - .next_window: +;-------------------------------------- +align 4 +.next_window: mov [edi + WDATA.fl_redraw], 1 test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED jnz .fix_maximized @@ -534,11 +580,14 @@ repos_windows: ;/////////////////////////////////////////////////////////////// sub eax, ebx jle @f mov [edi + WDATA.box.width], ebx - @@: +;-------------------------------------- +align 4 +@@: sub ebx, [edi + WDATA.box.width] mov [edi + WDATA.box.left], ebx - - .fix_vertical: +;-------------------------------------- +align 4 +.fix_vertical: mov eax, [edi + WDATA.box.top] add eax, [edi + WDATA.box.height] mov ebx, [Screen_Max_Y] @@ -548,12 +597,24 @@ repos_windows: ;/////////////////////////////////////////////////////////////// sub eax, ebx jle @f mov [edi + WDATA.box.height], ebx - @@: +;-------------------------------------- +align 4 +@@: sub ebx, [edi + WDATA.box.height] mov [edi + WDATA.box.top], ebx - jmp .fix_client_box - - .fix_maximized: +;-------------------------------------- +align 4 +.fix_client_box: + call window._.set_window_clientbox + add edi, sizeof.WDATA + loop .next_window +;-------------------------------------- +align 4 +.exit: + ret +;-------------------------------------- +align 4 +.fix_maximized: mov eax, [screen_workarea.left] mov [edi + WDATA.box.left], eax sub eax, [screen_workarea.right] @@ -566,19 +627,11 @@ repos_windows: ;/////////////////////////////////////////////////////////////// sub eax, [screen_workarea.bottom] neg eax mov [edi + WDATA.box.height], eax - - .fix_client_box: - call window._.set_window_clientbox - - add edi, sizeof.WDATA - loop .next_window - - .exit: - ret - -align 4 + jmp .fix_client_box ;------------------------------------------------------------------------------ -sys_window_mouse: ;//////////////////////////////////////////////////////////// +;align 4 +;------------------------------------------------------------------------------ +;sys_window_mouse: ;//////////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ @@ -597,8 +650,8 @@ sys_window_mouse: ;//////////////////////////////////////////////////////////// ; ; .exit: ; pop eax - ret - +; ret +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ draw_rectangle: ;////////////////////////////////////////////////////////////// @@ -613,13 +666,13 @@ draw_rectangle: ;////////////////////////////////////////////////////////////// push eax ebx ecx edi xor edi, edi - - .flags_set: +;-------------------------------------- +align 4 +.flags_set: push ebx ; set line color mov ecx, esi -; sub esi, 1 shl 25 ; draw top border rol ebx, 16 push ebx @@ -629,6 +682,8 @@ draw_rectangle: ;////////////////////////////////////////////////////////////// jnz @f sub ecx, 1 shl 25 call [draw_line] +;-------------------------------------- +align 4 @@: ; draw bottom border mov ebx, [esp - 2] @@ -652,13 +707,14 @@ draw_rectangle: ;////////////////////////////////////////////////////////////// pop edi ecx ebx eax ret - - .forced: +;-------------------------------------- +align 4 +.forced: push eax ebx ecx edi xor edi, edi inc edi jmp .flags_set - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ drawwindow_I_caption: ;//////////////////////////////////////////////////////// @@ -677,12 +733,15 @@ drawwindow_I_caption: ;//////////////////////////////////////////////////////// cmp ebx, eax jbe @f mov ebx, eax - @@: +;-------------------------------------- +align 4 +@@: push ebx xor edi, edi - - .next_line: +;-------------------------------------- +align 4 +.next_line: mov ebx, edx shl ebx, 16 add ebx, edx @@ -697,7 +756,9 @@ drawwindow_I_caption: ;//////////////////////////////////////////////////////// jz @f sub ecx, 0x00040404 mov [esi + WDATA.cl_titlebar], ecx - @@: +;-------------------------------------- +align 4 +@@: and ecx, 0x00ffffff call [draw_line] inc edx @@ -707,7 +768,7 @@ drawwindow_I_caption: ;//////////////////////////////////////////////////////// add esp, 4 pop [esi + WDATA.cl_titlebar] ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ drawwindow_I: ;//////////////////////////////////////////////////////////////// @@ -753,11 +814,12 @@ drawwindow_I: ;//////////////////////////////////////////////////////////////// mov ecx, [esi + WDATA.box.width] mov edx, [esi + WDATA.box.height] call [drawbar] - - .exit: +;-------------------------------------- +align 4 +.exit: popad ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ drawwindow_III_caption: ;///////////////////////////////////////////////////// @@ -777,12 +839,15 @@ drawwindow_III_caption: ;///////////////////////////////////////////////////// cmp ebx, eax jb @f mov ebx, eax - @@: +;-------------------------------------- +align 4 +@@: push ebx xor edi, edi - - .next_line: +;-------------------------------------- +align 4 +.next_line: mov ebx, edx shl ebx, 16 add ebx, edx @@ -795,11 +860,15 @@ drawwindow_III_caption: ;///////////////////////////////////////////////////// test ecx, 0x40000000 jz @f add ecx, 0x00040404 - @@: +;-------------------------------------- +align 4 +@@: test ecx, 0x80000000 jz @f sub ecx, 0x00040404 - @@: +;-------------------------------------- +align 4 +@@: mov [esi + WDATA.cl_titlebar], ecx and ecx, 0x00ffffff call [draw_line] @@ -810,7 +879,7 @@ drawwindow_III_caption: ;///////////////////////////////////////////////////// add esp, 4 pop [esi + WDATA.cl_titlebar] ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ drawwindow_III: ;////////////////////////////////////////////////////////////// @@ -842,8 +911,9 @@ drawwindow_III: ;////////////////////////////////////////////////////////////// mov ecx, 3 mov esi, [edx + WDATA.cl_frames] or esi, 1 shl 25; 0x02000000 used for draw_rectangle without top line - - .next_frame: +;-------------------------------------- +align 4 +.next_frame: add eax, 1 * 65536 - 1 add ebx, 0 * 65536 - 1 call draw_rectangle @@ -882,11 +952,12 @@ drawwindow_III: ;////////////////////////////////////////////////////////////// sub ecx, 4 sub edx, 4 call [drawbar] - - .exit: +;-------------------------------------- +align 4 +.exit: popad ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ waredraw: ;//////////////////////////////////////////////////////////////////// @@ -935,20 +1006,21 @@ waredraw: ;//////////////////////////////////////////////////////////////////// mov [edi + WDATA.fl_redraw], 1 xor eax, eax jmp .exit - - .do_not_draw: +;-------------------------------------- +align 4 +.do_not_draw: ; no it's not, just activate the window call window._.window_activate xor eax, eax mov byte[MOUSE_BACKGROUND], al mov byte[DONT_DRAW_MOUSE], al - - - .exit: +;-------------------------------------- +align 4 +.exit: mov byte[MOUSE_DOWN], 0 inc eax ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ minimize_window: ;///////////////////////////////////////////////////////////// @@ -988,12 +1060,13 @@ minimize_window: ;///////////////////////////////////////////////////////////// call redrawscreen pop esi edx ecx ebx eax - - .exit: +;-------------------------------------- +align 4 +.exit: popfd pop edi ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ restore_minimized_window: ;//////////////////////////////////////////////////// @@ -1021,7 +1094,9 @@ restore_minimized_window: ;//////////////////////////////////////////////////// cmp eax, [TASK_COUNT] jz @f mov ebp, calculatescreen - @@: +;-------------------------------------- +align 4 +@@: mov eax, [edi + WDATA.box.left] mov ebx, [edi + WDATA.box.top] mov ecx, [edi + WDATA.box.width] @@ -1031,12 +1106,13 @@ restore_minimized_window: ;//////////////////////////////////////////////////// call ebp inc [_display.mask_seqno] mov byte[MOUSE_BACKGROUND], 0 - - .exit: +;-------------------------------------- +align 4 +.exit: popfd popad ret - +;------------------------------------------------------------------------------ align 4 ; TODO: remove this proc ;------------------------------------------------------------------------------ @@ -1056,13 +1132,15 @@ window_check_events: ;///////////////////////////////////////////////////////// jnz @f call minimize_window jmp .exit - - @@: +;-------------------------------------- +align 4 +@@: call restore_minimized_window - - .exit: +;-------------------------------------- +align 4 +.exit: ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ sys_window_maximize_handler: ;///////////////////////////////////////////////// @@ -1099,8 +1177,9 @@ sys_window_maximize_handler: ;///////////////////////////////////////////////// sub [esp + BOX.height], ecx mov eax, esp jmp .set_box - - .restore_size: +;-------------------------------------- +align 4 +.restore_size: mov eax, esi shl eax, 8 add eax, SLOT_BASE + APPDATA.saved_box @@ -1109,8 +1188,9 @@ sys_window_maximize_handler: ;///////////////////////////////////////////////// [eax + BOX.top] \ [eax + BOX.left] mov eax, esp - - .set_box: +;-------------------------------------- +align 4 +.set_box: test bl, WSTATE_ROLLEDUP jz @f @@ -1118,15 +1198,17 @@ sys_window_maximize_handler: ;///////////////////////////////////////////////// call window._.get_rolledup_height mov [ecx + BOX.height], eax xchg eax, ecx - - @@: +;-------------------------------------- +align 4 +@@: call window._.set_window_box add esp, sizeof.BOX - - .exit: +;-------------------------------------- +align 4 +.exit: inc [_display.mask_seqno] ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ sys_window_rollup_handler: ;/////////////////////////////////////////////////// @@ -1154,15 +1236,17 @@ sys_window_rollup_handler: ;/////////////////////////////////////////////////// [edi + WDATA.box.left] mov eax, esp jmp .set_box - - .restore_size: +;-------------------------------------- +align 4 +.restore_size: test bl, WSTATE_MAXIMIZED jnz @f add esp, -sizeof.BOX lea eax, [edx + APPDATA.saved_box] jmp .set_box - - @@: +;-------------------------------------- +align 4 +@@: mov eax, [screen_workarea.top] push [screen_workarea.bottom] \ [edi + WDATA.box.width] \ @@ -1170,13 +1254,13 @@ sys_window_rollup_handler: ;/////////////////////////////////////////////////// [edi + WDATA.box.left] sub [esp + BOX.height], eax mov eax, esp - - .set_box: +;-------------------------------------- +align 4 +.set_box: call window._.set_window_box add esp, sizeof.BOX - ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ sys_window_start_moving_handler: ;///////////////////////////////////////////// @@ -1188,9 +1272,8 @@ sys_window_start_moving_handler: ;///////////////////////////////////////////// ;------------------------------------------------------------------------------ mov edi, eax call window._.draw_negative_box - ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ sys_window_end_moving_handler: ;/////////////////////////////////////////////// @@ -1212,7 +1295,7 @@ sys_window_end_moving_handler: ;/////////////////////////////////////////////// mov bl, [edi + WDATA.fl_wstate] call window._.set_window_box ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ sys_window_moving_handler: ;/////////////////////////////////////////////////// @@ -1228,7 +1311,6 @@ sys_window_moving_handler: ;/////////////////////////////////////////////////// mov edi, ebx call window._.draw_negative_box ret - ;============================================================================== ;///// private functions ////////////////////////////////////////////////////// ;============================================================================== @@ -1251,7 +1333,7 @@ endg ; to be reworked ; new_window_starting dd ? ;endg - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.invalidate_screen: ;////////////////////////////////////////////////// @@ -1271,7 +1353,9 @@ window._.invalidate_screen: ;////////////////////////////////////////////////// cmp ecx, edx jle @f mov ecx, edx - @@: +;-------------------------------------- +align 4 +@@: mov [draw_limits.left], ecx mov ecx, [eax + BOX.left] add ecx, [eax + BOX.width] @@ -1279,14 +1363,18 @@ window._.invalidate_screen: ;////////////////////////////////////////////////// cmp ecx, edx jae @f mov ecx, edx - @@: +;-------------------------------------- +align 4 +@@: mov [draw_limits.right], ecx mov ecx, [eax + BOX.top] mov edx, [ebx + BOX.top] cmp ecx, edx jle @f mov ecx, edx - @@: +;-------------------------------------- +align 4 +@@: mov [draw_limits.top], ecx mov ecx, [eax + BOX.top] add ecx, [eax + BOX.height] @@ -1294,9 +1382,10 @@ window._.invalidate_screen: ;////////////////////////////////////////////////// cmp ecx, edx jae @f mov ecx, edx - @@: +;-------------------------------------- +align 4 +@@: mov [draw_limits.bottom], ecx - ; recalculate screen buffer at old position push ebx mov edx, [eax + BOX.height] @@ -1307,7 +1396,6 @@ window._.invalidate_screen: ;////////////////////////////////////////////////// add edx, ebx call calculatescreen pop eax - ; recalculate screen buffer at new position mov edx, [eax + BOX.height] mov ecx, [eax + BOX.width] @@ -1325,7 +1413,7 @@ window._.invalidate_screen: ;////////////////////////////////////////////////// pop ebx eax ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.set_window_box: ;///////////////////////////////////////////////////// @@ -1350,10 +1438,10 @@ end if repz cmpsd pop edi jz .exit +;-------------------------------------- +align 4 @@: - add esp, -sizeof.BOX - mov ebx, esp if WDATA.box lea esi, [edi + WDATA.box] @@ -1402,11 +1490,12 @@ end if jnz .exit mov [eax + APPDATA.saved_box.height], edx - - .exit: +;-------------------------------------- +align 4 +.exit: pop esi ebx eax ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.set_window_clientbox: ;/////////////////////////////////////////////// @@ -1447,8 +1536,9 @@ window._.set_window_clientbox: ;/////////////////////////////////////////////// mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax add esp, 4 jmp .exit - - .whole_window: +;-------------------------------------- +align 4 +.whole_window: xor eax, eax mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax @@ -1456,11 +1546,12 @@ window._.set_window_clientbox: ;/////////////////////////////////////////////// mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax mov eax, [ecx + WDATA.box.height] mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax - - .exit: +;-------------------------------------- +align 4 +.exit: pop edi ecx eax ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.sys_set_window: ;///////////////////////////////////////////////////// @@ -1519,8 +1610,9 @@ window._.sys_set_window: ;///////////////////////////////////////////////////// je @f xor eax, eax - - @@: +;-------------------------------------- +align 4 +@@: mov [edi + APPDATA.wnd_caption], eax mov esi, [esp] @@ -1547,8 +1639,9 @@ window._.sys_set_window: ;///////////////////////////////////////////////////// mov byte[KEY_COUNT], 0 ; empty keyboard buffer mov byte[BTN_COUNT], 0 ; empty button buffer - - .set_client_box: +;-------------------------------------- +align 4 +.set_client_box: ; update window client box coordinates call window._.set_window_clientbox @@ -1556,7 +1649,7 @@ window._.sys_set_window: ;///////////////////////////////////////////////////// mov [edi + WDATA.fl_redraw], 0 mov edx, edi ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.check_window_position: ;////////////////////////////////////////////// @@ -1575,62 +1668,72 @@ window._.check_window_position: ;////////////////////////////////////////////// mov esi, [Screen_Max_X] cmp ecx, esi ja .fix_width_high - - .check_left: +;-------------------------------------- +align 4 +.check_left: or eax, eax jl .fix_left_low add eax, ecx cmp eax, esi jg .fix_left_high - - .check_height: +;-------------------------------------- +align 4 +.check_height: mov esi, [Screen_Max_Y] cmp edx, esi ja .fix_height_high - - .check_top: +;-------------------------------------- +align 4 +.check_top: or ebx, ebx jl .fix_top_low add ebx, edx cmp ebx, esi jg .fix_top_high - - .exit: +;-------------------------------------- +align 4 +.exit: pop esi edx ecx ebx eax ret - - .fix_width_high: +;-------------------------------------- +align 4 +.fix_width_high: mov ecx, esi mov [edi + WDATA.box.width], esi jmp .check_left - - .fix_left_low: +;-------------------------------------- +align 4 +.fix_left_low: xor eax, eax mov [edi + WDATA.box.left], eax jmp .check_height - - .fix_left_high: +;-------------------------------------- +align 4 +.fix_left_high: mov eax, esi sub eax, ecx mov [edi + WDATA.box.left], eax jmp .check_height - - .fix_height_high: +;-------------------------------------- +align 4 +.fix_height_high: mov edx, esi mov [edi + WDATA.box.height], esi jmp .check_top - - .fix_top_low: +;-------------------------------------- +align 4 +.fix_top_low: xor ebx, ebx mov [edi + WDATA.box.top], ebx jmp .exit - - .fix_top_high: +;-------------------------------------- +align 4 +.fix_top_high: mov ebx, esi sub ebx, edx mov [edi + WDATA.box.top], ebx jmp .exit - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.get_titlebar_height: ;//////////////////////////////////////////////// @@ -1645,10 +1748,12 @@ window._.get_titlebar_height: ;//////////////////////////////////////////////// jne @f mov eax, [_skinh] ret - @@: +;-------------------------------------- +align 4 +@@: mov eax, 21 ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.get_rolledup_height: ;//////////////////////////////////////////////// @@ -1664,15 +1769,19 @@ window._.get_rolledup_height: ;//////////////////////////////////////////////// mov eax, [_skinh] add eax, 3 ret - @@: +;-------------------------------------- +align 4 +@@: or al, al jnz @f mov eax, 21 ret - @@: +;-------------------------------------- +align 4 +@@: mov eax, 21 + 2 ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.set_screen: ;///////////////////////////////////////////////////////// @@ -1704,8 +1813,9 @@ end virtual jnz .check_for_shaped_window cmp [window_data + edi + WDATA.box.height], 0 jz .exit - - .check_for_shaped_window: +;-------------------------------------- +align 4 +.check_for_shaped_window: mov edi, esi shl edi, 8 add edi, SLOT_BASE @@ -1731,8 +1841,9 @@ end virtual push ax shl eax, 16 pop ax - - .next_line: +;-------------------------------------- +align 4 +.next_line: push ecx shr ecx, 2 rep stosd @@ -1746,8 +1857,9 @@ end virtual jnz .next_line jmp .exit - - .shaped_window: +;-------------------------------------- +align 4 +.shaped_window: ; for (y=0; y <= x_size; y++) ; for (x=0; x <= x_size; x++) ; if (shape[coord(x,y,scale)]==1) @@ -1794,11 +1906,13 @@ end virtual add [ff_ysz], ebx mov ebx, [ff_y] - - .ff_new_y: +;-------------------------------------- +align 4 +.ff_new_y: mov edx, [ff_x] - - .ff_new_x: +;-------------------------------------- +align 4 +.ff_new_x: ; -- body -- mov ecx, [ff_scale] mov eax, [ff_width] @@ -1817,7 +1931,9 @@ end virtual mov eax, esi mov [ebp], al ; -- end body -- - @@: +;-------------------------------------- +align 4 +@@: inc ebp inc edx cmp edx, [ff_xsz] @@ -1832,13 +1948,15 @@ end virtual jb .ff_new_y add esp, 24 - - .exit: +;-------------------------------------- +align 4 +.exit: popad inc [_display.mask_seqno] ret - - .read_byte: +;-------------------------------------- +align 4 +.read_byte: ; eax - address ; esi - slot push eax ecx edx esi @@ -1848,7 +1966,7 @@ end virtual call read_process_memory pop esi edx ecx eax ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.window_activate: ;//////////////////////////////////////////////////// @@ -1873,11 +1991,13 @@ window._.window_activate: ;//////////////////////////////////////////////////// je .set_window_redraw_flag cmp al, 0x04 jne .move_others_down - - .set_window_redraw_flag: +;-------------------------------------- +align 4 +.set_window_redraw_flag: mov [window_data + ebx + WDATA.fl_redraw], 1 - - .move_others_down: +;-------------------------------------- +align 4 +.move_others_down: ; ax <- process no movzx ebx, word[esi] ; ax <- position in window stack @@ -1885,8 +2005,9 @@ window._.window_activate: ;//////////////////////////////////////////////////// ; drop others xor eax, eax - - .next_stack_window: +;-------------------------------------- +align 4 +.next_stack_window: cmp eax, [TASK_COUNT] jae .move_self_up inc eax @@ -1901,8 +2022,9 @@ window._.window_activate: ;//////////////////////////////////////////////////// jbe .next_stack_window dec word[WIN_STACK + eax * 2] jmp .next_stack_window - - .move_self_up: +;-------------------------------------- +align 4 +.move_self_up: movzx ebx, word[esi] ; number of processes mov ax, [TASK_COUNT] @@ -1911,16 +2033,18 @@ window._.window_activate: ;//////////////////////////////////////////////////// ; update on screen - window stack xor eax, eax - - .next_window_pos: +;-------------------------------------- +align 4 +.next_window_pos: cmp eax, [TASK_COUNT] jae .reset_vars inc eax movzx ebx, word[WIN_STACK + eax * 2] mov [WIN_POS + ebx * 2], ax jmp .next_window_pos - - .reset_vars: +;-------------------------------------- +align 4 +.reset_vars: mov byte[KEY_COUNT], 0 mov byte[BTN_COUNT], 0 mov word[MOUSE_SCROLL_H], 0 @@ -1928,7 +2052,6 @@ window._.window_activate: ;//////////////////////////////////////////////////// pop ebx eax ret - ;------------------------------------------------------------------------------ window._.window_deactivate: ;//////////////////////////////////////////////////// ;------------------------------------------------------------------------------ @@ -1937,7 +2060,8 @@ window._.window_deactivate: ;/////////////////////////////////////////////////// ;> esi = pointer to WIN_POS+ window data ;------------------------------------------------------------------------------ push eax ebx -;------------------------------------------------------------------------------ +;-------------------------------------- +align 4 .move_others_up: ; ax <- process no movzx ebx, word[esi] @@ -1945,6 +2069,8 @@ window._.window_deactivate: ;/////////////////////////////////////////////////// movzx ebx, word[WIN_STACK + ebx * 2] ; up others xor eax, eax +;-------------------------------------- +align 4 .next_stack_window: cmp eax, [TASK_COUNT] jae .move_self_down @@ -1953,13 +2079,16 @@ window._.window_deactivate: ;/////////////////////////////////////////////////// jae .next_stack_window inc word[WIN_STACK + eax * 2] jmp .next_stack_window -;---------------------------------------------- +;-------------------------------------- +align 4 .move_self_down: movzx ebx, word[esi] ; this is the last (and the low) mov [WIN_STACK + ebx * 2], word 1 ; update on screen - window stack xor eax, eax +;-------------------------------------- +align 4 .next_window_pos: cmp eax, [TASK_COUNT] jae .reset_vars @@ -1967,7 +2096,8 @@ window._.window_deactivate: ;/////////////////////////////////////////////////// movzx ebx, word[WIN_STACK + eax * 2] mov [WIN_POS + ebx * 2], ax jmp .next_window_pos -;----------------------------------------------- +;-------------------------------------- +align 4 .reset_vars: mov byte[KEY_COUNT], 0 mov byte[BTN_COUNT], 0 @@ -1999,8 +2129,9 @@ window._.check_window_draw: ;////////////////////////////////////////////////// movzx eax, word[WIN_STACK + eax * 2] ; get value of the curr process lea esi, [WIN_POS + eax * 2] ; get address of this process at 0xC400 - - .next_window: +;-------------------------------------- +align 4 +.next_window: add esi, 2 mov eax, [TASK_COUNT] @@ -2037,17 +2168,19 @@ window._.check_window_draw: ;////////////////////////////////////////////////// jge .next_window pop esi edx ebx eax - - .exit.redraw: +;-------------------------------------- +align 4 +.exit.redraw: xor ecx, ecx inc ecx ret - - .exit.no_redraw: +;-------------------------------------- +align 4 +.exit.no_redraw: pop esi edx ebx eax xor ecx, ecx ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.draw_window_caption: ;//////////////////////////////////////////////// @@ -2060,7 +2193,9 @@ window._.draw_window_caption: ;//////////////////////////////////////////////// cmp edx, [CURRENT_TASK] jne @f inc eax - @@: +;-------------------------------------- +align 4 +@@: mov edx, [CURRENT_TASK] shl edx, 5 add edx, window_data @@ -2072,27 +2207,31 @@ window._.draw_window_caption: ;//////////////////////////////////////////////// je .draw_caption_style_3 jmp .not_style_3 - - .draw_caption_style_3: +;-------------------------------------- +align 4 +.draw_caption_style_3: push edx call drawwindow_IV_caption add esp, 4 jmp .2 - - .not_style_3: +;-------------------------------------- +align 4 +.not_style_3: cmp bl, 2 jne .not_style_2 call drawwindow_III_caption jmp .2 - - .not_style_2: +;-------------------------------------- +align 4 +.not_style_2: cmp bl, 0 jne .2 call drawwindow_I_caption - - .2: +;-------------------------------------- +align 4 +.2: mov edi, [CURRENT_TASK] shl edi, 5 test [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION @@ -2109,8 +2248,9 @@ window._.draw_window_caption: ;//////////////////////////////////////////////// je .skinned jmp .not_skinned - - .skinned: +;-------------------------------------- +align 4 +.skinned: mov ebp, [edi + window_data + WDATA.box.left - 2] mov bp, word[edi + window_data + WDATA.box.top] movzx eax, word[edi + window_data + WDATA.box.width] @@ -2136,8 +2276,9 @@ window._.draw_window_caption: ;//////////////////////////////////////////////// add bx, -3 add ebx, ebp jmp .dodraw - - .not_skinned: +;-------------------------------------- +align 4 +.not_skinned: cmp al, 1 je .exit @@ -2157,17 +2298,19 @@ window._.draw_window_caption: ;//////////////////////////////////////////////// mov esi, eax mov ebx, 0x00080007 add ebx, ebp - - .dodraw: +;-------------------------------------- +align 4 +.dodraw: mov ecx, [common_colours + 16] or ecx, 0x80000000 xor edi, edi call dtext_asciiz_esi - - .exit: +;-------------------------------------- +align 4 +.exit: call [draw_pointer] ret - +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.draw_negative_box: ;////////////////////////////////////////////////// @@ -2178,6 +2321,8 @@ window._.draw_negative_box: ;////////////////////////////////////////////////// ;------------------------------------------------------------------------------ push eax ebx esi mov esi, 0x01000000 +;-------------------------------------- +align 4 .1: mov eax, [edi + BOX.left - 2] mov ax, word[edi + BOX.left] @@ -2189,6 +2334,8 @@ window._.draw_negative_box: ;////////////////////////////////////////////////// pop esi ebx eax ret ;------------------------------------------------------------------------------ +align 4 +;------------------------------------------------------------------------------ window._.end_moving__box: ;////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? Draw positive box @@ -2198,8 +2345,8 @@ window._.end_moving__box: ;////////////////////////////////////////////////// push eax ebx esi xor esi, esi jmp window._.draw_negative_box.1 - - +;------------------------------------------------------------------------------ +align 4 ;------------------------------------------------------------------------------ window._.get_rect: ;///////////////////////////////////////////////////// ;------------------------------------------------------------------------------ @@ -2220,6 +2367,5 @@ window._.get_rect: ;///////////////////////////////////////////////////// add edx, [eax-twdw + WDATA.box.height] mov [ecx+RECT.bottom], edx - ret - +;------------------------------------------------------------------------------ diff --git a/kernel/branches/Kolibri-acpi/init.inc b/kernel/branches/Kolibri-acpi/init.inc index 06483c59f7..c51487c114 100644 --- a/kernel/branches/Kolibri-acpi/init.inc +++ b/kernel/branches/Kolibri-acpi/init.inc @@ -432,6 +432,11 @@ proc test_cpu ret endp +iglobal +align 4 +acpi_lapic_base dd 0xfee00000 ; default local apic base +endg + uglobal align 4 acpi_rsdp rd 1 @@ -443,8 +448,10 @@ acpi_dev_size rd 1 acpi_rsdt_base rd 1 acpi_madt_base rd 1 -acpi_lapic_base rd 1 acpi_ioapic_base rd 1 + +cpu_count rd 1 +smpt rd 16 endg ACPI_HI_RSDP_WINDOW_START equ 0x000E0000 @@ -493,6 +500,7 @@ rsdt_find: ;ecx= rsdt edx= SIG lea ebx, [ecx+36] mov esi, [ecx+4] add esi, ecx +align 4 .next: mov eax, [ebx] cmp [eax], edx @@ -513,9 +521,16 @@ rsdt_find: ;ecx= rsdt edx= SIG pop ebx ret +align 4 +madt_find: + + + + + + ret align 4 - check_acpi: call acpi_locate @@ -529,26 +544,53 @@ check_acpi: test eax, eax jz .done + xchg bx, bx + mov [acpi_madt_base-OS_BASE], eax mov ecx, [eax+36] mov [acpi_lapic_base-OS_BASE], ecx + mov edi, smpt-OS_BASE + mov ebx, [ecx+0x20] + shr ebx, 24 ; read APIC ID + + mov [edi], ebx ; bootstrap always first + inc [cpu_count] + add edi, 4 + lea edx, [eax+44] mov ecx, [eax+4] add ecx, eax .check: mov eax, [edx] - cmp al, 1 - je .ioapic + cmp al, 0 + jne .io_apic + shr eax, 24 ; get APIC ID + cmp eax, ebx ; skip self + je .next + + test [edx+4], byte 1 ; is enabled ? + jz .next + + cmp [cpu_count-OS_BASE], 16 + jae .next + + stosd ; store APIC ID + inc [cpu_count-OS_BASE] .next: + mov eax, [edx] movzx eax, ah add edx, eax cmp edx, ecx jb .check .done: ret -.ioapic: + +.io_apic: + cmp al, 1 + jne .next + mov eax, [edx+4] mov [acpi_ioapic_base-OS_BASE], eax - ret + jmp .next diff --git a/kernel/branches/Kolibri-acpi/kernel.asm b/kernel/branches/Kolibri-acpi/kernel.asm index 9eb2c8750d..b5d78fab57 100644 --- a/kernel/branches/Kolibri-acpi/kernel.asm +++ b/kernel/branches/Kolibri-acpi/kernel.asm @@ -342,18 +342,24 @@ ap_entry: or ebx, CR4_PGE mov cr4, ebx @@: + mov esi, [LAPIC_BASE] + xor ebp, ebp .1: - mov ebx, LFB_BASE - mov edx, 128 + mov ebx, [esi+0x20] ;apic_id + shr ebx, 24 + shl ebx, 6+2 + add ebx, LFB_BASE + mov edx, 32 .2: - mov ecx, 128 + mov ecx, 32 mov edi, ebx mov eax, [_display.width] lea ebx, [ebx+eax*4] - mov eax, 0xFF808080 + mov eax, ebp rep stosd dec edx jnz .2 + dec ebp jmp .1 hlt @@ -466,6 +472,8 @@ high_code: mul [_display.height] mov [_WinMapSize], eax + call calculate_fast_getting_offset_for_WinMapAddress + mov esi, BOOT_VAR+0x9080 movzx ecx, byte [esi-1] mov [NumBiosDisks], ecx @@ -483,14 +491,7 @@ high_code: cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors je v20ga32 jmp v20ga24 -; mov [PUTPIXEL], dword Vesa12_putpixel24 ; Vesa 1.2 -; mov [GETPIXEL], dword Vesa12_getpixel24 -; cmp [ScreenBPP], byte 24 -; jz ga24 -; mov [PUTPIXEL], dword Vesa12_putpixel32 -; mov [GETPIXEL], dword Vesa12_getpixel32 -; ga24: -; jmp v20ga24 + setvesa20: mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 mov [GETPIXEL], dword Vesa20_getpixel24 @@ -685,6 +686,9 @@ no_mode_0x12: call LAPIC_init + mov eax, 1 + call start_ap + ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) ; they are used: when partitions are scanned, hd_read relies on timer call unmask_timer @@ -1992,21 +1996,7 @@ sys_end: ; restore default cursor before killing pusha mov ecx, [current_slot] - mov eax, [def_cursor] - mov [ecx+APPDATA.cursor], eax - - movzx eax, word [MOUSE_Y] - movzx ebx, word [MOUSE_X] - mov ecx, [Screen_Max_X] - inc ecx - mul ecx - add eax, [_WinMapAddress] - movzx edx, byte [ebx+eax] - shl edx, 8 - mov esi, [edx+SLOT_BASE+APPDATA.cursor] - push esi - call [_display.select_cursor] - mov [current_cursor], esi + call restore_default_cursor_before_killing popa @@: ;-------------------------------------- @@ -2025,7 +2015,25 @@ sys_end: mov ebx, 100 call delay_hs jmp waitterm +;------------------------------------------------------------------------------ +restore_default_cursor_before_killing: + mov eax, [def_cursor] + mov [ecx+APPDATA.cursor], eax + movzx eax, word [MOUSE_Y] + movzx ebx, word [MOUSE_X] + mov ecx, [Screen_Max_X] + inc ecx + mul ecx + add eax, [_WinMapAddress] + movzx edx, byte [ebx+eax] + shl edx, 8 + mov esi, [edx+SLOT_BASE+APPDATA.cursor] + push esi + call [_display.select_cursor] + mov [current_cursor], esi + ret +;------------------------------------------------------------------------------ iglobal align 4 sys_system_table: @@ -2101,21 +2109,8 @@ sysfn_terminate: ; 18.2 = TERMINATE pusha mov ecx, [esp+32] shl ecx, 8 - mov eax, [def_cursor] - mov [ecx+SLOT_BASE+APPDATA.cursor], eax - - movzx eax, word [MOUSE_Y] - movzx ebx, word [MOUSE_X] - mov ecx, [Screen_Max_X] - inc ecx - mul ecx - add eax, [_WinMapAddress] - movzx edx, byte [ebx+eax] - shl edx, 8 - mov esi, [edx+SLOT_BASE+APPDATA.cursor] - push esi - call [_display.select_cursor] - mov [current_cursor], esi + add ecx, SLOT_BASE + call restore_default_cursor_before_killing popa @@: add esp, 4 @@ -4875,7 +4870,22 @@ read_from_hd: ; Read from hd - fn not in use paleholder: ret - +;------------------------------------------------------------------------------ +align 4 +calculate_fast_getting_offset_for_WinMapAddress: +; calculate data area for fast getting offset to _WinMapAddress + mov eax, [_display.width] + mov ecx, [_display.height] + inc ecx + mov edi, d_width_calc_area + cld +@@: + stosd + add eax, [_display.width] + dec ecx + jnz @r + ret +;------------------------------------------------------------------------------ align 4 set_screen: cmp eax, [Screen_Max_X] @@ -4912,6 +4922,8 @@ set_screen: test eax, eax jz .epic_fail + call calculate_fast_getting_offset_for_WinMapAddress + popad call repos_windows diff --git a/kernel/branches/Kolibri-acpi/memmap.inc b/kernel/branches/Kolibri-acpi/memmap.inc index 78656f4798..3b4c88303a 100644 --- a/kernel/branches/Kolibri-acpi/memmap.inc +++ b/kernel/branches/Kolibri-acpi/memmap.inc @@ -62,7 +62,7 @@ ; 3c dword cpu usage in cpu timer tics ; ; -; 5000 -> 68FF free (6k6) +; 5000 -> 68FF display width fast calc area (6k6) ; 6900 -> 6EFF saved picture under mouse pointer (1k5) ; ; 6F00 -> 6FFF free (256) diff --git a/kernel/branches/Kolibri-acpi/video/cursors.inc b/kernel/branches/Kolibri-acpi/video/cursors.inc index 3bac2772da..05ffcc2359 100644 --- a/kernel/branches/Kolibri-acpi/video/cursors.inc +++ b/kernel/branches/Kolibri-acpi/video/cursors.inc @@ -1000,6 +1000,19 @@ align 4 mov [_display.check_mouse], check_mouse_area_for_putpixel_new mov [_display.check_m_pixel], check_mouse_area_for_getpixel_new + cmp [PUTPIXEL], dword VGA_putpixel + je @f + cmp [ScreenBPP], byte 32 + je .32 + mov [PUTPIXEL], dword Vesa20_putpixel24_new + jmp @f +;-------------------------------------- +align 4 +.32: + mov [PUTPIXEL], dword Vesa20_putpixel32_new +;-------------------------------------- +align 4 +@@: stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM mov [def_cursor], eax ret diff --git a/kernel/branches/Kolibri-acpi/video/vesa20.inc b/kernel/branches/Kolibri-acpi/video/vesa20.inc index afb67ee71a..44bc445732 100644 --- a/kernel/branches/Kolibri-acpi/video/vesa20.inc +++ b/kernel/branches/Kolibri-acpi/video/vesa20.inc @@ -243,13 +243,15 @@ align 4 mov ebx, [CURRENT_TASK] cmp byte [ScreenBPP], 32 je put_image_end_32 -;put_image_end_24: +;-------------------------------------- +put_image_end_24: mov edi, [putimg.real_sy] + cmp [_display.select_cursor], 0 + jne put_image_end_24_new ;-------------------------------------- align 4 .new_line: mov ecx, [putimg.real_sx] -; push ebp edx ;-------------------------------------- align 4 .new_x: @@ -268,7 +270,7 @@ align 4 sub ecx, edi ; check mouse area for putpixel - call [_display.check_mouse] + call check_mouse_area_for_putpixel pop ecx ; store to real LFB mov [LFB_BASE+edx], ax @@ -277,16 +279,15 @@ align 4 ;-------------------------------------- align 4 .skip: -; add esi, 3 ;[putimg.source_bpp] add edx, 3 inc ebp dec ecx jnz .new_x -; pop edx ebp + add esi, [putimg.line_increment] add edx, [putimg.screen_newline];[BytesPerScanLine] add ebp, [putimg.winmap_newline];[Screen_Max_X] -; inc ebp + cmp [putimg.ebp], putimage_get1bpp jz .correct cmp [putimg.ebp], putimage_get2bpp @@ -309,15 +310,93 @@ align 4 add esp, putimg.stack_data popad ret -;------------------------------------------------------------------------------ +;-------------------------------------- align 4 -put_image_end_32: - mov edi, [putimg.real_sy] +put_image_end_24_new: +;-------------------------------------- +align 4 +.new_line: + mov ecx, [putimg.real_sx] +;-------------------------------------- +align 4 +.new_x: + push [putimg.edi] + mov eax, [putimg.ebp+4] + call eax + cmp [ebp], bl + jne .skip +;-------------------------------------- + push ecx + mov ecx, [putimg.real_sy_and_abs_cy + 4] + sub ecx, edi +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_subtraction_CUR_hot_y] + jb .no_mouse_area + + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae .no_mouse_area + + rol ecx, 16 + add ecx, [putimg.real_sx_and_abs_cx + 4] + sub ecx, [esp] +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_subtraction_CUR_hot_x] + jb .no_mouse_area + + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae .no_mouse_area +;-------------------------------------- +; check mouse area for putpixel + call check_mouse_area_for_putpixel_new.1 +;-------------------------------------- +align 4 +.no_mouse_area: + pop ecx +; store to real LFB + mov [LFB_BASE+edx], ax + shr eax, 16 + mov [LFB_BASE+edx+2], al +;-------------------------------------- +align 4 +.skip: + add edx, 3 + inc ebp + dec ecx + jnz .new_x + + add esi, [putimg.line_increment] + add edx, [putimg.screen_newline];[BytesPerScanLine] + add ebp, [putimg.winmap_newline];[Screen_Max_X] + + cmp [putimg.ebp], putimage_get1bpp + jz .correct + cmp [putimg.ebp], putimage_get2bpp + jz .correct + cmp [putimg.ebp], putimage_get4bpp + jnz @f +;-------------------------------------- +align 4 +.correct: + mov eax, [putimg.edi] + mov byte [eax], 80h +;-------------------------------------- +align 4 +@@: + dec edi + jnz .new_line + jmp put_image_end_24.finish +;------------------------------------------------------------------------------ +align 4 +put_image_end_32: + mov edi, [putimg.real_sy] + cmp [_display.select_cursor], 0 + jne put_image_end_32_new ;-------------------------------------- align 4 .new_line: mov ecx, [putimg.real_sx] -; push ebp edx ;-------------------------------------- align 4 .new_x: @@ -336,23 +415,22 @@ align 4 sub ecx, edi ; check mouse area for putpixel - call [_display.check_mouse] + call check_mouse_area_for_putpixel pop ecx ; store to real LFB mov [LFB_BASE+edx], eax ;-------------------------------------- align 4 .skip: -; add esi, [putimg.source_bpp] add edx, 4 inc ebp dec ecx jnz .new_x -; pop edx ebp + add esi, [putimg.line_increment] add edx, [putimg.screen_newline];[BytesPerScanLine] add ebp, [putimg.winmap_newline];[Screen_Max_X] -; inc ebp + cmp [putimg.ebp], putimage_get1bpp jz .correct cmp [putimg.ebp], putimage_get2bpp @@ -374,9 +452,89 @@ align 4 .finish: add esp, putimg.stack_data popad + cmp [SCR_MODE], dword 0x12 + jne @f call VGA__putimage +;-------------------------------------- +align 4 +@@: mov [EGA_counter], 1 ret +;-------------------------------------- +align 4 +put_image_end_32_new: +;-------------------------------------- +align 4 +.new_line: + mov ecx, [putimg.real_sx] +;-------------------------------------- +align 4 +.new_x: + push [putimg.edi] + mov eax, [putimg.ebp+4] + call eax + cmp [ebp], bl + jne .skip +;-------------------------------------- + push ecx + mov ecx, [putimg.real_sy_and_abs_cy + 4] + sub ecx, edi +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_subtraction_CUR_hot_y] + jb .no_mouse_area + + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae .no_mouse_area + + rol ecx, 16 + add ecx, [putimg.real_sx_and_abs_cx + 4] + sub ecx, [esp] +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_subtraction_CUR_hot_x] + jb .no_mouse_area + + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae .no_mouse_area +;-------------------------------------- +; check mouse area for putpixel + call check_mouse_area_for_putpixel_new.1 +;-------------------------------------- +align 4 +.no_mouse_area: + pop ecx +; store to real LFB + mov [LFB_BASE+edx], eax +;-------------------------------------- +align 4 +.skip: + add edx, 4 + inc ebp + dec ecx + jnz .new_x + + add esi, [putimg.line_increment] + add edx, [putimg.screen_newline];[BytesPerScanLine] + add ebp, [putimg.winmap_newline];[Screen_Max_X] + + cmp [putimg.ebp], putimage_get1bpp + jz .correct + cmp [putimg.ebp], putimage_get2bpp + jz .correct + cmp [putimg.ebp], putimage_get4bpp + jnz @f +;-------------------------------------- +align 4 +.correct: + mov eax, [putimg.edi] + mov byte [eax], 80h +;-------------------------------------- +align 4 +@@: + dec edi + jnz .new_line + jmp put_image_end_32.finish ;------------------------------------------------------------------------------ align 4 __sys_putpixel: @@ -398,14 +556,10 @@ __sys_putpixel: jnz .forced ; not forced: - - push eax - mov edx, [_display.width]; screen x size - imul edx, ebx - add eax, [_WinMapAddress] + mov edx, [d_width_calc_area + ebx*4] + add edx, [_WinMapAddress] movzx edx, byte [eax+edx] cmp edx, [CURRENT_TASK] - pop eax jne .exit ;-------------------------------------- align 4 @@ -447,7 +601,7 @@ Vesa20_putpixel24: ; check mouse area for putpixel test eax, 0x04000000 jnz @f - call [_display.check_mouse] + call check_mouse_area_for_putpixel ;-------------------------------------- align 4 @@: @@ -455,7 +609,48 @@ align 4 mov [LFB_BASE+ebx+edi], ax shr eax, 16 mov [LFB_BASE+ebx+edi+2], al + ret +;----------------------------------------------------------------------------- +align 4 +Vesa20_putpixel24_new: +; eax = x +; ebx = y + mov ecx, eax + shl ecx, 16 + mov cx, bx + + imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier + lea edi, [eax+eax*2]; edi = x*3 + mov eax, [esp+32-8+4] ;-------------------------------------- +; check mouse area for putpixel + test eax, 0x04000000 + jnz @f +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_subtraction_CUR_hot_y] + jb @f + + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae @f + + rol ecx, 16 +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_subtraction_CUR_hot_x] + jb @f + + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae @f + + call check_mouse_area_for_putpixel_new.1 +;-------------------------------------- +align 4 +@@: +; store to real LFB + mov [LFB_BASE+ebx+edi], ax + shr eax, 16 + mov [LFB_BASE+ebx+edi+2], al ret ;----------------------------------------------------------------------------- align 4 @@ -473,14 +668,54 @@ Vesa20_putpixel32: ; check mouse area for putpixel test eax, 0x04000000 jnz @f - call [_display.check_mouse] + call check_mouse_area_for_putpixel ;-------------------------------------- align 4 @@: and eax, 0xffffff ; store to real LFB mov [LFB_BASE+edi], eax + ret +;----------------------------------------------------------------------------- +align 4 +Vesa20_putpixel32_new: +; eax = x +; ebx = y + mov ecx, eax + shl ecx, 16 + mov cx, bx + + imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier + lea edi, [ebx+eax*4]; edi = x*4+(y*y multiplier) + mov eax, [esp+32-8+4]; eax = color ;-------------------------------------- +; check mouse area for putpixel + test eax, 0x04000000 + jnz @f +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_subtraction_CUR_hot_y] + jb @f + + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae @f + + rol ecx, 16 +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_subtraction_CUR_hot_x] + jb @f + + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae @f + + call check_mouse_area_for_putpixel_new.1 +;-------------------------------------- +align 4 +@@: + and eax, 0xffffff +; store to real LFB + mov [LFB_BASE+edi], eax ret ;----------------------------------------------------------------------------- align 4 @@ -1055,7 +1290,12 @@ align 4 .end: add esp, drbar.stack_data popad + cmp [SCR_MODE], dword 0x12 + jne @f call VGA_draw_bar +;-------------------------------------- +align 4 +@@: xor eax, eax mov [EGA_counter], 1 ret @@ -1238,7 +1478,12 @@ dp4: jbe dp2 popad mov [EGA_counter], 1 + cmp [SCR_MODE], dword 0x12 + jne @f call VGA_drawbackground +;-------------------------------------- +align 4 +@@: ret ;------------------------------------------------------------------------------ align 4 @@ -1445,7 +1690,12 @@ sdpdone: add esp, 44 popad mov [EGA_counter], 1 + cmp [SCR_MODE], dword 0x12 + jne @f call VGA_drawbackground +;-------------------------------------- +align 4 +@@: ret uglobal diff --git a/kernel/branches/Kolibri-acpi/video/vga.inc b/kernel/branches/Kolibri-acpi/video/vga.inc index 920c57c6a4..11a4aa8ff5 100644 --- a/kernel/branches/Kolibri-acpi/video/vga.inc +++ b/kernel/branches/Kolibri-acpi/video/vga.inc @@ -13,7 +13,8 @@ $Revision$ - +;------------------------------------------------------------------------------ +align 4 paletteVGA: ;16 colour palette @@ -24,9 +25,9 @@ paletteVGA: mov ecx, 16 mov dx, 0x3c9 xor eax, eax - - palvganew: - +;-------------------------------------- +align 4 +palvganew: mov al, 0 test ah, 4 jz palvgalbl1 @@ -34,7 +35,9 @@ paletteVGA: test ah, 8 jz palvgalbl1 add al, 32 - palvgalbl1: +;-------------------------------------- +align 4 +palvgalbl1: out dx, al; red 0,31 or 63 mov al, 0 test ah, 2 @@ -43,7 +46,9 @@ paletteVGA: test ah, 8 jz palvgalbl2 add al, 32 - palvgalbl2: +;-------------------------------------- +align 4 +palvgalbl2: out dx, al; blue 0,31 or 63 mov al, 0 test ah, 1 @@ -52,7 +57,9 @@ paletteVGA: test ah, 8 jz palvgalbl3 add al, 32 - palvgalbl3: +;-------------------------------------- +align 4 +palvgalbl3: out dx, al; green 0,31 or 63 add ah, 1 loop palvganew @@ -60,59 +67,76 @@ paletteVGA: ; mov ax, 0005h ; out dx, ax ret - +;------------------------------------------------------------------------------ +align 4 palette320x200: - mov edx, 0x3c8 xor eax, eax out dx, al mov ecx, 256 mov edx, 0x3c9 xor eax, eax - - palnew: +;-------------------------------------- +align 4 +palnew: mov al, 0 test ah, 64 jz pallbl1 add al, 21 - pallbl1: +;-------------------------------------- +align 4 +pallbl1: test ah, 128 jz pallbl2 add al, 42 - pallbl2: +;-------------------------------------- +align 4 +pallbl2: out dx, al mov al, 0 test ah, 8 jz pallbl3 add al, 8 - pallbl3: +;-------------------------------------- +align 4 +pallbl3: test ah, 16 jz pallbl4 add al, 15 - pallbl4: +;-------------------------------------- +align 4 +pallbl4: test ah, 32 jz pallbl5 add al, 40 - pallbl5: +;-------------------------------------- +align 4 +pallbl5: out dx, al mov al, 0 test ah, 1 jz pallbl6 add al, 8 - pallbl6: +;-------------------------------------- +align 4 +pallbl6: test ah, 2 jz pallbl7 add al, 15 - pallbl7: +;-------------------------------------- +align 4 +pallbl7: test ah, 4 jz pallbl8 add al, 40 - pallbl8: +;-------------------------------------- +align 4 +pallbl8: out dx, al add ah, 1 loop palnew - ret +;------------------------------------------------------------------------------ align 4 uglobal novesachecksum dd 0x0 @@ -123,13 +147,12 @@ uglobal temp: .cx dd 0 endg +;------------------------------------------------------------------------------ align 4 checkVga_N13: - cmp [SCR_MODE], dword 0x13 jne @f -; cnvl: pushad cmp [EGA_counter], 1 je novesal @@ -137,21 +160,28 @@ checkVga_N13: cmp ecx, [novesachecksum] jne novesal popad - @@: +;-------------------------------------- +align 4 +@@: ret - - novesal: +;-------------------------------------- +align 4 +novesal: mov [novesachecksum], ecx mov ecx, 0 movzx eax, word [MOUSE_Y] cmp eax, 100 jge m13l3 mov eax, 100 - m13l3: +;-------------------------------------- +align 4 +m13l3: cmp eax, 480-100 jbe m13l4 mov eax, 480-100 - m13l4: +;-------------------------------------- +align 4 +m13l4: sub eax, 100 imul eax, 640*4 add ecx, eax @@ -159,11 +189,15 @@ checkVga_N13: cmp eax, 160 jge m13l1 mov eax, 160 - m13l1: +;-------------------------------------- +align 4 +m13l1: cmp eax, 640-160 jbe m13l2 mov eax, 640-160 - m13l2: +;-------------------------------------- +align 4 +m13l2: sub eax, 160 shl eax, 2 add ecx, eax @@ -173,7 +207,9 @@ checkVga_N13: mov edx, 200 mov ecx, 320 cld - m13pix: +;-------------------------------------- +align 4 +m13pix: lodsd test eax, eax jz .save_pixel @@ -188,7 +224,9 @@ checkVga_N13: and ebx, (128+64)*256*256; red shr ebx, 8+8 add eax, ebx - .save_pixel: +;-------------------------------------- +align 4 +.save_pixel: stosb loop m13pix mov ecx, 320 @@ -198,17 +236,18 @@ checkVga_N13: mov [EGA_counter], 0 popad ret - +;------------------------------------------------------------------------------ +align 4 VGA_drawbackground: ; draw all - cmp [SCR_MODE], dword 0x12 - jne .end pushad mov esi, [LFBAddress] mov edi, VGABasePtr mov ebx, 640/32; 640*480/(8*4) mov edx, 480 - @@: +;-------------------------------------- +align 4 +@@: push ebx edx esi edi shl edx, 9 lea edx, [edx+edx*4] @@ -221,9 +260,9 @@ VGA_drawbackground: jnz @r call VGA_draw_long_line_1 popad - .end: ret - +;------------------------------------------------------------------------------ +align 4 VGA_draw_long_line: mov dx, 3ceh mov ax, 0ff08h @@ -231,7 +270,9 @@ VGA_draw_long_line: out dx, ax mov ax, 0005h out dx, ax - m12pix: +;-------------------------------------- +align 4 +m12pix: call VGA_draw_32_pixels dec ebx jnz m12pix @@ -246,7 +287,8 @@ VGA_draw_long_line: out dx, al sti ret - +;------------------------------------------------------------------------------ +align 4 VGA_draw_32_pixels: xor eax, eax mov ebp, VGA_8_pixels @@ -255,9 +297,13 @@ VGA_draw_32_pixels: mov [ebp+8], eax mov [ebp+12], eax mov ch, 4 - .main_loop: +;-------------------------------------- +align 4 +.main_loop: mov cl, 8 - .convert_pixels_to_VGA: +;-------------------------------------- +align 4 +.convert_pixels_to_VGA: lodsd ; eax = 24bit colour test eax, eax jz .end @@ -273,14 +319,18 @@ VGA_draw_32_pixels: cmp al, 170 jbe .p13green or [ebp+12], ch - .p13green: +;-------------------------------------- +align 4 +.p13green: cmp ah, 85 jbe .p13red or [ebp+4], ch cmp ah, 170 jbe .p13red or [ebp+12], ch - .p13red: +;-------------------------------------- +align 4 +.p13red: shr eax, 8 cmp ah, 85 jbe .p13cont @@ -288,11 +338,15 @@ VGA_draw_32_pixels: cmp ah, 170 jbe .p13cont or [ebp+12], ch - .p13cont: +;-------------------------------------- +align 4 +.p13cont: ror eax, 8 mov ch, ah inc cl - .end: +;-------------------------------------- +align 4 +.end: dec cl jnz .convert_pixels_to_VGA inc ebp @@ -303,7 +357,9 @@ VGA_draw_32_pixels: mov esi, ebp mov dx, 3c4h mov ah, 1h - @@: +;-------------------------------------- +align 4 +@@: mov al, 02h out dx, ax xchg ax, bp @@ -316,12 +372,25 @@ VGA_draw_32_pixels: add edi, 4 pop esi ret - +;------------------------------------------------------------------------------ +align 4 VGA_putpixel: ; eax = x ; ebx = y mov ecx, eax mov eax, [esp+32-8+4] ; color +;-------------------------------------- + push ecx + shl ecx, 16 + mov cx, bx +; check mouse area for putpixel + test eax, 0x04000000 + jnz @f + call [_display.check_mouse] +;-------------------------------------- +align 4 +@@: + pop ecx shl ebx, 9 lea ebx, [ebx+ebx*4] ; умножение на 5 lea edx, [ebx+ecx*4] ; + x*BytesPerPixel (Vesa2.0 32) @@ -343,6 +412,8 @@ VGA_putpixel: cmp al, 170 jbe .p13green or dl, 0x08 +;-------------------------------------- +align 4 .p13green: cmp ah, 85 jbe .p13red @@ -350,6 +421,8 @@ VGA_putpixel: cmp ah, 170 jbe .p13red or dl, 0x08 +;-------------------------------------- +align 4 .p13red: shr eax, 8 cmp ah, 85 @@ -358,6 +431,8 @@ VGA_putpixel: cmp ah, 170 jbe .p13cont or dl, 0x08 +;-------------------------------------- +align 4 .p13cont: ror edx, 8 inc cl @@ -371,14 +446,12 @@ VGA_putpixel: rol edx, 8 mov [edi], dl popfd -;.end: ret - +;------------------------------------------------------------------------------ +align 4 VGA__putimage: ; ecx = size [x|y] ; edx = coordinates [x|y] - cmp [SCR_MODE], dword 0x12 - jne @f pushad rol edx, 16 movzx eax, dx @@ -389,16 +462,14 @@ VGA__putimage: movzx ecx, cx call VGA_draw_bar_1 popad -@@: ret - +;------------------------------------------------------------------------------ +align 4 VGA_draw_bar: ; eax cx ; ebx cy ; ecx xe ; edx ye - cmp [SCR_MODE], dword 0x12 - jne @f pushad sub ecx, eax sub edx, ebx @@ -408,9 +479,9 @@ VGA_draw_bar: and edx, 0xffff call VGA_draw_bar_1 popad -@@: ret - +;------------------------------------------------------------------------------ +align 4 VGA_draw_bar_1: mov [temp.cx], eax mov eax, [TASK_BASE] @@ -429,13 +500,16 @@ VGA_draw_bar_1: mov ebx, ecx shr ebx, 5 inc ebx +;-------------------------------------- +align 4 .main_loop: call VGA_draw_long_line_1 dec edx jnz .main_loop call VGA_draw_long_line_1 ret - +;------------------------------------------------------------------------------ +align 4 VGA_draw_long_line_1: push ebx edx esi edi shl edx, 9 @@ -446,5 +520,4 @@ VGA_draw_long_line_1: call VGA_draw_long_line pop edi esi edx ebx ret - - +;------------------------------------------------------------------------------