include mc.ash .MODEL SMALL ; ; Tom Jennings ; new: 28 Jun 90 ; mru: 23 Aug 92 ; ;Screen functions, coded in assembly for speed. ; COLUMNS equ 80 ;columns/line ; ; ;void _wininit() ; One-time initialization for the windowing stuff ; called automatically by the first call to ; init_window(). ; ;char getcursheight() ; Returns the current cursor height. ; ;struct _cell far *toaddr(line,col) ;unsigned short line,col; ; Convert line/column to a pointer to a screen cell. ; Coded as a series of shifts and adds for speed. ; This means that columns per line is hard-coded as ; 80, which isn't likely to change soon. ; ;struct _cell far *rptchar(p,c,a,n) ;struct _cell far *p; ;char c,a; ;unsigned short n; ; Write N characters starting at the given pointer. ; Assumes that the write will not go past the end ; of the line, ie. that starting col + n <= 80. ; .CODE scrseg dw 0 ;screen base segment ;void wininit func _wininit mov ah,15 ;Get Video Mode int 10h mov cs:scrseg,0b000h;(mono address) cmp al,7 jz sc1 mov cs:scrseg,0b800h;else xGA sc1: endf _wininit ;char getcursheight() func _getcursheight mov ax,0040h ;get current cursor mov es,ax ;shape mov bx,0060h mov ax,es:[bx] ;read cursor type sub al,ah ;convert to xor ah,ah ;cursor height endf _getcursheight ;struct _cell far *toaddr(line,col) func _toaddr mov ax,arg0 ; this op total mov bx,ax add bx,bx ; (line * 2) mov cl,3 shl ax,cl ; (line * 8) add ax,bx ; (l*2 + l*8) line *= 10 shl ax,cl ; line *= 80 add ax,arg1 ; + col AX * 80 + col shl ax,1 ; make cell ptr mov dx,scrseg endf _toaddr ;struct _cell far *rptchar(p,c,a,n) func _rptchar push es les di,arg0 ;ES:DI= cell ptr mov al,arg2 ;AL= char mov ah,arg3 ;AH= attr mov cx,arg4 ;CX= count cld rep stosw ;do it! mov dx,es mov ax,di ;AX:DX= cell ptr pop es endf _rptchar end