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

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

Changes to XTIDE Universal BIOS:

  • INT 13h functions should no longer use Assembly Library.
  • Boot menu now properly displays swapped drive numbers.
File size: 5.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:
[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
[137]63    mov     ax, [cs:ROMVARS.wBootTimeout]
[135]64    CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
[88]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
[124]74    jmp     BootMenu_GetMenuitemToDXforDriveInDL
[88]75ALIGN JUMP_ALIGN
76.DoNotSetDefaultMenuitem:
77    xor     dx, dx                      ; Whatever appears first on boot menu
78    ret
[3]79
[88]80
81; Parameters:
82;   CX:         Index of new highlighted item
83;   DX:         Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
[3]84ALIGN JUMP_ALIGN
[88]85.ItemHighlightedFromCX:
86    push    cx
[3]87    call    RamVars_GetSegmentToDS
88    call    DriveXlate_Reset
[130]89    call    BootMenu_GetDriveToDXforMenuitemInCX
[3]90    call    DriveXlate_SetDriveToSwap
[140]91
92    xor     ax, ax  ; Update first floppy drive (for translated drive number)
[88]93    CALL_MENU_LIBRARY RefreshItemFromAX
[140]94    mov     dl, 80h
95    call    BootMenu_GetMenuitemToDXforDriveInDL
96    xchg    ax, dx  ; Update first hard disk (for translated drive number)
[88]97    CALL_MENU_LIBRARY RefreshItemFromAX
[140]98    pop     ax      ; Update new item (for translated drive number)
99    CALL_MENU_LIBRARY RefreshItemFromAX
[88]100    CALL_MENU_LIBRARY RefreshInformation
101    stc
[3]102    ret
103
104
[88]105; Parameters:
106;   AL:         ASCII character for the key
107;   AH:         Keyboard library scan code for the key
[3]108ALIGN JUMP_ALIGN
[88]109.KeyStrokeInAX:
[92]110    cmp     ah, ROM_BOOT_HOTKEY_SCANCODE
111    jne     SHORT .CheckDriveHotkeys
[95]112    jmp     Int19hMenu_RomBoot
[92]113ALIGN JUMP_ALIGN
114.CheckDriveHotkeys:
[130]115    call    BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
116    cmp     ax, [bp+MENUINIT.wItems]
[92]117    jae     SHORT .EventCompleted   ; Invalid key
[88]118    CALL_MENU_LIBRARY HighlightItemFromAX
119    ; Fall to .ItemSelectedFromCX
[3]120
121
[88]122; Parameters:
123;   CX:         Index of selected item
[3]124ALIGN JUMP_ALIGN
[88]125.ItemSelectedFromCX:
126    CALL_MENU_LIBRARY Close
127.EventCompleted:
128    stc
[3]129    ret
130
131
[88]132; Parameters:
133;   CX:         Index of item to refresh
134;   Cursor has been positioned to the beginning of item line
[3]135ALIGN JUMP_ALIGN
[88]136.RefreshItemFromCX:
137    mov     bx, .rgwItemTypeRefresh
138    jmp     SHORT .RefreshItemOrInformationWithJumpTableInCSBX
[3]139
[88]140
141; Parameters:
142;   CX:         Index of highlighted item
143;   Cursor has been positioned to the beginning of first line
[3]144ALIGN JUMP_ALIGN
[88]145.RefreshInformation:
146    mov     bx, .rgwInformationItemTypeRefresh
147    ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
[3]148
149;--------------------------------------------------------------------
[88]150; RefreshItemOrInformationWithJumpTableInCSBX
[3]151;   Parameters:
152;       CX:     Index of selected menuitem
[88]153;       CS:BX:  Ptr to ITEM_TYPE_REFRESH jump table
[3]154;   Returns:
[88]155;       CF:     set since event processed
[3]156;--------------------------------------------------------------------
[88]157.RefreshItemOrInformationWithJumpTableInCSBX:
158    cmp     cl, NO_ITEM_HIGHLIGHTED
159    je      SHORT .EventCompleted
160
[3]161    call    RamVars_GetSegmentToDS
[130]162    call    BootMenu_GetDriveToDXforMenuitemInCX
[128]163    test    dl, dl                  ; Floppy drive?
164    jns     SHORT .DrawFloppyDrive
[88]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.