[comp.sys.amiga] Problems with Gadget rendering...

JK829055@pucal.bitnet (Jim Karczewski, Programmer -- TTR Development, Inc.) (11/05/90)

Hello..
        I am hoping someone out there can help me with a little problem
I am Having.. I have anAssembly Program that opens a screen,then a window,
inside the window is a gadget (TOGGLESELECT) which has some custome imagery.
The problem is, is that the Gadget is never displayed.. And I can't seem
to unserstand what I am doing wrong.. Here is the code:

        SECTION CODE

        INCLUDE "intuition/intuition.i"
OPENSCREEN      EQU     -198
OPENWINDOW      EQU     -204
CLOSESCREEN     EQU     -66
CLOSEWINDOW     EQU     -72
CLOSELIBRARY    EQU     -414
OPENLIBRARY     EQU     -408
EXECBASE        EQU     4
NULL            EQU     0

RUN:
        BSR     OPENINT
        BSR     SCROPEN
        BSR     WINDOPEN


OPENINT:
        MOVE.L  EXECBASE,A6
        LEA     INTNAME,A1
        JSR     OPENLIBRARY(A6)
        MOVE.L  D0,INTBASE
        RTS

OPENDOS:
        LEA     DOSNAME,A1
        JSR     OPENLIBRARY(A6)
        MOVE.L  D0,DOSNAME
        RTS

SCROPEN:
        MOVE.L  INTBASE,A6
        LEA     NewScreenStructure,A0
        JSR     OPENSCREEN(A6)
        MOVE.L  D0,SCREENHD
        RTS

SCRCLOSE:
        MOVE.L  INTBASE,A6
        MOVE.L  SCREENHD,A0
        JSR     CLOSESCREEN(A6)
        RTS

WINDOPEN:
        MOVE.L  INTBASE,A6
        LEA     NewWindowStructure1,A0
        JSR     OPENWINDOW(A6)
        MOVE.L  D0,WINDOWHD
        RTS

WINDCLOSE:
        MOVE.L  INTBASE,A6
        MOVE.L  WINDOWHD,A0
        JSR     CLOSEWINDOW(A6)
        RTS


NewScreenStructure:
        dc.w    0,0     ;screen XY origin relative to View
        dc.w    320,200 ;screen width and height
        dc.w    4       ;screen depth (number of bitplanes)
        dc.b    0,1     ;detail and block pens
        dc.w    NULL    ;display modes for this screen
        dc.w    CUSTOMSCREEN    ;screen type
        dc.l    NULL    ;pointer to default screen font
        dc.l    NULL    ;screen title
        dc.l    NULL    ;first in list of custom screen gadgets
        dc.l    NULL    ;pointer to custom BitMap structure

Palette:
        dc.w    $0333   ;color #0
        dc.w    $0DDD   ;color #1
        dc.w    $0888   ;color #2
        dc.w    $0555   ;color #3
        dc.w    $000F   ;color #4
        dc.w    $0F0F   ;color #5
        dc.w    $00FF   ;color #6
        dc.w    $0FFF   ;color #7
        dc.w    $0620   ;color #8
        dc.w    $0E50   ;color #9
        dc.w    $09F1   ;color #10
        dc.w    $0EB0   ;color #11
        dc.w    $055F   ;color #12
        dc.w    $092F   ;color #13
        dc.w    $00F8   ;color #14
        dc.w    $0CCC   ;color #15
PaletteColorCount equ (*-Palette)/2

NewWindowStructure1:
        dc.w    12,22   ;window XY origin relative to TopLeft of screen
        dc.w    210,99  ;window width and height
        dc.b    0,1     ;detail and block pens
        dc.l    CLOSEWINDOW     ;IDCMP flags
        dc.l    WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCARER
EFRESH  ;ot
   her window flags
        dc.l    GadgetList1     ;first gadget in gadget list
        dc.l    NULL    ;custom CHECKMARK imagery
        dc.l    NewWindowName1  ;window title
SCREENHD:       dc.l    0       ;custom screen pointer
        dc.l    NULL    ;custom bitmap
        dc.w    5,5     ;minimum width and height
        dc.w    -1,-1   ;maximum width and height
        dc.w    CUSTOMSCREEN    ;destination screen type
NewWindowName1:
        dc.b    'Your new window',0
        cnop 0,2
GadgetList1:
Gadget1:
        dc.l    NULL    ;next gadget
        dc.w    50,37   ;origin XY of hit box relative to window TopLeft
        dc.w    21,19   ;hit box width and height
        dc.w    GADGHIMAGE+GADGIMAGE    ;gadget flags
        dc.w    GADGIMMEDIATE+TOGGLESELECT      ;activation flags
        dc.w    BOOLGADGET      ;gadget type flags
        dc.l    Image1  ;gadget border or image to be rendered
        dc.l    Image2  ;alternate imagery for selection
        dc.l    NULL    ;first IntuiText structure
        dc.l    NULL    ;gadget mutual-exclude long word
        dc.l    NULL    ;SpecialInfo structure
        dc.w    NULL    ;user-definable data
        dc.l    NULL    ;pointer to user-definable data
Image1:
        dc.w    0,0     ;XY origin relative to container TopLeft
        dc.w    21,19   ;Image width and height in pixels
        dc.w    4       ;number of bitplanes in Image
        dc.l    ImageData1      ;pointer to ImageData
        dc.b    $000F,$0000     ;PlanePick and PlaneOnOff
        dc.l    NULL    ;next Image structure
