source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm @ 183

Last change on this file since 183 was 183, checked in by gregli@…, 12 years ago

Space optimization, added option to inline offsets for MENUEVENT structure, for situations (such as the XTIDE bios) where only one menu is needed. Ifdef'd change (set in main.asm) so either method can be used.

File size: 6.4 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Boot Menu event handler for menu library callbacks.
3
4; Section containing code
5SECTION .text
6
7struc ITEM_TYPE_REFRESH
8    .HardDisk           resb    2
9    .FloppyDrive        resb    2
10endstruc
11
12
13;--------------------------------------------------------------------
14; BootMenuEvent_Handler
15;   Common parameters for all events:
16;       BX:         Menu event (anything from MENUEVENT struct)
17;       SS:BP:      Menu library handle
18;   Common return values for all events:
19;       CF:         Set if event processed
20;                   Cleared if event not processed
21;   Corrupts registers:
22;       All
23;--------------------------------------------------------------------
24ALIGN JUMP_ALIGN
25BootMenuEvent_Handler:
26       
27%ifdef MENUEVENT_INLINE_OFFSETS
28       
29    add     bx, BootMenuEvent_Handler
30    jmp     bx
31       
32%else
33       
34    cmp     bx, BYTE MENUEVENT.RefreshItemFromCX    ; Above last supported item?
35    ja      SHORT .EventNotHandled
36    jmp     [cs:bx+.rgfnEventSpecificHandlers]
37       
38%endif
39       
40.EventNotHandled:
41    clc
42    ret
43
44%ifdef MENUEVENT_INLINE_OFFSETS
45       
46MENUEVENT_InitializeMenuinitFromDSSI equ  (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler)
47MENUEVENT_ExitMenu equ  (BootMenuEvent_Handler.EventCompleted - BootMenuEvent_Handler)
48MENUEVENT_IdleProcessing equ (BootMenuEvent_Handler.EventNotHandled - BootMenuEvent_Handler)
49MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler)
50MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler)
51MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler)
52MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler)
53MENUEVENT_RefreshInformation equ (BootMenuEvent_Handler.RefreshInformation - BootMenuEvent_Handler)
54MENUEVENT_RefreshItemFromCX equ (BootMenuEvent_Handler.RefreshItemFromCX - BootMenuEvent_Handler)
55
56%else
57       
58ALIGN WORD_ALIGN
59.rgfnEventSpecificHandlers:
60    dw      .InitializeMenuinitFromDSSI ; MENUEVENT.InitializeMenuinitFromDSSI
61    dw      .EventCompleted             ; MENUEVENT.ExitMenu
62    dw      .EventNotHandled            ; MENUEVENT.IdleProcessing
63    dw      .ItemHighlightedFromCX      ; MENUEVENT.ItemHighlightedFromCX
64    dw      .ItemSelectedFromCX         ; MENUEVENT.ItemSelectedFromCX
65    dw      .KeyStrokeInAX              ; MENUEVENT.KeyStrokeInAX
66    dw      BootMenuPrint_TitleStrings  ; MENUEVENT.RefreshTitle
67    dw      .RefreshInformation         ; MENUEVENT.RefreshInformation
68    dw      .RefreshItemFromCX          ; MENUEVENT.RefreshItemFromCX
69       
70%endif
71
72
73; Parameters:
74;   DS:SI:      Ptr to MENUINIT struct to initialize
75; Returns:
76;   DS:SI:      Ptr to initialized MENUINIT struct
77ALIGN JUMP_ALIGN
78.InitializeMenuinitFromDSSI:
79    push    ds
80    call    RamVars_GetSegmentToDS
81    call    .GetDefaultMenuitemToDX
82    call    BootMenu_GetMenuitemCountToAX
83    pop     ds
84    mov     [si+MENUINIT.wItems], ax
85    mov     [si+MENUINIT.wHighlightedItem], dx
86    mov     WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
87    mov     BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH
88    call    BootMenu_GetHeightToAHwithItemCountInAL
89    mov     [si+MENUINIT.bHeight], ah
90    mov     ax, [cs:ROMVARS.wBootTimeout]
91    CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
92    stc
93    ret
94
95ALIGN JUMP_ALIGN
96.GetDefaultMenuitemToDX:
97    mov     dl, [cs:ROMVARS.bBootDrv]   ; Default boot drive
98    call    BootMenu_IsDriveInSystem
99    jnc     SHORT .DoNotSetDefaultMenuitem
100    call    DriveXlate_SetDriveToSwap
101    jmp     BootMenu_GetMenuitemToDXforDriveInDL
102ALIGN JUMP_ALIGN
103.DoNotSetDefaultMenuitem:
104    xor     dx, dx                      ; Whatever appears first on boot menu
105    ret
106
107
108; Parameters:
109;   CX:         Index of new highlighted item
110;   DX:         Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
111ALIGN JUMP_ALIGN
112.ItemHighlightedFromCX:
113    push    cx
114    call    RamVars_GetSegmentToDS
115    call    DriveXlate_Reset
116    call    BootMenu_GetDriveToDXforMenuitemInCX
117    call    DriveXlate_SetDriveToSwap
118
119    xor     ax, ax  ; Update first floppy drive (for translated drive number)
120    CALL_MENU_LIBRARY RefreshItemFromAX
121    mov     dl, 80h
122    call    BootMenu_GetMenuitemToDXforDriveInDL
123    xchg    ax, dx  ; Update first hard disk (for translated drive number)
124    CALL_MENU_LIBRARY RefreshItemFromAX
125    pop     ax      ; Update new item (for translated drive number)
126    CALL_MENU_LIBRARY RefreshItemFromAX
127    CALL_MENU_LIBRARY RefreshInformation
128    stc
129    ret
130
131
132; Parameters:
133;   AL:         ASCII character for the key
134;   AH:         Keyboard library scan code for the key
135ALIGN JUMP_ALIGN
136.KeyStrokeInAX:
137    cmp     ah, ROM_BOOT_HOTKEY_SCANCODE
138    jne     SHORT .CheckDriveHotkeys
139    jmp     Int19hMenu_RomBoot
140ALIGN JUMP_ALIGN
141.CheckDriveHotkeys:
142    call    BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
143    cmp     ax, [bp+MENUINIT.wItems]
144    jae     SHORT .EventCompleted   ; Invalid key
145    CALL_MENU_LIBRARY HighlightItemFromAX
146    ; Fall to .ItemSelectedFromCX
147
148
149; Parameters:
150;   CX:         Index of selected item
151ALIGN JUMP_ALIGN
152.ItemSelectedFromCX:
153    CALL_MENU_LIBRARY Close
154.EventCompleted:
155    stc
156    ret
157
158
159; Parameters:
160;   CX:         Index of item to refresh
161;   Cursor has been positioned to the beginning of item line
162ALIGN JUMP_ALIGN
163.RefreshItemFromCX:
164    mov     bx, .rgwItemTypeRefresh
165    jmp     SHORT .RefreshItemOrInformationWithJumpTableInCSBX
166
167
168; Parameters:
169;   CX:         Index of highlighted item
170;   Cursor has been positioned to the beginning of first line
171ALIGN JUMP_ALIGN
172.RefreshInformation:
173    mov     bx, .rgwInformationItemTypeRefresh
174    ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
175
176;--------------------------------------------------------------------
177; RefreshItemOrInformationWithJumpTableInCSBX
178;   Parameters:
179;       CX:     Index of selected menuitem
180;       CS:BX:  Ptr to ITEM_TYPE_REFRESH jump table
181;   Returns:
182;       CF:     set since event processed
183;--------------------------------------------------------------------
184.RefreshItemOrInformationWithJumpTableInCSBX:
185    cmp     cl, NO_ITEM_HIGHLIGHTED
186    je      SHORT .EventCompleted
187
188    call    RamVars_GetSegmentToDS
189    call    BootMenu_GetDriveToDXforMenuitemInCX
190    test    dl, dl                  ; Floppy drive?
191    jns     SHORT .DrawFloppyDrive
192    jmp     [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
193ALIGN JUMP_ALIGN
194.DrawFloppyDrive:
195    jmp     [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
196
197; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX
198ALIGN WORD_ALIGN
199.rgwItemTypeRefresh:
200istruc ITEM_TYPE_REFRESH
201    at  ITEM_TYPE_REFRESH.HardDisk,         dw  BootMenuPrint_HardDiskMenuitem
202    at  ITEM_TYPE_REFRESH.FloppyDrive,      dw  BootMenuPrint_FloppyMenuitem
203iend
204.rgwInformationItemTypeRefresh:
205istruc ITEM_TYPE_REFRESH
206    at  ITEM_TYPE_REFRESH.HardDisk,         dw  BootMenuPrint_HardDiskMenuitemInformation
207    at  ITEM_TYPE_REFRESH.FloppyDrive,      dw  BootMenuPrint_FloppyMenuitemInformation
208iend
Note: See TracBrowser for help on using the repository browser.