;simple drawing program using bios and dos interrupts ;ASCII codes, using the numpad ;Up(8) 56 ;Down(2) 50 ;Left(4) 52 ;Right(6) 54 ;ESC 27 org 100h INIT: mov ah, 00 ;to set video mode mov al, 13 ;graphics mode 320x200 256 color vga int 10h ;change mode mov bh, 00 ;change video mode mov cx, 160 ;set x mov dx, 100 ;set y -should be middle of screen..hopefully POLLING: mov ah, 08 ;to get input without echo, return stored in al int 21h ;get the input cmp al, 56 ;is the return value up? jz UP ;if so jump to UP cmp al, 50 ;is the return value down? jz DOWN ;if so jump to DOWN cmp al, 52 ;is the return value left? jz LEFT ;if so jump to LEFT cmp al, 54 ;is the return value right? jz RIGHT ;if so jump to RIGHT cmp al, 27 ;is the return value esc? jz EXIT UP: dec dx ;decrement dx, the Y axis..The lower X is higher on the screen jmp DRAW ;jump to DRAW ^^ at least i'm pretty sure it is. DOWN: inc dx ;increment dx, the Y axis jmp DRAW LEFT: dec cx ;decrement cx, the X axis jmp DRAW RIGHT: inc cx ;increment cx, the X axis jmp DRAW DRAW: mov ah, 0ch ;for drawing pixel mov al, 0Fh ;color int 10h ;draw pixel. bh(page) cx, dx(axes) are already set jmp POLLING ;go back to get more presses EXIT: mov ah, 00 ;to set video mode mov al, 03 ;80x25 16 color text mode int 10h ;return to video mode for dos int 20h ;terminate
;simple drawing program using bios and dos interrupts ;ASCII codes, using the numpad ;Up(8) 56 ;Down(2) 50 ;Left(4) 52 ;Right(6) 54 ;ESC 27 org 100h INIT: mov ah, 00 ;to set video mode mov al, 13 ;graphics mode 320x200 256 color vga int 10h ;change mode
mov bh, 00 ;change video mode mov cx, 160 ;set x mov dx, 100 ;set y -should be middle of screen..hopefully POLLING: mov ah, 08 ;to get input without echo, return stored in al int 21h ;get the input
cmp al, 56 ;is the return value up? jz UP ;if so jump to UP cmp al, 50 ;is the return value down? jz DOWN ;if so jump to DOWN cmp al, 52 ;is the return value left? jz LEFT ;if so jump to LEFT cmp al, 54 ;is the return value right? jz RIGHT ;if so jump to RIGHT cmp al, 27 ;is the return value esc? jz EXIT UP: dec dx ;decrement dx, the Y axis..The lower X is higher on the screen jmp DRAW ;jump to DRAW ^^ at least i'm pretty sure it is. DOWN: inc dx ;increment dx, the Y axis jmp DRAW LEFT: dec cx ;decrement cx, the X axis jmp DRAW RIGHT: inc cx ;increment cx, the X axis jmp DRAW
DRAW: mov ah, 0ch ;for drawing pixel mov al, 0Fh ;color int 10h ;draw pixel. bh(page) cx, dx(axes) are already set jmp POLLING ;go back to get more presses EXIT: mov ah, 00 ;to set video mode mov al, 03 ;80x25 16 color text mode int 10h ;return to video mode for dos int 20h ;terminate
org 100h START: mov ah, 00 ;to set up the video mode mov al, 13h ;320x200 256 Color VGA mode mov bh, 00 ;video page int 10h ;bios int to change video mode AXIS: mov cx, 160 ;X Axis mov dx, 100 ;Y Axis POLL: mov ah, 08 ;to get keypress w/o echo int 21h ;get press ;USING WASD FOR DIRECTION cmp al, 119 ;UP jz UP cmp al, 115 ;DOWN jz DOWN cmp al, 97 ;LEFT jz LEFT cmp al, 100 ;RIGHT jz RIGHT cmp al, 27 ;ESC jz ESC UP: dec dx ;make pixel go up jmp PIXEL DOWN: inc dx ;make pixel go down jmp PIXEL LEFT: dec cx ;make pixel go left jmp PIXEL RIGHT: inc cx ;make pixel go right jmp PIXEL PIXEL: mov ah, 0ch ;write pixel mode mov al, 0Fh ;color, white int 10h ;draw pixel, bh, dx, cx already set. jmp POLL ;get another press ESC: mov ah, 00 ;same as in START mov al, 03 ;80x25 16 color, normal mode for DOS int 10h int 20h ;terminate