User manual
PAL tutorial
PalVideoOutWrite (VideoOut, {24-bit expression});
Getting run-time information from the resource
Some PAL resources return run-time information to the user about their current state. The PAL methods
for accessing this information are of the form
PalXGetY (PalHandle), where X is the type of
resource,
Y is the attribute to query and PalHandle is the handle to the PAL resource to be queried.
In the tutorial source code, the macro
GenerateData(), for generating the display pattern, uses some
information retrieved from the video output resource. Every clock cycle, it tests the x and y coordinates
of the current scan position, to see if they are at the bottom right of the visible area of the screen. The
macros for getting the x and y coordinates are
PalVideoOutGetY() and PalVideoOutGetX(). They
are used in conjunction with the compile-time macros that find the dimensions of the visible area of the
screen:
macro expr VisibleX = PalVideoOutGetVisibleXCT (VideoOut, ClockRate);
macro expr VisibleY = PalVideoOutGetVisibleYCT (VideoOut);
EndOfFrame = (PalVideoOutGetY(VideoOut) == VisibleY) &&
(PalVideoOutGetX(VideoOut) == VisibleX);
This sets the variable
EndOfFrame to 1 when the current scan position is one pixel to the bottom and
right of the visible area of the screen and 0 otherwise. The position of the square is recalculated once
each frame using this variable.
1.4 PAL Tutorial Part 2
The Part2 project in the PAL tutorial describes how to add resource selection to your program.
You may need to write an application that will run on boards with very different devices available and so
write code that will use different resources for different platforms. This can be written in a portable
fashion, without testing explicitly for a particular platform.
In this part of the tutorial, user control is added for:
• Stopping and starting the movement of the square
• Changing the colour of the square
Depending on the resources available on the target device, buttons on either the target platform circuit
board or a mouse attached to a PS/2 port are used.
The significant change from the first part of the tutorial is the addition of the macro
HumanInterface(): this macro is called by the GenerateData() macro in order to read the input
from the user. This code also makes use of the PS/2 mouse driver in the
pal_mouse.hcl library.
1.4.1 Compile-time configuration
Determining which resources will be used
Some applications may need to perform the same functions on boards with different resources. PAL
allows you to write one piece of code that will automatically select the resources to use for the target
platform. This can be done by querying the resources available on the target platform, rather than
explicitly testing for a particular target platform. This makes your code much more portable because it
will support any board with those resources available.
In the tutorial source code, two key expressions are used to determine which resources will be used.
These are:
www.celoxica.com
Page 10