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

Last change on this file since 260 was 258, checked in by gregli@…, 13 years ago

Added floppy drive emulation over the serial connection (MODULE_SERIAL_FLOPPY). Along the way, various optimizations were made to stay within the 8K ROM size target. Also, serial code now returns the number of sectors transferred.

File size: 5.3 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
7;--------------------------------------------------------------------
8; BootMenuEvent_Handler
[88]9; Common parameters for all events:
10; BX: Menu event (anything from MENUEVENT struct)
11; SS:BP: Menu library handle
12; Common return values for all events:
13; CF: Set if event processed
14; Cleared if event not processed
[3]15; Corrupts registers:
[88]16; All
[3]17;--------------------------------------------------------------------
18ALIGN JUMP_ALIGN
19BootMenuEvent_Handler:
[202]20
[183]21%ifdef MENUEVENT_INLINE_OFFSETS
[202]22
[258]23 add bx, BootMenuEvent_Handler.FirstEvent
[183]24 jmp bx
[3]25
[258]26MENUEVENT_InitializeMenuinitFromDSSI equ (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler.FirstEvent)
27MENUEVENT_ExitMenu equ (BootMenuEvent_EventCompleted - BootMenuEvent_Handler.FirstEvent)
28MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler.FirstEvent)
29MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler.FirstEvent)
30MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler.FirstEvent)
31MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler.FirstEvent)
32MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - BootMenuEvent_Handler.FirstEvent)
33MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - BootMenuEvent_Handler.FirstEvent)
[202]34;
35; Note that there is no entry for MENUEVENT_IdleProcessing. If MENUEVENT_IDLEPROCESSING_ENABLE is not %defined,
[189]36; then the entry point will not be called (saving memory on this end and at the CALL point).
37;
[202]38
[183]39%else
[202]40
[189]41 cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item?
42 ja SHORT .EventNotHandled
43 jmp [cs:bx+.rgfnEventSpecificHandlers]
44
45.EventNotHandled:
46 clc
47 ret
[202]48
[3]49ALIGN WORD_ALIGN
[88]50.rgfnEventSpecificHandlers:
[241]51 dw .InitializeMenuinitFromDSSI ; MENUEVENT.InitializeMenuinitFromDSSI
52 dw BootMenuEvent_EventCompleted ; MENUEVENT.ExitMenu
53 dw .EventNotHandled ; MENUEVENT.IdleProcessing
54 dw .ItemHighlightedFromCX ; MENUEVENT.ItemHighlightedFromCX
55 dw .ItemSelectedFromCX ; MENUEVENT.ItemSelectedFromCX
56 dw .KeyStrokeInAX ; MENUEVENT.KeyStrokeInAX
57 dw BootMenuPrint_TitleStrings ; MENUEVENT.RefreshTitle
58 dw BootMenuPrint_RefreshInformation ; MENUEVENT.RefreshInformation
59 dw BootMenuPrint_RefreshItem ; MENUEVENT.RefreshItemFromCX
[202]60
[183]61%endif
[3]62
63
[88]64; Parameters:
65; DS:SI: Ptr to MENUINIT struct to initialize
66; Returns:
67; DS:SI: Ptr to initialized MENUINIT struct
[3]68ALIGN JUMP_ALIGN
[258]69.FirstEvent:
[88]70.InitializeMenuinitFromDSSI:
71 push ds
72 call RamVars_GetSegmentToDS
73 call .GetDefaultMenuitemToDX
[124]74 call BootMenu_GetMenuitemCountToAX
[88]75 pop ds
[124]76 mov [si+MENUINIT.wItems], ax
[88]77 mov [si+MENUINIT.wHighlightedItem], dx
78 mov WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
79 mov BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH
[124]80 call BootMenu_GetHeightToAHwithItemCountInAL
[88]81 mov [si+MENUINIT.bHeight], ah
[137]82 mov ax, [cs:ROMVARS.wBootTimeout]
[135]83 CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
[88]84 stc
[3]85 ret
86
[88]87ALIGN JUMP_ALIGN
88.GetDefaultMenuitemToDX:
89 mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive
90 call BootMenu_IsDriveInSystem
91 jnc SHORT .DoNotSetDefaultMenuitem
92 call DriveXlate_SetDriveToSwap
[124]93 jmp BootMenu_GetMenuitemToDXforDriveInDL
[88]94ALIGN JUMP_ALIGN
95.DoNotSetDefaultMenuitem:
96 xor dx, dx ; Whatever appears first on boot menu
97 ret
[3]98
[88]99
100; Parameters:
101; CX: Index of new highlighted item
102; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
[3]103ALIGN JUMP_ALIGN
[88]104.ItemHighlightedFromCX:
105 push cx
[241]106 call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
[3]107 call DriveXlate_Reset
108 call DriveXlate_SetDriveToSwap
[140]109
110 xor ax, ax ; Update first floppy drive (for translated drive number)
[88]111 CALL_MENU_LIBRARY RefreshItemFromAX
[140]112 mov dl, 80h
113 call BootMenu_GetMenuitemToDXforDriveInDL
114 xchg ax, dx ; Update first hard disk (for translated drive number)
[88]115 CALL_MENU_LIBRARY RefreshItemFromAX
[140]116 pop ax ; Update new item (for translated drive number)
117 CALL_MENU_LIBRARY RefreshItemFromAX
[88]118 CALL_MENU_LIBRARY RefreshInformation
119 stc
[3]120 ret
121
122
[88]123; Parameters:
124; AL: ASCII character for the key
125; AH: Keyboard library scan code for the key
[3]126ALIGN JUMP_ALIGN
[88]127.KeyStrokeInAX:
[92]128 cmp ah, ROM_BOOT_HOTKEY_SCANCODE
129 jne SHORT .CheckDriveHotkeys
[212]130 ;; NOTE: carry flag will be clear after compare above that resulted in zero
131 jmp Int19hMenu_JumpToBootSector_or_RomBoot
[92]132ALIGN JUMP_ALIGN
133.CheckDriveHotkeys:
[130]134 call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
135 cmp ax, [bp+MENUINIT.wItems]
[241]136 jae SHORT BootMenuEvent_EventCompleted ; Invalid key
[248]137
138 ; Highlighting new item resets drive translation and we do not want that.
139 ; We must be able to translate both floppy drive and hard drive when using hotkey.
140 call RamVars_GetSegmentToDS
141 mov dx, [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap]
[88]142 CALL_MENU_LIBRARY HighlightItemFromAX
[248]143 or [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], dx
[88]144 ; Fall to .ItemSelectedFromCX
[3]145
146
[88]147; Parameters:
148; CX: Index of selected item
[3]149ALIGN JUMP_ALIGN
[88]150.ItemSelectedFromCX:
151 CALL_MENU_LIBRARY Close
[248]152
[241]153BootMenuEvent_EventCompleted:
[88]154 stc
[3]155 ret
156
Note: See TracBrowser for help on using the repository browser.