Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1899 → Rev 1898

/kernel/branches/Kolibri-A/trunk/data32.inc
413,9 → 413,9
 
;* end code - Mario79
 
;img_background rd 1
;mem_BACKGROUND rd 1
;static_background_data rd 1
img_background rd 1
mem_BACKGROUND rd 1
static_background_data rd 1
 
cache_ide0:
cache_ide0_pointer rd 1
/kernel/branches/Kolibri-A/trunk/gui/mouse.inc
518,13 → 518,11
;< esi = process slot
;< edi = pointer to WDATA struct
;------------------------------------------------------------------------------
mov esi, [mouse.state.pos.y]
mov edi, [mouse.state.pos.x]
shr esi, 1
shr edi, 2
imul esi, [_WinMapWidth]
add edi, [_WinMapAddress]
add esi, edi
mov esi, [Screen_Max_X]
inc esi
imul esi, [mouse.state.pos.y]
add esi, [_WinMapAddress]
add esi, [mouse.state.pos.x]
movzx esi, byte[esi]
mov edi, esi
shl edi, 5
/kernel/branches/Kolibri-A/trunk/gui/window.inc
12,7 → 12,7
;///// public functions ///////////////////////////////////////////////////////
;==============================================================================
 
window.BORDER_SIZE = 4
window.BORDER_SIZE = 5
 
macro FuncTable name, table_name, [label]
{
336,11 → 336,11
@@: cmp edx, -1
jne @f
mov edx, [edi + WDATA.box.width]
; and dl, 0xFC
and dl, 0xFC
@@: cmp esi, -1
jne @f
mov esi, [edi + WDATA.box.height]
; and esi, 0xFFFFFFFE
and esi, 0xFFFFFFFE
 
@@: push esi edx ecx ebx
mov eax, esp
515,10 → 515,10
mov eax, [edi + WDATA.box.width]
sub eax, ebx
jle @f
; and bl, 0xFC ; <<<<<<<
and bl, 0xFC ; <<<<<<<
mov [edi + WDATA.box.width], ebx
@@: sub ebx, [edi + WDATA.box.width]
; and bl, 0xFC ; <<<<<<<
and bl, 0xFC ; <<<<<<<
mov [edi + WDATA.box.left], ebx
 
.fix_vertical:
530,10 → 530,10
mov eax, [edi + WDATA.box.height]
sub eax, ebx
jle @f
; and bl, 0xFE ; <<<<<<<
and bl, 0xFE ; <<<<<<<
mov [edi + WDATA.box.height], ebx
@@: sub ebx, [edi + WDATA.box.height]
; and bl, 0xFE ; <<<<<<<
and bl, 0xFE ; <<<<<<<
mov [edi + WDATA.box.top], ebx
jmp .fix_client_box
 
666,7 → 666,6
add ebx, edx
mov eax, [esi + WDATA.box.left]
inc eax
 
shl eax, 16
add eax, [esi + WDATA.box.left]
add eax, [esi + WDATA.box.width]
1456,9 → 1455,9
movzx eax, cx
mov [edi + WDATA.box.height], eax
sar ebx, 16
; and bl, 0xFC ; <<<<<<<<
and bl, 0xFC ; <<<<<<<<
sar ecx, 16
; and cl, 0xFE ; <<<<<<<<
and cl, 0xFE ; <<<<<<<<
mov [edi + WDATA.box.left], ebx
mov [edi + WDATA.box.top], ecx
 
1648,7 → 1647,6
ff_width dd ?
ff_xsz dd ?
ff_ysz dd ?
ff_map dd ?
ff_scale dd ?
end virtual
 
1675,40 → 1673,39
sub edx, ebx
inc ecx
inc edx
shr ecx, 2 ; 1 tile = 4 pix
shr edx, 1 ; 1 tile = 2 lines
 
; get WinMap start
push esi
mov edi, [_WinMapWidth]
mov esi, edi
shr ebx, 1
imul edi, ebx
shr eax, 2
shr eax, 1
shr eax, 1
add edi, eax
add edi, [_WinMapAddress]
pop eax ; al = process#
; mov ah, al
; push ax
; shl eax, 16
; pop ax ; eax = 4 dup PROCESS_NUM
pop eax
mov ah, al
push ax
shl eax, 16
pop ax
 
sub esi, ecx ; map line increment (bytes)
mov ebx, ecx ; map line width
.next_line:
; shr ecx, 2 ; 1dword = 4 tiles
; rep stosd ; filling the screen map
; mov ecx, ebx
; and ecx, 3 ; 0 to 3 tiles remaining
push ecx
shr ecx, 2
rep stosd
mov ecx, [esp]
and ecx, 3
rep stosb
mov ecx, ebx
pop ecx
add edi, esi
sub edi, ecx
dec edx
jnz .next_line
 
jmp .exit
 
.shaped_window:
; for (y=0; y <= y_size; y++)
; for (y=0; y <= x_size; y++)
; for (x=0; x <= x_size; x++)
; if (shape[coord(x,y,scale)]==1)
; set_pixel(x, y, process_number);
1720,22 → 1717,19
 
push [edi + APPDATA.wnd_shape_scale] ; push scale first -> for loop
 
push ebx
; get WinMap start -> ebp
push eax
mov ebp, eax
shr ebp, 2
mov eax, [_WinMapWidth] ; <<<<
imul eax, ebx
mov ebp, [esp]
shr ebp, 1
shr ebp, 1
add ebp, eax
add ebp, [_WinMapAddress]
mov eax, [_WinMapWidth]
shr ebx, 1
imul eax, ebx
add ebp, eax ; ebp = map origin
 
mov edi, [edi + APPDATA.wnd_shape]
pop eax
pop ebx
push ebp ; for loop - screen map origin
 
; eax = x_start
; ebx = y_start
; ecx = x_size
1742,10 → 1736,9
; edx = y_size
; esi = process_number
; edi = &shape
; ebp = [ff_map]
; [scale]
push edx ecx ; for loop - x,y size
 
push edx ecx ; for loop - x,y size
mov ecx, esi
shl ecx, 5
mov edx, [window_data + ecx + WDATA.box.top]
1776,41 → 1769,40
add eax, edx
pop edx ebx
add eax, edi
call .read_byte ; al= shaped window pix-mask at a given point
call .read_byte
test al,al
jz @f
mov eax, esi
mov [ebp], al ; a tile belongs to the window if the 1st pixel's mask = 1
mov [ebp], al
; -- end body --
@@:
add edx, 4
inc ebp
@@: inc ebp
inc edx
cmp edx, [ff_xsz]
jb .ff_new_x
 
sub ebp, [ff_xsz]
add ebp, [ff_x]
add ebp, [Screen_Max_X] ; screen.x
inc ebp
inc ebx
inc ebx
cmp ebx, [ff_ysz]
jnb @f
mov ebp, [ff_map]
add ebp, [_WinMapWidth] ; even line: jump to next map row
mov [ff_map], ebp
jmp .ff_new_y
@@:
add esp, 7*4
jb .ff_new_y
 
add esp, 24
 
.exit:
popad
ret
 
.read_byte:
; eax - buffer address
; esi - slot#
; eax - address
; esi - slot
push eax ecx edx esi
xchg eax, esi
lea ecx, [esp + 12] ; buffer addr = stacked [eax] to return
mov edx, 1 ; buffer size
call read_process_memory ; (core/taskman.inc) returns #bytes read
pop esi edx ecx eax ; eax = PID
lea ecx, [esp + 12]
mov edx, 1
call read_process_memory
pop esi edx ecx eax
ret
 
align 4
/kernel/branches/Kolibri-A/trunk/gui/font.inc
51,7 → 51,7
cmp byte [edx], 0
jz .end
; // Alver 22.06.2008 // {
cmp byte [esp+28], 1 ; was the entry point = dtext.1 ?
cmp byte [esp+28], 1
jne @f
dec esi
js .end
58,7 → 58,7
; } \\ Alver \\
@@:
inc edx
pushad ; esp -= 64 !
pushad
movzx edx, byte [edx-1]
test ecx, 0x10000000
jnz .font2
71,14 → 71,14
shr dl, 1
jz .pixloop1end
jnc .nopix
call _putpixel
call [putpixel]
jmp .pixloop1cont
.nopix:
test ecx, 0x40000000
jz .pixloop1cont
push ecx
mov ecx, [esp+4+20h+20h] ; original eax?
call _putpixel
mov ecx, [esp+4+20h+20h]
call [putpixel]
pop ecx
.pixloop1cont:
inc eax
103,7 → 103,7
.pixloop2:
shr dl, 1
jnc .nopix2
call _putpixel
call [putpixel]
jmp .pixloop2cont
.nopix2:
test ecx, 0x40000000
110,7 → 110,7
jz .pixloop2cont
push ecx
mov ecx, [esp+12+20h+20h]
call _putpixel
call [putpixel]
pop ecx
.pixloop2cont:
inc eax
/kernel/branches/Kolibri-A/trunk/hid/mousedrv.inc
161,7 → 161,7
mov esi, edi
add edi, esi
add edi, esi ; *3
add edi, mousepointer ;[MOUSE_PICTURE] ; we have our str address
add edi,[MOUSE_PICTURE] ; we have our str address
mov esi, edi
add esi, 16*24*3
push ecx
/kernel/branches/Kolibri-A/trunk/kernel.asm
63,6 → 63,9
 
USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices
 
; Enabling the next line will enable serial output console
;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
 
include "proc32.inc"
include "kglobals.inc"
 
341,8 → 344,8
mov [screen_workarea.bottom],eax
movzx eax,word [BOOT_VAR+0x9008] ; screen mode
mov [SCR_MODE],eax
; mov eax,[BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add == not used any more
; mov [BANK_SWITCH],eax
mov eax,[BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add
mov [BANK_SWITCH],eax
movzx eax, word[BOOT_VAR+0x9001] ; for other modes
mov [BytesPerScanLine],ax
mov [_display.pitch], eax
372,8 → 375,8
; === EGA, VGA & Vesa 1.2 modes not supported ===
setvesa20:
v20ga32:
; mov [PUTPIXEL],dword put_pixel
; mov [GETPIXEL],dword get_pixel
mov [PUTPIXEL],dword put_pixel
mov [GETPIXEL],dword get_pixel
 
; -------- Fast System Call init ----------
.SEnP:
511,8 → 514,8
mov [BgrDrawMode],eax
mov [BgrDataWidth],eax
mov [BgrDataHeight],eax
; mov [mem_BACKGROUND], 4
; mov [img_background], static_background_data
mov [mem_BACKGROUND], 4
mov [img_background], static_background_data
 
mov [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE
 
600,6 → 603,17
mov esi, boot_memdetect
call boot_log
 
; <<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>
mov ebx, img_test_struct
mov ecx, 3*65536 + 4
mov edx, 32*65536 + 512
mov esi, 32
xor edi, edi
mov ebp, edi
call sys_putimage_palette.forced
 
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>
 
movzx ecx, word [boot_y]
or ecx, (10+29*6) shl 16 ; "Determining amount of memory"
sub ecx, 10
631,9 → 645,16
 
mov esi,boot_bgr
call boot_log
call _init_background ;graph32.inc ?
call init_background
call calculatebackground
 
; RESERVE SYSTEM IRQ'S JA PORT'S
 
; mov esi,boot_resirqports
; call boot_log
; call reserve_irqs_ports
 
 
; SET UP OS TASK
 
mov esi,boot_setostask
685,138 → 706,6
mov [SLOT_BASE+APPDATA.cursor],eax
mov [SLOT_BASE+APPDATA.cursor+256],eax
 
; <<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>
 
; mov esi, img_test_struct_8
; mov edi, 151
 
; mov ebp, edi
; imul edi, [BytesPerScanLine]
; add edi, LFB_BASE + 32*4
; mov [img_lfb_origin], edi
; shr ebp, 1
; imul ebp, [_WinMapWidth]
; add ebp, 32/4
; add ebp, [_WinMapAddress]
; mov ecx, ebp
; add ecx, [_WinMapWidth]
; mov byte[ecx+1], 2
; mov ecx, 6
; mov [img_pix_y], ecx
; mov eax, 1
; mov [img_bytes_per_pix], eax
; mov ebx, 1
; bts ebx, 24
; mov eax, 8-1
; mov [img_pix_x], eax
; inc eax
; shr eax, 2
; mov [img_map_x], eax
; mov [img_draw_core_fn], draw_core_8bpp
; mov [img_draw_edge_fn], draw_edge_8bpp
; mov [img_buf_line_size], 9
; mov [img_palette], img_test_palette
 
; call draw_aligned_box
; add edi, 48
; mov edx, 8
; call draw_unaligned_edge
; mono
; bts ebx, 25
; add edi, [_WinMapWidth] ; = 1/16 of the screen width
; mov esi, img_test_struct_1
; mov [img_lfb_origin], edi
; mov ecx, 9
; mov [img_map_x], 4
; mov [img_bitoffset], 1
; mov [img_edgeoffset], 16
; mov [img_draw_core_fn], draw_core_1bpp
; mov [img_draw_edge_fn], draw_edge_1bpp
; mov [img_buf_line_size], 2
; mov [img_bytes_per_pix], 0
; call draw_aligned_box
; add edi, 48
; mov edx, 8
; call draw_unaligned_edge
; btr ebx, 25
; 32bpp
; add edi, [_WinMapWidth] ; = 1/16 of the screen width
; mov esi, img_test_struct_32
; mov [img_lfb_origin], edi
; mov ecx, 6
; mov [img_map_x], 2
; mov [img_draw_core_fn], draw_core_32bpp
; mov [img_draw_edge_fn], draw_edge_32bpp
; mov [img_buf_line_size], 32
; mov [img_bytes_per_pix], 4
; call draw_aligned_box
; add edi, 48
; mov edx, 8
; call draw_unaligned_edge
 
; 24bpp
; add edi, [_WinMapWidth] ; = 1/16 of the screen width
; mov esi, img_test_struct_24
; mov [img_lfb_origin], edi
; mov ecx, 7
; mov [img_map_x], 4
; mov [img_draw_core_fn], draw_core_24bpp
; mov [img_draw_edge_fn], draw_edge_24bpp
; mov [img_buf_line_size], 45
; mov [img_bytes_per_pix], 3
; call draw_aligned_box
; add edi, 80
; mov edx, 4
; call draw_unaligned_edge
 
; mov [TASK_BASE-twdw + WDATA.box.left], 0
; mov [TASK_BASE-twdw + WDATA.box.top], 0
; mov eax, [Screen_Max_X]
; mov [TASK_BASE-twdw + WDATA.box.width], eax
; mov eax, [Screen_Max_Y]
; mov [TASK_BASE-twdw + WDATA.box.height], eax
; mov ebx, img_test_struct_24
; mov ecx, 16*65536 + 7
; mov edx, 512*65536 + 400
 
; call _putimage
 
 
;-----------
; mov ebx, img_test_struct_32
; mov ecx, 6*65536 + 6
; mov edx, 32*65536 + 512
; mov esi, 32
; xor edi, edi
; mov ebp, edi
; call sys_putimage_palette.forced
 
; mov [img_palette], img_test_palette
; mov [img_bytes_per_pix], 0
; mov [img_buf_line_size], 0
; mov ebx, img_test_palette
; mov [img_draw_core_fn], draw_core_0bpp
; mov [img_draw_edge_fn], draw_edge_0bpp
; mov ecx, 20*65536 + 9
; mov edx, 513*65536 + 401
; call _putimage
 
; mov eax, 561
; mov ebx, 461
; mov ecx, 555
; mov edx, 333
; mov edi, 0xAA5533
; call _drawbar
 
 
 
; jmp $
 
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 
 
; READ TSC / SECOND
 
mov esi,boot_tsc
855,18 → 744,17
 
call set_variables
 
 
 
; SET MOUSE
 
;call detect_devices
stdcall load_driver, szPS2MDriver
; stdcall load_driver, szCOM_MDriver
 
mov esi,boot_setmouse
call boot_log
; call setmouse
cli
call setmouse
 
 
; STACK AND FDC
 
call stack_init
964,7 → 852,47
;// mike.dld ]
 
 
; Setup serial output console (if enabled)
 
if defined debug_com_base
 
; enable Divisor latch
 
mov dx, debug_com_base+3
mov al, 1 shl 7
out dx, al
 
; Set speed to 115200 baud (max speed)
 
mov dx, debug_com_base
mov al, 0x01
out dx, al
 
mov dx, debug_com_base+1
mov al, 0x00
out dx, al
 
; No parity, 8bits words, one stop bit, dlab bit back to 0
 
mov dx, debug_com_base+3
mov al, 3
out dx, al
 
; disable interrupts
 
mov dx, debug_com_base+1
mov al, 0
out dx, al
 
; clear + enable fifo (64 bits)
 
mov dx, debug_com_base+2
mov al, 0x7 + 1 shl 5
out dx, al
 
 
end if
 
; START MULTITASKING
 
if preboot_blogesc
1005,6 → 933,9
inc edi
call dtext
 
; mov [novesachecksum],1000
; call checkVga_N13
 
popad
 
ret
1020,9 → 951,11
call window_check_events
call mouse_check_events
call checkmisc
; call checkVga_N13
call stack_handler
call checkidle
; call check_fdd_motor_status
call check_fdd_motor_status
; call check_ATAPI_device_event
jmp osloop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
1831,7 → 1764,6
test eax, eax
jz @F
 
 
stdcall user_free, eax
@@:
 
2218,29 → 2150,227
bgrlock db 0
endg
 
;=============================== SysFn 15 ================================
; no background service supported so far ...
;===========================================
 
sys_background:
 
cmp ebx,6 ; subfns 1..5 do not return anything
jb .exit
mov dword [esp+32], 0 ; subfns 6,7 return 0 as error
cmp ebx,1 ; BACKGROUND SIZE
jnz nosb1
test ecx,ecx
; cmp ecx,0
jz sbgrr
test edx,edx
; cmp edx,0
jz sbgrr
@@:
;;Maxis use atomic bts for mutexes 4.4.2009
bts dword [bgrlock], 0
jnc @f
call change_task
jmp @b
@@:
mov [BgrDataWidth],ecx
mov [BgrDataHeight],edx
; mov [bgrchanged],1
 
pushad
; return memory for old background
mov eax, [img_background]
cmp eax, static_background_data
jz @f
stdcall kernel_free, eax
@@:
; calculate RAW size
xor eax,eax
inc eax
cmp [BgrDataWidth],eax
jae @f
mov [BgrDataWidth],eax
@@:
cmp [BgrDataHeight],eax
jae @f
mov [BgrDataHeight],eax
@@:
mov eax,[BgrDataWidth]
imul eax,[BgrDataHeight]
lea eax,[eax*3]
mov [mem_BACKGROUND],eax
; get memory for new background
stdcall kernel_alloc, eax
test eax, eax
jz .memfailed
mov [img_background], eax
jmp .exit
.memfailed:
; revert to static monotone data
mov [img_background], static_background_data
xor eax, eax
inc eax
mov [BgrDataWidth], eax
mov [BgrDataHeight], eax
mov [mem_BACKGROUND], 4
.exit:
popad
mov [bgrlock], 0
 
sbgrr:
ret
 
;=============================== SysFn 39 ================================
; no background service supported so far ...
;===========================================
align 4
nosb1:
 
sys_getbackground:
mov dword [esp+32], 0
cmp ebx,2 ; SET PIXEL
jnz nosb2
 
mov eax, [img_background]
test ecx, ecx
jz @f
cmp eax, static_background_data
 
jz .ret
@@:
mov ebx, [mem_BACKGROUND]
add ebx, 4095
and ebx, -4096
sub ebx, 4
cmp ecx, ebx
ja .ret
 
mov ebx,[eax+ecx]
and ebx,0xFF000000 ;255*256*256*256
and edx,0x00FFFFFF ;255*256*256+255*256+255
add edx,ebx
mov [eax+ecx],edx
.ret:
ret
nosb2:
 
;===========================================
cmp ebx,3 ; DRAW BACKGROUND
jnz nosb3
draw_background_temp:
; cmp [bgrchanged],1 ;0
; je nosb31
;draw_background_temp:
; mov [bgrchanged],1 ;0
 
mov [background_defined], 1
mov byte[BACKGROUND_CHANGED], 1
call force_redraw_background
nosb31:
ret
nosb3:
 
cmp ebx,4 ; TILED / STRETCHED
jnz nosb4
cmp ecx,[BgrDrawMode]
je nosb41
mov [BgrDrawMode],ecx
; mov [bgrchanged],1
nosb41:
ret
nosb4:
 
cmp ebx,5 ; BLOCK MOVE TO BGR
jnz nosb5
cmp [img_background], static_background_data
jnz @f
test edx, edx
jnz .fin
cmp esi, 4
ja .fin
@@:
; bughere
mov eax, ecx
mov ebx, edx
add ebx, [img_background] ;IMG_BACKGROUND
mov ecx, esi
call memmove
.fin:
ret
nosb5:
 
cmp ebx, 6
jnz nosb6
;;Maxis use atomic bts for mutex 4.4.2009
@@:
bts dword [bgrlock], 0
jnc @f
call change_task
jmp @b
@@:
mov eax, [CURRENT_TASK]
mov [bgrlockpid], eax
cmp [img_background], static_background_data
jz .nomem
stdcall user_alloc, [mem_BACKGROUND]
mov [esp+32], eax
test eax, eax
jz .nomem
mov ebx, eax
shr ebx, 12
or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK
mov esi, [img_background]
shr esi, 12
mov ecx, [mem_BACKGROUND]
add ecx, 0xFFF
shr ecx, 12
.z:
mov eax, [page_tabs+ebx*4]
test al, 1
jz @f
call free_page
@@:
mov eax, [page_tabs+esi*4]
or al, PG_UW
mov [page_tabs+ebx*4], eax
mov eax, ebx
shl eax, 12
invlpg [eax]
inc ebx
inc esi
loop .z
ret
.nomem:
and [bgrlockpid], 0
mov [bgrlock], 0
nosb6:
cmp ebx, 7
jnz nosb7
cmp [bgrlock], 0
jz .err
mov eax, [CURRENT_TASK]
cmp [bgrlockpid], eax
jnz .err
mov eax, ecx
mov ebx, ecx
shr eax, 12
mov ecx, [page_tabs+(eax-1)*4]
test cl, USED_BLOCK+DONT_FREE_BLOCK
jz .err
jnp .err
push eax
shr ecx, 12
dec ecx
@@:
and dword [page_tabs+eax*4], 0
mov edx, eax
shl edx, 12
push eax
invlpg [edx]
pop eax
inc eax
loop @b
pop eax
and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK
stdcall user_free, ebx
mov [esp+32], eax
and [bgrlockpid], 0
mov [bgrlock], 0
ret
.err:
and dword [esp+32], 0
ret
 
nosb7:
ret
 
force_redraw_background:
and [draw_data+32 + RECT.left], 0
and [draw_data+32 + RECT.top], 0
2252,9 → 2382,54
pop ebx eax
inc byte[REDRAW_BACKGROUND]
ret
;===========================================
 
align 4
 
sys_getbackground:
; cmp eax,1 ; SIZE
dec ebx
jnz nogb1
mov eax,[BgrDataWidth]
shl eax,16
mov ax,[BgrDataHeight]
mov [esp+32],eax
ret
 
nogb1:
; cmp eax,2 ; PIXEL
dec ebx
jnz nogb2
 
mov eax, [img_background]
test ecx, ecx
jz @f
cmp eax, static_background_data
jz .ret
@@:
mov ebx, [mem_BACKGROUND]
add ebx, 4095
and ebx, -4096
sub ebx, 4
cmp ecx, ebx
ja .ret
 
mov eax,[ecx+eax]
 
and eax, 0xFFFFFF
mov [esp+32],eax
.ret:
ret
nogb2:
 
; cmp eax,4 ; TILED / STRETCHED
dec ebx
dec ebx
jnz nogb4
mov eax,[BgrDrawMode]
nogb4:
mov [esp+32],eax
ret
 
align 4
 
sys_getkey:
2671,6 → 2846,26
;---------------------------------------------------------------------------------------------
 
 
; check if pixel is allowed to be drawn
; -- not in use any more ?
 
;checkpixel:
; push eax ebx edx
; shr ebx, 1
; mov edx, [_WinMapWidth] ; <<<<
; imul edx, ebx
; shr eax, 2
; add eax, [_WinMapAddress]
; mov dl, [eax+edx]
;
; xor ecx, ecx
; mov eax, [CURRENT_TASK]
; cmp al, dl
; setne cl
;
; pop edx ebx eax
; ret
 
iglobal
cpustring db 'CPU',0
endg
3096,10 → 3291,18
 
drawbackground:
inc [mouse_pause]
call draw_background ; graph32.inc
; cmp [BgrDrawMode],dword 1
; jne bgrstr
; call vesa20_drawbackground_tiled
call drawbackground
dec [mouse_pause]
call [draw_pointer]
ret
; bgrstr:
; call vesa20_drawbackground_stretch
; dec [mouse_pause]
; call [draw_pointer]
; ret
 
; ====================================================================
align 4
3136,8 → 3339,7
inc [mouse_pause]
call _putimage
dec [mouse_pause]
call [draw_pointer]
ret
jmp [draw_pointer]
 
 
align 4
3155,13 → 3357,12
add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left]
rol edx, 16
.forced:
push eax
push esi
mov [img_palette], edi
mov eax, esi
cmp eax, 32 ;>32bpp (stupid call)
ja .exit
shr al, 3 ; 0=1bpp or solid color
shr al, 3 ; 0=1bpp, other lo-pix modes not supported
push esi
mov [img_bytes_per_pix], eax
mov esi, [eax*4 + img_core_proc_0]
mov [img_draw_core_fn], esi
3169,34 → 3370,29
mov [img_draw_edge_fn], esi
mov esi, ecx
shr esi, 16 ; esi = SizeX
or al, al
jz .1bpp
imul esi, eax
or al, al
jnz .done
mov eax, [esp] ; bits per pixel
or al, al
jz .done
jmp .done
.1bpp:
add esi, 7
shr esi, 3 ; 8 pixels per byte
mov [img_draw_edge_fn], draw_edge_1bpp
mov [img_draw_core_fn], draw_core_1bpp
.done:
add esi, ebp ; + line offset
mov [img_buf_line_size], esi
pop esi
pop eax
jmp sys_putimage_bpp
jmp _putimage ;<<< sys_putimage_bpp
.exit:
ret
 
align 4
img_core_proc_0 dd draw_core_0bpp
img_core_proc_0 dd draw_core_1bpp
img_core_proc_1 dd draw_core_8bpp
img_core_proc_2 dd draw_core_16bpp
img_core_proc_3 dd draw_core_24bpp
img_core_proc_4 dd draw_core_32bpp
 
img_edge_proc_0 dd draw_edge_0bpp
img_edge_proc_0 dd draw_edge_1bpp
img_edge_proc_1 dd draw_edge_8bpp
img_edge_proc_2 dd draw_edge_16bpp
img_edge_proc_3 dd draw_edge_24bpp
3218,7 → 3414,7
.forced:
inc [mouse_pause]
; dbv20:
call _drawbar
call vesa20_drawbar
dec [mouse_pause]
jmp [draw_pointer]
 
3321,25 → 3517,27
ret
 
 
;setmouse: ; set mousepicture -pointer
setmouse: ; set mousepicture -pointer
; ps2 mouse enable
 
; mov [MOUSE_PICTURE],dword mousepointer
; cli
; ret
mov [MOUSE_PICTURE],dword mousepointer
 
;if used _rdtsc
;_rdtsc:
; bt [cpu_caps], CAPS_TSC
; jnc ret_rdtsc
; rdtsc
; ret
; ret_rdtsc:
; mov edx,0xffffffff
; mov eax,0xffffffff
; ret
;end if
cli
 
ret
 
if used _rdtsc
_rdtsc:
bt [cpu_caps], CAPS_TSC
jnc ret_rdtsc
rdtsc
ret
ret_rdtsc:
mov edx,0xffffffff
mov eax,0xffffffff
ret
end if
 
rerouteirqs:
 
cli
3469,6 → 3667,24
cmp eax, 1
jne .smbl1
 
if defined debug_com_base
 
push dx ax
 
@@: ; Wait for empty transmit register (yes, this slows down system..)
mov dx, debug_com_base+5
in al, dx
test al, 1 shl 5
jz @r
 
mov dx, debug_com_base ; Output the byte
mov al, bl
out dx, al
 
pop ax dx
 
end if
 
mov [msg_board_data+ecx],bl
inc ecx
and ecx, 4095
3659,9 → 3875,16
mov eax, ebx
mov ebx, ecx
mov ecx, edx
mov edx, [TASK_BASE]
add eax, [edx-twdw+WDATA.box.left]
add ebx, [edx-twdw+WDATA.box.top]
mov edi, [current_slot]
add eax, [edi+APPDATA.wnd_clientbox.left]
add ebx, [edi+APPDATA.wnd_clientbox.top]
xor edi, edi ; no force
; call [_display.disable_mouse]
jmp __sys_putpixel
; mov edi, 1
call [_display.disable_mouse]
jmp [putpixel]
 
align 4
 
3743,7 → 3966,7
div ecx
mov ebx, edx
xchg eax, ebx
call get_pixel ; eax - x, ebx - y
call dword [GETPIXEL] ; eax - x, ebx - y
mov [esp + 32], ecx
ret
 
3805,7 → 4028,7
push eax ebx ecx
add eax,ecx
 
call get_pixel ; eax - x, ebx - y
call dword [GETPIXEL] ; eax - x, ebx - y
 
mov [ebp],cx
shr ecx,16
3964,7 → 4187,8
stdcall kernel_free, [_WinMapAddress]
 
mov eax, [_display.width]
shr eax, 2
shr eax, 1
shr eax, 1
mov [_WinMapWidth], eax
mov eax, [_display.height]
shr eax, 1
4304,28 → 4528,3
uglobals_size = $ - endofcode
diff16 "Zero-filled blk",0,endofcode
diff16 "End of kernel ",0,$
 
;Êóðãèíÿí - ìàòåìàòèê, è îñíîâíûå ñâîè âûâîäû äåëàåò íà îñíîâå òåîðèè êàòàñòðîô (åñòü òàêàÿ âïîëíå ñåáå ïðèêëàäíàÿ îáëàñòü ìàòåìàòèêè) ñ ýëåìåíòàìè âàðèàöèîííîãî è ôàêòîðíîãî àíàëèçà.  ïðèíöèïå, îí ìîã áû èçëîæèòü ñóòü â 3-4 ñóõèõ ôîðìóëàõ, íî òîëüêî ïîíÿòü èõ ìîãëè (è çàõîòåëè) áû ÷åëîâåê 200-300...
 
;Âîò è ïðèõîäèòñÿ åìó èçëàãàòü òî æå ñàìîå, íî ãîðàçäî äëèííåå è äîõîä÷èâåå. Ëè÷íî ÿ íå ïîëåíèëñÿ è ïðî÷èòàë öèêë "Êðèçèñ è äðóãèå" â àðõèâå "Çàâòðà" çà 2009 ãîä.
 
 
;Âîò î÷åíü êðàòêàÿ âûæèìêà åãî îñíîâíûõ èäåé (ñ ìîåé êîëîêîëüíè, êîíå÷íî):
 
;1) Ïëàíåòà ïåðåíàñåëåíà, ðåñóðñîâ íà âñåõ íå õâàòèò, ïåðèîä ëèáåðàëüíåíêîé ãëîáàëèçàöèè äîëæåí ñìåíèòüñÿ ýðîé æåñòêîãî ðàöèîíèðîâàíèÿ ïðè òîòàëüíîì êîíòðîëå âñåãî.
 
;2) Ó ãðÿäóùåãî òîòàëèòàðíîãî îáùåñòâà äîëæíà áûòü ãîñïîäñòâóþùàÿ èäåîëîãèÿ, ìîáèëèçóþùàÿ ëþäåé â ñóðîâîé áîðüáå. Êàêîé åé áûòü? äëÿ ýòîãî íàäî îòâåòèòü íà äâà îñíîâíûõ âîïðîñà: à) ìîæíî ëè ñäåëàòü ÷åëîâåêà ëó÷øå, ñèëüíåå, óìíåå? è á) ìîæíî ëè ñäåëàòü îáùåñòâî ëó÷øå, ñïðàâåäëèâåå, ñâîáîäíåå?
 
