1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029
|
; asmsyntax=nasm
;
; main-cmds.asm
;
; command handles for main program
;
; Copyright (C) 2000, Suzhe. See file COPYING for details.
;
%ifdef MAIN
%define MAIN_MENU_ON 0x01
%define RECORD_MENU_ON 0x02
%define SYS_MENU_ON 0x04
;=============================================================================
;show_help ---- show the help window
;=============================================================================
show_help:
mov di, [str_idx.help]
mov si, [str_idx.help_content]
or si, si
jz .end
call count_lines
mov dx, cx
add dh, [size.box_height]
add dl, [size.box_width]
mov al, [color.help_msg]
mov bx, [color.help_win_frame]
xchg si, di
call message_box
call get_key
call draw_screen
.end:
ret
;=============================================================================
;show_about ---- show the about window
;=============================================================================
show_about:
mov di, [str_idx.about]
mov si, [str_idx.about_content]
or si, si
jz .end
call count_lines
mov dx, cx
add dh, [size.box_height]
add dl, [size.box_width]
mov al, [color.about_msg]
mov bx, [color.about_win_frame]
xchg si, di
call message_box
call get_key
call draw_screen
.end:
ret
;=============================================================================
;ask_save_changes ---- save boot manager to disk
;=============================================================================
ask_save_changes:
cmp byte [change_occured], 0
je .no_changes
mov si, [str_idx.ask_save_changes]
call info_box
cmp ax, kbEnter
je save_changes
cmp al, [yes_key_lower]
je save_changes
cmp al, [yes_key_upper]
je save_changes
.no_changes:
ret
;=============================================================================
;save_changes ---- save boot manager to disk
;=============================================================================
save_changes:
test byte [kernel_flags], KNLFLAG_SECURITY
jz .normal
call confirm_root_passwd
jc .end
.normal:
%ifndef EMULATE_PROG
call save_boot_manager
jc .disk_error
%endif
mov byte [change_occured], 0 ; clear change signature.
mov si, [str_idx.changes_saved]
call info_box
ret
.disk_error:
call show_disk_error
.end:
ret
;=============================================================================
;change_video_mode ---- change the video mode
;=============================================================================
change_video_mode:
inc byte [change_occured] ; some changes occured.
mov al, [video_mode]
not al
mov [video_mode], al
call init_video
call draw_screen
ret
;=============================================================================
;up_cur_in_menu ---- move the boot record cursor up in command menu
;=============================================================================
up_cur_in_menu:
call up_cursor
call draw_screen
ret
;=============================================================================
;up_cursor ---- move the cursor up
;=============================================================================
up_cursor:
mov al, [focus_record]
or al, al ; already at top of the list
jz .end ; do nothing
dec al
mov [focus_record], al
cmp [first_visible_rec], al
jbe .end ; no need to scroll down.
mov [first_visible_rec], al ;
.end:
ret
;=============================================================================
;down_cur_in_menu ---- move the boot record cursor down in command menu
;=============================================================================
down_cur_in_menu:
call down_cursor
call draw_screen
ret
;=============================================================================
;down_cursor ---- move the cursor down
;=============================================================================
down_cursor:
mov al, [focus_record]
inc al
cmp al, [good_record_number] ;
jae .end ; already at bottom of the list
mov [focus_record], al
sub al, [first_visible_rec]
cmp al, [size.bootmenu_height]
jb .end ; no need to scroll up
inc byte [first_visible_rec]
.end:
ret
;=============================================================================
;change_name ---- change the record name
;=============================================================================
change_name:
call auth_record_cmd
jc .end
call get_record_pointer
add si, struc_bootrecord.name ;
lea di, [tmp_buffer] ; get old name.
mov cl, MAX_NAME_LENGTH ;
xor ch, ch ;
push cx ;
push di ;
call strncpy ;
pop di ;
pop cx ;
push si
movzx ax, byte [color.input_box_msg]
mov bx, [color.input_box_frame]
mov si, [str_idx.name]
call input_box
pop si
jc .end_clean
xchg di, si
xor ch, ch
call strncpy
inc byte [change_occured] ; some changes occured.
.end_clean:
call draw_screen
.end:
ret
;=============================================================================
;login_as_root ---- login as root
;=============================================================================
login_as_root:
cmp dword [root_password], 0
jz .end
mov al, [root_login]
or al, al
jnz .logout
call confirm_root_passwd
jc .end
mov byte [root_login], 1
jmp short .end_clean
.logout:
xor al, al
mov [root_login], al
.end_clean:
call draw_screen
.end:
ret
;=============================================================================
;change_security_mode ---- change the secure mode
;=============================================================================
change_security_mode:
cmp dword[root_password], 0
jz .end
test byte [kernel_flags], KNLFLAG_SECURITY
jz .enter_security
call confirm_root_passwd
jc .end
and byte [kernel_flags], ~ KNLFLAG_SECURITY
jmp short .end_clean
.enter_security:
or byte [kernel_flags], KNLFLAG_SECURITY
.end_clean:
inc byte [change_occured]
call draw_screen
.end:
ret
;=============================================================================
;change_root_passwd ---- change the root password
;=============================================================================
change_root_passwd:
call confirm_root_passwd
jc .end
mov si, [str_idx.new_root_passwd]
call input_passwd
jc .end
mov bx, ax
mov cx, dx
push bx
push cx
mov si, [str_idx.retype_passwd]
call input_passwd
pop cx
pop bx
jc .end
cmp bx, ax
jne .wrong
cmp cx, dx
jne .wrong
mov [root_password], bx
mov [root_password+2], cx
mov byte [root_login], 0
and byte [kernel_flags], ~ KNLFLAG_SECURITY
mov si, [str_idx.passwd_changed]
call info_box
inc byte [change_occured] ; some changes occured.
jmp short .end
.wrong:
mov si, [str_idx.wrong_passwd]
call error_box
.end:
ret
;=============================================================================
;change_record_passwd ---- change the record password
;=============================================================================
change_record_passwd:
call auth_record_cmd
jc .end
mov si, [str_idx.new_record_passwd]
call input_passwd
jc .end
mov bx, ax
mov cx, dx
push bx
push cx
mov si, [str_idx.retype_passwd]
call input_passwd
pop cx
pop bx
jc .end
cmp bx, ax
jne .wrong
cmp cx, dx
jne .wrong
call get_record_pointer
mov [si+struc_bootrecord.password], bx
mov [si+struc_bootrecord.password+2], cx
mov si, [str_idx.passwd_changed]
call info_box
inc byte [change_occured] ; some changes occured.
ret
.wrong:
mov si, [str_idx.wrong_passwd]
call error_box
.end:
ret
;=============================================================================
;set_default_record ---- set the default boot record
;=============================================================================
set_default_record:
cmp byte [good_record_number], 0
je .end
call confirm_root_passwd
jc .end
movzx dx, [focus_record] ; get real record index
lea si, [good_record_list] ;
add si, dx ;
lodsb ;
mov [default_record], al
inc byte [change_occured] ; some changes occured.
call draw_bootmenu
.end:
ret
;=============================================================================
;unset_default_record ---- unset the default boot record
;=============================================================================
unset_default_record:
call confirm_root_passwd
jc .end
mov byte [default_record], 0xFF
inc byte [change_occured] ; some changes occured.
call draw_bootmenu
.end:
ret
;=============================================================================
;toggle_auto_active ---- toggle the auto active switch
;=============================================================================
toggle_auto_active:
cmp byte [good_record_number], 0
je .end
call get_record_pointer
call check_allow_act
jc .end
push si
call confirm_security_passwd
pop si
jc .end
xor word [si + struc_bootrecord.flags], INFOFLAG_AUTOACTIVE
inc byte [change_occured] ; some changes occured.
.end:
ret
;=============================================================================
;toggle_auto_hide ---- toggle the auto hide switch
;=============================================================================
toggle_auto_hide:
cmp byte [good_record_number], 0
je .end
call get_record_pointer
call check_allow_hide
jc .end
push si
call confirm_security_passwd
pop si
jc .end
xor word [si + struc_bootrecord.flags], INFOFLAG_AUTOHIDE
inc byte [change_occured] ; some changes occured.
.end:
ret
;=============================================================================
;mark_active ---- mark the record active
;=============================================================================
mark_active:
cmp byte [good_record_number], 0
je .end
call get_record_pointer
call check_allow_act
jc .end
push si
call confirm_security_passwd
pop si
jc .end
mov dl, [si + struc_bootrecord.drive_id]
push si
lea si, [good_record_list]
lea di, [boot_records]
movzx cx, byte [good_record_number]
mov dh, SIZE_OF_BOOTRECORD
xor ebx, ebx
cld
.loop_clear_act: ; clear all active marks of
push di ; the boot records in same
lodsb ; drive and father partition.
mul dh
add di, ax
cmp dl, [di + struc_bootrecord.drive_id]
jne .do_nothing
cmp [di + struc_bootrecord.father_abs_addr], ebx
jne .do_nothing
and word [di + struc_bootrecord.flags], ~ INFOFLAG_ACTIVE
.do_nothing:
pop di
loop .loop_clear_act
pop si
call mark_record_active
jc .error ; mark active ok
call recheck_same_records ; recheck same records
jc .disk_error
ret
.error:
or ax, ax
jz .cannot_act
.disk_error:
call show_disk_error
ret
.cannot_act:
mov si, [str_idx.mark_act_failed]
call error_box
.end:
ret
;=============================================================================
;toggle_hidden ---- toggle a record's hidden attribute
;=============================================================================
toggle_hidden:
cmp byte [good_record_number], 0
je .end
call get_record_pointer
call check_allow_hide
jc .end
push si
call confirm_security_passwd
pop si
jc .end
call toggle_record_hidden
jc .error ; toggle hidden ok
call recheck_same_records ; recheck same records
jc .disk_error
ret
.error:
or ax, ax
jz .cannot_hide
.disk_error:
call show_disk_error
ret
.cannot_hide:
mov si, [str_idx.toggle_hid_failed]
call error_box
.end:
ret
;=============================================================================
;delete_record ---- delete a boot record
;=============================================================================
delete_record:
cmp byte [good_record_number], 0
je .end
call confirm_root_passwd
jc .end
call get_record_pointer
test word [si + struc_bootrecord.flags], INFOFLAG_HIDDEN
jz .del_it
call toggle_record_hidden ; unhide it first.
jnc .del_it ; unhide ok, del it.
or ax, ax
jz .cannot_hide
call show_disk_error
ret
.cannot_hide:
mov si, [str_idx.toggle_hid_failed]
call error_box
ret
.del_it:
xor al, al
mov di, si
mov cx, SIZE_OF_BOOTRECORD
cld
rep stosb
inc byte [change_occured] ; some changes occured.
call init_good_record_list
mov al, [good_record_number]
or al, al
jz .no_record
dec al
cmp al, [first_visible_rec] ; adjust the cursor
jae .check_focus_pos ; and menu position.
mov [first_visible_rec], al ;
.check_focus_pos: ;
cmp al, [focus_record] ;
jae .end ;
mov [focus_record], al ;
ret
.no_record:
mov [first_visible_rec], al
mov [focus_record], al
.end:
ret
;=============================================================================
;rescan_all_drives ---- research all drives for boot records
;=============================================================================
rescan_all_records:
and byte [kernel_flags], ~ KNLFLAG_ONLYPARTS
jmp short rescan_records
;=============================================================================
;rescan_fixed_drives ---- research fixed drives for boot records
;=============================================================================
rescan_all_partitions:
or byte [kernel_flags], KNLFLAG_ONLYPARTS
;=============================================================================
;rescan_records ---- research all drives for boot records
;=============================================================================
rescan_records:
call confirm_root_passwd
jc .end
movzx cx, byte [good_record_number]
or cl, cl ; if no good record then go to
jz .init_it ; init directly.
lea di, [good_record_list]
mov dl, SIZE_OF_BOOTRECORD
; unhide all hidden partition first.
.loop_unhide:
mov al, [di]
inc di
mul dl
lea si, [boot_records]
add si, ax
test word [si + struc_bootrecord.flags], INFOFLAG_HIDDEN
jz .not_hidden
call toggle_record_hidden
jc .hidden_error
call recheck_same_records
jc .disk_error
.not_hidden:
loop .loop_unhide
.init_it:
inc byte [change_occured] ; some changes occured.
call init_boot_records
call init_good_record_list
xor al, al
mov byte [focus_record], al
mov byte [first_visible_rec], al
call draw_screen
jmp short .end
.hidden_error:
or ax, ax
jz .cannot_hide
.disk_error:
call show_disk_error
ret
.cannot_hide:
mov si, [str_idx.toggle_hid_failed]
call error_box
.end:
ret
;=============================================================================
;move_main_win_left ---- move the main window left
;=============================================================================
move_main_win_left:
mov al, [main_window_col]
or al, al
jz .no_move
dec al
mov [main_window_col], al
call draw_screen
.no_move:
ret
;=============================================================================
;move_main_win_up ---- move the main window up
;=============================================================================
move_main_win_up:
mov al, [main_window_row]
cmp al, [size.copyright]
jbe .no_move
dec al
mov [main_window_row], al
call draw_screen
.no_move:
ret
;=============================================================================
;move_main_win_right ---- move the main window right
;=============================================================================
move_main_win_right:
mov al, [main_window_col]
mov ah, [screen_width]
sub ah, [main_win_width]
sub ah, 2
cmp al, ah
jae .no_move
inc al
mov [main_window_col], al
call draw_screen
.no_move:
ret
;=============================================================================
;move_main_win_down ---- move the main window down
;=============================================================================
move_main_win_down:
mov al, [main_window_row]
mov ah, [screen_height]
sub ah, [size.hint]
cmp al, ah
jae .no_move
inc al
mov [main_window_row], al
call draw_screen
.no_move:
ret
;=============================================================================
;set_delay_time ---- set the delay time
;=============================================================================
set_delay_time:
call confirm_root_passwd
jc .end
movzx ax, [color.input_box_msg]
mov bx, [color.input_box_frame]
mov cl, 3
mov si, [str_idx.delay_time]
lea di, [tmp_buffer]
mov byte [di], 0
call input_box
jc .end_clean
mov si, di
call atoi
cmp ax, 255
jbe .set_time
mov al, 255
.set_time:
mov [delay_time], al
inc byte [change_occured] ; some changes occured.
.end_clean:
call draw_screen
.end:
ret
;=============================================================================
;boot_it ---- boot the selected record
;=============================================================================
boot_it:
cmp byte [good_record_number], 0
je .end
call confirm_record_passwd
jc .end
movzx dx, byte [focus_record] ; get real record index
lea si, [good_record_list] ;
add si, dx ;
lodsb ;
push ax
test byte [kernel_flags], KNLFLAG_REMLAST
jz .no_remlast
mov [default_record], al
call save_boot_manager
jnc .cont_boot
call show_disk_error
jmp short .cont_boot
.no_remlast:
call ask_save_changes ; ask if save the changes.
.cont_boot:
call hide_auto_hides
pop ax
jc .end
call do_boot_record
.end:
ret
;=============================================================================
;return_to_bios ---- give control back to BIOS
;=============================================================================
return_to_bios:
call confirm_root_passwd
jc .end
call ask_save_changes ; ask if save the changes.
call reset_video_mode
call uninstall_myint13h
%ifdef EMULATE_PROG
mov ax, 0x4c00 ; exit to dos
int 0x21 ;
%else
int 0x18 ; return to BIOS
%endif
.end:
ret
;=============================================================================
; Duplicate the boot record
;=============================================================================
dup_bootrecord:
cmp byte [good_record_number], 0
je .end
call confirm_root_passwd
jc .end
mov ax, SIZE_OF_BOOTRECORD
mov cx, MAX_RECORD_NUM
lea di, [boot_records]
.search_empty_slot:
test byte [di + struc_bootrecord.flags], DRVFLAG_DRIVEOK | INFOFLAG_ISSPECIAL
jz .found_empty
add di, ax
loop .search_empty_slot
jmp short .no_empty_slot
.found_empty:
inc byte [change_occured]
call get_record_pointer
mov cx, ax
cld
rep movsb
call init_good_record_list
.no_empty_slot:
.end:
ret
;=============================================================================
; move the boot record down
;=============================================================================
move_record_down:
movzx bx, byte [focus_record]
mov al, [good_record_list + bx]
inc bl
mov ah, [good_record_list + bx]
cmp bl, [good_record_number]
jae .end
cmp al, [default_record]
jne .chknext
mov [default_record], ah
jmp short .swap_record
.chknext:
cmp ah, [default_record]
jne .swap_record
mov [default_record], al
.swap_record:
mov [focus_record], bl
call swap_records
dec byte [focus_record]
call down_cursor
.end:
ret
;=============================================================================
; move the boot record up
;=============================================================================
move_record_up:
movzx bx, byte [focus_record]
or bl, bl
jz .end
mov al, [good_record_list + bx]
dec bl
mov ah, [good_record_list + bx]
cmp al, [default_record]
jne .chknext
mov [default_record], ah
jmp short .swap_record
.chknext:
cmp ah, [default_record]
jne .swap_record
mov [default_record], al
.swap_record:
call swap_records
call up_cursor
.end:
ret
;=============================================================================
; swap current and previous boot record
;=============================================================================
swap_records:
dec byte [focus_record]
call get_record_pointer
mov di, si
inc byte [focus_record]
call get_record_pointer ; si -> current di -> prev
mov cx, SIZE_OF_BOOTRECORD
.loop_swap:
mov al, [si]
mov bl, [di]
mov [si], bl
mov [di], al
inc si
inc di
loop .loop_swap
ret
;=============================================================================
;toggle_swapid ---- toggle the swap driver id flag
;=============================================================================
toggle_swapid:
call get_record_pointer
test word [si + struc_bootrecord.flags], DRVFLAG_ISCDROM | INFOFLAG_ISSPECIAL
jnz .end
push si
call auth_record_cmd
pop si
jc .end
xor word [si + struc_bootrecord.flags], INFOFLAG_SWAPDRVID
call check_bootrecord
inc byte [change_occured]
.end:
ret
;=============================================================================
;toggle_schedule ---- toggle the schedule of the bootrecord
;=============================================================================
toggle_schedule:
call auth_record_cmd
jc .end
call get_record_pointer
test word [si + struc_bootrecord.flags], INFOFLAG_SCHEDULED
jnz .clear_schedule
push si
call input_schedule_time
pop si
jc .end
or dx, dx
jnz .set_schedule
not dx
.set_schedule:
call set_record_schedule
jmp short .end_ok
.clear_schedule:
and word [si + struc_bootrecord.flags], ~INFOFLAG_SCHEDULED
.end_ok:
inc byte [change_occured]
.end:
ret
;=============================================================================
;input_schedule_time ---- input the schedule time
;input:
; none
;output:
; cf = 0 success,
; ax = begin time (in minutes)
; bx = end time (in minutes)
; dx = days info (bit 0 to bit 7 indicate Mon to Sun)
; cf = 1 cancel
;=============================================================================
input_schedule_time:
pusha
xor ax, ax
mov cx, 4
cld
mov di, tmp_schedule_begin
rep stosw
mov al, [color.input_box_msg]
mov bx, [color.input_box_frame]
mov si, [str_idx.input_schedule]
mov cl, 19
lea di, [tmp_schedule_input]
call input_box
jc .failed
;convert begin time
mov si, di
call str_to_schtime
jc .invalid_input
mov [tmp_schedule_begin], ax
;convert end time
lodsb
cmp al,'-'
jne .invalid_input
call str_to_schtime
jc .invalid_input
mov [tmp_schedule_end], ax
;convert day info
lodsb
or al, al
jz .end
cmp al, ';'
jne .invalid_input
mov cx, 7
xor dx, dx
.loop_get_days:
lodsb
or al, al
jz .end_get_days
sub al, '0'
cmp al, 7
jae .invalid_input
mov bx, 1
push cx
mov cl, al
shl bx, cl
pop cx
or dx, bx
loop .loop_get_days
.end_get_days:
mov [tmp_schedule_day], dx
.end:
clc
.failed:
pushf
call draw_screen
popf
jmp short .exit
.invalid_input:
call draw_screen
mov si, [str_idx.invalid_schedule]
call error_box
stc
.exit:
popa
mov ax, [tmp_schedule_begin]
mov bx, [tmp_schedule_end]
mov dx, [tmp_schedule_day]
ret
;=============================================================================
;input ds:si -> string
;output cf =0 ok, ax = time in minutes
; cf =1 fail
;=============================================================================
str_to_schtime:
xor bx, bx
xor cx, cx
call atoi
cmp al, 24 ; hh must be less than 24
ja .fail
mov bl, al
lodsb
cmp al, ':'
jne .fail
call atoi
cmp al, 60 ; mm must be less than 60
jae .fail
mov cl, al
mov al, 60
mul bl
add ax, cx
cmp ax, 24*60 ; begin time must be no more than
ja .fail ; 24*60 minutes
clc
ret
.fail:
stc
ret
;=============================================================================
;toggle_keystrokes ---- toggle the keystrokes switch of the bootrecord
;=============================================================================
toggle_keystrokes:
call auth_record_cmd
jc .end
call get_record_pointer
test word [si + struc_bootrecord.flags], INFOFLAG_HAVEKEYS
jz .input_keys
and word [si + struc_bootrecord.flags], ~INFOFLAG_HAVEKEYS
jmp short .end_ok
.input_keys:
lea di, [si + struc_bootrecord.keystrokes]
mov cl, MAX_KEYSTROKES
push si
call input_keystrokes
pop si
or ch, ch
jz .end
or word [si + struc_bootrecord.flags], INFOFLAG_HAVEKEYS
.end_ok:
inc byte [change_occured]
.end:
ret
;=============================================================================
;input_keystrokes ---- input a set of key strokes
;input:
; cl = max key strokes number
; es:di -> the buffer
;output:
; es:di -> the buffer filled by key strokes
; ch = number of key strokes that inputed
;=============================================================================
input_keystrokes:
call turnon_scrolllock
push di
xor ch, ch
xor ax, ax
cld
.loop_input:
push cx
push di
call draw_ikm_box
call read_keystroke
pop di
pop cx
stosw
jc .end
inc ch
cmp ch, cl
jb .loop_input
.end:
push cx
call draw_screen
pop cx
pop di
call turnoff_scrolllock
ret
;=============================================================================
;draw_ikm_box ---- draw input keystrokes message box
;input:
; ax = key code
; ch = key count
;=============================================================================
draw_ikm_box:
pusha
mov si, [str_idx.input_keystrokes]
lea di, [tmp_buffer]
push di
push cx
call strcpy
mov cl, 4
call htoa ; fill in the key code string
add di, 4
mov si, [str_idx.key_count]
call strcpy
pop cx
movzx ax, ch
mov cl, 2
call itoa ; fill in the key cound string
pop si
call count_lines
mov dl, cl
add dl, [size.box_width]
mov dh, [size.box_height]
add dh, ch
mov al, [color.input_box_msg]
mov bx, [color.input_box_frame]
mov di, [str_idx.input]
xchg di, si
call message_box
popa
ret
;=============================================================================
;read_keystroke ---- read a key stroke
;input:
; none (the scroll lock must be turned on before read keystrokes)
;output:
; cf = 0 success, ax = key code
; cf = 1 cancel (scroll lock was turned off)
;=============================================================================
read_keystroke:
.loop_read:
mov ah, 0x01
or ah, [keyboard_type]
call bioskey
jnz .have_key
mov ah, 0x02
or ah, [keyboard_type]
call bioskey
test al, kbScrollMask
jz .cancel
jmp short .loop_read
.have_key:
mov ah, [keyboard_type]
call bioskey
clc
ret
.cancel:
xor ax, ax
stc
ret
;=============================================================================
;show_record_info ---- show the information of the boot record
;=============================================================================
show_record_info:
cmp byte [good_record_number], 0
jmpe .end
call get_record_pointer
lea di, [tmp_buffer]
call get_record_schedule
push dx
push bx
push ax
push dword [si + struc_bootrecord.password]
mov bx, [si + struc_bootrecord.flags]
mov ax, [si + struc_bootrecord.drive_id]
mov dx, si
add si, struc_bootrecord.name
push si ; save record name pointer
push dx ; save record pointer
push ax ; save drive_id and part_id
;write drive id
mov si, [str_idx.drive_id]
call strcpy
test bx, INFOFLAG_ISSPECIAL
jz .drvid_ok
mov al, '-'
stosb
stosb
jmp short .write_partid
.drvid_ok:
mov dl, al
call get_drvid_str
.write_partid:
;write part id
mov si, [str_idx.part_id]
call strcpy
pop ax
test bx, INFOFLAG_ISSPECIAL
jz .partid_ok
mov al, '-'
stosb
jmp short .write_rectype
.partid_ok:
movzx ax, ah
mov cx, 2
call itoa
add di, cx
.write_rectype:
;write record type
mov si, [str_idx.record_type]
call strcpy
mov si, di
call strlen
mov ax, cx
pop si
call get_record_typestr
mov si, di
call strlen
sub cx, ax
add di, cx
;write record name
mov si, [str_idx.record_name]
call strcpy
pop si
call strcpy
;write flags
mov cx, 7
mov dx, bx
xor bx, bx
.loop_copy_flags:
mov si, [str_idx.auto_active + bx]
mov ax, [.flag_val + bx]
call .copy_flag_stat
inc bx
inc bx
loop .loop_copy_flags
;write password flag
mov si, [str_idx.password]
call strcpy
pop ecx
or ecx, ecx
jz .no_pswd
mov si, [str_idx.yes]
jmp short .pswd
.no_pswd:
mov si, [str_idx.no]
.pswd:
call strcpy
;write schedule time
mov si, [str_idx.schedule]
call strcpy
mov cx, dx
pop ax
pop bx
pop dx
test cx, INFOFLAG_SCHEDULED
jz .no_sched
call schedule_to_str
jmp short .show_info
.no_sched:
mov si, [str_idx.no]
call strcpy
.show_info:
lea si, [tmp_buffer]
call info_box
.end:
ret
; si -> flag string
; ax = flag
.copy_flag_stat:
call strcpy
test dx, ax
jz .no_this_flag
mov si, [str_idx.yes]
jmp short .copy_flag
.no_this_flag:
mov si, [str_idx.no]
.copy_flag:
call strcpy
ret
.flag_val dw INFOFLAG_AUTOACTIVE, INFOFLAG_ACTIVE, INFOFLAG_AUTOHIDE, INFOFLAG_HIDDEN, INFOFLAG_SWAPDRVID
dw INFOFLAG_LOGICAL, INFOFLAG_HAVEKEYS
;=============================================================================
;schedule_to_str ---- convert schedule time to string
;input:
; ax = start time
; bx = stop time
; dx = days info
; es:di -> buffer
;output:
; none
;=============================================================================
schedule_to_str:
pusha
cld
call sch_time_to_str
mov si, di
call strlen
add di, cx
mov al, '-'
stosb
mov ax, bx
call sch_time_to_str
mov si, di
call strlen
add di, cx
mov al, ';'
stosb
call sch_days_to_str
popa
ret
;=============================================================================
;sch_days_to_str ---- convert days info string 0123456
;input:
; dx = day bits
; es:di -> buffer
;output:
; none
;=============================================================================
sch_days_to_str:
pusha
mov cx, 7
mov al, '0'
mov bx, 1
.loop_chk:
test dx, bx
jz .nothisday
stosb
.nothisday:
shl bx, 1
inc al
loop .loop_chk
xor al, al
stosb
popa
ret
;=============================================================================
;sch_time_to_str ---- convert time in minute info string hh:mm
;input:
; ax = time
; es:di -> buffer
;output:
; none
;=============================================================================
sch_time_to_str:
pusha
mov dl, 60
div dl
push ax
xor ah, ah
cmp al, 10
jb .hlten
mov cx, 2
jmp short .showh
.hlten:
mov cx,1
.showh:
call itoa
mov al,':'
add di, cx
stosb
pop ax
movzx ax, ah
cmp al, 10
jb .mlten
mov cx, 2
jmp short .showm
.mlten:
mov cx,1
.showm:
call itoa
popa
ret
;=============================================================================
; do_power_off ---- turn of the power
;=============================================================================
do_power_off:
call power_off
ret
;=============================================================================
;change_bootmenu_style ---- change the boot menu's draw style
;=============================================================================
change_bootmenu_style:
mov al, [bootmenu_style]
inc al
cmp al, 4
jb .ok
xor al, al
.ok:
mov [bootmenu_style], al
call init_bootmenu_width
call draw_screen
inc byte [change_occured]
ret
;=============================================================================
;toggle_rem_last ---- toggle the remember last switch.
;=============================================================================
toggle_rem_last:
call confirm_root_passwd
jc .end
xor byte [kernel_flags], KNLFLAG_REMLAST
inc byte [change_occured]
call draw_screen
.end:
ret
;=============================================================================
; show_cmd_menu ---- show a command menu
; input:
; al = cmd menu mask
; ds:si -> menu struct
; output:
; none
;=============================================================================
show_cmd_menu:
pusha
mov bl, [cmd_menu_stat]
push bx
mov [cmd_menu_stat], al
push si
call draw_screen
pop si
xor al, al
call popup_menu
pop bx
mov [cmd_menu_stat], bl
call draw_screen
popa
ret
;=============================================================================
; show_main_menu ---- show the main commands menu
;=============================================================================
show_main_menu:
mov al, MAIN_MENU_ON
lea si, [main_menu]
call show_cmd_menu
ret
;=============================================================================
; show_record_menu ---- show the record commands menu
;=============================================================================
show_record_menu:
mov al, RECORD_MENU_ON
lea si, [record_menu]
call show_cmd_menu
ret
;=============================================================================
; show_sys_menu ---- show the system commands menu
;=============================================================================
show_sys_menu:
mov al, SYS_MENU_ON
lea si, [sys_menu]
call show_cmd_menu
ret
;=============================================================================
;move_menu_left ---- move the menu left
;input:
; ds:si -> point to menu structure
;=============================================================================
move_menu_left:
mov al, [si + struc_menu.win_pos]
or al, al
jz .no_move
dec al
mov [si + struc_menu.win_pos], al
call draw_screen
.no_move:
ret
;=============================================================================
;move_menu_up ---- move the menu up
;input:
; ds:si -> point to menu structure
;=============================================================================
move_menu_up:
mov al, [si + struc_menu.win_pos + 1]
cmp al, [size.copyright]
jbe .no_move
dec al
mov [si + struc_menu.win_pos + 1], al
call draw_screen
.no_move:
ret
;=============================================================================
;move_menu_right ---- move the menu right
;input:
; ds:si -> point to menu structure
;=============================================================================
move_menu_right:
mov al, [si + struc_menu.win_pos]
mov ah, [screen_width]
sub ah, [si + struc_menu.win_size]
sub ah, 2
cmp al, ah
jae .no_move
inc al
mov [si + struc_menu.win_pos], al
call draw_screen
.no_move:
ret
;=============================================================================
;move_menu_down ---- move the menu down
;=============================================================================
move_menu_down:
mov al, [si + struc_menu.win_pos + 1]
mov ah, [screen_height]
sub ah, [si + struc_menu.win_size + 1]
sub ah, [size.hint]
cmp al, ah
jae .no_move
inc al
mov [si + struc_menu.win_pos + 1], al
call draw_screen
.no_move:
ret
;=============================================================================
; boot_prev_in_menu ---- boot previous MBR in command menu
;=============================================================================
boot_prev_in_menu:
call check_prev_mbr
jc .end
call confirm_root_passwd
jc .end
call boot_prev_mbr
.end:
ret
;=============================================================================
; install_sbm
;=============================================================================
install_sbm:
%ifndef EMULATE_PROG
cmp byte [good_record_number], 0
je .end
call get_record_pointer
mov ax, [si + struc_bootrecord.flags]
test ax , INFOFLAG_ISDRIVER
jz .end
test ax, DRVFLAG_ISCDROM
jnz .end
call confirm_root_passwd
jc .end
mov dl, [si + struc_bootrecord.drive_id]
push dx
lea di, [tmp_buffer]
mov si, [str_idx.inst_confirm]
push di
call strcpy
call get_drvid_str
mov al, '?'
stosb
mov al, 0x0d
stosb
mov si, [str_idx.confirm]
call strcpy
pop si
call info_box
pop dx
cmp al, [yes_key_lower]
je .go_inst
cmp al, [yes_key_upper]
je .go_inst
mov si, [str_idx.inst_abort]
call error_box
.end:
ret
.go_inst:
;read mbr into buffer
xor ebx, ebx
mov ax, (INT13H_READ << 8) | 0x01
lea di, [disk_buf]
call disk_access
jmpc .disk_error
;backup old previous mbr
lea si, [previous_mbr]
mov cx, SECTOR_SIZE
call xchg_buffer
;backup sbmk header data
xor si, si
lea di, [disk_buf1]
mov cx, end_of_sbmk_header
rep movsb
;set some variate
xor eax, eax
inc al
mov cl, [kernel_sectors]
mov [kernel_drvid], dl
mov [kernel_sects1], cl
mov [kernel_addr1], eax ; kernel address = 1
mov [kernel_sects2], ah ; only one block of kernel
mov [checksum], ah ; set checksum to zero
mov [sbml_codes + struc_sbml_header.kernel_sects1], cl
mov [sbml_codes + struc_sbml_header.kernel_addr1], eax
mov [sbml_codes + struc_sbml_header.kernel_sects2], ah
;write sbmk to disk
call save_boot_manager
pushf
;restore sbmk header data
xor di, di
lea si, [disk_buf1]
mov cx, end_of_sbmk_header
rep movsb
;restore previous mbr
lea si, [previous_mbr]
lea di, [disk_buf]
push di
mov cx, SECTOR_SIZE
call xchg_buffer
pop di
popf
jc .disk_error
;copy sbml to disk_buf
push di
lea si, [sbml_codes]
mov cx, SIZE_OF_MBR
rep movsb
pop di
mov word [di + BR_FLAG_OFF], BR_GOOD_FLAG
;write loader to disk
mov ax, (INT13H_WRITE << 8) | 0x01
xor ebx,ebx
call disk_access
jc .disk_error
;install ok
mov si, [str_idx.inst_ok]
call info_box
ret
.disk_error:
call show_disk_error
%endif
ret
; cx = count
; si -> source
; di -> dest
xchg_buffer:
pusha
.xchg:
mov al, [si]
xchg al, [di]
mov [si], al
inc si
inc di
loop .xchg
popa
ret
;=============================================================================
; uninstall_sbm
;=============================================================================
uninstall_sbm:
%ifndef EMULATE_PROG
call confirm_root_passwd
jc .end
lea di, [tmp_buffer]
mov si, [str_idx.uninst_confirm]
push di
call strcpy
mov si, [str_idx.confirm]
call strcpy
pop si
call info_box
cmp al, [yes_key_lower]
je .go_uninst
cmp al, [yes_key_upper]
je .go_uninst
mov si, [str_idx.uninst_abort]
call error_box
.end:
ret
.go_uninst:
;read mbr into buffer
mov dl, [kernel_drvid]
xor ebx, ebx
mov ax, (INT13H_READ << 8) | 0x01
lea di, [disk_buf]
call disk_access
jc .disk_error
;check if sbm is present
cmp dword [di + struc_sbml_header.magic], SBML_MAGIC
jne .no_sbml
cmp word [di + struc_sbml_header.version], SBML_VERSION
jne .no_sbml
;restore previous mbr
push di
lea si, [previous_mbr]
mov cx, SIZE_OF_MBR
cld
rep movsb
pop di
mov word [di + BR_FLAG_OFF], BR_GOOD_FLAG
;write mbr back to disk
xor ebx, ebx
mov ax, (INT13H_WRITE << 8) | 0x01
lea di, [disk_buf]
call disk_access
jc .disk_error
mov si, [str_idx.uninst_ok]
call info_box
call reboot
ret
.disk_error:
call show_disk_error
ret
.no_sbml:
mov si, [str_idx.no_sbml]
call error_box
%endif
ret
;=============================================================================
; toggle_int13ext
;=============================================================================
toggle_int13ext:
call confirm_root_passwd
jc .end
mov al, [kernel_flags]
xor al, KNLFLAG_NOINT13EXT
mov [kernel_flags], al
test al, KNLFLAG_NOINT13EXT
jnz .no_int13ext
mov byte [use_int13_ext], 1
jmp short .endok
.no_int13ext:
mov byte [use_int13_ext], 0
.endok:
inc byte [change_occured]
call draw_screen
.end:
ret
;=============================================================================
; set_cdrom_ioports
;=============================================================================
set_cdrom_ioports:
%ifndef DISABLE_CDBOOT
test byte [kernel_flags], KNLFLAG_NOCDROM
jnz .end
call confirm_root_passwd
jc .end
lea di, [tmp_buffer]
push di
mov byte [di], 0
mov ax, [cdrom_ioports]
or ax, ax
jz .no_ports
mov cl, 4
call htoa
add di, 4
mov al, ','
stosb
mov ax, [cdrom_ioports+2]
call htoa
.no_ports:
pop di
movzx ax, [color.input_box_msg]
mov bx, [color.input_box_frame]
mov cl, 9
mov si, [str_idx.io_port]
call input_box
jc .end_clean
mov si, di
call atoh
cmp byte [si], ','
jne .invalid
mov bx, ax
inc si
call atoh
cmp byte [si], 0
jne .invalid
mov cx, ax
mov [cdrom_ioports], bx
mov [cdrom_ioports+2], cx
inc byte [change_occured] ; some changes occured.
call set_io_ports
jmp short .end_clean
.invalid:
mov si, [str_idx.invalid_ioports]
call error_box
jmp .end
.end_clean:
call draw_screen
.end:
%endif
ret
;=============================================================================
; set_y2k_year
;=============================================================================
set_y2k_year:
%ifdef Y2K_BUGFIX
call confirm_root_passwd
jc .end
lea di, [tmp_buffer]
mov byte [di], 0
mov cl,4
mov ax,[y2k_last_year]
or ax,ax
jz .nofix
call bcd_to_str
.nofix:
movzx ax, [color.input_box_msg]
mov bx, [color.input_box_frame]
mov si, [str_idx.year]
call input_box
jc .end_clean
xor bx,bx
or ch,ch
jz .set
mov si,di
.loop:
shl bx,cl
lodsb
sub al,'0'
or bl,al
dec ch
jnz .loop
mov ah,4
int 0x1a
jc .end_clean
mov cx,bx
mov ah,5
int 0x1a
.set:
mov [y2k_last_year],bx
inc byte [change_occured] ; some changes occured.
.end_clean:
call draw_screen
.end
%endif
ret
%endif ; END OF MAIN
|