From AmigaBlitzWiki
Jump to: navigation, search

Standard Intuition screens can easily be created by Blitz using the Screen command. This will set up a standard screen for you to use for your program. Graphics can be drawn directly onto the screen's bitmap, or you can open Intuition windows on the screen, complete with menus, gadgets etc.

In its simplest form, the Screen command opens a screen based on the Mode parameter, which tells it how many bitplanes are required. This version of the Screen command does not support AGA screens, so a maximum of 6 bitplanes can be requested. By default, this is a low-res screen, so 320x256 on a PAL Amiga and 320x200 on an NTSC Amiga. Adding 8 to the Mode parameter requests a high resolution screen which is 640 pixels wide, but still 256 or 200 pixels high. Adding 16 requests an interlaced screen which is 512 or 400 pixels high. So, to open a 320x200 screen with 4 bitplanes (16 colours) on an NTSC Amiga:

Screen 0, 4, "My Screen"

The 0 is the ID number you assign to the screen, and the "My Screen" string is the title which will appear in the screen's title bar. This string is optional. And to create a 640x400 screen (high res + interlaced), again with 4 bitplanes:

Screen 0, 28, "My High-Res Screen"

The 28 results from 4 (bitplanes) + 8 (high-res) + 16 (interlaced).

A longer form of the Screen command allows more control by allowing you to set individual parameters:

Screen Screen#, X, Y, Width, Height, Depth, VMode, Title$, Dpen, Bpen [,BMap#]

Screen# is the ID, same as before. X and Y are the offset of the top left corner of the screen relative to the main screen, so would normally both be 0. Width and Height are the size of the screen in pixels. These can be smaller or larger than the screenmode, in which case the screen will be restricted in size or will scroll automatically when the mouse is brought to the side.

Depth is the number of bitplanes, from 1 to 8. Trying to open a screen depth that isn't supported by the hardware will result in an error.

VMode is the viewmode of the screen, and is formed by ORing together the flags required from the following list:

  • $0 (low-res)
  • $4 (interlaced)
  • $20 (super-high-res, 1280 pixels wide)
  • $200 (HAM)
  • $8000 (high-res)

Title$ is a string containing the title to be displayed in the title bar. If not required, use an empty string here ("").

DPen and BPen are the detail and block pens for the screen. These are normally 1 and 2 for the system palette, but may be changed to help your screen look right if you use a custom palette.

Finally, bitmap is the ID number of a bitmap to associate with the screen. This is optional, but if included will allow drawing directly to the screen using Blitz's graphics commands.

So, to open a 640x512 interlaced screen with 6 bitplanes (64 colours):

Screen 0, 0, 0, 640, 512, 6, $4|$8000, "My Screen", 1, 2

Using the Workbench Screen

Many programs use the Workbench screen instead of opening their own. To do this, simply use the WBToScreen command:

WBToScreen 0

This assigns the screen ID 0 to the Workbench screen, after which it can be treated like your own screen. This allows you to open windows on the screen, but also draw on it like any other. This might not be welcomed by other users however!

Other Useful Screen Commands

ShowScreen 0
Pops the screen with ID 0 to the front
HideScreen 0
Pops the screen with ID 0 to the back
BeepScreen 1
Causes a standard system beep on the screen with ID 1
FindScreen 1 [, "Workbench"]
Finds the first public screen in the system's list of screens and assigns is the ID 1 for you to use. Optionally a name can also be specified, in which case that screen name will be searched for. Be careful, you should know that the screen already exists!
CloseScreen 3
Closes screen ID 3. All windows on the screen will need to be closed first, so don't try to do this if your program already has windows open on it.
ShowBitmap 2
Replaces the screen's bitmap with bitmap ID 2. Useful to double-buffer graphics on the screen.