Author Topic: Problem whith PCOPY  (Read 7477 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Problem whith PCOPY
« Reply #15 on: September 25, 2020, 01:36:19 pm »
Hey just look at our avatar choices! ;-))

*counts colors in Bplus avatar*
1... 2... 3... 4... .... ....?

Yep need those 16m colors!
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Problem whith PCOPY
« Reply #16 on: September 25, 2020, 02:04:17 pm »
*counts colors in Bplus avatar*
1... 2... 3... 4... .... ....?

Yep need those 16m colors!

Yep need those shades! QB4.5 red and blue and that god awful green wouldn't do!

And don't let Pete get you with "Lay off the weed and learn to read!"

That's a Trump trick to cast dispersion's on others so people don't see how severely handicapped he is with Screen 0.

BTW I tried to count colors in your avatar, ha! Ha!
« Last Edit: September 25, 2020, 02:07:47 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem whith PCOPY
« Reply #17 on: September 25, 2020, 02:40:40 pm »
Quote
But not sure how to get the colors from screen 0 to translate back in a 32 bit screen mode.

Look in the SaveImage library.  It shows how to convert a text screen to a graphical screen.  (And then it saves it to a picture, which you can just LOADIMAGE and use, if you want to change resolutions, or not.)

Quick run down of the process:
USE SCREEN(), POINT (), or _MEMIMAGE to get the color and character of each block on the text screen.
Create a graphic screen of WIDTH * _FONTWIDTH, HEIGHT * _FONTHEIGHT size
Now just set foreground, background color and PRINT each character, in place, on your graphical screen.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Problem whith PCOPY
« Reply #18 on: September 25, 2020, 04:01:28 pm »
Quick run down of the process:
USE SCREEN(), POINT (), or _MEMIMAGE to get the color and character of each block on the text screen.
Create a graphic screen of WIDTH * _FONTWIDTH, HEIGHT * _FONTHEIGHT size
Now just set foreground, background color and PRINT each character, in place, on your graphical screen.

I kind of meant with the PEEK method where it just returns 0-255 for the color value. And even simpler, Screen 0 having a base of 0-15 colors.
Granted after becoming radioactive I only have a half-life!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem whith PCOPY
« Reply #19 on: September 25, 2020, 04:39:19 pm »
I kind of meant with the PEEK method where it just returns 0-255 for the color value. And even simpler, Screen 0 having a base of 0-15 colors.

It still returns a value from 0 to 255.  4 bits are foreground color, 3 bits are background, and the last bit toggles blinking on and off.  You’ll need to MOD and \ your return value to get the colors used.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Problem whith PCOPY
« Reply #20 on: September 25, 2020, 05:05:43 pm »
Hey everybody, cover your eyes. Pete's FLASHING again!

Code: QB64: [Select]
  1. SCREEN 0, 0, 0, 0
  2.     COLOR 7, 0: CLS
  3.     x0$ = "": x1$ = ""
  4.     f = f + 1: IF f > 30 THEN b = b + 1: f = 0
  5.     IF b > 15 THEN IF f = 30 THEN EXIT DO ELSE b = 0
  6.     COLOR 7, 0: PRINT "f ="; f, "b ="; b;
  7.     COLOR f, b
  8.     LOCATE 1, 40: PRINT "Pete..."
  9.     FOR i = 1 TO 47
  10.         x0$ = x0$ + CHR$(SCREEN(1, i))
  11.         x1$ = x1$ + CHR$(SCREEN(1, i, 1))
  12.     NEXT
  13.     PCOPY 0, 1
  14.     SLEEP
  15.     COLOR 7, 0: CLS
  16.     SLEEP
  17.     PCOPY 1, 0
  18.     LOCATE 2, 1
  19.     FOR i = 1 TO 47
  20.         IF ASC(MID$(x1$, i, 1)) \ 16 >= 8 THEN
  21.             ' Flashing
  22.             'PRINT ASC(MID$(x1$, i, 1)) MOD 16 + 16, ASC(MID$(x1$, i, 1)) \ 16 - 8
  23.             COLOR ASC(MID$(x1$, i, 1)) MOD 16 + 16, ASC(MID$(x1$, i, 1)) \ 16 - 8
  24.         ELSE
  25.             ' Non-Flashing
  26.             COLOR ASC(MID$(x1$, i, 1)) MOD 16, ASC(MID$(x1$, i, 1)) \ 16
  27.         END IF
  28.         PRINT MID$(x0$, i, 1);
  29.     NEXT
  30.     COLOR 7, 0
  31.     SLEEP
  32.  

