COLOURWINDOW by Mike Fuller Ed: The CW_Example program in this drawer shows how the requestor discussed here can be incorporated in a program. However, there is one small glitch - it wasn't tested under K/S 2.0 and as a result, when run from the icon, causes a "suspendable" software error on exiting. If run from Workbench 1.3 (workbench or CLI) or from the shell in WB2, all is well. Note that the requester code itself is not responsible for this error, so use it with impunity.  ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| ColourWindow is a colour requester that was originally coded in C by Anders Bjerin of the Amiga C Club. It was part of the C Manual, a wonderful set of tutorials and program examples available on Fish disks 456 and 457 [Ed: or more recently, a 4-disk set UT 312 A,B,C,D]. Unfortunately, the Amiga assembly programmer is not nearly as well looked after as the C user and this prompted me to port the program into assembly as a teaching example. I would like to see an organised assembly association, similar to the C club, that provides tutorials and examples covering the major areas of the Amiga's system. If anyone knows of such an association, would like to help organise one, would like to contribute tutorials/programs towards one or just has a similar interest, please contact me by writing or phoning the number listed at the end of these docs. USING COLOURWINDOW ColourWindow is an assembly language subroutine that may be used by anyone in their own programs. It adjusts to any number of colours, excluding HAM and extra-halfbrite, and can be used with any normal screen resolution. When it is invoked, it uses minimal CPU time, and it also cleans up completely after it is closed. Prior to calling ColourWindow, four parameters need to be set up: A pointer to the associated screen in register A0 (long) A pointer to the ColourWindow title in register A1 (long) The X (left side) position of the requester in register D0 (word) The Y (top side) position of the requester in register D1 (word) Additionally, the intuition.library and graphics.library must have been opened by your program and their base pointers externally defined (XDEF). I refer to these pointers as Intbase and Graphbase, if you call them something else the relevant names will have to be changed in the ColourWindow subroutine. Some of the macros I use in the program are contained in the Macros file, which should be included with this program code. The standard Commodore Includes (.i files) are also required, which I have in an assigned INCLUDE: file. An example of using ColourWindow in a program could be: movea.l Screenptr,a0 ;pointer to screen lea CW_Title,a1 ;pointer to ColourWindow title move.w #50,d0 ;X position move.w #100,d1 ;Y position jsr ColourWindow ;open requester A byte value will be returned in register D0 indicating success (0) or failure (5) in opening the requester window. If the Workbench screen is being used, 0 should be passed in A0. If 0 is passed in A1, a default requester title, "Colour Window", will be used. If the X and/or Y values are too big or small for the requester to fit, it will be positioned as close as possible to these coordinates. This will allow you to use the current mouse coordinates when you call the requester, and it will open under, or close to, the mouse pointer. Read the source code for the CW-Example program to see how it can be used in a program. The CW-Example will open a high-res, interlaced screen, open a full-size window, draw some pretty lines, and wait for the user to click in the window. This will open the ColourWindow requester, allowing you to play with the colours. You can exit the program by clicking the main window's Closewindow gadget after closing the ColourWindow requester. I assembled the executable using A68K. ie. A68K ColourWindow.asm -iINCLUDE: A68K CW-Executable.asm -iINCLUDE: I used Blink to link the two modules. ie. Blink CW-Executable.o,ColourWindow.o to CW-Executable lib amiga.lib COLOURWINDOW GADGETS _ _  || Colour Window ===============  |   R     12     G    0 SPREAD EX  B    0 COPY UNDO      OK CANCEL A colour is selected by clicking on its box at the bottom of the requester. Three proportional gadgets, representing the red, green and blue values, allow you to adjust the selected colour value. The numeric values are shown just to the right of these. The SPREAD gadget will give an even spread over a range of colours. The EX gadget will exchange two colours. The COPY gadget will copy a colour. The UNDO gadget will undo the last colour change. Clicking on the OK gadget will retain the changes and close the requester. Clicking on either the CANCEL or Closewindow gadgets will close the requester and revert to the previous colours. LEGAL This program is public domain with NO RIGHTS RESERVED. You may use it as you like and modify it to suit your own programs, it is intended to be a teaching example. If you can improve it, please let me know, I am learning too. Although it works well for me, I accept no responsibility if it does any damage to your hardware or software. I am also interested in hearing about any bugs it may contain. Please contact me if you have any input about an assembly association, anything related to the ColourWindow program, or just want to discuss the Amiga or programming in general (I'm also open to any job offers). Mike Fuller 4 Sonego Ave Kelmscott W.A. 6111 (09) 390 9350  ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 ||| 28 |||