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

Last change on this file since 588 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
Line 
1; Project name  :   Assembly Library
2; Description   :   Functions for managing display context.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 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
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;--------------------------------------------------------------------
32ALIGN DISPLAY_JUMP_ALIGN
33DisplayContext_Initialize:
34    mov     WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], DEFAULT_CHARACTER_OUTPUT
35    mov     BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], SCREEN_BACKGROUND_ATTRIBUTE
36    call    DisplayCursor_GetDefaultCursorShapeToAX
37    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape], ax
38    ; Fall to .DetectAndSetDisplaySegment
39
40;--------------------------------------------------------------------
41; .DetectAndSetDisplaySegment
42;   Parameters:
43;       DS:     BDA segment (zero)
44;   Returns:
45;       Nothing
46;   Corrupts registers:
47;       AX, DX
48;--------------------------------------------------------------------
49.DetectAndSetDisplaySegment:
50    mov     ax, COLOR_TEXT_SEGMENT
51    cmp     BYTE [VIDEO_BDA.bMode], MDA_TEXT_MODE
52    eCMOVE  ah, MONO_TEXT_SEGMENT >> 8
53    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2], ax
54    ; Fall to .InitializeFlags
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
68    eCMOVC  dl, FLG_CONTEXT_ATTRIBUTES | FLG_CONTEXT_CGA
69    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], dl
70    ; Fall to .InitializeCursor
71
72;--------------------------------------------------------------------
73; .InitializeCursor
74;   Parameters:
75;       DS:     BDA segment (zero)
76;   Returns:
77;       Nothing
78;   Corrupts registers:
79;       AX, DX
80;--------------------------------------------------------------------
81.InitializeCursor:
82    call    DisplayCursor_GetHardwareCoordinatesToAX    ; Coordinates before init
83    call    DisplayCursor_SetCoordinatesFromAX          ; Cursor to Display Context
84    ; Fall to DisplayContext_SynchronizeToHardware
85
86;--------------------------------------------------------------------
87; DisplayContext_SynchronizeToHardware
88;   Parameters:
89;       DS:     BDA segment (zero)
90;   Returns:
91;       Nothing
92;   Corrupts registers:
93;       AX, DX
94;--------------------------------------------------------------------
95ALIGN DISPLAY_JUMP_ALIGN
96DisplayContext_SynchronizeToHardware:
97    call    DisplayPage_SynchronizeToHardware
98    call    DisplayCursor_SynchronizeShapeToHardware
99    jmp     DisplayCursor_SynchronizeCoordinatesToHardware
100
101
102;--------------------------------------------------------------------
103; DisplayContext_Push
104; DisplayContext_Pop
105;   Parameters:
106;       Nothing
107;   Returns:
108;       Nothing
109;   Corrupts registers:
110;       AX, DI
111;--------------------------------------------------------------------
112%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
113    %ifndef MODULE_BOOT_MENU
114        %define EXCLUDE
115    %endif
116%endif
117
118%ifndef EXCLUDE
119ALIGN DISPLAY_JUMP_ALIGN
120DisplayContext_Push:
121    mov     di, ds                  ; Backup DS
122    LOAD_BDA_SEGMENT_TO ds, ax
123    pop     ax                      ; Pop return address
124
125%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
126    %assign i 0
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
138%endif
139
140    mov     ds, di                  ; Restore DS
141    jmp     ax
142
143
144ALIGN DISPLAY_JUMP_ALIGN
145DisplayContext_Pop:
146    mov     di, ds                  ; Backup DS
147    LOAD_BDA_SEGMENT_TO ds, ax
148    pop     ax                      ; Pop return address
149
150%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
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
164%endif
165
166    push    ax                      ; Push return address
167    push    dx
168    call    DisplayContext_SynchronizeToHardware
169    pop     dx
170    mov     ds, di                  ; Restore DS
171    ret
172%endif ; EXCLUDE
173%undef EXCLUDE
174
175
176;--------------------------------------------------------------------
177; DisplayContext_PrepareOffScreenBufferInESBXwithLengthInCX
178;   Parameters:
179;       CX:     Off screen buffer length in characters
180;       ES:BX:  Ptr to off screen buffer
181;   Returns:
182;       Nothing
183;   Corrupts registers:
184;       AX, DI
185;--------------------------------------------------------------------
186%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
187ALIGN DISPLAY_JUMP_ALIGN
188DisplayContext_PrepareOffScreenBufferInESBXwithLengthInCX:
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
199    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam], cx
200
201    mov     bx, di
202    pop     ds
203    ret
204%endif ; EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
205
206
207;--------------------------------------------------------------------
208; DisplayContext_SetCharacterPointerFromBXAX
209;   Parameters:
210;       BX:AX:  Ptr to destination for next character to output
211;       DS:     BDA segment (zero)
212;   Returns:
213;       ES:DI:  Pointer that was in BX:AX
214;   Corrupts registers:
215;       AX
216;--------------------------------------------------------------------
217%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
218ALIGN DISPLAY_JUMP_ALIGN
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
225%endif
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;--------------------------------------------------------------------
237%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
238ALIGN DISPLAY_JUMP_ALIGN
239DisplayContext_GetCharacterPointerToBXAX:
240    mov     ax, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition]
241    mov     bx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
242    ret
243%endif
244
245
246%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
247    %ifndef MODULE_BOOT_MENU
248        %define EXCLUDE
249    %endif
250%endif
251;--------------------------------------------------------------------
252; DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
253;   Parameters:
254;       AX:     Offset to character output function
255;       BL:     Attribute Flag
256;       DS:     BDA segment (zero)
257;   Returns:
258;       Nothing
259;   Corrupts registers:
260;       BL
261;--------------------------------------------------------------------
262%ifndef EXCLUDE ; 1 of 3
263ALIGN DISPLAY_JUMP_ALIGN
264DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL:
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
268    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], ax
269    ret
270%endif
271
272
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;--------------------------------------------------------------------
283%ifndef EXCLUDE ; 2 of 3
284ALIGN DISPLAY_JUMP_ALIGN
285DisplayContext_SetCharacterAttributeFromAL:
286    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], al
287    ret
288%endif
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;--------------------------------------------------------------------
301%ifndef EXCLUDE ; 3 of 3
302ALIGN DISPLAY_JUMP_ALIGN
303DisplayContext_SetCharacterOutputParameterFromAX:
304    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam], ax
305    ret
306%endif
307
308%undef EXCLUDE
309
310
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
319;--------------------------------------------------------------------
320%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
321ALIGN DISPLAY_JUMP_ALIGN
322DisplayContext_GetCharacterOutputParameterToDX:
323    mov     dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam]
324    ret
325%endif
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
337;--------------------------------------------------------------------
338%ifndef MODULE_STRINGS_COMPRESSED
339ALIGN DISPLAY_JUMP_ALIGN
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
345%endif
346
347
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
357;--------------------------------------------------------------------
358%ifndef MODULE_STRINGS_COMPRESSED
359ALIGN DISPLAY_JUMP_ALIGN
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
364ALIGN DISPLAY_JUMP_ALIGN, ret
365ReturnOffsetInAX:
366    ret
367%endif
Note: See TracBrowser for help on using the repository browser.