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

Last change on this file since 129 was 128, checked in by krille_n_@…, 14 years ago

Changes to the XTIDE Universal BIOS:

  • Size optimizations in various files.
File size: 5.1 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:
[127]26 cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item?
[88]27 ja SHORT .EventNotHandled
[127]28 jmp [cs:bx+.rgfnEventSpecificHandlers]
[88]29.EventNotHandled:
30 clc
31 ret
[3]32
33ALIGN WORD_ALIGN
[88]34.rgfnEventSpecificHandlers:
[124]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
[3]44
45
[88]46; Parameters:
47; DS:SI: Ptr to MENUINIT struct to initialize
48; Returns:
49; DS:SI: Ptr to initialized MENUINIT struct
[3]50ALIGN JUMP_ALIGN
[88]51.InitializeMenuinitFromDSSI:
52 push ds
53 call RamVars_GetSegmentToDS
54 call .GetDefaultMenuitemToDX
[124]55 call BootMenu_GetMenuitemCountToAX
[88]56 pop ds
[124]57 mov [si+MENUINIT.wItems], ax
[88]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
[124]61 call BootMenu_GetHeightToAHwithItemCountInAL
[88]62 mov [si+MENUINIT.bHeight], ah
63 stc
[3]64 ret
65
[88]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
[124]72 jmp BootMenu_GetMenuitemToDXforDriveInDL
[88]73ALIGN JUMP_ALIGN
74.DoNotSetDefaultMenuitem:
75 xor dx, dx ; Whatever appears first on boot menu
76 ret
[3]77
[88]78
79; Parameters:
80; CX: Index of new highlighted item
81; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
[3]82ALIGN JUMP_ALIGN
[88]83.ItemHighlightedFromCX:
84 push cx
85 push dx
[3]86 call RamVars_GetSegmentToDS
87 call DriveXlate_Reset
[92]88 call BootMenu_ConvertMenuitemFromCXtoDriveInDX
[3]89 call DriveXlate_SetDriveToSwap
[88]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
[3]96 ret
97
98
[88]99; Parameters:
100; AL: ASCII character for the key
101; AH: Keyboard library scan code for the key
[3]102ALIGN JUMP_ALIGN
[88]103.KeyStrokeInAX:
[92]104 cmp ah, ROM_BOOT_HOTKEY_SCANCODE
105 jne SHORT .CheckDriveHotkeys
[95]106 jmp Int19hMenu_RomBoot
[92]107ALIGN JUMP_ALIGN
108.CheckDriveHotkeys:
109 call BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX
[88]110 cmp cx, [bp+MENUINIT.wItems]
[92]111 jae SHORT .EventCompleted ; Invalid key
[88]112 xchg ax, cx
113 CALL_MENU_LIBRARY HighlightItemFromAX
114 ; Fall to .ItemSelectedFromCX
[3]115
116
[88]117; Parameters:
118; CX: Index of selected item
[3]119ALIGN JUMP_ALIGN
[88]120.ItemSelectedFromCX:
121 CALL_MENU_LIBRARY Close
122.EventCompleted:
123 stc
[3]124 ret
125
126
[88]127; Parameters:
128; CX: Index of item to refresh
129; Cursor has been positioned to the beginning of item line
[3]130ALIGN JUMP_ALIGN
[88]131.RefreshItemFromCX:
132 mov bx, .rgwItemTypeRefresh
133 jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX
[3]134
[88]135
136; Parameters:
137; CX: Index of highlighted item
138; Cursor has been positioned to the beginning of first line
[3]139ALIGN JUMP_ALIGN
[88]140.RefreshInformation:
141 mov bx, .rgwInformationItemTypeRefresh
142 ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
[3]143
144;--------------------------------------------------------------------
[88]145; RefreshItemOrInformationWithJumpTableInCSBX
[3]146; Parameters:
147; CX: Index of selected menuitem
[88]148; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table
[3]149; Returns:
[88]150; CF: set since event processed
[3]151;--------------------------------------------------------------------
152ALIGN JUMP_ALIGN
[88]153.RefreshItemOrInformationWithJumpTableInCSBX:
154 cmp cl, NO_ITEM_HIGHLIGHTED
155 je SHORT .EventCompleted
156
[3]157 call RamVars_GetSegmentToDS
[92]158 call BootMenu_ConvertMenuitemFromCXtoDriveInDX
[128]159 test dl, dl ; Floppy drive?
160 jns SHORT .DrawFloppyDrive
[88]161 jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
[3]162ALIGN JUMP_ALIGN
[88]163.DrawFloppyDrive:
164 jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
[3]165
[88]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.