[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

2935.0. "Help with screen programming?" by MSBIS1::LANDINGHAM (Guy M.,BXB1-1/F11,293-5297) Tue Sep 19 1989 13:47

I am writing a simple interface to the Amiga graphics routines (class project).

What I want to do is open a custom screen with no titlebar, gadgets, etc, and
render some lines directly onto the screen.

I've succeeded in opening the screen and drawing some lines, but the screen 
opens with the default Workbench colors which I'd like to change.

I have indicated CUSTOMSCREEN in the NewScreen structure I am using to open my
screen.  I hope this means that I do not have to use the default Workbench
screen colors.

I am using the Sybex Amiga Programmer's Handbook (not, I've found, the most
structured book I've ever used.)

It seems the SetRGB4, GetRGB4, LoadRGB4 calls do what I want, but they all
take a ColorMap as an argument.  I can find no mention of a ColorMap anywhere
in the screen structure.

Can anyone help?

Thanks in advance.
T.RTitleUserPersonal
Name
DateLines
2935.1WJG::GUINEAUImpossible ConcentrationTue Sep 19 1989 13:565
Take a look at the source to my CM program (WJG::AMIGA:CM.ARC). It does
just what you want.

John
2935.2from memory... but maybe correct anyway. ;-)ATLV5::MCDONALD_JSurly to bed, surly to rise...Tue Sep 19 1989 15:4137
>I am using the Sybex Amiga Programmer's Handbook (not, I've found, the most
>structured book I've ever used.)

I fully agree.  It certainly doesn't help you learn to program on the amiga. 
There are a couple of really good introductory books out though.  I just bought
the Abacus book entitled "Advanced C Programming for the Amiga" or something
very much like that.  I rate it as excellent introductory material.


>It seems the SetRGB4, GetRGB4, LoadRGB4 calls do what I want, but they all
>take a ColorMap as an argument.  I can find no mention of a ColorMap anywhere
>in the screen structure.

I'm just pulling this from memory, but here goes.  I believe that the
'colormap' is just an array of words, one element for each color register. 
(i.e. element one is the RGB mask for color 1, element 2 for color 2, etc.)
So if you were going to have a four color screen with colors 0 - 4 defined as
black, red, white, and blue, then your color mask would be roughly:

	UWORD	cmap[4] = {	0x0000,	0x0f00, 0x0fff, 0x000f	};

Note that the first half-byte of the color specification is always 0, followed
by the red value (0-f), the green value (0-f), and the blue value (0-f).
Also note that this might not be syntactically correct C code.  It is from
memory, and I don't do much programming in C here at work.  Whenever I start
hacking at home, I always find lots of syntax errors for the first few
compiles.  

After you get the RGB map filled with the desired RGB specifications, you can
call the SETRBG4 routine.  I think its arguments are #-colors, colormap, and
pointer-to-screen?  Anyway, you end up passing in the colormap and screen
pointer and whatever else it needs, and voila... the colors are changed.
Any windows you open up on this screen will now use that color mask.


				Hope this helps some,
				John
2935.3WJG::GUINEAUImpossible ConcentrationTue Sep 19 1989 16:233
I believe the colormap struct hangs off the screens RastPort ( scr->RastPort)

John
2935.4Beware - Minor sidetrackSSDEVO::YESSEComputing at 6200 ft.Wed Sep 20 1989 14:2612
Re .2:

>I fully agree.  It certainly doesn't help you learn to program on the amiga. 
>There are a couple of really good introductory books out though.  I just bought
>the Abacus book entitled "Advanced C Programming for the Amiga" or something
>very much like that.  I rate it as excellent introductory material.

Quick diversion here...I saw the book at a local bookstore, and believe it's
based on Manx C.  Would you recommend the book for Lattice programmers? I.e.,
Are there significant differences in the code examples given that would
frustrate the heck out of a Lattice user?

2935.5examples shouldn't be much problemMKODEV::OSBORNEBlade WalkerThu Sep 21 1989 10:1540
re:.4
>Are there significant differences in the code examples given that would
>frustrate the heck out of a Lattice user?