;3) ñóùåñòâóåò 4 âîçìîæíûõ îòâåòà íà ýòè 2 âîïðîñà: (à+á+) èñòîðè÷åñêèé ìîäåðí, îí æå êîììóíèçì; (à+á-) àíòèèñòîðè÷åñêèé ìîäåðí, èëè ôàøèçì; (à-á+) ðåëèãèîçíûé ôóíäàìåíòàëèçì, èëè Êîíòðìîäåðí; è íàêîíåö (à-á-) öèíè÷íûé àíòèãóìàíèçì, îí æå Ïîñòìîäåðí.
 
;4) êðóøåíèå êîììóíèñòè÷åñêîãî ïðîåêòà â XX âåêå áûëî òùàòåëüíî ñïëàíèðîâàííîé êàòàñòðîôîé ñ öåëüþ ïîâîðîòà ÷åëîâå÷åñòâà ñ ìîäåðíèñòñêîãî ïóòè ðàçâèòèÿ íà ïîñòìîäåðíèñòñêèé ïóòü ðàñïàäà. Êóðãèíÿí çäåñü èìååò â âèäó êàòàñòðîôó â ìàòåìàòè÷åñêîì ñìûñëå, ò.å. íå êàêîå-òî ïå÷àëüíîå ñîáûòèå, à ïðîöåññ, ïðèâîäÿùèé ê òàêîìó ñîáûòèþ. ß íå õî÷ó ïåðåñêàçûâàòü çäåñü âñå ïîëîæåíèÿ òåîðèè êàòàñòðîô - âàæíî òîëüêî ïîíèìàòü, ÷òî òàêîé ïðîöåññ âîâñå íå îáÿçàòåëüíî äîëæåí ïðèâîäèòü ê ôàòàëüíîìó èñõîäó - âûõîä èç êàòàñòðîôû âñåãäà ìîæíî íàéòè, âïëîòü äî ñàìîãî ïîñëåäíåãî ìîìåíòà!
 
