Rev 536 | Rev 555 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 536 | Rev 546 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | $Revision: 536 $ |
1 | $Revision: 546 $ |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3 | ;; ;; |
3 | ;; ;; |
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;; ;; |
6 | ;; ;; |
Line 860... | Line 860... | ||
860 | 860 | ||
861 | vesa20_drawbackground_stretch: |
861 | vesa20_drawbackground_stretch: |
862 | call [disable_mouse] |
862 | call [disable_mouse] |
863 | pushad |
863 | pushad |
- | 864 | ; Helper variables |
|
864 | ; Helper variables |
865 | ; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1) |
- | 866 | mov eax, [BgrDataWidth] |
|
865 | mov eax, [BgrDataWidth] |
867 | dec eax |
866 | xor edx, edx |
868 | xor edx, edx |
867 | mov ecx, [ScreenWidth] |
869 | div dword [ScreenWidth] |
868 | inc ecx |
870 | push eax ; high |
869 | div ecx |
871 | xor eax, eax |
870 | push eax ; quo |
872 | div dword [ScreenWidth] |
- | 873 | push eax ; low |
|
871 | push edx ; rem |
874 | ; the same for height |
- | 875 | mov eax, [BgrDataHeight] |
|
872 | mov eax, [BgrDataHeight] |
876 | dec eax |
873 | xor edx, edx |
877 | xor edx, edx |
874 | mov ecx, [ScreenHeight] |
878 | div dword [ScreenHeight] |
875 | inc ecx |
879 | push eax ; high |
876 | div ecx |
880 | xor eax, eax |
877 | push eax |
881 | div dword [ScreenHeight] |
878 | push edx |
882 | push eax ; low |
879 | ; External loop for all y from start to end |
883 | ; External loop for all y from start to end |
880 | mov ebx, [draw_data+32+RECT.top] ; y start |
884 | mov ebx, [draw_data+32+RECT.top] ; y start |
881 | mov ebp, [draw_data+32+RECT.left] ; x start |
885 | mov ebp, [draw_data+32+RECT.left] ; x start |
882 | ; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp] |
886 | ; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp] |
Line 895... | Line 899... | ||
895 | ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB |
899 | ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB |
896 | call calculate_edi |
900 | call calculate_edi |
897 | xchg edi, ebp |
901 | xchg edi, ebp |
898 | ; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress |
902 | ; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress |
899 | push ebx |
903 | push ebx |
900 | ; 2) Calculate offset in background memory block |
- | |
901 | push eax |
904 | push eax |
- | 905 | ; 2) Calculate offset in background memory block |
|
902 | mov eax, ebx |
906 | mov eax, ebx |
903 | mul dword [BgrDataHeight] |
907 | imul ebx, dword [esp+12] |
904 | mov ecx, [ScreenHeight] |
908 | mul dword [esp+8] |
905 | inc ecx |
- | |
906 | div ecx ; eax := y * BgrDataHeight / ScreenHeight |
909 | add edx, ebx ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1) |
907 | ; edx := (y * BgrDataHeight) mod ScreenHeight |
- | |
908 | mov esi, eax |
910 | mov esi, edx |
909 | pop eax |
- | |
910 | push edx ; dword [esp] = (y * BgrDataHeight) mod ScreenHeight |
- | |
911 | ; dword [esp+4] = y * BgrDataHeight / ScreenHeight |
- | |
912 | push eax |
- | |
913 | mov ecx, [BgrDataWidth] |
911 | imul esi, [BgrDataWidth] |
914 | lea edx, [ecx*3] |
- | |
915 | imul edx, [BgrDataHeight] |
- | |
916 | add edx, [img_background] |
- | |
917 | push edx |
912 | push edx |
918 | mul ecx |
913 | push eax |
919 | imul esi, ecx |
914 | mov eax, [esp+8] |
920 | dec ecx |
915 | mul dword [esp+28] |
921 | push ecx |
916 | push eax |
922 | mov ecx, [ScreenWidth] |
917 | mov eax, [esp+12] |
923 | inc ecx |
918 | mul dword [esp+28] |
924 | div ecx ; eax := x * BgrDataWidth / ScreenWidth |
919 | add [esp], edx |
925 | ; edx := (x * BgrDataWidth) mod ScreenWidth |
920 | pop edx ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1) |
926 | add esi, eax |
921 | add esi, edx |
927 | lea esi, [esi*3] |
922 | lea esi, [esi*3] |
928 | add esi, [img_background] |
923 | add esi, [img_background] |
- | 924 | mov ecx, eax |
|
929 | push ecx edx esi |
925 | push eax edx esi |
930 | ; 3) Loop through redraw rectangle and copy background data |
926 | ; 3) Loop through redraw rectangle and copy background data |
931 | ; Registers meaning: |
927 | ; Registers meaning: |
932 | ; ecx = (x * BgrDataWidth) / ScreenWidth |
928 | ; edx:ecx = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1) |
933 | ; edx = (x * BgrDataWidth) mod ScreenWidth (used to fast recalculating of ecx,esi) |
- | |
934 | ; esi -> bgr memory, edi -> output |
929 | ; esi -> bgr memory, edi -> output |
935 | ; ebp = offset in WinMapAddress |
930 | ; ebp = offset in WinMapAddress |
936 | ; dword [esp] = saved esi |
931 | ; dword [esp] = saved esi |
937 | ; dword [esp+4] = saved edx |
932 | ; dword [esp+4] = saved edx |
938 | ; dword [esp+8] = saved ecx |
933 | ; dword [esp+8] = saved ecx |
939 | ; dword [esp+12] = BgrDataWidth-1, x-limit for overlapping of points |
934 | ; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1) |
940 | ; dword [esp+16] = end of bgr memory (defines y-limit for overlapping of points) |
- | |
941 | ; dword [esp+20] = x |
935 | ; dword [esp+20] = x |
942 | ; dword [esp+24] = (y * BgrDataHeight) mod ScreenHeight (used to fast recalculating of esi) |
- | |
943 | ; dword [esp+28] = y |
936 | ; dword [esp+24] = y |
944 | ; precalculated constants: |
937 | ; precalculated constants: |
945 | ; dword [esp+32] = BgrDataHeight mod ScreenHeight |
- | |
946 | ; dword [esp+36] = BgrDataHeight div ScreenHeight |
938 | ; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1) |
947 | ; dword [esp+40] = BgrDataWidth mod ScreenWidth |
939 | ; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1) |
948 | ; dword [esp+44] = BgrDataWidth div ScreenWidth |
- | |
949 | sdp3: |
940 | sdp3: |
950 | add edx, [esp+40] |
- | |
951 | cmp [ebp+WinMapAddress], byte 1 |
941 | cmp [ebp+WinMapAddress], byte 1 |
952 | jnz snbgp |
942 | jnz snbgp |
953 | mov al, [esi+2] |
943 | mov al, [esi+2] |
954 | shl eax, 16 |
944 | shl eax, 16 |
955 | mov ax, [esi] |
945 | mov ax, [esi] |
956 | cmp ecx, [esp+12] |
946 | test ecx, ecx |
957 | jae @f |
- | |
958 | cmp edx, [ScreenWidth] |
- | |
959 | jb @f |
947 | jz @f |
960 | mov ebx, [esi+2] |
948 | mov ebx, [esi+2] |
961 | shr ebx, 8 |
949 | shr ebx, 8 |
962 | call overlapping_of_points |
950 | call overlapping_of_points |
963 | @@: |
951 | @@: |
964 | mov ebx, [esp+24] |
- | |
965 | add ebx, [esp+32] |
952 | cmp dword [esp+12], 0 |
966 | cmp ebx, [ScreenHeight] |
- | |
967 | jbe @f |
953 | jz .novert |
968 | mov ebx, [BgrDataWidth] |
954 | mov ebx, [BgrDataWidth] |
969 | lea ebx, [ebx*3] |
955 | lea ebx, [ebx*3] |
970 | add ebx, esi |
956 | add ebx, esi |
- | 957 | push eax |
|
971 | cmp ebx, [esp+16] |
958 | mov al, [ebx+2] |
- | 959 | shl eax, 16 |
|
- | 960 | mov ax, [ebx] |
|
- | 961 | test ecx, ecx |
|
972 | jae @f |
962 | jz .nohorz |
973 | mov ebx, [ebx-1] |
963 | mov ebx, [ebx+2] |
974 | shr ebx, 8 |
964 | shr ebx, 8 |
975 | call overlapping_of_points |
965 | call overlapping_of_points |
- | 966 | .nohorz: |
|
- | 967 | mov ebx, eax |
|
- | 968 | pop eax |
|
- | 969 | push ecx |
|
- | 970 | mov ecx, [esp+4+12] |
|
- | 971 | call overlapping_of_points |
|
- | 972 | pop ecx |
|
976 | @@: |
973 | .novert: |
977 | mov [edi], ax |
974 | mov [edi], ax |
978 | shr eax, 16 |
975 | shr eax, 16 |
979 | mov [edi+2], al |
976 | mov [edi+2], al |
980 | snbgp: |
977 | snbgp: |
981 | cmp [ScreenBPP], byte 25 |
978 | cmp [ScreenBPP], byte 25 |
Line 984... | Line 981... | ||
984 | mov eax, [esp+20] |
981 | mov eax, [esp+20] |
985 | add eax, 1 |
982 | add eax, 1 |
986 | mov [esp+20], eax |
983 | mov [esp+20], eax |
987 | cmp eax, [draw_data+32+RECT.right] |
984 | cmp eax, [draw_data+32+RECT.right] |
988 | ja sdp4 |
985 | ja sdp4 |
- | 986 | add ecx, [esp+36] |
|
- | 987 | mov eax, edx |
|
989 | mov eax, [esp+44] |
988 | adc edx, [esp+40] |
990 | add ecx, eax |
989 | sub eax, edx |
991 | lea eax, [eax*3] |
990 | lea eax, [eax*3] |
992 | add esi, eax |
991 | sub esi, eax |
993 | ; add edx, [esp+40] |
- | |
994 | cmp edx, [ScreenWidth] |
- | |
995 | jbe sdp3 |
- | |
996 | sub edx, [ScreenWidth] |
- | |
997 | add ecx, 1 |
- | |
998 | add esi, 3 |
- | |
999 | sub edx, 1 |
- | |
1000 | jmp sdp3 |
992 | jmp sdp3 |
1001 | sdp4: |
993 | sdp4: |
1002 | ; next y |
994 | ; next y |
1003 | mov ebx, [esp+28] |
995 | mov ebx, [esp+24] |
1004 | add ebx, 1 |
996 | add ebx, 1 |
1005 | mov [esp+28], ebx |
997 | mov [esp+24], ebx |
1006 | cmp ebx, [draw_data+32+RECT.bottom] |
998 | cmp ebx, [draw_data+32+RECT.bottom] |
1007 | ja sdpdone |
999 | ja sdpdone |
1008 | ; advance edi, ebp to next scan line |
1000 | ; advance edi, ebp to next scan line |
1009 | sub eax, [draw_data+32+RECT.left] |
1001 | sub eax, [draw_data+32+RECT.left] |
1010 | sub ebp, eax |
1002 | sub ebp, eax |
Line 1017... | Line 1009... | ||
1017 | jz @f |
1009 | jz @f |
1018 | sub edi, eax |
1010 | sub edi, eax |
1019 | @@: |
1011 | @@: |
1020 | add edi, [BytesPerScanLine] |
1012 | add edi, [BytesPerScanLine] |
1021 | ; restore ecx,edx; advance esi to next background line |
1013 | ; restore ecx,edx; advance esi to next background line |
- | 1014 | mov eax, [esp+28] |
|
- | 1015 | mov ebx, [esp+32] |
|
- | 1016 | add [esp+12], eax |
|
- | 1017 | mov eax, [esp+16] |
|
- | 1018 | adc [esp+16], ebx |
|
1022 | pop esi edx ecx |
1019 | pop esi edx ecx |
1023 | push ecx edx |
1020 | push ecx edx |
1024 | xor ebx, ebx |
- | |
1025 | mov eax, [esp+24-4] |
- | |
1026 | add eax, [esp+32-4] |
1021 | sub eax, [esp+16-4] |
1027 | cmp eax, [ScreenHeight] |
- | |
1028 | jbe @f |
- | |
1029 | sub eax, [ScreenHeight] |
- | |
1030 | mov ebx, 1 |
- | |
1031 | sub eax, ebx |
- | |
1032 | @@: |
- | |
1033 | mov [esp+24-4], eax |
- | |
1034 | add ebx, [esp+36-4] |
- | |
1035 | lea ebx, [ebx*3] |
1022 | lea eax, [eax*3] |
1036 | imul ebx, [BgrDataWidth] |
1023 | imul eax, [BgrDataWidth] |
1037 | add esi, ebx |
1024 | sub esi, eax |
1038 | push esi |
1025 | push esi |
1039 | mov eax, [draw_data+32+RECT.left] |
1026 | mov eax, [draw_data+32+RECT.left] |
1040 | mov [esp+20], eax |
1027 | mov [esp+20], eax |
1041 | jmp sdp3 |
1028 | jmp sdp3 |
1042 | sdpdone: |
1029 | sdpdone: |
1043 | add esp, 48 |
1030 | add esp, 44 |
1044 | popad |
1031 | popad |
1045 | mov [EGA_counter],1 |
1032 | mov [EGA_counter],1 |
1046 | call VGA_drawbackground |
1033 | call VGA_drawbackground |
1047 | ret |
1034 | ret |
Line 1048... | Line 1035... | ||
1048 | 1035 | ||
1049 | overlapping_of_points: |
1036 | overlapping_of_points: |
1050 | push ecx edx edi |
1037 | push ecx edx |
- | 1038 | mov edx, eax |
|
- | 1039 | push esi |
|
1051 | mov ecx, eax |
1040 | shr ecx, 24 |
1052 | mov edx, ebx |
1041 | mov esi, ecx |
1053 | movzx eax, cl |
1042 | mov ecx, ebx |
1054 | movzx ebx, dl |
- | |
1055 | add eax, ebx |
- | |
1056 | rcr eax, 1 |
1043 | movzx ebx, dl |
1057 | movzx edi, ax |
1044 | movzx eax, cl |
1058 | movzx eax, ch |
1045 | sub eax, ebx |
1059 | movzx ebx, dh |
1046 | movzx ebx, dh |
1060 | add eax, ebx |
- | |
1061 | rcr eax, 1 |
- | |
1062 | ror edi, 8 |
1047 | imul eax, esi |
1063 | add edi, eax |
- | |
1064 | shr ecx, 8 |
- | |
1065 | shr edx, 8 |
1048 | add dl, ah |
- | 1049 | movzx eax, ch |
|
- | 1050 | sub eax, ebx |
|
- | 1051 | imul eax, esi |
|
- | 1052 | add dh, ah |
|
- | 1053 | ror ecx, 16 |
|
- | 1054 | ror edx, 16 |
|
1066 | movzx eax, ch |
1055 | movzx eax, cl |
1067 | movzx ebx, dh |
1056 | movzx ebx, dl |
1068 | add eax, ebx |
1057 | sub eax, ebx |
1069 | rcr eax, 1 |
1058 | imul eax, esi |
- | 1059 | pop esi |
|
1070 | ror edi, 8 |
1060 | add dl, ah |
- | 1061 | mov eax, edx |
|
1071 | add eax, edi |
1062 | pop edx |
1072 | ror eax, 16 |
1063 | ror eax, 16 |
1073 | pop edi edx ecx |
1064 | pop ecx |