Skip to content

Instantly share code, notes, and snippets.

@nathanpc
Created June 18, 2011 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanpc/1033204 to your computer and use it in GitHub Desktop.
Save nathanpc/1033204 to your computer and use it in GitHub Desktop.
VBE And Mouse Use
org 100h
main:
call set_video_mode
.main_loop:
call get_mouse_input
call draw_top_bar
call get_keyboard_input
jz .main_loop
jmp exit
set_video_mode:
mov ah, 0h
mov al, 13h ; 320x200 256 color graphics (MCGA,VGA)
int 10h
mov ax, 1h ; show mouse cursor
int 33h
ret
get_mouse_input:
mov ax, 3h ; Get Mouse Position and Button Status
int 33h ; CX = X, DX = Y, BX = status
mov [mouseX], cx
mov [mouseY], dx
ret
draw_top_bar:
mov cx, [screenW] ; column (X)
mov dx, 5 ; row (Y)
mov al, 0Fh ; white color
@@:
mov ah, 0Ch ; put pixel
int 10h
dec cx ; ZF = (cx == 0)? 1 : 0
jnz @b
mov cx, [screenW]
dec dx ; go to the next line
jnz @b
ret
get_keyboard_input:
mov ah, 1h; ; 0h = wait for keypress; 1h = Get Keyboard Status
int 16h ; AL = ASCII (F# = 0), AH = keyboard scancode
ret
set_text_mode: ; return to text mode:
mov ah, 0h
mov al, 3h ;text mode 3
int 10h
ret
exit:
mov ah, 4Ch ; default output of the .com format
int 21h
screenW dw 319 ; (só appear 1 until 319) = 320
screenH dw 199 ; (só appear 1 until 199) = 200
mouseX dw 0
mouseY dw 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment