1 | ; File name : DisplayCharOut.asm |
---|
2 | ; Project name : Assembly Library |
---|
3 | ; Created date : 26.6.2010 |
---|
4 | ; Last update : 8.10.2010 |
---|
5 | ; Author : Tomi Tilli |
---|
6 | ; Description : Functions for outputting characters to video memory. |
---|
7 | ; These functions are meant to be called by Display_CharacterFromAL |
---|
8 | ; and Display_RepeatCharacterFromAL using function pointer |
---|
9 | ; stored in DISPLAY_CONTEXT. |
---|
10 | |
---|
11 | ; Section containing code |
---|
12 | SECTION .text |
---|
13 | |
---|
14 | ;-------------------------------------------------------------------- |
---|
15 | ; DisplayCharOut_TeletypeOutputWithAttribute |
---|
16 | ; DisplayCharOut_TeletypeOutput |
---|
17 | ; Parameters: |
---|
18 | ; AL: Character to output |
---|
19 | ; AH: Attribute to output |
---|
20 | ; DS: BDA segment (zero) |
---|
21 | ; ES:DI: Ptr to video memory where to output |
---|
22 | ; Returns: |
---|
23 | ; DI: Incremented for next character |
---|
24 | ; Corrupts registers: |
---|
25 | ; AX, DX |
---|
26 | ;-------------------------------------------------------------------- |
---|
27 | ALIGN JUMP_ALIGN |
---|
28 | DisplayCharOut_TeletypeOutputWithAttribute: |
---|
29 | cmp al, ' ' ; Printable character? |
---|
30 | jb SHORT DisplayCharOut_BiosTeletypeOutput |
---|
31 | WAIT_RETRACE_IF_NECESSARY_THEN stosw |
---|
32 | ret |
---|
33 | |
---|
34 | ALIGN JUMP_ALIGN |
---|
35 | DisplayCharOut_TeletypeOutput: |
---|
36 | cmp al, ' ' ; Printable character? |
---|
37 | jae SHORT DisplayCharOut_Character |
---|
38 | ; Fall to DisplayCharOut_BiosTeletypeOutput |
---|
39 | |
---|
40 | ;-------------------------------------------------------------------- |
---|
41 | ; DisplayCharOut_BiosTeletypeOutput |
---|
42 | ; Parameters: |
---|
43 | ; AL: Control character |
---|
44 | ; DS: BDA segment (zero) |
---|
45 | ; ES:DI: Ptr to video memory where to output |
---|
46 | ; Returns: |
---|
47 | ; DI: Incremented for next character |
---|
48 | ; Corrupts registers: |
---|
49 | ; AX, DX |
---|
50 | ;-------------------------------------------------------------------- |
---|
51 | ALIGN JUMP_ALIGN |
---|
52 | DisplayCharOut_BiosTeletypeOutput: |
---|
53 | push ax |
---|
54 | call DisplayCursor_SynchronizeCoordinatesToHardware |
---|
55 | pop ax |
---|
56 | call .OutputCharacterWithBIOS |
---|
57 | call DisplayCursor_GetHardwareCoordinatesToAX |
---|
58 | jmp DisplayCursor_SetCoordinatesFromAX |
---|
59 | |
---|
60 | ;-------------------------------------------------------------------- |
---|
61 | ; .OutputCharacterWithBIOS |
---|
62 | ; Parameters: |
---|
63 | ; AL: Character to output |
---|
64 | ; DS: BDA segment |
---|
65 | ; Returns: |
---|
66 | ; Nothing |
---|
67 | ; Corrupts registers: |
---|
68 | ; AX |
---|
69 | ;-------------------------------------------------------------------- |
---|
70 | ALIGN JUMP_ALIGN |
---|
71 | .OutputCharacterWithBIOS: |
---|
72 | push bx |
---|
73 | mov ah, TELETYPE_OUTPUT |
---|
74 | mov bh, [VIDEO_BDA.bActivePage] |
---|
75 | int BIOS_VIDEO_INTERRUPT_10h |
---|
76 | pop bx |
---|
77 | ret |
---|
78 | |
---|
79 | |
---|
80 | ;-------------------------------------------------------------------- |
---|
81 | ; DisplayCharOut_Attribute |
---|
82 | ; DisplayCharOut_Character |
---|
83 | ; DisplayCharOut_CharacterWithAttribute |
---|
84 | ; Parameters: |
---|
85 | ; AL: Character to output |
---|
86 | ; AH: Attribute to output |
---|
87 | ; DS: BDA segment (zero) |
---|
88 | ; ES:DI: Ptr to video memory where to output |
---|
89 | ; Returns: |
---|
90 | ; DI: Incremented for next character |
---|
91 | ; Corrupts registers: |
---|
92 | ; AX, DX |
---|
93 | ;-------------------------------------------------------------------- |
---|
94 | ALIGN JUMP_ALIGN |
---|
95 | DisplayCharOut_Attribute: |
---|
96 | xchg al, ah ; Swap character and attribute |
---|
97 | inc di ; Skip character |
---|
98 | WAIT_RETRACE_IF_NECESSARY_THEN stosb |
---|
99 | ret |
---|
100 | |
---|
101 | ALIGN JUMP_ALIGN |
---|
102 | DisplayCharOut_Character: |
---|
103 | WAIT_RETRACE_IF_NECESSARY_THEN stosb |
---|
104 | inc di ; Skip attribute |
---|
105 | ret |
---|
106 | |
---|
107 | ALIGN JUMP_ALIGN |
---|
108 | DisplayCharOut_CharacterWithAttribute: |
---|
109 | WAIT_RETRACE_IF_NECESSARY_THEN stosw |
---|
110 | ret |
---|
111 | |
---|
112 | |
---|
113 | ;-------------------------------------------------------------------- |
---|
114 | ; DisplayCharOut_WriteCharacterToBuffer |
---|
115 | ; Parameters: |
---|
116 | ; AL: Character to output |
---|
117 | ; DS: BDA segment (zero) |
---|
118 | ; ES:DI: Ptr to destination string buffer |
---|
119 | ; DISPLAY_CONTEXT.wCharOutParam: Offset to end of buffer (one past last) |
---|
120 | ; Returns: |
---|
121 | ; ES:DI: Updated for next character |
---|
122 | ; Corrupts registers: |
---|
123 | ; AX, DX |
---|
124 | ;-------------------------------------------------------------------- |
---|
125 | ALIGN JUMP_ALIGN |
---|
126 | DisplayCharOut_WriteCharacterToBuffer: |
---|
127 | cmp di, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam] |
---|
128 | jae SHORT .BufferFull |
---|
129 | stosb |
---|
130 | .BufferFull: |
---|
131 | ret |
---|