Just to prove there is a way in SCREEN 0 to differentiate flashing from non-flashing characters. I apologize in advance if I'm off on any of the color parameters. I didn't want to spend much time on this, so I didn't check it for accuracy. It's just to demonstrate the method I'd use to detect flashing colors on the screen, and preserve them, which PCOPY will not do on its own.

Just hold a key down to "flash" through all the color combos. When f > 15 "Pete..." will flash. The second line "Pete..." will flash as well, which is possible only because of the conditional color algorithm. Let me know if it needs any tweaking or if anything was missed. I may have actually made something like this 20+ years ago for a screen saver routine.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Problem whith PCOPY
« Reply #21 on: September 25, 2020, 05:15:53 pm »
It still returns a value from 0 to 255.  4 bits are foreground color, 3 bits are background, and the last bit toggles blinking on and off.  You’ll need to MOD and \ your return value to get the colors used.  ;)

But no way to directly translate the base(foreground) color to 32bit mode.
which seems odd since we can ,sort of, use 32bit colors in screen 0
COLOR _RGB(255,0,0)

least I believe _RGB() finds the nearest color in the available palette. But we cant reverse the process, presumably cause 32bit modes have no palette to compare from. However QB45 did have a base palette to work with, so maybe we could add that under the hood and pull the RGB values off of that internal palette?

It would make it easier to translate old QB45 code to QB64 if someone wanted to make use of a larger screen but didn't want to have to rewrite everything. Just change the SCREEN line but not have to worry about going through the code and changing all the COLOR statements. Yes probably a nitch scenario.
An augmentation of the COLOR statement, if used in 32bit mode to automatically choose from the palette if a value 0-255 is used?
Granted after becoming radioactive I only have a half-life!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem whith PCOPY
« Reply #22 on: September 25, 2020, 05:35:39 pm »
But no way to directly translate the base(foreground) color to 32bit mode.
which seems odd since we can ,sort of, use 32bit colors in screen 0
COLOR _RGB(255,0,0)

least I believe _RGB() finds the nearest color in the available palette. But we cant reverse the process, presumably cause 32bit modes have no palette to compare from. However QB45 did have a base palette to work with, so maybe we could add that under the hood and pull the RGB values off of that internal palette?

It would make it easier to translate old QB45 code to QB64 if someone wanted to make use of a larger screen but didn't want to have to rewrite everything. Just change the SCREEN line but not have to worry about going through the code and changing all the COLOR statements. Yes probably a nitch scenario.
An augmentation of the COLOR statement, if used in 32bit mode to automatically choose from the palette if a value 0-255 is used?

Use _RED, _GREEN, _BLUE.

For example, SCREEN 0 High Intensity Blue might be 125, 125, 255.  (I don’t remember the exact values, but you can get them with the command.)

Then use _RGB32() with those values to convert to a 32-bit color . 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem whith PCOPY
« Reply #23 on: September 25, 2020, 05:39:04 pm »
Quick demo:

SCREEN 0
FOR i = 0 TO 15
    PRINT I, _RED(I), _GREEN(I), _BLUE(I)
NEXT
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Problem whith PCOPY
« Reply #24 on: September 26, 2020, 01:43:17 am »
Hey everybody, cover your eyes. Pete's FLASHING again!

