From 15170454cc58404d65dd18834edd4759ce5dcf0f Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Fri, 19 Jan 2007 03:58:46 +0000 Subject: [PATCH] imports header kernel objects segmented sound buffers git-svn-id: svn://kolibrios.org@281 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/const.inc | 32 +- kernel/trunk/core/dll.inc | 57 +- kernel/trunk/core/exports.inc | 76 +- kernel/trunk/core/heap.inc | 3 +- kernel/trunk/core/memory.inc | 21 +- kernel/trunk/core/taskman.inc | 33 +- kernel/trunk/drivers/ati2d.asm | 105 ++- kernel/trunk/drivers/infinity.asm | 86 +-- kernel/trunk/drivers/main.inc | 9 +- kernel/trunk/drivers/mixer.asm | 1097 ++++++++++++++-------------- kernel/trunk/drivers/sceletone.asm | 22 +- kernel/trunk/drivers/sis.asm | 17 +- kernel/trunk/drivers/unisound.asm | 16 +- kernel/trunk/hid/mousedrv.inc | 4 +- kernel/trunk/kernel.asm | 20 +- kernel/trunk/kernel32.inc | 4 +- kernel/trunk/video/cursors.inc | 207 +++--- 17 files changed, 939 insertions(+), 870 deletions(-) diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index 6ab71e607e..b91a305336 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -312,19 +312,39 @@ struc SYS_VARS dd ? } +struc APPOBJ ;common object header +{ + .magic dd ? ; + .destroy dd ? ;internal destructor + .fd dd ? ;next object in list + .bk dd ? ;prev object in list + .pid dd ? ;owner id +}; + +virtual at 0 + APPOBJ APPOBJ +end virtual + +APP_OBJ_OFFSET equ 48 + struc CURSOR -{ .magic dd ? - .size dd ? - .pid dd ? - .base dd ? - .hot_x dd ? +{;common object header + .magic dd ? ;'CURS' + .destroy dd ? ;internal destructor + .fd dd ? ;next object in list + .bk dd ? ;prev object in list + .pid dd ? ;owner id + + ;cursor data + .base dd ? ;allocated memory + .hot_x dd ? ;hotspot coords .hot_y dd ? } virtual at 0 CURSOR CURSOR end virtual -CURSOR_SIZE equ 24 +CURSOR_SIZE equ 32 struc BOOT_DATA { .bpp dd ? diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index 5dc6f2937c..d3bd59d72d 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -1,8 +1,8 @@ DRV_ENTRY equ 1 DRV_EXIT equ -1 -DRV_COMPAT equ 1 ;minimal required drivers version -DRV_CURRENT equ 1 ;current drivers model version +DRV_COMPAT equ 2 ;minimal required drivers version +DRV_CURRENT equ 2 ;current drivers model version DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT @@ -371,10 +371,10 @@ reg_service: mov ecx, [.handler] mov [eax+SRV.srv_proc], ecx - ret + ret 8 .fail: xor eax, eax - ret + ret 8 align 4 proc get_proc stdcall, exp:dword, sz_name:dword @@ -965,7 +965,6 @@ proc load_library stdcall, file_name:dword ret endp - align 4 proc stop_all_services @@ -987,6 +986,54 @@ proc stop_all_services ret endp +; param +; eax= pid +; ebx= size + +align 4 +create_kernel_object: + + push ebx + call malloc + pop ebx + test eax, eax + jz .fail + + mov ecx,[CURRENT_TASK] + shl ecx,8 + add ecx, PROC_BASE+APP_OBJ_OFFSET + + mov edx, [ecx+APPOBJ.fd] + mov [eax+APPOBJ.fd], edx + mov [eax+APPOBJ.bk], ecx + mov [eax+APPOBJ.pid], ebx + + mov [ecx+APPOBJ.fd], eax + mov [edx+APPOBJ.bk], eax +.fail: + ret + +; param +; eax= object + +align 4 +destroy_kernel_object: + + mov ebx, [eax+APPOBJ.fd] + mov ecx, [eax+APPOBJ.bk] + mov [ebx+APPOBJ.bk], ecx + mov [ecx+APPOBJ.fd], ebx + + xor edx, edx ;clear common header + mov [eax], edx + mov [eax+4], edx + mov [eax+8], edx + mov [eax+12], edx + mov [eax+16], edx + + call free ;release object memory + ret + drv_sound db '/rd/1/drivers/unisound.obj', 0 drv_infinity db '/rd/1/drivers/infinity.obj', 0 diff --git a/kernel/trunk/core/exports.inc b/kernel/trunk/core/exports.inc index 0284072fe6..f0269eb5cb 100644 --- a/kernel/trunk/core/exports.inc +++ b/kernel/trunk/core/exports.inc @@ -2,54 +2,94 @@ iglobal szKernel db 'KERNEL', 0 szVersion db 'version',0 + + szRegService db 'RegService',0 + szGetService db 'GetService',0 + szServiceHandler db 'ServiceHandler',0 szAttachIntHandler db 'AttachIntHandler',0 - szSysMsgBoardStr db 'SysMsgBoardStr', 0 + szFpuSave db 'FpuSave',0 + szFpuRestore db 'FpuRestore',0 + szPciApi db 'PciApi', 0 szPciRead32 db 'PciRead32', 0 szPciRead8 db 'PciRead8', 0 szPciWrite8 db 'PciWrite8',0 - szAllocKernelSpace db 'AllocKernelSpace',0 + + szAllocPage db 'AllocPage',0 + szAllocPages db 'AllocPages',0 + szFreePage db 'FreePage',0 + szGetPgAddr db 'GetPgAddr',0 szMapPage db 'MapPage',0 - szRegService db 'RegService',0 + szMapSpace db 'MapSpace',0 + szCommitPages db 'CommitPages',0 + szReleasePages db 'ReleasePages',0 + + szAllocKernelSpace db 'AllocKernelSpace',0 + szFreeKernelSpace db 'FreeKernelSpace',0 szKernelAlloc db 'KernelAlloc',0 szKernelFree db 'KernelFree',0 - szGetPgAddr db 'GetPgAddr',0 - szGetCurrentTask db 'GetCurrentTask',0 - szGetService db 'GetService',0 - szServiceHandler db 'ServiceHandler',0 - szFpuSave db 'FpuSave',0 - szFpuRestore db 'FpuRestore',0 + szUserAlloc db 'UserAlloc',0 + szUserFree db 'UserFree',0 + szKmalloc db 'Kmalloc',0 + szKfree db 'Kfree',0 + + szCreateObject db 'CreateObject',0 + szDestroyObject db 'DestroyObject',0 + szLoadCursor db 'LoadCursor',0 szSetHwCursor db 'SetHwCursor',0 szHwCursorRestore db 'HwCursorRestore', 0 szHwCursorCreate db 'HwCursorCreate', 0 + + szSysMsgBoardStr db 'SysMsgBoardStr', 0 + szGetCurrentTask db 'GetCurrentTask',0 szLFBAddress db 'LFBAddress',0 szLoadFile db 'LoadFile',0 szSendEvent db 'SendEvent',0 + align 16 kernel_export: + dd szRegService , reg_service + dd szGetService , get_service + dd szServiceHandler , srv_handler dd szAttachIntHandler, attach_int_handler - dd szSysMsgBoardStr , sys_msg_board_str + dd szFpuSave , fpu_save + dd szFpuRestore , fpu_restore + dd szPciApi , pci_api dd szPciRead32 , pci_read32 dd szPciRead8 , pci_read8 dd szPciWrite8 , pci_write8 - dd szAllocKernelSpace, alloc_kernel_space + + dd szAllocPage , alloc_page + dd szAllocPages , alloc_pages + dd szFreePage , free_page dd szMapPage , map_page - dd szRegService , reg_service + dd szMapSpace , map_space + dd szGetPgAddr , get_pg_addr + dd szCommitPages , commit_pages ;not implemented + dd szReleasePages , release_pages + + dd szAllocKernelSpace, alloc_kernel_space + dd szFreeKernelSpace , free_kernel_space dd szKernelAlloc , kernel_alloc dd szKernelFree , kernel_free - dd szGetPgAddr , get_pg_addr - dd szGetCurrentTask , get_curr_task - dd szGetService , get_service - dd szServiceHandler , srv_handler - dd szFpuSave , fpu_save - dd szFpuRestore , fpu_restore + dd szUserAlloc , user_alloc + dd szUserFree , user_free + dd szKmalloc , malloc + dd szKfree , free + + dd szCreateObject , create_kernel_object + dd szDestroyObject , destroy_kernel_object + dd szLoadCursor , load_cursor dd szSetHwCursor , set_hw_cursor dd szHwCursorRestore , hw_restore dd szHwCursorCreate , create_cursor + + dd szSysMsgBoardStr , sys_msg_board_str + dd szGetCurrentTask , get_curr_task dd szLoadFile , load_file dd szSendEvent , send_event exp_lfb: diff --git a/kernel/trunk/core/heap.inc b/kernel/trunk/core/heap.inc index 4d9c76391c..9c85769263 100644 --- a/kernel/trunk/core/heap.inc +++ b/kernel/trunk/core/heap.inc @@ -578,7 +578,7 @@ proc kernel_free stdcall, base:dword and [heap_mutex], 0 mov ecx, [esi+block_size]; - + shr ecx, 12 call release_pages ;eax, ecx stdcall free_kernel_space, [base] ret @@ -643,7 +643,6 @@ proc user_alloc stdcall, alloc_size:dword mov edi, dword [ebx+PROC_BASE+APPDATA.heap_top]; heap_top add esi, new_app_base add edi, new_app_base - l_0: cmp esi, edi jae m_exit diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index ff1d2ca868..c76ac4d164 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -242,6 +242,13 @@ proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword ret endp +align 4 +map_space: ;not implemented + + + ret + + align 4 proc free_page ;arg: eax page address @@ -265,8 +272,19 @@ proc free_page endp ; param -; ecx= size +; eax= page base +; ebx= liear address +; ecx= count + +align 4 +commit_pages: ;not implemented + + + ret + +; param ; eax= base +; ecx= count align 4 release_pages: @@ -274,7 +292,6 @@ release_pages: mov ebx, pg_data.pg_mutex call wait_mutex ;ebx - shr ecx, 12 mov esi, eax mov edi, eax diff --git a/kernel/trunk/core/taskman.inc b/kernel/trunk/core/taskman.inc index aac9384cc7..bf104e2f7a 100644 --- a/kernel/trunk/core/taskman.inc +++ b/kernel/trunk/core/taskman.inc @@ -996,16 +996,20 @@ proc set_app_params stdcall,slot:dword, params:dword,\ @@: rep movsd - mov ebx,[slot] - cmp ebx,[TASK_COUNT] - jle .noinc - inc dword [TASK_COUNT] ;update number of processes + mov ebx,[slot] + cmp ebx,[TASK_COUNT] + jle .noinc + inc dword [TASK_COUNT] ;update number of processes .noinc: - shl ebx,8 - mov ecx, [def_cursor] - mov [PROC_BASE+APPDATA.cursor+ebx],ecx + shl ebx,8 + lea edx, [ebx+PROC_BASE+APP_OBJ_OFFSET] + mov [PROC_BASE+APPDATA.fd_obj+ebx],edx + mov [PROC_BASE+APPDATA.bk_obj+ebx],edx - shr ebx,3 + mov ecx, [def_cursor] + mov [PROC_BASE+APPDATA.cursor+ebx],ecx + + shr ebx,3 mov eax, new_app_base mov dword [CURRENT_TASK+ebx+0x10],eax @@ -1014,11 +1018,14 @@ proc set_app_params stdcall,slot:dword, params:dword,\ mov edx,[edx] ;app_cmdline test edx,edx jz @F ;application don't need parameters - mov eax, edx - add eax, 256 - jc @f - cmp eax, [PROC_BASE+APPDATA.mem_size+ebx*8] - ja @f + + mov eax, edx + add eax, 256 + jc @f + + cmp eax, [PROC_BASE+APPDATA.mem_size+ebx*8] + ja @f + add edx, new_app_base stdcall k_strncpy, edx, [cmd_line], 256 @@: diff --git a/kernel/trunk/drivers/ati2d.asm b/kernel/trunk/drivers/ati2d.asm index ffa4afdd19..f74d0ea76c 100644 --- a/kernel/trunk/drivers/ati2d.asm +++ b/kernel/trunk/drivers/ati2d.asm @@ -2,6 +2,7 @@ format MS COFF include 'proc32.inc' +include 'imports.inc' DEBUG equ 1 @@ -33,18 +34,23 @@ virtual at 0 end virtual struc CURSOR -{ .magic dd ? - .size dd ? - .pid dd ? - .base dd ? - .hot_x dd ? +{;common object header + .magic dd ? ;'CURS' + .destroy dd ? ;internal destructor + .fd dd ? ;next object in list + .bk dd ? ;prev object in list + .pid dd ? ;owner id + + ;cursor data + .base dd ? ;allocated memory + .hot_x dd ? ;hotspot coords .hot_y dd ? } virtual at 0 CURSOR CURSOR end virtual -CURSOR_SIZE equ 24 +CURSOR_SIZE equ 32 R8500 equ 0x514C ;R200 R9000 equ 0x4966 ;RV250 @@ -155,18 +161,6 @@ public START public service_proc public version -extrn SysMsgBoardStr -extrn PciApi -extrn PciRead32 -extrn AllocKernelSpace -extrn MapPage -extrn RegService -extrn SetHwCursor -extrn HwCursorRestore -extrn HwCursorCreate -extrn LFBAddress -extrn LoadFile - CURSOR_IMAGE_OFFSET equ 0x00500000 DRV_ENTRY equ 1 @@ -192,18 +186,12 @@ proc START stdcall, state:dword test eax, eax jz .fail - xor eax, eax - mov edi, cursors - mov ecx, CURSOR_SIZE*16 - cld - rep stosd - - not eax + or eax, -1 mov [cursor_map], eax mov [cursor_map+4], eax mov edx, cursor_map mov [cursor_start], edx - add edx, 4 + add edx, 8 mov [cursor_end], edx stdcall RegService, sz_ati_srv, service_proc @@ -457,16 +445,41 @@ video_free: popfd ret +; param +; eax= pid +; ebx= src +; ecx= flags + align 4 -proc ati_cursor stdcall, hcursor:dword, src:dword, flags:dword +ati_cursor: +.src equ esp +.flags equ esp+4 +.hcursor equ esp+8 - stdcall video_alloc + sub esp, 4 ;space for .hcursor + push ecx + push ebx - mov edi, [hcursor] + mov ebx, eax + mov eax, CURSOR_SIZE + call CreateObject + test eax, eax + jz .fail + + mov [.hcursor],eax + + xor ebx, ebx + mov [eax+CURSOR.magic], 'CURS' + mov [eax+CURSOR.destroy], destroy_cursor + mov [eax+CURSOR.hot_x], ebx + mov [eax+CURSOR.hot_y], ebx + + call video_alloc + mov edi, [.hcursor] mov [edi+CURSOR.base], eax - mov esi, [src] - mov ebx, [flags] + mov esi, [.src] + mov ebx, [.flags] cmp bx, LOAD_INDIRECT je .indirect @@ -476,8 +489,9 @@ proc ati_cursor stdcall, hcursor:dword, src:dword, flags:dword mov [edi+CURSOR.hot_y], edx stdcall ati_init_cursor, eax, esi - mov eax, [hcursor] + mov eax, [.hcursor] .fail: + add esp, 12 ret .indirect: shr ebx, 16 @@ -486,14 +500,15 @@ proc ati_cursor stdcall, hcursor:dword, src:dword, flags:dword mov [edi+CURSOR.hot_x], ecx mov [edi+CURSOR.hot_y], edx - xchg edi, eax - push edi + mov edi, eax + mov ebx, eax mov ecx, 64*64 xor eax,eax + cld rep stosd + mov edi, ebx - mov esi, [src] - pop edi + mov esi, [.src] mov ebx, 32 cld @@: @@ -502,9 +517,20 @@ proc ati_cursor stdcall, hcursor:dword, src:dword, flags:dword add edi, 128 dec ebx jnz @B - mov eax, [hcursor] + mov eax, [.hcursor] + add esp, 12 + ret + +align 4 +destroy_cursor: + + push eax + mov eax, [eax+CURSOR.base] + call video_free + pop eax + + call DestroyObject ret -endp align 4 proc ati_init_cursor stdcall, dst:dword, src:dword @@ -955,7 +981,7 @@ devices dd (R8500 shl 16)+VID_ATI dd (R9800XT shl 16)+VID_ATI dd 0 ;terminator -version dd 0x00010001 +version dd 0x00020002 sz_ati_srv db 'HWCURSOR',0 @@ -970,7 +996,6 @@ section '.data' data readable writable align 16 pCursor db 4096 dup(?) -cursors rb CURSOR_SIZE*64 cursor_map rd 2 cursor_start rd 1 cursor_end rd 1 diff --git a/kernel/trunk/drivers/infinity.asm b/kernel/trunk/drivers/infinity.asm index 6e607af78e..21158765e7 100644 --- a/kernel/trunk/drivers/infinity.asm +++ b/kernel/trunk/drivers/infinity.asm @@ -17,6 +17,7 @@ format MS COFF include 'proc32.inc' include 'main.inc' +include 'imports.inc' DEBUG equ 1 @@ -30,25 +31,6 @@ public START public service_proc public version -extrn AttachIntHandler -extrn SysMsgBoardStr -extrn PciApi -extrn PciRead32 -extrn PciRead8 -extrn PciWrite8 -extrn AllocKernelSpace -extrn MapPage -extrn RegService -extrn KernelAlloc -extrn KernelFree -extrn GetPgAddr -extrn GetCurrentTask -extrn GetService -extrn ServiceHandler -extrn FpuSave -extrn FpuRestore -extrn SendEvent - SND_CREATE_BUFF equ 2 SND_PLAY equ 3 SND_STOP equ 4 @@ -212,13 +194,17 @@ proc CreateBuffer stdcall, format:dword mov edi, [str] mov [edi+STREAM.base], eax + mov [edi+STREAM.seg_0], eax mov [edi+STREAM.curr_seg], eax mov [edi+STREAM.notify_off1], eax - add eax, 0x8000 + add eax, 0x7FFF + mov [edi+STREAM.lim_0], eax + inc eax + mov [edi+STREAM.seg_1], eax mov [edi+STREAM.notify_off2], eax add eax, 0x7FFF mov [edi+STREAM.limit], eax - + mov [edi+STREAM.lim_1], eax inc eax mov [edi+STREAM.work_buff], eax @@ -266,7 +252,6 @@ proc CreateBuffer stdcall, format:dword mov eax, [str] ret - .fail: xor eax, eax ret @@ -367,7 +352,7 @@ proc play_buffer stdcall, str:dword mov [ebx+STREAM.work_write], eax mov [ebx+STREAM.work_count], 0 - mov eax, [ebx+STREAM.base] + mov eax, [ebx+STREAM.seg_0] mov [ebx+STREAM.curr_seg], eax mov esi, [ebx+STREAM.curr_seg] @@ -520,6 +505,7 @@ proc free_stream ret endp +if 0 align 4 proc check_stream @@ -529,18 +515,22 @@ proc check_stream mov esi, [play_list+edx] mov eax, [esi+STR.curr_seg] - cmp eax, [esi+STR.limit] + cmp eax, [esi+STR.lim_0] jb .next -.m1: - mov eax,[esi+STR.base] + mov eax, [esi+STREAM.seg_0] + mov ecx, [esi+STREAM.lim_0] + xchg eax, [ebx+STREAM.seg_1] + xchg ecx, [ebx+STREAM.lim_1] + mov [esi+STREAM.seg_0], eax + mov [esi+STREAM.lim_0], ecx mov [esi+STR.curr_seg], eax .next: add edx, 4 loop .l1 ret endp - +end if align 4 proc prepare_playlist @@ -728,35 +718,35 @@ resampler_params: dd 2048, 0x02000000, 5462, resample_28 ;35 PCM_2_8_8 dd 1024, 0x02000000, 5462, resample_18 ;36 PCM_1_8_8 -m7 dw 0x8000,0x8000,0x8000,0x8000 -mm80 dq 0x8080808080808080 -mm_mask dq 0xFF00FF00FF00FF00 +m7 dw 0x8000,0x8000,0x8000,0x8000 +mm80 dq 0x8080808080808080 +mm_mask dq 0xFF00FF00FF00FF00 -stream_map dd 0xFFFF ; 16 -version dd 0x00010001 +stream_map dd 0xFFFF ; 16 +version dd 0x00020002 -szInfinity db 'INFINITY',0 -szSound db 'SOUND',0 +szInfinity db 'INFINITY',0 +szSound db 'SOUND',0 if DEBUG -msgFail db 'Sound service not loaded',13,10,0 -msgPlay db 'Play buffer',13,10,0 -msgStop db 'Stop',13,10,0 -msgUser db 'User callback',13,10,0 -msgMem db 'Not enough memory',13,10,0 +msgFail db 'Sound service not loaded',13,10,0 +msgPlay db 'Play buffer',13,10,0 +msgStop db 'Stop',13,10,0 +msgUser db 'User callback',13,10,0 +msgMem db 'Not enough memory',13,10,0 end if section '.data' data readable writable align 16 -stream rb STREAM_SIZE*16 +stream rb STREAM_SIZE*16 -play_list rd 16 -mix_input rd 16 +play_list rd 16 +mix_input rd 16 -stream_list rd 17 -play_count rd 1 -stream_count rd 1 -hSound rd 1 -mix_buff rd 1 -mix_buff_map rd 1 +stream_list rd 17 +play_count rd 1 +stream_count rd 1 +hSound rd 1 +mix_buff rd 1 +mix_buff_map rd 1 diff --git a/kernel/trunk/drivers/main.inc b/kernel/trunk/drivers/main.inc index 1a4c5e8a55..b870a63205 100644 --- a/kernel/trunk/drivers/main.inc +++ b/kernel/trunk/drivers/main.inc @@ -98,8 +98,13 @@ struc STREAM .r_silence dd 0 .base dd 0 - .curr_seg dd 0 .limit dd 0 + .seg_0 dd 0 + .lim_0 dd 0 + .seg_1 dd 0 + .lim_1 dd 0 + .curr_seg dd 0 + .buff_size dd 0 .notify_off1 dd 0 .notify_off2 dd 0 @@ -107,7 +112,7 @@ struc STREAM .resample dd 0 } -STREAM_SIZE equ 23*4 +STREAM_SIZE equ 27*4 virtual at 0 STREAM STREAM diff --git a/kernel/trunk/drivers/mixer.asm b/kernel/trunk/drivers/mixer.asm index 84d2c8f93b..34255a5bb8 100644 --- a/kernel/trunk/drivers/mixer.asm +++ b/kernel/trunk/drivers/mixer.asm @@ -15,169 +15,171 @@ align 4 proc new_mix stdcall, output:dword - locals - mixCounter dd ? - mixIndex dd ? - streamIndex dd ? - inputCount dd ? - main_count dd ? - blockCount dd ? - mix_out dd ? - endl + locals + mixCounter dd ? + mixIndex dd ? + streamIndex dd ? + inputCount dd ? + main_count dd ? + blockCount dd ? + mix_out dd ? + endl - call prepare_playlist + call prepare_playlist - cmp [play_count], 0 - je .exit + cmp [play_count], 0 + je .exit call FpuSave - mov [main_count], 32; + mov [main_count], 32; .l00: - mov [mix_buff_map], 0x0000FFFF; - xor eax, eax - mov [mixCounter], eax - mov [mixIndex],eax - mov [streamIndex], eax; - mov ebx, [play_count] - mov [inputCount], ebx + mov [mix_buff_map], 0x0000FFFF; + xor eax, eax + mov [mixCounter], eax + mov [mixIndex],eax + mov [streamIndex], eax; + mov ebx, [play_count] + mov [inputCount], ebx .l0: - mov ecx, 4 + mov ecx, 4 .l1: - mov ebx, [streamIndex] - mov esi, [play_list+ebx*4] - mov eax, [esi+STREAM.work_read] - add [esi+STREAM.work_read], 512 + mov ebx, [streamIndex] + mov esi, [play_list+ebx*4] + mov eax, [esi+STREAM.work_read] + add [esi+STREAM.work_read], 512 - mov ebx, [mixIndex] - mov [mix_input+ebx*4], eax - inc [mixCounter] - inc [mixIndex] - inc [streamIndex] - dec [inputCount] - jz .m2 + mov ebx, [mixIndex] + mov [mix_input+ebx*4], eax + inc [mixCounter] + inc [mixIndex] + inc [streamIndex] + dec [inputCount] + jz .m2 - dec ecx - jnz .l1 + dec ecx + jnz .l1 - cmp [mixCounter], 4 - jnz .m2 + cmp [mixCounter], 4 + jnz .m2 - stdcall mix_4_1, [mix_input],[mix_input+4],[mix_input+8],[mix_input+12] - sub [mixIndex],4 - mov ebx, [mixIndex] - mov [mix_input+ebx*4], eax - inc [mixIndex] - mov [mixCounter], 0 + stdcall mix_4_1, [mix_input],[mix_input+4],[mix_input+8],[mix_input+12] + sub [mixIndex],4 + mov ebx, [mixIndex] + mov [mix_input+ebx*4], eax + inc [mixIndex] + mov [mixCounter], 0 - cmp [inputCount], 0 - jnz .l0 + cmp [inputCount], 0 + jnz .l0 .m2: - cmp [mixIndex], 1 - jne @f - stdcall copy_mem, [output], [mix_input] - jmp .m3 + cmp [mixIndex], 1 + jne @f + stdcall copy_mem, [output], [mix_input] + jmp .m3 @@: - cmp [mixIndex], 2 - jne @f - stdcall mix_2_1, [output], [mix_input], [mix_input+4] - jmp .m3 + cmp [mixIndex], 2 + jne @f + stdcall mix_2_1, [output], [mix_input], [mix_input+4] + jmp .m3 @@: - cmp [mixIndex], 3 - jne @f - stdcall mix_3_1, [output],[mix_input],[mix_input+4],[mix_input+8] - jmp .m3 + cmp [mixIndex], 3 + jne @f + stdcall mix_3_1, [output],[mix_input],[mix_input+4],[mix_input+8] + jmp .m3 @@: - stdcall final_mix, [output],[mix_input],[mix_input+4],[mix_input+8], [mix_input+12] + stdcall final_mix, [output],[mix_input],[mix_input+4],[mix_input+8], [mix_input+12] .m3: - add [output],512 + add [output],512 - sub [main_count], 1 - jnz .l00 + sub [main_count], 1 + jnz .l00 - call update_stream + call update_stream emms call FpuRestore - ret + ret .exit: - mov edi, [output] - mov ecx, 0x1000 - xor eax, eax - cld - rep stosd - ret + mov edi, [output] + mov ecx, 0x1000 + xor eax, eax + cld + rep stosd + ret endp - align 4 proc update_stream - locals + locals stream_index dd ? ev_code dd ? ;EVENT ev_offs dd ? rd 4 - endl + endl - mov [stream_index], 0 + mov [stream_index], 0 .l1: - mov edx, [stream_index] - mov esi, [play_list+edx*4] + mov edx, [stream_index] + mov esi, [play_list+edx*4] - mov eax, [esi+STREAM.work_read] - cmp eax, [esi+STREAM.work_top] - jb @f - mov eax, [esi+STREAM.work_buff] + mov eax, [esi+STREAM.work_read] + cmp eax, [esi+STREAM.work_top] + jb @f + mov eax, [esi+STREAM.work_buff] @@: - mov [esi+STREAM.work_read], eax + mov [esi+STREAM.work_read], eax - cmp [esi+STREAM.format], PCM_2_16_48 - je .copy + cmp [esi+STREAM.format], PCM_2_16_48 + je .copy - sub [esi+STREAM.work_count], 16384 + sub [esi+STREAM.work_count], 16384 - cmp [esi+STREAM.work_count], 32768 - ja @f + cmp [esi+STREAM.work_count], 32768 + ja @f - stdcall refill, esi + stdcall refill, esi @@: - inc [stream_index] - dec [play_count] - jnz .l1 - - ret + inc [stream_index] + dec [play_count] + jnz .l1 + ret .copy: - mov ebx, esi - mov edi, [ebx+STREAM.work_write] - cmp edi, [ebx+STREAM.work_top] - jb @f - mov edi, [ebx+STREAM.work_buff] - mov [ebx+STREAM.work_write], edi + mov ebx, esi + mov edi, [ebx+STREAM.work_write] + cmp edi, [ebx+STREAM.work_top] + jb @f + mov edi, [ebx+STREAM.work_buff] + mov [ebx+STREAM.work_write], edi @@: - mov esi, [ebx+STREAM.curr_seg] - mov ecx, 16384/4 - cld - rep movsd + mov esi, [ebx+STREAM.curr_seg] + mov ecx, 16384/4 + cld + rep movsd mov [ebx+STREAM.work_write], edi - cmp esi, [ebx+STREAM.limit] - jb @f + cmp esi, [ebx+STREAM.lim_0] + jb @f - mov esi, [ebx+STREAM.base] + mov esi, [ebx+STREAM.seg_0] + mov eax, [ebx+STREAM.lim_0] + xchg esi, [ebx+STREAM.seg_1] + xchg eax, [ebx+STREAM.lim_1] + mov [ebx+STREAM.seg_0], esi + mov [ebx+STREAM.lim_0], eax @@: - mov [ebx+STREAM.curr_seg], esi + mov [ebx+STREAM.curr_seg], esi - xor ecx, ecx - cmp esi, [ebx+STREAM.notify_off2] - je @f + xor ecx, ecx + cmp esi, [ebx+STREAM.notify_off2] + je @f - mov ecx,0x8000 - cmp esi, [ebx+STREAM.notify_off1] - je @f + mov ecx,0x8000 + cmp esi, [ebx+STREAM.notify_off1] + je @f - inc [stream_index] - dec [play_count] - jnz .l1 - - ret + inc [stream_index] + dec [play_count] + jnz .l1 + ret @@: mov [ev_code], 0xFF000001 mov [ev_offs], ecx @@ -193,61 +195,66 @@ proc update_stream not eax mov [ebx+STREAM.notify_task], eax ;-1 .l_end: - inc [stream_index] - dec [play_count] - jnz .l1 - ret + inc [stream_index] + dec [play_count] + jnz .l1 + ret endp align 4 proc refill stdcall, str:dword - locals + locals ev_code dd ? ;EVENT ev_offs dd ? rd 4 - endl + endl - mov ebx, [str] - mov ecx, [ebx+STREAM.work_write] - cmp ecx, [ebx+STREAM.work_top] - jbe .m2 - mov esi, [ebx+STREAM.work_top] - sub ecx, esi - mov edi, [ebx+STREAM.work_buff] - shr ecx, 2 - rep movsd ;call memcpy + mov ebx, [str] + mov ecx, [ebx+STREAM.work_write] + cmp ecx, [ebx+STREAM.work_top] + jbe .m2 + mov esi, [ebx+STREAM.work_top] + sub ecx, esi + mov edi, [ebx+STREAM.work_buff] + shr ecx, 2 + rep movsd ;call memcpy - mov [ebx+STREAM.work_write], edi + mov [ebx+STREAM.work_write], edi .m2: - mov esi, [ebx+STREAM.curr_seg] - mov edi, [ebx+STREAM.work_write] - mov edx, [ebx+STREAM.r_buff] + mov esi, [ebx+STREAM.curr_seg] + mov edi, [ebx+STREAM.work_write] + mov edx, [ebx+STREAM.r_buff] - stdcall [ebx+STREAM.resample], edi, esi, edx,\ - [ebx+STREAM.r_dt],[ebx+STREAM.r_size],[ebx+STREAM.r_end] + stdcall [ebx+STREAM.resample], edi, esi, edx,\ + [ebx+STREAM.r_dt],[ebx+STREAM.r_size],[ebx+STREAM.r_end] - mov ebx, [str] + mov ebx, [str] - add [ebx+STREAM.work_count], eax; - add [ebx+STREAM.work_write], eax; + add [ebx+STREAM.work_count], eax; + add [ebx+STREAM.work_write], eax; - mov eax, [ebx+STREAM.curr_seg] - add eax, [ebx+STREAM.r_size] - cmp eax, [ebx+STREAM.limit] - jb @f - mov eax, [ebx+STREAM.base] + mov eax, [ebx+STREAM.curr_seg] + add eax, [ebx+STREAM.r_size] + cmp eax, [ebx+STREAM.lim_0] + jb @f + + mov eax, [ebx+STREAM.seg_0] + mov ecx, [ebx+STREAM.lim_0] + xchg eax, [ebx+STREAM.seg_1] + xchg ecx, [ebx+STREAM.lim_1] + mov [ebx+STREAM.seg_0], eax + mov [ebx+STREAM.lim_0], ecx @@: - mov [ebx+STREAM.curr_seg], eax + mov [ebx+STREAM.curr_seg], eax - xor ecx, ecx - cmp eax, [ebx+STREAM.notify_off2] - je @f + xor ecx, ecx + cmp eax, [ebx+STREAM.notify_off2] + je @f - mov ecx,0x8000 - cmp eax, [ebx+STREAM.notify_off1] - je @f - - ret + mov ecx,0x8000 + cmp eax, [ebx+STREAM.notify_off1] + je @f + ret @@: mov [ev_code], 0xFF000001 mov [ev_offs], ecx @@ -414,14 +421,14 @@ align 4 proc copy_stream stdcall, dest:dword,src:dword,r_buff:dword,\ r_dt:dword, r_size:dword,r_end:dword - mov ecx, [r_size] - mov eax, ecx - shr ecx, 2 - mov esi, [src] - mov edi, [dest] - rep movsd - mov eax, 16384 - ret + mov ecx, [r_size] + mov eax, ecx + shr ecx, 2 + mov esi, [src] + mov edi, [dest] + rep movsd + mov eax, 16384 + ret endp align 4 @@ -603,79 +610,78 @@ align 4 proc s8_stereo stdcall, dest:dword,src:dword,r_buff:dword,\ r_dt:dword, r_size:dword,r_end:dword + mov esi, [src] + mov edi, [dest] + mov ecx, [r_size] + shr ecx, 7 - mov esi, [src] - mov edi, [dest] - mov ecx, [r_size] - shr ecx, 7 - - movq mm7, [mm80] - movq mm6, [mm_mask] + movq mm7, [mm80] + movq mm6, [mm_mask] @@: - call s8_s_mmx - add edi, 64 - add esi, 32 - call s8_s_mmx - add edi, 64 - add esi, 32 - call s8_s_mmx - add edi, 64 - add esi, 32 - call s8_s_mmx - add edi, 64 - add esi, 32 + call s8_s_mmx + add edi, 64 + add esi, 32 + call s8_s_mmx + add edi, 64 + add esi, 32 + call s8_s_mmx + add edi, 64 + add esi, 32 + call s8_s_mmx + add edi, 64 + add esi, 32 dec ecx - jnz @b + jnz @b - mov eax, [r_size] - add eax, eax - ret + mov eax, [r_size] + add eax, eax + ret endp proc m8_stereo stdcall, dest:dword,src:dword,r_buff:dword,\ r_dt:dword, r_size:dword,r_end:dword - mov esi, [src] - mov edi, [dest] - mov ecx, [r_size] - shr ecx, 6 + mov esi, [src] + mov edi, [dest] + mov ecx, [r_size] + shr ecx, 6 - movq mm7, [mm80] - movq mm6, [mm_mask] + movq mm7, [mm80] + movq mm6, [mm_mask] @@: - call m8_s_mmx - add edi, 64 - add esi, 16 - call m8_s_mmx - add edi, 64 - add esi, 16 - call m8_s_mmx - add edi, 64 - add esi, 16 - call m8_s_mmx - add edi, 64 - add esi, 16 - dec ecx - jnz @b + call m8_s_mmx + add edi, 64 + add esi, 16 + call m8_s_mmx + add edi, 64 + add esi, 16 + call m8_s_mmx + add edi, 64 + add esi, 16 + call m8_s_mmx + add edi, 64 + add esi, 16 + dec ecx + jnz @b - mov eax, [r_size] - add eax, eax - add eax, eax - ret + mov eax, [r_size] + add eax, eax + add eax, eax + ret endp align 4 proc alloc_mix_buff - bsf eax, [mix_buff_map] - jnz .find - xor eax, eax - ret + bsf eax, [mix_buff_map] + jnz .find + xor eax, eax + ret .find: - btr [mix_buff_map], eax - shl eax, 9 - add eax, [mix_buff] - ret + btr [mix_buff_map], eax + shl eax, 9 + add eax, [mix_buff] + ret endp proc m16_s_mmx @@ -743,117 +749,117 @@ endp align 4 proc s8_s_mmx - movq mm0, [esi] - psubb mm0, mm7 - movq mm1, mm0 - punpcklbw mm0, mm0 - pand mm0, mm6 - punpckhbw mm1, mm1 - pand mm1, mm6 - movq [edi], mm0 - movq [edi+8], mm1 + movq mm0, [esi] + psubb mm0, mm7 + movq mm1, mm0 + punpcklbw mm0, mm0 + pand mm0, mm6 + punpckhbw mm1, mm1 + pand mm1, mm6 + movq [edi], mm0 + movq [edi+8], mm1 - movq mm0, [esi+8] - psubb mm0, mm7 - movq mm1, mm0 - punpcklbw mm0, mm0 - pand mm0, mm6 - punpckhbw mm1, mm1 - pand mm1, mm6 - movq [edi+16], mm0 - movq [edi+24], mm1 + movq mm0, [esi+8] + psubb mm0, mm7 + movq mm1, mm0 + punpcklbw mm0, mm0 + pand mm0, mm6 + punpckhbw mm1, mm1 + pand mm1, mm6 + movq [edi+16], mm0 + movq [edi+24], mm1 - movq mm0, [esi+16] - psubb mm0, mm7 - movq mm1, mm0 - punpcklbw mm0, mm0 - pand mm0, mm6 - punpckhbw mm1, mm1 - pand mm1, mm6 - movq [edi+32], mm0 - movq [edi+40], mm1 + movq mm0, [esi+16] + psubb mm0, mm7 + movq mm1, mm0 + punpcklbw mm0, mm0 + pand mm0, mm6 + punpckhbw mm1, mm1 + pand mm1, mm6 + movq [edi+32], mm0 + movq [edi+40], mm1 - movq mm0, [esi+24] - psubb mm0, mm7 - movq mm1, mm0 - punpcklbw mm0, mm0 - pand mm0, mm6 - punpckhbw mm1, mm1 - pand mm1, mm6 - movq [edi+48], mm0 - movq [edi+56], mm1 + movq mm0, [esi+24] + psubb mm0, mm7 + movq mm1, mm0 + punpcklbw mm0, mm0 + pand mm0, mm6 + punpckhbw mm1, mm1 + pand mm1, mm6 + movq [edi+48], mm0 + movq [edi+56], mm1 - ret + ret endp align 4 proc m8_s_mmx - movq mm0, [esi] - psubb mm0, mm7 - movq mm1, mm0 - punpcklbw mm0, mm0 - pand mm0, mm6 - punpckhbw mm1, mm1 - pand mm1, mm6 - movq mm2, mm0 - punpcklwd mm0, mm0 - punpckhwd mm2, mm2 + movq mm0, [esi] + psubb mm0, mm7 + movq mm1, mm0 + punpcklbw mm0, mm0 + pand mm0, mm6 + punpckhbw mm1, mm1 + pand mm1, mm6 + movq mm2, mm0 + punpcklwd mm0, mm0 + punpckhwd mm2, mm2 - movq mm3, mm1 - punpcklwd mm1, mm1 - punpckhwd mm3, mm3 + movq mm3, mm1 + punpcklwd mm1, mm1 + punpckhwd mm3, mm3 - movq [edi], mm0 - movq [edi+8], mm2 - movq [edi+16], mm1 - movq [edi+24], mm3 + movq [edi], mm0 + movq [edi+8], mm2 + movq [edi+16], mm1 + movq [edi+24], mm3 - movq mm0, [esi+8] - psubb mm0, mm7 - movq mm1, mm0 - punpcklbw mm0, mm0 - pand mm0, mm6 - punpckhbw mm1, mm1 - pand mm1, mm6 - movq mm2, mm0 - punpcklwd mm0, mm0 - punpckhwd mm2, mm2 + movq mm0, [esi+8] + psubb mm0, mm7 + movq mm1, mm0 + punpcklbw mm0, mm0 + pand mm0, mm6 + punpckhbw mm1, mm1 + pand mm1, mm6 + movq mm2, mm0 + punpcklwd mm0, mm0 + punpckhwd mm2, mm2 - movq mm3, mm1 - punpcklwd mm1, mm1 - punpckhwd mm3, mm3 + movq mm3, mm1 + punpcklwd mm1, mm1 + punpckhwd mm3, mm3 - movq [edi+32], mm0 - movq [edi+40], mm2 - movq [edi+48], mm1 - movq [edi+56], mm3 + movq [edi+32], mm0 + movq [edi+40], mm2 + movq [edi+48], mm1 + movq [edi+56], mm3 - ret + ret endp align 4 proc mix_2_1 stdcall, output:dword, str0:dword, str1:dword - mov edi, [output] + mov edi, [output] - stdcall mix_2_1_mmx, edi, [str0],[str1] - add edi, 128 - add [str0], 128 - add [str1], 128 - stdcall mix_2_1_mmx, edi, [str0],[str1] - add edi, 128 - add [str0], 128 - add [str1], 128 - stdcall mix_2_1_mmx, edi, [str0],[str1] - add edi, 128 - add [str0], 128 - add [str1], 128 - stdcall mix_2_1_mmx, edi, [str0],[str1] + stdcall mix_2_1_mmx, edi, [str0],[str1] + add edi, 128 + add [str0], 128 + add [str1], 128 + stdcall mix_2_1_mmx, edi, [str0],[str1] + add edi, 128 + add [str0], 128 + add [str1], 128 + stdcall mix_2_1_mmx, edi, [str0],[str1] + add edi, 128 + add [str0], 128 + add [str1], 128 + stdcall mix_2_1_mmx, edi, [str0],[str1] - ret + ret endp @@ -954,312 +960,307 @@ endp align 4 proc mix_2_1_mmx stdcall, output:dword, str0:dword, str1:dword - mov edx, [output] - mov eax, [str0] - mov ecx, [str1] + mov edx, [output] + mov eax, [str0] + mov ecx, [str1] - movq mm0, [eax] - paddsw mm0, [ecx] - ; psraw mm0, 1 - movq [edx], mm0 + movq mm0, [eax] + paddsw mm0, [ecx] + ; psraw mm0, 1 + movq [edx], mm0 - movq mm1, [eax+8] - paddsw mm1,[ecx+8] - ; psraw mm1, 1 - movq [edx+8], mm1 + movq mm1, [eax+8] + paddsw mm1,[ecx+8] + ; psraw mm1, 1 + movq [edx+8], mm1 - movq mm2, [eax+16] - paddsw mm2, [ecx+16] - ; psraw mm2, 1 - movq [edx+16], mm2 + movq mm2, [eax+16] + paddsw mm2, [ecx+16] + ; psraw mm2, 1 + movq [edx+16], mm2 - movq mm3, [eax+24] - paddsw mm3, [ecx+24] - ; psraw mm3, 1 - movq [edx+24], mm3 + movq mm3, [eax+24] + paddsw mm3, [ecx+24] + ; psraw mm3, 1 + movq [edx+24], mm3 - movq mm0, [eax+32] - paddsw mm0, [ecx+32] - ; psraw mm0, 1 - movq [edx+32], mm0 + movq mm0, [eax+32] + paddsw mm0, [ecx+32] + ; psraw mm0, 1 + movq [edx+32], mm0 - movq mm1, [eax+40] - paddsw mm1, [ecx+40] - ; psraw mm1, 1 - movq [edx+40], mm1 + movq mm1, [eax+40] + paddsw mm1, [ecx+40] + ; psraw mm1, 1 + movq [edx+40], mm1 - movq mm2, [eax+48] - paddsw mm2, [ecx+48] - ; psraw mm2, 1 - movq [edx+48], mm2 + movq mm2, [eax+48] + paddsw mm2, [ecx+48] + ; psraw mm2, 1 + movq [edx+48], mm2 - movq mm3, [eax+56] - paddsw mm3, [ecx+56] - ; psraw mm3, 1 - movq [edx+56], mm3 + movq mm3, [eax+56] + paddsw mm3, [ecx+56] + ; psraw mm3, 1 + movq [edx+56], mm3 - movq mm0, [eax+64] - paddsw mm0, [ecx+64] - ; psraw mm0, 1 - movq [edx+64], mm0 + movq mm0, [eax+64] + paddsw mm0, [ecx+64] + ; psraw mm0, 1 + movq [edx+64], mm0 - movq mm1, [eax+72] - paddsw mm1, [ecx+72] - ; psraw mm1, 1 - movq [edx+72], mm1 + movq mm1, [eax+72] + paddsw mm1, [ecx+72] + ; psraw mm1, 1 + movq [edx+72], mm1 - movq mm2, [eax+80] - paddsw mm2, [ecx+80] - ; psraw mm2, 1 - movq [edx+80], mm2 + movq mm2, [eax+80] + paddsw mm2, [ecx+80] + ; psraw mm2, 1 + movq [edx+80], mm2 - movq mm3, [eax+88] - paddsw mm3, [ecx+88] - ; psraw mm3, 1 + movq mm3, [eax+88] + paddsw mm3, [ecx+88] + ; psraw mm3, 1 + movq [edx+88], mm3 - movq [edx+88], mm3 + movq mm0, [eax+96] + paddsw mm0, [ecx+96] + ; psraw mm0, 1 + movq [edx+96], mm0 - movq mm0, [eax+96] - paddsw mm0, [ecx+96] - ; psraw mm0, 1 + movq mm1, [eax+104] + paddsw mm1, [ecx+104] + ; psraw mm1, 1 + movq [edx+104], mm1 - movq [edx+96], mm0 + movq mm2, [eax+112] + paddsw mm2, [ecx+112] + ; psraw mm2, 1 + movq [edx+112], mm2 - movq mm1, [eax+104] - paddsw mm1, [ecx+104] - ; psraw mm1, 1 + movq mm3, [eax+120] + paddsw mm3, [ecx+120] + ; psraw mm3, 1 + movq [edx+120], mm3 - movq [edx+104], mm1 - - movq mm2, [eax+112] - paddsw mm2, [ecx+112] - ; psraw mm2, 1 - - movq [edx+112], mm2 - - movq mm3, [eax+120] - paddsw mm3, [ecx+120] - ; psraw mm3, 1 - - movq [edx+120], mm3 - - ret + ret endp align 4 proc mix_3_1_mmx stdcall, output:dword, str0:dword, str1:dword, str2:dword - mov edx, [output] - mov eax, [str0] - mov ebx, [str1] - mov ecx, [str2] + mov edx, [output] + mov eax, [str0] + mov ebx, [str1] + mov ecx, [str2] - movq mm0, [eax] - paddsw mm0, [ebx] - paddsw mm0, [ecx] - movq [edx], mm0 + movq mm0, [eax] + paddsw mm0, [ebx] + paddsw mm0, [ecx] + movq [edx], mm0 - movq mm1, [eax+8] - paddsw mm1,[ebx+8] - paddsw mm1,[ecx+8] - movq [edx+8], mm1 + movq mm1, [eax+8] + paddsw mm1,[ebx+8] + paddsw mm1,[ecx+8] + movq [edx+8], mm1 - movq mm2, [eax+16] - paddsw mm2, [ebx+16] - paddsw mm2, [ecx+16] - movq [edx+16], mm2 + movq mm2, [eax+16] + paddsw mm2, [ebx+16] + paddsw mm2, [ecx+16] + movq [edx+16], mm2 - movq mm3, [eax+24] - paddsw mm3, [ebx+24] - paddsw mm3, [ecx+24] - movq [edx+24], mm3 + movq mm3, [eax+24] + paddsw mm3, [ebx+24] + paddsw mm3, [ecx+24] + movq [edx+24], mm3 - movq mm0, [eax+32] - paddsw mm0, [ebx+32] - paddsw mm0, [ecx+32] - movq [edx+32], mm0 + movq mm0, [eax+32] + paddsw mm0, [ebx+32] + paddsw mm0, [ecx+32] + movq [edx+32], mm0 - movq mm1, [eax+40] - paddsw mm1, [ebx+40] - paddsw mm1, [ecx+40] - movq [edx+40], mm1 + movq mm1, [eax+40] + paddsw mm1, [ebx+40] + paddsw mm1, [ecx+40] + movq [edx+40], mm1 - movq mm2, [eax+48] - paddsw mm2, [ebx+48] - paddsw mm2, [ecx+48] - movq [edx+48], mm2 + movq mm2, [eax+48] + paddsw mm2, [ebx+48] + paddsw mm2, [ecx+48] + movq [edx+48], mm2 - movq mm3, [eax+56] - paddsw mm3, [ebx+56] - paddsw mm3, [ecx+56] - movq [edx+56], mm3 + movq mm3, [eax+56] + paddsw mm3, [ebx+56] + paddsw mm3, [ecx+56] + movq [edx+56], mm3 - movq mm0, [eax+64] - paddsw mm0, [ebx+64] - paddsw mm0, [ecx+64] - movq [edx+64], mm0 + movq mm0, [eax+64] + paddsw mm0, [ebx+64] + paddsw mm0, [ecx+64] + movq [edx+64], mm0 - movq mm1, [eax+72] - paddsw mm1, [ebx+72] - paddsw mm1, [ecx+72] - movq [edx+72], mm1 + movq mm1, [eax+72] + paddsw mm1, [ebx+72] + paddsw mm1, [ecx+72] + movq [edx+72], mm1 - movq mm2, [eax+80] - paddsw mm2, [ebx+80] - paddsw mm2, [ecx+80] - movq [edx+80], mm2 + movq mm2, [eax+80] + paddsw mm2, [ebx+80] + paddsw mm2, [ecx+80] + movq [edx+80], mm2 - movq mm3, [eax+88] - paddsw mm3, [ebx+88] - paddsw mm3, [ecx+88] - movq [edx+88], mm3 + movq mm3, [eax+88] + paddsw mm3, [ebx+88] + paddsw mm3, [ecx+88] + movq [edx+88], mm3 - movq mm0, [eax+96] - paddsw mm0, [ebx+96] - paddsw mm0, [ecx+96] - movq [edx+96], mm0 + movq mm0, [eax+96] + paddsw mm0, [ebx+96] + paddsw mm0, [ecx+96] + movq [edx+96], mm0 - movq mm1, [eax+104] - paddsw mm1, [ebx+104] - paddsw mm1, [ecx+104] - movq [edx+104], mm1 + movq mm1, [eax+104] + paddsw mm1, [ebx+104] + paddsw mm1, [ecx+104] + movq [edx+104], mm1 - movq mm2, [eax+112] - paddsw mm2, [ebx+112] - paddsw mm2, [ecx+112] - movq [edx+112], mm2 + movq mm2, [eax+112] + paddsw mm2, [ebx+112] + paddsw mm2, [ecx+112] + movq [edx+112], mm2 - movq mm3, [eax+120] - paddsw mm3, [ebx+120] - paddsw mm3, [ecx+120] - movq [edx+120], mm3 + movq mm3, [eax+120] + paddsw mm3, [ebx+120] + paddsw mm3, [ecx+120] + movq [edx+120], mm3 - ret + ret endp align 4 proc mix_4_1_mmx stdcall, output:dword, str0:dword, str1:dword,\ - str2:dword, str3:dword + str2:dword, str3:dword - mov edx, [output] - mov esi, [str0] - mov eax, [str1] - mov ebx, [str2] - mov ecx, [str3] + mov edx, [output] + mov esi, [str0] + mov eax, [str1] + mov ebx, [str2] + mov ecx, [str3] - movq mm0, [esi] - movq mm1, [eax] - paddsw mm0, [ebx] - paddsw mm1, [ecx] - paddsw mm0, mm1 - movq [edx], mm0 + movq mm0, [esi] + movq mm1, [eax] + paddsw mm0, [ebx] + paddsw mm1, [ecx] + paddsw mm0, mm1 + movq [edx], mm0 - movq mm2, [esi+8] - movq mm3, [eax+8] - paddsw mm2, [ebx+8] - paddsw mm3, [ecx+8] - paddsw mm2, mm3 - movq [edx+8], mm2 + movq mm2, [esi+8] + movq mm3, [eax+8] + paddsw mm2, [ebx+8] + paddsw mm3, [ecx+8] + paddsw mm2, mm3 + movq [edx+8], mm2 - movq mm0, [esi+16] - movq mm1, [eax+16] - paddsw mm0, [ebx+16] - paddsw mm1, [ecx+16] - paddsw mm0, mm1 - movq [edx+16], mm0 + movq mm0, [esi+16] + movq mm1, [eax+16] + paddsw mm0, [ebx+16] + paddsw mm1, [ecx+16] + paddsw mm0, mm1 + movq [edx+16], mm0 - movq mm2, [esi+24] - movq mm3, [eax+24] - paddsw mm2, [ebx+24] - paddsw mm3, [ecx+24] - paddsw mm2, mm3 - movq [edx+24], mm2 + movq mm2, [esi+24] + movq mm3, [eax+24] + paddsw mm2, [ebx+24] + paddsw mm3, [ecx+24] + paddsw mm2, mm3 + movq [edx+24], mm2 - movq mm0, [esi+32] - movq mm1, [eax+32] - paddsw mm0, [ebx+32] - paddsw mm1, [ecx+32] - paddsw mm0, mm1 - movq [edx+32], mm0 + movq mm0, [esi+32] + movq mm1, [eax+32] + paddsw mm0, [ebx+32] + paddsw mm1, [ecx+32] + paddsw mm0, mm1 + movq [edx+32], mm0 - movq mm2, [esi+40] - movq mm3, [eax+40] - paddsw mm2, [ebx+40] - paddsw mm3, [ecx+40] - paddsw mm2, mm3 - movq [edx+40], mm2 + movq mm2, [esi+40] + movq mm3, [eax+40] + paddsw mm2, [ebx+40] + paddsw mm3, [ecx+40] + paddsw mm2, mm3 + movq [edx+40], mm2 - movq mm0, [esi+48] - movq mm1, [eax+48] - paddsw mm0, [ebx+48] - paddsw mm1, [ecx+48] - paddsw mm0, mm1 - movq [edx+48], mm0 + movq mm0, [esi+48] + movq mm1, [eax+48] + paddsw mm0, [ebx+48] + paddsw mm1, [ecx+48] + paddsw mm0, mm1 + movq [edx+48], mm0 - movq mm2, [esi+56] - movq mm3, [eax+56] - paddsw mm2, [ebx+56] - paddsw mm3, [ecx+56] - paddsw mm2, mm3 - movq [edx+56], mm2 + movq mm2, [esi+56] + movq mm3, [eax+56] + paddsw mm2, [ebx+56] + paddsw mm3, [ecx+56] + paddsw mm2, mm3 + movq [edx+56], mm2 - movq mm0, [esi+64] - movq mm1, [eax+64] - paddsw mm0, [ebx+64] - paddsw mm1, [ecx+64] - paddsw mm0, mm1 - movq [edx+64], mm0 + movq mm0, [esi+64] + movq mm1, [eax+64] + paddsw mm0, [ebx+64] + paddsw mm1, [ecx+64] + paddsw mm0, mm1 + movq [edx+64], mm0 - movq mm2, [esi+72] - movq mm3, [eax+72] - paddsw mm2, [ebx+72] - paddsw mm3, [ecx+72] - paddsw mm2, mm3 - movq [edx+72], mm2 + movq mm2, [esi+72] + movq mm3, [eax+72] + paddsw mm2, [ebx+72] + paddsw mm3, [ecx+72] + paddsw mm2, mm3 + movq [edx+72], mm2 - movq mm2, [esi+80] - movq mm3, [eax+80] - paddsw mm2, [ebx+80] - paddsw mm3, [ecx+80] - paddsw mm2, mm3 - movq [edx+80], mm2 + movq mm2, [esi+80] + movq mm3, [eax+80] + paddsw mm2, [ebx+80] + paddsw mm3, [ecx+80] + paddsw mm2, mm3 + movq [edx+80], mm2 - movq mm2, [esi+88] - movq mm3, [eax+88] - paddsw mm2, [ebx+88] - paddsw mm3, [ecx+88] - paddsw mm2, mm3 - movq [edx+88], mm2 + movq mm2, [esi+88] + movq mm3, [eax+88] + paddsw mm2, [ebx+88] + paddsw mm3, [ecx+88] + paddsw mm2, mm3 + movq [edx+88], mm2 - movq mm2, [esi+96] - movq mm3, [eax+96] - paddsw mm2, [ebx+96] - paddsw mm3, [ecx+96] - paddsw mm2, mm3 - movq [edx+96], mm2 + movq mm2, [esi+96] + movq mm3, [eax+96] + paddsw mm2, [ebx+96] + paddsw mm3, [ecx+96] + paddsw mm2, mm3 + movq [edx+96], mm2 - movq mm2, [esi+104] - movq mm3, [eax+104] - paddsw mm2, [ebx+104] - paddsw mm3, [ecx+104] - paddsw mm2, mm3 - movq [edx+104], mm2 + movq mm2, [esi+104] + movq mm3, [eax+104] + paddsw mm2, [ebx+104] + paddsw mm3, [ecx+104] + paddsw mm2, mm3 + movq [edx+104], mm2 - movq mm2, [esi+112] - movq mm3, [eax+112] - paddsw mm2, [ebx+112] - paddsw mm3, [ecx+112] - paddsw mm2, mm3 - movq [edx+112], mm2 + movq mm2, [esi+112] + movq mm3, [eax+112] + paddsw mm2, [ebx+112] + paddsw mm3, [ecx+112] + paddsw mm2, mm3 + movq [edx+112], mm2 - movq mm2, [esi+120] - movq mm3, [eax+120] - paddsw mm2, [ebx+120] - paddsw mm3, [ecx+120] - paddsw mm2, mm3 - movq [edx+120], mm2 + movq mm2, [esi+120] + movq mm3, [eax+120] + paddsw mm2, [ebx+120] + paddsw mm3, [ecx+120] + paddsw mm2, mm3 + movq [edx+120], mm2 - ret + ret endp align 4 diff --git a/kernel/trunk/drivers/sceletone.asm b/kernel/trunk/drivers/sceletone.asm index 7717bd8d78..b4d6f9827d 100644 --- a/kernel/trunk/drivers/sceletone.asm +++ b/kernel/trunk/drivers/sceletone.asm @@ -4,7 +4,7 @@ format MS COFF include 'proc32.inc' - +include 'imports.inc' OS_BASE equ 0; new_app_base equ 0x60400000 @@ -27,24 +27,6 @@ public START public service_proc public version -extrn AttachIntHandler -extrn SysMsgBoardStr -extrn PciApi -extrn PciRead32 -extrn PciRead8 -extrn PciWrite8 -extrn AllocKernelSpace -extrn KernelAlloc -extrn MapPage -extrn GetPgAddr -extrn RegService -extrn ServiceHandler -extrn SetHwCursor -extrn LFBAddress -extrn LoadFile -extrn FpuSave -extrn FpuRestore - DEBUG equ 1 DRV_ENTRY equ 1 @@ -161,7 +143,7 @@ align 4 devices dd (DEVICE_ID shl 16)+VENDOR_ID dd 0 ;terminator -version dd 0x00010001 +version dd 0x00020002 my_service db 'MY_SERVICE',0 ;max 16 chars include zero diff --git a/kernel/trunk/drivers/sis.asm b/kernel/trunk/drivers/sis.asm index 58bd007a8e..221280ea0a 100644 --- a/kernel/trunk/drivers/sis.asm +++ b/kernel/trunk/drivers/sis.asm @@ -1,8 +1,8 @@ format MS COFF - include 'proc32.inc' +include 'imports.inc' DEBUG equ 1 @@ -251,19 +251,6 @@ public START public service_proc public version -extrn AttachIntHandler -extrn SysMsgBoardStr -extrn PciApi -extrn PciRead32 -extrn PciRead8 -extrn PciWrite8 -extrn AllocKernelSpace -extrn MapPage -extrn RegService -extrn KernelAlloc -extrn GetPgAddr -extrn GetCurrentTask - section '.flat' code readable align 16 proc START stdcall, state:dword @@ -1143,7 +1130,7 @@ align 4 devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS dd 0 -version dd 0x00010001 +version dd 0x00020002 msg_AC db '7012 AC97 controller',13,10, 0 msg_SIS db 'Silicon Integrated Systems',13,10, 0 diff --git a/kernel/trunk/drivers/unisound.asm b/kernel/trunk/drivers/unisound.asm index ccf6089bf0..8fde9be3c3 100644 --- a/kernel/trunk/drivers/unisound.asm +++ b/kernel/trunk/drivers/unisound.asm @@ -3,6 +3,7 @@ format MS COFF include 'proc32.inc' +include 'imports.inc' DEBUG equ 1 @@ -277,19 +278,6 @@ public START public service_proc public version -extrn AttachIntHandler -extrn SysMsgBoardStr -extrn PciApi -extrn PciRead32 -extrn PciRead8 -extrn PciWrite8 -extrn AllocKernelSpace -extrn MapPage -extrn RegService -extrn KernelAlloc -extrn GetPgAddr -extrn GetCurrentTask - section '.flat' code readable align 16 proc START stdcall, state:dword @@ -1363,7 +1351,7 @@ devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH dd 0 ;terminator -version dd 0x00010001 +version dd 0x00020002 msg_ICH db 'Intel ICH', 13,10, 0 msg_ICH0 db 'Intel ICH0', 13,10, 0 diff --git a/kernel/trunk/hid/mousedrv.inc b/kernel/trunk/hid/mousedrv.inc index 69a1e15a6b..131b7939e2 100644 --- a/kernel/trunk/hid/mousedrv.inc +++ b/kernel/trunk/hid/mousedrv.inc @@ -106,8 +106,8 @@ save_draw_mouse: cmp [ecx+CURSOR.magic], 'CURS' jne .fail - cmp [ecx+CURSOR.size], CURSOR_SIZE - jne .fail +; cmp [ecx+CURSOR.size], CURSOR_SIZE +; jne .fail push ecx call [set_hw_cursor] popad diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index c34a1d40f8..1bd3df02f9 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -438,15 +438,6 @@ B32: call init_events -; mov [dll_map], 0xFFFFFFFF -; mov [srv_map], 0xFFFFFFFF - -; call alloc_dll -; mov edi, eax -; mov esi, szKernel -; mov ecx, 16 -; rep movsb - mov eax, srv.fd-SRV_FD_OFFSET mov [srv.fd], eax mov [srv.bk], eax @@ -557,7 +548,6 @@ include 'vmodeld.inc' call setmouse mov [pci_access_enabled],1 - call init_cursors ; SET PRELIMINARY WINDOW STACK AND POSITIONS @@ -594,14 +584,19 @@ include 'vmodeld.inc' mov dword [0x80000+APPDATA.sse_handler], 0 ; name for OS/IDLE process + mov dword [0x80000+256+APPDATA.app_name], dword 'OS/I' mov dword [0x80000+256+APPDATA.app_name+4], dword 'DLE ' mov ebx, [def_cursor] mov dword [0x80000+256+APPDATA.cursor], ebx - mov dword [0x80000+256+APPDATA.fpu_handler], 0 mov dword [0x80000+256+APPDATA.sse_handler], 0 + mov ebx, PROC_BASE+256+APP_OBJ_OFFSET + mov dword [0x80000+256+APPDATA.fd_obj], ebx + mov dword [0x80000+256+APPDATA.bk_obj], ebx + + ;set fpu save area mov esi, eax bt [cpu_caps], CAPS_SSE @@ -646,6 +641,9 @@ include 'vmodeld.inc' mov ax,tss0 ltr ax + call init_cursors + + ; READ TSC / SECOND mov esi,boot_tsc diff --git a/kernel/trunk/kernel32.inc b/kernel/trunk/kernel32.inc index f3b44dfc54..81a9b8c3d7 100644 --- a/kernel/trunk/kernel32.inc +++ b/kernel/trunk/kernel32.inc @@ -182,8 +182,10 @@ struc APPDATA .cursor dd ? ;+44 .ev_first dd ? ;+48 .ev_last dd ? ;+52 + .fd_obj dd ? ;+56 + .bk_obj dd ? ;+60 - db 72 dup(?) ;+56 + db 64 dup(?) ;+64 .wnd_shape dd ? ;+128 .wnd_shape_scale dd ? ;+132 diff --git a/kernel/trunk/video/cursors.inc b/kernel/trunk/video/cursors.inc index 38258a5ba7..cf16aba202 100644 --- a/kernel/trunk/video/cursors.inc +++ b/kernel/trunk/video/cursors.inc @@ -270,87 +270,20 @@ alloc_cursor: xor ebx, ebx mov [eax+CURSOR.magic], 'CURS' - mov [eax+CURSOR.size], CURSOR_SIZE +; mov [eax+CURSOR.destructor], CURSOR_SIZE mov [eax+CURSOR.pid], ebx mov [eax+CURSOR.hot_x], ebx mov [eax+CURSOR.hot_y], ebx .fail: ret -if 0 - -align 4 -proc alloc_cursor - - pushfd - cli - mov ebx, [cursor_start] - mov ecx, [cursor_end] -.l1: - bsf eax,[ebx]; - jnz .found - add ebx,4 - cmp ebx, ecx - jb .l1 - popfd - xor eax,eax - ret -.found: - btr [ebx], eax - popfd - - mov [cursor_start],ebx - sub ebx, cursor_map - lea eax,[eax+ebx*8] - shl eax,3 - lea eax,[cursors+eax+eax*2] - - xor ebx, ebx - mov [eax+CURSOR.magic], 'CURS' - mov [eax+CURSOR.size], CURSOR_SIZE - mov [eax+CURSOR.pid], ebx - mov [eax+CURSOR.hot_x], ebx - mov [eax+CURSOR.hot_y], ebx - ret -endp - - -align 4 -proc free_cursor - pushfd - cli - xor edx, edx - mov ecx, CURSOR_SIZE - sub eax, cursors - div ecx - test edx, edx - jnz .exit - - mov ebx, cursor_map - bts [ebx], eax - shr eax, 3 - and eax, not 3 - add eax, ebx - cmp [cursor_start], eax - ja @f -.exit: - popfd - ret -@@: - mov [cursor_start], eax - popfd - ret -endp - -end if - align 4 proc set_cursor stdcall, hcursor:dword mov eax, [hcursor] cmp [eax+CURSOR.magic], 'CURS' jne .fail - cmp [eax+CURSOR.size], CURSOR_SIZE - jne .fail +; cmp [eax+CURSOR.size], CURSOR_SIZE +; jne .fail mov ebx, [CURRENT_TASK] shl ebx, 8 xchg eax, [ebx+PROC_BASE+APPDATA.cursor] @@ -363,17 +296,43 @@ proc set_cursor stdcall, hcursor:dword ret endp -proc vesa_cursor stdcall, hcursor:dword, src:dword, flags:dword +; param +; eax= pid +; ebx= src +; ecx= flags + +vesa_cursor: +.src equ esp +.flags equ esp+4 +.hcursor equ esp+8 + + sub esp, 4 ;space for .hcursor + push ecx + push ebx + + mov ebx, eax + mov eax, CURSOR_SIZE + call create_kernel_object + test eax, eax + jz .fail + + mov [.hcursor],eax + + xor ebx, ebx + mov [eax+CURSOR.magic], 'CURS' + mov [eax+CURSOR.destroy], destroy_cursor + mov [eax+CURSOR.hot_x], ebx + mov [eax+CURSOR.hot_y], ebx stdcall kernel_alloc, 0x1000 test eax, eax jz .fail - mov edi, [hcursor] + mov edi, [.hcursor] mov [edi+CURSOR.base], eax - mov esi, [src] - mov ebx, [flags] + mov esi, [.src] + mov ebx, [.flags] cmp bx, LOAD_INDIRECT je .indirect @@ -383,8 +342,9 @@ proc vesa_cursor stdcall, hcursor:dword, src:dword, flags:dword mov [edi+CURSOR.hot_y], edx stdcall vesa_init_cursor, eax, esi - mov eax, [hcursor] + mov eax, [.hcursor] .fail: + add esp, 12 ret .indirect: shr ebx, 16 @@ -397,8 +357,8 @@ proc vesa_cursor stdcall, hcursor:dword, src:dword, flags:dword mov ecx, 1024 cld rep movsd + add esp, 12 ret -endp align 4 proc load_cursor stdcall, src:dword, flags:dword @@ -416,16 +376,12 @@ proc load_cursor stdcall, src:dword, flags:dword jz .exit mov [src], eax @@: - call alloc_cursor - test eax, eax - jz .fail - - mov ebx, [CURRENT_TASK] - shl ebx, 5 - mov ebx, [0x3000+ebx+4] - mov [eax+CURSOR.pid], ebx - - stdcall [create_cursor], eax, [src], [flags] + mov eax, [CURRENT_TASK] + shl eax, 5 + mov eax, [0x3000+eax+4] + mov ebx, [src] + mov ecx, [flags] + call [create_cursor] ;eax, ebx, ecx mov [handle], eax .fail: cmp word [flags], LOAD_FROM_FILE @@ -450,8 +406,8 @@ proc delete_cursor stdcall, hcursor:dword mov esi, [hcursor] cmp [esi+CURSOR.magic], 'CURS' jne .fail - cmp [esi+CURSOR.size], CURSOR_SIZE - jne .fail +; cmp [esi+CURSOR.size], CURSOR_SIZE +; jne .fail mov ebx, [CURRENT_TASK] shl ebx, 5 @@ -466,31 +422,51 @@ proc delete_cursor stdcall, hcursor:dword mov eax, [def_cursor] mov [ebx+PROC_BASE+APPDATA.cursor], eax @@: - mov eax, [hw_cursor] - test eax, eax - jz @F - - xor ebx, ebx - mov ecx, [esi+CURSOR.base] - mov [hsrv], eax - mov [io_code], VIDEO_FREE - mov [input], ecx - mov [inp_size], 4 - mov [output], ebx - mov [out_size], ebx - - lea eax, [hsrv] - stdcall srv_handler, eax - jmp .exit -@@: - stdcall kernel_free, [esi+CURSOR.base] -.exit: mov eax, [hcursor] - call free + call [eax+APPOBJ.destroy] .fail: ret + +;@@: +; mov eax, [hw_cursor] +; test eax, eax +; jz @F + +; xor ebx, ebx +; mov ecx, [esi+CURSOR.base] +; mov [hsrv], eax +; mov [io_code], VIDEO_FREE +; mov [input], ecx +; mov [inp_size], 4 +; mov [output], ebx +; mov [out_size], ebx + +; lea eax, [hsrv] +; stdcall srv_handler, eax +; jmp .exit +;@@: +; stdcall kernel_free, [esi+CURSOR.base] +;.exit: +; mov eax, [hcursor] +; call destroy_kernel_object +;.fail: +; ret endp +; param +; eax= cursor + +align 4 +destroy_cursor: + + push eax + stdcall kernel_free, [eax+CURSOR.base] + pop eax + + + call destroy_kernel_object + ret + align 4 proc init_cursors cmp [0xfe0c],word 0x13 @@ -509,21 +485,6 @@ proc init_cursors .init: mov [cur_def_interl], ebx -if 0 - xor eax, eax - mov edi, cursors - mov ecx, CURSOR_SIZE*16 - cld - rep stosd - - not eax - mov [cursor_map], eax - mov [cursor_map+4], eax - mov edx, cursor_map - mov [cursor_start], edx - add edx, 8 - mov [cursor_end], edx -end if stdcall load_driver, drv_hw_mouse mov [hw_cursor], eax test eax, eax