1 ;----------------------------------------------------------;
2 ; BOS kernel Christoffer Bubach, 2003-2005. ;
3 ;----------------------------------------------------------;
5 ; Textmode screen functions. ;
7 ;----------------------------------------------------------;
12 screen_rows db 25 ; all comments assume
13 screen_cols db 80 ; that this is 25 & 80
17 ;--------------------------------------;
18 ; change cursor attribs ;
19 ; in: bx = cursor attribs ;
20 ;--------------------------------------;
38 ;----------------------;
40 ;----------------------;
45 movzx cx, [screen_rows]
58 ;-----------------------------------;
59 ; get the cursor pos ;
60 ; out: bh = x bl = y ;
61 ;-----------------------------------;
76 ;-------------------------------;
77 ; get the cursor pos ;
79 ;-------------------------------;
102 ;------------------------------;
103 ; set the cursor to: ;
105 ;------------------------------;
111 mov al, [screen_cols]
112 mul bl ; bl * al = ax
122 ;--------------------------;
123 ; set the cursor to: ;
125 ;--------------------------;
145 ;-----------------------;
146 ; cursor position +1 ;
147 ;-----------------------;
152 mov al, [screen_cols]
153 mov bl, [screen_rows]
158 cmp bx, ax ; 0x7CF = (80*25)-1
173 ;-----------------------;
174 ; cursor position -1 ;
175 ;-----------------------;
192 ;---------------------------------------;
193 ; backspace - delete last typed char ;
194 ;---------------------------------------;
216 ;-----------------------------------------;
218 ; in: bl = char, bh = attrib ;
219 ;-----------------------------------------;
238 mov [es:(eax*2 + 0xB8000)], bx
248 ;------------------------------------------;
249 ; print 32-bit hex value ;
250 ; in: ebx = value, cl = color ;
251 ;------------------------------------------;
258 mov eax, ebx ; quick & dirty fix so
259 mov bh, cl ; input reg != eax
283 ;-------------------------------------------------;
284 ; display a asciiz message on the screen ;
285 ; in: esi = message, bl = color ;
286 ;-------------------------------------------------;
312 movzx ebx, [cursor_pos]
313 mov [es:(ebx*2 + 0xB8000)], ax
319 call setcursor ; update cursor on screen
327 ;-----------------------------;
328 ; make a new line (CR, LF) ;
329 ;-----------------------------;
334 mov bh, [screen_rows]
365 mov al, [screen_rows] ; mov bx, 80*24
366 mov bl, [screen_cols]
383 movzx esi, [screen_cols]
384 shl esi, 1 ; 80*2 = 160
385 mov cl, [screen_rows]
389 shr ax, 2 ; ax = (160*24)/4
390 movzx ecx, ax ; ecx = - || -
391 add esi, 0xB8000 ; esi = 0xB8000+160
395 mov cl, [screen_cols]
396 shl cl, 1 ; 80*2 = 160
397 mov al, [screen_rows]
401 add edi, 0xB8000 ; edi = 0xB8000+160*24
402 movzx ecx, [screen_cols]
404 mov eax, 0x07000700 ; fill with zeros