source: xtideuniversalbios/trunk/Configurator/Src/MenuPage.asm @ 2

Last change on this file since 2 was 2, checked in by aitotat, 14 years ago
File size: 4.6 KB
Line 
1; File name     :   MenuPage.asm
2; Project name  :   XTIDE Univeral BIOS Configurator
3; Created date  :   15.4.2010
4; Last update   :   27.4.2010
5; Author        :   Tomi Tilli
6; Description   :   Functions to access MENUPAGE structs.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Returns number of visible menuitems in MENUPAGE.
13;
14; MenuPage_GetNumberOfVisibleItems
15;   Parameters:
16;       DS:SI:  Ptr to MENUPAGE
17;   Returns:
18;       AX:     Number of visible menuitems
19;   Corrupts registers:
20;       DI
21;--------------------------------------------------------------------
22ALIGN JUMP_ALIGN
23MenuPage_GetNumberOfVisibleItems:
24    xor     ax, ax                  ; Zero visible menuitems
25    mov     di, MenuPage_IterateForNumberOfVisibleItems
26    jmp     SHORT MenuPage_IterateMenuPageItems
27
28;--------------------------------------------------------------------
29; Iteration callback function for MenuPage_GetNumberOfVisibleItems.
30;
31; MenuPage_IterateForNumberOfVisibleItems
32;   Parameters:
33;       AX:     Number of visible menuitems found so far
34;       DS:BX:  Ptr to MENUPAGEITEM to examine
35;   Returns:
36;       AX:     Number of visible menuitems found so far
37;       CF:     Cleared to continue iteration
38;   Corrupts registers:
39;       Nothing
40;--------------------------------------------------------------------
41ALIGN JUMP_ALIGN
42MenuPage_IterateForNumberOfVisibleItems:
43    test    BYTE [bx+MENUPAGEITEM.bFlags], FLG_MENUPAGEITEM_VISIBLE ; Clears CF
44    jz      SHORT .NextItem
45    inc     ax                      ; Increment visible menuitems
46ALIGN JUMP_ALIGN
47.NextItem:
48    ret
49
50
51;--------------------------------------------------------------------
52; Returns pointer to MENUPAGEITEM for visible index (menu library index).
53;
54; MenuPage_GetMenuPageItemForVisibleIndex
55;   Parameters:
56;       CX:     Index of visible menuitem
57;       DS:SI:  Ptr to MENUPAGE
58;   Returns:
59;       DS:DI:  Ptr to MENUPAGEITEM
60;       CF:     Set if MENUPAGEITEM was found
61;   Corrupts registers:
62;       AX
63;--------------------------------------------------------------------
64ALIGN JUMP_ALIGN
65MenuPage_GetMenuPageItemForVisibleIndex:
66    mov     ax, cx                  ; Menuitem index to menuitems to skip
67    mov     di, MenuPage_IterateForVisibleIndex
68    jmp     SHORT MenuPage_IterateMenuPageItems
69
70;--------------------------------------------------------------------
71; Iteration callback function for MenuPage_GetMenuPageItemForVisibleIndex.
72;
73; MenuPage_IterateForVisibleIndex
74;   Parameters:
75;       AX:     Number of visible menuitems left to skip
76;       DS:BX:  Ptr to MENUPAGEITEM to examine
77;   Returns:
78;       AX:     Number of visible menuitems left to skip
79;       CF:     Cleared to continue iteration
80;               Set if correct MENUPAGEITEM was found
81;   Corrupts registers:
82;       Nothing
83;--------------------------------------------------------------------
84ALIGN JUMP_ALIGN
85MenuPage_IterateForVisibleIndex:
86    test    BYTE [bx+MENUPAGEITEM.bFlags], FLG_MENUPAGEITEM_VISIBLE ; Clears CF
87    jz      SHORT .NextItem
88    sub     ax, BYTE 1              ; Set CF if correct MENUITEM found
89ALIGN JUMP_ALIGN
90.NextItem:
91    ret
92
93
94;--------------------------------------------------------------------
95; Iterates MENUPAGEITEMs until terminated by callback function or
96; all MENUPAGEITEMs have been iterated.
97;
98; MenuPage_IterateMenuPageItems
99;   Parameters:
100;       AX,DX:  Parameters to callback function
101;       DI:     Offset to iteration callback function
102;       DS:SI:  Ptr to MENUPAGE
103;   Returns:
104;       AX,DX:  Return values from callback function
105;       DS:DI:  Ptr to MENUPAGEITEM (only if CF set)
106;       CF:     Cleared if terminated by end of menuitems
107;               Set if terminated by callback function
108;   Corrupts registers:
109;       Nothing, unless corrupted by callback function
110;--------------------------------------------------------------------
111ALIGN JUMP_ALIGN
112MenuPage_IterateMenuPageItems:
113    push    cx
114    push    bx
115    eMOVZX  cx, BYTE [si+MENUPAGE.bItemCnt]
116    lea     bx, [si+MENUPAGE.rgMenuPageItem]
117ALIGN JUMP_ALIGN
118.IterationLoop:
119    call    di                          ; Callback function
120    jc      SHORT .IterationComplete    ; CF set, end iteration
121    add     bx, BYTE MENUPAGEITEM_size
122    loop    .IterationLoop
123    clc                                 ; Clear CF since end of MENUITEMs
124ALIGN JUMP_ALIGN
125.IterationComplete:
126    mov     di, bx                      ; DS:DI points to MENUPAGEITEM
127    pop     bx
128    pop     cx
129    ret
130
131
132;--------------------------------------------------------------------
133; Updates number of menuitems and redraws them.
134;
135; MenuPage_InvalidateItemCount
136;   Parameters:
137;       DS:SI:  Ptr to MENUPAGE
138;   Returns:
139;       Nothing
140;   Corrupts registers:
141;       AX, BX, CX, DX
142;--------------------------------------------------------------------
143ALIGN JUMP_ALIGN
144MenuPage_InvalidateItemCount:
145    push    di
146    call    MenuPage_GetNumberOfVisibleItems
147    mov     cx, ax
148    mov     dl, MFL_UPD_ITEM | MFL_UPD_NFO
149    call    Menu_InvItemCnt
150    pop     di
151    ret
Note: See TracBrowser for help on using the repository browser.