Announcement

Collapse
No announcement yet.

Mouse Control Program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mouse Control Program

    I need help on this program below I got from another tutorial site. For some reason it doesn't work because of the PCOPY within it. Plus it comes up with another error #499 I think and highlights the CALL absolute as the error. PCOPY is a statement which is used in Quickbasic or Qbasic. I've even tried it in quickbasic but still doesn't work.

    '-------------| START MOUSE PROGRAM (START COPYING HERE)--------------------

    DEFINT A-Z
    DECLARE SUB mouse (cx, dx, bx)
    DECLARE SUB MousePointer (SW)
    DIM SHARED a(9) 'Set up array for code
    DEF SEG = VARSEG(a(0)) 'Get array segment (nnnn: )
    ' (two 8 bit)
    FOR i = 0 TO 17 'length of DATA to
    READ r 'read
    POKE VARPTR(a(0)) + i, r 'into array/2 (nnnn:iiii) (one 8 bit)
    NEXT i 'until 17

    '**************************** Machine Code *********************************

    DATA &HB8,&H00,&H00 : ' mov AX,[n] [Swap code-(L),(H)] in AX
    DATA &H55 : ' push BP Save BP
    DATA &H8B,&HEC : ' mov BP,SP Get BP to c Seg
    DATA &HCD,&H33 : ' int 33 Interrupt 33
    DATA &H92 : ' xchg AX,[reg] [Swap code-reg] in AX
    DATA &H8B,&H5E,&H06 : ' mov BX,[BP+6] Point to (variable)
    DATA &H89,&H07 : ' mov [BX],AX Put AX in (variable)
    DATA &H5D : ' pop BP Restore BP
    DATA &HCA,&H02,&H00 : ' ret 2 Far return

    SCREEN 13
    '****************************** Mouse set up ******************************

    CALL MousePointer(0) 'Reset mouse and
    CALL MousePointer(1) 'turn pointer on
    CALL MousePointer(3) 'Get coordinates

    '****************************** P R O G R A M ******************************
    DO 'Put your code here
    CALL mouse(cx, dx, bx)
    LOCATE 1, 1: PRINT dx; cx; bx
    LOOP UNTIL INKEY$ = CHR$(27) 'Stop your code here
    END

    SUB mouse (cx, dx, bx)

    POKE VARPTR(a(4)), &H92 'Swap code,Get CX setup
    CALL absolute(cx, VARPTR(a(0))) 'Run Code
    ' cx = cx / 8 'Adjust 25x80
    POKE VARPTR(a(4)), &H91 'Swap code,Get DX setup
    CALL absolute(dx, VARPTR(a(0))) 'Run Code
    dx = dx / 2 'Adjust 25x80
    POKE VARPTR(a(4)), &H93 'Swap code,Get BX setup
    CALL absolute(bx, VARPTR(a(0))) 'Run Code

    'Note :
    'Remove the /8
    'for graphics modes.

    END SUB

    SUB MousePointer (SW)

    POKE VARPTR(a(0)) + 1, SW 'Swap code,Set AX = (SW)
    CALL absolute(c, VARPTR(a(0))) 'Run Code

    'Note:
    'SW = 0-reset
    'SW = 1-on
    'SW = 2-off
    'SW = 3-coordinates


    END SUB

  • #2
    Hi Russ!

    I havn't worked with this mouse stuff for ages, although I used to do a lot of it years back. I never could understand why some of those old basic programs went through all the difficulties they did toi get the mouse to work. I'm sorry I can't decipher your program for you, but I found this little demo that shows how to use the mouse in PB35. It prints the mouse coordinates in the upper left corner of the screen as you move the mouse. To exit the program right click.

    Code:
    Dim blnExit As Integer
    %False =  0
    %True  = -1
    %AX=1  : %BX=2 : %CX=3 : %DX=4
    CLS
    Reg %AX, &H0
    Call Interrupt &H33
    Reg %AX, 1
    CALL Interrupt &H33
    DO
      Reg %Ax, &H3
      CALL Interrupt &H33
      Locate 1,1:Print Reg(%Dx)\8, Reg(%CX)\8
      IF Reg(%Bx) <> 0 THEN
         blnExit = %True
         DO
           Reg %Ax, &H3
           CALL Interrupt &H33
         LOOP WHILE Reg(%Bx) = 1
      END IF
      ! push DS                '''Lance Edmunds code for releasing time slice
      ! mov AX, &H1680
      ! int &H2F
      ! pop DS
    LOOP UNTIL blnExit = %True
    CLS
    END
    Last edited by Fred Harris; 3 Mar 2009, 12:23 PM.
    Fred
    "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

    Comment


    • #3
      Mouse routines

      I have attached a zip file containing a program (including the executable and subroutines) I wrote a long time ago, intending to create alternate mouse cursors for my own DOS programs. Perhaps you might find something useful in it.

      regards, Ian
      Attached Files
      Last edited by Ian Cairns; 3 Mar 2009, 01:08 PM.
      :) IRC :)

      Comment


      • #4
        There was a mouseunit unit file provided with PB-DOS 3.5.

        That would probably work better than something converted from brand M.
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          The mouse was somewhat of a mystery to me too when I was first learning to use QuickBasic. At the time I remember seeing old code like Russ posted where machine codes were poked into memory here and there, and Call Absolute was used.. That must have been code left over from gwbasic interpreter days is all I can figure, because I never had to do anything like that in Quickbasic or PBDos.

          I used Dos probably longer than I should have, probably because it worked so well on all the data recorder programming I did. Towards the end I think most of us doing a lot of DOS programming were writing mouse driven programs where we were calling mouse & keyboard interrupts in polling loops, and responding, to 'events' with function calls very much like in Windows programming now. It is for reasons such as this that I never felt overly intimidated by Windows programming. It just seemed really natural to me because the over all high level view of it wasn't very much different at all from what we were doing in DOS. I mean, conceptually, and from a very high level abstracted view, what you are doing in a DOS program where you are in a loop polling mouse & keyboard interrupts isn't a whole lot different from...

          Code:
          Function fnWndProc(Byval hWnd As Long,Byval wMsg As Long,Byval wParam As Long,Byval lParam As Long) As Long
          
            '...message processing code
          
            fnWndProc=DefWindowProc(hWnd, wMsg, wParam, lParam)
          End Function
          
          
          While GetMessage(Msg,%NULL,0,0)
              TranslateMessage Msg
              DispatchMessage Msg
            Wend
          ...in a Windows program. Yes, yes, I know - the whole multi-process thing, but I'm speaking from a high level here.
          Fred
          "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

          Comment


          • #6
            I mean, conceptually, and from a very high level abstracted view, what you are doing in a DOS program where you are in a loop polling mouse & keyboard interrupts isn't a whole lot different from...
            Au contraire, mon ami.

            Maybe the code looks similar, but conceptually I think it is a whole different world.

            When you poll under MS-DOS, YOU control when you are told "something important" has happened.... your program only has to deal with that "something important" when YOU are ready for it.

            In the Windows environment, you don't ask, you are told; and your program has to be ready to handle that 'telling' at any time.

            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Thanks everyone

              Thank you every one for posting a quick response to my message.

              Russ :-)

              Comment


              • #8
                message deleted
                Last edited by Buck Huffman; 7 Mar 2009, 01:57 AM.

                Comment

                Working...
                X