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
RevLine 
[88]1; Project name  :   XTIDE Universal BIOS
[3]2; Description   :   Boot Menu event handler for menu library callbacks.
3
4; Section containing code
5SECTION .text
6
[88]7struc ITEM_TYPE_REFRESH
8    .HardDisk           resb    2
9    .FloppyDrive        resb    2
10endstruc
11
12
[3]13;--------------------------------------------------------------------
14; BootMenuEvent_Handler
[88]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
[3]21;   Corrupts registers:
[88]22;       All
[3]23;--------------------------------------------------------------------
24ALIGN JUMP_ALIGN
25BootMenuEvent_Handler:
[183]26       
27%ifdef MENUEVENT_INLINE_OFFSETS
28       
29    add     bx, BootMenuEvent_Handler
30    jmp     bx
31       
32%else
33       
[127]34    cmp     bx, BYTE MENUEVENT.RefreshItemFromCX    ; Above last supported item?
[88]35    ja      SHORT .EventNotHandled
[127]36    jmp     [cs:bx+.rgfnEventSpecificHandlers]
[183]37       
38%endif
39       
[88]40.EventNotHandled:
41    clc
42    ret
[3]43
[183]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       
[3]58ALIGN WORD_ALIGN
[88]59.rgfnEventSpecificHandlers:
[124]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
[183]69       
70%endif
[3]71
72
[88]73; Parameters:
74;   DS:SI:      Ptr to MENUINIT struct to initialize
75; Returns:
76;   DS:SI:      Ptr to initialized MENUINIT struct
[3]77ALIGN JUMP_ALIGN
[88]78.InitializeMenuinitFromDSSI:
79    push    ds
80    call    RamVars_GetSegmentToDS
81    call    .GetDefaultMenuitemToDX
[124]82    call    BootMenu_GetMenuitemCountToAX
[88]83    pop     ds
[124]84    mov     [si+MENUINIT.wItems], ax
[88]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
[124]88    call    BootMenu_GetHeightToAHwithItemCountInAL
[88]89    mov     [si+MENUINIT.bHeight], ah
[137]90    mov     ax, [cs:ROMVARS.wBootTimeout]
[135]91    CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
[88]92    stc
[3]93    ret
94
[88]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
[124]101    jmp     BootMenu_GetMenuitemToDXforDriveInDL
[88]102ALIGN JUMP_ALIGN
103.DoNotSetDefaultMenuitem:
104    xor     dx, dx                      ; Whatever appears first on boot menu
105    ret
[3]106
[88]107
108; Parameters:
109;   CX:         Index of new highlighted item
110;   DX:         Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
[3]111ALIGN JUMP_ALIGN
[88]112.ItemHighlightedFromCX:
113    push    cx
[3]114    call    RamVars_GetSegmentToDS
115    call    DriveXlate_Reset
[130]116    call    BootMenu_GetDriveToDXforMenuitemInCX
[3]117    call    DriveXlate_SetDriveToSwap
[140]118
119    xor     ax, ax  ; Update first floppy drive (for translated drive number)
[88]120    CALL_MENU_LIBRARY RefreshItemFromAX
[140]121    mov     dl, 80h
122    call    BootMenu_GetMenuitemToDXforDriveInDL
123    xchg    ax, dx  ; Update first hard disk (for translated drive number)
[88]124    CALL_MENU_LIBRARY RefreshItemFromAX
[140]125    pop     ax      ; Update new item (for translated drive number)
126    CALL_MENU_LIBRARY RefreshItemFromAX
[88]127    CALL_MENU_LIBRARY RefreshInformation
128    stc
[3]129    ret
130
131
[88]132; Parameters:
133;   AL:         ASCII character for the key
134;   AH:         Keyboard library scan code for the key
[3]135ALIGN JUMP_ALIGN
[88]136.KeyStrokeInAX:
[92]137    cmp     ah, ROM_BOOT_HOTKEY_SCANCODE
138    jne     SHORT .CheckDriveHotkeys
[95]139    jmp     Int19hMenu_RomBoot
[92]140ALIGN JUMP_ALIGN
141.CheckDriveHotkeys:
[130]142    call    BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
143    cmp     ax, [bp+MENUINIT.wItems]
[92]144    jae     SHORT .EventCompleted   ; Invalid key
[88]145    CALL_MENU_LIBRARY HighlightItemFromAX
146    ; Fall to .ItemSelectedFromCX
[3]147
148
[88]149; Parameters:
150;   CX:         Index of selected item
[3]151ALIGN JUMP_ALIGN
[88]152.ItemSelectedFromCX:
153    CALL_MENU_LIBRARY Close
154.EventCompleted:
155    stc
[3]156    ret
157
158
[88]159; Parameters:
160;   CX:         Index of item to refresh
161;   Cursor has been positioned to the beginning of item line
[3]162ALIGN JUMP_ALIGN
[88]163.RefreshItemFromCX:
164    mov     bx, .rgwItemTypeRefresh
165    jmp     SHORT .RefreshItemOrInformationWithJumpTableInCSBX
[3]166
[88]167
168; Parameters:
169;   CX:         Index of highlighted item
170;   Cursor has been positioned to the beginning of first line
[3]171ALIGN JUMP_ALIGN
[88]172.RefreshInformation:
173    mov     bx, .rgwInformationItemTypeRefresh
174    ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
[3]175
176;--------------------------------------------------------------------
[88]177; RefreshItemOrInformationWithJumpTableInCSBX
[3]178;   Parameters:
179;       CX:     Index of selected menuitem
[88]180;       CS:BX:  Ptr to ITEM_TYPE_REFRESH jump table
[3]181;   Returns:
[88]182;       CF:     set since event processed
[3]183;--------------------------------------------------------------------
[88]184.RefreshItemOrInformationWithJumpTableInCSBX:
185    cmp     cl, NO_ITEM_HIGHLIGHTED
186    je      SHORT .EventCompleted
187
[3]188    call    RamVars_GetSegmentToDS
[130]189    call    BootMenu_GetDriveToDXforMenuitemInCX
[128]190    test    dl, dl                  ; Floppy drive?
191    jns     SHORT .DrawFloppyDrive
[88]192    jmp     [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
[3]193ALIGN JUMP_ALIGN
[88]194.DrawFloppyDrive:
195    jmp     [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
[3]196
[88]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.