Author Topic: PCOPY a magician of video pages!  (Read 1500 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
PCOPY a magician of video pages!
« on: January 23, 2021, 09:15:11 am »
Hi Guys and Gals
my knowledge of QB64 goes on! Each day and each moment is a good source of knowledge.
Reading this thread my attention falls on the use of SCREENhttps://www.qb64.org/wiki/SCREEN and of PCOPYhttps://www.qb64.org/wiki/index.php/PCOPY.
Well what's about the last one?
I remember in QB45 that you can use PCOPY only for being video pages, so the number that you can use is depending from the SCREEN mode set in the code. A different value activates an error.

In QB64 PCOPY has got a special feature: when you use PCOPY with QB64 screen mode (32bit color) you can specify  any digit as name of a screen video page to use as canvas. It's a magic feature because you needn't create a _NEWIMAGE with the same dimensions and attribute (32bit color), PCOPY does it by itself.
What is bad? Only the wiki documentation that shows this feature in a demonstration code, but no words into the help.
Here wiki example 1 that shows this feature of PCOPY
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32) 'any graphics mode should work without setting up pages
  2. SetupCursor
  3. PRINT "Hello World!"
  4.   DO WHILE _MOUSEINPUT: LOOP 'main loop must contain _MOUSEINPUT  
  5. '       other program code    
  6.  
  7. SUB SetupCursor
  8. ON TIMER(0.02) UpdateCursor
  9.  
  10. SUB UpdateCursor
  11. PCOPY _DISPLAY, 100  'any page number as desination with the _DISPLAY function as source
  12. PSET (_MOUSEX, _MOUSEY), _RGB(0, 255, 0)
  13. DRAW "ND10F10L3F5L4H5L3"
  14. _DISPLAY                  'statement shows image
  15. PCOPY 100, _DISPLAY 'function return as destination page
  16. END SUB  
as you can see with my little mod
it needn't _DISPLAY , and you can copy among as many as you want (under the limit of RAM avaiable on the machine) screen video pages with no effort of declaring it before to use.
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32) 'any graphics mode should work without setting up pages
  2. SetupCursor
  3. PRINT "Hello World!"
  4.     DO WHILE _MOUSEINPUT: LOOP 'main loop must contain _MOUSEINPUT
  5.     '       other program code
  6.  
  7. SUB SetupCursor
  8.     ON TIMER(0.02) UpdateCursor
  9.     TIMER ON
  10.  
  11. SUB UpdateCursor
  12.     PCOPY 0, 100 ' _DISPLAY, 100 'any page number as desination with the _DISPLAY function as source
  13.     PSET (_MOUSEX, _MOUSEY), _RGB(0, 255, 0)
  14.     DRAW "ND10F10L3F5L4H5L3"
  15.     _DISPLAY 'statement shows image
  16.     PCOPY 100, 20
  17.     PCOPY 20, _DISPLAY 'function return as destination page
  18.  

Moreover PCOPY uses dimensions of screen active
run this code to see
Code: QB64: [Select]
  1. a& = _NEWIMAGE(640, 480, 32) 'any graphics mode should work without setting up pages
  2. b& = _NEWIMAGE(200, 100, 32)
  3.  
  4. PAINT (1, 1), _RGB32(50, 127, 222)
  5. PAINT (1, 1), _RGB32(150, 27, 22)
  6. SetupCursor
  7. PRINT "Hello World!"
  8.     DO WHILE _MOUSEINPUT: LOOP 'main loop must contain _MOUSEINPUT
  9.     '       other program code
  10.  
  11. SUB SetupCursor
  12.     ON TIMER(0.02) UpdateCursor
  13.     TIMER ON
  14.  
  15. SUB UpdateCursor
  16.     PCOPY 0, 100 ' _DISPLAY, 100 'any page number as desination with the _DISPLAY function as source
  17.     PSET (_MOUSEX, _MOUSEY), _RGB(0, 255, 0)
  18.     DRAW "ND10F10L3F5L4H5L3"
  19.     _DISPLAY 'statement shows image
  20.     PCOPY 100, 20
  21.     PCOPY 20, _DISPLAY 'function return as destination page
  22.  

PS _SOURCE doesn't seem to affect PCOPY working

Good news added to my knowledge.
Programming isn't difficult, only it's  consuming time and coffee

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: PCOPY a magician of video pages!
« Reply #1 on: January 23, 2021, 10:39:11 am »
I'm working on a further addition, also for graphics users, called PeteCOPY. While PCOPY flips pages on, PeteCOPY flips them off. It also returns your program to SCREEN 0, the way God intended it.

I'm actually a big flipping fan of PCOPY. I use it extensively for popups. Here is a very simple example: https://www.qb64.org/forum/index.php?topic=3530.msg128559#msg128559

Nice to this added enhancement, you posted, in QB64.

Thanks for posting it,

Pete

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