[29] | 1 | ; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
|
---|
| 2 | ;
|
---|
| 3 | ; This file is part of AiR-BOOT
|
---|
| 4 | ;
|
---|
| 5 | ; AiR-BOOT is free software: you can redistribute it and/or modify it under
|
---|
| 6 | ; the terms of the GNU General Public License as published by the Free
|
---|
| 7 | ; Software Foundation, either version 3 of the License, or (at your option)
|
---|
| 8 | ; any later version.
|
---|
| 9 | ;
|
---|
| 10 | ; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
| 11 | ; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 12 | ; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
---|
| 13 | ; details.
|
---|
| 14 | ;
|
---|
| 15 | ; You should have received a copy of the GNU General Public License along with
|
---|
| 16 | ; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | ;
|
---|
[8] | 18 | ;---------------------------------------------------------------------------
|
---|
| 19 | ; AiR-BOOT / OTHER ROUTINES
|
---|
| 20 | ;---------------------------------------------------------------------------
|
---|
| 21 |
|
---|
[51] | 22 | IFDEF MODULE_NAMES
|
---|
[30] | 23 | DB 'OTHER',0
|
---|
| 24 | ENDIF
|
---|
| 25 |
|
---|
[8] | 26 | ; In: DS:SI - Pointer to begin of string
|
---|
| 27 | ; CX - Len of string
|
---|
| 28 | ; Out: CX - Supposed real len of string
|
---|
| 29 | ; Zero Flag set if nul string
|
---|
| 30 | ; Destroyed: None
|
---|
[43] | 31 | GetLenOfName Proc Near Uses ax si
|
---|
| 32 | add si, cx
|
---|
| 33 | dec si
|
---|
| 34 | GLON_NameLoop:
|
---|
| 35 | mov al, ds:[si]
|
---|
| 36 | dec si
|
---|
| 37 | cmp al, 32
|
---|
| 38 | ja GLON_EndLoop
|
---|
| 39 | dec cx
|
---|
| 40 | jnz GLON_NameLoop
|
---|
| 41 | GLON_EndLoop:
|
---|
| 42 | or cx, cx
|
---|
| 43 | ret ; return supposed len
|
---|
| 44 | GetLenOfName EndP
|
---|
[8] | 45 |
|
---|
| 46 | ; In: DS:SI - Pointer to NUL-terminated string
|
---|
| 47 | ; Out: CX - Length of string
|
---|
| 48 | ; Zero Flag set if nul string
|
---|
| 49 | ; Destroyed: None
|
---|
[43] | 50 | GetLenOfString Proc Near Uses ax si
|
---|
| 51 | xor cx, cx
|
---|
| 52 | GLOS_StringLoop:
|
---|
| 53 | lodsb
|
---|
| 54 | or al, al
|
---|
| 55 | jz GLOS_EndOfString
|
---|
| 56 | inc cx
|
---|
| 57 | jmp GLOS_StringLoop
|
---|
[8] | 58 |
|
---|
[43] | 59 | GLOS_EndOfString:
|
---|
| 60 | or cx, cx
|
---|
| 61 | ret
|
---|
| 62 | GetLenOfString EndP
|
---|
[8] | 63 |
|
---|
| 64 | ; In: DS:SI - Pointer to NUL-terminated strings
|
---|
| 65 | ; CL - Counter, how many strings to count
|
---|
| 66 | ; Out: CX - Length of strings
|
---|
| 67 | ; Destroyed: None
|
---|
[43] | 68 | GetLenOfStrings Proc Near Uses bx dx si
|
---|
| 69 | mov dh, cl
|
---|
| 70 | xor dl, dl
|
---|
| 71 | GLOSS_StringsLoop:
|
---|
| 72 | call GetLenOfString
|
---|
| 73 | add dl, cl
|
---|
| 74 | add si, cx
|
---|
| 75 | inc si
|
---|
| 76 | dec dh
|
---|
| 77 | jnz GLOSS_StringsLoop
|
---|
| 78 | ;movzx cx, dl
|
---|
| 79 | mov cl,dl
|
---|
| 80 | mov ch,0
|
---|
| 81 | ret
|
---|
| 82 | GetLenOfStrings EndP
|
---|
[30] | 83 |
|
---|
[51] | 84 |
|
---|
| 85 |
|
---|
| 86 | ;
|
---|
| 87 | ; DO PREPARING STUFF.
|
---|
| 88 | ;
|
---|
[43] | 89 | PRECRAP_Main Proc Near
|
---|
[105] | 90 |
|
---|
[111] | 91 | IFDEF AUX_DEBUG
|
---|
[164] | 92 | IF 0
|
---|
[142] | 93 | DBG_TEXT_OUT_AUX 'PRECRAP_Main:'
|
---|
[123] | 94 | PUSHRF
|
---|
[111] | 95 | ;~ call DEBUG_DumpRegisters
|
---|
| 96 | ;~ call AuxIO_DumpParagraph
|
---|
| 97 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 98 | POPRF
|
---|
[111] | 99 | ENDIF
|
---|
| 100 | ENDIF
|
---|
| 101 |
|
---|
[51] | 102 | ;
|
---|
| 103 | ; Tasm needs .386 to handle 32-bit constants so we push the current
|
---|
| 104 | ; operating state and switch temporarily to handle
|
---|
| 105 | ; InitialFreeDriveletterMap.
|
---|
| 106 | ;
|
---|
| 107 | IFDEF TASM
|
---|
| 108 | pushstate
|
---|
| 109 | .386
|
---|
| 110 | ENDIF
|
---|
| 111 | ; Initialize the FreeDriveletterMap.
|
---|
| 112 | ; This is used by driveletter reassignment functions.
|
---|
| 113 | mov di, offset [FreeDriveletterMap]
|
---|
| 114 | mov ax, InitialFreeDriveletterMap AND 0ffffh
|
---|
| 115 | cld
|
---|
| 116 | stosw
|
---|
| 117 | mov ax, InitialFreeDriveletterMap SHR 16
|
---|
| 118 | stosw
|
---|
| 119 | ;
|
---|
| 120 | ; Restore Tasm operating state.
|
---|
| 121 | ;
|
---|
| 122 | IFDEF TASM
|
---|
| 123 | popstate
|
---|
| 124 | ENDIF
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 | ; Use video page 0 for screen output
|
---|
[46] | 128 | mov word ptr [VideoIO_Segment], VideoIO_Page0
|
---|
[8] | 129 |
|
---|
[43] | 130 | ; Don't use blinking attribute
|
---|
| 131 | call VideoIO_NoBlinking
|
---|
[8] | 132 |
|
---|
[43] | 133 | ; Get HardDriveCount
|
---|
| 134 | call DriveIO_GetHardDriveCount
|
---|
[30] | 135 |
|
---|
| 136 |
|
---|
[43] | 137 | ; Rousseau: added
|
---|
| 138 | call VideoIO_ClearScreen
|
---|
[30] | 139 |
|
---|
[43] | 140 | ; Cursor to upper-left
|
---|
[46] | 141 | mov byte ptr [TextPosX], 0
|
---|
| 142 | mov byte ptr [TextPosY], 0
|
---|
[43] | 143 | call VideoIO_CursorSet
|
---|
[30] | 144 |
|
---|
[43] | 145 | ;~ mov ax, VideoIO_Page1
|
---|
| 146 | ;~ call VideoIO_BackUpTo ; Copy BIOS POST to Second Page
|
---|
[30] | 147 |
|
---|
[43] | 148 | ; Copyright
|
---|
[117] | 149 | mov si, [offset Copyright]
|
---|
[165] | 150 | call VideoIO_Print
|
---|
| 151 | inc [TextPosY]
|
---|
| 152 | mov [TextPosX], 0
|
---|
| 153 | call MBR_TeletypeSyncPos
|
---|
[30] | 154 |
|
---|
[43] | 155 | ;call SOUND_Beep
|
---|
[30] | 156 |
|
---|
[46] | 157 | ; Show build info
|
---|
| 158 | call VideoIO_PrintBuildInfo
|
---|
[30] | 159 |
|
---|
[165] | 160 | ; Let user know we started scanning...
|
---|
| 161 | IFDEF AUX_DEBUG
|
---|
| 162 | xor si, si
|
---|
| 163 | call MBR_TeletypeNL
|
---|
| 164 | ENDIF
|
---|
| 165 | mov si, offset [scanning_txt]
|
---|
| 166 | call MBR_TeletypeBold
|
---|
| 167 |
|
---|
[142] | 168 | ; Show message if com-port debugging is active
|
---|
| 169 | IFDEF AUX_DEBUG
|
---|
| 170 | ; Don't show message if com-port debugging is not active
|
---|
| 171 | mov dx, [BIOS_AuxParms]
|
---|
| 172 | test dl, dl
|
---|
| 173 | jz @F
|
---|
[30] | 174 |
|
---|
[142] | 175 | ; Show initialization message
|
---|
[165] | 176 | mov ah, [TextPosY]
|
---|
| 177 | mov [TextPosY], 2
|
---|
[142] | 178 | mov si, offset AuxInitMsg
|
---|
[165] | 179 | ;~ call MBR_Teletype
|
---|
| 180 | call VideoIO_Print
|
---|
[142] | 181 |
|
---|
| 182 | ; Sync output position
|
---|
[165] | 183 | ;~ call VideoIO_SyncPos
|
---|
[142] | 184 |
|
---|
| 185 | ; Show port number
|
---|
| 186 | mov al, dl
|
---|
| 187 | call VideoIO_PrintByteDynamicNumber
|
---|
[165] | 188 | mov [TextPosY], ah
|
---|
[142] | 189 | @@:
|
---|
| 190 | ENDIF
|
---|
| 191 |
|
---|
[43] | 192 | ; Calculate Cooper-Bar Tables
|
---|
[51] | 193 | IFDEF FX_ENABLED
|
---|
[43] | 194 | call FX_CalculateTables
|
---|
[51] | 195 | ENDIF
|
---|
[30] | 196 |
|
---|
[43] | 197 | ; Calculate LVM-CRC-Table
|
---|
| 198 | call LVM_InitCRCTable
|
---|
[30] | 199 |
|
---|
[43] | 200 | ; Get HardDriveCount
|
---|
| 201 | call DriveIO_GetHardDriveCount
|
---|
[30] | 202 |
|
---|
[43] | 203 | ; Calculate CHS/LBA Switch Table
|
---|
| 204 | call DriveIO_InitLBASwitchTable
|
---|
[8] | 205 |
|
---|
[43] | 206 | ; Setup PartitionPointers-Table
|
---|
| 207 | call PART_CalculateStraightPartPointers
|
---|
[29] | 208 |
|
---|
[234] | 209 | ; Load charset or glyphs if needed
|
---|
| 210 | IFDEF TXT_LoadCharset
|
---|
| 211 | IF BLD_LANG_TXT EQ 'es'
|
---|
| 212 | call CHARSET_IncludeSpanish
|
---|
| 213 | ENDIF
|
---|
| 214 | IF BLD_LANG_TXT EQ 'ru'
|
---|
[43] | 215 | call CHARSET_IncludeCyrillic
|
---|
[234] | 216 | ENDIF
|
---|
| 217 | ENDIF
|
---|
[29] | 218 |
|
---|
| 219 |
|
---|
[55] | 220 | ; This sets [CurIO_UseExtension] flag.
|
---|
[95] | 221 | call DriveIO_CheckFor13extensions
|
---|
[55] | 222 | mov al,[CurIO_UseExtension]
|
---|
| 223 | test al,al
|
---|
| 224 | jnz INT13X_Supported
|
---|
[8] | 225 |
|
---|
[55] | 226 | ;
|
---|
| 227 | ; Show Message that BIOS INT13X is not supported
|
---|
| 228 | ; and Halt the System.
|
---|
| 229 | ;
|
---|
| 230 | mov cx, 0C04h
|
---|
| 231 | mov si, offset TXT_NoINT13XSupport
|
---|
| 232 | call SETUP_ShowErrorBox
|
---|
| 233 |
|
---|
| 234 | ; Halt the system.
|
---|
| 235 | jmp HaltSystem
|
---|
| 236 |
|
---|
| 237 |
|
---|
| 238 | ;
|
---|
| 239 | ; INT13X Supported so continue.
|
---|
| 240 | ;
|
---|
| 241 | INT13X_Supported:
|
---|
| 242 |
|
---|
[8] | 243 |
|
---|
[51] | 244 | ;
|
---|
[105] | 245 | ; Setup the size of the INT13X Disk Address Packet
|
---|
| 246 | ;
|
---|
| 247 | mov [INT13X_DAP], INT13X_DAP_Size
|
---|
| 248 |
|
---|
| 249 | ;
|
---|
[51] | 250 | ; Check valididy of the AiR-BOOT Configuration.
|
---|
| 251 | ;
|
---|
| 252 | call PRECRAP_CheckConfiguration
|
---|
[36] | 253 |
|
---|
| 254 |
|
---|
[43] | 255 | ; =======================================
|
---|
| 256 | ; Checks for MBR Virii :) I love that job
|
---|
| 257 | ; =======================================
|
---|
[46] | 258 | test byte ptr [CFG_DetectStealth], 1
|
---|
[43] | 259 | jz PCM_NoStealthDetection
|
---|
| 260 | call VIRUS_CheckForStealth
|
---|
| 261 | PCM_NoStealthDetection:
|
---|
[46] | 262 | test byte ptr [CFG_DetectVirus], 1
|
---|
[43] | 263 | jz PCM_NoVirusDetection
|
---|
| 264 | call VIRUS_CheckForVirus
|
---|
| 265 | PCM_NoVirusDetection:
|
---|
[36] | 266 |
|
---|
[30] | 267 |
|
---|
[43] | 268 | ; ============================================
|
---|
| 269 | ; Delay for some time and get Strg/Alt State
|
---|
| 270 | ; ============================================
|
---|
[223] | 271 |
|
---|
| 272 | ; While the FX-module is excluded from newer versions, we want to retain
|
---|
| 273 | ; the option of enabling it.
|
---|
| 274 | IFDEF FX_ENABLED
|
---|
[46] | 275 | test byte ptr [CFG_CooperBars], 1
|
---|
[43] | 276 | jnz PCM_ShortDelay
|
---|
[223] | 277 | ENDIF
|
---|
| 278 |
|
---|
[43] | 279 | mov al, 27 ; About 1.5 seconds
|
---|
[46] | 280 | test byte ptr [CFG_FloppyBootGetName], 1
|
---|
[43] | 281 | jz PCM_LongDelay
|
---|
| 282 | PCM_ShortDelay:
|
---|
[36] | 283 |
|
---|
[43] | 284 | mov al, 13 ; shorten delay,if floppy gets accessed
|
---|
| 285 | PCM_LongDelay:
|
---|
[30] | 286 |
|
---|
[43] | 287 | call TIMER_WaitTicCount
|
---|
[36] | 288 |
|
---|
[43] | 289 | ; First check, if any normal key got pressed...
|
---|
| 290 | mov ah, 1
|
---|
| 291 | int 16h
|
---|
| 292 | jz PCM_NoNormalKeyPressed
|
---|
| 293 | ; User doesn't know what to do...or he is crazy <g> so display message
|
---|
| 294 | mov si, offset TXT_HowEnterSetup
|
---|
| 295 | call MBR_Teletype
|
---|
| 296 | mov al, 54 ; about 3 seconds, delay again
|
---|
[30] | 297 |
|
---|
[43] | 298 | call TIMER_WaitTicCount
|
---|
[30] | 299 |
|
---|
[43] | 300 | PCM_NoNormalKeyPressed:
|
---|
| 301 | ; Now get keyboard Strg/Alt State
|
---|
| 302 | mov ah, 02h
|
---|
| 303 | int 16h
|
---|
[46] | 304 | mov [SETUP_KeysOnEntry], al
|
---|
[30] | 305 |
|
---|
[43] | 306 | ; Copy device-name to the ContBIOSbootSeq-IPT entry
|
---|
| 307 | ; We may not do this before PRECRAP_CheckConfiguration, because otherwise
|
---|
| 308 | ; this check will fail.
|
---|
| 309 | call PART_UpdateResumeBIOSName
|
---|
| 310 | ret
|
---|
| 311 | PRECRAP_Main EndP
|
---|
[30] | 312 |
|
---|
[51] | 313 |
|
---|
| 314 |
|
---|
| 315 |
|
---|
[43] | 316 | AFTERCRAP_Main Proc Near
|
---|
[111] | 317 |
|
---|
| 318 | IFDEF AUX_DEBUG
|
---|
| 319 | IF 0
|
---|
[123] | 320 | DBG_TEXT_OUT_AUX 'AFTERCRAP_Main:'
|
---|
| 321 | PUSHRF
|
---|
[111] | 322 | ;~ call DEBUG_DumpRegisters
|
---|
| 323 | ;~ call AuxIO_DumpParagraph
|
---|
| 324 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 325 | POPRF
|
---|
[111] | 326 | ENDIF
|
---|
| 327 | ENDIF
|
---|
| 328 |
|
---|
[43] | 329 | ; ===================================================
|
---|
| 330 | ; Now get volume label of FloppyDrive, if wanted...
|
---|
| 331 | ; ===================================================
|
---|
[46] | 332 | test byte ptr [CFG_FloppyBootGetName], 1
|
---|
[43] | 333 | jz ACM_NoFloppyGetName
|
---|
| 334 | call DriveIO_UpdateFloppyName
|
---|
| 335 | or ax, ax
|
---|
| 336 | jnz ACM_NoFloppyGetName
|
---|
| 337 | ; Try a second time, if it failed to detect the Floppy
|
---|
| 338 | call DriveIO_UpdateFloppyName
|
---|
| 339 | ACM_NoFloppyGetName:
|
---|
| 340 | ret
|
---|
| 341 | AFTERCRAP_Main EndP
|
---|
[30] | 342 |
|
---|
[51] | 343 |
|
---|
[8] | 344 | ; Checks Configuration CheckSum...Displays message, if failed.
|
---|
| 345 | PRECRAP_CheckConfiguration Proc Near Uses ds si es di
|
---|
[111] | 346 |
|
---|
| 347 | IFDEF AUX_DEBUG
|
---|
| 348 | IF 0
|
---|
[123] | 349 | DBG_TEXT_OUT_AUX 'PRECRAP_CheckConfiguration:'
|
---|
| 350 | PUSHRF
|
---|
[111] | 351 | ;~ call DEBUG_DumpRegisters
|
---|
| 352 | ;~ call AuxIO_DumpParagraph
|
---|
| 353 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 354 | POPRF
|
---|
[111] | 355 | ENDIF
|
---|
| 356 | ENDIF
|
---|
| 357 |
|
---|
[43] | 358 | mov si, offset Configuration
|
---|
| 359 | xor bx, bx
|
---|
[31] | 360 |
|
---|
[43] | 361 | ; Changed from 5 to calculated value (not here, see compat. issue below)
|
---|
| 362 | ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
|
---|
| 363 | ; Size of the ab-configuration in 512 byte sectors
|
---|
| 364 | ; mov cx, (MBR_BackUpMBR - Configuration) / 200h
|
---|
[31] | 365 |
|
---|
[43] | 366 | ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
|
---|
[54] | 367 | ; AB v1.0.8+ *should* stores a 7 sector configuration with a
|
---|
[43] | 368 | ; 7 sector checksum.
|
---|
[54] | 369 | ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8+
|
---|
[43] | 370 | ; config as corrupted, while this is not the case.
|
---|
[54] | 371 | ; So, for compatibility reasons, in v1.0.8+, the checksum stored is over
|
---|
[43] | 372 | ; 5 sectors, to be compatible with v1.07.
|
---|
| 373 | ; This may change (be corrected) in future versions !
|
---|
| 374 | mov cx,5
|
---|
[32] | 375 |
|
---|
[200] | 376 | mov dx, [CFG_CheckConfig] ; Get current CRC for configuration
|
---|
| 377 | mov [CFG_CheckConfig], bx ; Mark it as invalid
|
---|
[43] | 378 | PCCC_Loop:
|
---|
[200] | 379 | call MBR_GetCheckOfSector ; Calculate CRC
|
---|
[43] | 380 | loop PCCC_Loop
|
---|
[200] | 381 | cmp bx, dx ; Validate CRC
|
---|
| 382 |
|
---|
| 383 | ;
|
---|
| 384 | ; The CRC is calculated and inserted in the loader image when
|
---|
| 385 | ; AiR-BOOT is installed. Ignoring the CRC enables manually
|
---|
| 386 | ; merging the loader without using the installer. This is used
|
---|
| 387 | ; for debugging in virtual machines, where it is easy to
|
---|
| 388 | ; merge the loader to the disk image of the VM.
|
---|
| 389 | ;
|
---|
| 390 | IFNDEF CRC_IGNORE
|
---|
| 391 | jne PCCC_Failed ; Validation failed, halt AiR-BOOT
|
---|
| 392 | ENDIF
|
---|
| 393 |
|
---|
| 394 | mov CFG_CheckConfig, dx ; Restore the valid CRC
|
---|
[43] | 395 | ret
|
---|
[200] | 396 |
|
---|
| 397 | ;
|
---|
| 398 | ; CRC validation for the configuration failed.
|
---|
| 399 | ; Inform the user of this and halt the system.
|
---|
| 400 | ;
|
---|
[43] | 401 | PCCC_Failed:
|
---|
| 402 | mov si, offset TXT_ERROR_CheckConfig
|
---|
| 403 | call MBR_Teletype
|
---|
| 404 | mov si, offset TXT_ERROR_CheckFailed
|
---|
| 405 | call MBR_Teletype
|
---|
| 406 | jmp MBR_HaltSystem
|
---|
[8] | 407 | PRECRAP_CheckConfiguration EndP
|
---|
[30] | 408 |
|
---|
| 409 |
|
---|
| 410 | ; Rousseau: added
|
---|
| 411 | ; In: SI - Pointer to begin of string (EOS is 0)
|
---|
| 412 | ; Destroyed: SI
|
---|
| 413 | ; Fixme: Uses double writes to use attribute with teletype-function.
|
---|
[43] | 414 | MBR_TeletypeBold Proc Near Uses ax bx cx
|
---|
| 415 | MBRT_LoopBold:
|
---|
| 416 | lodsb
|
---|
| 417 | or al, al
|
---|
| 418 | jz MBRT_EndBold
|
---|
| 419 | push ax
|
---|
| 420 | mov ah,09h
|
---|
| 421 | mov bx,15
|
---|
| 422 | mov cx,1
|
---|
| 423 | int 10h
|
---|
| 424 | pop ax
|
---|
| 425 | mov ah,0eh
|
---|
| 426 | mov bx,7 ; Does not do anything in text-modus
|
---|
| 427 | mov cx,1
|
---|
| 428 | int 10h
|
---|
| 429 | jmp MBRT_LoopBold
|
---|
| 430 | MBRT_EndBold:
|
---|
| 431 | ret
|
---|
| 432 | MBR_TeletypeBold EndP
|
---|
[30] | 433 |
|
---|
[43] | 434 |
|
---|
[30] | 435 | ; In: SI - Pointer to begin of string (EOS is 0)
|
---|
| 436 | ; Destroyed: SI
|
---|
| 437 | ; Fixme: Uses double writes to use attribute with teletype-function.
|
---|
[43] | 438 | MBR_TeletypeVolName Proc Near Uses ax bx cx
|
---|
| 439 | mov cx, 11
|
---|
| 440 | MBRT_LoopVolName:
|
---|
| 441 | mov dx,cx ; Backup counter
|
---|
| 442 | lodsb
|
---|
| 443 | or al, al
|
---|
| 444 | jz MBRT_EndVolName
|
---|
| 445 | push ax
|
---|
| 446 | mov ah,09h
|
---|
| 447 | mov bx,15
|
---|
| 448 | mov cx,1
|
---|
| 449 | int 10h ; DX is preserved
|
---|
| 450 | pop ax
|
---|
| 451 | mov ah,0eh
|
---|
| 452 | mov bx,7 ; Does not do anything in text-modus
|
---|
| 453 | mov cx,1
|
---|
| 454 | int 10h ; DX is preserved
|
---|
| 455 | mov cx,dx ; Restore counter
|
---|
| 456 | loop MBRT_LoopVolName
|
---|
| 457 | MBRT_EndVolName:
|
---|
| 458 | ret
|
---|
| 459 | MBR_TeletypeVolName EndP
|
---|
[30] | 460 |
|
---|
| 461 | ; Rousseau: added
|
---|
| 462 | ; Move cursor to next line
|
---|
| 463 | ; Just do a new-line if SI==0
|
---|
[43] | 464 | MBR_TeletypeNL Proc Near Uses ax bx cx
|
---|
| 465 | test si,si
|
---|
| 466 | jz MBR_TeletypeNL_NL
|
---|
| 467 | call MBR_Teletype
|
---|
| 468 | MBR_TeletypeNL_NL:
|
---|
| 469 | push si
|
---|
| 470 | mov si, offset NL
|
---|
| 471 | call MBR_Teletype
|
---|
| 472 | pop si
|
---|
| 473 | ret
|
---|
| 474 | MBR_TeletypeNL EndP
|
---|
[30] | 475 |
|
---|
| 476 | ; Sync teletype position to VideoIO
|
---|
| 477 | MBR_TeletypeSyncPos Proc Near Uses ax bx cx dx
|
---|
[43] | 478 | pushf
|
---|
| 479 | mov bh, 0
|
---|
| 480 | mov ah, 02h
|
---|
[46] | 481 | mov dh,byte ptr [TextPosY]
|
---|
| 482 | mov dl,byte ptr [TextPosX]
|
---|
[43] | 483 | int 10h
|
---|
| 484 | popf
|
---|
| 485 | ret
|
---|
[30] | 486 | MBR_TeletypeSyncPos EndP
|
---|
[101] | 487 |
|
---|
[121] | 488 | ;------------------------------------------------------------------------------
|
---|
[101] | 489 | ; Check if a memory block is all zeros
|
---|
[121] | 490 | ;------------------------------------------------------------------------------
|
---|
| 491 | ; IN : BX pointer to memblock
|
---|
| 492 | ; : CX length to check, zero length is interpreted as block is zero
|
---|
| 493 | ; OUT : ZF=1 block if all zeros
|
---|
| 494 | ; NOTE : Segment used is DS, which should be the same as ES
|
---|
| 495 | ;------------------------------------------------------------------------------
|
---|
| 496 | IsMemBlockZero Proc Near Uses ax di es
|
---|
[101] | 497 | push ds ; Segment to use
|
---|
| 498 | pop es ; Pop in ES because ES is required for scasb
|
---|
| 499 | mov di, bx ; Pointer to memblock
|
---|
| 500 | xor al, al ; Compare to zero
|
---|
[121] | 501 | cld ; Direction upwards
|
---|
[101] | 502 | repe scasb ; Scan the block, will leave ZF=1 if all zeros
|
---|
| 503 | ret
|
---|
| 504 | IsMemBlockZero EndP
|
---|
| 505 |
|
---|
[121] | 506 | ;------------------------------------------------------------------------------
|
---|
[101] | 507 | ; Check if a loaded sector is all zeros
|
---|
[121] | 508 | ;------------------------------------------------------------------------------
|
---|
[124] | 509 | ; IN : SI pointer to sector buffer
|
---|
[121] | 510 | ; OUT : ZF=1 block if all zeros
|
---|
| 511 | ; NOTE : Segment used is DS
|
---|
| 512 | ;------------------------------------------------------------------------------
|
---|
[124] | 513 | IsSectorBufferZero Proc Near Uses bx cx
|
---|
| 514 | mov bx, si ; Address of sector buffer
|
---|
[101] | 515 | mov cx, sector_size ; Normal size of a sector (512 bytes)
|
---|
| 516 | call IsMemBlockZero ; Check the memory block
|
---|
| 517 | ret
|
---|
[124] | 518 | IsSectorBufferZero EndP
|
---|
[121] | 519 |
|
---|
| 520 | ;------------------------------------------------------------------------------
|
---|
| 521 | ; Fill a memory block with a specific value
|
---|
| 522 | ;------------------------------------------------------------------------------
|
---|
| 523 | ; IN : AL value to fill block with
|
---|
| 524 | ; : BX pointer to memblock
|
---|
| 525 | ; : CX length to fill, 0 fills nothing
|
---|
| 526 | ; OUT : ZF=1 if fill value was 0
|
---|
| 527 | ; NOTE : Segment used is DS
|
---|
| 528 | ;------------------------------------------------------------------------------
|
---|
| 529 | FillMemBlock Proc Near Uses cx di es
|
---|
| 530 | push ds ; Segment to use
|
---|
| 531 | pop es ; Pop in ES because ES is required for scasb
|
---|
| 532 | mov di, bx ; Pointer to memblock
|
---|
| 533 | cld ; Direction upwards
|
---|
| 534 | rep stosb ; Fill the memory block with value in AL
|
---|
| 535 | test al, al ; Set ZR if fill value used is 0
|
---|
| 536 | ret
|
---|
| 537 | FillMemBlock EndP
|
---|
| 538 |
|
---|
| 539 | ;------------------------------------------------------------------------------
|
---|
| 540 | ; Fill a memory block with zeros
|
---|
| 541 | ;------------------------------------------------------------------------------
|
---|
| 542 | ; IN : BX pointer to memblock
|
---|
| 543 | ; : CX length to fill, 0 fills nothing
|
---|
| 544 | ; OUT : Nothing
|
---|
| 545 | ; NOTE : Segment used is DS
|
---|
| 546 | ;------------------------------------------------------------------------------
|
---|
| 547 | ClearMemBlock Proc Near Uses ax
|
---|
| 548 | xor al, al ; Fill value
|
---|
| 549 | call FillMemBlock ; Fill the memory block
|
---|
| 550 | ret
|
---|
| 551 | ClearMemBlock EndP
|
---|
| 552 |
|
---|
| 553 | ;------------------------------------------------------------------------------
|
---|
| 554 | ; Clears a sector buffer
|
---|
| 555 | ;------------------------------------------------------------------------------
|
---|
[124] | 556 | ; IN : SI pointer to sector buffer
|
---|
[121] | 557 | ; OUT : Nothing
|
---|
| 558 | ; NOTE : Segment used is DS
|
---|
| 559 | ;------------------------------------------------------------------------------
|
---|
[124] | 560 | ClearSectorBuffer Proc Near Uses bx cx
|
---|
| 561 | mov bx, si ; Address of sector buffer
|
---|
[121] | 562 | mov cx, sector_size ; Normal size of a sector (512 bytes)
|
---|
| 563 | call ClearMemBlock ; Clear the sector buffer
|
---|
| 564 | ret
|
---|
| 565 | ClearSectorBuffer EndP
|
---|
| 566 |
|
---|