source: xtideuniversalbios/trunk/Assembly_Library/Src/Display/DisplayContext.asm@ 591

Last change on this file since 591 was 588, checked in by krille_n_@…, 9 years ago

Changes:

  • Fixed a bug in AH24h_HSetBlocks.asm from r550. Trying to set a too large block size with an XT-CF card in DMA transfer mode would corrupt the stack.
  • Fixed a bug from r545 where the list of devices under g_szDeviceTypeValues in Strings.asm was no longer up to date causing the boot menu to display the wrong string for devices numbered higher than DEVICE_8BIT_XTCF_PIO8.
  • Made some fairly significant changes to the XT-CF code to reduce size. Two changes in functionality; 1) Added a simple check to validate the request for a change of the XT-CF transfer mode. 2) Changing transfer mode to use DMA no longer calls AH24h_SetBlockSize if the block size already is within the limits of DMA transfers. UNTESTED
  • XTIDECFG now clears IDEVARS.bIRQ when changing IDE controller to a serial device to keep the boot menu from displaying it since the serial device doesn't use IRQs at all.
  • Other minor optimizations.
File size: 10.9 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for managing display context.
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
[41]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; DisplayContext_Initialize
25; Parameters:
26; DS: BDA segment (zero)
27; Returns:
28; Nothing
29; Corrupts registers:
30; AX, DX, DI
31;--------------------------------------------------------------------
[369]32ALIGN DISPLAY_JUMP_ALIGN
[41]33DisplayContext_Initialize:
34 mov WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], DEFAULT_CHARACTER_OUTPUT
[44]35 mov BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], SCREEN_BACKGROUND_ATTRIBUTE
[407]36 call DisplayCursor_GetDefaultCursorShapeToAX
[287]37 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape], ax
[101]38 ; Fall to .DetectAndSetDisplaySegment
[41]39
40;--------------------------------------------------------------------
41; .DetectAndSetDisplaySegment
42; Parameters:
43; DS: BDA segment (zero)
44; Returns:
45; Nothing
46; Corrupts registers:
[50]47; AX, DX
[41]48;--------------------------------------------------------------------
49.DetectAndSetDisplaySegment:
[50]50 mov ax, COLOR_TEXT_SEGMENT
[41]51 cmp BYTE [VIDEO_BDA.bMode], MDA_TEXT_MODE
[101]52 eCMOVE ah, MONO_TEXT_SEGMENT >> 8
[50]53 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2], ax
[101]54 ; Fall to .InitializeFlags
[50]55
56;--------------------------------------------------------------------
57; .InitializeFlags
58; Parameters:
59; DS: BDA segment (zero)
60; Returns:
61; Nothing
62; Corrupts registers:
63; AX, DX
64;--------------------------------------------------------------------
65.InitializeFlags:
66 mov dl, FLG_CONTEXT_ATTRIBUTES
67 call CgaSnow_IsCgaPresent
[588]68 eCMOVC dl, FLG_CONTEXT_ATTRIBUTES | FLG_CONTEXT_CGA
[50]69 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], dl
[101]70 ; Fall to .InitializeCursor
[41]71
[101]72;--------------------------------------------------------------------
73; .InitializeCursor
74; Parameters:
75; DS: BDA segment (zero)
76; Returns:
77; Nothing
78; Corrupts registers:
79; AX, DX
80;--------------------------------------------------------------------
81.InitializeCursor:
[115]82 call DisplayCursor_GetHardwareCoordinatesToAX ; Coordinates before init
83 call DisplayCursor_SetCoordinatesFromAX ; Cursor to Display Context
[101]84 ; Fall to DisplayContext_SynchronizeToHardware
[41]85
86;--------------------------------------------------------------------
[101]87; DisplayContext_SynchronizeToHardware
88; Parameters:
89; DS: BDA segment (zero)
90; Returns:
91; Nothing
92; Corrupts registers:
93; AX, DX
94;--------------------------------------------------------------------
[369]95ALIGN DISPLAY_JUMP_ALIGN
[101]96DisplayContext_SynchronizeToHardware:
97 call DisplayPage_SynchronizeToHardware
98 call DisplayCursor_SynchronizeShapeToHardware
99 jmp DisplayCursor_SynchronizeCoordinatesToHardware
100
101
102;--------------------------------------------------------------------
[41]103; DisplayContext_Push
[491]104; DisplayContext_Pop
[41]105; Parameters:
106; Nothing
107; Returns:
108; Nothing
109; Corrupts registers:
110; AX, DI
111;--------------------------------------------------------------------
[491]112%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
113 %ifndef MODULE_BOOT_MENU
114 %define EXCLUDE
115 %endif
116%endif
117
118%ifndef EXCLUDE
[369]119ALIGN DISPLAY_JUMP_ALIGN
[41]120DisplayContext_Push:
121 mov di, ds ; Backup DS
122 LOAD_BDA_SEGMENT_TO ds, ax
123 pop ax ; Pop return address
124
[194]125%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
[41]126 %assign i 0
[531]127 %ifdef USE_386
128 %rep DISPLAY_CONTEXT_size / 4
129 push DWORD [VIDEO_BDA.displayContext + i]
130 %assign i i+4
131 %endrep
132 %else
133 %rep DISPLAY_CONTEXT_size / 2
134 push WORD [VIDEO_BDA.displayContext + i]
135 %assign i i+2
136 %endrep
137 %endif
[194]138%endif
[491]139
[41]140 mov ds, di ; Restore DS
141 jmp ax
142
[491]143
[369]144ALIGN DISPLAY_JUMP_ALIGN
[41]145DisplayContext_Pop:
146 mov di, ds ; Backup DS
147 LOAD_BDA_SEGMENT_TO ds, ax
148 pop ax ; Pop return address
149
[491]150%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
[531]151 %ifdef USE_386
152 %assign i DISPLAY_CONTEXT_size-4
153 %rep DISPLAY_CONTEXT_size / 4
154 pop DWORD [VIDEO_BDA.displayContext + i]
155 %assign i i-4
156 %endrep
157 %else
158 %assign i DISPLAY_CONTEXT_size-2
159 %rep DISPLAY_CONTEXT_size / 2
160 pop WORD [VIDEO_BDA.displayContext + i]
161 %assign i i-2
162 %endrep
163 %endif
[194]164%endif
[491]165
[41]166 push ax ; Push return address
167 push dx
168 call DisplayContext_SynchronizeToHardware
169 pop dx
170 mov ds, di ; Restore DS
171 ret
[491]172%endif ; EXCLUDE
173%undef EXCLUDE
[41]174
[491]175
[41]176;--------------------------------------------------------------------
[52]177; DisplayContext_PrepareOffScreenBufferInESBXwithLengthInCX
[48]178; Parameters:
[52]179; CX: Off screen buffer length in characters
180; ES:BX: Ptr to off screen buffer
[48]181; Returns:
182; Nothing
183; Corrupts registers:
[52]184; AX, DI
[48]185;--------------------------------------------------------------------
[133]186%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]187ALIGN DISPLAY_JUMP_ALIGN
[52]188DisplayContext_PrepareOffScreenBufferInESBXwithLengthInCX:
[48]189 push ds
190
191 LOAD_BDA_SEGMENT_TO ds, di
192 xchg ax, bx
193 mov bx, es
194 call DisplayContext_SetCharacterPointerFromBXAX ; ES:DI now has the pointer
195
196 mov bl, ATTRIBUTES_NOT_USED
197 mov ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
198 call DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
[52]199 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam], cx
[48]200
201 mov bx, di
202 pop ds
203 ret
[491]204%endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[48]205
206
207;--------------------------------------------------------------------
[41]208; DisplayContext_SetCharacterPointerFromBXAX
209; Parameters:
210; BX:AX: Ptr to destination for next character to output
211; DS: BDA segment (zero)
212; Returns:
[48]213; ES:DI: Pointer that was in BX:AX
[41]214; Corrupts registers:
215; AX
216;--------------------------------------------------------------------
[133]217%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]218ALIGN DISPLAY_JUMP_ALIGN
[41]219DisplayContext_SetCharacterPointerFromBXAX:
220 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], ax
221 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2], bx
222 xchg di, ax
223 mov es, bx
224 ret
[133]225%endif
[41]226
227
228;--------------------------------------------------------------------
229; DisplayContext_GetCharacterPointerToBXAX
230; Parameters:
231; DS: BDA segment (zero)
232; Returns:
233; BX:AX: Ptr to destination for next character to output
234; Corrupts registers:
235; Nothing
236;--------------------------------------------------------------------
[133]237%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]238ALIGN DISPLAY_JUMP_ALIGN
[41]239DisplayContext_GetCharacterPointerToBXAX:
240 mov ax, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition]
241 mov bx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
242 ret
[133]243%endif
[41]244
245
[491]246%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
247 %ifndef MODULE_BOOT_MENU
248 %define EXCLUDE
249 %endif
250%endif
[41]251;--------------------------------------------------------------------
[45]252; DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
[41]253; Parameters:
254; AX: Offset to character output function
[45]255; BL: Attribute Flag
[41]256; DS: BDA segment (zero)
257; Returns:
258; Nothing
259; Corrupts registers:
[50]260; BL
[41]261;--------------------------------------------------------------------
[491]262%ifndef EXCLUDE ; 1 of 3
[369]263ALIGN DISPLAY_JUMP_ALIGN
[45]264DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL:
[50]265 and bl, FLG_CONTEXT_ATTRIBUTES
266 and BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], ~FLG_CONTEXT_ATTRIBUTES
267 or [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], bl
[41]268 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], ax
269 ret
[491]270%endif
[41]271
[489]272
[41]273;--------------------------------------------------------------------
274; DisplayContext_SetCharacterAttributeFromAL
275; Parameters:
276; AL: Character attribute
277; DS: BDA segment (zero)
278; Returns:
279; Nothing
280; Corrupts registers:
281; Nothing
282;--------------------------------------------------------------------
[491]283%ifndef EXCLUDE ; 2 of 3
[369]284ALIGN DISPLAY_JUMP_ALIGN
[41]285DisplayContext_SetCharacterAttributeFromAL:
286 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], al
287 ret
[491]288%endif
[41]289
290
291;--------------------------------------------------------------------
292; DisplayContext_SetCharacterOutputParameterFromAX
293; Parameters:
294; AX: Parameter for Character Output function
295; DS: BDA segment (zero)
296; Returns:
297; Nothing
298; Corrupts registers:
299; Nothing
300;--------------------------------------------------------------------
[491]301%ifndef EXCLUDE ; 3 of 3
[369]302ALIGN DISPLAY_JUMP_ALIGN
[41]303DisplayContext_SetCharacterOutputParameterFromAX:
304 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam], ax
305 ret
[491]306%endif
307
308%undef EXCLUDE
309
310
[41]311;--------------------------------------------------------------------
312; DisplayContext_GetCharacterOutputParameterToDX
313; Parameters:
314; DS: BDA segment (zero)
315; Returns:
316; DX: User parameter for Character Output function
317; Corrupts registers:
318; Nothing
[133]319;--------------------------------------------------------------------
[491]320%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
[369]321ALIGN DISPLAY_JUMP_ALIGN
[181]322DisplayContext_GetCharacterOutputParameterToDX:
323 mov dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam]
324 ret
325%endif
[44]326
327
328;--------------------------------------------------------------------
329; DisplayContext_GetCharacterOffsetToAXfromByteOffsetInAX
330; Parameters:
331; AX: Offset in bytes from some character to another
332; DS: BDA segment (zero)
333; Returns:
334; AX: Offset in characters from some character to another
335; Corrupts registers:
336; Nothing
[133]337;--------------------------------------------------------------------
[201]338%ifndef MODULE_STRINGS_COMPRESSED
[369]339ALIGN DISPLAY_JUMP_ALIGN
[44]340DisplayContext_GetCharacterOffsetToAXfromByteOffsetInAX:
341 test BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_ATTRIBUTES
342 jz SHORT ReturnOffsetInAX
343 sar ax, 1 ; BYTE count to WORD count
344 ret
[194]345%endif
[44]346
[491]347
[44]348;--------------------------------------------------------------------
349; DisplayContext_GetByteOffsetToAXfromCharacterOffsetInAX
350; Parameters:
351; AX: Offset in characters from some character to another
352; DS: BDA segment (zero)
353; Returns:
354; AX: Offset in bytes from some character to another
355; Corrupts registers:
356; Nothing
[133]357;--------------------------------------------------------------------
[201]358%ifndef MODULE_STRINGS_COMPRESSED
[369]359ALIGN DISPLAY_JUMP_ALIGN
[44]360DisplayContext_GetByteOffsetToAXfromCharacterOffsetInAX:
361 test BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_ATTRIBUTES
362 jz SHORT ReturnOffsetInAX
363 sal ax, 1 ; WORD count to BYTE count
[369]364ALIGN DISPLAY_JUMP_ALIGN, ret
[44]365ReturnOffsetInAX:
366 ret
[194]367%endif
Note: See TracBrowser for help on using the repository browser.