home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff330.lzh / Palette / palette.asm < prev    next >
Assembly Source File  |  1990-03-02  |  31KB  |  1,170 lines

  1. *        filename: palette.asm
  2. *
  3. *        1/22/90
  4. *
  5. *        Authors: Randy Jouett & CJ Fruge
  6. *
  7. *        inspired by c sheppner's "palette tool", of cbm    
  8. *        (actually, ripped almost totally)
  9. *        who was in turn inspired by cheath, of microsmiths.
  10. *
  11. *        "I stand on the shoulders of giants." -- ae
  12. *
  13. *        NOTE: This file was assembled using the CAPE
  14. *        assembler.  Some changes will undoubtedly be
  15. *        necessary for other assemblers.
  16. *    
  17. *        This program was written to be a _stand-alone_
  18. *        replacement for Palette Tool on 1.3 Extras Disk.    
  19. *
  20.  
  21.     include    "asm.i"            ; general amiga includes
  22. ;    include "macros.i"        ; included by "asm.i"
  23.  
  24.  
  25.     BASEREG    B
  26.     OPTIMON
  27. ;    ADDSYM
  28.  
  29.     XLVO    OpenLibrary    
  30.     XLVO    CloseLibrary    
  31.     XLVO    OpenWindow
  32.     XLVO    CloseWindow
  33.     XLVO    WaitPort
  34.     XLVO    GetMsg    
  35.     XLVO    ReplyMsg
  36.     XLVO    AllocMem
  37.     XLVO    FreeMem
  38.     XLVO    SetAPen
  39.     XLVO    SetBPen
  40.     XLVO    SetDrMd
  41.     XLVO    DrawBorder
  42.     XLVO    Draw
  43.     XLVO    Move
  44.     XLVO    Text
  45.     XLVO    ModifyProp
  46.     XLVO    GetRGB4
  47.     XLVO    LoadRGB4
  48.     XLVO    RectFill
  49.     XLVO    FindTask
  50.     XLVO    Forbid
  51.     
  52.     XREF    _LinkerDB    ; for base relative addressing    
  53.  
  54. * ---------------------------------------
  55. * ----- E Q U A T E S -------------------
  56. * ---------------------------------------
  57.  
  58. * program limits
  59.  
  60. MXCOLRS    equ    32            ; max colors (5 planes)
  61. MXPLNS    equ    5            ; max planes
  62. V_EXTRA_HALFBRITE    equ    $80    ; not equ'd in asm includes
  63.  
  64. * window specs
  65.  
  66. PWIDE    equ    192            ; palette window width
  67. PBHIGH    equ    72            ; Height offset for window
  68.  
  69. * Gadget ID's
  70.  
  71. colID    equ    1            ; color gadget ids (col# + 1)
  72. okID    equ    MXCOLRS+1        ; id = 33
  73. resID    equ    MXCOLRS+2        ; id = 34
  74. canID    equ    MXCOLRS+3        ; id = 35
  75. rID    equ    MXCOLRS+4        ; id = 36
  76. bID    equ    MXCOLRS+5        ; id = 37
  77. gID    equ    MXCOLRS+6        ; id = 38
  78.  
  79. * Proportional RGB Gadgets
  80.  
  81. PRPX    equ    52            ; x coord, relative to bottom
  82. PRPY    equ    -62            ; Top prop, relative to bottom
  83. PRPW    equ    90            ; rgb gadget width
  84. PRPH    equ    11            ; rgb gadget height
  85. RGB_BDY    equ    $FFF            ; horizbody value for rgb gadgets
  86.  
  87. * Text Selection
  88.  
  89. TXTX    equ    8            ; x coord, relative to bottom
  90. TXTY    equ    -17            ; y coord, relative to bottom
  91. TXTW    equ    54            ; ok, cancel, & reset text height
  92. TXTH    equ    13            ; ok, cancel, & reset text width
  93.  
  94. * Palette Color Gadgets
  95.  
  96. COLX    equ    10            ; x offset of first color gadget
  97. COLY    equ    14            ; y offset of first color gadget
  98. COLSW    equ    4            ; space between color gads
  99. COLH    equ    10            ; Image height
  100. COLDY    equ    (COLH+COLSW)        ; y spacing between rows
  101.  
  102. CHX1    equ    8            ; x1 coord for color swatch
  103. CHX2    equ    34            ; x2 coord for color swatch
  104.  
  105. * ---------------------------------------
  106. * ----- M A I N   C O D E   S E C T I O N
  107. * ---------------------------------------
  108.  
  109.     SECTION    palcode,CODE
  110.  
  111.     XDEF    _palette        ; public reference
  112.  
  113. _palette:
  114.  
  115.     movem.l    d2-d7/a2-a6,-(sp)    ; Save data & address regs.
  116.  
  117.     lea    _LinkerDB,a4        ; need for base rel addressing
  118.  
  119.     sub.l    a1,a1            ; clear the address reg
  120.     SYS    FindTask,4        ; find this task
  121.  
  122.     move.l    a6,EBase(a4)        ; save ExecBase pointer in fast ram
  123.     move.l    d0,a2            ; save ptr to process struct
  124.     tst.l    pr_CLI(a2)        ; is it CLI?
  125.     bne.s    fromcli            ; yep, from cli
  126.  
  127.     lea    pr_MsgPort(a2),a0    ; get message port for this process
  128.     move.l    a0,a2            ; save mess port in a2
  129.     SYS    WaitPort        ; wait for WB message
  130.     
  131.     move.l    a2,a0            ; put port back in a0
  132.     SYS    GetMsg            ; get the WB message
  133.     move.l    d0,wb_message(a4)    ; save the message        
  134.  
  135. fromcli:
  136.     lea    gfxname(a4),a1        ; open gfx lib
  137.     moveq    #0,d0
  138.     SYS    OpenLibrary
  139.     move.l    d0,GBase(a4)
  140.     beq    nogfx
  141.  
  142.     lea    intuiname(a4),a1    ; open intuition lib    
  143.     moveq    #0,d0
  144.     SYS    OpenLibrary
  145.     move.l    d0,IBase(a4)
  146.     beq    nointui
  147.  
  148.     move.l    d0,a0            ; get IntuitionBase
  149.     move.l    ib_FirstScreen(a0),d1    ; get ptr to FirstScreen
  150.     move.l    d1,pScr(a4)        ; save the screen ptr
  151.     move.l    d1,a0
  152.     lea    sc_ViewPort(a0),a1    ; get effective address
  153.     move.l    a1,pVp(a4)        ; store the ViewPort ptr
  154.     move.w    vp_Modes(a1),d1        ; get modes in d0
  155.     move.l    d1,d0            ; stash for the and
  156.     and.w    #V_HAM,d0        ; is it HAM?
  157.     bne    cant_handle        ; cant handle HAM
  158.     and.w    #V_EXTRA_HALFBRITE,d1    ; is it extra half bright?
  159.     bne    cant_handle        ; cant handle EHB
  160.     lea    sc_RastPort(a0),a0    ; get rastport
  161.     move.l    rp_BitMap(a0),a0    ; get bitmap
  162.     moveq    #0,d0            ; clr d0.
  163.     move.b    bm_Depth(a0),d0        ; get depth
  164.     move.w    d0,nPlanes(a4)        ; store depth
  165.     cmp.w    #MXPLNS,d0        ; is planes > 5?
  166.     bgt    cant_handle        ; cant handle colors>32, get out
  167.     moveq    #1,d3            ; clr d1
  168.     lsl.w    d0,d3            ; 1 << depth = # colors
  169.     move.w    d3,nColors(a4)        ; save number of colors
  170.  
  171. * allocate memory for (#colors * (sizeof struct image + gadget))
  172.  
  173.     move.l    #(gg_SIZEOF+ig_SIZEOF),d0
  174.     mulu.w    d3,d0
  175.     move.l    d0,d2
  176.     move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  177.     SYS    AllocMem
  178.     move.l    d0,pGads(a4)        ; save ptr to mem alloc'ed
  179.     beq    nogadmem        ; cudnt get mem
  180.  
  181.     move.l    d2,gadmemsize(a4)    ; save mem for gads' & images'.
  182.     moveq    #0,d1            ; clr the reg
  183.     move.w    nColors(a4),d1        ; get colors in d1    
  184.     mulu.w    #gg_SIZEOF,d1        ; size of gadget struct
  185.     add.l    d1,d0            ; colors*image size + gad ptr
  186.     move.l    d0,pImgs(a4)        ; stash the images ptr    
  187.     moveq    #0,d1
  188.     moveq    #0,d2            ; clr the regs
  189.     moveq    #0,d6
  190.     moveq    #0,d0
  191.     move.w    nPlanes(a4),d0        ; get depth
  192.     subq.w    #1,d0            ; (depth-1) index.
  193.     lea    gadwidth(a4),a0        ; a0 -> gadwidth[0]
  194.     move.b    0(a0,d0.w),d1        ; index depth-1 bytes into array
  195.     lea    gadrows(a4),a0        ; a0 -> gadrows[0]
  196.     move.b    0(a0,d0.w),d2        ; index depth-1 bytes into array
  197.     lea    colBorXY(a4),a0        ; a0 -> colBorXY[0]
  198.     move.w    d1,d6            ; keep d1
  199.     addq.w    #1,d6            ; width + 1
  200.     moveq    #4,d7            ; index 2 words
  201.     move.w    d6,0(a0,d7.w)        ; stuff borxy[2] with width+1
  202.     addq.w    #4,d7            ; index 2 more words
  203.     move.w    d6,0(a0,d7.w)        ; stuff borxy[4] with width+1
  204.  
  205.     addq    #COLSW,d1        ; colorgad Dx
  206.     lea    colGadX(a4),a0        ; a0 -> colGadX
  207.     lea    colGadY(a4),a1        ; a1 -> colGadY
  208.     moveq    #0,d6            ; clr d6, row cntr    
  209.     moveq    #0,d7            ; clr d7, col cntr    
  210.     moveq    #0,d0            ; clr d0, x coordinate
  211.     moveq    #0,d5            ; clr d5, y coordinate
  212.     moveq    #0,d3            ; set word ptr
  213.  
  214. do_cols_rows:
  215.     moveq    #0,d0            ; d1=colg dx, d2=#rows
  216.     move.b    d7,d0            ; move col cntr into d0
  217.     mulu    d1,d0            ; multiply colgadx to get x coord 
  218.     add.w    #COLX,d0        ; add offset to get x coord
  219.     moveq    #0,d5            ; zero the calc y coord
  220.     move.w    d6,d5            ; move row cntr to d5
  221.     mulu    #COLDY,d5        ; multiply to get y coord
  222.     add.w    #COLY,d5        ; add offset to get y coord
  223.     move.w    d0,0(a0,d3.w)        ; stuff gadx[index] with x coord
  224.     move.w    d5,0(a1,d3.w)        ; stuff gady[index] with y coord
  225.     addq.w    #2,d3            ; increment index
  226.     addq.w    #1,d7            ; increment col cntr
  227.     cmp.w    nColors(a4),d7        ; is col > #colors ?
  228.     beq.s    xy_fini            ; the CORRECT french spelling!
  229.     cmp.b    #8,d7            ; full column is 8 gadgets
  230.     bne.s    do_cols_rows        ; finish the row
  231.     moveq    #0,d7            ; clr the column counter
  232.     addq.w    #1,d6            ; increment row cntr
  233.     cmp.b    d2,d6            ; is row>number of rows ?
  234.     bne.s    do_cols_rows        ; start new row
  235.  
  236. xy_fini:
  237.     move.l    pGads(a4),a2        ; a2 -> gadget alloc
  238.     move.l    pImgs(a4),a3        ; a3 -> image alloc
  239.     moveq    #colID,d6        ; initialize planeonoff variable
  240.     moveq    #0,d4            ; clear pen plane cntr
  241.     move.w    nColors(a4),d3        ; put in # colors
  242.     subq.w    #1,d3            ; colors-1 for dbra
  243.     subq    #COLSW,d1        ; change colg dx to colgw
  244.  
  245. * initialize gadget & image structures
  246.  
  247. do_gads_imgs:
  248.     move.w    (a0)+,gg_LeftEdge(a2)    ; gadget->LeftEdge = colGadX[n]
  249.     move.w    (a1)+,gg_TopEdge(a2)    ; gadget->TopEdge = colGadY[n]
  250.     move.w    d1,gg_Width(a2)        ; gadget->Width = colw
  251.     move.w    #COLH,gg_Height(a2)           ; gadget->Height= COLH
  252.     move.w    #(GADGHBOX!GADGIMAGE),gg_Flags(a2) ; gadget->Flags = 
  253.     move.w    #GADGIMMEDIATE,gg_Activation(a2)   ; gadget->Activation =
  254.     move.w    #BOOLGADGET,gg_GadgetType(a2)       ; gadget->Type =
  255.     move.l    a3,gg_GadgetRender(a2)    ; gadget->GadgetRender = &image[n]
  256.     move.w    d6,gg_GadgetID(a2)    ; gadget->GadgetID = colid+cntr
  257.     move.l    a2,a5            ; save ptr
  258.     add.l    #gg_SIZEOF,a2        ; bump addr reg    
  259.     move.l    a2,gg_NextGadget(a5)    ; gadget->NextGadget = gad++
  260.  
  261.     move.w    d1,ig_Width(a3)        ; image->Width = coldx
  262.     move.w    #COLH,ig_Height(a3)    ; image->Height = COLH
  263.     move.w    #1,ig_Depth(a3)        ; image->Depth = 1
  264.     move.b    d4,ig_PlaneOnOff(a3)    ; image->PlaneOnOff = pen plane cntr
  265.     add.l    #ig_SIZEOF,a3        ; bump address reg
  266.     addq.b    #1,d6            ; inc gad id cntr.
  267.     addq.b    #1,d4            ; inc pen plane cntr.
  268.     dbra    d3,do_gads_imgs        ; top of loop
  269.                     ; fall thru and
  270.     lea    okGad(a4),a0        ; put ok gad address in a0
  271.     move.l    a0,gg_NextGadget(a5)    ; gadget->NextGadget = &okGad
  272.  
  273. * set window to screen characteristics
  274.  
  275.     lea    newpWin(a4),a0        ; put addr of newin struct in a0
  276.     move.l    pGads(a4),nw_FirstGadget(a0)    ; stuff nw_FirstGadget ptr
  277.     move.l    pScr(a4),a1            ; get the screen ptr
  278.     move.l    a1,nw_Screen(a0)    ; stuff screen ptr in nw_Screen ptr
  279.     moveq    #0,d0            ; clr d0
  280.     move.w    sc_Flags(a1),d0        ; put sc_Flags var in d0
  281.     and.w    #SCREENTYPE,d0        ; and the flags variable
  282.     move.w    d0,nw_Type(a0)        ; put it nw_Type var 
  283.     mulu    #COLDY,d2        ; # rows * COLDY
  284.     add.w    #10,d2            ; + row offset
  285.     add.w    #PBHIGH,d2        ; + window height offset
  286.     move.w    d2,nw_Height(a0)    ; put in nw_Height var
  287.     SYS    OpenWindow,IBase(a4)    ; open window
  288.     move.l    d0,pWin(a4)        ; save the window ptr
  289.     beq    nowin            ; get the f**k out
  290.  
  291.     move.l    d0,a0            ; put winptr in a0
  292.     move.l    wd_RPort(a0),pRp(a4)    ; put Rport in pRp
  293.     move.l    wd_UserPort(a0),pUp(a4)    ; put UserPort in pUp
  294.  
  295.     moveq    #0,d4
  296.     move.w    nColors(a4),d4        ; move #colors in d4
  297.     subq    #1,d4            ; subtract 1 for dbra
  298.     moveq    #0,d3            ; clr d3
  299.     lea    curColor(a4),a2        ; get ptr to curcolors in a2
  300.     lea    resColor(a4),a3        ; get ptr to rescolors in a3
  301.     move.l    pVp(a4),a5        ; get screen's viewport ptr in a5
  302.     move.l    vp_ColorMap(a5),a5    ; put colormap ptr in a5
  303.  
  304. colorloop:
  305.     move.l    a5,a0            ; put colormap ptr in a0
  306.     move.l    d3,d0            ; put entry index in d0
  307.     SYS    GetRGB4,GBase(a4)    ; get colors from system
  308.     move.w    d0,(a2)+        ; move colorvalue into curcolor
  309.     move.w    d0,(a3)+        ; move colorvalue into rescolor
  310.     addq    #1,d3            ; increment entry index
  311.     dbra    d4,colorloop        ; do it color times
  312.  
  313.     moveq    #0,d6            ; old color reg in d6 = color0
  314.     moveq    #0,d7            ; new color reg in d7 = color0
  315.     bsr    select_color        ; select_color uses d6 & d7
  316.  
  317. Forever:                ; start of infinite loop
  318.     move.l    pUp(a4),a2        ; UserPort in a0    
  319.     move.l    a2,a0
  320.     SYS    WaitPort,EBase(a4)    ; wait on the port
  321.     
  322.     move.l    a2,a0
  323.     SYS    GetMsg            ; get the message
  324.     tst.l    d0            ; null message?
  325.     beq.s    Forever
  326.  
  327.     moveq    #0,d5            ; clr the reg
  328.     move.l    d0,a1            ; copy message addr to a1
  329.     move.l    im_Class(a1),d7        ; d7 has the im_Class 
  330.     move.l    im_IAddress(a1),a0    ; a0 has the im_IAddress
  331.     move.w    gg_GadgetID(a0),d5    ; d5 has the gadget id
  332.     SYS    ReplyMsg        ; reply with ptr in a1
  333.  
  334.     cmp.l    #MOUSEMOVE,d7        ; is it a mousemove ?
  335.     bne.s    notmousemove        ; nope
  336.     moveq    #0,d6            ; clr the reg
  337.     move.w    pReg(a4),d6        ; move pReg to d6 for call
  338.     bsr    mod_color        ; modify the color(s)
  339.     bra.s    Forever            ; done & go wait for messages
  340.  
  341. notmousemove:
  342.     cmp.l    #GADGETDOWN,d7        ; is it a gadgetdown event ?
  343.     bne.s    gadgetup        ; nope, hasta be gadget up
  344.     cmp.w    #okID,d5        ; is the gad id < okid ?
  345.     blt.s    colorgad        ; yes, gad id is a color gad
  346.  
  347. slid_gadgets:
  348.     moveq    #0,d6            ; clr the reg
  349.     move.w    pReg(a4),d6        ; move pReg to d6 for call
  350.     bsr    mod_color        ; modify the color(s)
  351.     bra.s    Forever            ; done & go wait for messages
  352.  
  353. colorgad:
  354.     cmp.w    #colID,d5        ; it the gad id >= colID
  355.     blt.s    Forever            ; no, get outa here
  356.     moveq    #0,d6            ; clr the reg
  357.     move.w    pReg(a4),d6        ; move pReg to d6 for call
  358.     move.w    d5,d7            ; move gadget id to d7
  359.     subq.w    #colID,d7        ; subtract to get color selected
  360.     move.w    d7,pReg(a4)        ; store the new color
  361.     bsr    select_color        ; draw the user's selection
  362.     bra    Forever            ; done & go wait for messages
  363.  
  364. gadgetup:
  365.     cmp.w    #okID,d5        ; is the gad id < okID ?
  366.     blt.s    slid_gadgets        ; yes, user slid gadget
  367.     cmp.w    #okID,d5        ; user hit ok ?
  368.     bne.s    reset            ; nope
  369.     beq.s    clean_exit        ; user is happy / colors
  370.     bra    Forever            ; gone & wait for messages
  371.  
  372. reset:
  373.     cmp.w    #canID,d5        ; user hit cancel ?
  374.     beq.s    cancel            ; hit cancel
  375.     cmp.w    #resID,d5        ; user hit reset ?
  376.     bne.s    slid_gadgets        ; no, user slid the gadgets
  377.     bsr    reset_colors        ; reset the colors
  378.     move.w    pReg(a4),d6        ; get old color
  379.     moveq    #0,d7            ; new color is color 0
  380.     move.w    d7,pReg(a4)        ; save as selected color
  381.     bsr.s    select_color        ; re-select color 0
  382.     bra    Forever            ; gone & wait for messages
  383.  
  384. cancel:
  385.     bsr    reset_colors        ; reset the colors
  386.  
  387. * clean up and back outs
  388.  
  389. clean_exit:
  390.     move.l    pUp(a4),a0        ; get the userport in a0
  391.     SYS    GetMsg,EBase(a4)
  392.     tst.l    d0            ; any messages ?
  393.     beq.s    no_messages        ; no, exit
  394.  
  395.     move.l    d0,a1            ; move mes ptr to a1
  396.     SYS    ReplyMsg        ; reply the message
  397.     bra.s    clean_exit        ; go & eat them all
  398.  
  399. no_messages:
  400.     move.l    pWin(a4),a0        ; get window ptr in a0
  401.     SYS    CloseWindow,IBase(a4)
  402.  
  403. nowin:
  404.     move.l    pGads(a4),a1        ; get mem ptr
  405.     move.l    gadmemsize,d0        ; get size of memory alloc'ed
  406.     SYS    FreeMem,EBase(a4)
  407.  
  408. nogadmem:
  409.     move.l    IBase(a4),a1        ; move ibase to a1
  410.     SYS    CloseLibrary        ; close intuition
  411.  
  412. cant_handle:
  413. nointui:
  414.     move.l    GBase(a4),a1        ; move gbase to a1
  415.     SYS    CloseLibrary        ; close graphics
  416.     
  417.     move.l    wb_message(a4),d2    ; get the stashed wb message
  418.     beq.s    nogfx            ; no message, exit
  419.     SYS    Forbid            ; dont UnLoadSeg me yet
  420.     
  421.     move.l    d2,a1            ; put wb message in a1
  422.     SYS    ReplyMsg        ; reply to WorkBench
  423.  
  424. nogfx:
  425.     movem.l    (sp)+,d2-d7/a2-a6    ; restore the stack
  426.     rts                ; END OF PROGRAM
  427.  
  428. * ---------------------------------------
  429. * ----- S U B R O U T I N E S -----------
  430. * ---------------------------------------
  431.  
  432. * ------------------------------    
  433. * update color selection -------
  434. * ------------------------------    
  435.  
  436. select_color:                ; d6=old, d7=new
  437.                     ; erase the old border / pen 0
  438.     move.w    d7,d3            ; stash new col in d3        
  439.     add.w    d6,d6            ; convert old col to byte index
  440.     add.w    d7,d7            ; convert new col to byte index
  441.     lea    colGadX(a4),a5        ; save gadx in a5
  442.     lea    colGadY(a4),a3        ; save gady in a3
  443.     move.l    pRp(a4),a2        ; save the rastport in a2    
  444.  
  445.     lea    colBor(a4),a1        ; ptr to colbor in a1
  446.     move.b    #0,bd_FrontPen(a1)    ; set front pen to zero
  447.     moveq    #0,d0
  448.     moveq    #0,d1
  449.     move.w    0(a5,d6.w),d0        ; colGadX[old]
  450.     move.w    0(a3,d6.w),d1        ; colGadY[old]
  451.     move.l    a2,a0            ; rastport in a0
  452.     SYS    DrawBorder,IBase(a4)    ; draw the border
  453.                     ; draw the new border / pen 1
  454.     lea    colBor(a4),a1        ; ptr to colBor in a1
  455.     move.b    #1,bd_FrontPen(a1)    ; set front pen to 1
  456.     moveq    #0,d0
  457.     moveq    #0,d1
  458.     move.w    0(a5,d7.w),d0        ; colGadX[new]
  459.     move.w    0(a3,d7.w),d1        ; colGadY[new]
  460.     move.l    a2,a0            ; rastport in a0
  461.     SYS    DrawBorder        ; draw the border
  462.  
  463.     move.l    a2,a1            ; rastport in a1
  464.     move.l    #RP_JAM1,d0        ; draw mode in d0
  465.     SYS    SetDrMd,GBase(a4)        ; set the draw mode
  466.  
  467.     move.l    a2,a1            ; rastport in a1
  468.     moveq    #1,d0            ; set pen to 1 in d0
  469.     SYS    SetAPen            ; set the area pen to 1
  470.                     ; color swatch from window height
  471.     move.l    pWin(a4),a0        ; get ptr to window
  472.     moveq    #0,d4
  473.     moveq    #0,d5
  474.     move.w    wd_Height(a0),d5    ; put window height in d5
  475.     move.w    d5,d4            ; put window height in d4
  476.     sub.w    #63,d5            ; gives d5=CHY1
  477.     sub.w    #23,d4            ; gives d4=CHY2
  478.                     ; border around color swatch
  479.     move.l    a2,a1            ; rastport in a1
  480.     move.l    #CHX1,d0        ; chx1 in d0        
  481.     move.l    d5,d1            ; chy1 in d1        
  482.     SYS    Move            ; move tuda spot
  483.  
  484.     move.l    a2,a1            ; rastport in a1
  485.     move.l    #CHX2,d0        ; chx2 in d0        
  486.     move.l    d5,d1            ; chy1 in d1        
  487.     SYS    Draw            ; draw tudere
  488.  
  489.     move.l    a2,a1            ; rastport in a1
  490.     move.l    #CHX2,d0        ; chx2 in d0        
  491.     move.l    d4,d1            ; chy2 in d1        
  492.     SYS    Draw            ; draw tudere
  493.  
  494.     move.l    a2,a1            ; rastport in a1
  495.     move.l    #CHX1,d0        ; chx1 in d0        
  496.     move.l    d4,d1            ; chy2 in d1        
  497.     SYS    Draw            ; draw tudere
  498.  
  499.     move.l    a2,a1            ; rastport in a1
  500.     move.l    #CHX1,d0        ; chx1 in d0        
  501.     move.l    d5,d1            ; chy1 in d1        
  502.     SYS    Draw            ; draw tudere
  503.  
  504.     move.l    a2,a1            ; rastport in a1
  505.     moveq    #0,d0
  506.     move.w    d3,d0            ; set pen color to new col in d3
  507.     SYS    SetAPen            ; set the area pen to 1
  508.  
  509.     move.l    a2,a1            ; rastport in a1
  510.     move.l    #CHX1,d0        ; chx1 in d0
  511.     addq.w    #2,d0            ; add offset
  512.     move.l    d5,d1            ; chy1 in d1
  513.     addq.w    #2,d1            ; add offset
  514.     move.l    #CHX2,d2        ; chx2 in d2    
  515.     subq.w    #2,d2            ; subtract to get offset    
  516.     move.l    d4,d3            ; put chy2 in d3    
  517.     subq.w    #2,d3            ; subtract to get offset    
  518.     SYS    RectFill        ; rect fill that baby
  519.  
  520.     lea    curColor(a4),a1        ; get curcolor ptr
  521.     move.w    0(a1,d7.w),d6        ; put curcolor[new] in d6=rgb
  522.     bsr    mod_color_prop        ; mod_color_props uses d6=rgb
  523.     bsr.s    print_RGB        ; print_RGB uses d6=rgb
  524.     rts
  525.  
  526. * refresh color selected -------
  527.  
  528. mod_color:                ; color reg in d6
  529.                     ; modify sel'd color from slider
  530.     moveq    #12,d3            ; 12 bit shifter
  531.     lea    rInf(a4),a0        ; get ptr to red info struct
  532.     move.w    pi_HorizPot(a0),d0    ; get horiz pot value in d0
  533.     asr.w    d3,d0            ; asr 12 bits
  534.     and.l    #$0F,d0            ; mask the result
  535.     
  536.     lea    gInf(a4),a0        ; get ptr to green info struct
  537.     move.w    pi_HorizPot(a0),d1    ; get horiz pot value in d1
  538.     asr.w    d3,d1            ; asr 12 bits
  539.     and.l    #$0F,d1            ; mask the result
  540.     
  541.     lea    bInf(a4),a0        ; get ptr to blue info struct
  542.     move.w    pi_HorizPot(a0),d2    ; get horiz pot value in d2
  543.     asr.w    d3,d2            ; asr 12 bits
  544.     and.l    #$0F,d2            ; mask the result
  545.                     ; d0=red, d1=green, d2=blue
  546.     asl.l    #8,d0            ; shift the red 8 bits
  547.     asl.l    #4,d1            ; shift the green 4 bits
  548.     or.l    d1,d0            ; OR them with blue
  549.     or.l    d2,d0            ; new color value
  550.     move.w    d6,d1            ; stash the rgb value
  551.     add.w    d1,d1            ; get color*2 bytes in d1
  552.     lea    curColor(a4),a1        ; get ptr to curcolor
  553.     move.w    d0,0(a1,d1.w)        ; stuff curcolor[n] with colorvalue    
  554.     move.w    d0,d6            ; put current color in d6
  555.     moveq    #0,d0            ; clr d0 for the call
  556.     move.w    nColors(a4),d0        ; move # colors to d0
  557.     move.l    pVp(a4),a0        ; viewport in a0
  558.     SYS    LoadRGB4,GBase(a4)    ; load the colors
  559.                     ; fall thru into print_RGB
  560.  
  561. * print RGB hex value ----------
  562.  
  563. print_RGB:
  564.                     ; rgb value is in d6
  565.     move.w    d6,d1            ; move value red reg
  566.     asr.w    #8,d1            ; red value
  567.     and.l    #$F,d1            ; mask the red
  568.  
  569.     move.w    d6,d2            ; move value green reg
  570.     asr.w    #4,d2            ; green value
  571.     and.l    #$F,d2            ; mask the green
  572.  
  573.     move.w    d6,d0            ; move value blue reg
  574.     and.l    #$F,d0            ; mask the blue
  575.     
  576.     lea    rgbstring(a4),a5    ; get address of format string
  577.     lea    rgbdisplay(a4),a2    ; get address of display string
  578.     move.b    0(a5,d1.w),(a2)+    ; format the red into value    
  579.     move.b    0(a5,d2.w),(a2)+    ; format the green into value
  580.     move.b    0(a5,d0.w),(a2)        ; format the blue into value
  581.  
  582.     move.l    pRp(a4),a3        ; save rastport ptr in a3
  583.  
  584.     move.l    a3,a1            ; rastport in a1 for the call
  585.     moveq    #1,d0            ; got as a long
  586.     SYS    SetAPen,GBase(a4)    ; set the area pen
  587.  
  588.     move.l    a3,a1            ; rastport in a1 for the call
  589.     moveq    #0,d0            ; clr the reg
  590.     SYS    SetBPen            ; set the background pen
  591.  
  592.     move.l    a3,a1            ; rastport in a1 for the call
  593.     move.l    #RP_JAM2,d0        ; got as a long
  594.     SYS    SetDrMd            ; set the draw mode to overwrite
  595.  
  596.     move.l    a3,a1            ; rastport in a1 for the call
  597.     move.l    #PWIDE,d0        ; put in the x offset
  598.     sub.b    #40,d0            ; get the x value
  599.     move.l    pWin(a4),a0        ; get window ptr
  600.     moveq    #0,d1
  601.     move.w    wd_Height(a0),d1    ; get window height
  602.     sub.b    #40,d1            ; get the y value
  603.     SYS    Move            ; move tudere
  604.             
  605.     lea     rgbdisplay(a4),a0    ; string ptr in a0
  606.     move.l    a3,a1            ; rastport in a1 for the call
  607.     moveq    #3,d0            ; count in d0
  608.     SYS    Text            ; spit it out
  609.     rts
  610.     
  611. * ------------------------------
  612. * modify proportional gads -----
  613. * ------------------------------
  614.  
  615. * ModifyProp (IBase)            ; rgb value = d6
  616. * gadget->      a0
  617. * window->      a1
  618. * requester->     a2
  619. * pi_Flags    d0        
  620. * pi_HorizPot    d1
  621. * pi_VertPot    d2
  622. * pi_HorizBody    d3
  623. * pi_VertBody    d4
  624.  
  625. mod_color_prop:
  626.                     ; modify the red gadget
  627.     sub.l    a2,a2            ; clr the requester arg
  628.     move.l    #$11111111,d7        ; store the multiplier in d7
  629.  
  630.     move.w    d6,d1            ; move value red reg
  631.     asr.w    #8,d1            ; red value
  632.     and.l    #$F,d1            ; mask the red
  633.     muls.w    d7,d1            ; mult to get horiz pot val
  634.     lea    rGad(a4),a0        ; get the gadget address in a0
  635.     move.l    pWin(a4),a1        ; get the window ptr in a1
  636.     lea    rInf(a4),a3        ; get rInf ptr
  637.     moveq    #0,d0
  638.     move.l    d0,d2
  639.     move.l    d0,d3
  640.     move.l    d0,d4
  641.     move.w    pi_Flags(a3),d0        ; flags in d0
  642.     move.w    pi_VertPot(a3),d2    ; horiz pot in d2
  643.     move.w    pi_HorizBody(a3),d3    ; horiz body in d3
  644.     move.w    pi_VertBody(a3),d4    ; horiz body in d3
  645.     SYS    ModifyProp,IBase(a4)
  646.                     ; modify the green gad
  647.     move.w    d6,d1            ; move rgb value green reg
  648.     asr.w    #4,d1            ; green value
  649.     and.l    #$F,d1            ; mask the green
  650.     muls.w    d7,d1            ; mult to get horiz pot val
  651.     lea    gGad(a4),a0        ; get the gadget address in a0
  652.     move.l    pWin(a4),a1        ; get the window ptr in a1
  653.     lea    gInf(a4),a3        ; get rInf ptr
  654.     moveq    #0,d0
  655.     move.l    d0,d2
  656.     move.l    d0,d3
  657.     move.l    d0,d4
  658.     move.w    pi_Flags(a3),d0        ; flags in d0
  659.     move.w    pi_VertPot(a3),d2    ; horiz pot in d2
  660.     move.w    pi_HorizBody(a3),d3    ; horiz body in d3
  661.     move.w    pi_VertBody(a3),d4    ; horiz body in d3
  662.     SYS    ModifyProp
  663.                     ; modify the blue gad
  664.     move.w    d6,d1            ; move rgb value blue reg
  665.     and.l    #$F,d1            ; mask the blue
  666.     muls.w    d7,d1            ; mult to get horiz pot val
  667.     lea    bGad(a4),a0        ; get the gadget address in a0
  668.     move.l    pWin(a4),a1        ; get the window ptr in a1
  669.     lea    bInf(a4),a3        ; get rInf ptr
  670.     moveq    #0,d0
  671.     move.l    d0,d2
  672.     move.l    d0,d3
  673.     move.l    d0,d4
  674.     move.w    pi_Flags(a3),d0        ; flags in d0
  675.     move.w    pi_VertPot(a3),d2    ; horiz pot in d2
  676.     move.w    pi_HorizBody(a3),d3    ; horiz body in d3
  677.     move.w    pi_VertBody(a3),d4    ; horiz body in d3
  678.     SYS    ModifyProp        ; modify the gadget
  679.     rts
  680.  
  681. * ------------------------------        
  682. * reset_colors------------------
  683. * ------------------------------
  684.  
  685. reset_colors:                ; no args
  686.                     ; reset the default colors
  687.     lea    curColor(a4),a0        ; addr of curcolors in a0
  688.     lea    resColor(a4),a1        ; addr of resetcolors in a1
  689.     move.w    nColors(a4),d0        ; get the number of colors
  690.     subq.w    #1,d0            ; ready for dbra
  691.  
  692. resetloop:
  693.  
  694.     move.w    (a1)+,(a0)+        ; word copy the array
  695.     dbra    d0,resetloop        ; loop
  696.  
  697.     lea    resColor(a4),a1        ; get ptr to curcolor
  698.     moveq    #0,d0
  699.     move.w    nColors(a4),d0        ; move # colors to d0
  700.     move.l    pVp(a4),a0        ; viewport in a0
  701.     SYS    LoadRGB4,GBase(a4)    ; load the colors
  702.     rts
  703.  
  704. * ---------------------------------------
  705. * ----- INITIALIZED DATA SECTION --------
  706. * ---------------------------------------
  707.  
  708.     SECTION    __MERGED,DATA
  709.  
  710. * internally referenced data
  711.  
  712. r_text:
  713.     dc.b    'R',0
  714.     ds.w    0
  715.  
  716. g_text:
  717.     dc.b    'G',0
  718.     ds.w    0
  719.  
  720. b_text:
  721.     dc.b    'B',0
  722.     ds.w    0
  723.  
  724. can_text:
  725.     dc.b    'CANCEL',0
  726.     ds.w    0
  727.  
  728. reset_text:
  729.     dc.b    'RESET',0
  730.     ds.w    0
  731.  
  732. ok_text:
  733.     dc.b    'OK',0
  734.     ds.w    0
  735.  
  736. newpW_title:
  737.     dc.b    'Palette Tool V1.1',0
  738.     ds.w    0
  739.  
  740. canGad:                    ; Gadget structure
  741.     dc.l    rGad            ; gg_NextGadget
  742.     dc.w    TXTX+122        ; gg_LeftEdge
  743.     dc.w    TXTY            ; gg_TopEdge
  744.     dc.w    TXTW            ; gg_Width
  745.     dc.w    TXTH            ; gg_Height
  746.     dc.w    GADGHCOMP!GRELBOTTOM    ; gg_Flags
  747.     dc.w    RELVERIFY        ; gg_Activation
  748.     dc.w    BOOLGADGET        ; gg_GadgetType
  749.     dc.l    txtBor            ; gg_GadgetRender
  750.     dc.l    0            ; gg_SelectRender
  751.     dc.l    canTxt            ; gg_GadgetText
  752.     dc.l    0            ; gg_MutualExclude
  753.     dc.l    0            ; gg_SpecialInfo
  754.     dc.w    canID            ; gg_GadgetID
  755.     dc.l    0            ; gg_UserData
  756.  
  757. resGad:                    ; Gadget structure
  758.     dc.l    canGad            ; gg_NextGadget
  759.     dc.w    TXTX+61            ; gg_LeftEdge
  760.     dc.w    TXTY            ; gg_TopEdge
  761.     dc.w    TXTW            ; gg_Width
  762.     dc.w    TXTH            ; gg_Height
  763.     dc.w    GADGHCOMP!GRELBOTTOM    ; gg_Flags
  764.     dc.w    RELVERIFY        ; gg_Activation
  765.     dc.w    BOOLGADGET        ; gg_GadgetType
  766.     dc.l    txtBor            ; gg_GadgetRender
  767.     dc.l    0            ; gg_SelectRender
  768.     dc.l    resTxt            ; gg_GadgetText
  769.     dc.l    0            ; gg_MutualExclude
  770.     dc.l    0            ; gg_SpecialInfo
  771.     dc.w    resID            ; gg_GadgetID
  772.     dc.l    0            ; gg_UserData
  773.         
  774. txtBorXY:
  775.     dc.w    0            ; points for border structure
  776.     dc.w    0
  777.     dc.w    TXTW-1
  778.     dc.w    0
  779.     dc.w    TXTW-1
  780.     dc.w    TXTH-1
  781.     dc.w    0
  782.     dc.w    TXTH-1
  783.     dc.w    0
  784.     dc.w    0
  785.  
  786. txtBor:                    ; Border structure
  787.     dc.w    0            ; bd_LeftEdge
  788.     dc.w    0            ; bd_TopEdge
  789.     dc.b    3            ; bd_FrontPen
  790.     dc.b    0            ; bd_BackPen
  791.     dc.b    RP_JAM1            ; bd_DrawMode
  792.     dc.b    5            ; bd_Count
  793.     dc.l    txtBorXY        ; bd_XY
  794.     dc.l    0            ; bd_NextBorder
  795.  
  796. rTxt:                    ; IntuiText structure
  797.     dc.b    1            ; it_FrontPen
  798.     dc.b    0            ; it_BackPen
  799.     dc.b    RP_JAM1            ; it_DrawMode
  800.     dc.b    0            ; it_KludgeFill00
  801.     dc.w    -11            ; it_LeftEdge
  802.     dc.w    2            ; it_TopEdge
  803.     dc.l    0            ; it_ITextFont
  804.     dc.l    r_text            ; it_IText
  805.     dc.l    0            ; it_NextText
  806.  
  807. gTxt:                    ; IntuiText structure
  808.     dc.b    1            ; it_FrontPen
  809.     dc.b    0            ; it_BackPen
  810.     dc.b    RP_JAM1            ; it_DrawMode
  811.     dc.b    0            ; it_KludgeFill00
  812.     dc.w    -11            ; it_LeftEdge
  813.     dc.w    2            ; it_TopEdge
  814.     dc.l    0            ; it_ITextFont
  815.     dc.l    g_text            ; it_IText
  816.     dc.l    0            ; it_NextText
  817.  
  818. bTxt:                    ; IntuiText structure
  819.     dc.b    1            ; it_FrontPen
  820.     dc.b    0            ; it_BackPen
  821.     dc.b    RP_JAM1            ; it_DrawMode
  822.     dc.b    0            ; it_KludgeFill00
  823.     dc.w    -11            ; it_LeftEdge
  824.     dc.w    2            ; it_TopEdge
  825.     dc.l    0            ; it_ITextFont
  826.     dc.l    b_text            ; it_IText
  827.     dc.l    0            ; it_NextText
  828.  
  829. canTxt:                    ; IntuiText structure
  830.     dc.b    1            ; it_FrontPen
  831.     dc.b    0            ; it_BackPen
  832.     dc.b    RP_JAM1            ; it_DrawMode
  833.     dc.b    0            ; it_KludgeFill00
  834.     dc.w    4            ; it_LeftEdge
  835.     dc.w    3            ; it_TopEdge
  836.     dc.l    0            ; it_ITextFont
  837.     dc.l    can_text        ; it_IText
  838.     dc.l    0            ; it_NextText
  839.  
  840. resTxt:                    ; IntuiText structure
  841.     dc.b    1            ; it_FrontPen
  842.     dc.b    0            ; it_BackPen
  843.     dc.b    RP_JAM1            ; it_DrawMode
  844.     dc.b    0            ; it_KludgeFill00
  845.     dc.w    8            ; it_LeftEdge
  846.     dc.w    3            ; it_TopEdge
  847.     dc.l    0            ; it_ITextFont
  848.     dc.l    reset_text        ; it_IText
  849.     dc.l    0            ; it_NextText
  850.  
  851. okTxt:                    ; IntuiText structure
  852.     dc.b    1            ; it_FrontPen
  853.     dc.b    0            ; it_BackPen
  854.     dc.b    RP_JAM1            ; it_DrawMode
  855.     dc.b    0            ; it_KludgeFill00
  856.     dc.w    19            ; it_LeftEdge
  857.     dc.w    3            ; it_TopEdge
  858.     dc.l    0            ; it_ITextFont
  859.     dc.l    ok_text            ; it_IText
  860.     dc.l    0            ; it_NextText
  861.  
  862. * externally referenced data
  863.  
  864.     XDEF    rInf
  865.     XDEF    gInf
  866.     XDEF    bInf
  867.  
  868.     XDEF    rGad
  869.     XDEF    gGad
  870.     XDEF    bGad
  871.     XDEF    okGad
  872.  
  873.     XDEF    colBorXY
  874.     XDEF    colBor
  875.  
  876.     XDEF    newpWin
  877.     XDEF    pWin
  878.     XDEF    pScr
  879.  
  880.     XDEF    EBase
  881.     XDEF    GBase
  882.     XDEF    IBase
  883.     XDEF    wb_message
  884.  
  885.     XDEF    pImgs
  886.     XDEF    pGads
  887.  
  888.     XDEF    pUp
  889.     XDEF    pRp
  890.     XDEF    pVp
  891.  
  892.     XDEF    gadmemsize
  893.     XDEF    nColors
  894.     XDEF    nPlanes
  895.  
  896.     XDEF    gadwidth
  897.     XDEF    gadrows
  898.  
  899.     XDEF    gfxname
  900.     XDEF    intuiname
  901.     XDEF    rgbstring
  902.     XDEF    rgbdisplay
  903.     XDEF    pReg
  904.  
  905. rInf:                    ; PropInfo structure
  906.     dc.w    AUTOKNOB!FREEHORIZ    ; pi_Flags
  907.     dc.w    0            ; pi_HorizPot
  908.     dc.w    0            ; pi_VertPot
  909.     dc.w    RGB_BDY            ; pi_HorizBody
  910.     dc.w    0            ; pi_VertBody
  911.     dc.w    0            ; pi_CWidth
  912.     dc.w    0            ; pi_CHeight
  913.     dc.w    0            ; pi_HPotRes
  914.     dc.w    0            ; pi_VpotRes
  915.     dc.w    0            ; pi_LeftBorder
  916.     dc.w    0            ; pi_TopBorder
  917.  
  918. gInf:                    ; PropInfo structure
  919.     dc.w    AUTOKNOB!FREEHORIZ    ; pi_Flags
  920.     dc.w    0            ; pi_HorizPot
  921.     dc.w    0            ; pi_VertPot
  922.     dc.w    RGB_BDY            ; pi_HorizBody
  923.     dc.w    0            ; pi_VertBody
  924.     dc.w    0            ; pi_CWidth
  925.     dc.w    0            ; pi_CHeight
  926.     dc.w    0            ; pi_HPotRes
  927.     dc.w    0            ; pi_VpotRes
  928.     dc.w    0            ; pi_LeftBorder
  929.     dc.w    0            ; pi_TopBorder
  930.  
  931. bInf:                    ; PropInfo structure
  932.     dc.w    AUTOKNOB!FREEHORIZ    ; pi_Flags
  933.     dc.w    0            ; pi_HorizPot
  934.     dc.w    0            ; pi_VertPot
  935.     dc.w    RGB_BDY            ; pi_HorizBody
  936.     dc.w    0            ; pi_VertBody
  937.     dc.w    0            ; pi_CWidth
  938.     dc.w    0            ; pi_CHeight
  939.     dc.w    0            ; pi_HPotRes
  940.     dc.w    0            ; pi_VpotRes
  941.     dc.w    0            ; pi_LeftBorder
  942.     dc.w    0            ; pi_TopBorder
  943.  
  944. rGad:                    ; Gadget structure
  945.     dc.l    gGad            ; gg_NextGadget
  946.     dc.w    PRPX            ; gg_LeftEdge
  947.     dc.w    PRPY            ; gg_TopEdge
  948.     dc.w    PRPW            ; gg_Width
  949.     dc.w    PRPH            ; gg_Height
  950.     dc.w    GADGHNONE!GADGIMAGE!GRELBOTTOM        ; gg_Flags
  951.     dc.w    GADGIMMEDIATE!RELVERIFY!FOLLOWMOUSE    ; gg_Activation
  952.     dc.w    PROPGADGET        ; gg_GadgetType
  953.     dc.l    rImg            ; gg_GadgetRender
  954.     dc.l    0            ; gg_SelectRender
  955.     dc.l    rTxt            ; gg_GadgetText
  956.     dc.l    0            ; gg_MutualExclude
  957.     dc.l    rInf            ; gg_SpecialInfo
  958.     dc.w    rID            ; gg_GadgetID
  959.     dc.l    0            ; gg_UserData
  960.  
  961. gGad:                    ; Gadget structure
  962.     dc.l    bGad            ; gg_NextGadget
  963.     dc.w    PRPX            ; gg_LeftEdge
  964.     dc.w    PRPY+15            ; gg_TopEdge
  965.     dc.w    PRPW            ; gg_Width
  966.     dc.w    PRPH            ; gg_Height
  967.     dc.w    GADGHNONE!GADGIMAGE!GRELBOTTOM        ; gg_Flags
  968.     dc.w    GADGIMMEDIATE!RELVERIFY!FOLLOWMOUSE    ; gg_Activation
  969.     dc.w    PROPGADGET        ; gg_GadgetType
  970.     dc.l    gImg            ; gg_GadgetRender
  971.     dc.l    0            ; gg_SelectRender
  972.     dc.l    gTxt            ; gg_GadgetText
  973.     dc.l    0            ; gg_MutualExclude
  974.     dc.l    gInf            ; gg_SpecialInfo
  975.     dc.w    gID            ; gg_GadgetID
  976.     dc.l    0            ; gg_UserData
  977.         
  978. bGad:                    ; Gadget structure
  979.     dc.l    0            ; gg_NextGadget
  980.     dc.w    PRPX            ; gg_LeftEdge
  981.     dc.w    PRPY+30            ; gg_TopEdge
  982.     dc.w    PRPW            ; gg_Width
  983.     dc.w    PRPH            ; gg_Height
  984.     dc.w    GADGHNONE!GADGIMAGE!GRELBOTTOM        ; gg_Flags
  985.     dc.w    GADGIMMEDIATE!RELVERIFY!FOLLOWMOUSE    ; gg_Activation
  986.     dc.w    PROPGADGET        ; gg_GadgetType
  987.     dc.l    bImg            ; gg_GadgetRender
  988.     dc.l    0            ; gg_SelectRender
  989.     dc.l    bTxt            ; gg_GadgetText
  990.     dc.l    0            ; gg_MutualExclude
  991.     dc.l    bInf            ; gg_SpecialInfo
  992.     dc.w    bID            ; gg_GadgetID
  993.     dc.l    0            ; gg_UserData
  994.  
  995. okGad:                    ; Gadget structure
  996.     dc.l    resGad            ; gg_NextGadget
  997.     dc.w    TXTX            ; gg_LeftEdge
  998.     dc.w    TXTY            ; gg_TopEdge
  999.     dc.w    TXTW            ; gg_Width
  1000.     dc.w    TXTH            ; gg_Height
  1001.     dc.w    GADGHCOMP!GRELBOTTOM    ; gg_Flags
  1002.     dc.w    RELVERIFY        ; gg_Activation
  1003.     dc.w    BOOLGADGET        ; gg_GadgetType
  1004.     dc.l    txtBor            ; gg_GadgetRender
  1005.     dc.l    0            ; gg_SelectRender
  1006.     dc.l    okTxt            ; gg_GadgetText
  1007.     dc.l    0            ; gg_MutualExclude
  1008.     dc.l    0            ; gg_SpecialInfo
  1009.     dc.w    okID            ; gg_GadgetID
  1010.     dc.l    0            ; gg_UserData
  1011.  
  1012. colBorXY:
  1013.     dc.w    -2            ; points for border structure
  1014.     dc.w    -2
  1015.     dc.w    0
  1016.     dc.w    -2
  1017.     dc.w    0
  1018.     dc.w    COLH+1
  1019.     dc.w    -2
  1020.     dc.w    COLH+1
  1021.     dc.w    -2
  1022.     dc.w    -2
  1023.  
  1024. colBor:
  1025.     dc.w    0            ; bd_LeftEdge
  1026.     dc.w    0            ; bd_TopEdge
  1027.     dc.b    1            ; bd_FrontPen
  1028.     dc.b    0            ; bd_BackPen
  1029.     dc.b    RP_JAM1            ; bd_DrawMode
  1030.     dc.b    5            ; bd_Count
  1031.     dc.l    colBorXY        ; bd_XY
  1032.     dc.l    0            ; bd_NextBorder
  1033.  
  1034. newpWin:
  1035.                     ; NewWindow structure
  1036.     dc.w    36            ; nw_LeftEdge
  1037.     dc.w    24            ; nw_Top Edge
  1038.     dc.w    PWIDE            ; nw_Width
  1039.     dc.w    0            ; nw_Height    (SET before open)
  1040.     dc.b    2            ; nw_DetailPen
  1041.     dc.b    1            ; nw_BlockPen
  1042.     dc.l    MOUSEMOVE!GADGETUP!GADGETDOWN        ; nw_IDCMPFlags
  1043.     dc.l    WINDOWDRAG!ACTIVATE!SMART_REFRESH    ;nw_Flags
  1044.     dc.l    0            ; nw_FirstGadget(SET before open)    
  1045.     dc.l    0            ; nw_CheckMark
  1046.     dc.l    newpW_title        ; nw_Title
  1047.     dc.l    0            ; nw_Screen    (SET before open)
  1048.     dc.l    0            ; nw_BitMap
  1049.     dc.w    0            ; nw_MinWidth
  1050.     dc.w    0            ; nw_MinHeight
  1051.     dc.w    0            ; nw_MaxWidth
  1052.     dc.w    0            ; nw_MaxHeight
  1053.     dc.w    0            ; nw_Type    (SET before open)
  1054.  
  1055. EBase:
  1056.     dc.l    0            ; execbase in fast RAM
  1057.  
  1058. wb_message:
  1059.     dc.l    0            ; storage for WB message
  1060.  
  1061. GBase:
  1062.     dc.l    0            ; graphics in fast RAM
  1063.  
  1064. IBase:
  1065.     dc.l    0            ; intuition in fast RAM
  1066.  
  1067. pImgs:
  1068.     dc.l    0            ; Ptr to Image struct
  1069.  
  1070. pGads:
  1071.     dc.l    0            ; Ptr to Gadget struct
  1072.  
  1073. pWin:
  1074.     dc.l    0            ; pointer to Window structure
  1075.  
  1076. pVp:
  1077.     dc.l    0            ; pointer to ViewPort structure
  1078.  
  1079. pRp:
  1080.     dc.l    0            ; pointer to RastPort structure
  1081.  
  1082. pUp:
  1083.     dc.l    0            ; pointer to UserPort structure
  1084.  
  1085. pScr:
  1086.     dc.l    0            ; pointer to Screen structure
  1087.  
  1088. gadmemsize:
  1089.     dc.l    0            ; size of memory alloc'ed
  1090.  
  1091. nColors:
  1092.     dc.w    0            ; number of colors
  1093.  
  1094. nPlanes:    
  1095.     dc.w    0            ; number of bitplanes
  1096.  
  1097. gadwidth:
  1098.     dc.b    84            ; width for 2 colors
  1099.     dc.b    40            ; width for 4 colors
  1100.     dc.b    18            ; width for 8 colors
  1101.     dc.b    18            ; width for 16 colors
  1102.     dc.b    18            ; width for 32 colors
  1103.     ds.w    0
  1104.  
  1105. gadrows:
  1106.     dc.b    1            ; rows for 2 colors
  1107.     dc.b    1            ; rows for 4 colors
  1108.     dc.b    1            ; rows for 8 colors    
  1109.     dc.b    2            ; rows for 16 colors
  1110.     dc.b    4            ; rows for 32 colors
  1111.     ds.w    0
  1112.  
  1113. gfxname:
  1114.     dc.b    'graphics.library',0
  1115.     ds.w    0
  1116.  
  1117. intuiname:
  1118.     dc.b    'intuition.library',0
  1119.     ds.w    0
  1120.  
  1121. rgbstring:
  1122.     dc.b    '0123456789ABCDEF',0    ; display char array
  1123.     ds.w    0
  1124.  
  1125. rgbdisplay:                ; RGB display string
  1126.     dc.b    '000',0
  1127.     ds.w    0
  1128.  
  1129. pReg:
  1130.     dc.w    0            ;current color selected.
  1131.  
  1132. * ---------------------------------------
  1133. * ----- UNITIALIZED BSS DATA SECTION ----
  1134. * ---------------------------------------
  1135.  
  1136.     SECTION    __MERGED,BSS
  1137.  
  1138. * externally referenced data
  1139.  
  1140.     XDEF    rImg
  1141.     XDEF    gImg
  1142.     XDEF    bImg
  1143.     XDEF    colGadX
  1144.     XDEF    colGadY
  1145.     XDEF    curColor
  1146.     XDEF    resColor
  1147.  
  1148. rImg:                    ; size of Image structure
  1149.     ds.b    ig_SIZEOF
  1150.  
  1151. gImg:                    ; size of Image structure
  1152.     ds.b    ig_SIZEOF
  1153.  
  1154. bImg:                    ; size of Image structure
  1155.     ds.b    ig_SIZEOF
  1156.  
  1157. colGadX:                ; x-coord array for gads
  1158.     ds.w    MXCOLRS
  1159.  
  1160. colGadY:                ; y-coord array for gads
  1161.     ds.w    MXCOLRS
  1162.  
  1163. curColor:                ; current color array
  1164.     ds.w    MXCOLRS
  1165.  
  1166. resColor:                ; reset color array
  1167.     ds.w    MXCOLRS
  1168.  
  1169.     END
  1170.