Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Ophelius

Pages: [1]
1
QB64 Discussion / Re: Strange mouse wheel results
« on: August 15, 2020, 05:45:23 pm »
I get the same behaviour, but I don't think it's the fault of QB64. I've seen it in other applications. My money is on the OS, or hardware. I'm using a Logitech M510 wireless, which has been dropped on the floor at least a couple times a day. I've never really looked into trying to fix it, just figured it was normal.

Hmm, that's weird. I tried it on 2 different mice, same thing, and I've never experienced this other than with the Qb64 editor and programs compiled with it

2
QB64 Discussion / Re: Strange mouse wheel results
« on: August 15, 2020, 03:07:05 pm »
Does pretty much the same thing for me when trying to scroll through code in the IDE. 1 or 2 click delay before things start happening, but it also does this in most games I play that make use of the scroll wheel. I always thought that was intended behavior or hardware behavior just in case the user bumped the scroll wheel so they did get constant jittering around.

Good that it's not just me. I've never seen behavior like that in any other game or software. It's a tad annoying in my opinion that the QB64 IDE does this, and also anything compiled with QB64 will do this. The mouse wheel should respond the 1st scroll click you make. It does seem like an internal counter is counting. No matter how slow you click, when that counter counts to 3 it allows clicks in that direction, and resets itself when changing direction.

Devs: Is this intentional? Is this a feature programmed into QB or is this a possible bug?

3
QB64 Discussion / Re: Strange mouse wheel results
« on: August 12, 2020, 08:32:13 pm »
Does this make a difference?

Code: QB64: [Select]
  1. DO: _LIMIT 100
  2.         Scroll = Scroll + _MOUSEWHEEL
  3.     LOOP
  4.     LOCATE 10, 20: PRINT Scroll
  5.     _DISPLAY
  6. LOOP UNTIL INKEY$ = CHR$(13) ' press Enter to quit
  7.  


No, same thing. One thing to note is the 1st scroll after the program starts takes 2 clicks to get going, not 3. But then it's back to 3 when changing directions as stated above

4
QB64 Discussion / Strange mouse wheel results
« on: August 12, 2020, 08:21:38 pm »
The mouse wheel doesn't work until at least 3 consecutive clicks up or down has been registered, then it works fine after each click in the same direction. If you change direction, it then takes another 3 clicks in that direction to get it started. If you go back and forth between up and down never clicking more than 2, it'll never register a wheel click. Example, this sequence won't cause any click: go up 2, down 2, up 1, down 1, up 2, down 1, up 2, down 2...this will never scroll the wheel. But as soon as you hit that 3rd click in the same direction it works in that direction every click.

I tried the simplest example in the help, same problem:
Code: QB64: [Select]
  1. DO: _LIMIT 100
  2.         Scroll = Scroll + _MOUSEWHEEL
  3.         LOCATE 10, 20: PRINT Scroll
  4.     LOOP
  5. LOOP UNTIL INKEY$ = CHR$(13) ' press Enter to quit
  6.  

It's not my mouse, the scrolling works fine everywhere else in Windows.

Any idea?

5
QB64 Discussion / Re: Screen flicker when switching active monitor
« on: August 09, 2020, 11:01:41 pm »
Thank you, but there's no flickering when the program is active, only for a brief moment when clicking away from the program onto my main monitor, and once more when clicking back into it.

I tried this example from the help:
Code: QB64: [Select]
  1. CONST MenuHeight = 200
  2.  
  3. SCREEN _NEWIMAGE(640, 480, 32)
  4. 'SLEEP 1
  5.     _LIMIT 30
  6.     DisplayMenu
  7.     k = _KEYHIT
  8.     IF k <> 0 THEN PRINT k,
  9. LOOP UNTIL k = 32 OR k = 27
  10.  
  11. SUB DisplayMenu
  12. STATIC init, MS_HW AS LONG
  13. IF NOT init THEN
  14.     init = -1
  15.     MS = _NEWIMAGE(640, MenuHeight, 32) 'MenuScreen image
  16.     D = _DEST: _DEST MS
  17.     CLS , &HFFAAAAAA 'background color gray
  18.     _PRINTSTRING (20, 2), "Menu Test" 'image text
  19.     MS_HW = _COPYIMAGE(MS, 33) 'create the MenuScreen_HardWare image
  20.     _FREEIMAGE MS
  21.     _DEST D
  22. _PUTIMAGE (0, 0)-(640, MenuHeight), MS_HW
  23. END SUB  
  24.  