;5) êàòèòüñÿ ïî ýòîìó êàòàñòðîôè÷åñêîìó ïóòè ëåãêî, íî íàéòè âûõîä èç êàòàñòðîôû ñ êàæäûì øàãîì âñå ñëîæíåå. ×òîáû èçáåæàòü ôàòàëüíîãî êîíöà, îäíîé ýíåðãèè ìàëî - òðåáóåòñÿ èçðÿäíàÿ ñèëà âîëè.
 
;6) çäåñü Êóðãèíÿí ïîäêëþ÷àåò äðóãîé ìàòåìàòè÷åñêèé àïïàðàò - òåîðèþ èãð. È ïîêàçûâàåò, êàê øóëåðà - ìàãèñòðû ñëîæíîé êîàëèöèîííî-àíòàãîíèñòè÷åñêîé èãðû óìåþò öåëåíàïðàâëåííî è ýôôåêòèâíî ëèøàòü ïðîòèâíèêîâ âîëè è ñìûñëîâ äëÿ ïîèñêà âûõîäà èç êàòàñòðîôû.
 
;7) êîíå÷íî, ÷åëîâå÷åñêîå îáùåñòâî - ñëîæíåéøàÿ ñèñòåìà ñ íåïðåäñêàçóåìûì îòêëèêîì íà àêòèíûå äåéñòâèÿ êàæäîãî èç èãðîêîâ. Äàæå îïûòíåéøèé øóëåð ìîæåò çäåñü ñäåëàòü íåâåðíûå õîäû. Íî â ðàñïîðÿæåíèè ìàñòåðîâ èãðû èìååòñÿ åùå îäèí ìîùíûé àïïàðàò - ôàêòîðíûé àíàëèç, ïîçâîëÿþùèé ýôôåêòèâíî êîððåêòèðîâàòü ïðîìàõè è ëó÷øå ïðåäñêàçûâòü ïîâåäåíèå ñëîæíûõ ñèñòåì.
 
