source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/Dialog/DialogDrive.asm @ 58

Last change on this file since 58 was 58, checked in by aitotat, 13 years ago

Changes to Assembly Library:

  • Exiting menu with ESC can now be canceled.
File size: 3.5 KB
Line 
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; Section containing code
10SECTION .text
11
12;--------------------------------------------------------------------
13; DialogDrive_GetDriveWithIoInDSSI
14;   Parameters:
15;       DS:SI:  Ptr to DRIVE_DIALOG_IO
16;       SS:BP:  Ptr to parent MENU
17;   Returns:
18;       Nothing
19;   Corrupts registers:
20;       AX, BX, CX, DX, SI, DI
21;--------------------------------------------------------------------
22ALIGN JUMP_ALIGN
23DialogDrive_GetDriveWithIoInDSSI:
24    mov     bx, DriveEventHandler
25    mov     BYTE [si+DRIVE_DIALOG_IO.bUserCancellation], TRUE
26    jmp     Dialog_DisplayWithDialogInputInDSSIandHandlerInBX
27
28
29;--------------------------------------------------------------------
30; DriveEventHandler
31;   Common parameters for all events:
32;       BX:         Menu event (anything from MENUEVENT struct)
33;       SS:BP:      Ptr to DIALOG
34;   Common return values for all events:
35;       CF:         Set if event processed
36;                   Cleared if event not processed
37;   Corrupts registers:
38;       All
39;--------------------------------------------------------------------
40ALIGN JUMP_ALIGN
41DriveEventHandler:
42    jmp     [cs:bx+.rgfnEventHandlers]
43
44
45ALIGN JUMP_ALIGN
46.InitializeMenuinitFromDSSI:
47    xor     ax, ax
48    call    Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX
49    call    Drive_GetFlagsForAvailableDrivesToDXAX
50    mov     [bp+MENU.dwUserData], ax
51    mov     [bp+MENU.dwUserData+2], dx
52
53    call    Bit_GetSetCountToCXfromDXAX
54    mov     [bp+MENUINIT.wItems], cx
55
56    dec     cx          ; Items initialized to one. Ignore it.
57    add     cl, [bp+MENUINIT.bHeight]
58    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
59    MIN_U   cl, ah
60    mov     [bp+MENUINIT.bHeight], cl
61    ret
62
63
64ALIGN JUMP_ALIGN
65.ItemSelectedFromCX:
66    call    ConvertDriveLetterToBLfromItemIndexInCX
67    lds     si, [bp+DIALOG.fpDialogIO]
68    mov     BYTE [si+DRIVE_DIALOG_IO.bUserCancellation], FALSE
69    mov     [si+DRIVE_DIALOG_IO.cReturnDriveLetter], bl
70    sub     bl, 'A'
71    mov     [si+DRIVE_DIALOG_IO.bReturnDriveNumber], bl
72    jmp     MenuInit_CloseMenuWindow
73
74
75ALIGN JUMP_ALIGN
76.RefreshItemFromCX:
77    push    bp
78
79    call    ConvertDriveLetterToBLfromItemIndexInCX
80    mov     bp, sp
81    push    bx
82    mov     si, g_szDriveFormat
83    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
84
85    pop     bp
86    stc
87    ret
88
89
90.rgfnEventHandlers:
91istruc MENUEVENT
92    at  MENUEVENT.InitializeMenuinitFromDSSI,   dw  .InitializeMenuinitFromDSSI
93    at  MENUEVENT.ExitMenu,                     dw  Dialog_EventExitMenu
94    at  MENUEVENT.IdleProcessing,               dw  Dialog_EventNotHandled
95    at  MENUEVENT.ItemHighlightedFromCX,        dw  Dialog_EventNotHandled
96    at  MENUEVENT.ItemSelectedFromCX,           dw  .ItemSelectedFromCX
97    at  MENUEVENT.KeyStrokeInAX,                dw  Dialog_EventNotHandled
98    at  MENUEVENT.RefreshTitle,                 dw  Dialog_EventRefreshTitle
99    at  MENUEVENT.RefreshInformation,           dw  Dialog_EventRefreshInformation
100    at  MENUEVENT.RefreshItemFromCX,            dw  .RefreshItemFromCX
101iend
102
103
104;--------------------------------------------------------------------
105; ConvertDriveLetterToBLfromItemIndexInCX
106;   Parameters:
107;       CX:     Item index
108;       SS:BP:  Ptr to DIALOG
109;   Returns:
110;       BL:     Drive letter
111;   Corrupts registers:
112;       AX, CX, DX
113;--------------------------------------------------------------------
114ALIGN JUMP_ALIGN
115ConvertDriveLetterToBLfromItemIndexInCX:
116    inc     cx          ; Index to count
117    mov     bl, 'A'-1
118    mov     ax, [bp+MENU.dwUserData]
119    mov     dx, [bp+MENU.dwUserData+2]
120ALIGN JUMP_ALIGN
121.CheckNextBit:
122    inc     bx          ; Increment drive letter
123    shr     dx, 1
124    rcr     ax, 1
125    jnc     SHORT .CheckNextBit
126    loop    .CheckNextBit
127    ret
Note: See TracBrowser for help on using the repository browser.