[48] | 1 | ; Project name : Assembly Library
|
---|
| 2 | ; Description : Functions for preventing CGA snow.
|
---|
| 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 |
|
---|
[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 |
|
---|
| 96 |
|
---|
| 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 | ;--------------------------------------------------------------------
|
---|
[369] | 109 | ALIGN DISPLAY_JUMP_ALIGN
|
---|
[49] | 110 | CgaSnow_RepMovsb:
|
---|
[50] | 111 | call LoadCgaStatusRegisterAddressToDXifCgaPresent
|
---|
| 112 | jz SHORT .RepMovsbWithoutWaitSinceUnknownPort
|
---|
[48] | 113 |
|
---|
| 114 | .MovsbNextByte:
|
---|
| 115 | cli ; Interrupt request would mess up timing
|
---|
| 116 | WAIT_UNTIL_SAFE_CGA_WRITE
|
---|
[223] | 117 | es movsb
|
---|
[48] | 118 | sti
|
---|
| 119 | loop .MovsbNextByte
|
---|
| 120 | ret
|
---|
| 121 | .RepMovsbWithoutWaitSinceUnknownPort:
|
---|
| 122 | eSEG_STR rep, es, movsb
|
---|
| 123 | ret
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | ;--------------------------------------------------------------------
|
---|
[50] | 127 | ; LoadCgaStatusRegisterAddressToDXifCgaPresent
|
---|
[48] | 128 | ; Parameters:
|
---|
| 129 | ; DS: BDA segment (zero)
|
---|
| 130 | ; Returns:
|
---|
| 131 | ; DX: CGA Status Register Address
|
---|
[50] | 132 | ; ZF: Set if CGA not present
|
---|
| 133 | ; Cleared if CGA present
|
---|
[48] | 134 | ; Corrupts registers:
|
---|
| 135 | ; Nothing
|
---|
| 136 | ;--------------------------------------------------------------------
|
---|
[369] | 137 | ALIGN DISPLAY_JUMP_ALIGN
|
---|
[50] | 138 | LoadCgaStatusRegisterAddressToDXifCgaPresent:
|
---|
| 139 | test BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_CGA
|
---|
| 140 | jz SHORT .NoCgaDetected
|
---|
| 141 | mov dx, CGA_STATUS_REGISTER
|
---|
[369] | 142 | ALIGN DISPLAY_JUMP_ALIGN, ret
|
---|
[50] | 143 | .NoCgaDetected:
|
---|
[48] | 144 | ret
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | %endif ; ELIMINATE_CGA_SNOW
|
---|