;8) è òåì íå ìåíåå, âûõîä åñòü! Äëÿ íà÷àëà, íàäî ðåàëüíî îñîçíàòü ñâîþ ïîçèöèþ â èãðå è íàâÿçàòü ñâîþ, àêòèâíóþ èãðó (êàæäûé íîâûé àêòèâíûé èãðîê óñëîæíÿåò ïàðòíåðàì àíàëèç èãðû). Ýòî ñëîæíî (ïðîùå áûòü áîëâàíîì), è ýòî òðåáóåò Âîëè è âîññîçäàíèÿ Ñìûñëîâ.
 
;9) äàæå ñàìàÿ àêòèâíàÿ èãðà áóäåò ïðîñòûì áàðàõòàíüåì, åñëè íå ñòàâèòñÿ êîíå÷íàÿ öåëü. Òàêàÿ öåëü åñòü. Òî÷íåå - áûëà: ïðîåêò (à+á+). Åñëè åå âîññòàíîâèòü, ìû íå ïðîñòî âåðíåìñÿ ê àêòèâíîé èãðå - ìû ìîæåì ñôîðìèðîâàòü ìîùíóþ êîàëèöèþ àíòèïîñòìîäåðíèñòîâ.
/kernel/branches/Kolibri-A/trunk/video/graph32.inc
51,26 → 51,21
mov eax, [img_map_x]
xor ecx, ecx
cmp bl, byte[ebp] ; check the left tile first
je .new_tile
bts ebx, 26 ; ebx[26] = 1 if edi/esi pushed
jz .new_tile
bts ebx, 26 ; ebx[26] = 1 if edi/esi already pushed
jc .seek_visible
push edi
push esi
push [img_bitoffset]
jmp .seek_visible
.new_tile:
inc ecx ; visible - scan the open space
cmp ecx, eax
jz .end_of_line
cmp bl, byte[ebp+ecx]
cmp bl, byte[ebp+ecx] ; overlapped? draw the visible segment if so
je .new_tile
; overlapped? draw the last visible segment if so
bts ebx, 26 ; check if edi/esi already pushed
jc @f
push edi
push esi
push [img_bitoffset]
@@: call [img_draw_core_fn] ; bpp-specific helper (see below)
 
call [img_draw_core_fn] ; bpp-specific helper (see below)
 
.seek_visible:
inc ecx
cmp ecx, eax
81,17 → 76,8
sub eax, ecx
shl ecx, 4
add edi, ecx ; shift the left edge
bt ebx, 25 ; 1bpp?
jc @f
shr ecx, 2
imul ecx, [img_bytes_per_pix]
jmp .new_visible
@@: shr ecx, 8 ; 2 tiles = 1 byte
jnc .new_visible
rol [img_bitoffset], 4
jnc .new_visible
inc ecx
.new_visible:
add esi, ecx
xor ecx, ecx
jmp .new_tile
102,7 → 88,6
.next_line:
bt ebx, 26
jnc @f
pop [img_bitoffset]
pop esi
pop edi
@@: inc edx
132,7 → 117,7
pushad
mov eax, [img_buf_line_size]
mov bh, dl ; store the 1st tile offset
btr ebx, 24 ; check if the 1st line odd
bt ebx, 24 ; check if the 1st line odd
jnc .new_tile
cmp bl, byte[ebp]
jne @f
143,6 → 128,7
add edi, [BytesPerScanLine]
add ebp, [_WinMapWidth]
add esi, eax
btr ebx, 24
.new_tile:
cmp bl, byte[ebp]
jne .skip_tile
180,18 → 166,6
; bh = edx = tile offset (0, 4, 8 or 12 bytes)
 
align 4
draw_edge_0bpp:
push eax
mov eax, [esi]
.putpix:
mov [edi+edx], eax
sub dl, 4
jae .putpix
.exit:
movzx edx, bh
pop eax
ret
align 4
draw_edge_32bpp:
push eax
.putpix:
200,7 → 174,7
sub dl, 4
jae .putpix
.exit:
movzx edx, bh
mov dl, bh
pop eax
ret
align 4
211,8 → 185,8
mov eax, [esi]
and eax, 0x00FFFFFF
mov [edi+edx], eax
cmp dl, bh
je .exit
test dl, bh
jz .exit
add dl, 4
add esi, 3
jmp .putpix
228,8 → 202,8
movzx eax, byte[esi]
mov eax, [ebp+eax*4]
mov [edi+edx], eax
cmp dl, bh
je .exit
test dl, bh
jz .exit
add dl, 4
inc esi
jmp .putpix
238,29 → 212,28
ret
align 4
draw_edge_1bpp:
pushad
movzx edx, bh
add edx, edi
push eax ecx ebx ebp
mov ebp, [img_palette]
mov ebx, [ebp+4] ; forecolor
mov ebp, [ebp] ; backcolor
mov ecx, [img_edgeoffset] ; cl = 1 << left_edge_pix_num
mov eax, [esi]
mov ebp, [esi]
xor dl, dl
.testbit:
test eax, ecx
test ebp, ecx
jnz @f
mov eax, ebp
jmp .putpix
@@: mov eax, ebx
.putpix:
mov [edi], eax
cmp edi, edx
je .exit
add edi, 4
rol ecx, 1
mov [edi+edx], eax
test dl, bh
jz .exit
add dl, 4
shl ecx, 1
jmp .testbit
.exit:
popad
pop ebp ebx ecx eax
ret
 
