Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7bb55490c7
Fetching contributors…

Cannot retrieve contributors at this time

file 216 lines (186 sloc) 3.278 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
; screen.asm

SET_MODE equ 00H
SET_CURSOR_LOCATION equ 02H
READ_CURSOR_LOCATION equ 03H
SCROLL_WINDOW equ 06H
READ_CHARACTER equ 08H
WRITE_CHARACTER equ 0AH
WRITE_DOT equ 0CH
VIDEO_SERVICE equ 10H

CLEAR_ALL_LINES equ 00H
NORMAL_ATTRIBUTE equ 07H
PAGE_NUMBER equ 00H


public screen_set_mode
public screen_get_cursor_location
public screen_locate
public screen_read_char
public screen_write_char
public screen_clear_window
public screen_write_dot

code segment public byte 'code'
assume cs:code
;
; purpose: set the screen mode
; input: al = mode (3 = 80x24 color, 6 = 640x200, others exist)
; output: nothing (screen mode is change and screen is cleared)
; destroys: nothing
;
screen_set_mode proc near
push ax
push si
push di
push bp

mov ah, SET_MODE
int VIDEO_SERVICE

pop bp
pop di
pop si
pop ax
ret
screen_set_mode endp


;
; purpose: get the cursors location
; input: nothing
; output: dx holds the location (dh=row, dl=column)
; destroys: nothing
;
screen_get_cursor_location proc near
push ax
push bx
push cx
push si
push di
push bp

mov bh, PAGE_NUMBER
mov ah, READ_CURSOR_LOCATION
int VIDEO_SERVICE

pop bp
pop di
pop si
pop cx
pop bx
pop ax
ret
screen_get_cursor_location endp


;
; purpose: set the location of the cursor
; input: dx holds the location dl=column, dh=row
; output: nothing (the cursor is moved)
; destroys: nothing
;
screen_locate proc near
push ax
push bx
push cx
push si
push di
push bp

mov bh, PAGE_NUMBER
mov ah, SET_CURSOR_LOCATION
int VIDEO_SERVICE

pop bp
pop di
pop si
pop cx
pop bx
pop ax
ret
screen_locate endp


;
; purpose: read the character at the current screen location
; input: nothing
; output: al = character at current cursor location
; destroys: nothing
;
screen_read_char proc near
push bx
push cx
push dx
push si
push di
push bp

mov bh, PAGE_NUMBER
mov ah, READ_CHARACTER
int VIDEO_SERVICE

pop bp
pop di
pop si
pop dx
pop cx
pop bx
ret
screen_read_char endp


;
; purpose: write a character to the screen at the present curcor location
; input: al holds the character
; output: nothing (the screen is updated)
; destroys: nothing
;
screen_write_char proc near
push ax
push bx
push cx
push dx
push si
push di
push bp

mov bh, PAGE_NUMBER
mov cx,1
mov ah, WRITE_CHARACTER
int VIDEO_SERVICE

pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
screen_write_char endp

;
; purpose: clear a window on the screen
; input: ch,cl = upper left row, column, dh,dl = lower left row, column
; output: nothing (affects screen)
; destroys: nothing
;
screen_clear_window proc near
push bx
push cx
push dx
push si
push di
push bp


mov bh, NORMAL_ATTRIBUTE
mov al, CLEAR_ALL_LINES
mov ah, SCROLL_WINDOW
int VIDEO_SERVICE

pop bp
pop di
pop si
pop dx
pop cx
pop bx
ret
screen_clear_window endp

;
; purpose: write a dot
; input: al = color value, dx = row, cx = column
; (if al bit 7 is 1 then al bits 0-6 are xor'd with current value.)
; output: nothing (affects screen)
; destroys: nothing
;
screen_write_dot proc near
push ax
push si
push di
push bp

mov ah, WRITE_DOT
int VIDEO_SERVICE

pop bp
pop di
pop si
pop ax
ret
screen_write_dot endp
code ends
end
Something went wrong with that request. Please try again.