and it does the same thing, so there's probably nothing I can do. It doesn't do this with other full screen programs when I click back and forth between monitors, so I thought it might of been how I was rendering. Thanks

6
QB64 Discussion / Screen flicker when switching active monitor
« on: August 09, 2020, 09:36:00 pm »
I have software I made that I use primarily on my 2nd monitor in full screen. When I click away to my main monitor, my program flickers black for 1/4 of sec, and flickers again when clicking back into it. Any way around this? It's not the end of the world, but it's slightly annoying.

Here's how I declare and render:

Init:
Code: QB64: [Select]
  1.    
  2.     SCREEN _NEWIMAGE(ScreenW, ScreenH, 32)
  3.  
  4.     VPage = _NEWIMAGE(ScreenW, ScreenH, 32)
  5.    
  6.     BG = _NEWIMAGE(ScreenW, ScreenH, 32)
  7.  
  8.  
  9.  

Mainloop:
Code: QB64: [Select]
  1.  
  2.     _DEST VPage
  3.     _PUTIMAGE , BG, VPage
  4.  
  5.     'main loop code
  6.  
  7.     _PUTIMAGE , VPage, 0
  8.  
  9.     _LIMIT 60
  10.  
  11.  

Any help would be appreciated. Thanks

7
QB64 Discussion / Re: Possible Variable-length strings in Types bugs
« on: August 09, 2020, 02:15:47 pm »
We have found that you can't assume Types initialized to 0 or "" for strings, maybe your code is assuming this?

If you say DIM x you can count on x being 0 to start or DIM s as string you can count on s ="", not so with variables in defined types.

Oh, also with a REDIM PRESERVE expanding an array, don't assume all is 0 or "".

There were places where I wasn't initializing the variables, I was assuming uninitialized Type variables would be 0 or "" like you said. That's probably why. But since I already reverted my code to what it was prior, I'll just keep what I have which works. Good to know for the future.Thanks

8
QB64 Discussion / Possible Variable-length strings in Types bugs
« on: August 09, 2020, 01:31:01 pm »
There's definitely some internal bugs when it comes to those. Before I found out this feature was added, I had several Types for various objects, but any strings were put in separate arrays like this:

'All the following code is just for examples

REDIM SHARED Obj(0 TO n) AS ObjType
REDIM SHARED ObjText(0 TO n) AS STRING

Both arrays always had the same numbers of elements so it was easy to reference the strings for whatever objects I needed. This worked great and was better than trying to use fixed-length strings in Types.

But when I found out about variable-length strings added to Types, I added the strings to my Types like this in order to clean up my code:

Type ObjType
   a as integer
   b as integer
   Text as string
End Type

REDIM SHARED Obj(0 to n) AS ObjType

After I did this, my program became possessed, weird bugs would happen, some that were even different if I ran the program at another time, even though no code changed.
They appear to be related to the internal memory of how QB handles the strings in the Types.
The bugs seems to always happen in places when I would get the Len of the string -> LEN(Obj(id).Text). I checked and the function is returning the correct length in all my tests, so there's something more internal going on. There seems to be memory overlaps, causing random elements and objects to change their behavior because memory locations are being corrupted.

Another thing that might be affecting it is I have several dozens of objects, each being REDIMed _PRESERVEd when they were created/added to the array, maybe that has something to do with it.

So after scratching my head all day looking if it was my own code, I came to the conclusion that it wasn't my code and put my code back to what it was, putting the strings back in separate arrays. After I did that, my program became normal again working perfectly.

Sorry I can't be more specific, the bugs were really random and weird, but I can tell it's some internal memory problem.


9
QB64 Discussion / using VB6 functions in QB64
« on: July 18, 2020, 11:11:55 pm »
Hi,
I read in the manual that it's possible to use external functions. I'm porting some code from an old Visual Basic 6 program, and would like to use in my QB64 program some of the functions that are built in with VB6.
One of them is called Format(), which says in the object browser it's part of VBA.Strings, and VBA is a library from VBA6.dll.

Any help would be appreciated to figure out how to use this VB6 function and more in QB64.

Thanks

10
QB64 Discussion / Re: Mouse Routines
« on: February 26, 2020, 03:25:04 pm »
Ooh ok I see, there's a buffer. Makes sense now. Thanks

11
QB64 Discussion / Re: Mouse Routines
« on: February 26, 2020, 02:45:23 pm »
I'm not sure what you mean by the program being in two loops.

