[52] | 1 | ; File name : CharOutLineSplitter.asm
|
---|
| 2 | ; Project name : Assembly Library
|
---|
| 3 | ; Created date : 11.10.2010
|
---|
| 4 | ; Last update : 12.10.2010
|
---|
| 5 | ; Author : Tomi Tilli
|
---|
| 6 | ; Description : Functions for splitting menu lines during character output.
|
---|
| 7 |
|
---|
| 8 | ; Section containing code
|
---|
| 9 | SECTION .text
|
---|
| 10 |
|
---|
| 11 | ;--------------------------------------------------------------------
|
---|
| 12 | ; CharOutLineSplitter_PrepareForPrintingTextLines
|
---|
| 13 | ; Parameters:
|
---|
| 14 | ; SS:BP: Ptr to MENU
|
---|
| 15 | ; Returns:
|
---|
| 16 | ; Nothing
|
---|
| 17 | ; Corrupts registers:
|
---|
| 18 | ; AX, DX, DI
|
---|
| 19 | ;--------------------------------------------------------------------
|
---|
| 20 | ALIGN JUMP_ALIGN
|
---|
| 21 | CharOutLineSplitter_PrepareForPrintingTextLines:
|
---|
| 22 | call .GetLastTextLineColumnOffsetToDX
|
---|
| 23 | call CharOutLineSplitter_GetFirstTextLineColumnOffsetToAX
|
---|
| 24 | mov ah, dl ; AL = Text line first column, AH = Text line last column
|
---|
| 25 | CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX
|
---|
| 26 | ret
|
---|
| 27 |
|
---|
| 28 | ;--------------------------------------------------------------------
|
---|
| 29 | ; .GetLastTextLineColumnOffsetToDX
|
---|
| 30 | ; Parameters:
|
---|
| 31 | ; SS:BP: Ptr to MENU
|
---|
| 32 | ; Returns:
|
---|
| 33 | ; DX: Offset to last (allowed) character in text line
|
---|
| 34 | ; Corrupts registers:
|
---|
| 35 | ; AX
|
---|
| 36 | ;--------------------------------------------------------------------
|
---|
| 37 | ALIGN JUMP_ALIGN
|
---|
| 38 | .GetLastTextLineColumnOffsetToDX:
|
---|
| 39 | call CharOutLineSplitter_GetFirstTextLineColumnOffsetToAX
|
---|
| 40 | xchg dx, ax
|
---|
| 41 | call MenuLocation_GetMaxTextLineLengthToAX
|
---|
| 42 | shl ax, 1
|
---|
| 43 | add dx, ax
|
---|
| 44 | ret
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | ;--------------------------------------------------------------------
|
---|
| 48 | ; CharOutLineSplitter_GetFirstTextLineColumnOffsetToAX
|
---|
| 49 | ; CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
|
---|
| 50 | ; Parameters:
|
---|
| 51 | ; SS:BP: Ptr to MENU
|
---|
| 52 | ; Returns:
|
---|
| 53 | ; AX: Offset to end of text line (first border area character)
|
---|
| 54 | ; Corrupts registers:
|
---|
| 55 | ; Nothing
|
---|
| 56 | ;--------------------------------------------------------------------
|
---|
| 57 | ALIGN JUMP_ALIGN
|
---|
| 58 | CharOutLineSplitter_GetFirstTextLineColumnOffsetToAX:
|
---|
| 59 | call CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
|
---|
| 60 | add al, MENU_TEXT_COLUMN_OFFSET<<1
|
---|
| 61 | ret
|
---|
| 62 |
|
---|
| 63 | ALIGN JUMP_ALIGN
|
---|
| 64 | CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX:
|
---|
| 65 | call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
|
---|
| 66 | xor ah, ah
|
---|
| 67 | shl ax, 1
|
---|
| 68 | ret
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | ;--------------------------------------------------------------------
|
---|
| 72 | ; CharOutLineSplitter_IsCursorAtTheEndOfTextLine
|
---|
| 73 | ; Parameters:
|
---|
| 74 | ; DS: BDA segment (zero)
|
---|
| 75 | ; ES:DI: Ptr to cursor location in video memory
|
---|
| 76 | ; Returns:
|
---|
| 77 | ; CF: Set if end of text line
|
---|
| 78 | ; Clear if more characters fit on current text line
|
---|
| 79 | ; Corrupts registers:
|
---|
| 80 | ; DX
|
---|
| 81 | ;--------------------------------------------------------------------
|
---|
| 82 | ALIGN JUMP_ALIGN
|
---|
| 83 | CharOutLineSplitter_IsCursorAtTheEndOfTextLine:
|
---|
| 84 | push ax
|
---|
| 85 |
|
---|
| 86 | mov dl, [VIDEO_BDA.wColumns]
|
---|
| 87 | shl dl, 1 ; DX = bytes per row
|
---|
| 88 | mov ax, di
|
---|
| 89 | div dl ; AL = row index, AH = column index
|
---|
| 90 | cmp [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam+1], ah
|
---|
| 91 |
|
---|
| 92 | pop ax
|
---|
| 93 | ret
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | ;--------------------------------------------------------------------
|
---|
| 97 | ; CharOutLineSplitter_MovePartialWordToNewTextLine
|
---|
| 98 | ; Parameters:
|
---|
| 99 | ; AL: Character to output
|
---|
| 100 | ; AH: Attribute to output
|
---|
| 101 | ; DS: BDA segment (zero)
|
---|
| 102 | ; ES:DI: Ptr to end of text line in video memory
|
---|
| 103 | ; Returns:
|
---|
| 104 | ; DI: Updated to next character for new text line
|
---|
| 105 | ; Corrupts registers:
|
---|
| 106 | ; AX, DX
|
---|
| 107 | ;--------------------------------------------------------------------
|
---|
| 108 | ALIGN JUMP_ALIGN
|
---|
| 109 | CharOutLineSplitter_MovePartialWordToNewTextLine:
|
---|
| 110 | push si
|
---|
| 111 | push cx
|
---|
| 112 | push ax
|
---|
| 113 |
|
---|
| 114 | call GetOffsetToPartialWordToSIandSizeToCX
|
---|
| 115 | call MenuCharOut_PrintLFCRandAdjustOffsetForStartOfLine
|
---|
| 116 | jcxz .NothingToMove
|
---|
| 117 | call MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
|
---|
| 118 | .NothingToMove:
|
---|
| 119 | pop ax
|
---|
| 120 | pop cx
|
---|
| 121 | pop si
|
---|
| 122 | ret
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | ;--------------------------------------------------------------------
|
---|
| 126 | ; GetOffsetToPartialWordToSIandSizeToCX
|
---|
| 127 | ; Parameters:
|
---|
| 128 | ; ES:DI: Ptr to space before border character
|
---|
| 129 | ; Returns:
|
---|
| 130 | ; CX: Number of bytes that needs to be moved
|
---|
| 131 | ; ES:SI: Ptr to beginning of partial word that needs to be moved to new line
|
---|
| 132 | ; Corrupts registers:
|
---|
| 133 | ; Nothing
|
---|
| 134 | ;--------------------------------------------------------------------
|
---|
| 135 | ALIGN JUMP_ALIGN
|
---|
| 136 | GetOffsetToPartialWordToSIandSizeToCX:
|
---|
| 137 | xor cx, cx
|
---|
| 138 | mov si, di
|
---|
| 139 | ALIGN JUMP_ALIGN
|
---|
| 140 | .ScanNextCharacter: ; Space will always be found since one comes after border
|
---|
| 141 | dec si
|
---|
| 142 | dec si
|
---|
| 143 | cmp BYTE [es:si], ' '
|
---|
| 144 | je SHORT .PartialWordFound
|
---|
| 145 | inc cx
|
---|
| 146 | jmp SHORT .ScanNextCharacter
|
---|
| 147 | ALIGN JUMP_ALIGN
|
---|
| 148 | .PartialWordFound:
|
---|
| 149 | inc si
|
---|
| 150 | inc si ; SI now points one past space
|
---|
| 151 | shl cx, 1 ; Characters to bytes
|
---|
| 152 | ret
|
---|
| 153 |
|
---|
| 154 |
|
---|
| 155 | ;--------------------------------------------------------------------
|
---|
| 156 | ; MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
|
---|
| 157 | ; Parameters:
|
---|
| 158 | ; CX: Number of BYTEs in partial word
|
---|
| 159 | ; DS: BDA segment (zero)
|
---|
| 160 | ; ES:SI: Ptr to partial word on previous line
|
---|
| 161 | ; ES:DI: Ptr to new empty line
|
---|
| 162 | ; Returns:
|
---|
| 163 | ; ES:DI: Ptr where to store next character
|
---|
| 164 | ; Corrupts registers:
|
---|
| 165 | ; AX, CX, DX, SI
|
---|
| 166 | ;--------------------------------------------------------------------
|
---|
| 167 | ALIGN JUMP_ALIGN
|
---|
| 168 | MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX:
|
---|
| 169 | push si
|
---|
| 170 | push cx
|
---|
| 171 | WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
|
---|
| 172 | pop cx
|
---|
| 173 | pop si
|
---|
| 174 |
|
---|
| 175 | xchg di, si
|
---|
| 176 | shr cx, 1 ; Bytes to characters
|
---|
| 177 | mov al, ' '
|
---|
| 178 | call DisplayPrint_RepeatCharacterFromALwithCountInCX
|
---|
| 179 | mov di, si
|
---|
| 180 | ret
|
---|