Rev 1295 | Rev 2603 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1295 | Rev 1327 | ||
---|---|---|---|
Line 62... | Line 62... | ||
62 | public @EXPORT as 'EXPORTS' |
62 | public @EXPORT as 'EXPORTS' |
Line 63... | Line 63... | ||
63 | 63 | ||
64 | include '../../../../proc32.inc' |
64 | include '../../../../proc32.inc' |
65 | include '../../../../macros.inc' |
65 | include '../../../../macros.inc' |
66 | include '../libio/libio.inc' |
66 | include '../libio/libio.inc' |
Line 67... | Line 67... | ||
67 | purge section ; mov,add,sub |
67 | purge section,mov,add,sub |
Line 68... | Line 68... | ||
68 | 68 | ||
Line 655... | Line 655... | ||
655 | 655 | ||
656 | pop edi edx ecx |
656 | pop edi edx ecx |
657 | ret |
657 | ret |
Line -... | Line 658... | ||
- | 658 | endp |
|
- | 659 | ||
- | 660 | ;;================================================================================================;; |
|
- | 661 | proc ini.get_shortcut _f_name, _sec_name, _key_name, _def_val, _modifiers ;///////////////////////;; |
|
- | 662 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 663 | ;? Read shortcut key ;; |
|
- | 664 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 665 | ;> _f_name = ini filename |
|
- | 666 | ;> _sec_name = section name |
|
- | 667 | ;> _key_name = key name |
|
- | 668 | ;> _def_val = default value to return if no key, section or file found |
|
- | 669 | ;> _modifiers = pointer to dword variable which receives modifiers state as in 66.4 |
|
- | 670 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 671 | ;< eax = [_def_val] (error) / shortcut key value as scancode |
|
- | 672 | ;< [[_modifiers]] = unchanged (error) / modifiers state for this shortcut |
|
- | 673 | ;;================================================================================================;; |
|
- | 674 | locals |
|
- | 675 | buf rb 64 |
|
- | 676 | endl |
|
- | 677 | ||
- | 678 | push ebx esi edi |
|
- | 679 | ||
- | 680 | lea esi, [buf] |
|
- | 681 | stdcall ini.get_str, [_f_name], [_sec_name], [_key_name], esi, 64, 0 |
|
- | 682 | cmp byte[esi],0 |
|
- | 683 | je .exit_error |
|
- | 684 | ||
- | 685 | xor ebx, ebx ; ebx holds the value of modifiers |
|
- | 686 | .loop: |
|
- | 687 | ; test for end |
|
- | 688 | xor eax, eax |
|
- | 689 | cmp byte [esi], al |
|
- | 690 | jz .exit_ok ; exit with scancode zero |
|
- | 691 | ; skip all '+'s |
|
- | 692 | cmp byte [esi], '+' |
|
- | 693 | jnz @f |
|
- | 694 | inc esi |
|
- | 695 | jmp .loop |
|
- | 696 | @@: |
|
- | 697 | ; test for names |
|
- | 698 | mov edi, .names_table |
|
- | 699 | xor edx, edx |
|
- | 700 | .names_loop: |
|
- | 701 | movzx ecx, byte [edi] |
|
- | 702 | inc edi |
|
- | 703 | push esi |
|
- | 704 | @@: |
|
- | 705 | lodsb |
|
- | 706 | or al, 20h |
|
- | 707 | scasb |
|
- | 708 | loopz @b |
|
- | 709 | jz .name_found |
|
- | 710 | pop esi |
|
- | 711 | lea edi, [edi+ecx+4] |
|
- | 712 | inc edx |
|
- | 713 | cmp byte [edi], 0 |
|
- | 714 | jnz .names_loop |
|
- | 715 | ; special test: functional keys F |
|
- | 716 | cmp byte [esi], 'f' |
|
- | 717 | jz @f |
|
- | 718 | cmp byte [esi], 'F' |
|
- | 719 | jnz .no_fx |
|
- | 720 | @@: |
|
- | 721 | mov edi, esi |
|
- | 722 | inc esi |
|
- | 723 | call libini._.str_to_int |
|
- | 724 | test eax, eax |
|
- | 725 | jz .fx |
|
- | 726 | mov esi, edi |
|
- | 727 | .no_fx: |
|
- | 728 | ; name not found, that must be usual key |
|
- | 729 | movzx eax, byte [esi] |
|
- | 730 | stdcall libini._.ascii_to_scan, eax |
|
- | 731 | test eax, eax |
|
- | 732 | jz .exit_error |
|
- | 733 | ; all is ok |
|
- | 734 | .exit_ok: |
|
- | 735 | mov ecx, [_modifiers] |
|
- | 736 | test ecx, ecx |
|
- | 737 | jz @f |
|
- | 738 | mov [ecx], ebx |
|
- | 739 | ||
- | 740 | @@: |
|
- | 741 | ||
- | 742 | pop edi esi ebx |
|
- | 743 | ret |
|
- | 744 | ||
- | 745 | .exit_error: |
|
- | 746 | mov eax, [_def_val] |
|
- | 747 | pop edi esi ebx |
|
- | 748 | ret |
|
- | 749 | ; handler for Fx |
|
- | 750 | ; eax = number |
|
- | 751 | .fx: |
|
- | 752 | cmp eax, 10 |
|
- | 753 | ja @f |
|
- | 754 | add eax, 3Bh-1 |
|
- | 755 | jmp .exit_ok |
|
- | 756 | @@: |
|
- | 757 | add eax, 57h-11 |
|
- | 758 | jmp .exit_ok |
|
- | 759 | ; handlers for names |
|
- | 760 | .name_found: |
|
- | 761 | pop eax ; ignore saved esi |
|
- | 762 | call dword [edi] |
|
- | 763 | cmp edx, .num_modifiers |
|
- | 764 | jae .exit_ok |
|
- | 765 | jmp .loop |
|
- | 766 | ; modifiers |
|
- | 767 | ; syntax of value for each modifier: |
|
- | 768 | ; 0 = none, 1 = exactly one of L+R, 2 = both L+R, 3 = L, 4 = R |
|
- | 769 | ; Logic for switching: LShift+RShift=LShift+Shift=Shift+Shift, LShift+LShift=LShift |
|
- | 770 | ; generic modifier: 0->1->2->2, 3->2, 4->2 |
|
- | 771 | ; left modifier: 0->3->3, 1->2->2, 4->2 |
|
- | 772 | ; right modifier: 0->4->4, 1->2->2, 3->2 |
|
- | 773 | ; Shift corresponds to first hex digit, Ctrl - second, Alt - third |
|
- | 774 | macro shortcut_handle_modifiers name,reg,shift |
|
- | 775 | { |
|
- | 776 | local .set2,.set3,.set4 |
|
- | 777 | .#name#_handler: ; generic modifier |
|
- | 778 | test reg, 0xF |
|
- | 779 | jnz .set2 |
|
- | 780 | if shift |
|
- | 781 | or reg, 1 shl shift |
|
- | 782 | else |
|
- | 783 | inc reg |
|
- | 784 | end if |
|
- | 785 | retn |
|
- | 786 | .set2: |
|
- | 787 | and reg, not (0xF shl shift) |
|
- | 788 | or reg, 2 shl shift |
|
- | 789 | retn |
|
- | 790 | .l#name#_handler: |
|
- | 791 | mov al, reg |
|
- | 792 | and al, 0xF shl shift |
|
- | 793 | jz .set3 |
|
- | 794 | cmp al, 3 shl shift |
|
- | 795 | jnz .set2 |
|
- | 796 | retn |
|
- | 797 | .set3: |
|
- | 798 | add reg, 3 shl shift |
|
- | 799 | retn |
|
- | 800 | .r#name#_handler: |
|
- | 801 | mov al, reg |
|
- | 802 | and al, 0xF shl shift |
|
- | 803 | jz .set4 |
|
- | 804 | cmp al, 4 shl shift |
|
- | 805 | jnz .set2 |
|
- | 806 | retn |
|
- | 807 | .set4: |
|
- | 808 | add reg, 4 shl shift |
|
- | 809 | retn |
|
- | 810 | } |
|
- | 811 | shortcut_handle_modifiers shift,bl,0 |
|
- | 812 | shortcut_handle_modifiers ctrl,bl,4 |
|
- | 813 | shortcut_handle_modifiers alt,bh,0 |
|
- | 814 | ; names of keys |
|
- | 815 | .name_handler: |
|
- | 816 | movzx eax, byte [.names_scancodes+edx-.num_modifiers] |
|
- | 817 | retn |
|
- | 818 | endp |
|
- | 819 | ||
- | 820 | ; note: comparison ignores case, so this table keeps lowercase names |
|
- | 821 | ; macro does this |
|
- | 822 | macro shortcut_name_with_handler name,handler |
|
- | 823 | { |
|
- | 824 | local .start, .end |
|
- | 825 | db .end - .start |
|
- | 826 | .start: |
|
- | 827 | db name |
|
- | 828 | .end: |
|
- | 829 | repeat .end - .start |
|
- | 830 | load .a byte from .start + % - 1 |
|
- | 831 | store byte .a or 0x20 at .start + % - 1 |
|
- | 832 | end repeat |
|
- | 833 | dd handler |
|
- | 834 | } |
|
- | 835 | macro shortcut_name [name] |
|
- | 836 | { |
|
- | 837 | shortcut_name_with_handler name, .name_handler |
|
- | 838 | } |
|
- | 839 | ; all names here must be in english |
|
- | 840 | ; ... or modify lowercasing in macro and in comparison |
|
- | 841 | .names_table: |
|
- | 842 | ; generic modifiers |
|
- | 843 | shortcut_name_with_handler 'Ctrl', .ctrl_handler |
|
- | 844 | shortcut_name_with_handler 'Alt', .alt_handler |
|
- | 845 | shortcut_name_with_handler 'Shift', .shift_handler |
|
- | 846 | ; concrete modifiers |
|
- | 847 | shortcut_name_with_handler 'LCtrl', .lctrl_handler |
|
- | 848 | shortcut_name_with_handler 'RCtrl', .rctrl_handler |
|
- | 849 | shortcut_name_with_handler 'LAlt', .lalt_handler |
|
- | 850 | shortcut_name_with_handler 'RAlt', .ralt_handler |
|
- | 851 | shortcut_name_with_handler 'LShift', .lshift_handler |
|
- | 852 | shortcut_name_with_handler 'RShift', .rshift_handler |
|
- | 853 | .num_modifiers = 9 |
|
- | 854 | ; symbolic names of keys |
|
- | 855 | shortcut_name 'Home', 'End', 'PgUp', 'PgDn', 'Ins', 'Insert', 'Del', 'Delete' |
|
- | 856 | shortcut_name 'Tab', 'Plus', 'Esc', 'Enter', 'Backspace', 'Space', 'Left', 'Right' |
|
- | 857 | shortcut_name 'Up', 'Down' |
|
- | 858 | ; end of table |
|
- | 859 | db 0 |
|
- | 860 | ini.get_shortcut.names_scancodes: |
|
- | 861 | ; scancodes for 'Home' ... 'Down' |
|
- | 862 | db 47h, 4Fh, 49h, 51h, 52h, 52h, 53h, 53h |
|
Line 658... | Line 863... | ||
658 | endp |
863 | db 0Fh, 4Eh, 01h, 1Ch, 0Eh, 39h, 4Bh, 4Dh |
659 | 864 | db 48h, 50h |
|
660 | 865 | ||
661 | ;;================================================================================================;; |
866 | ;;================================================================================================;; |
Line 697... | Line 902... | ||
697 | align 16 |
902 | align 16 |
698 | @EXPORT: |
903 | @EXPORT: |
Line 699... | Line 904... | ||
699 | 904 | ||
700 | export \ |
905 | export \ |
701 | libini._.init , 'lib_init' , \ |
906 | libini._.init , 'lib_init' , \ |
702 | 0x00080008 , 'version' , \ |
907 | 0x00080009 , 'version' , \ |
703 | ini.enum_sections , 'ini_enum_sections' , \ |
908 | ini.enum_sections , 'ini_enum_sections' , \ |
704 | ini.enum_keys , 'ini_enum_keys' , \ |
909 | ini.enum_keys , 'ini_enum_keys' , \ |
705 | ini.get_str , 'ini_get_str' , \ |
910 | ini.get_str , 'ini_get_str' , \ |
706 | ini.get_int , 'ini_get_int' , \ |
911 | ini.get_int , 'ini_get_int' , \ |
707 | ini.get_color , 'ini_get_color' , \ |
912 | ini.get_color , 'ini_get_color' , \ |
708 | ini.set_str , 'ini_set_str' , \ |
913 | ini.set_str , 'ini_set_str' , \ |
709 | ini.set_int , 'ini_set_int' , \ |
914 | ini.set_int , 'ini_set_int' , \ |
- | 915 | ini.set_color , 'ini_set_color' , \ |