Code: QB64: [Select]
  1. SCREEN 0, 0, 0, 0
  2.     COLOR 7, 0: CLS
  3.     x0$ = "": x1$ = ""
  4.     f = f + 1: IF f > 30 THEN b = b + 1: f = 0
  5.     IF b > 15 THEN IF f = 30 THEN EXIT DO ELSE b = 0
  6.     COLOR 7, 0: PRINT "f ="; f, "b ="; b;
  7.     COLOR f, b
  8.     LOCATE 1, 40: PRINT "Pete..."
  9.     FOR i = 1 TO 47
  10.         x0$ = x0$ + CHR$(SCREEN(1, i))
  11.         x1$ = x1$ + CHR$(SCREEN(1, i, 1))
  12.     NEXT
  13.     PCOPY 0, 1
  14.     SLEEP
  15.     COLOR 7, 0: CLS
  16.     SLEEP
  17.     PCOPY 1, 0
  18.     LOCATE 2, 1
  19.     FOR i = 1 TO 47
  20.         IF ASC(MID$(x1$, i, 1)) \ 16 >= 8 THEN
  21.             ' Flashing
  22.             'PRINT ASC(MID$(x1$, i, 1)) MOD 16 + 16, ASC(MID$(x1$, i, 1)) \ 16 - 8
  23.             COLOR ASC(MID$(x1$, i, 1)) MOD 16 + 16, ASC(MID$(x1$, i, 1)) \ 16 - 8
  24.         ELSE
  25.             ' Non-Flashing
  26.             COLOR ASC(MID$(x1$, i, 1)) MOD 16, ASC(MID$(x1$, i, 1)) \ 16
  27.         END IF
  28.         PRINT MID$(x0$, i, 1);
  29.     NEXT
  30.     COLOR 7, 0
  31.     SLEEP
  32.  

Just to prove there is a way in SCREEN 0 to differentiate flashing from non-flashing characters. I apologize in advance if I'm off on any of the color parameters. I didn't want to spend much time on this, so I didn't check it for accuracy. It's just to demonstrate the method I'd use to detect flashing colors on the screen, and preserve them, which PCOPY will not do on its own.

Just hold a key down to "flash" through all the color combos. When f > 15 "Pete..." will flash. The second line "Pete..." will flash as well, which is possible only because of the conditional color algorithm. Let me know if it needs any tweaking or if anything was missed. I may have actually made something like this 20+ years ago for a screen saver routine.

Pete

Now Modify your program to make use of a Dark Grey in the background. Surely with your mighty Screen 0 knowledge you can.
Granted after becoming radioactive I only have a half-life!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Problem whith PCOPY
« Reply #25 on: September 26, 2020, 02:25:25 am »
Code: QB64: [Select]
  1. OUT &H3C8, 0
  2. OUT &H3C9, 10
  3. OUT &H3C9, 10
  4. OUT &H3C9, 10
  5. msg$ = "Cobalt's Sofa Kingdom :D"
  6. COLOR 15, 0: PRINT msg$

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem whith PCOPY
« Reply #26 on: September 26, 2020, 02:39:59 am »
When Pete says he likes to do things the hard way, he’s not kidding.

Why use something slow and hard to decipher, like: ASC(MID$(x1$, i, 1))

You know, you can just use ASC(x1$, i), and accomplish the exact same thing...

If there’s ever a need for an obsolete, overly-complicated solution to a simple problem, Pete’s the guy to go to, to ask for advice on it!
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Problem whith PCOPY
« Reply #27 on: September 26, 2020, 01:23:40 pm »
Code: QB64: [Select]
  1. OUT &H3C8, 0
  2. OUT &H3C9, 10
  3. OUT &H3C9, 10
  4. OUT &H3C9, 10
  5. msg$ = "Cobalt's Sofa Kingdom :D"
  6. COLOR 15, 0: PRINT msg$

Pete

Something tells me your method there wont produce these results.
« Last Edit: September 26, 2020, 02:09:42 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Problem whith PCOPY
« Reply #28 on: September 26, 2020, 02:54:38 pm »
Code: QB64: [Select]
  1. PALETTE 7, 56
  2. msg$ = "Bright white text on a dark grey background, on a black screen..."
  3. COLOR 15, 7: PRINT msg$
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/