Author Topic: [Bug ?!] _RGB32 issue with CONST  (Read 3219 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
[Bug ?!] _RGB32 issue with CONST
« on: May 08, 2019, 07:15:52 am »
Hi guys
while I'm trying to code with QB64 version 1.3 96937f0  I have got this issue....

I can affirm that _RGBA32 and CONST are good friends and code works fine  but it is not the same about CONST and _RGB32

well CPR (copy->paste->run) this code
Code: QB64: [Select]
  1. CONST YVel = 5, Hscreen = 400, Wscreen = 600, Rball = 10, MaxBall = 10
  2. CONST Blu = _RGB32(0, 0, 255), Green = _RGB32(0, 255, 0)
  3. DIM Yball(1 TO MaxBall) AS INTEGER, A AS LONG, W AS INTEGER, CountBall AS INTEGER
  4. A = _NEWIMAGE(Wscreen, Hscreen, 32)
  5. IF A < -2 THEN SCREEN A ELSE PRINT "Error in Screen setup"
  6.  
  7.  
  8.     K = INKEY$
  9.     CLS
  10.     LOCATE 1, 1: PRINT " press Space to shoot, Esc to quit      Countball="; CountBall
  11.     PRINT " to test the issue press space while balls arrive to the top of screen"
  12.     FOR W = 1 TO MaxBall STEP 1
  13.         IF Yball(W) > 0 THEN
  14.             CIRCLE (400, Yball(W)), Rball, Blu
  15.             PAINT STEP(0, 0), Blu, Blu
  16.             LINE (200 - 1, Yball(W) - 1)-STEP(Rball + 2, Rball + 2), Green, B
  17.             LINE (200, Yball(W))-STEP(Rball, Rball), Blu, BF
  18.  
  19.             Yball(W) = Yball(W) - YVel
  20.             IF Yball(W) <= 0 THEN IF CountBall > 0 THEN CountBall = CountBall - 1
  21.         END IF
  22.     NEXT W
  23.     IF K = " " THEN
  24.         IF CountBall < MaxBall THEN
  25.             CountBall = CountBall + 1
  26.             Yball(CountBall) = (Hscreen - (2 * Rball))
  27.         END IF
  28.     END IF
  29.     _LIMIT 10
  30. LOOP UNTIL K = CHR$(27)
  31.  
works fine Yes!

now please CPR this one code
Code: QB64: [Select]
  1. CONST YVel = 5, Hscreen = 400, Wscreen = 600, Rball = 10, MaxBall = 10
  2. CONST Blu = _RGB32(0, 0, 255)
  3. CONST Green = _RGB32(0, 255, 0)
  4. DIM Yball(1 TO MaxBall) AS INTEGER, A AS LONG, W AS INTEGER, CountBall AS INTEGER
  5. A = _NEWIMAGE(Wscreen, Hscreen, 32)
  6. IF A < -2 THEN SCREEN A ELSE PRINT "Error in Screen setup"
  7.  
  8.  
  9.     K = INKEY$
  10.     CLS
  11.     LOCATE 1, 1: PRINT " press Space to shoot, Esc to quit      Countball="; CountBall
  12.     PRINT " to test the issue press space while balls arrive to the top of screen"
  13.     FOR W = 1 TO MaxBall STEP 1
  14.         IF Yball(W) > 0 THEN
  15.             CIRCLE (400, Yball(W)), Rball, Blu
  16.             PAINT STEP(0, 0), Blu, Blu
  17.             LINE (200 - 1, Yball(W) - 1)-STEP(Rball + 2, Rball + 2), Green, B
  18.             LINE (200, Yball(W))-STEP(Rball, Rball), Blu, BF
  19.  
  20.             Yball(W) = Yball(W) - YVel
  21.             IF Yball(W) <= 0 THEN IF CountBall > 0 THEN CountBall = CountBall - 1
  22.         END IF
  23.     NEXT W
  24.     IF K = " " THEN
  25.         IF CountBall < MaxBall THEN
  26.             CountBall = CountBall + 1
  27.             Yball(CountBall) = (Hscreen - (2 * Rball))
  28.         END IF
  29.     END IF
  30.     _LIMIT 10
  31. LOOP UNTIL K = CHR$(27)
  32.  
and you can see the issue...
_RGB32 need a own single row of code to work with CONST
see attachment to sum of issue
  [ You are not allowed to view this attachment ]  
Thanks to read and try.
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: [Bug ?!] _RGB32 issue with CONST
« Reply #1 on: May 08, 2019, 10:40:38 am »
That's funny, for me, no blue in first:
Code: QB64: [Select]
  1. CONST Blu = _RGB32(0, 0, 255), Green = _RGB32(0, 255, 0)

and the 2nd works fine:
Code: QB64: [Select]
  1. CONST Blu = _RGB32(0, 0, 255)
  2. CONST Green = _RGB32(0, 255, 0)
  3.  

Probably because you need one variable per CONST:
Code: QB64: [Select]
  1. CONST Blu = _RGB32(0, 0, 255): CONST Green = _RGB32(0, 255, 0)  'works
  2.  

Append: Looked up CONST. And I guess you should be able to do more than one on a line with just a comma.
« Last Edit: May 08, 2019, 11:01:26 am by bplus »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: [Bug ?!] _RGB32 issue with CONST
« Reply #2 on: May 08, 2019, 06:35:48 pm »
has to due with the ALPHA option in _RGB32
if you do this it will work

CONST Blu = _RGB32(0, 0, 255, 255), Green = _RGB32(0, 255, 0, 255)

in QB64 v1.1 it wasn't necessary to fill all 4 options out so it must have to due with one of the tweaks done to the _RBG\_RGB32 routines for V1.3
Granted after becoming radioactive I only have a half-life!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: [Bug ?!] _RGB32 issue with CONST
« Reply #3 on: May 30, 2019, 06:59:15 pm »
Hi Bplus
sorry for this necromancy but I fall today in this experience....

about your right suggestion
Quote
Probably because you need one variable per CONST:
Code: QB64 [Select]
CONST Blu = _RGB32(0, 0, 255): CONST Green = _RGB32(0, 255, 0)  'works

well it seems that the issue comes back as warning "Invalid name on current line "if we use three definitions on the same line of code!
copy and paste in your QB64Ide this code to see
Code: QB64: [Select]
  1. CONST CPlanet = _RGBA32(238, 111, 89, 255): CONST CMoon = _RGBA32(100, 227, 11, 255): CONST CBlack = _RGBA32(0, 0, 10, 255)
  2.  

and with this my zombie I say you good coding this is just a feedback.
Thanks to read

Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: [Bug ?!] _RGB32 issue with CONST
« Reply #4 on: May 30, 2019, 07:34:17 pm »
And yet this works!
Code: QB64: [Select]
  1. CONST CPlanet = _RGBA32(238, 111, 89, 255), CMoon = _RGBA32(100, 227, 11, 155), CBlack = _RGBA32(0, 0, 50, 255)
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. CIRCLE (100, 100), 30, CPlanet
  4. CIRCLE (200, 200), 10, CMoon
  5. CIRCLE (300, 200), 105, CBlack
  6.  

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: [Bug ?!] _RGB32 issue with CONST
« Reply #5 on: May 31, 2019, 07:26:18 am »
Great this one experience!

now it works also old error!  :D I cannot believe!
I have done no adjournment about QB64 or Windows 10 and I'd got this news

please copy and paste...
Code: QB64: [Select]
  1. 'CONST CoPlanet = _RGBA32(238, 111, 89, 255): CONST CoMoon = _RGBA32(100, 227, 11, 255): CONST CoBlack = _RGBA32(0, 0, 10, 255)
  2. CONST CoPlanet = _RGBA32(238, 111, 89, 255): CONST CoMoon = _RGBA32(100, 227, 11, 255), CoBlack = _RGBA32(0, 0, 10, 255)
  3.  
  4. CONST CPlanet = _RGB32(238, 111, 89, 255), CMoon = _RGB32(100, 227, 11, 155), CBlack = _RGB32(100, 0, 50, 255)
  5. SCREEN _NEWIMAGE(800, 600, 32)
  6. CIRCLE (100, 100), 30, CPlanet
  7. CIRCLE (200, 200), 10, CMoon
  8. CIRCLE (300, 200), 105, CBlack
  9.  
now also _RGB32 works fine just with the comma separator!
Thanks for reply.
Programming isn't difficult, only it's  consuming time and coffee

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: [Bug ?!] _RGB32 issue with CONST
« Reply #6 on: June 12, 2019, 11:24:49 am »
Why would three CONST separated by colons ":" be any different than having three CONST on different lines?

I always thought ":" was equivalent to a new line.
« Last Edit: June 12, 2019, 12:09:55 pm by Raven_Singularity »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: [Bug ?!] _RGB32 issue with CONST
« Reply #7 on: June 12, 2019, 11:58:42 am »
Why woul three CONST separated by colons ":" be any different than having three CONST on different lines?

I always thought ":" was equivalent to a new line.

CONST is an internal replacement type routine, and with the colon parsing, it’s a little buggy with self referential calls on the same line.

CONST x = 3: CONST y = x

The above line of code will probably glitch out on you, as QB64 tries to process it.  The x = 3 should register a CONST value of x, but it doesn’t update those definitions until it gets to the end of the line, so the second segment will see y = x as being an undefined variable reference.

If colons were handled as separate lines, we wouldn’t see this glitch, but they’re not.  They’re more indicators of segmenting a line of code into multiple commands.  Think of the following:

x = 3: y = 4: PRUNT x + y

Whoooops!!  I misspelled PRINT!  Which LINE is that code on, when the error pops up at the bottom line of the IDE?

It’s on line 1, not line 3. 

*************************

Generally speaking, CONST should work without any glitches in relation to colons, but it current doesn’t.  Since it’s generally an easy work around (just separate the lines), and I’ve been occupied with other things in life, it hasn’t been a high priority fix on my list of things to do.

Turn

CONST x = 3: CONST y = x

into:

CONST x = 3
CONST y = x

And the glitch should go away, when it presents itself.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: [Bug ?!] _RGB32 issue with CONST
« Reply #8 on: June 12, 2019, 12:12:21 pm »
^ Thanks for the detailed explanation.  Fascinating.  I can see the issue with line numbering now.