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