Subversion Repositories Kolibri OS

Rev

Rev 71 | Rev 77 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 71 Rev 75
Line 551... Line 551...
551
.rus1:
551
.rus1:
552
; 0x410-0x43F -> 0x80-0xAF
552
; 0x410-0x43F -> 0x80-0xAF
553
	add	al, 0x70
553
	add	al, 0x70
554
	jmp	.doit
554
	jmp	.doit
555
.rus2:
555
.rus2:
556
; 0x440-0x450 -> 0xE0-0xEF
556
; 0x440-0x44F -> 0xE0-0xEF
557
	add	al, 0xA0
557
	add	al, 0xA0
558
.ascii:
558
.ascii:
559
.doit:
559
.doit:
560
	stosb
560
	stosb
561
	jmp	uni2ansi_str
561
	jmp	uni2ansi_str
562
.done:
562
.done:
563
	mov	byte [edi], 0
563
	mov	byte [edi], 0
564
	ret
564
	ret
Line -... Line 565...
-
 
565
 
-
 
566
ansi2uni_char:
-
 
567
; convert ANSI character in al to UNICODE character in ax, using cp866 encoding
-
 
568
        mov     ah, 0
-
 
569
; 0x00-0x7F - trivial map
-
 
570
        cmp     al, 0x80
-
 
571
        jb      .ret
-
 
572
; 0x80-0xAF -> 0x410-0x43F
-
 
573
        cmp     al, 0xB0
-
 
574
        jae     @f
-
 
575
        add     ax, 0x410-0x80
-
 
576
.ret:
-
 
577
        ret
-
 
578
@@:
-
 
579
; 0xE0-0xEF -> 0x440-0x44F
-
 
580
        cmp     al, 0xE0
-
 
581
        jb      .unk
-
 
582
        cmp     al, 0xF0
-
 
583
        jae     @f
-
 
584
        add     ax, 0x440-0xE0
-
 
585
        ret
-
 
586
; 0xF0 -> 0x401
-
 
587
; 0xF1 -> 0x451
-
 
588
@@:
-
 
589
        cmp     al, 'ð'
-
 
590
        jz      .yo1
-
 
591
        cmp     al, 'ñ'
-
 
592
        jz      .yo2
-
 
593
.unk:
-
 
594
        mov     al, '_'         ; ah=0
-
 
595
        ret
-
 
596
.yo1:
-
 
597
        mov     ax, 0x401
-
 
598
        ret
-
 
599
.yo2:
-
 
600
        mov     ax, 0x451
-
 
601
        ret
565
 
602
 
566
char_toupper:
603
char_toupper:
567
; convert character to uppercase, using cp866 encoding
604
; convert character to uppercase, using cp866 encoding
568
; in: al=symbol
605
; in: al=symbol
569
; out: al=converted symbol
606
; out: al=converted symbol
Line 605... Line 642...
605
	cmp	byte [edi+11], 0xF
642
	cmp	byte [edi+11], 0xF
606
	jz	.longname
643
	jz	.longname
607
	push	ecx
644
	push	ecx
608
	mov	ecx, 8
645
	mov	ecx, 8
609
	push	edi ebp ecx
646
        push	edi ebp ecx
-
 
647
        cmp     byte [ebp-4], 0
-
 
648
        jnz     .unicode_short
610
@@:
649
@@:
611
	mov	al, [edi]
650
	mov	al, [edi]
612
	inc	edi
651
	inc	edi
613
	mov	[ebp], al
652
	mov	[ebp], al
614
	inc	ebp
653
	inc	ebp
Line 639... Line 678...
639
	dec	ebp
678
	dec	ebp
640
@@:
679
@@:
641
	and	byte [ebp], 0	; CF=0
680
	and	byte [ebp], 0	; CF=0
642
	pop	ebp edi ecx
681
	pop	ebp edi ecx
643
	ret
682
	ret
-
 
683
.unicode_short:
-
 
684
@@:
-
 
685
        mov     al, [edi]
-
 
