Author Topic: Proposed Enhancements To QB64  (Read 3664 times)

0 Members and 1 Guest are viewing this topic.

Offline fatman2021

  • Newbie
  • Posts: 11
Proposed Enhancements To QB64
« on: July 21, 2017, 03:07:16 pm »
Think of your monitor as a glass window, through which you can view whatever QB64 displays on its own "screen".
The screen would be used to show QB64 images is not the same as your monitor, because an QB64 screen should be able
to be changed in many different ways, while the glass window of the monitor remains firmly fixed.

Whenever an QB64 program is run, a screen area should be automatically set up to display the results of that
program. This would be known as the "default" screen, and it forms the standard display area that would be used for all
normal drawing operations. The default screen should be given the identity number zero. The screen zero would be 640 pixels
wide, 400 pixels high and and would display 16 different colors.

Apart from the default screen, we should be able to set up seven more screens in a QB64 program, and each of these
new screens should be given an identity number from 1 to 7. When a new screen is set up, it would be "opened", and
when this is done, its individual width, height, number of colors and pixel size would also be defined.

Although the default screen would be 640 pixels wide, you would be able to double this to 1280 pixels across the screen.
When the screen is 640 pixels wide it would be in low resolution, or "Lowres", for short. If this is changed to 1280
pixels wide, the screen would be in high resolution, known as "Hires".

SCREEN OPEN (open a new screen)

Syntax: Screen Open number,width,height,colors,pixMde

To open a new screen give the SCREEN OPEN command, followed by these parameters:

Number - the identification number of the new screen, ranging from 0 to 7. If a screen with this number already
         exists, it would be completely replaced by this new screen.

Width  - sets up the number of pixels that will make up the width of the new screen. There would be no problem
         in opening a screen that is wider than the physical limit of the monitor, and extra-wide screens would
         be manipulated by the SCREEN OFFSET command. The widest possible screen would be 5120 pixels across, from
         zero to 5119

Height - holds the number of pixels that make up the height of the screen. Like the width parameter, this can be larger
         than the visible screen height to a maximum of 2880 pixels, and scrolled into view. Screens with oversized
         widths and heights can be used with all of the normal screen techniques.

Colors - sets the number of colors to be used for the new screen. The choice for this number is normally 2,4,8,
         16,256, 16-bit, 24-bit, or 32-bit. There are three special screens that can make use of 32 or 64 colors with
         Extra Half Bright mode screens, and 4096 colors Hold And Modify mode screens.

pixMde - is a choice of the width of the pixel points on the screen. Lowres is the normal status, allowing 640 pixels to
         be displayed across the screen, at any one time. Hires halves the width of each pixel, and so allows 1280 to
         be displayed.

LOWRES (set screen mode to 640 pixels wide)

Code: QB64: [Select]
  1. Screen Open number,width,height,colors,Lowres
  2.  

HIRES (set screen mode to 1280 pixels wide)

Code: QB64: [Select]
  1. Screen Open number,width,height,colors,Hires
  2.  

When the default screen is automatically opened, screen 0 would be the equivalent to the following setting:

Code: QB64: [Select]
  1. Screen Open 0,640,480,16,Lowres
  2.  

To open screen number 1 as an oversize high-resolution screen with eight colors, you would use the following:

Code: QB64: [Select]
  1. Screen Open 1,1280,1080,4096,Hires
  2.  

This the following routine would opens all eight available screens and brings them into view:

Code: QB64: [Select]
  1. Curs Off : Cls 13: Paper 13
  2. Print : Center "Hello, I'm SCREEN 0"
  3. For S=1 To 7
  4. Screen Open S,320,20,16,Lowres
  5. Curs Off : Cls S+2 : Paper S+2
  6. Center "And I am SCREEN"+Str$(S)
  7. Screen Display S,,50+S*25,,8
  8.  

SCREEN CLOSE (erase a screen)

Syntax: Screen Close number

The SCREEN CLOSE command would be used to erase a screen and free the memory it was using for other programming
needs. Simply specify the screen number to be deleted.

DEFAULT (re-set to the default screen)

The DEFAULT instruction would closes all currently opened screens and restores the display back to the original
default setting.

AUTO VIEW ON
AUTO VIEW OFF

The Auto View instructions would toggle viewing mode on and off.

