1 | ; File name : DialogDrive.asm |
---|
2 | ; Project name : Assembly Library |
---|
3 | ; Created date : 22.10.2010 |
---|
4 | ; Last update : 18.11.2010 |
---|
5 | ; Author : Tomi Tilli |
---|
6 | ; Description : Displays drive dialog. |
---|
7 | |
---|
8 | ; |
---|
9 | ; XTIDE Universal BIOS and Associated Tools |
---|
10 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
11 | ; |
---|
12 | ; This program is free software; you can redistribute it and/or modify |
---|
13 | ; it under the terms of the GNU General Public License as published by |
---|
14 | ; the Free Software Foundation; either version 2 of the License, or |
---|
15 | ; (at your option) any later version. |
---|
16 | ; |
---|
17 | ; This program is distributed in the hope that it will be useful, |
---|
18 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | ; GNU General Public License for more details. |
---|
21 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
22 | ; |
---|
23 | |
---|
24 | ; Section containing code |
---|
25 | SECTION .text |
---|
26 | |
---|
27 | ;-------------------------------------------------------------------- |
---|
28 | ; DialogDrive_GetDriveWithIoInDSSI |
---|
29 | ; Parameters: |
---|
30 | ; DS:SI: Ptr to DRIVE_DIALOG_IO |
---|
31 | ; SS:BP: Ptr to parent MENU |
---|
32 | ; Returns: |
---|
33 | ; Nothing |
---|
34 | ; Corrupts registers: |
---|
35 | ; AX, BX, CX, DX, SI, DI |
---|
36 | ;-------------------------------------------------------------------- |
---|
37 | ALIGN JUMP_ALIGN |
---|
38 | DialogDrive_GetDriveWithIoInDSSI: |
---|
39 | mov bx, DriveEventHandler |
---|
40 | mov BYTE [si+DRIVE_DIALOG_IO.bUserCancellation], TRUE |
---|
41 | jmp Dialog_DisplayWithDialogInputInDSSIandHandlerInBX |
---|
42 | |
---|
43 | |
---|
44 | ;-------------------------------------------------------------------- |
---|
45 | ; DriveEventHandler |
---|
46 | ; Common parameters for all events: |
---|
47 | ; BX: Menu event (anything from MENUEVENT struct) |
---|
48 | ; SS:BP: Ptr to DIALOG |
---|
49 | ; Common return values for all events: |
---|
50 | ; CF: Set if event processed |
---|
51 | ; Cleared if event not processed |
---|
52 | ; Corrupts registers: |
---|
53 | ; All |
---|
54 | ;-------------------------------------------------------------------- |
---|
55 | ALIGN JUMP_ALIGN |
---|
56 | DriveEventHandler: |
---|
57 | jmp [cs:bx+.rgfnEventHandlers] |
---|
58 | |
---|
59 | |
---|
60 | ALIGN JUMP_ALIGN |
---|
61 | .InitializeMenuinitFromDSSI: |
---|
62 | xor ax, ax |
---|
63 | call Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX |
---|
64 | call Drive_GetFlagsForAvailableDrivesToDXAX |
---|
65 | mov [bp+MENU.dwUserData], ax |
---|
66 | mov [bp+MENU.dwUserData+2], dx |
---|
67 | |
---|
68 | call Bit_GetSetCountToCXfromDXAX |
---|
69 | mov [bp+MENUINIT.wItems], cx |
---|
70 | |
---|
71 | dec cx ; Items initialized to one. Ignore it. |
---|
72 | add cl, [bp+MENUINIT.bHeight] |
---|
73 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
74 | MIN_U cl, ah |
---|
75 | mov [bp+MENUINIT.bHeight], cl |
---|
76 | ret |
---|
77 | |
---|
78 | |
---|
79 | ALIGN JUMP_ALIGN |
---|
80 | .ItemSelectedFromCX: |
---|
81 | call ConvertDriveLetterToBLfromItemIndexInCX |
---|
82 | lds si, [bp+DIALOG.fpDialogIO] |
---|
83 | mov BYTE [si+DRIVE_DIALOG_IO.bUserCancellation], FALSE |
---|
84 | mov [si+DRIVE_DIALOG_IO.cReturnDriveLetter], bl |
---|
85 | sub bl, 'A' |
---|
86 | mov [si+DRIVE_DIALOG_IO.bReturnDriveNumber], bl |
---|
87 | jmp MenuInit_CloseMenuWindow |
---|
88 | |
---|
89 | |
---|
90 | ALIGN JUMP_ALIGN |
---|
91 | .RefreshItemFromCX: |
---|
92 | push bp |
---|
93 | |
---|
94 | call ConvertDriveLetterToBLfromItemIndexInCX |
---|
95 | mov bp, sp |
---|
96 | push bx |
---|
97 | mov si, g_szDriveFormat |
---|
98 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI |
---|
99 | |
---|
100 | pop bp |
---|
101 | stc |
---|
102 | ret |
---|
103 | |
---|
104 | |
---|
105 | .rgfnEventHandlers: |
---|
106 | istruc MENUEVENT |
---|
107 | at MENUEVENT.InitializeMenuinitFromDSSI, dw .InitializeMenuinitFromDSSI |
---|
108 | at MENUEVENT.ExitMenu, dw Dialog_EventExitMenu |
---|
109 | at MENUEVENT.IdleProcessing, dw Dialog_EventNotHandled |
---|
110 | at MENUEVENT.ItemHighlightedFromCX, dw Dialog_EventNotHandled |
---|
111 | at MENUEVENT.ItemSelectedFromCX, dw .ItemSelectedFromCX |
---|
112 | at MENUEVENT.KeyStrokeInAX, dw Dialog_EventNotHandled |
---|
113 | at MENUEVENT.RefreshTitle, dw Dialog_EventRefreshTitle |
---|
114 | at MENUEVENT.RefreshInformation, dw Dialog_EventRefreshInformation |
---|
115 | at MENUEVENT.RefreshItemFromCX, dw .RefreshItemFromCX |
---|
116 | iend |
---|
117 | |
---|
118 | |
---|
119 | ;-------------------------------------------------------------------- |
---|
120 | ; ConvertDriveLetterToBLfromItemIndexInCX |
---|
121 | ; Parameters: |
---|
122 | ; CX: Item index |
---|
123 | ; SS:BP: Ptr to DIALOG |
---|
124 | ; Returns: |
---|
125 | ; BL: Drive letter |
---|
126 | ; Corrupts registers: |
---|
127 | ; AX, CX, DX |
---|
128 | ;-------------------------------------------------------------------- |
---|
129 | ALIGN JUMP_ALIGN |
---|
130 | ConvertDriveLetterToBLfromItemIndexInCX: |
---|
131 | inc cx ; Index to count |
---|
132 | mov bl, 'A'-1 |
---|
133 | mov ax, [bp+MENU.dwUserData] |
---|
134 | mov dx, [bp+MENU.dwUserData+2] |
---|
135 | ALIGN JUMP_ALIGN |
---|
136 | .CheckNextBit: |
---|
137 | inc bx ; Increment drive letter |
---|
138 | shr dx, 1 |
---|
139 | rcr ax, 1 |
---|
140 | jnc SHORT .CheckNextBit |
---|
141 | loop .CheckNextBit |
---|
142 | ret |
---|