The QBasic Forum      Other Subforums, Links and Downloads     Search

I made one of those in text mode...

by (no login)

Probably assembles in just about anything... I used MASM 6.15. Actually works best in a window, because of the way Windows does screen writes in a window...or something.

-=-=-=-

.8086
.model tiny
.stack
.code

org 100h

main:
mov ax,0
int 33h ; test mouse driver
cmp ax,0
jz endprog
push ds
mov dx,0b800h
mov ds,dx ; set video segment,
mov al,0 ; wipe 80 x 25 with 0h
mov bx,0
loop1: mov [bx],al
add bx,2
cmp bx,0fa0h
jl loop1
mov ax,1
int 33h ; show cursor
loop2: mov ax,3 ; main program loop
int 33h ; get mouse position and buttons
cmp bx,0
jz loop2 ; loop while no buttons are active
and bx,2 ; was the right button pressed?
jnz endprog
push cx
push dx ; record where the click occurred
loop3: mov ax,3
int 33h
cmp bx,0
jnz loop3 ; loop while any button is still pressed
pop dx ; restore row number
mov cl,2
shl dx,cl
mov ax,dx ; dx is given in row*8; needs to be in row*160,
shl ax,cl ; or (row*8)*5 = (row*8)*4 + ((row*8)*4)*4.
add dx,ax
pop cx ; restore column number
push dx ; store row index
mov dx,cx
mov cl,2
shr dx,cl ; dx is given in col*8, needs to be col*2
pop bx ; restore row index; bx is for XOR
add bx,dx ; now dx is the index (in B800) of the mouse cursor
mov al,0dbh
xor [bx],al ; toggle that square between 0 and DBh
jmp loop2 ; and loop back
endprog: pop ds
mov ah,0
int 21h

end main

Posted on May 15, 2008, 9:57 PM
from IP address 24.159.248.107

Respond to this message   

Return to Index