Changeset 42 in xtideuniversalbios for trunk/Assembly_Library/Src/Display
- Timestamp:
- Sep 18, 2010, 6:04:31 PM (14 years ago)
- google:author:
- aitotat
- Location:
- trunk/Assembly_Library/Src/Display
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Src/Display/DisplayCharOut.asm
r41 r42 2 2 ; Project name : Assembly Library 3 3 ; Created date : 26.6.2010 4 ; Last update : 1 3.8.20104 ; Last update : 18.9.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Functions for outputting characters to video memory. … … 13 13 14 14 ;-------------------------------------------------------------------- 15 ; WAIT_RETRACE_IF_NECESSARY_THEN 16 ; Parameters: 17 ; AL: Character to output 18 ; AH: Attribute to output (stosw only) 19 ; DS: BDA segment (zero) 20 ; ES:DI: Ptr to video memory where to output 21 ; Returns: 22 ; DI: Incremented for next character 23 ; Corrupts registers: 24 ; AX, DX 25 ;-------------------------------------------------------------------- 26 %macro WAIT_RETRACE_IF_NECESSARY_THEN 1 27 %ifdef ELIMINATE_CGA_SNOW 28 %ifidn %1, stosb 29 call StosbWithoutCgaSnow 30 %else 31 call StoswWithoutCgaSnow 32 %endif 33 %else 34 %1 ; STOSB or STOSW 35 %endif 36 %endmacro 37 38 39 ;-------------------------------------------------------------------- 15 40 ; DisplayCharOut_TeletypeOutputWithAttribute 16 41 ; DisplayCharOut_TeletypeOutput … … 29 54 cmp al, ' ' ; Printable character? 30 55 jb SHORT DisplayCharOut_BiosTeletypeOutput 31 stosw56 WAIT_RETRACE_IF_NECESSARY_THEN stosw 32 57 ret 33 58 … … 85 110 ; AL: Character to output 86 111 ; AH: Attribute to output 87 ; ES:DI: Ptr to video memory where to output 88 ; Returns: 89 ; DI: Incremented for next character 90 ; Corrupts registers: 91 ; AX 112 ; DS: BDA segment (zero) 113 ; ES:DI: Ptr to video memory where to output 114 ; Returns: 115 ; DI: Incremented for next character 116 ; Corrupts registers: 117 ; AX, DX 92 118 ;-------------------------------------------------------------------- 93 119 ALIGN JUMP_ALIGN … … 95 121 xchg al, ah ; Swap character and attribute 96 122 inc di ; Skip character 97 stosb123 WAIT_RETRACE_IF_NECESSARY_THEN stosb 98 124 ret 99 125 100 126 ALIGN JUMP_ALIGN 101 127 DisplayCharOut_Character: 102 stosb128 WAIT_RETRACE_IF_NECESSARY_THEN stosb 103 129 inc di ; Skip attribute 104 130 ret … … 106 132 ALIGN JUMP_ALIGN 107 133 DisplayCharOut_CharacterWithAttribute: 108 stosw134 WAIT_RETRACE_IF_NECESSARY_THEN stosw 109 135 ret 110 136 … … 129 155 .BufferFull: 130 156 ret 157 158 159 ; STOSB and STOSW replacement functions to prevent CGA snow. These will slow 160 ; drawing a lot so use them only if it is necessary to eliminate CGA snow. 161 %ifdef ELIMINATE_CGA_SNOW 162 163 OFFSET_TO_CGA_STATUS_REGISTER EQU 6 ; Base port 3D4h + 6 = 3DAh 164 CGA_STATUS_REGISTER EQU 3DAh 165 166 ;-------------------------------------------------------------------- 167 ; WAIT_UNTIL_SAFE_CGA_WRITE 168 ; Parameters: 169 ; DX: CGA Status Register Address (3DAh) 170 ; Returns: 171 ; Interrupts disabled 172 ; Corrupts registers: 173 ; AL 174 ;-------------------------------------------------------------------- 175 %macro WAIT_UNTIL_SAFE_CGA_WRITE 0 176 cli ; Interrupt request would mess up timing 177 %%WaitUntilNotInRetrace: 178 in al, dx 179 shr al, 1 ; 1 = Bit 0: A 1 indicates that regen-buffer memory access can be 180 ; made without interfering with the display. (H or V retrace) 181 jc SHORT %%WaitUntilNotInRetrace 182 sti 183 nop ; Should have time to serve IRQ here 184 cli 185 %%WaitUntilNextRetraceStarts: 186 in al, dx 187 shr al, 1 188 jnc SHORT %%WaitUntilNextRetraceStarts 189 %endmacro 190 191 ;-------------------------------------------------------------------- 192 ; StosbWithoutCgaSnow 193 ; StoswWithoutCgaSnow 194 ; Parameters: 195 ; AL: Character to output 196 ; AH: Attribute to output (StoswWithoutCgaSnow only) 197 ; DS: BDA segment (zero) 198 ; ES:DI: Ptr to video memory where to output 199 ; Returns: 200 ; DI: Incremented for next character 201 ; Corrupts registers: 202 ; AX, DX 203 ;-------------------------------------------------------------------- 204 ALIGN JUMP_ALIGN 205 StosbWithoutCgaSnow: 206 call LoadAndVerifyStatusRegisterFromBDA 207 jne SHORT .StosbWithoutWaitSinceUnknownPort 208 209 mov ah, al 210 WAIT_UNTIL_SAFE_CGA_WRITE 211 mov al, ah 212 stosb 213 sti 214 ret 215 ALIGN JUMP_ALIGN 216 .StosbWithoutWaitSinceUnknownPort: 217 stosb 218 ret 219 220 ALIGN JUMP_ALIGN 221 StoswWithoutCgaSnow: 222 call LoadAndVerifyStatusRegisterFromBDA 223 jne SHORT .StoswWithoutWaitSinceUnknownPort 224 225 push bx 226 xchg bx, ax 227 WAIT_UNTIL_SAFE_CGA_WRITE 228 xchg ax, bx 229 stosw 230 pop bx 231 sti 232 ret 233 ALIGN JUMP_ALIGN 234 .StoswWithoutWaitSinceUnknownPort: 235 stosw 236 ret 237 238 ;-------------------------------------------------------------------- 239 ; LoadAndVerifyStatusRegisterFromBDA 240 ; Parameters: 241 ; DS: BDA segment (zero) 242 ; Returns: 243 ; DX: CGA Status Register Address 244 ; ZF: Set if CGA Base Port found in BDA 245 ; Corrupts registers: 246 ; Nothing 247 ;-------------------------------------------------------------------- 248 ALIGN JUMP_ALIGN 249 LoadAndVerifyStatusRegisterFromBDA: 250 mov dx, [BDA.wVidPort] 251 add dl, OFFSET_TO_CGA_STATUS_REGISTER 252 cmp dx, CGA_STATUS_REGISTER 253 ret 254 255 %endif ; ELIMINATE_CGA_SNOW -
trunk/Assembly_Library/Src/Display/DisplayPrint.asm
r41 r42 2 2 ; Project name : Assembly Library 3 3 ; Created date : 26.6.2010 4 ; Last update : 1 0.8.20104 ; Last update : 18.9.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Functions for display output. … … 250 250 251 251 ;-------------------------------------------------------------------- 252 ; DisplayPrint_RepeatCharacterFromALwithCountInCX253 ; Parameters:254 ; AL: Character to display255 ; CX: Repeat count256 ; DS: BDA segment (zero)257 ; ES:DI: Ptr to cursor location in video RAM258 ; Returns:259 ; DI: Updated offset to video RAM260 ; Corrupts registers:261 ; AX, DX262 ;--------------------------------------------------------------------263 ALIGN JUMP_ALIGN264 DisplayPrint_RepeatCharacterFromALwithCountInCX:265 push ax266 call DisplayPrint_CharacterFromAL267 pop ax268 loop DisplayPrint_RepeatCharacterFromALwithCountInCX269 ret270 271 272 ;--------------------------------------------------------------------273 ; DisplayPrint_CharacterFromAL274 ; Parameters:275 ; AL: Character to display276 ; DS: BDA segment (zero)277 ; ES:DI: Ptr to cursor location in video RAM278 ; Returns:279 ; DI: Updated offset to video RAM280 ; Corrupts registers:281 ; AX, DX282 ;--------------------------------------------------------------------283 ALIGN JUMP_ALIGN284 DisplayPrint_CharacterFromAL:285 mov ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]286 jmp [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut]287 288 289 ;--------------------------------------------------------------------290 252 ; DisplayPrint_ClearScreen 291 253 ; Parameters: … … 317 279 ; ES:DI: Ptr to cursor location in video RAM 318 280 ; Returns: 319 ; Nothing281 ; DI: Updated offset to video RAM 320 282 ; Corrupts registers: 321 283 ; AX, DX … … 323 285 ALIGN JUMP_ALIGN 324 286 DisplayPrint_ClearAreaWithHeightInAHandWidthInAL: 287 push si 325 288 push cx 326 289 push bx 327 push di 328 329 xchg bx, ax ; Move parameters to BX 290 291 xchg bx, ax ; Area size to BX 330 292 call DisplayCursor_GetSoftwareCoordinatesToAX 331 xchg dx, ax ; Coordinates now in DX 332 xor cx, cx ; Zero CX 333 334 ALIGN JUMP_ALIGN 335 .ClearRowFromArea: 293 xchg si, ax ; Software (Y,X) coordinates now in SI 294 xor cx, cx 295 296 ALIGN JUMP_ALIGN 297 .ClearRowLoop: 298 mov cl, bl ; Area width now in CX 336 299 mov al, ' ' ; Clear with space 337 mov ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute] 338 mov cl, bl ; Area width = WORDs to clear 339 rep stosw 340 dec bh 341 jz SHORT .AreaCleared 342 343 inc dh ; Increment row 344 push dx 345 xchg ax, dx 300 call DisplayPrint_RepeatCharacterFromALwithCountInCX 301 302 xchg ax, si ; Coordinates to AX 303 inc ah ; Increment row 304 mov si, ax 346 305 call DisplayCursor_SetCoordinatesFromAX 347 pop dx 348 jmp SHORT .ClearRowFromArea 349 350 ALIGN JUMP_ALIGN 351 .AreaCleared: 352 pop di 353 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], di 306 dec bh ; Decrement rows left 307 jnz SHORT .ClearRowLoop 308 354 309 pop bx 355 310 pop cx 356 ret 311 pop si 312 ret 313 314 315 ;-------------------------------------------------------------------- 316 ; DisplayPrint_RepeatCharacterFromALwithCountInCX 317 ; Parameters: 318 ; AL: Character to display 319 ; CX: Repeat count 320 ; DS: BDA segment (zero) 321 ; ES:DI: Ptr to cursor location in video RAM 322 ; Returns: 323 ; DI: Updated offset to video RAM 324 ; Corrupts registers: 325 ; AX, DX 326 ;-------------------------------------------------------------------- 327 ALIGN JUMP_ALIGN 328 DisplayPrint_RepeatCharacterFromALwithCountInCX: 329 push ax 330 call DisplayPrint_CharacterFromAL 331 pop ax 332 loop DisplayPrint_RepeatCharacterFromALwithCountInCX 333 ret 334 335 336 ;-------------------------------------------------------------------- 337 ; DisplayPrint_CharacterFromAL 338 ; Parameters: 339 ; AL: Character to display 340 ; DS: BDA segment (zero) 341 ; ES:DI: Ptr to cursor location in video RAM 342 ; Returns: 343 ; DI: Updated offset to video RAM 344 ; Corrupts registers: 345 ; AX, DX 346 ;-------------------------------------------------------------------- 347 ALIGN JUMP_ALIGN 348 DisplayPrint_CharacterFromAL: 349 mov ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute] 350 jmp [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut]
Note:
See TracChangeset
for help on using the changeset viewer.