[48] | 1 | ; Project name : Assembly Library
|
---|
| 2 | ; Description : Functions for preventing CGA snow.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
[491] | 5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
[526] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
[376] | 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.
|
---|
[491] | 12 | ;
|
---|
[376] | 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
|
---|
[491] | 16 | ; GNU General Public License for more details.
|
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
[491] | 18 | ;
|
---|
[376] | 19 |
|
---|
[48] | 20 | ; Section containing code
|
---|
| 21 | SECTION .text
|
---|
| 22 |
|
---|
[50] | 23 | ;--------------------------------------------------------------------
|
---|
| 24 | ; CgaSnow_IsCgaPresent
|
---|
| 25 | ; Parameters:
|
---|
| 26 | ; DS: BDA segment (zero)
|
---|
| 27 | ; Returns:
|
---|
| 28 | ; CF: Set if CGA detected
|
---|
| 29 | ; Cleared if CGA not detected
|
---|
| 30 | ; Corrupts registers:
|
---|
| 31 | ; AX
|
---|
| 32 | ;--------------------------------------------------------------------
|
---|
[369] | 33 | ALIGN DISPLAY_JUMP_ALIGN
|
---|
[50] | 34 | CgaSnow_IsCgaPresent:
|
---|
| 35 | cmp WORD [BDA.wVidPort], CGA_STATUS_REGISTER - OFFSET_TO_CGA_STATUS_REGISTER
|
---|
| 36 | jne SHORT .CgaNotFound
|
---|
[52] | 37 |
|
---|
| 38 | ; All standard CGA modes use 25 rows but only EGA and later store it to BDA.
|
---|
| 39 | cmp BYTE [BDA.bVidRows], 25
|
---|
| 40 | jge SHORT .CgaNotFound
|
---|
[50] | 41 | stc
|
---|
| 42 | ret
|
---|
[369] | 43 | ALIGN DISPLAY_JUMP_ALIGN
|
---|
[50] | 44 | .CgaNotFound:
|
---|
| 45 | clc
|
---|
| 46 | ret
|
---|
[48] | 47 |
|
---|
[50] | 48 |
|
---|
[162] | 49 | ; CGA snow prevention must be kept optional to avoid unnecessary
|
---|
| 50 | ; overhead when building programs meant for non-CGA systems.
|
---|
[48] | 51 | %ifdef ELIMINATE_CGA_SNOW
|
---|
| 52 |
|
---|
| 53 | ;--------------------------------------------------------------------
|
---|
[49] | 54 | ; CgaSnow_Stosb
|
---|
| 55 | ; CgaSnow_Stosw
|
---|
[48] | 56 | ; Parameters:
|
---|
| 57 | ; AL: Character to output
|
---|
| 58 | ; AH: Attribute to output (CgaSnow_StoswWithoutCgaSnow only)
|
---|
| 59 | ; DS: BDA segment (zero)
|
---|
| 60 | ; ES:DI: Ptr to video memory where to output
|
---|
| 61 | ; Returns:
|
---|
| 62 | ; DI: Incremented for next character
|
---|
| 63 | ; Corrupts registers:
|
---|
| 64 | ; AX, DX
|
---|
| 65 | ;--------------------------------------------------------------------
|
---|
[369] | 66 | ALIGN DISPLAY_JUMP_ALIGN
|
---|
[49] | 67 | CgaSnow_Stosb:
|
---|
[50] | 68 | call LoadCgaStatusRegisterAddressToDXifCgaPresent
|
---|
| 69 | jz SHORT .StosbWithoutWaitSinceUnknownPort
|
---|
[48] | 70 |
|
---|
| 71 | mov ah, al
|
---|
| 72 | cli ; Interrupt request would mess up timing
|
---|
| 73 | WAIT_UNTIL_SAFE_CGA_WRITE
|
---|
| 74 | mov al, ah
|
---|
| 75 | .StosbWithoutWaitSinceUnknownPort:
|
---|
| 76 | stosb
|
---|
| 77 | sti
|
---|
| 78 | ret
|
---|
| 79 |
|
---|
[369] | 80 | ALIGN DISPLAY_JUMP_ALIGN
|
---|
[49] | 81 | CgaSnow_Stosw:
|
---|
[48] | 82 | push bx
|
---|
[50] | 83 | call LoadCgaStatusRegisterAddressToDXifCgaPresent
|
---|
| 84 | jz SHORT .StoswWithoutWaitSinceUnknownPort
|
---|
[48] | 85 |
|
---|
| 86 | xchg bx, ax
|
---|
| 87 | cli ; Interrupt request would mess up timing
|
---|
| 88 | WAIT_UNTIL_SAFE_CGA_WRITE
|
---|
| 89 | xchg ax, bx
|
---|
| 90 | .StoswWithoutWaitSinceUnknownPort:
|
---|
| 91 | stosw
|
---|
[162] | 92 | sti
|
---|
[48] | 93 | pop bx
|
---|
| 94 | ret
|
---|
| 95 |
|
---|
[491] | 96 |
|
---|
[48] | 97 | ;--------------------------------------------------------------------
|
---|
[49] | 98 | ; CgaSnow_RepMovsb
|
---|
[48] | 99 | ; Parameters:
|
---|
| 100 | ; CX: Number of characters to copy
|
---|
| 101 | ; DS: BDA segment (zero)
|
---|
| 102 | ; ES:SI: Ptr to video memory where to read from
|
---|
| 103 | ; ES:DI: Ptr to video memory where to write to
|
---|
| 104 | ; Returns:
|
---|
| 105 | ; SI, DI: Updated for next character
|
---|
| 106 | ; Corrupts registers:
|
---|
| 107 | ; AX, CX, DX
|
---|
| 108 | ;--------------------------------------------------------------------
|
---|
[491] | 109 | %ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
|
---|
| 110 | %ifdef MODULE_STRINGS_COMPRESSED
|
---|
| 111 | %define EXCLUDE
|
---|
| 112 | %endif
|
---|
| 113 | %ifdef MODULE_BOOT_MENU
|
---|
| 114 | %undef EXCLUDE
|
---|
| 115 | %endif
|
---|
| 116 | %endif
|
---|
| 117 |
|
---|
| 118 | %ifndef EXCLUDE
|
---|
[369] | 119 | ALIGN DISPLAY_JUMP_ALIGN
|
---|
[49] | 120 | CgaSnow_RepMovsb:
|
---|
[50] | 121 | call LoadCgaStatusRegisterAddressToDXifCgaPresent
|
---|
| 122 | jz SHORT .RepMovsbWithoutWaitSinceUnknownPort
|
---|
[48] | 123 |
|
---|
| 124 | .MovsbNextByte:
|
---|
| 125 | cli ; Interrupt request would mess up timing
|
---|
| 126 | WAIT_UNTIL_SAFE_CGA_WRITE
|
---|
[223] | 127 | es movsb
|
---|
[48] | 128 | sti
|
---|
| 129 | loop .MovsbNextByte
|
---|
| 130 | ret
|
---|
| 131 | .RepMovsbWithoutWaitSinceUnknownPort:
|
---|
| 132 | eSEG_STR rep, es, movsb
|
---|
| 133 | ret
|
---|
[489] | 134 | %endif
|
---|
[491] | 135 | %undef EXCLUDE
|
---|
[48] | 136 |
|
---|
[491] | 137 |
|
---|
[48] | 138 | ;--------------------------------------------------------------------
|
---|
[50] | 139 | ; LoadCgaStatusRegisterAddressToDXifCgaPresent
|
---|
[48] | 140 | ; Parameters:
|
---|
| 141 | ; DS: BDA segment (zero)
|
---|
| 142 | ; Returns:
|
---|
| 143 | ; DX: CGA Status Register Address
|
---|
[50] | 144 | ; ZF: Set if CGA not present
|
---|
| 145 | ; Cleared if CGA present
|
---|
[48] | 146 | ; Corrupts registers:
|
---|
| 147 | ; Nothing
|
---|
| 148 | ;--------------------------------------------------------------------
|
---|
[369] | 149 | ALIGN DISPLAY_JUMP_ALIGN
|
---|
[50] | 150 | LoadCgaStatusRegisterAddressToDXifCgaPresent:
|
---|
| 151 | test BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_CGA
|
---|
| 152 | jz SHORT .NoCgaDetected
|
---|
| 153 | mov dx, CGA_STATUS_REGISTER
|
---|
[369] | 154 | ALIGN DISPLAY_JUMP_ALIGN, ret
|
---|
[50] | 155 | .NoCgaDetected:
|
---|
[48] | 156 | ret
|
---|
| 157 |
|
---|
| 158 |
|
---|
| 159 | %endif ; ELIMINATE_CGA_SNOW
|
---|