Qbasicnews.com

Full Version: Mouse pointer management in SCREEN 12 mode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to code a cursor management for SCREEN 12 mode, for a young progger in France.

I thought it would be easy, but this code just won't work ! All I have is a blank mouse pointer (i.e. 100% invisible).

Does the problem come from the code, or from the mouse driver (I run XP Pro)


Code:
DATA 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1
DATA 0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0
DATA 0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0
DATA 0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0
DATA 0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
DATA 0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0
DATA 0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0
DATA 0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0
DATA 0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
DATA 0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0
DATA 0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0
DATA 0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0
DATA 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1

DIM Cursor$(63)
FOR m% = 0 TO 31
Byte% = 0
FOR p% = 0 TO 7
READ Bit%
Byte% = Byte% + Bit% * 2 ^ (7 - p%)
NEXT p%
Cursor$(m%) = CHR$(Byte%)
NEXT m%

Regs.ax = 9
Regs.bx = 8 'Hot spot, horizontal
Regs.cx = 8 'Hot spot, horizontal
Regs.dx = VARSEG(Cursor$)
Regs.dx = VARPTR(Cursor$)
CALL INTERRUPTx(&H33, Regs, Regs)
1.- Notice you are dimensioning an array of 63 strings and setting one char in each string. Unfortunately a string array is just an array of pointers to strings. The real strings are in a different place and probably are not contiguous.
If you want to use strings, to work byte to byte, use a fixed length string:
Code:
DIM a$ as string*64
(don't know if QB will accept the $ after the name of the string)

2.- AFAIK the array must be 64 bytes, the first 32 bytes must be filled with a mask (all ones will work) and the remaining 32 bytes contains the real drawing. This is the way it worked for me the only time I tried.
I have corrected the cursor as string*64, but I have a strange result: at first run, I have the standard arrow. Second run, I try to load a custom pointer, and I have only a pixel as pointer...

Third run, I do not load the custom pointer, and I still have only a pixel, even after a driver reset via function 0.

I think the XP driver is not complient...
You are doing this:

Code:
Regs.dx = VARSEG(Cursor$)
Regs.dx = VARPTR(Cursor$)

Is it right to rewrite a register before calling the interrupt???
You're doing a couple things wrong. First, you need 2 masks, one for the screen and one for the cursor. Second, like Antoni said, you can't use string arrays. If you want to use variable-length strings you need to use SADD as well. Finally, like ak00ma said, you need to set es to the segment, not dx. (Probably just a typo on your part.)

Here's code that works...mostly. The cursor's fine, but the hotspot is screwey for some reason.

Code:
DEFINT A-Z
'$INCLUDE: 'QB.BI'

'Screen mask
DATA 0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0
DATA 1,0,1,1,1,1,1,0,1,1,1,1,1,1,0,1
DATA 1,1,0,1,1,1,1,0,1,1,1,1,1,0,1,1
DATA 1,1,1,0,1,1,1,0,1,1,1,1,0,1,1,1
DATA 1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,1
DATA 1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1
DATA 1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1
DATA 1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1
DATA 1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1
DATA 1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1
DATA 1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1
DATA 1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,1
DATA 1,1,1,0,1,1,1,0,1,1,1,1,0,1,1,1
DATA 1,1,0,1,1,1,1,0,1,1,1,1,1,0,1,1
DATA 1,0,1,1,1,1,1,0,1,1,1,1,1,1,0,1
DATA 0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0

'Cursor mask
DATA 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1
DATA 0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0
DATA 0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0
DATA 0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0
DATA 0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
DATA 0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0
DATA 0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0
DATA 0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0
DATA 0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
DATA 0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0
DATA 0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0
DATA 0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0
DATA 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1

SCREEN 12

FOR Mask = 1 TO 2
  FOR y = 0 TO 15
    Byte1 = 0
    FOR x = 0 TO 7
      READ Bit
      IF Bit THEN Byte1 = Byte1 + 2 ^ (7 - x)
    NEXT
    Byte2 = 0
    FOR x = 0 TO 7
      READ Bit
      IF Bit THEN Byte2 = Byte2 + 2 ^ (7 - x)
    NEXT
    Cursor$ = Cursor$ + CHR$(Byte2) + CHR$(Byte1)
  NEXT
NEXT


DIM Regs AS RegTypeX
Regs.ax = 0
CALL INTERRUPTX(&H33, Regs, Regs)

Regs.ax = 1
CALL INTERRUPTX(&H33, Regs, Regs)

Regs.ax = 9
Regs.bx = 8 'Hot spot, horizontal
Regs.cx = 8 'Hot spot, vertical
Regs.es = VARSEG(Cursor$)
Regs.dx = SADD(Cursor$)
CALL INTERRUPTX(&H33, Regs, Regs)
I admit I did not really take time to debug what I had done... the typo on "es" is just an example...