draw_edge_16bpp:
269,46 → 242,35
 
;-------------
; aligned core helpers
; esi -> left point address (buffer)
; esi -> left point address (image)
; edi -> left point address (screen)
; ecx = number of tiles to draw
; cx = number of tiles to draw
align 4
draw_core_0bpp:
push eax ecx edi
pushfd
; cli
cld
mov eax, [esi]
shl ecx, 2
rep stosd
popfd
pop edi ecx eax
ret
align 4
draw_core_32bpp:
push ecx esi edi
pushfd
; cli
cld
shl ecx, 2
rep movsd
popfd
pop edi esi ecx
push ecx
shl ecx, 1
dec ecx
.putpix:
fld qword[esi+ecx*8] ; 2 qwords = 1 tile
fstp qword[edi+ecx*8]
dec cx
jnb .putpix
pop ecx
ret
align 4
draw_core_24bpp:
push eax ecx edx
shl ecx, 2 ; ecx = numpixels
push eax ecx
shl ecx, 2
dec ecx
lea edx, [ecx*2+ecx] ; edx = buffer byte offset
lea eax, [ecx*2+ecx]
.putpix:
mov eax, [esi+edx]
mov eax, [esi+eax]
and eax, 0x00FFFFFF
mov [edi+ecx*4], eax
dec ecx
sub edx, 3
sub dx, 3
dec cx
jnb .putpix
pop edx ecx eax
pop ecx eax
ret
align 4
draw_core_8bpp:
327,7 → 289,7
jnz .putone
add esi, edx ;-)
add edi, 16
dec ecx
dec cx
jnz .putpix
.exit:
popad
340,6 → 302,8
mov ebp, [ebp] ; background color
mov ebx, [img_bitoffset]
shl ecx, 2 ; 1 tyle = 4 pix
dec ecx
jb .exit
.newblock:
mov eax, [esi]
.putpix:
350,8 → 314,8
.bkcolor:
mov [edi], ebp
.nextpix:
dec ecx
jz .exit
dec cx
jb .exit
rol ebx, 1
jc .nextblock
add edi, 4
375,10 → 339,6
; ebx -> Buffer origin
; ecx = packed size [x|y]
; edx = packed coordinates [x|y]
; static variables required:
; [img_draw_core_fn], [img_draw_edge_fn]
; [img_bytes_per_pix], [img_buf_line_size]
; [img_palette] (1bpp and 8bpp only)
 
_putimage:
; call [_display.disable_mouse]
396,15 → 356,14
and edx, 0xFFFF ; Ytop
shr eax, 16 ; Xleft
.calculate_abs_coords:
mov edi, [TASK_BASE]
mov ebx, [edi-twdw + WDATA.box.left]
mov ecx, [edi-twdw + WDATA.box.top]
mov ebx, [TASK_BASE-twdw + WDATA.box.left]
mov ecx, [TASK_BASE-twdw + WDATA.box.top]
add ebx, eax
add ecx, edx
mov [img_screen_x], ebx ; abs Xleft
; mov [img_screen_y], ecx ; ecx = abs Ytop ; hold it !
.check_x_size:
mov ebx, [edi-twdw + WDATA.box.width]
mov ebx, [TASK_BASE-twdw + WDATA.box.width]
inc ebx ; ebx = window Xsize
sub ebx, eax ; eax = rel Xleft
jbe .finish ; image is out of the window
415,7 → 374,7
@@: dec eax
mov [img_pix_x], eax
.check_y_size:
mov ebx, [edi-twdw + WDATA.box.height]
mov ebx, [TASK_BASE-twdw + WDATA.box.height]
inc ebx ; ebx = real window y-size
sub ebx, edx ; edx = rel Ytop
jbe .finish ; image isn't visible
437,9 → 396,6
mov bl, byte [img_bytes_per_pix]
or bl, bl
jnz @f
mov ecx, [img_buf_line_size]
or cl, cl
je @f
bts ebx, 25
@@: mov bl, byte [CURRENT_TASK] ; get process number
mov ebp, ecx ; ecx = absY
451,10 → 407,9
mov ecx, eax ; eax = absX
shr ecx, 2
add eax, [img_pix_x]
inc eax
shr eax, 2
add eax, ebp
; mov [img_map_right], eax ; right edge tile
mov [img_map_right], eax ; right edge tile
add ebp, ecx ; left edge Map origin
mov ecx, [img_pix_y]
sub eax, ebp
467,8 → 422,8
; ebp -> corner tile position
; ecx = [img_pix_y] = image height
; bl = task #
; ebx[24] = 1 if Ytop is odd
; ebx[25] = 1 if 1bpp image
; ebx[24] = 1 if the core Y is odd
; ebx[25] = 1bpp image
 
.start:
bt ebx, 25
479,10 → 434,10
mov [img_edgeoffset], eax
@@:
mov edx, edi
mov dh, 0x0C
and dl, dh
and edx, 0x0C
jz .go_right ; left edge already aligned
.left_edge:
mov dh, 0x0C
sub dh, dl
movzx edx, dh
call draw_unaligned_edge
526,19 → 481,19
mov eax, [img_pix_x]
shl eax, 2 ; 1 pix = 4 bytes
add eax, edi ; rightEdge last pix (LFB addr)
shl edx, 4
add edi, edx ; rightEdge Screen origin
movzx edx, al
mov eax, [img_map_x]
and dl, 0x0C
cmp dl, 0x0C
je .core_block ; rightEdge is already tile-aligned
jz .core_block ; rightEdge is already tile-aligned
and al, 0xF0
mov edi, eax ; rightEdge Screen origin
.right_edge:
call draw_unaligned_edge
dec [img_map_x]
.core_block:
pop ebp
mov eax, [img_map_x]
or eax, eax ; empty central core?
jz .finish
mov ebp, [esp]
mov edi, [img_lfb_origin]
mov esi, [img_buf_origin]
545,7 → 500,7
call draw_aligned_box
.finish:
add esp, (putimg.stack_data + 4)
add esp, putimg.stack_data
; call [_display.enable_mouse]
popad
ret
554,81 → 509,19
mov edx, [img_pix_x]
shl edx, 2 ; edx = rightmost tile offset (0, 4, 8, or 12 bytes)
call draw_unaligned_edge
add esp, putimg.stack_data
popad
ret
jmp .finish
 
 
;align 64
;img_test_struct_32: ; 8 x 10
; dd 0x112233, 0x223344, 0x334455, 0x445566, 0x556677, 0x667788, 0x778899, 0x887766
; dd 0x223344, 0x334455, 0x445566, 0x556677, 0x667788, 0x777799, 0x887766, 0x997755
; dd 0x334455, 0x445566, 0x556677, 0x667788, 0x777799, 0x887766, 0x997755, 0xAA7744
; dd 0x445566, 0x556677, 0x667788, 0x777799, 0x887766, 0x997755, 0xAA7744, 0xBB7733
; dd 0x334455, 0x445566, 0x556677, 0x667788, 0x777799, 0x887766, 0x997755, 0xAA7744
; dd 0x223344, 0x334455, 0x445566, 0x556677, 0x667788, 0x777799, 0x887766, 0x997755
; dd 0x112233, 0x223344, 0x334455, 0x445566, 0x556677, 0x667788, 0x777799, 0x887766
; dd 0x001122, 0x112233, 0x223344, 0x334455, 0x445566, 0x556677, 0x667788, 0x777799
; dd 0x220000, 0x001122, 0x112233, 0x223344, 0x334455, 0x445566, 0x556677, 0x667788
; dd 0x441100, 0x220000, 0x001122, 0x112233, 0x223344, 0x334455, 0x445566, 0x556677
align 64
img_test_struct:
dd 0x00112233, 0x00223344, 0x00334455, 0x00445566
dd 0x00223344, 0x00334455, 0x00445566, 0x00334455
dd 0x00334455, 0x00445566, 0x00334455, 0x00223344
dd 0x00445566, 0x00334455, 0x00223344, 0x00112233
 