QB64 buffers the mouse input. You can check if there is information in the buffer by verifying that _MOUSEINPUT is true (-1). If it is you can use any of the mouse commands to grab that instance in time. _MOUSEINPUT has been placed in a WHILE:WEND loop to keep reporting about the status of the buffer. When _MOUSEINPUT is finally false (0) the buffer has been cleared.

You see this happen in Windows when you start clicking on things and Windows can't keep up, but it still remembers where and what your mouse did, even when it was busy beforehand, and catches up with you.

What I mean is that in QB45, you were stuck on the Input line until the user pressed enter(caught in the input loop, program halts until enter is pressed). The example given shows an input, but somehow it's also checking the while:wend at the same time? Is this not procedural programming anymore?

12
QB64 Discussion / Re: Mouse Routines
« on: February 26, 2020, 12:29:45 pm »
Here's a little demo to show how the _MOUSEINPUT command can be used to your advantage:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32)
  2. INPUT "Click around on the screen a few times then press ENTER", a$
  3.         LINE -(_MOUSEX, _MOUSEY), _RGB32(255, 255, 255)
  4.         clicks = clicks + 1
  5.     END IF
  6. PRINT "You clicked"; clicks; " times"

Even when the INPUT command has taken over QB64 is monitoring the mouse.

Ok, I understand the advantage now, that is much better.
Edit: Although this does seem strange to me since the program is both in the Input loop and While:Wend loop at the same time? How is this possible? If it's in the documentation please point me to it so I can understand. Thanks

13
QB64 Discussion / Re: Mouse Routines
« on: February 26, 2020, 12:59:02 am »
Ah, I see, thanks guys. I guess it's just about wrapping my head around a new approach, I'm used to the old way which works for my coding styles. Either way, I was just curious, and the routines I posted are there and works fine if someone want's to use them.

14
QB64 Discussion / Re: Mouse Routines
« on: February 26, 2020, 12:39:40 am »
First, Welcome to the Forum :-)

Which "built-in" mouse routines are you referring to? These..

_MOUSEX, _MOUSEY, _MOUSEBUTTON(), _MOUSEINPUT, _MOUSEWHEEL, etc..?

These commands are a god-send compared to what was available back in the QB45 days. Could you provide some code examples of what you are referring to?

Yes, all of those. Maybe I just didn't put too much thought into it. Like this for example:

Code: QB64: [Select]
  1.   DO WHILE _MOUSEINPUT '      Check the mouse status
  2.   LOOP
  3.  

This will only get you the values when they change, and you can't just print _MouseX etc without using _Mouseinput first.
All the examples in the help for _MouseInput, _MouseButton, etc have all these Do:Loops where it can be a lot simpler. I've used a lot of libraries in the past and none managed mouse inputs this way, they all have simple functions that return the current values when called. Maybe I'm just not used to it. So what's the advantage?

15
QB64 Discussion / Mouse Routines
« on: February 26, 2020, 12:19:28 am »
Hi,
I just recently discovered QB64, and as a huge user of QB45 in the 90's and early 2000's, QB64 is just an amazing upgrade!
That being said, I've been toying around with the built-in mouse routines and omg are they inefficient! I don't see the logic in having it only update when it changes, it makes you need all these awkward loops to do simple things. Is there an advantage I'm not understanding?

Here's some routines I modified from online examples that use assembly to read the values at any time, not just when they change:

Code: QB64: [Select]
  1. FUNCTION MouseX% ()
  2.  
  3.     STATIC AsmMouseX%(), InitDone%
  4.  
  5.     IF InitDone% = 0 THEN
  6.         Asm$ = "B80300CD33891EAA0A890EBB0B8916CC0CCB"
  7.         Bytes% = LEN(Asm$) \ 2
  8.         REDIM AsmMouseX%(Bytes%)
  9.  
  10.         DEF SEG = VARSEG(AsmMouseX%(0))
  11.         FOR i% = 0 TO Bytes% - 1
  12.             POKE VARPTR(AsmMouseX%(0)) + i%, VAL("&H" + MID$(Asm$, (i% * 2) + 1, 2))
  13.         NEXT i%
  14.         DEF SEG
  15.         InitDone% = 1
  16.  
  17.     END IF
  18.  
  19.     DEF SEG = VARSEG(AsmMouseX%(0))
  20.     CALL ABSOLUTE(VARPTR(AsmMouseX%(0)))
  21.     DEF SEG
  22.  
  23.     MouseX% = (PEEK(&HBBB) + PEEK(&HBBC) * 256)
  24.  
  25.  
  26. FUNCTION MouseY% ()
  27.     STATIC AsmMouseY%(), InitDone%
  28.  
  29.     IF InitDone% = 0 THEN
  30.         Asm$ = "B80300CD33891EAA0A890EBB0B8916CC0CCB"
  31.         Bytes% = LEN(Asm$) \ 2
  32.         REDIM AsmMouseY%(Bytes%)
  33.  
  34.         DEF SEG = VARSEG(AsmMouseY%(0))
  35.         FOR i% = 0 TO Bytes% - 1
  36.             POKE VARPTR(AsmMouseY%(0)) + i%, VAL("&H" + MID$(Asm$, (i% * 2) + 1, 2))
  37.         NEXT i%
  38.         DEF SEG
  39.         InitDone% = 1
  40.  
  41.     END IF
  42.  
  43.     DEF SEG = VARSEG(AsmMouseY%(0))
  44.     CALL ABSOLUTE(VARPTR(AsmMouseY%(0)))
  45.     DEF SEG
  46.  
  47.     MouseY% = (PEEK(&HCCC) + PEEK(&HCCD) * 256)
  48.  
  49.  
  50. FUNCTION MouseB% ()
  51.     '0 = none, 1 = left, 2=right, 3=both
  52.     STATIC AsmMouseB%(), InitDone%
  53.  
  54.     IF InitDone% = 0 THEN
  55.         Asm$ = "B80300CD33891EAA0A890EBB0B8916CC0CCB"
  56.         Bytes% = LEN(Asm$) \ 2
  57.         REDIM AsmMouseB%(Bytes%)
  58.  
  59.         DEF SEG = VARSEG(AsmMouseB%(0))
  60.         FOR i% = 0 TO Bytes% - 1
  61.             POKE VARPTR(AsmMouseB%(0)) + i%, VAL("&H" + MID$(Asm$, (i% * 2) + 1, 2))
  62.         NEXT i%
  63.         DEF SEG
  64.         InitDone% = 1
  65.  
  66.     END IF
  67.  
  68.     DEF SEG = VARSEG(AsmMouseB%(0))
  69.     CALL ABSOLUTE(VARPTR(AsmMouseB%(0)))
  70.     DEF SEG
  71.  
  72.     MouseB% = PEEK(&HAAA)
  73.  
  74.  
  75. SUB MouseOn ()
  76.     STATIC AsmMouseOn%(), InitDone%
  77.  
  78.     IF InitDone% = 0 THEN
  79.         Asm$ = "B80100CD33891EAA0A890EBB0B8916CC0CCB"
  80.         Bytes% = LEN(Asm$) \ 2
  81.         REDIM AsmMouseOn%(Bytes%)
  82.  
  83.         DEF SEG = VARSEG(AsmMouseOn%(0))
  84.         FOR i% = 0 TO Bytes% - 1
  85.             POKE VARPTR(AsmMouseOn%(0)) + i%, VAL("&H" + MID$(Asm$, (i% * 2) + 1, 2))
  86.         NEXT i%
  87.         DEF SEG
  88.         InitDone% = 1
  89.     END IF
  90.  
  91.     DEF SEG = VARSEG(AsmMouseOn%(0))
  92.     CALL ABSOLUTE(VARPTR(AsmMouseOn%(0)))
  93.     DEF SEG
  94.  
  95.  
  96. SUB MouseOff ()
  97.     STATIC AsmMouseOff%(), InitDone%
  98.  
  99.     IF InitDone% = 0 THEN
  100.         Asm$ = "B80200CD33891EAA0A890EBB0B8916CC0CCB"
  101.         Bytes% = LEN(Asm$) \ 2
  102.         REDIM AsmMouseOff%(Bytes%)
  103.  
  104.         DEF SEG = VARSEG(AsmMouseOff%(0))
  105.         FOR i% = 0 TO Bytes% - 1
  106.             POKE VARPTR(AsmMouseOff%(0)) + i%, VAL("&H" + MID$(Asm$, (i% * 2) + 1, 2))
  107.         NEXT i%
  108.         DEF SEG
  109.         InitDone% = 1
  110.     END IF
  111.  
  112.     DEF SEG = VARSEG(AsmMouseOff%(0))
  113.     CALL ABSOLUTE(VARPTR(AsmMouseOff%(0)))
  114.     DEF SEG
  115.  
  116.  


To me this is way better, whenever you need the current mouse values you just use these functions:
Code: QB64: [Select]
  1. MouseOn
  2.    locate 1,1: Print MouseX, MouseY, MouseB
  3.  

What are your thoughts?

Pages: [1]