The SCREEN OPEN could be used to create a new screen, the screen would usually be displayed at once. This may be
inconvenient during the initialisation stages of a program, in which case the AUTO VIEW OFF command would be
used to disable this automatic display system. Screens would then be updated at a convenient point, using the VIEW
instruction. To re-activate the automatic screen updating system, you would use the AUTO VIEW ON command.

VIEW (display current screen setting)

When the AUTO VIEW OFF instruction is engaged, VIEW could be used to display any changes that have been made
to the current screen settings, and they would be displayed at the next vertical blank period following the VIEW
command.

Once a screen has been opened, it would be positioned and moved anywhere on the monitor. This means that screens
would be made to bounce, slip, slide, flip over, sink out of sight and behave in all sorts of bizarre ways. This
would also means that screens could overlap or be displayed above one another, and so several different screen modes
would be shown at once in separate areas of the display.

SCREEN DISPLAY (position a screen)

Syntax1: Screen Display number
Syntax2: Screen Display number,x,y, width,height

To position a screen, the SCREEN DISPLAY command would be used, followed by these parameters:

Number - refers to the number of the screen to be displayed, from 0 to 7. All or any of the other parameters could be
         omitted, but the relevant commas must be included.

x,y    - coordinates would given as "hardware" coordinates, which refer to physical positions on the monitor, not the
         area that would be used by QB64 screens. These set the position from which your QB64 screen  displayed on
         the monitor.

X coordinates would range from 0 to 448, and they would be automatically rounded down to the nearest 16-pixel boundary.
Only the positions from 112 to 432 would actually visible on the monitor, so avoid using an x-coordinate below 112.

Y coordinates would range between 0 and 312, but because every monitor displays a slightly different visible area, it
would be sensible to keep the range between 30 and 300. A small amount of experimenting will reveal what suits your own
system.

Width  - would set the width of the screen in pixels. If this is different from the original setting, only a part of the
         image would be shown, starting from the top left-hand corner of the screen. It would also be rounded down to the
         nearest 16 pixels.

Height - would be used to set the height of the screen in exactly the same way as the width. If any of the optional
         parameters are left out, the default settings will be applied automatically.

Setting up Screens For example, to display screen zero, keeping its original width and height, this line would be used:

Code: QB64: [Select]
  1. Screen Display 0,112,40,,
  2.  

Only one screen at a time would be shown on each horizontal line of the display, but several screens would be placed on
top of one another. If screens are placed next to each other, in other words if they are sewn together to make a
continuous display, there would be one line of pixels where of the screens meet that becomes "dead".

One way of getting over this dead zone is to create an extra-large screen that is bigger than the monitor display, and
then move the visible area around inside its boundaries. When using extra-large screens, the area to be viewed is set
with the SCREEN OFFSET command.

SCREEN OFFSET(offset screen at hardware coordinates)

Syntax: Screen Offset number,x,y

The SCREEN OFFSET command would be followed by the number of the screen to be displayed, then the x,y-coordinates
of the "offset", which would point to where the top left-hand corner of the visible display would to start, measured from
the top left-hand corner of the extra-large screen.

The visible area would be Moved around the extra-large screen by changing the offset coordinates, and some very
smooth scrolling effects would be achieved. These would be used for background graphics in computer games, as well as
more serious applications like route finders or star constellations.

SCREEN CLONE(clone a screen)

Syntax: Screen Clone number

To create an identical copy of the current screen, and assign this new "clone" with a new screen number, the SCREEN CLONE
command would be used followed by the destination screen number. Here is an example of a multi-cloned screen:

Code: QB64: [Select]
  1. Screen Open 0,320,20,4,Lowres
  2. Flash Off
  3. Screen Display 0,,70,,
  4. For S=1 To 7
  5. Screen Clone S
  6. Screen Display S,,S*20+70,,
  7. Print "Start typing";
  8. If A$<>"" Then Print A$;
  9.  

Screen cloning is an ideal technique for two-player computer games, with each player controlling half of the visible
display area. The clone would uses the same memory area as the original screen, and would be displayed at the same place
as the original. Any of the usual screen operations would be used with the clone, such as SCREEN DISPLAY and SCREEN OFFSET.

However, because there would be only one copy of the original screen data in memory, it woudl impossible to use the SCREEN
command with the cloned copy.

DUAL PLAYFIELD(combine two screens)