;align 64
;img_test_struct_24: ; 8 x 16
; dw 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211, 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB
; dw 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB, 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211
; dw 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211, 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB
; dw 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB, 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211
; dw 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211, 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB
; dw 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB, 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211
; dw 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211, 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB
; dw 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB, 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211
; dw 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211, 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB
; dw 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB, 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211
; dw 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211, 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB
; dw 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB, 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211
; dw 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211, 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB
; dw 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB, 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211
; dw 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211, 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB
; dw 0xBBAA, 0xAACC, 0xCCBB, 0xBBAA, 0xAACC, 0xCCBB, 0x1100, 0x0022, 0x2211, 0x1100, 0x0022, 0x2211
 
;align 64
;img_test_struct_8: ; 20 x 10
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
; db 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0
 
;align 64
;img_test_struct_1: ; 16 x 10
; db 0x0F, 0xF0
; db 0x0F, 0xF0
; db 0x3C, 0xC3
; db 0x3C, 0xC3
; db 0xF0, 0x0F
; db 0xF0, 0x0F
; db 0x3C, 0xC3
; db 0x3C, 0xC3
; db 0x0F, 0xF0
; db 0x0F, 0xF0
 
;align 64
;img_test_palette: ; 6 colors
; dd 0x00BB2233, 0xAA4466, 0x995555, 0x00339966, 0x00884455, 0x00775566, 0x00664455, 0x00553344, 0x0
 
;**************************************************************************************
align 4
__sys_putpixel:
push edx
mov edx, [TASK_BASE]
add eax, [edx-twdw+WDATA.box.left]
add ebx, [edx-twdw+WDATA.box.top]
pop edx
_putpixel:
 
; eax = x coordinate
646,13 → 539,14
 
.not_forced:
push ebx eax
shr eax, 2
shr eax, 1
shr eax, 1
shr ebx, 1
imul ebx, [_WinMapWidth] ; win_map (X size)/2
add ebx, eax
mov al, byte [CURRENT_TASK]
mov ah, byte [_WinMapAddress+ebx]
cmp ah, al
mov bl, byte [_WinMapAddress+ebx]
cmp bl, al
pop eax ebx
jne .exit0
.checked:
671,15 → 565,15
 
 
 
;align 4
;_put_pixel: ; left for compatibility with Vesa20_putpixel32
;; eax = x
;; ebx = y
; 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
; mov [LFB_BASE+edi], ecx
; ret
align 4
put_pixel: ; left for compatibility with Vesa20_putpixel32
; eax = x
; ebx = y
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
mov [LFB_BASE+edi], ecx
ret
 
 
; DRAWLINE
854,7 → 748,7
mov ecx, [ebp] ; check the line segment (16 pixels!)
xor ecx, [CURRENT_TASK]
; -- the line ---
jmp dword [hline.drawtable + edi*4] ; (C) Serge, 2010
jmp dword [hline.drawtable + edi*4] ; a coolhack (C) Serge
 
 
align 4 ; internal loop
991,71 → 885,236
;*************************************************
 
 
virtual at esp
drbar:
.bar_sx dd ?
.bar_sy dd ?
.bar_cx dd ?
.bar_cy dd ?
.abs_cx dd ?
.abs_cy dd ?
.real_sx dd ?
.real_sy dd ?
.color dd ?
.line_inc_scr dd ?
.line_inc_map dd ?
.stack_data = 4*11
end virtual
 
align 4
; eax xOrigin
; ebx yOrigin
; ecx xSize
; edx ySize
; eax cx
; ebx cy
; ecx xe
; edx ye
; edi color
 
_drawbar:
vesa20_drawbar:
pushad
sub esp, putimg.stack_data
mov [img_bytes_per_pix], 0
mov [img_buf_line_size], 0
mov [img_draw_core_fn], draw_core_0bpp
mov [img_draw_edge_fn], draw_edge_0bpp
mov [putimg.image_sx], ecx
mov [putimg.image_sy], edx
mov edx, ebx
mov [img_palette], edi
mov esi, img_palette
mov [img_buf_origin], esi
call [_display.disable_mouse]
sub esp, drbar.stack_data
mov [drbar.color], edi
sub edx, ebx
jle .exit
sub ecx, eax
jle .exit
mov [drbar.bar_sy], edx
mov [drbar.bar_sx], ecx
mov [drbar.bar_cx], eax
mov [drbar.bar_cy], ebx
mov edi, [TASK_BASE]
add eax, [edi-twdw + WDATA.box.left] ; win_cx
add ebx, [edi-twdw + WDATA.box.top] ; win_cy
mov [drbar.abs_cx], eax
mov [drbar.abs_cy], ebx
; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
mov ebx, [edi-twdw + WDATA.box.width] ; ebx = wnd_sx
; note that WDATA.box.width is one pixel less than real window x-size
inc ebx
sub ebx, [drbar.bar_cx]
ja @f
.exit:
add esp, drbar.stack_data
popad
xor eax, eax
inc eax
ret
@@:
cmp ebx, [drbar.bar_sx]
jbe .end_x
mov ebx, [drbar.bar_sx]
.end_x:
mov [drbar.real_sx], ebx
; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
mov ebx, [edi-twdw + WDATA.box.height] ; ebx = wnd_sy
inc ebx
sub ebx, [drbar.bar_cy]
ja @f
add esp, drbar.stack_data
popad
xor eax, eax
inc eax
ret
@@:
cmp ebx, [drbar.bar_sy]
jbe .end_y
mov ebx, [drbar.bar_sy]
.end_y:
mov [drbar.real_sy], ebx
; line_inc_map
mov eax, [Screen_Max_X]
sub eax, [drbar.real_sx]
inc eax
shr eax, 1 ; <<<<<<
shr eax, 1
mov [drbar.line_inc_map], eax ; vertical increment: map
; line_inc_scr
mov eax, [drbar.real_sx]
shl eax, 1
shl eax, 1
neg eax
add eax, [BytesPerScanLine]
mov [drbar.line_inc_scr], eax ; vertical increment: screen
; pointer to screen
mov edx, [drbar.abs_cy]
mov ebx, edx
imul edx, [BytesPerScanLine] ; edx = LFB line offset
mov eax, [drbar.abs_cx]
shl eax, 1
shl eax, 1
add edx, eax ; edx = LFB corner offset
; pointer to pixel map
shr ebx, 1
imul ebx, [_WinMapWidth] ; eax = Wmap corner pos
mov eax, [drbar.abs_cx]
shr eax, 1
shr eax, 1
add eax, ebx
add eax, [_WinMapAddress]
xchg eax, ebp ; ebp = Wmap corner
; get process number
mov ebx, [CURRENT_TASK]
 
jmp _putimage.calculate_abs_coords
; ret
; eax - RGB-color
; bl - process num
; ecx - pix counter (in a tile)
; edx - pointer to screen
; esi - counter
; edi - counter
 
mov eax, [drbar.color] ;; BBGGRR00
mov esi, 0
align 4
.new_y:
mov edi, [drbar.real_sx]
movzx ecx, dl
shr cl, 2 ; pix# = edx/4
and cl, 3 ; pix position in a tile
.new_tile:
cmp byte [ebp], bl
jne .skip
.new_x:
mov [LFB_BASE+edx], eax
add edx, 4
dec edi
jz .add_line
inc cl
and cl, 3
jnz .new_x
jmp .new_tile
.skip:
add edx, 4*4
and dl, 0xF0 ; LFB align 16
inc ebp
sub edi, 4 ; <<<<<
add edi, ecx ; left tile may be 1,2 or 3px only
jae .new_tile
 
draw_background:
.add_line:
add edx, [drbar.line_inc_scr]
; gradient-filled bars
test eax, 0x80000000
jz @f
test al, al
jz @f
dec al
@@:
inc esi
test esi, 1
jne @f
add ebp, [drbar.line_inc_map]
@@:
cmp esi, [drbar.real_sy]
jbe .new_y
add esp, drbar.stack_data
popad
xor eax, eax
ret
 
 
align 4
;drawbackground:
call [_display.disable_mouse]
pushad
pushfd
cld ; increment edi here!
mov ebp, [_WinMapAddress]
mov eax, 0x00337766 ; bgndcolor
mov bl, 1
mov edx, [Screen_Max_X]
; External loop for all y from start to end
mov ebx, [draw_data+32+RECT.top] ; y start
.fill_line:
mov edi, [draw_data+32+RECT.left] ; x start
shl edi, 1
shl edi, 1
mov eax, [BytesPerScanLine]
mul ebx
xchg edi, eax
add edi, eax
add edi, LFB_BASE
 