ImageData1:
        dc.w    $FFFF,$F800,$FFFF,$F800,$C000,$1800,$C007,$9800
        dc.w    $C018,$1800,$C060,$1800,$C080,$1800,$C100,$1800
        dc.w    $C200,$1800,$C400,$1800,$C400,$1800,$C800,$1800
        dc.w    $C800,$1800,$C800,$1800,$C800,$1800,$C800,$1800
        dc.w    $C000,$1800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$FFFF,$F000,$FFFF,$E000
        dc.w    $C000,$0000,$C007,$8000,$C018,$0000,$C060,$0000
        dc.w    $C080,$0000,$C100,$0000,$C200,$0000,$C400,$0000
        dc.w    $C400,$0000,$C800,$0000,$C800,$0000,$C800,$0000
        dc.w    $C800,$0000,$C800,$0000,$C000,$0000,$8000,$0000
        dc.w    $0000,$0000,$FFFF,$F000,$FFFF,$E000,$C000,$0000
        dc.w    $C000,$0000,$C000,$0000,$C000,$0000,$C000,$0000
        dc.w    $C000,$0000,$C000,$0000,$C000,$0000,$C000,$0000
        dc.w    $C000,$0000,$C000,$0000,$C000,$0000,$C000,$0000
        dc.w    $C000,$0000,$C000,$0000,$8000,$0000,$0000,$0000
Image2:
        dc.w    0,0     ;XY origin relative to container TopLeft
        dc.w    21,19   ;Image width and height in pixels
        dc.w    4       ;number of bitplanes in Image
        dc.l    ImageData2      ;pointer to ImageData
        dc.b    $000F,$0000     ;PlanePick and PlaneOnOff
        dc.l    NULL    ;next Image structure
ImageData2:
        dc.w    $FFFF,$F800,$FFFF,$F800,$C000,$1800,$C007,$9800
        dc.w    $C018,$1800,$C060,$1800,$C080,$1800,$C100,$1800
        dc.w    $C200,$1800,$C400,$1800,$C400,$1800,$C800,$1800
        dc.w    $C800,$1800,$C800,$1800,$C800,$1800,$C800,$1800
        dc.w    $C000,$1800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$FFFF,$F800,$FFFF,$F800
        dc.w    $FFFF,$F800,$FFFF,$F800,$0000,$0800,$0000,$1800
        dc.w    $0000,$1800,$0007,$9800,$0018,$1800,$0060,$1800
        dc.w    $0080,$1800,$0100,$1800,$0200,$1800,$0400,$1800
        dc.w    $0400,$1800,$0800,$1800,$0800,$1800,$0800,$1800
        dc.w    $0800,$1800,$0800,$1800,$0000,$1800,$7FFF,$F800
        dc.w    $FFFF,$F800,$0000,$0800,$0000,$1800,$0000,$1800
        dc.w    $0000,$1800,$0000,$1800,$0000,$1800,$0000,$1800
        dc.w    $0000,$1800,$0000,$1800,$0000,$1800,$0000,$1800
        dc.w    $0000,$1800,$0000,$1800,$0000,$1800,$0000,$1800
        dc.w    $0000,$1800,$0000,$1800,$7FFF,$F800,$FFFF,$F800

INTBASE:        DC.L    0
DOSBASE:        DC.L    0
WINDOWHD:       DC.L    0
INTNAME:        DC.B    'intuition.library',0
                CNOP    0,2
DOSNAME:        DC.B    'dos.library',0
                CNOP    0,2
END


Could someone PLEASE TELL ME WHAT IS WRONG.. I am Using LATTICE ASM To
compile the code, along with BLINK to link the program.. THANKS!!!!


                                                Jim Karczewski

peter@cbmvax.commodore.com (Peter Cherna) (11/05/90)

In article <35429@nigel.ee.udel.edu> JK829055@pucal.bitnet (Jim Karczewski, Programmer -- TTR Development, Inc.) writes:
>Hello..
>        I am hoping someone out there can help me with a little problem
>I am Having.. I have anAssembly Program that opens a screen,then a window,
>inside the window is a gadget (TOGGLESELECT) which has some custome imagery.
>The problem is, is that the Gadget is never displayed.. And I can't seem
>to unserstand what I am doing wrong.. Here is the code:

Judging by the code sample, it appears you aren't putting the Image data
into "chip" memory.  The Amiga has two kinds of memory - memory that
the custom chips can access (put graphics and sound data there), and
memory that the chips can't.  This second type of memory is called
"fast" memory since it typically runs much faster.  So you must ensure
that your Image data (not the Image or Gadget structures themselves, though)
are reachable by the custom chips.

You may be able to specify that part of your data gets placed into
chip memory (consult the assembler/linker manual).  Otherwise, allocate
some chip memory (Use AllocMem(size, MEMF_CHIP)), then copy the image
data there, and refer to the copy.   (Don't forget to free the memory
upon exit).

>                                                Jim Karczewski

     Peter
--
     Peter Cherna, Software Engineer, Commodore-Amiga, Inc.
     {uunet|rutgers}!cbmvax!peter    peter@cbmvax.cbm.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"She read him like a book:  she liked to peek at his end."