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

Last change on this file since 100 was 95, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

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