mov ebp, ebx
shr ebp, 1
imul ebp, [_WinMapWidth]
mov edx, eax
shr edx, 1
mov edi, LFB_BASE
mov esi, [BytesPerScanLine]
.new_row:
xor ecx, ecx
.fill:
cmp byte [ebp+ecx], bl
jne .next
shr edx, 1
add ebp, edx
add ebp, [_WinMapAddress]
xor edx, edx
inc edx
mov esi, 0x0336677 ; <<< RGB
; eax = x, ebx = y (screen coordinates)
; ecx - aux. var
; edx = 1
; esi = 0RGB, edi -> output
; ebp = offset in WinMapAddress
.fill_tile:
cmp [ebp], dl
jnz .next_tile
mov [edi], esi
mov [edi+4], esi
mov [edi+8], esi
mov [edi+12],esi
mov ecx, [BytesPerScanLine]
mov [ecx+edi], esi
mov [ecx+edi+4], esi
mov [ecx+edi+8], esi
mov [ecx+edi+12],esi
.next_tile:
add edi, 4*4
add ebp, edx
add ax, 4
mov ecx, [draw_data+32+RECT.right]
shr ecx, 1
shr ecx, 1
cmp eax, ecx
jbe .fill_tile
mov [edi+esi], eax ; fill all 8 pixels of this tile
stosd
mov [edi+esi], eax
stosd
mov [edi+esi], eax
stosd
mov [edi+esi], eax
stosd
.next: inc ecx
cmp ecx, [_WinMapWidth]
jb .fill
dec edx
jz .done
add ebp, ecx ; += [_WinMapWidth]
add edi, esi ; += [BytesPerScanLine]
jmp .new_row
.done:
popfd
.next_line:
inc ebx
mov ecx, [draw_data+32+RECT.bottom]
shr ecx, 1
jbe .fill_line
popad
ret
 
; ----------
 
 
drawbackground_stretch: ; left for future development
call drawbackground
ret
1069,27 → 1128,109
bgr_next_line rd 1920
endg
 
smooth_line:
mov al, [esi+2]
shl eax, 16
mov ax, [esi]
test ecx, ecx
jz @f
mov ebx, [esi+2]
shr ebx, 8
call [overlapping_of_points_ptr]
@@:
stosd
mov eax, [esp+20+8]
inc eax
mov [esp+20+8], eax
cmp eax, [draw_data+32+RECT.right]
ja @f
add ecx, [esp+36+8]
mov eax, edx
adc edx, [esp+40+8]
sub eax, edx
lea eax, [eax*3]
sub esi, eax
jmp smooth_line
@@:
mov eax, [draw_data+32+RECT.left]
mov [esp+20+8], eax
ret
 
_init_background:
; mov edi, BgrAuxTable
; xor edx, edx
;.loop2:
; mov eax, edx
; shl eax, 8
; neg eax
; mov ecx, 0x200
;.loop1:
; mov byte [edi], ah
; inc edi
; add eax, edx
; loop .loop1
; add dl, 4
; jnz .loop2
mov byte [REDRAW_BACKGROUND], 1
; mov dword[BgrAuxTable], 0x00337766
align 16
overlapping_of_points:
push ecx edx
mov edx, eax
push esi
shr ecx, 26
mov esi, ecx
mov ecx, ebx
shl esi, 9
movzx ebx, dl
movzx eax, cl
sub eax, ebx
movzx ebx, dh
add dl, [BgrAuxTable+(eax+0x100)+esi]
movzx eax, ch
sub eax, ebx
add dh, [BgrAuxTable+(eax+0x100)+esi]
ror ecx, 16
ror edx, 16
movzx eax, cl
movzx ebx, dl
sub eax, ebx
add dl, [BgrAuxTable+(eax+0x100)+esi]
pop esi
mov eax, edx
pop edx
ror eax, 16
pop ecx
ret
 
iglobal
align 4
overlapping_of_points_ptr dd overlapping_of_points
endg
 
init_background:
mov edi, BgrAuxTable
xor edx, edx
.loop2:
mov eax, edx
shl eax, 8
neg eax
mov ecx, 0x200
.loop1:
mov byte [edi], ah
inc edi
add eax, edx
loop .loop1
add dl, 4
jnz .loop2
test byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
jz @f
mov [overlapping_of_points_ptr], overlapping_of_points_mmx
@@:
ret
 
align 16
overlapping_of_points_mmx:
movd mm0, eax
movd mm4, eax
movd mm1, ebx
pxor mm2, mm2
punpcklbw mm0, mm2
punpcklbw mm1, mm2
psubw mm1, mm0
movd mm3, ecx
psrld mm3, 24
packuswb mm3, mm3
packuswb mm3, mm3
pmullw mm1, mm3
psrlw mm1, 8
packuswb mm1, mm2
paddb mm4, mm1
movd eax, mm4
ret
diff16 "GRAPH32 code end ",0,$
diff10 "GRAPH32 code size",get_pixel,$
 
/kernel/branches/Kolibri-A/trunk/const.inc
85,7 → 85,7
CAPS_SYSCAL equ 64 ;
CAPS_XD equ 65 ;execution disable
CAPS_FFXSR equ 66 ;
CAPS_RDTSCP equ 67 ; not used anywhere
CAPS_RDTSCP equ 67 ;
CAPS_X64 equ 68 ;
CAPS_3DNOW equ 69 ;
CAPS_3DNOWEXT equ 70 ;
197,7 → 197,7
mouseunder equ (OS_BASE+0x0006900)
CDDataBuf equ (OS_BASE+0x0007000)
FLOPPY_BUFF equ (OS_BASE+0x0008000)
;ACTIVE_PROC_STACK equ (OS_BASE+0x000A400) ;unused
ACTIVE_PROC_STACK equ (OS_BASE+0x000A400) ;unused
idts equ (OS_BASE+0x000B100)
WIN_STACK equ (OS_BASE+0x000C000)
WIN_POS equ (OS_BASE+0x000C400)
204,16 → 204,16
FDD_BUFF equ (OS_BASE+0x000D000)
 
;unused ? only one reference
;ENABLE_TASKSWITCH equ (OS_BASE+0x000E000)
ENABLE_TASKSWITCH equ (OS_BASE+0x000E000)
 
;PUTPIXEL equ (OS_BASE+0x000E020)
;GETPIXEL equ (OS_BASE+0x000E024)
PUTPIXEL equ (OS_BASE+0x000E020)
GETPIXEL equ (OS_BASE+0x000E024)
 
;unused ? only one reference
; BANK_SWITCH equ (OS_BASE+0x000E030) ; VESA 1.2 - not used
BANK_SWITCH equ (OS_BASE+0x000E030)
 
;unused ? store mousepointer
;MOUSE_PICTURE equ (OS_BASE+0x000F200) ; mousedrv.inc - not used
MOUSE_PICTURE equ (OS_BASE+0x000F200)
 
MOUSE_VISIBLE equ (OS_BASE+0x000F204)
WIN_TEMP_XY equ (OS_BASE+0x000F300)
/kernel/branches/Kolibri-A/trunk/memmap.inc
67,9 → 67,9
;
; 6F00 -> 6FFF free (256)
;
; 7000 -> 7FFF unused? CD driver (4k)
; 7000 -> 7FFF used CD driver
;
; 8000 -> A3FF used? FLOPPY driver (4k)
; 8000 -> A3FF used FLOPPY driver
;
; A400 -> B0FF free (3k3), unused ACTIVE_PROC_STACK
 
143,14 → 143,14
;
; 0x80010000 -> 6CBFF kernel, 32-bit run-time code (up to 371 Kb)
; in the current version:
; -> 00B3C 16-bit code end
; -> 00B37 16-bit code end
; -> 00C40 16-bit data end
; -> 10C40 32-bit code start
; -> 2D07E 32-bit code end
; -> 30418..end_of_kernel zero-filled zone after preinit_mem
; -> 33D63 uninitialized globals start
; -> 3BF52 end_of_kernel
; -> 3C000 not used (>200k)
; -> 2D582 32-bit code end
; -> 30918..end_of_kernel zero-filled zone after preinit_mem
; -> 3421B uninitialized globals start
; -> 3C40A end_of_kernel
; -> 3D000 not used (194k)
; 0x80050000 -> 090000 zero-filled zone after preinit_mem
; 0x8006CC00 -> 6DBFF stack at boot time (4Kb)
;