686
        inc     edi
-
 
687
        call    ansi2uni_char
-
 
688
        mov     [ebp], ax
-
 
689
        inc     ebp
-
 
690
        inc     ebp
-
 
691
        loop    @b
-
 
692
        pop     ecx
-
 
693
@@:
-
 
694
	cmp	word [ebp-2], ' '
-
 
695
	jnz	@f
-
 
696
	dec	ebp
-
 
697
	dec     ebp
-
 
698
	loop	@b
-
 
699
@@:
-
 
700
	mov	word [ebp], '.'
-
 
701
	inc	ebp
-
 
702
	inc     ebp
-
 
703
	mov	ecx, 3
-
 
704
	push	ecx
-
 
705
@@:
-
 
706
	mov	al, [edi]
-
 
707
	inc	edi
-
 
708
	call    ansi2uni_char
-
 
709
	mov	[ebp], ax
-
 
710
        inc     ebp
-
 
711
        inc     ebp
-
 
712
        loop    @b
-
 
713
        pop     ecx
-
 
714
@@:
-
 
715
	cmp	word [ebp-2], ' '
-
 
716
	jnz	@f
-
 
717
	dec	ebp
-
 
718
	dec     ebp
-
 
719
	loop	@b
-
 
720
	dec	ebp
-
 
721
	dec     ebp
-
 
722
@@:
-
 
723
	and	word [ebp], 0	; CF=0
-
 
724
	pop	ebp edi ecx
-
 
725
	ret
644
.longname:
726
.longname:
645
; LFN
727
; LFN
646
	mov	al, byte [edi]
728
	mov	al, byte [edi]
647
	and	eax, 0x3F
729
	and	eax, 0x3F
648
	dec	eax
730
	dec	eax
Line 679... Line 761...
679
; if this is not first entry, more processing required
761
; if this is not first entry, more processing required
680
	stc
762
	stc
681
	ret
763
	ret
682
@@:
764
@@:
683
; if this is first entry:
765
; if this is first entry:
-
 
766
        cmp     byte [ebp-4], 0
-
 
767
        jnz     .ret
684
; buffer at ebp contains UNICODE name, convert it to ANSI
768
; buffer at ebp contains UNICODE name, convert it to ANSI
685
	push	esi edi
769
	push	esi edi
686
	mov	esi, ebp
770
	mov	esi, ebp
687
	mov	edi, ebp
771
	mov	edi, ebp
688
	call	uni2ansi_str
772
	call	uni2ansi_str
689
	pop	edi esi
773
	pop	edi esi
-
 
774
.ret:
690
	clc
775
	clc
691
	ret
776
	ret
Line 692... Line 777...
692
 
777
 
693
fat_compare_name:
778
fat_compare_name:
Line 723... Line 808...
723
@@:
808
@@:
724
	pop	eax
809
	pop	eax
725
	pop	esi ebp
810
	pop	esi ebp
726
	ret
811
	ret
Line -... Line 812...
-
 
812
 
-
 
813
fat_time_to_bdfe:
-
 
814
; in: eax=FAT time
-
 
815
; out: eax=BDFE time
-
 
816
	push	ecx edx
-
 
817
	mov	ecx, eax
-
 
818
	mov	edx, eax
-
 
819
	shr	eax, 11
-
 
820
	shl	eax, 16	; hours
-
 
821
	and	edx, 0x1F
-
 
822
	add	edx, edx
-
 
823
	mov	al, dl	; seconds
-
 
824
	shr	ecx, 5
-
 
825
	and	ecx, 0x3F
-
 
826
	mov	ah, cl	; minutes
-
 
827
	pop	edx ecx
-
 
828
	ret
-
 
829
 
-
 
830
fat_date_to_bdfe:
-
 
831
	push	ecx edx
-
 
832
	mov	ecx, eax
-
 
833
	mov	edx, eax
-
 
834
	shr	eax, 9
-
 
835
	add	ax, 1980
-
 
836
	shl	eax, 16	; year
