Menu

Using a Mouse Basic

Smithdoor
2020-04-18
2020-04-23
  • Smithdoor

    Smithdoor - 2020-04-18

    In earley 1980's I use mouse vai the RS232 port but did not find any way to use todays USB mouse by the way of the COM
    But did find my information from 1987 on a mouse in QBASIC 4.0
    So write in PC-Bacis then move over to Qbasic 4.0 to use the mouse.
    Here is the simple program for QBasic 4.0

    Hope helps

    DEFINT A-Z
    DECLARE SUB Mouse (MIU)
    '
    ' This was around since in 1987 from my files David B Smith
    ' "Mouse" Sub-Routine
    ' sample program changing color only runs on QBASIC 4 or QBASIX 4.5 update 2020
    ' First you will need to start QB/etc. with the /L option
    ' Type QB/L it files need QB.BI
    ' later the program needs ABSOLUTE.ASM
    ' also the file mouse.com
    ' SCREEN 0 is 639 X 199 H X V
    ' MIU Is only a name and can be changed AKA (Mouse In Use) or MIU
    ' This only shows a box in Screen 0 and other screens a Arrow
    '
    ' MOUSE 1 turned on Box or Arrow You can see it on the screen.
    ' MOUSE 2 turned off. You can no longer see it on the screen.
    ' MOUSE 3 status is returned into by using PEEK is used for reading
    ' B = PEEK(&HAAA) Current button being pressed (1 = left, 2 = right)
    ' h = PEEK(&HBBB) + PEEK(&HBBC) 256 Current Horizontal position on screen
    ' V = PEEK(&HCCC) + PEEK(&HCCD) 256 Current Vertical position on screen
    '
    ''''''''''''''''''''''' Enter your code here Initialize Program just use PC-BASIC ''''''''''''''''''''''''''''''''
    SCREEN 0, 0, 0: ' ### srceen can be 0 to 13
    COLOR 14, 1
    CLS
    PRINT "Press Esc to end": ' ### Demo showing how both Keyboard and mouse can work on same screen
    LOCATE 13, 28: PRINT "Press mouse botton on box >"; STRING$(4, 177);:' ### Demo box
    10 LOCATE 7, 10
    th = (INT(h / 36)): ' used for box not need for most games
    tv = (INT(V / 8)): ' v/8 gives about 25 lines
    PRINT B, V, h, tv, th: ' display information on the mouse
    ' Below shows button press at location 12, 12 and buttons L, M & R press
    IF th = 12 AND tv = 12 AND B = 1 THEN COLOR 0, 3
    IF th = 12 AND tv = 12 AND B = 4 THEN COLOR 15, 4
    IF th = 12 AND tv = 12 AND B = 2 THEN COLOR 2, 1
    Mouse 1 ' ### Display Arrow Only IF THEN need to be above this line
    A$ = INKEY$: ' ### note use GOTO at bottom only DO Not use IF A$="" This so mouse info is read data use data
    IF A$ = CHR$(27) THEN PRINT "END only used for demo": END
    Mouse 3 ' ### status is returned Button , Vert and Horiz position
    B = PEEK(&HAAA) ' Get values for: Buttons
    h = PEEK(&HBBB) + PEEK(&HBBC) 256 ' Horizontal position ( 2 bytes )
    V = PEEK(&HCCC) + PEEK(&HCCD) 256 ' Vertical position ( 2 bytes )
    GOTO 10

    ' " " " "
    ' " " " "
    ''''''''''''''''''''''' END OF program ''''''''''''''''''''''''''''''''
    ''''''''''''''''''''''' Mouse sub program ''''''''''''''''''''''''''''''''
    SUB Mouse (MIU) STATIC 'Define sub & parameter(s) passed.
    SHARED B, h, V 'Share variables with main sub.
    IF MIU = 1 THEN Crsr = 1 'Show Cursor.
    IF MIU = 2 AND Crsr = 0 THEN EXIT SUB 'Don't hide Cursor more than once.
    IF MIU = 2 AND Crsr = 1 THEN Crsr = 0 'Hide Cursor.
    POKE 100, 184: POKE 101, MIU: POKE 102, 0 'Poke machine code necessary for
    POKE 103, 205: POKE 104, 51: POKE 105, 137 'using the mouse into memory
    POKE 106, 30: POKE 107, 170: POKE 108, 10 'starting at offset 100 in the
    POKE 109, 137: POKE 110, 14: POKE 111, 187 'current segment. This code is
    POKE 112, 11: POKE 113, 137: POKE 114, 22 'then executed as a unit, via the
    POKE 115, 204: POKE 116, 12: POKE 117, 203 'statement " Call Absolute ".
    CALL Absolute(100) 'Call machine code.
    B = PEEK(&HAAA) 'Get values for: Buttons
    h = PEEK(&HBBB) + PEEK(&HBBC) 256 'Horizontal position ( 2 bytes )
    V = PEEK(&HCCC) + PEEK(&HCCD) 256 'Vertical position ( 2 bytes )
    END SUB 'End of sub-program.
    *

     
    • Smithdoor

      Smithdoor - 2020-04-21

      Thank youI just try in GW Basic and PC Basic.I works great in GW Basic still try get in PC Basic
      I try find that for days on internet 
      Thank youDave
      Sent from Yahoo Mail on Android

      On Sat, Apr 18, 2020 at 10:56 AM, Smithdoorsmithdoor@users.sourceforge.net wrote:
      In earley 1980's I use mouse vai the RS232 port but did not find any way to use todays USB mouse by the way of the COM
      But did find my information from 1987 on a mouse in QBASIC 4.0
      So write in PC-Bacis then move over to Qbasic 4.0 to use the mouse.
      Here is the simple program for QBasic 4.0

      Hope helps

      DEFINT A-Z
      DECLARE SUB Mouse (MIU)
      '
      ' This was around since in 1987 from my files David B Smith
      ' "Mouse" Sub-Routine
      ' sample program changing color only runs on QBASIC 4 or QBASIX 4.5 update 2020
      ' First you will need to start QB/etc. with the /L option
      ' Type QB/L it files need QB.BI
      ' later the program needs ABSOLUTE.ASM
      ' also the file mouse.com
      ' SCREEN 0 is 639 X 199 H X V
      ' MIU Is only a name and can be changed AKA (Mouse In Use) or MIU
      ' This only shows a box in Screen 0 and other screens a Arrow
      '
      ' MOUSE 1 turned on Box or Arrow You can see it on the screen.
      ' MOUSE 2 turned off. You can no longer see it on the screen.
      ' MOUSE 3 status is returned into by using PEEK is used for reading
      ' B = PEEK(&HAAA) Current button being pressed (1 = left, 2 = right)
      ' h = PEEK(&HBBB) + PEEK(&HBBC) 256 Current Horizontal position on screen
      ' V = PEEK(&HCCC) + PEEK(&HCCD) 256 Current Vertical position on screen
      '
      ''''''''''''''''''''''' Enter your code here Initialize Program just use PC-BASIC ''''''''''''''''''''''''''''''''
      SCREEN 0, 0, 0: ' ### srceen can be 0 to 13
      COLOR 14, 1
      CLS
      PRINT "Press Esc to end": ' ### Demo showing how both Keyboard and mouse can work on same screen
      LOCATE 13, 28: PRINT "Press mouse botton on box >"; STRING$(4, 177);:' ### Demo box
      10 LOCATE 7, 10
      th = (INT(h / 36)): ' used for box not need for most games
      tv = (INT(V / 8)): ' v/8 gives about 25 lines
      PRINT B, V, h, tv, th: ' display information on the mouse
      ' Below shows button press at location 12, 12 and buttons L, M & R press
      IF th = 12 AND tv = 12 AND B = 1 THEN COLOR 0, 3
      IF th = 12 AND tv = 12 AND B = 4 THEN COLOR 15, 4
      IF th = 12 AND tv = 12 AND B = 2 THEN COLOR 2, 1
      Mouse 1 ' ### Display Arrow Only IF THEN need to be above this line
      A$ = INKEY$: ' ### note use GOTO at bottom only DO Not use IF A$="" This so mouse info is read data use data
      IF A$ = CHR$(27) THEN PRINT "END only used for demo": END
      Mouse 3 ' ### status is returned Button , Vert and Horiz position
      B = PEEK(&HAAA) ' Get values for: Buttons
      h = PEEK(&HBBB) + PEEK(&HBBC) 256 ' Horizontal position ( 2 bytes )
      V = PEEK(&HCCC) + PEEK(&HCCD) 256 ' Vertical position ( 2 bytes )
      GOTO 10

      ' " " " "
      ' " " " "
      ''''''''''''''''''''''' END OF program ''''''''''''''''''''''''''''''''
      ''''''''''''''''''''''' Mouse sub program ''''''''''''''''''''''''''''''''
      SUB Mouse (MIU) STATIC 'Define sub & parameter(s) passed.
      SHARED B, h, V 'Share variables with main sub.
      IF MIU = 1 THEN Crsr = 1 'Show Cursor.
      IF MIU = 2 AND Crsr = 0 THEN EXIT SUB 'Don't hide Cursor more than once.
      IF MIU = 2 AND Crsr = 1 THEN Crsr = 0 'Hide Cursor.
      POKE 100, 184: POKE 101, MIU: POKE 102, 0 'Poke machine code necessary for
      POKE 103, 205: POKE 104, 51: POKE 105, 137 'using the mouse into memory
      POKE 106, 30: POKE 107, 170: POKE 108, 10 'starting at offset 100 in the
      POKE 109, 137: POKE 110, 14: POKE 111, 187 'current segment. This code is
      POKE 112, 11: POKE 113, 137: POKE 114, 22 'then executed as a unit, via the
      POKE 115, 204: POKE 116, 12: POKE 117, 203 'statement " Call Absolute ".
      CALL Absolute(100) 'Call machine code.
      B = PEEK(&HAAA) 'Get values for: Buttons
      h = PEEK(&HBBB) + PEEK(&HBBC) 256 'Horizontal position ( 2 bytes )
      V = PEEK(&HCCC) + PEEK(&HCCD) 256 'Vertical position ( 2 bytes )
      END SUB 'End of sub-program.
      *

      Using a Mouse Basic

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/pcbasic/discussion/programs/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       
      • Tuxtoo

        Tuxtoo - 2020-04-22

        Hi Dave,

        Just glad I could help you out.

        Stuart

        On 21/04/20 21:38, Smithdoor wrote:

        Thank youI just try in GW Basic and PC Basic.I works great in GW Basic
        still try get in PC Basic
        I try find that for days on internet
        Thank youDave
        Sent from Yahoo Mail on Android

        On Sat, Apr 18, 2020 at 10:56 AM,
        Smithdoorsmithdoor@users.sourceforge.net
        smithdoor@users.sourceforge.net wrote:
        In earley 1980's I use mouse vai the RS232 port but did not find any
        way to use todays USB mouse by the way of the COM
        But did find my information from 1987 on a mouse in QBASIC 4.0
        So write in PC-Bacis then move over to Qbasic 4.0 to use the mouse.
        Here is the simple program for QBasic 4.0

        Hope helps

        DEFINT A-Z
        DECLARE SUB Mouse (MIU)
        '
        ' This was around since in 1987 from my files David B Smith
        ' "Mouse" Sub-Routine
        ' sample program changing color only runs on QBASIC 4 or QBASIX 4.5
        update 2020
        ' First you will need to start QB/etc. with the /L option
        ' Type QB/L it files need QB.BI
        ' later the program needs ABSOLUTE.ASM
        ' also the file mouse.com
        ' SCREEN 0 is 639 X 199 H X V
        ' MIU Is only a name and can be changed AKA (Mouse In Use) or MIU
        ' This only shows a box in Screen 0 and other screens a Arrow
        '
        ' MOUSE 1 turned on Box or Arrow You can see it on the screen.
        ' MOUSE 2 turned off. You can no longer see it on the screen.
        ' MOUSE 3 status is returned into by using PEEK is used for reading
        ' B = PEEK(&HAAA) Current button being pressed (1 = left, 2 = right)
        ' h = PEEK(&HBBB) + PEEK(&HBBC) 256 Current Horizontal position on screen
        ' V = PEEK(&HCCC) + PEEK(&HCCD) 256 Current Vertical position on screen
        '
        ''''''''''''''''''''''' Enter your code here Initialize Program just
        use PC-BASIC ''''''''''''''''''''''''''''''''
        SCREEN 0, 0, 0: ' ### srceen can be 0 to 13
        COLOR 14, 1
        CLS
        PRINT "Press Esc to end": ' ### Demo showing how both Keyboard and
        mouse can work on same screen
        LOCATE 13, 28: PRINT "Press mouse botton on box >"; STRING$(4, 177);:'

        Demo box

        10 LOCATE 7, 10
        th = (INT(h / 36)): ' used for box not need for most games
        tv = (INT(V / 8)): ' v/8 gives about 25 lines
        PRINT B, V, h, tv, th: ' display information on the mouse
        ' Below shows button press at location 12, 12 and buttons L, M & R press
        IF th = 12 AND tv = 12 AND B = 1 THEN COLOR 0, 3
        IF th = 12 AND tv = 12 AND B = 4 THEN COLOR 15, 4
        IF th = 12 AND tv = 12 AND B = 2 THEN COLOR 2, 1
        Mouse 1 ' ### Display Arrow Only IF THEN need to be above this line
        A$ = INKEY$: ' ### note use GOTO at bottom only DO Not use IF A$=""
        This so mouse info is read data use data
        IF A$ = CHR$(27) THEN PRINT "END only used for demo": END
        Mouse 3 ' ### status is returned Button , Vert and Horiz position
        B = PEEK(&HAAA) ' Get values for: Buttons
        h = PEEK(&HBBB) + PEEK(&HBBC) 256 ' Horizontal position ( 2 bytes )
        V = PEEK(&HCCC) + PEEK(&HCCD) 256 ' Vertical position ( 2 bytes )
        GOTO 10

        ' " " " "
        ' " " " "
        ''''''''''''''''''''''' END OF program ''''''''''''''''''''''''''''''''
        ''''''''''''''''''''''' Mouse sub program ''''''''''''''''''''''''''''''''
        SUB Mouse (MIU) STATIC 'Define sub & parameter(s) passed.
        SHARED B, h, V 'Share variables with main sub.
        IF MIU = 1 THEN Crsr = 1 'Show Cursor.
        IF MIU = 2 AND Crsr = 0 THEN EXIT SUB 'Don't hide Cursor more than once.
        IF MIU = 2 AND Crsr = 1 THEN Crsr = 0 'Hide Cursor.
        POKE 100, 184: POKE 101, MIU: POKE 102, 0 'Poke machine code necessary for
        POKE 103, 205: POKE 104, 51: POKE 105, 137 'using the mouse into memory
        POKE 106, 30: POKE 107, 170: POKE 108, 10 'starting at offset 100 in the
        POKE 109, 137: POKE 110, 14: POKE 111, 187 'current segment. This code is
        POKE 112, 11: POKE 113, 137: POKE 114, 22 'then executed as a unit,
        via the
        POKE 115, 204: POKE 116, 12: POKE 117, 203 'statement " Call Absolute ".
        CALL Absolute(100) 'Call machine code.
        B = PEEK(&HAAA) 'Get values for: Buttons
        h = PEEK(&HBBB) + PEEK(&HBBC) 256 'Horizontal position ( 2 bytes )
        V = PEEK(&HCCC) + PEEK(&HCCD) 256 'Vertical position ( 2 bytes )
        END SUB 'End of sub-program.
        *

        Using a Mouse Basic

        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/pcbasic/discussion/programs/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/


        Using a Mouse Basic
        https://sourceforge.net/p/pcbasic/discussion/programs/thread/e75438739d/?limit=250#538d/08ec


        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/pcbasic/discussion/programs/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

         
  • Tuxtoo

    Tuxtoo - 2020-04-21

    Dave, This may be the ultimate solution for you as far as implementing the mouse in GW-BASIC. It comes from this page.

    Here is the listing:

    1 KEY OFF: CLS
    2 SCREEN 9
    3 FUNK = 1: GOSUB 200
    4 FUNK = 3: GOSUB 200
    5 LOCATE 1,1: PRINT B,H,V
    6 IF B = 1 THEN PSET(H,V),14
    7 IF B = 2 THEN CLS
    8 IF B = 3 OR INKEY$ <>"" THEN GOTO 10
    9 GOTO 3
    10 FUNK =2: GOSUB 200: END
    
    199 'Start of Mouse Sub-routine
    200 POKE 0,184: POKE 1,FUNK: POKE 2,0
    201 POKE 3,205: POKE 4,51: POKE 5,137
    202 POKE 6,30: POKE 7,170: POKE 8,10
    203 POKE 9,137: POKE 10,14: POKE 11,187
    204 POKE 12,11: POKE 13,137: POKE 14,22
    205 POKE 15,204:POKE 16,12: POKE 17,203
    206 AB = 0: CALL AB
    207 B=PEEK(&HAAA)
    208 H=PEEK(&HBBB) + PEEK(&HBBC) * 256
    209 V=PEEK(&HCCC) + PEEK(&HCCD) * 256
    210 RETURN
    

    This program is way beyond my capabilities, but it does work in GW-BASIC but not with PC-BASIC.

    Hope this helps.

    Stuart

     

    Last edit: Tuxtoo 2020-04-21
  • Smithdoor

    Smithdoor - 2020-04-21

    Thank you Stuart
    I just try in GW and PC Basic works great in GW Basic and your right in does not work on PC

    Thank you
    Dave

    I spent days looking for mouse program it was printed in the PC Magazine around 1985 the name (FUNK) was the Arthur as I remember.

     
  • Smithdoor

    Smithdoor - 2020-04-23

    Up date on notes for using a mouse on QB4

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.