Syntax: Dual Playfield first screen,second screen

The DUAL PLAYFIELD mode would be the equivalent of mixing together two images from separate video cameras, and would be
achieved by displaying two screens simultaneously at the same x,y- coordinates. Each of the two screens would be
manipulated completely independently from one other, and this can be exploited to produce very smooth parallax
scrolling. Because the sizes of the two screens can be different, a smaller screen would be scrolled against a larger
background screen, creating the parallax effect.

The colors of these screens would be taken from the palette of the first screen with color zero being treated as
transparent. The first screen would makes use of half of the available colors, while the second screen would be the other
half of the available colors. When you are drawing to the second screen, QB64 would automatically convert the color
index to the appropriate number before using it. This would means that colors of the first half of the second screen's
palette would use the second half of the first screen's palette, in ascending order. Always make the first screen the
current screen when changing the color settings.

Remember that the automatic conversion process would not apply to assignment statements such as COLOR or
PALETTE.

When using SCREEN OFFSET to position a dual playfield screen, always specify the first screen, and never set
screen offsets for both dual playfield screens to zero.

DUAL PRIORITY(reverse order of dual playfield screens)

Syntax: Dual Priority first screen, second screen

Normally, the first screen of a dual playfield would be displayed directly over the second screen. To reverse this order,
so that the second screen appears in front of the first, you would use the DUAL PRIORITY command. Please note that this
instruction would only changes the order of display, and would have no effect on the screen organisation at all, so that the
first screen in the parameter list would still be used for all color assignments, and with the SCREEN DISPLAY command.

Screens would be removed from view by permanently erasing them, or by hiding them away for later display.

CLS(clear current screen)

Syntax1: Cls
Syntax2: Cls color number
Syntax3: Cls color number,x1,y1 To x2,y2

The CLS command would erases all or part of the current screen. Used on its own, the contents of the current screen would
be deleted and replaced by the current color. Any windows that may have been set up would also be cleared in this
way.

By specifying the index number of a particular color after the CLS command, the clearing operation would be carried
out using that color. A rectangular part of the current screen could also be cleared, leaving the rest of the screen intact.
This would be achieved by adding the coordinates of the block to be filed with the specified color, from the top left-hand
corner, to the bottom right. For example:

Code: QB64: [Select]
  1. Cls: Circle 100,98,98: Cls 0,50,50 To 150,150
  2.  

SCREEN HIDE(hide a screen)

Syntax1: Screen Hide
Syntax2: Screen Hide number

SCREEN SHOW(show a screen)

Syntax1: Screen Show
Syntax2: Screen Show number

You would use the SCREEN HIDE command to remove the current screen from view. It would then be restored using a SCREEN
SHOW instruction, like this:

Code: QB64: [Select]
  1. Cls : Print "I am the Current Screen" : Wait 100
  2. Screen Hide : Wait Key
  3. Screen Show
  4.  

Any screen would be temporarily hidden, by including its index number after the SCREEN HIDE instruction. This
screen would be revealed with a similar request to SCREEN SHOW, followed by the relevant screen number.

Because screens may be of different sizes, and because they can be displayed at various positions on the monitor by
offsets and overlaps, and because there can be up to eight electronic screens queuing up one behind the other, a
method is needed to bring any one of these screens to the front of the display.

SCREEN TO FRONT(move screen to front of display)

Syntax1: Screen To Front
Syntax2: Screen To Front number

You would use the SCREEN TO FRONT to move the selected screen to the front of the display queue. If the screen number
is omitted after the command, then the current screen would be brought to the front.

SCREEN TO BACK(move screen to back of display)

Syntax1: Screen To Back
Syntax2: Screen To Back number

This command is used to move a screen to the background of the display. If another screen is already there, it will
be displayed in front of the chosen screen. Again, if the screen number is omitted after a SCREEN TO BACK
command, the current screen will be relegated to the back of the display queue:

Code: QB64: [Select]
  1. Center "Hello again, Screen 0 here"
  2. Wait 100
  3. Screen Open 1,320,200,2,Lowres
  4. Center "Excuse me, make way for Screen 1"
  5. Wait 100 : Screen To Front 0
  6. Wait 100 : Screen To Back
  7.  

SCREEN (set current screen)

Syntax: Screen number

This command when used with the Open command would allow all graphical and text operations to be directed to the
selected screen number:

Code: QB64: [Select]
  1. Screen Open 2,320,32,16,Lowres
  2. Screen Display 2,,130,,
  3. Plot 0,0: Draw To 320,200
  4.  

If the chosen screen is outside of the current display area or is hidden, there would be no visible effect. However, any
graphics would be drawn in memory, waiting to be displayed whenever this screen comes into view, or out of hiding
after a Screen Show command.

Defining screen colours
DEFAULT PALETTE (define standard palette)

Syntax: Default Palette &H1....&H1000

It may be necessary to open several screens using the same palette. To simplify this process, the DEFAULT
PALETTE instruction would be used to define a standard palette which would be used by all subsequent screens created by
the SCREEN OPEN command. Colors are set using the RGB(A). Up to 4096 colors may be defined, depending on the screen mode,
and any colors that are not re-set must have their appropriate commas in place. Here is an example line for eight color
screens:

Code: QB64: [Select]
  1. Default Palette &H000,&H111,&HA69,,,,,&HFFF
  2.  

GET PALETTE(copy palette from a screen)

Syntax1: Get Palette number
Syntax2: Get Palette number,mask

This command would copy the colors from a specified screen, and loads them into the current screen. This would be useful
when data is being moved from one screen to another with a SCREEN COPY command, and the same color settings need to be
shared for both screens. An optional mask sould be added after the screen number, allowing only selected colors to be
loaded.

Note: This proposal is based off contents form the AMOS Professional manual. On Dec. 01 201201 at the Pianeta Amiga 2012, Pietro Ghizzoni, current owner of AMOS Pro sources after Francois Lionet ceased development, agreed to release the source code to AMOS Professional as Public Domain https://web.archive.org/web/20130530022407/http://www.pianetaamiga.it.  The source code for AMOS Professional can be downloaded at https://github.com/marc365/AMOSProfessional. The AMOS Professional manual can be downloaded at https://archive.org/details/amos-pro-compiler-manual. jAMOS is a AMOS BASIC reimplementation in Java and can be downloaded at https://sourceforge.net/projects/javaamos/ jAMOS.jar and it's source code can be used as a proof of concept.
« Last Edit: July 23, 2017, 04:23:49 pm by fatman2021 »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Proposed Enhancements To QB64
« Reply #1 on: July 22, 2017, 06:53:40 am »
What you suggest already contains QB64. Work With screens like as with pictures, use _COPYIMAGE if you want an authentic screen. To switch source and target screens, use _SOURCE and _DEST. You can use many ways to delete only part of the screen. You can also control rendering, such as _DISPLAY, or you can switch the hardware, software, or openGL screen via _DISPLAYORDER. If you want to have multiple screens at the same time, create them over _NEWIMAGE and switch them over SCREEN. There can be as many as they can fit into RAM (then swap to disk).
When it comes to inserting multiple screens into one, it goes through _PUTIMAGE and it can be anyway. Over and over, transparently or side by side. I have no more than 1 monitor for test for more monitors with 1 graphic card, but i thing, if is resolution 1280 x 1050 on monitor 0 and _PUTIMAGE insert image to 1300, 50 , its then displayed on second monitor at (1300 - 1280), 50. This i think only, i have it not tested. If anyone test this, i like result to know.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: Proposed Enhancements To QB64
« Reply #2 on: July 22, 2017, 04:12:16 pm »
I have no more than 1 monitor for test for more monitors with 1 graphic card, but i thing, if is resolution 1280 x 1050 on monitor 0 and _PUTIMAGE insert image to 1300, 50 , its then displayed on second monitor at (1300 - 1280), 50. This i think only, i have it not tested. If anyone test this, i like result to know.

This depends on how you have your desktop configured.  Does it clone the screens?  (A lot of times you see this option when a laptop might be hooked up to a TV to stream a movie or such.)  Does it extend the screen?  Which monitor is marked the primary screen and which is the secondary?

QB64 will handle larger screens just like any other windows program.  It might truncate the display at the edge of the visible screen.  It might wrap it over to the next display screen.  It all depends on your OS settings and which monitor you open the program up in to begin with.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Proposed Enhancements To QB64
« Reply #3 on: July 23, 2017, 01:13:03 pm »
Thank you for the answer, Steve. I'm glad it's how you write, I see in it another inspiration for another programs.