-
 
837
	and	edx, 0x1F
-
 
838
	mov	al, dl	; day
-
 
839
	shr	ecx, 5
-
 
840
	and	ecx, 0xF
-
 
841
	mov	ah, cl	; month
-
 
842
	pop	edx ecx
-
 
843
	ret
-
 
844
 
-
 
845
fat_entry_to_bdfe:
-
 
846
; convert FAT entry at edi to BDFE (block of data of folder entry) at esi, advance esi
-
 
847
; destroys eax
-
 
848
        movzx   eax, byte [edi+11]
-
 
849
        mov     [esi], eax	; attributes
-
 
850
        mov     eax, [ebp-4]
-
 
851
        mov     [esi+4], eax	; ASCII/UNICODE name
-
 
852
        movzx   eax, word [edi+14]
-
 
853
        call    fat_time_to_bdfe
-
 
854
        mov     [esi+8], eax	; creation time
-
 
855
        movzx   eax, word [edi+16]
-
 
856
        call    fat_date_to_bdfe
-
 
857
        mov     [esi+12], eax	; creation date
-
 
858
        and     dword [esi+16], 0	; last access time is not supported on FAT
-
 
859
        movzx   eax, word [edi+18]
-
 
860
        call    fat_date_to_bdfe
-
 
861
        mov     [esi+20], eax	; last access date
-
 
862
        movzx   eax, word [edi+22]
-
 
863
        call    fat_time_to_bdfe
-
 
864
        mov     [esi+24], eax	; last write time
-
 
865
        movzx   eax, word [edi+24]
-
 
866
        call    fat_date_to_bdfe
-
 
867
        mov     [esi+28], eax	; last write date
-
 
868
        mov     eax, [edi+28]
-
 
869
        mov     [esi+32], eax	; file size (low dword)
-
 
870
        xor     eax, eax
-
 
871
        mov     [esi+36], eax	; file size (high dword)
-
 
872
        push    ecx edi
-
 
873
        lea     edi, [esi+40]
-
 
874
        mov     esi, ebp
-
 
875
        mov     ecx, 259/2
-
 
876
        rep     movsd
-
 
877
        movsw
-
 
878
        stosw
-
 
879
        mov     esi, edi
-
 
880
        pop     edi ecx
-
 
881
        ret
727
 
882
 
728
rd_find_lfn:
883
rd_find_lfn:
729
; in: esi->name
884
; in: esi->name
730
; out: CF=1 - file not found
885
; out: CF=1 - file not found
731
;      else CF=0 and edi->direntry
886
;      else CF=0 and edi->direntry
732
	push	esi ebp edi
887
	push	esi ebp edi
733
	sub	esp, 262*2	; allocate space for LFN
888
	sub	esp, 262*2	; allocate space for LFN
-
 
889
	mov	ebp, esp	; ebp points to buffer
734
	mov	ebp, esp	; ebp points to buffer
890
	push	0		; for fat_get_name: read ASCII name
735
	mov	edi, 0x100000+512*19	; to root dir
891
	mov	edi, 0x100000+512*19	; to root dir
736
.l1:
892
.l1:
737
	call	fat_get_name
893
	call	fat_get_name
738
	jc	.l2
894
	jc	.l2
Line 741... Line 897...
741
.l2:
897
.l2:
742
	add	edi, 0x20
898
	add	edi, 0x20
743
	cmp	edi, 0x100000+512*33
899
	cmp	edi, 0x100000+512*33
744
	jb	.l1
900
	jb	.l1
745
.notfound:
901
.notfound:
746
	add	esp, 262*2
902
	add	esp, 262*2+4
747
	pop	edi ebp esi
903
	pop	edi ebp esi
748
	stc
904
	stc
749
	ret
905
	ret
750
.found:
906
.found:
751
; found
907
; found
Line 755... Line 911...
755
	add	edi, 0x20
911
	add	edi, 0x20
756
@@:
912
@@:
757
; folders are not supported
913
; folders are not supported
758
	cmp	byte [esi], 0
