Results 1 to 4 of 4

Thread: Interrupt call function for QBasic (specifically int 33h)->

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,909

    Interrupt call function for QBasic (specifically int 33h)->

    A mouse interrupt caller for QBasic:

    Code:
    ; Mouse interrupt call procedure for QBasic.
    push bp           ; Save previous bp.
    mov bp,sp         ; Set new bp.
    push si           ; Save si.
    mov si,[bp+6]     ; Load registers structure offset. 
    mov ax,[si]       ; Load values into CPU registers.
    mov cx,[si+2]     ;
    mov dx,[si+4]     ; 
    mov bx,[si+6]     ; 
    int 0x33          ; Call mouse interrupt.
    mov [si],ax       ; Save CPU registers to structure.
    mov [si+2],cx     ; 
    mov [si+4],dx     ; 
    mov [si+6],bx     ; 
    pop si            ; Restore si.
    pop bp            ; Restore bp.
    retf 2            ; Return and remove arguments from stack.
    Just compile it with Nasm or similar.

    A QBasic example:
    Code:
    DEFINT A-Z
    
    TYPE RegistersStr
     ax AS INTEGER
     cx AS INTEGER
     dx AS INTEGER
     bx AS INTEGER
    END TYPE
    
    DECLARE FUNCTION LoadWrapper$ ()
    DECLARE SUB CallInt33h ()
    
    DIM SHARED Int33h AS STRING
    DIM SHARED Registers AS RegistersStr
    
     CLS
     Int33h = LoadWrapper$
    
     Registers.ax = &H1
     Registers.cx = &H0
     Registers.dx = &H0
     Registers.bx = &H0
     CallInt33h
    
     DO
      Registers.ax = &H3
      Registers.cx = &H0
      Registers.dx = &H0
      Registers.bx = &H0
      CallInt33h
      LOCATE 1, 1: PRINT Registers.cx, Registers.dx, " ";
     LOOP WHILE INKEY$ = ""
     
    END
    
    SUB CallInt33h
     DEF SEG = VARSEG(Int33h)
     CALL ABSOLUTE(Registers, SADD(Int33h))
    END SUB
    
    FUNCTION LoadWrapper$
    DIM FileH AS INTEGER
    
     FileH = FREEFILE
     OPEN "Int33h.BIN" FOR INPUT LOCK READ WRITE AS FileH
     CLOSE FileH
    
     FileH = FREEFILE
     OPEN "Int33h.BIN" FOR BINARY LOCK READ WRITE AS FileH
      Int33h = INPUT$(LOF(FileH), FileH)
     CLOSE FileH
    
     LoadWrapper$ = Int33h
    END FUNCTION
    Tested with QBasic 1.1 and QuickBASIC 4.5. Probably works with QuickBASIC 7.1 and VBDos too.

    Changing it to handle other registers and interrupts should be simple. :-)

    New versions of programs originally for qb45 changed to work with QBasic will likely be released in the near future! :-)
    Last edited by Peter Swinkels; Jan 23rd, 2025 at 09:44 AM. Reason: I prefer hex values to set regs. :-)

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,909

    Re: Interrupt call function for QBasic (specifically int 33h)->

    Okay, I tested it with VBDOS, to make it work with there VARSEG needs to be changed to SSEG. Furthermore, the code works fine in the example I provided but it refuses to cooperate in when I try to integrate into my other programs. As near as I can tell the interrupt caller fails to read the parameters properly.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,909

    Re: Interrupt call function for QBasic (specifically int 33h)->

    QBasic is even more limited than I remembered:

    QuickBASIC 4.5 has the following that QBasic doesn't:
    1. A PCOPY statement that works with high-resolution text mode.
    2. The COMMAND$ function.
    3. More speed.
    4. A compiler.
    5. The ability to be extended with libraries.
    6. Better memory management.
    7. The SETMEM function.
    8. And probably a few more things I forgot to mention.

    *groans* - Oh well, I am working on something more substantial in QBasic that demonstrates using the mouse than the example I already posted.
    Last edited by Peter Swinkels; Jan 26th, 2025 at 07:36 AM. Reason: QBasic does support $DYNAMIC and $STATIC after all.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,909

    Re: Interrupt call function for QBasic (specifically int 33h)->

    Okay, here is a fully working program demonstrating how to use the mouse in QBasic:

    https://github.com/PeterSwinkels/QBDraw/

    As to updating my other projects to work with QBasic, I was a bit too optimistic about what was possible and am not going through with that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width