[88] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Functions for printing boot menu strings. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
| 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
| 7 | ; |
---|
| 8 | ; This program is free software; you can redistribute it and/or modify |
---|
| 9 | ; it under the terms of the GNU General Public License as published by |
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ; (at your option) any later version. |
---|
| 12 | ; |
---|
| 13 | ; This program is distributed in the hope that it will be useful, |
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | ; GNU General Public License for more details. |
---|
| 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 18 | ; |
---|
| 19 | |
---|
[3] | 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
[241] | 24 | ; BootMenuPrint_RefreshItem |
---|
[294] | 25 | ; |
---|
[189] | 26 | ; Parameters: |
---|
| 27 | ; DL: Untranslated Floppy Drive number |
---|
| 28 | ; Returns: |
---|
| 29 | ; Nothing |
---|
| 30 | ; Corrupts registers: |
---|
[241] | 31 | ; AX, BX, DX, SI, DI |
---|
[189] | 32 | ;-------------------------------------------------------------------- |
---|
[241] | 33 | BootMenuPrint_RefreshItem: |
---|
| 34 | call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS |
---|
| 35 | jnc BootMenuEvent_EventCompleted ; if no menu item selected, out we go |
---|
[294] | 36 | |
---|
[189] | 37 | push bp |
---|
| 38 | mov bp, sp |
---|
| 39 | |
---|
[262] | 40 | call FindDPT_ForDriveNumberInDL |
---|
[258] | 41 | jc .notOurs |
---|
[241] | 42 | |
---|
[254] | 43 | call BootMenuInfo_ConvertDPTtoBX |
---|
[241] | 44 | mov si, g_szDriveNumBOOTNFO ; special g_szDriveNum that prints from BDA |
---|
| 45 | jmp .go |
---|
[294] | 46 | |
---|
[241] | 47 | .notOurs: |
---|
[294] | 48 | mov si,g_szDriveNum |
---|
[241] | 49 | mov bx,g_szForeignHD ; assume a hard disk for the moment |
---|
[294] | 50 | |
---|
| 51 | test dl, dl |
---|
[241] | 52 | js .go |
---|
| 53 | mov bl,((g_szFloppyDrv)-$$ & 0xff) ; and revisit the earlier assumption... |
---|
[294] | 54 | |
---|
[241] | 55 | .go: |
---|
| 56 | mov ax, dx ; preserve DL for the floppy drive letter addition |
---|
| 57 | call DriveXlate_ToOrBack |
---|
| 58 | push dx ; translated drive number |
---|
| 59 | push bx ; sub string |
---|
| 60 | add al, 'A' ; floppy drive letter (we always push this although |
---|
| 61 | push ax ; the hard disks don't ever use it, but it does no harm) |
---|
[294] | 62 | |
---|
[258] | 63 | jmp short BootMenuPrint_RefreshInformation.FormatRelay |
---|
[130] | 64 | |
---|
| 65 | ;-------------------------------------------------------------------- |
---|
[88] | 66 | ; Prints Boot Menu title strings. |
---|
[3] | 67 | ; |
---|
[88] | 68 | ; BootMenuPrint_TitleStrings |
---|
[3] | 69 | ; Parameters: |
---|
[88] | 70 | ; Nothing |
---|
[3] | 71 | ; Returns: |
---|
[88] | 72 | ; CF: Set since menu event handled |
---|
[3] | 73 | ; Corrupts registers: |
---|
[88] | 74 | ; AX, SI, DI |
---|
[3] | 75 | ;-------------------------------------------------------------------- |
---|
[88] | 76 | BootMenuPrint_TitleStrings: |
---|
| 77 | mov si, ROMVARS.szTitle |
---|
[96] | 78 | call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF |
---|
| 79 | CALL_DISPLAY_LIBRARY PrintNewlineCharacters |
---|
[88] | 80 | mov si, ROMVARS.szVersion |
---|
[161] | 81 | ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF |
---|
[3] | 82 | |
---|
| 83 | ;-------------------------------------------------------------------- |
---|
[128] | 84 | ; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF |
---|
| 85 | ; Parameters: |
---|
| 86 | ; CS:SI: Ptr to NULL terminated string to print |
---|
| 87 | ; Returns: |
---|
| 88 | ; CF: Set since menu event was handled successfully |
---|
| 89 | ; Corrupts registers: |
---|
[186] | 90 | ; AX, DI |
---|
[128] | 91 | ;-------------------------------------------------------------------- |
---|
| 92 | BootMenuPrint_NullTerminatedStringFromCSSIandSetCF: |
---|
[186] | 93 | ; |
---|
| 94 | ; We send all CSSI strings through the Format routine for the case of |
---|
| 95 | ; compressed strings, but this doesn't hurt in the non-compressed case either |
---|
| 96 | ; (perhaps a little slower, but shouldn't be noticeable to the user) |
---|
| 97 | ; and results in smaller code size. |
---|
| 98 | ; |
---|
| 99 | push bp |
---|
| 100 | mov bp,sp |
---|
[258] | 101 | jmp short BootMenuPrint_RefreshInformation.FormatRelay |
---|
[128] | 102 | |
---|
[294] | 103 | |
---|
[128] | 104 | ;-------------------------------------------------------------------- |
---|
[3] | 105 | ; BootMenuPrint_FloppyMenuitemInformation |
---|
| 106 | ; Parameters: |
---|
| 107 | ; DL: Untranslated Floppy Drive number |
---|
| 108 | ; DS: RAMVARS segment |
---|
| 109 | ; Returns: |
---|
[88] | 110 | ; CF: Set since menu event was handled successfully |
---|
[3] | 111 | ; Corrupts registers: |
---|
[88] | 112 | ; AX, BX, CX, DX, SI, DI, ES |
---|
[3] | 113 | ;-------------------------------------------------------------------- |
---|
[241] | 114 | BootMenuPrint_RefreshInformation: |
---|
[294] | 115 | CALL_MENU_LIBRARY ClearInformationArea |
---|
| 116 | |
---|
[241] | 117 | call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS |
---|
| 118 | jnc BootMenuEvent_EventCompleted ; if no menu selection, abort |
---|
[182] | 119 | |
---|
[161] | 120 | push bp |
---|
| 121 | mov bp, sp |
---|
[241] | 122 | |
---|
[258] | 123 | mov si, g_szCapacity ; Setup print string now, carries through to print call |
---|
| 124 | |
---|
[262] | 125 | call FindDPT_ForDriveNumberInDL |
---|
[259] | 126 | |
---|
[262] | 127 | inc dl ; are we a hard disk? |
---|
| 128 | dec dl ; inc/dec will set SF, without modifying CF or DL |
---|
[294] | 129 | js .HardDiskRefreshInformation |
---|
[258] | 130 | |
---|
[262] | 131 | jnc .ours ; Based on CF from FindDPT_ForDriveNumberInDL above |
---|
[241] | 132 | call FloppyDrive_GetType ; Get Floppy Drive type to BX |
---|
[258] | 133 | jmp .around |
---|
| 134 | .ours: |
---|
| 135 | call AH8h_GetDriveParameters |
---|
[294] | 136 | .around: |
---|
[182] | 137 | |
---|
[255] | 138 | mov ax, g_szFddSizeOr ; .PrintXTFloppyType |
---|
[294] | 139 | test bl, bl ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD) |
---|
[255] | 140 | jz SHORT .PushAXAndOutput |
---|
[241] | 141 | |
---|
[255] | 142 | mov al, (g_szFddUnknown - $$) & 0xff ; .PrintUnknownFloppyType |
---|
[3] | 143 | cmp bl, FLOPPY_TYPE_35_ED |
---|
[255] | 144 | ja SHORT .PushAXAndOutput |
---|
[294] | 145 | |
---|
[161] | 146 | ; Fall to .PrintKnownFloppyType |
---|
[3] | 147 | |
---|
| 148 | ;-------------------------------------------------------------------- |
---|
[161] | 149 | ; .PrintKnownFloppyType |
---|
[3] | 150 | ; Parameters: |
---|
[161] | 151 | ; BX: Floppy drive type |
---|
[3] | 152 | ; Returns: |
---|
[88] | 153 | ; CF: Set since menu event was handled successfully |
---|
[3] | 154 | ; Corrupts registers: |
---|
[161] | 155 | ; AX, BX, SI, DI |
---|
[294] | 156 | ; |
---|
[182] | 157 | ; Floppy Drive Types: |
---|
| 158 | ; |
---|
[294] | 159 | ; 0 Handled above |
---|
[182] | 160 | ; 1 FLOPPY_TYPE_525_DD 5 1/4 360K |
---|
| 161 | ; 2 FLOPPY_TYPE_525_HD 5 1/4 1.2M |
---|
| 162 | ; 3 FLOPPY_TYPE_35_DD 3 1/2 720K |
---|
| 163 | ; 4 FLOPPY_TYPE_35_HD 3 1/2 1.44M |
---|
| 164 | ; 5 3.5" ED on some BIOSes 3 1/2 2.88M |
---|
| 165 | ; 6 FLOPPY_TYPE_35_ED 3 1/2 2.88M |
---|
| 166 | ; >6 Unknwon, handled above |
---|
[294] | 167 | ; |
---|
[3] | 168 | ;-------------------------------------------------------------------- |
---|
[161] | 169 | .PrintKnownFloppyType: |
---|
[255] | 170 | mov al, (g_szFddSize - $$) & 0xff |
---|
| 171 | push ax |
---|
[294] | 172 | |
---|
[255] | 173 | mov al, (g_szFddThreeHalf - $$) & 0xff |
---|
[182] | 174 | cmp bl, FLOPPY_TYPE_525_HD |
---|
| 175 | ja .ThreeHalf |
---|
[255] | 176 | mov al, (g_szFddFiveQuarter - $$) & 0xff |
---|
[294] | 177 | .ThreeHalf: |
---|
[255] | 178 | push ax ; "5 1/4" or "3 1/2" |
---|
[3] | 179 | |
---|
[182] | 180 | mov al,FloppyTypes.rgbCapacityMultiplier |
---|
[258] | 181 | mov bh, 0 |
---|
[182] | 182 | mul byte [cs:bx+FloppyTypes.rgbCapacity - 1] ; -1 since 0 is handled above and not in the table |
---|
[255] | 183 | |
---|
[294] | 184 | .PushAXAndOutput: |
---|
[182] | 185 | push ax |
---|
[161] | 186 | |
---|
[258] | 187 | .FormatRelay: |
---|
| 188 | jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP |
---|
[88] | 189 | |
---|
[192] | 190 | |
---|
| 191 | ;-------------------------------------------------------------------- |
---|
[3] | 192 | ; Prints Hard Disk Menuitem information strings. |
---|
| 193 | ; |
---|
| 194 | ; BootMenuPrint_HardDiskMenuitemInformation |
---|
| 195 | ; Parameters: |
---|
| 196 | ; DS: RAMVARS segment |
---|
| 197 | ; Returns: |
---|
[88] | 198 | ; CF: Set since menu event was handled successfully |
---|
[3] | 199 | ; Corrupts registers: |
---|
| 200 | ; BX, CX, DX, SI, DI, ES |
---|
| 201 | ;-------------------------------------------------------------------- |
---|
[294] | 202 | .HardDiskRefreshInformation: |
---|
[262] | 203 | jc .HardDiskMenuitemInfoForForeignDrive ; Based on CF from FindDPT_ForDriveNumberInDL (way) above |
---|
[3] | 204 | |
---|
[127] | 205 | .HardDiskMenuitemInfoForOurDrive: |
---|
[262] | 206 | ePUSH_T ax, g_szInformation ; Add substring for our hard disk information |
---|
| 207 | call BootMenuInfo_GetTotalSectorCount ; Get Total LBA Size |
---|
[258] | 208 | jmp .ConvertSectorCountInBXDXAXtoSizeAndPushForFormat |
---|
[294] | 209 | |
---|
[127] | 210 | .HardDiskMenuitemInfoForForeignDrive: |
---|
| 211 | call DriveXlate_ToOrBack |
---|
[150] | 212 | call AH15h_GetSectorCountFromForeignDriveToDXAX |
---|
[88] | 213 | |
---|
[258] | 214 | .ConvertSectorCountInBXDXAXtoSizeAndPushForFormat: |
---|
| 215 | ePUSH_T cx, g_szCapacityNum ; Push format substring |
---|
| 216 | call Size_ConvertSectorCountInBXDXAXtoKiB |
---|
| 217 | mov cx, BYTE_MULTIPLES.kiB |
---|
| 218 | call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX |
---|
| 219 | push ax ; Size in magnitude |
---|
| 220 | push cx ; Tenths |
---|
[294] | 221 | push dx ; Magnitude character |
---|
| 222 | |
---|
[258] | 223 | test di,di |
---|
| 224 | jz short BootMenuPrint_FormatCSSIfromParamsInSSBP |
---|
[3] | 225 | |
---|
[258] | 226 | %include "BootMenuPrintCfg.asm" ; inline of code to fill out remainder of information string |
---|
| 227 | |
---|
| 228 | ;;; fall-through to BootMenuPrint_FormatCSSIfromParamsInSSBP |
---|
| 229 | |
---|
| 230 | |
---|
[3] | 231 | ;-------------------------------------------------------------------- |
---|
[241] | 232 | ; BootMenuPrint_FormatCSSIfromParamsInSSBP |
---|
[88] | 233 | ; Parameters: |
---|
[241] | 234 | ; CS:SI: Ptr to string to format |
---|
| 235 | ; BP: SP before pushing parameters |
---|
[88] | 236 | ; Returns: |
---|
[241] | 237 | ; BP: Popped from stack |
---|
[294] | 238 | ; CF: Set since menu event was handled successfully |
---|
[88] | 239 | ; Corrupts registers: |
---|
[120] | 240 | ; AX, DI |
---|
[88] | 241 | ;-------------------------------------------------------------------- |
---|
[241] | 242 | BootMenuPrint_FormatCSSIfromParamsInSSBP: |
---|
| 243 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI |
---|
[294] | 244 | stc ; Successful return from menu event |
---|
[241] | 245 | pop bp |
---|
[88] | 246 | ret |
---|
[294] | 247 | |
---|
| 248 | |
---|
[88] | 249 | ;-------------------------------------------------------------------- |
---|
[192] | 250 | ; BootMenuPrint_ClearScreen |
---|
[88] | 251 | ; Parameters: |
---|
[192] | 252 | ; Nothing |
---|
[88] | 253 | ; Returns: |
---|
[192] | 254 | ; Nothing |
---|
[88] | 255 | ; Corrupts registers: |
---|
[192] | 256 | ; AX, DI |
---|
[88] | 257 | ;-------------------------------------------------------------------- |
---|
[192] | 258 | BootMenuPrint_ClearScreen: |
---|
| 259 | call BootMenuPrint_InitializeDisplayContext |
---|
| 260 | xor ax, ax |
---|
| 261 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
| 262 | mov ax, ' ' | (MONO_NORMAL<<8) |
---|
| 263 | CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH |
---|
| 264 | ret |
---|
[88] | 265 | |
---|
| 266 | |
---|
| 267 | ;-------------------------------------------------------------------- |
---|
| 268 | ; BootMenuPrint_TheBottomOfScreen |
---|
[3] | 269 | ; Parameters: |
---|
| 270 | ; DS: RAMVARS segment |
---|
| 271 | ; Returns: |
---|
[88] | 272 | ; Nothing |
---|
[3] | 273 | ; Corrupts registers: |
---|
[92] | 274 | ; AX, BX, CX, DX, SI, DI |
---|
[3] | 275 | ;-------------------------------------------------------------------- |
---|
[88] | 276 | BootMenuPrint_TheBottomOfScreen: |
---|
[258] | 277 | call FloppyDrive_GetCountToAX |
---|
| 278 | xchg bx, ax ; Floppy Drive count to BL |
---|
| 279 | call RamVars_GetHardDiskCountFromBDAtoAX |
---|
| 280 | mov bh, al ; Hard Disk count to BH |
---|
[92] | 281 | ; Fall to .MoveCursorToHotkeyStrings |
---|
[3] | 282 | |
---|
[92] | 283 | ;-------------------------------------------------------------------- |
---|
| 284 | ; .MoveCursorToHotkeyStrings |
---|
| 285 | ; Parameters: |
---|
| 286 | ; Nothing |
---|
| 287 | ; Returns: |
---|
| 288 | ; Nothing |
---|
| 289 | ; Corrupts registers: |
---|
| 290 | ; AX, DI |
---|
| 291 | ;-------------------------------------------------------------------- |
---|
| 292 | .MoveCursorToHotkeyStrings: |
---|
| 293 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
| 294 | xor al, al |
---|
| 295 | dec ah |
---|
| 296 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
| 297 | ; Fall to .PrintHotkeyString |
---|
[3] | 298 | |
---|
| 299 | ;-------------------------------------------------------------------- |
---|
[92] | 300 | ; .PrintHotkeyString |
---|
[3] | 301 | ; Parameters: |
---|
[92] | 302 | ; BL: Floppy Drives |
---|
| 303 | ; BH: Hard Drives |
---|
[88] | 304 | ; Returns: |
---|
[92] | 305 | ; Nothing |
---|
[88] | 306 | ; Corrupts registers: |
---|
[120] | 307 | ; AX, CX, DX, SI, DI |
---|
[88] | 308 | ;-------------------------------------------------------------------- |
---|
[92] | 309 | .PrintHotkeyString: |
---|
| 310 | ; Display Library should not be called like this |
---|
| 311 | mov si, ATTRIBUTE_CHARS.cHighlightedItem |
---|
| 312 | call MenuAttribute_GetToAXfromTypeInSI |
---|
| 313 | xchg dx, ax |
---|
[122] | 314 | mov cx, MONO_BRIGHT |
---|
[88] | 315 | |
---|
[92] | 316 | test bl, bl ; Any Floppy Drives? |
---|
| 317 | jz SHORT .SkipFloppyDriveHotkeys |
---|
| 318 | mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8) |
---|
| 319 | mov si, g_szFDD |
---|
| 320 | call PushHotkeyParamsAndFormat |
---|
[88] | 321 | |
---|
[92] | 322 | .SkipFloppyDriveHotkeys: |
---|
| 323 | test bh, bh ; Any Hard Drives? |
---|
| 324 | jz SHORT .SkipHardDriveHotkeys |
---|
[258] | 325 | call BootMenu_GetLetterForFirstHardDiskToAL |
---|
| 326 | mov ah, ANGLE_QUOTE_RIGHT |
---|
[92] | 327 | mov si, g_szHDD |
---|
| 328 | call PushHotkeyParamsAndFormat |
---|
| 329 | |
---|
| 330 | .SkipHardDriveHotkeys: |
---|
| 331 | ; Fall to .PrintRomBootHotkey |
---|
| 332 | |
---|
[88] | 333 | ;-------------------------------------------------------------------- |
---|
[92] | 334 | ; .PrintRomBootHotkey |
---|
[88] | 335 | ; Parameters: |
---|
[92] | 336 | ; CX: Key Attribute |
---|
| 337 | ; DX: Description Attribute |
---|
[3] | 338 | ; Returns: |
---|
[88] | 339 | ; Nothing |
---|
[3] | 340 | ; Corrupts registers: |
---|
[120] | 341 | ; AX, SI, DI |
---|
[3] | 342 | ;-------------------------------------------------------------------- |
---|
[92] | 343 | .PrintRomBootHotkey: |
---|
| 344 | mov ax, 'F' | ('8'<<8) ; F8 |
---|
| 345 | mov si, g_szRomBoot |
---|
| 346 | ; Fall to PushHotkeyParamsAndFormat |
---|
| 347 | |
---|
| 348 | ;-------------------------------------------------------------------- |
---|
| 349 | ; PushHotkeyParamsAndFormat |
---|
| 350 | ; Parameters: |
---|
| 351 | ; AL: First character |
---|
| 352 | ; AH: Second character |
---|
| 353 | ; CX: Key Attribute |
---|
| 354 | ; DX: Description Attribute |
---|
| 355 | ; CS:SI: Description string |
---|
| 356 | ; Returns: |
---|
| 357 | ; Nothing |
---|
| 358 | ; Corrupts registers: |
---|
[120] | 359 | ; AX, SI, DI |
---|
[92] | 360 | ;-------------------------------------------------------------------- |
---|
| 361 | PushHotkeyParamsAndFormat: |
---|
| 362 | push bp |
---|
| 363 | mov bp, sp |
---|
| 364 | |
---|
| 365 | push cx ; Key attribute |
---|
| 366 | push ax ; First character |
---|
| 367 | xchg al, ah |
---|
| 368 | push ax ; Second character |
---|
| 369 | push dx ; Description attribute |
---|
| 370 | push si ; Description string |
---|
| 371 | push cx ; Key attribute for last space |
---|
| 372 | mov si, g_szHotkey |
---|
[294] | 373 | |
---|
| 374 | BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay: |
---|
[241] | 375 | jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP |
---|
[161] | 376 | |
---|
[182] | 377 | |
---|
[192] | 378 | ;-------------------------------------------------------------------- |
---|
| 379 | ; BootMenuPrint_InitializeDisplayContext |
---|
| 380 | ; Parameters: |
---|
| 381 | ; Nothing |
---|
| 382 | ; Returns: |
---|
| 383 | ; Nothing |
---|
| 384 | ; Corrupts registers: |
---|
| 385 | ; AX, DI |
---|
| 386 | ;-------------------------------------------------------------------- |
---|
| 387 | BootMenuPrint_InitializeDisplayContext: |
---|
| 388 | CALL_DISPLAY_LIBRARY InitializeDisplayContext |
---|
| 389 | ret |
---|
| 390 | |
---|
| 391 | |
---|
[241] | 392 | FloppyTypes: |
---|
| 393 | .rgbCapacityMultiplier equ 20 ; Multiplier to reduce word sized values to byte size |
---|
| 394 | .rgbCapacity: |
---|
| 395 | db 360 / FloppyTypes.rgbCapacityMultiplier ; type 1 |
---|
| 396 | db 1200 / FloppyTypes.rgbCapacityMultiplier ; type 2 |
---|
| 397 | db 720 / FloppyTypes.rgbCapacityMultiplier ; type 3 |
---|
| 398 | db 1440 / FloppyTypes.rgbCapacityMultiplier ; type 4 |
---|
| 399 | db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 5 |
---|
| 400 | db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 6 |
---|