914
	cmp	byte [esi], 0
759
	jnz	.notfound
915
	jnz	.notfound
760
	add	esp, 262*2+4	; CF=0
916
	add	esp, 262*2+4+4	; CF=0
761
	pop	ebp esi
917
	pop	ebp esi
762
	ret
918
	ret
Line 763... Line 919...
763
 
919
 
764
;----------------------------------------------------------------
920
;----------------------------------------------------------------
Line 849... Line 1005...
849
.done:
1005
.done:
850
	pop	edx ecx ebx ebx edi
1006
        pop     edx ecx ebx ebx edi
851
	xor	eax, eax
1007
        xor     eax, eax
852
	ret
1008
        ret
Line -... Line 1009...
-
 
1009
 
-
 
1010
;----------------------------------------------------------------
-
 
1011
;
-
 
1012
;  fs_RamdiskReadFolder - LFN variant for reading sys floppy folder
-
 
1013
;
-
 
1014
;  esi  points to filename; only root is folder on ramdisk
-
 
1015
;  ebx  pointer to 32-bit number = first wanted block
-
 
1016
;  ecx  number of blocks to read, 0+
-
 
1017
;  edx  mem location to return data
-
 
1018
;
-
 
1019
;  ret ebx = size or 0xffffffff file not found
-
 
1020
;      eax = 0 ok read or other = errormsg
-
 
1021
;
-
 
1022
;--------------------------------------------------------------
-
 
1023
fs_RamdiskReadFolder:
-
 
1024
        mov     ebx, [ebx]
-
 
1025
        cmp     byte [esi], 0
-
 
1026
        jz      @f
-
 
1027
; ramdisk doesn't support folders
-
 
1028
        mov     eax, ERROR_ACCESS_DENIED
-
 
1029
        or      ebx, -1
-
 
1030
        ret
-
 
1031
@@:
-
 
1032
        push    esi edi ecx
-
 
1033
; init header
-
 
1034
        push    ecx
-
 
1035
        mov     edi, edx
-
 
1036
        mov     ecx, 32/4
-
 
1037
        xor     eax, eax
-
 
1038
        rep     stosd
-
 
1039
        mov     byte [edx], 1   ; version
-
 
1040
        pop     ecx
-
 
1041
        push    ebp
-
 
1042
        sub     esp, 262*2      ; allocate space for LFN
-
 
1043
        mov     ebp, esp
-
 
1044
        push    1               ; for fat_get_name: read UNICODE name
-
 
1045
; read root
-
 
1046
        mov     esi, edi        ; esi points to block of data of folder entry (BDFE)
-
 
1047
        mov     edi, 0x100000+512*19
-
 
1048
.l1:
-
 
1049
        call    fat_get_name
-
 
1050
        jc      .l2
-
 
1051
        cmp     byte [edi+11], 0xF
-
 
1052
        jnz     @f
-
 
1053
        add     edi, 0x20
-
 
1054
@@:
-
 
1055
        inc     dword [edx+8]   ; new file found
-
 
1056
        dec     ebx
-
 
1057
        jns     .l2
-
 
1058
        dec     ecx
-
 
1059
        js      .l2
-
 
1060
        inc     dword [edx+4]  ; new file block copied
-
 
1061
        call    fat_entry_to_bdfe
-
 
1062
.l2:
-
 
1063
        add     edi, 0x20
-
 
1064
        cmp     edi, 0x100000+512*33
-
 
1065
        jb      .l1
-
 
1066
        add     esp, 262*2+4
-
 
1067
        pop     ebp
-
 
1068
        mov     ebx, [edx+8]
-
 
1069
        xor     eax, eax
-
 
1070
        dec     ecx
-
 
1071
        js      @f
-
 
1072
        mov     al, ERROR_END_OF_FILE
-
 
1073
@@:
-
 
1074
        pop     ecx edi esi
-
 
1075
        ret
853
 
1076
 
854
; \end{diamond}
1077
; \end{diamond}