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

Last change on this file since 124 was 124, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

  • Some boot menu fixes but menu does not work yet.
File size: 5.1 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    cmp     bx, MENUEVENT.RefreshItemFromCX ; Above last supported item?
27    ja      SHORT .EventNotHandled
28    jmp     [bx+.rgfnEventSpecificHandlers]
29.EventNotHandled:
30    clc
31    ret
32
33ALIGN WORD_ALIGN
34.rgfnEventSpecificHandlers:
35    dw      .InitializeMenuinitFromDSSI ; MENUEVENT.InitializeMenuinitFromDSSI
36    dw      .EventCompleted             ; MENUEVENT.ExitMenu
37    dw      .EventNotHandled            ; MENUEVENT.IdleProcessing
38    dw      .ItemHighlightedFromCX      ; MENUEVENT.ItemHighlightedFromCX
39    dw      .ItemSelectedFromCX         ; MENUEVENT.ItemSelectedFromCX
40    dw      .KeyStrokeInAX              ; MENUEVENT.KeyStrokeInAX
41    dw      BootMenuPrint_TitleStrings  ; MENUEVENT.RefreshTitle
42    dw      .RefreshInformation         ; MENUEVENT.RefreshInformation
43    dw      .RefreshItemFromCX          ; MENUEVENT.RefreshItemFromCX
44
45
46; Parameters:
47;   DS:SI:      Ptr to MENUINIT struct to initialize
48; Returns:
49;   DS:SI:      Ptr to initialized MENUINIT struct
50ALIGN JUMP_ALIGN
51.InitializeMenuinitFromDSSI:
52    push    ds
53    call    RamVars_GetSegmentToDS
54    call    .GetDefaultMenuitemToDX
55    call    BootMenu_GetMenuitemCountToAX
56    pop     ds
57    mov     [si+MENUINIT.wItems], ax
58    mov     [si+MENUINIT.wHighlightedItem], dx
59    mov     WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
60    mov     BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH
61    call    BootMenu_GetHeightToAHwithItemCountInAL
62    mov     [si+MENUINIT.bHeight], ah
63    stc
64    ret
65
66ALIGN JUMP_ALIGN
67.GetDefaultMenuitemToDX:
68    mov     dl, [cs:ROMVARS.bBootDrv]   ; Default boot drive
69    call    BootMenu_IsDriveInSystem
70    jnc     SHORT .DoNotSetDefaultMenuitem
71    call    DriveXlate_SetDriveToSwap
72    jmp     BootMenu_GetMenuitemToDXforDriveInDL
73ALIGN JUMP_ALIGN
74.DoNotSetDefaultMenuitem:
75    xor     dx, dx                      ; Whatever appears first on boot menu
76    ret
77
78
79; Parameters:
80;   CX:         Index of new highlighted item
81;   DX:         Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
82ALIGN JUMP_ALIGN
83.ItemHighlightedFromCX:
84    push    cx
85    push    dx
86    call    RamVars_GetSegmentToDS
87    call    DriveXlate_Reset
88    call    BootMenu_ConvertMenuitemFromCXtoDriveInDX
89    call    DriveXlate_SetDriveToSwap
90    pop     ax      ; Update previous item
91    CALL_MENU_LIBRARY RefreshItemFromAX
92    pop     ax      ; Update new item
93    CALL_MENU_LIBRARY RefreshItemFromAX
94    CALL_MENU_LIBRARY RefreshInformation
95    stc
96    ret
97
98
99; Parameters:
100;   AL:         ASCII character for the key
101;   AH:         Keyboard library scan code for the key
102ALIGN JUMP_ALIGN
103.KeyStrokeInAX:
104    cmp     ah, ROM_BOOT_HOTKEY_SCANCODE
105    jne     SHORT .CheckDriveHotkeys
106    jmp     Int19hMenu_RomBoot
107ALIGN JUMP_ALIGN
108.CheckDriveHotkeys:
109    call    BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX
110    cmp     cx, [bp+MENUINIT.wItems]
111    jae     SHORT .EventCompleted   ; Invalid key
112    xchg    ax, cx
113    CALL_MENU_LIBRARY HighlightItemFromAX
114    ; Fall to .ItemSelectedFromCX
115
116
117; Parameters:
118;   CX:         Index of selected item
119ALIGN JUMP_ALIGN
120.ItemSelectedFromCX:
121    CALL_MENU_LIBRARY Close
122.EventCompleted:
123    stc
124    ret
125
126
127; Parameters:
128;   CX:         Index of item to refresh
129;   Cursor has been positioned to the beginning of item line
130ALIGN JUMP_ALIGN
131.RefreshItemFromCX:
132    mov     bx, .rgwItemTypeRefresh
133    jmp     SHORT .RefreshItemOrInformationWithJumpTableInCSBX
134
135
136; Parameters:
137;   CX:         Index of highlighted item
138;   Cursor has been positioned to the beginning of first line
139ALIGN JUMP_ALIGN
140.RefreshInformation:
141    mov     bx, .rgwInformationItemTypeRefresh
142    ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
143
144;--------------------------------------------------------------------
145; RefreshItemOrInformationWithJumpTableInCSBX
146;   Parameters:
147;       CX:     Index of selected menuitem
148;       CS:BX:  Ptr to ITEM_TYPE_REFRESH jump table
149;   Returns:
150;       CF:     set since event processed
151;--------------------------------------------------------------------
152ALIGN JUMP_ALIGN
153.RefreshItemOrInformationWithJumpTableInCSBX:
154    cmp     cl, NO_ITEM_HIGHLIGHTED
155    je      SHORT .EventCompleted
156
157    call    RamVars_GetSegmentToDS
158    call    BootMenu_ConvertMenuitemFromCXtoDriveInDX
159    test    dl, 80h                 ; Floppy drive?
160    jz      SHORT .DrawFloppyDrive
161    jmp     [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
162ALIGN JUMP_ALIGN
163.DrawFloppyDrive:
164    jmp     [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
165
166; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX
167ALIGN WORD_ALIGN
168.rgwItemTypeRefresh:
169istruc ITEM_TYPE_REFRESH
170    at  ITEM_TYPE_REFRESH.HardDisk,         dw  BootMenuPrint_HardDiskMenuitem
171    at  ITEM_TYPE_REFRESH.FloppyDrive,      dw  BootMenuPrint_FloppyMenuitem
172iend
173.rgwInformationItemTypeRefresh:
174istruc ITEM_TYPE_REFRESH
175    at  ITEM_TYPE_REFRESH.HardDisk,         dw  BootMenuPrint_HardDiskMenuitemInformation
176    at  ITEM_TYPE_REFRESH.FloppyDrive,      dw  BootMenuPrint_FloppyMenuitemInformation
177iend
Note: See TracBrowser for help on using the repository browser.