News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How to move the mouse cursor with the keyboard

Started by majid1605, January 11, 2013, 09:20:17 AM

Previous topic - Next topic

majid1605

What is the problem my code?

stacksg segment para stack 'stack'

stacksg ends

datasg segment para 'data'

  msg db "A. $", 0
datasg  ends

codes segment para 'code'
assume ss:stacksg, ds:datasg, cs:codes
   mov ax, datasg
   mov ds, ax
    ;------------ ur programm
   

mov al,4
mov bh,0
int 10h

mov bh,0
mov bl,1001b
mov ah,0Bh
int 10h

mov ax,0
int 33h

mov ax,01h
int 33h

;mov dx,101h
;mov cx,161h
lable1:

mov ah,10h
int 16h
cmp al,48h ;up key (arrow) 24dec
je lable
cmp al,50h ;Down key (arrow) 24dec
je lable2


lable:
mov ax,03h
int 33h

mov ax,04h
int 33h
dec dx
cmp dx,0
jne lable1

lable2:
mov ax,03h
int 33h

mov ax,04h
int 33h
inc dx
cmp dx,199h
jne lable1

    ;------------ end of program
    mov ax, 4c00h
    int 21h



codes ends
     end

jj2007

I get a full blue screen with a big mouse cursor (arrow to the upper left). What is it supposed to do, what is your specific problem?

nidud

#2
deleted

dedndave

in your code, you have an empty stack segment
i guess that means no stack space ?

it's also helpful to use the model and segment "shortcut" directives...
        .MODEL  Small
        .386
        .STACK  1024
        OPTION  CaseMap:None

;####################################################################################

        .DATA

s$Hello db 'Hello World!',0Dh,0Ah,24h

;************************************************************************************

;        .DATA?

;####################################################################################

        .CODE

;************************************************************************************

_main   PROC

;----------------------------------

;DS = DGROUP

        mov     ax,@data
        mov     ds,ax

;----------------------------------

;display the string

        mov     dx,offset s$Hello
        mov     ah,9
        int     21h

;----------------------------------

;wait for key press

WaitKy: mov     ah,1
        int     16h
        jz      WaitKy

        mov     ah,0
        int     16h

;----------------------------------

;terminate

        mov     ax,4C00h
        int     21h

_main   ENDP

;####################################################################################

        END     _main

nidud

#4
deleted

sinsi


mov al,4
mov bh,0
int 10h


Int 10h needs the function in AH but you don't set it to anything.
🍺🍺🍺

dedndave

set video mode 4 ???
i don't remember what mode 4 is, but that doesn't sound right

dedndave


MichaelW

Mode 4 is a CGA emulation mode, 320x200, 4-color (2bpp), 1 page, starting address B8000h.
Well Microsoft, here's another nice mess you've gotten us into.

dedndave

on my machine, the cursor is the size of texas - lol

i used to use mode 13h a lot for graphics
i remember having to make my own cursor because it was too big   :P
but, i don't think it was as big as this one

dedndave

here is a cursor i used to use for mode 13h (320x200 256 colors)
i used words instead of bytes - the high byte was used as the z-buffer   :P
but, you can use this as a template to make whatever you like

the 0 words are transparent
; F6 = black
; FE = white
;
CBMEXI  DW      0F6h,0,0,0,0,0,0
        DW      0F6h,0F6h,0,0,0,0,0
        DW      0F6h,0FEh,0F6h,0,0,0,0
        DW      0F6h,0FEh,0FEh,0F6h,0,0,0
        DW      0F6h,0FEh,0FEh,0FEh,0F6h,0,0
        DW      0F6h,0FEh,0FEh,0FEh,0FEh,0F6h,0
        DW      0F6h,0FEh,0FEh,0FEh,0FEh,0FEh,0F6h
        DW      0F6h,0FEh,0FEh,0FEh,0FEh,0F6h,0
        DW      0F6h,0F6h,0F6h,0FEh,0FEh,0F6h,0
        DW      0,0,0,0F6h,0FEh,0FEh,0F6h
        DW      0,0,0,0F6h,0F6h,0F6h,0

majid1605

Thanks, everyone :eusa_clap:
I changed the code as follows.
There is a problem with move up.its work any key .  :icon_eek:

.model small
.stack
.code
start:
;   mov ax, datasg
;   mov ds, ax
    ;------------ ur programm


mov al,4
mov bh,0
int 10h

mov bh,0
mov bl,1001b
mov ah,0Bh
int 10h

mov ax,0
int 33h

mov ax,01h
int 33h

;mov dx,101h
;mov cx,161h
lable1:

mov ah,10h
int 16h
cmp ah,48h ;upArrow key 
je lable
cmp ah,50h ;DownArrow key
je lable2
cmp ah,4Dh ;RightArrow key 
je lable3
cmp ah,4Bh ;LeftArrow key 
je lable4


lable:; Moved up
mov ax,03h
int 33h
dec dx
mov ax,04h
int 33h
cmp dx,0
jne lable1

lable2:; Moved Down
mov ax,03h
int 33h
inc dx
mov ax,04h
int 33h
cmp dx,199h
jne lable1

lable3:; Moved right
mov ax,03h
int 33h
inc cx
mov ax,04h
int 33h
cmp dx,199h
jne lable1

lable4:; Moved left
mov ax,03h
int 33h
dec cx
mov ax,04h
int 33h
cmp dx,199h
jne lable1

    ;------------ end of program
    mov ax, 4c00h
    int 21h

     end start

dedndave

that's because of the logic in this part
int 16h
cmp ah,48h ;upArrow key 
je lable
cmp ah,50h ;DownArrow key
je lable2
cmp ah,4Dh ;RightArrow key 
je lable3
cmp ah,4Bh ;LeftArrow key 
je lable4

lable:; Moved up


notice that, if none of the conditions are met, the "Moved up" code is executed

dedndave

you can fix it like this
int 16h
cmp ah,50h ;DownArrow key
je lable2
cmp ah,4Dh ;RightArrow key 
je lable3
cmp ah,4Bh ;LeftArrow key 
je lable4
cmp ah,48h ;upArrow key 
jne test_something_else

lable:; Moved up


the last test is for the upArrow key
if it's not upArrow - do something else
the "something else" can be test the mouse or go back and wait for another key

majid1605

Thank you my friend

Why is the cursor out screen left and bottom.unless the screen is 320 x 200