1 ;:ts=8-----------------------------------------------| 2 ; Fast screen I/O routines. These peek and poke | 3 ; the screen directly to run faster than a raped ape | 4 ; Michael Toy, AI Design, March 1984 | 5 ;----------------------------------------------------| 6 7 dataseg segment para public 'data' 8 extrn scr_row_:word, LINES_:word, COLS_:word, ch_attr_:word 9 extrn iscuron_:word, c_row_:word, c_col_:word, scr_ds_:word 10 extrn no_check_:word, page_no_:word 11 dataseg ends 12 13 codeseg segment byte public 'code' 14 assume ds:dataseg, cs:codeseg 15 public move_, putchr_, curch_ 16 ;--------------------------------------------------------| 17 ; Here are the functions provided and their C interfaces | 18 ; | 19 ; move(row, col) | 20 ; putchr(ch) | 21 ; curch() | 22 ; Required support from the C language is to set up| 23 ; scr_ds_ to point to the base of the screen and scr_row_ | 24 ; to point to the beginning of each row. The variables | 25 ; LINES_ and COLS_ should be set up too. If iscuron_ is set| 26 ; then we call the BIOS to do things since we need to | 27 ; move the hardware cursor too and we probably don't care| 28 ; so much about speed. | 29 ;--------------------------------------------------------| 30 31 ;********** 32 ; move(row, col) 33 ; Move the cursor to the given row and column 34 ; 35 move_ proc near 36 push bp 37 mov bp,sp 38 39 ; 40 ; Set up the current row and column numbers to point to the correct 41 ; positions. 42 ; 43 mov dx,[bp + 4] 44 mov c_row_,dx 45 mov dx,[bp + 6] 46 mov c_col_,dx 47 cmp iscuron_,0 48 jz mvexit 49 ; 50 ; Here we call the BIOS to update the cursor position since the cursor is 51 ; on and I don't care to play with the 6845. 52 ; 53 mov dh,byte ptr [bp + 4] ; dl is left from above. 54 mov ah,2 55 mov bh,byte ptr page_no_ 56 int 10h 57 mvexit: 58 pop bp 59 ret 60 move_ endp 61 62 ;********** 63 ; putchar(ch) 64 ; Put the given character on the screen 65 ; 66 putchr_ proc near 67 push bp 68 mov bp,sp 69 push di 70 push si 71 72 cmp iscuron_,0 73 jnz putout 74 75 mov si,c_row_ 76 shl si,1 77 mov di,scr_row_[si] 78 mov ax,c_col_ 79 shl ax,1 80 add di,ax 81 push es 82 mov es,scr_ds_ 83 mov ah,byte ptr ch_attr_ 84 mov al,byte ptr [bp + 4] 85 cmp no_check_,1 86 jz ontime 87 ; 88 ; We need to wait for retrace since this is not the super fast monochrome 89 ; screen that we love so much. We have to save ax in cx since the brain 90 ; damaged instruction set won't let you do an IN to somewhere else. 91 ; 92 mov cx,ax 93 mov dx,03dah 94 cli 95 wait1: in al,dx 96 test al,1 97 jnz wait1 98 wait2: in al,dx 99 test al,1 100 jz wait2 101 mov ax,cx 102 103 ontime: 104 stosw 105 sti 106 pop es 107 jmp putdone 108 putout: 109 mov ah,9 110 mov al,byte ptr [bp + 4] 111 mov bl,byte ptr ch_attr_ 112 mov bh,byte ptr page_no_ 113 mov cx,1 114 int 10h 115 putdone: 116 pop si 117 pop di 118 pop bp 119 ret 120 putchr_ endp 121 122 ;********** 123 ; curch() 124 ; Return character and attribute at given position 125 ; 126 curch_ proc near 127 push bp 128 mov bp,sp 129 push di 130 push si 131 132 cmp iscuron_,0 133 jnz dosget 134 135 mov si,c_row_ 136 shl si,1 137 mov di,scr_row_[si] 138 mov ax,c_col_ 139 shl ax,1 140 add di,ax 141 push es 142 mov es,scr_ds_ 143 cmp no_check_,1 144 jz goget 145 ; 146 ; We need to wait for retrace since this is not the super fast monochrome 147 ; screen that we love so much. We have to save ax in cx since the brain 148 ; damaged instruction set won't let you do an IN to somewhere else. 149 ; 150 mov dx,03dah 151 cli 152 iwait1: in al,dx 153 test al,1 154 jnz iwait1 155 iwait2: in al,dx 156 test al,1 157 jz iwait2 158 159 goget: 160 mov ax,es:[di] 161 sti 162 pop es 163 jmp getdone 164 dosget: 165 mov ah,2 166 mov dh,byte ptr c_row_ 167 mov dl,byte ptr c_col_ 168 mov bh,byte ptr page_no_ 169 int 10h 170 mov ah,8 171 mov bh,byte ptr page_no_ 172 int 10h 173 getdone: 174 pop si 175 pop di 176 pop bp 177 ret 178 curch_ endp 179 180 181 codeseg ends 182 end 183 ÿ