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