Seems improbable, with a little caution. As a Manx user, I see mostly
examples which are apparently for Lattice C (e.g., Rob Peck's "Programmer's
Guide to the Amiga", or the ROM Kernal manuals). The only difference that
has had any impact is that Lattice compiles "int" as a "long" (32 bits),
while Manx's "int" is a "short" (16 bits), so I have to be careful with all
my calls to Amiga library routines, to make sure they get "longs".

Example from book (works with Lattice):

#define BITMAP_WIDTH	640
#define BITMAP_HEIGHT	200
#define BITMAP_DEPTH	4

struct BitMap mymap;

InitBitMap(&mymap,BITMAP_DEPTH,BITMAP_WIDTH,BITMAP_HEIGHT);

/* The above code would compile in Manx, but crash the machine at runtime,
because the dimensions passed are the wrong data type (ints)! To use the
example from Manx, the first three lines must be changed to: */

#define BITMAP_WIDTH	640L
#define BITMAP_HEIGHT	200L
#define BITMAP_DEPTH	4L

/* The "L" forces a "long" constant, instead of the default "int" */

You can use the "-l" flag with Manx to force "int" to be "long", but I
prefer to train myself to be aware of data typing. On a minor note, I'm
surprised that you found a book which uses "Manx" examples, since Lattice
is the "Amiga friendly" compiler. (Ever since Lattice 5.x, Manx 3.6a is
considered the "inferior" compiler, although just the opposite was the
case a few years ago... [sigh]).

John

2935.6Not Sybex!!!MSBIS2::LANDINGHAMGuy M.,BXB1-1/F11,293-5297Thu Sep 21 1989 12:2926
>================================================================================
>Note 2935.4               Help with screen programming?                   4 of 4
>SSDEVO::YESSE "Computing at 6200 ft."                12 lines  20-SEP-1989 13:26
>--------------------------------------------------------------------------------
>                         -< Beware - Minor sidetrack >-
>
>Re .2:
>
>>I fully agree.  It certainly doesn't help you learn to program on the amiga. 
>>There are a couple of really good introductory books out though.  I just bought
>>the Abacus book entitled "Advanced C Programming for the Amiga" or something
>>very much like that.  I rate it as excellent introductory material.
>
>Quick diversion here...I saw the book at a local bookstore, and believe it's
>based on Manx C.  Would you recommend the book for Lattice programmers? I.e.,
>Are there significant differences in the code examples given that would
>frustrate the heck out of a Lattice user?
>
>
Well, I certainly cannot recommend the Sybex book(s).  As well as being the
most poorly-organized references I've ever used, they also have errors.  For
instance, the description of one of the graphics lib routines (I think it is
SetRGB4) says the first argument should be a RastPort.  Every other scrap of
documentation I can find says it takes a ViewPort argument.  That alone would
give anyone programming with just the Sybex book a nasty bug which would be
hard to find...
2935.7Not all Sybex bad...MKODEV::OSBORNEBlade WalkerThu Sep 21 1989 14:1116
re:.6
>Well, I certainly cannot recommend the Sybex book(s).

You should probably specify which Sybex book you refer to. "Programmer's
Guide to the Amiga", by Rob Peck, is published by Sybex. I find it to be
the best book on Amiga programming I've seen. It's well organized, quite
clear, and reasonably free of errors. ALL manuals contain some errors,
and changes to the software take their toll. (The function ReportMouse
is described incorrectly in many manuals, but can be replaced by just
setting the flag in the Window structure, for example.)

Publishers may or may not have any consistent quality to the technical
books they publish. I suspect they depend a lot on the author's integrity
and skills, and in the case of Rob Peck, that's fine.

John O
2935.8Works okay for me.ATLV5::MCDONALD_JSurly to bed, surly to rise...Thu Sep 21 1989 17:4817
>>the Abacus book entitled "Advanced C Programming for the Amiga" or something
>
>Quick diversion here...I saw the book at a local bookstore, and believe it's
>based on Manx C.  Would you recommend the book for Lattice programmers? I.e.,
>Are there significant differences in the code examples given that would
>frustrate the heck out of a Lattice user?

I have Lattice V5.02 and I haven't had found any really frustrating differences
yet... well, since Manx has 16-bit integers, you have to pay attention to
things declared int.  But I haven't run into any major headaches.  

Then again, I haven't copied any examples straight from the book either.  I use
the examples as references and sort of hack out what I want to do.  Doing that,
I think I lessen my chances of finding Manx incompatibilities.  


					John
2935.9SetRGB4()NBOSWS::FRIESFri Sep 29 1989 06:2828
    What about this simple screen-color programming?
    
    #include <all_you_need>
    struct NewScreen NewScreen {...};
    struct Screen    *Screen,*OpenScreen; 
    struct ViewPort  vp;
    .
    .
    .
    Screen = OpenScreen(&NewScreen);
    if (!Screen)
      exit(0); 		/* or something else */
    
    vp = Screen->ViewPort;
    
    /* Assuming two bitplanes (4 colors) */
    SetRGB4(&vp,0L,0L,0L,0L);	/* BLACK as background color */
    SetRGB4(&vp,1L,15L,8L,0L);
    SetRGB4(&vp,2L,8L,0L,0L);
    SetRGB4(&vp,3L,15L,0L,0L);
    .
    .
    .
    
    So no color map is needed.
    
    regards
    Gerald
2935.10side track continued...AIAG::WISNERyou may ask yourself &#039;How do I work this?&#039;.Wed Oct 04 1989 18:5614
>>I am using the Sybex Amiga Programmer's Handbook (not, I've found, the most
>>structured book I've ever used.)
>
>I fully agree.  It certainly doesn't help you learn to program on the amiga.
>There are a couple of really good introductory books out though.  I just bought
>the Abacus book entitled "Advanced C Programming for the Amiga" or something
>very much like that.  I rate it as excellent introductory material.

Once I got a handle on Amiga graphics programming, I found "Amiga Programmer's 
Handbook" (not Peck's book) to be extremely useful.  The covers are falling off
my copy.  I like it's reference style, and the "index by function" on the
inside covers is very useful.  Caution:  There is a 1st edition of this book
that is not so good.  I have the second edition.