[41] | 1 | ; File name : MenuInit.asm
|
---|
| 2 | ; Project name : Assembly Library
|
---|
| 3 | ; Created date : 13.7.2010
|
---|
[60] | 4 | ; Last update : 22.11.2010
|
---|
[41] | 5 | ; Author : Tomi Tilli
|
---|
| 6 | ; Description : Functions for initializing menu system.
|
---|
| 7 |
|
---|
| 8 | ; Section containing code
|
---|
| 9 | SECTION .text
|
---|
| 10 |
|
---|
| 11 | ;--------------------------------------------------------------------
|
---|
| 12 | ; MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX
|
---|
| 13 | ; Parameters
|
---|
| 14 | ; DX:AX: User specified data
|
---|
| 15 | ; BX: Menu event handler
|
---|
| 16 | ; Returns:
|
---|
| 17 | ; AX: Index of selected item or NO_ITEM_SELECTED
|
---|
| 18 | ; Corrupts registers:
|
---|
| 19 | ; All except segments
|
---|
| 20 | ;--------------------------------------------------------------------
|
---|
| 21 | ALIGN JUMP_ALIGN
|
---|
| 22 | MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX:
|
---|
| 23 | push es
|
---|
| 24 | push ds
|
---|
| 25 | LOAD_BDA_SEGMENT_TO ds, cx
|
---|
| 26 | push WORD [BDA.wVidCurShape]
|
---|
| 27 | eENTER_STRUCT MENU_size
|
---|
| 28 |
|
---|
[46] | 29 | mov cx, MENU_size
|
---|
| 30 | call Memory_ZeroSSBPwithSizeInCX
|
---|
[41] | 31 | call MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX
|
---|
[52] | 32 | mov ax, [bp+MENUINIT.wHighlightedItem]
|
---|
[41] | 33 |
|
---|
| 34 | eLEAVE_STRUCT MENU_size
|
---|
| 35 | pop ax
|
---|
| 36 | CALL_DISPLAY_LIBRARY SetCursorShapeFromAX
|
---|
| 37 | pop ds
|
---|
| 38 | pop es
|
---|
| 39 | ret
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | ;--------------------------------------------------------------------
|
---|
| 43 | ; MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX
|
---|
| 44 | ; Parameters
|
---|
| 45 | ; DX:AX: User specified data
|
---|
| 46 | ; BX: Menu event handler
|
---|
| 47 | ; SS:BP: Ptr to MENU
|
---|
| 48 | ; Returns:
|
---|
| 49 | ; Nothing
|
---|
| 50 | ; Corrupts registers:
|
---|
| 51 | ; All, except SS:BP
|
---|
| 52 | ;--------------------------------------------------------------------
|
---|
| 53 | ALIGN JUMP_ALIGN
|
---|
| 54 | MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX:
|
---|
| 55 | mov [bp+MENU.fnEventHandler], bx
|
---|
| 56 | mov [bp+MENU.dwUserData], ax
|
---|
| 57 | mov [bp+MENU.dwUserData+2], dx
|
---|
| 58 |
|
---|
| 59 | mov ax, CURSOR_HIDDEN
|
---|
| 60 | CALL_DISPLAY_LIBRARY SetCursorShapeFromAX
|
---|
| 61 | call MenuEvent_InitializeMenuinit ; User initialization
|
---|
| 62 | call MenuInit_RefreshMenuWindow
|
---|
| 63 | jmp MenuLoop_Enter
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | ;--------------------------------------------------------------------
|
---|
| 67 | ; MenuInit_RefreshMenuWindow
|
---|
| 68 | ; Parameters
|
---|
| 69 | ; SS:BP: Ptr to MENU
|
---|
| 70 | ; Returns:
|
---|
| 71 | ; Nothing
|
---|
| 72 | ; Corrupts registers:
|
---|
| 73 | ; AX, BX, CX, DX, SI, DI
|
---|
| 74 | ;--------------------------------------------------------------------
|
---|
| 75 | ALIGN JUMP_ALIGN
|
---|
| 76 | MenuInit_RefreshMenuWindow:
|
---|
| 77 | call MenuBorders_RefreshAll ; Draw borders
|
---|
| 78 | call MenuText_RefreshTitle ; Draw title strings
|
---|
| 79 | call MenuText_RefreshAllItems ; Draw item strings
|
---|
| 80 | jmp MenuText_RefreshInformation ; Draw information strings
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | ;--------------------------------------------------------------------
|
---|
| 84 | ; MenuInit_CloseMenuWindow
|
---|
| 85 | ; Parameters
|
---|
| 86 | ; SS:BP: Ptr to MENU
|
---|
| 87 | ; Returns:
|
---|
| 88 | ; Nothing
|
---|
| 89 | ; Corrupts registers:
|
---|
| 90 | ; Nothing
|
---|
| 91 | ;--------------------------------------------------------------------
|
---|
| 92 | ALIGN JUMP_ALIGN
|
---|
| 93 | MenuInit_CloseMenuWindow:
|
---|
| 94 | or BYTE [bp+MENU.bFlags], FLG_MENU_EXIT
|
---|
| 95 | ret
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | ;--------------------------------------------------------------------
|
---|
| 99 | ; MenuInit_HighlightItemFromAX
|
---|
| 100 | ; Parameters
|
---|
| 101 | ; AX: Item to highlight
|
---|
| 102 | ; SS:BP: Ptr to MENU
|
---|
| 103 | ; Returns:
|
---|
| 104 | ; Nothing
|
---|
| 105 | ; Corrupts registers:
|
---|
| 106 | ; AX, BX, CX, DX, SI, DI
|
---|
| 107 | ;--------------------------------------------------------------------
|
---|
| 108 | ALIGN JUMP_ALIGN
|
---|
| 109 | MenuInit_HighlightItemFromAX:
|
---|
[52] | 110 | sub ax, [bp+MENUINIT.wHighlightedItem]
|
---|
[41] | 111 | jmp MenuScrollbars_MoveHighlightedItemByAX
|
---|
| 112 |
|
---|
[48] | 113 | ;--------------------------------------------------------------------
|
---|
| 114 | ; MenuInit_GetHighlightedItemToAX
|
---|
| 115 | ; Parameters
|
---|
| 116 | ; SS:BP: Ptr to MENU
|
---|
| 117 | ; Returns:
|
---|
| 118 | ; AX: Index of highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
| 119 | ; Corrupts registers:
|
---|
| 120 | ; Nothing
|
---|
| 121 | ;--------------------------------------------------------------------
|
---|
| 122 | ALIGN JUMP_ALIGN
|
---|
| 123 | MenuInit_GetHighlightedItemToAX:
|
---|
[52] | 124 | mov ax, [bp+MENUINIT.wHighlightedItem]
|
---|
[48] | 125 | ret
|
---|
[41] | 126 |
|
---|
[48] | 127 |
|
---|
[41] | 128 | ;--------------------------------------------------------------------
|
---|
| 129 | ; MenuInit_SetTitleHeightFromAL
|
---|
| 130 | ; MenuInit_SetInformationHeightFromAL
|
---|
| 131 | ; MenuInit_SetTotalItemsFromAX
|
---|
| 132 | ; Parameters
|
---|
| 133 | ; AX/AL: Parameter
|
---|
| 134 | ; SS:BP: Ptr to MENU
|
---|
| 135 | ; Returns:
|
---|
| 136 | ; Nothing
|
---|
| 137 | ; Corrupts registers:
|
---|
| 138 | ; Nothing
|
---|
| 139 | ;--------------------------------------------------------------------
|
---|
| 140 | ALIGN JUMP_ALIGN
|
---|
| 141 | MenuInit_SetTitleHeightFromAL:
|
---|
| 142 | mov [bp+MENUINIT.bTitleLines], al
|
---|
| 143 | ret
|
---|
| 144 |
|
---|
| 145 | ALIGN JUMP_ALIGN
|
---|
| 146 | MenuInit_SetInformationHeightFromAL:
|
---|
| 147 | mov [bp+MENUINIT.bInfoLines], al
|
---|
| 148 | ret
|
---|
| 149 |
|
---|
| 150 | ALIGN JUMP_ALIGN
|
---|
| 151 | MenuInit_SetTotalItemsFromAX:
|
---|
| 152 | mov [bp+MENUINIT.wItems], ax
|
---|
| 153 | ret
|
---|
| 154 |
|
---|
| 155 |
|
---|
| 156 | ;--------------------------------------------------------------------
|
---|
| 157 | ; MenuInit_SetUserDataFromDSSI
|
---|
| 158 | ; MenuInit_GetUserDataToDSSI
|
---|
| 159 | ; Parameters
|
---|
| 160 | ; DS:SI: User data (MenuInit_SetUserDataFromDSSI)
|
---|
| 161 | ; SS:BP: Ptr to MENU
|
---|
| 162 | ; Returns:
|
---|
| 163 | ; DS:SI: User data (MenuInit_GetUserDataToDSSI)
|
---|
| 164 | ; Corrupts registers:
|
---|
| 165 | ; Nothing
|
---|
| 166 | ;--------------------------------------------------------------------
|
---|
| 167 | ALIGN JUMP_ALIGN
|
---|
| 168 | MenuInit_SetUserDataFromDSSI:
|
---|
| 169 | mov [bp+MENU.dwUserData], si
|
---|
| 170 | mov [bp+MENU.dwUserData+2], ds
|
---|
| 171 | ret
|
---|
| 172 |
|
---|
| 173 | ALIGN JUMP_ALIGN
|
---|
| 174 | MenuInit_GetUserDataToDSSI:
|
---|
| 175 | lds si, [bp+MENU.dwUserData]
|
---|
| 176 | ret
|
---|