Search code examples
assemblydosdosbox

How can i do DOSBox Assembly mouse events


I've just started to learn the "assembly" language.

How can I print "Hello World" every time I left-click with the mouse and print "Bad World" every right-click on DOSBox.


Solution

  • I think I found the solution to the problem.

      program SEGMENT
      ASSUME CS:program,DS:program
      ORG 100h
    

    First we need to call mouse cursor.Check for catalog http://stanislavs.org/helppc/int_33.html

      start:
      MOV AX,01
      INT 33h
    

    http://stanislavs.org/helppc/int_33-5.html We will not use other bits except the last two bits, so we made the rest zero with AND operator.

      loop:
      MOV AX,03
      INT 33h
      AND BX,3h
    

    We compare the rotated value,and send the function according to the result

      CMP BX,1
      JE  left
      CMP BX,2
      JE  right
    
      cmp BX,0
      je  endss
      cmp bx,3 
      je  endss
      right:
      MOV DX,OFFSET stringright
      MOV AH,09h
      INT 21h
    
    
      jmp endss
      left:
      MOV DX,OFFSET stringleft
      MOV AH,09h
      INT 21h
    
      endss:
    
      jmp loop
      stringright DB "Right Clicked $"
      stringleft DB "Left Clicked $" 
    
      INT 20h
      program ENDS
      END start