home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 514b.lha / GadgetED_v2.3 / Source / gensrc.c < prev    next >
C/C++ Source or Header  |  1991-06-08  |  51KB  |  1,493 lines

  1. /*----------------------------------------------------------------------*
  2.    gensrc.c Version 2.3 -  © Copyright 1990-91 Jaba Development
  3.  
  4.    Author : Jan van den Baard
  5.    Purpose: What it's all about, the writing of C or Assembler source
  6.  *----------------------------------------------------------------------*/
  7.  
  8. extern struct GadgetList     Gadgets;
  9. extern struct Window        *MainWindow;
  10. extern struct Screen        *MainScreen;
  11. extern struct ge_prefs       prefs;
  12. extern struct Gadget         TextGadget;
  13. extern struct FileRequester *IODir;
  14. extern BOOL                  REQUESTER, WBSCREEN;
  15. extern UBYTE                 name[256], wdt[80], wlb[MAXLABEL];
  16. extern ULONG                 WindowFlags, IDCMPFlags;
  17. extern USHORT                BackFill, GadgetCount, WDBackFill;
  18.  
  19. BOOL   GenASM, HaveGad, MultyB;
  20.  
  21. struct GadgetList Borders;
  22.  
  23. /*
  24.  * split up the normal and 'BORDERONLY' gadgets in seperate lists
  25.  */
  26. static VOID split()
  27. {
  28.     register struct MyGadget *tmp;
  29.     register BCount = 0;
  30.  
  31.     NewList((void *)&Borders);
  32.  
  33.     if(!Gadgets.Head->Succ) return;
  34.  
  35.     while(1)
  36.     {   tmp = Gadgets.Head;
  37.         while(1)
  38.         {   if(TestBits((ULONG)tmp->SpecialFlags,BORDERONLY)) break;
  39.             if(!Gadgets.Head->Succ) return;
  40.             if((tmp = tmp->Succ) == (struct MyGadget *)&Gadgets.Tail) return;
  41.         }
  42.         Remove((void *)tmp);
  43.         AddHead((void *)&Borders,(void *)tmp);
  44.     }
  45. }
  46.  
  47. /*
  48.  * join the normal and 'BORDERONLY' gadgets again
  49.  */
  50. static VOID join()
  51. {
  52.     register struct MyGadget *tmp;
  53.  
  54.     while((tmp = (struct MyGadget *)RemHead((void *)&Borders)))
  55.          AddTail((void *)&Gadgets,(void *)tmp);
  56. }
  57.  
  58. /*
  59.  * write the IDCMPFlags
  60.  */
  61. static VOID WriteIFlags(file)
  62.     BPTR file;
  63. {
  64.     if(NOT IDCMPFlags)
  65.     {   if(GenASM)
  66.             WriteFormat(file,"0");
  67.         else
  68.             WriteFormat(file,"NULL");
  69.         return;
  70.     }
  71.     if(TestBits(IDCMPFlags,SIZEVERIFY))
  72.        WriteFormat(file,"SIZEVERIFY+");
  73.     if(TestBits(IDCMPFlags,NEWSIZE))
  74.        WriteFormat(file,"NEWSIZE+");
  75.     if(TestBits(IDCMPFlags,REFRESHWINDOW))
  76.        WriteFormat(file,"REFRESHWINDOW+");
  77.     if(TestBits(IDCMPFlags,ACTIVEWINDOW))
  78.        WriteFormat(file,"ACTIVEWINDOW+");
  79.     if(TestBits(IDCMPFlags,INACTIVEWINDOW))
  80.        WriteFormat(file,"INACTIVEWINDOW+");
  81.     if(TestBits(IDCMPFlags,GADGETDOWN))
  82.        WriteFormat(file,"GADGETDOWN+");
  83.     if(TestBits(IDCMPFlags,GADGETUP))
  84.        WriteFormat(file,"GADGETUP+");
  85.     if(TestBits(IDCMPFlags,CLOSEWINDOW))
  86.        WriteFormat(file,"CLOSEWINDOW+");
  87.     if(TestBits(IDCMPFlags,REQSET))
  88.        WriteFormat(file,"REQSET+");
  89.     if(TestBits(IDCMPFlags,REQCLEAR))
  90.        WriteFormat(file,"REQCLEAR+");
  91.     if(TestBits(IDCMPFlags,REQVERIFY))
  92.        WriteFormat(file,"REQVERIFY+");
  93.     if(TestBits(IDCMPFlags,MENUPICK))
  94.        WriteFormat(file,"MENUPICK+");
  95.     if(TestBits(IDCMPFlags,MENUVERIFY))
  96.        WriteFormat(file,"MENUVERIFY+");
  97.     if(TestBits(IDCMPFlags,MOUSEBUTTONS))
  98.        WriteFormat(file,"MOUSEBUTTONS+");
  99.     if(TestBits(IDCMPFlags,MOUSEMOVE))
  100.        WriteFormat(file,"MOUSEMOVE+");
  101.     if(TestBits(IDCMPFlags,DELTAMOVE))
  102.        WriteFormat(file,"DELTAMOVE+");
  103.     if(TestBits(IDCMPFlags,INTUITICKS))
  104.        WriteFormat(file,"INTUITICKS+");
  105.     if(TestBits(IDCMPFlags,NEWPREFS))
  106.        WriteFormat(file,"NEWPREFS+");
  107.     if(TestBits(IDCMPFlags,DISKINSERTED))
  108.        WriteFormat(file,"DISKINSERTED+");
  109.     if(TestBits(IDCMPFlags,DISKREMOVED))
  110.        WriteFormat(file,"DISKREMOVED+");
  111.     if(TestBits(IDCMPFlags,RAWKEY))
  112.        WriteFormat(file,"RAWKEY+");
  113.     if(TestBits(IDCMPFlags,VANILLAKEY))
  114.        WriteFormat(file,"VANILLAKEY+");
  115.     if(TestBits(IDCMPFlags,WBENCHMESSAGE))
  116.        WriteFormat(file,"WBENCHMESSAGE+");
  117.     if(TestBits(IDCMPFlags,LONELYMESSAGE))
  118.        WriteFormat(file,"LONELYMESSAGE+");
  119.     Seek(file,-1,OFFSET_CURRENT);
  120. }
  121.  
  122. /*
  123.  * write the window flags
  124.  */
  125. static VOID WriteWFlags(file)
  126.     BPTR file;
  127. {
  128.     if(NOT WindowFlags)
  129.     {   if(GenASM)
  130.             WriteFormat(file,"0");
  131.         else
  132.             WriteFormat(file,"NULL");
  133.         return;
  134.     }
  135.     if(TestBits(WindowFlags,WINDOWSIZING))
  136.       WriteFormat(file,"WINDOWSIZING+");
  137.     if(TestBits(WindowFlags,WINDOWDRAG))
  138.       WriteFormat(file,"WINDOWDRAG+");
  139.     if(TestBits(WindowFlags,WINDOWDEPTH))
  140.       WriteFormat(file,"WINDOWDEPTH+");
  141.     if(TestBits(WindowFlags,WINDOWCLOSE))
  142.       WriteFormat(file,"WINDOWCLOSE+");
  143.     if(TestBits(WindowFlags,SIZEBRIGHT))
  144.       WriteFormat(file,"SIZEBRIGHT+");
  145.     if(TestBits(WindowFlags,SIZEBBOTTOM))
  146.       WriteFormat(file,"SIZEBBOTTOM+");
  147.     if(TestBits(WindowFlags,NOCAREREFRESH))
  148.       WriteFormat(file,"NOCAREREFRESH+");
  149.     if(TestBits(WindowFlags,SIMPLE_REFRESH))
  150.       WriteFormat(file,"SIMPLE_REFRESH+");
  151.     if(TestBits(WindowFlags,SMART_REFRESH))
  152.       WriteFormat(file,"SMART_REFRESH+");
  153.     if(TestBits(WindowFlags,SUPER_BITMAP))
  154.       WriteFormat(file,"SUPER_BITMAP+");
  155.     if(TestBits(WindowFlags,BACKDROP))
  156.       WriteFormat(file,"BACKDROP+");
  157.     if(TestBits(WindowFlags,GIMMEZEROZERO))
  158.       WriteFormat(file,"GIMMEZEROZERO+");
  159.     if(TestBits(WindowFlags,BORDERLESS))
  160.       WriteFormat(file,"BORDERLESS+");
  161.     if(TestBits(WindowFlags,ACTIVATE))
  162.       WriteFormat(file,"ACTIVATE+");
  163.     if(TestBits(WindowFlags,REPORTMOUSE))
  164.       WriteFormat(file,"REPORTMOUSE+");
  165.     if(TestBits(WindowFlags,RMBTRAP))
  166.       WriteFormat(file,"RMBTRAP+");
  167.     Seek(file,-1,OFFSET_CURRENT);
  168. }
  169.  
  170. /*
  171.  * write the gadget flags
  172.  */
  173. static VOID WriteFlags(file,gad)
  174.     BPTR            file;
  175.     struct MyGadget *gad;
  176. {
  177.     struct Gadget *gadget;
  178.     ULONG   flags;
  179.  
  180.     gadget = &gad->Gadget;
  181.     flags   = (ULONG)gadget->Flags;
  182.  
  183.     if(NOT flags)
  184.     {   WriteFormat(file,"GADGHCOMP");
  185.         return;
  186.     }
  187.     if((TestBits(flags,GADGHIMAGE)) AND (TestBits(flags,GADGHBOX)))
  188.       WriteFormat(file,"GADGHNONE+");
  189.     else if(TestBits(flags,GADGHIMAGE))
  190.       WriteFormat(file,"GADGHIMAGE+");
  191.     else if(TestBits(flags,GADGHBOX))
  192.       WriteFormat(file,"GADGHBOX+");
  193.     else WriteFormat(file,"GADGHCOMP+");
  194.     if(TestBits(flags,GRELBOTTOM))
  195.       WriteFormat(file,"GRELBOTTOM+");
  196.     if(TestBits(flags,GRELRIGHT))
  197.       WriteFormat(file,"GRELRIGHT+");
  198.     if(TestBits(flags,GRELWIDTH))
  199.       WriteFormat(file,"GRELWIDTH+");
  200.     if(TestBits(flags,GRELHEIGHT))
  201.       WriteFormat(file,"GRELHEIGHT+");
  202.     if(TestBits(flags,GADGIMAGE))
  203.       WriteFormat(file,"GADGIMAGE+");
  204.     if(TestBits(flags,SELECTED))
  205.       WriteFormat(file,"SELECTED+");
  206.     if(TestBits((ULONG)gad->SpecialFlags,GADGETOFF))
  207.       WriteFormat(file,"GADGDISABLED+");
  208.     Seek(file,-1,OFFSET_CURRENT);
  209. }
  210.  
  211. /*
  212.  * write the activation gadget flags
  213.  */
  214. static VOID WriteActivation(file,gad)
  215.     BPTR            file;
  216.     struct MyGadget *gad;
  217. {
  218.     struct Gadget   *gadget;
  219.     ULONG  act;
  220.  
  221.     gadget = &gad->Gadget;
  222.     act    = (ULONG)gadget->Activation;
  223.  
  224.     if(TestBits(act,TOGGLESELECT))
  225.       WriteFormat(file,"TOGGLESELECT+");
  226.     if(NOT TestBits(gad->SpecialFlags,NOSIGNAL))
  227.     {   if(TestBits(act,RELVERIFY))
  228.           WriteFormat(file,"RELVERIFY+");
  229.         if(TestBits(act,GADGIMMEDIATE))
  230.           WriteFormat(file,"GADGIMMEDIATE+");
  231.     }
  232.     if(TestBits(act,RIGHTBORDER))
  233.       WriteFormat(file,"RIGHTBORDER+");
  234.     if(TestBits(act,LEFTBORDER))
  235.       WriteFormat(file,"LEFTBORDER+");
  236.     if(TestBits(act,TOPBORDER))
  237.       WriteFormat(file,"TOPBORDER+");
  238.     if(TestBits(act,BOTTOMBORDER))
  239.       WriteFormat(file,"BOTTOMBORDER+");
  240.     if(TestBits(act,STRINGCENTER))
  241.       WriteFormat(file,"STRINGCENTER+");
  242.     if(TestBits(act,STRINGRIGHT))
  243.       WriteFormat(file,"STRINGRIGHT+");
  244.     if(TestBits(act,LONGINT))
  245.       WriteFormat(file,"LONGINT+");
  246.     if(TestBits(act,ALTKEYMAP))
  247.       WriteFormat(file,"ALTKEYMAP+");
  248.     if(TestBits(act,BOOLEXTEND))
  249.       WriteFormat(file,"BOOLEXTEND+");
  250.     if(TestBits(act,ENDGADGET))
  251.       WriteFormat(file,"ENDGADGET+");
  252.     if(TestBits(act,FOLLOWMOUSE))
  253.       WriteFormat(file,"FOLLOWMOUSE+");
  254.     Seek(file,-1,OFFSET_CURRENT);
  255. }
  256.  
  257. /*
  258.  * write the gadget type
  259.  */
  260. static VOID WriteType(file,gad)
  261.     BPTR            file;
  262.     struct MyGadget *gad;
  263. {
  264.     struct Gadget   *gadget;
  265.     ULONG   type;
  266.  
  267.     gadget = &gad->Gadget;
  268.     type   = (ULONG)gadget->GadgetType;
  269.  
  270.     if(TestBits(type,PROPGADGET))
  271.       WriteFormat(file,"PROPGADGET+");
  272.     else if(TestBits(type,STRGADGET))
  273.       WriteFormat(file,"STRGADGET+");
  274.     else if(TestBits(type,BOOLGADGET))
  275.       WriteFormat(file,"BOOLGADGET+");
  276.     if(TestBits((ULONG)gad->SpecialFlags,GZZGADGET))
  277.       WriteFormat(file,"GZZGADGET+");
  278.     if(REQUESTER)
  279.       WriteFormat(file,"REQGADGET+");
  280.     Seek(file,-1,OFFSET_CURRENT);
  281. }
  282.  
  283. /*
  284.  * write the draw modes
  285.  */
  286. static VOID WriteDrMd(file,drmd,mode)
  287.     BPTR file;
  288.     ULONG drmd;
  289.     BOOL  mode; /* TRUE = Asm, FALSE = C */
  290. {
  291.     if(TestBits(drmd,JAM2))
  292.     {   if(mode) WriteFormat(file,"RP_JAM2+");
  293.         else     WriteFormat(file,"JAM2+");
  294.     }
  295.     else if(TestBits(drmd,JAM1))
  296.     {   if(mode) WriteFormat(file,"RP_JAM1+");
  297.         else     WriteFormat(file,"JAM1+");
  298.     }
  299.     if(TestBits(drmd,COMPLEMENT))
  300.     if(mode) WriteFormat(file,"RP_COMPLEMENT+");
  301.     else     WriteFormat(file,"COMPLEMENT+");
  302.     if(TestBits(drmd,INVERSVID))
  303.     if(mode) WriteFormat(file,"RP_INVERSVID+");
  304.     else     WriteFormat(file,"INVERSVID+");
  305.     Seek(file,-1,OFFSET_CURRENT);
  306. }
  307.  
  308. /*
  309.  * write the propinfo flags
  310.  */
  311. static VOID WritePFlags(file,info)
  312.     BPTR            file;
  313.     struct PropInfo *info;
  314. {
  315.     ULONG flags;
  316.  
  317.     flags = (ULONG)info->Flags;
  318.  
  319.     if(TestBits(flags,AUTOKNOB))
  320.      WriteFormat(file,"AUTOKNOB+");
  321.     if(TestBits(flags,FREEHORIZ))
  322.      WriteFormat(file,"FREEHORIZ+");
  323.     if(TestBits(flags,FREEVERT))
  324.      WriteFormat(file,"FREEVERT+");
  325.     if(TestBits(flags,PROPBORDERLESS))
  326.      WriteFormat(file,"PROPBORDERLESS+");
  327.     Seek(file,-1,OFFSET_CURRENT);
  328. }
  329.  
  330. #define RAWINC  prefs.no_flags
  331.  
  332. /*
  333.  * write the assembler border structure
  334.  */
  335. static VOID WriteAsmBorder(file,gadget)
  336.     BPTR            file;
  337.     struct MyGadget *gadget;
  338. {
  339.     struct Border *border;
  340.     SHORT         *XY;
  341.     COUNT    i,x=0;
  342.  
  343.     border = (struct Border *)gadget->Gadget.GadgetRender;
  344.     XY     = border->XY;
  345.  
  346.     while(1)
  347.     {
  348.         WriteFormat(file,"%s_pairs%ld:\n    DC.W    ",&gadget->GadgetLabel,x);
  349.         for(i=0;i<(border->Count << 1);i++) WriteFormat(file,"%ld,",XY[i]);
  350.         Seek(file,-1,OFFSET_CURRENT);
  351.         WriteFormat(file,"\n\n");
  352.         WriteFormat(file,"%s_bord%ld:\n",&gadget->GadgetLabel,x);
  353.         WriteFormat(file,"    DC.W    %ld,%ld\n",border->LeftEdge,border->TopEdge);
  354.         WriteFormat(file,"    DC.B    %ld,%ld\n",border->FrontPen,border->BackPen);
  355.         WriteFormat(file,"    DC.B    ");
  356.         if(RAWINC)
  357.             WriteFormat(file,"$%02lx",border->DrawMode);
  358.         else
  359.             WriteDrMd(file,(ULONG)border->DrawMode,TRUE);
  360.         WriteFormat(file,"\n    DC.B    %ld\n",border->Count);
  361.         WriteFormat(file,"    DC.L    %s_pairs%ld\n",&gadget->GadgetLabel,x++);
  362.         if(border = border->NextBorder)
  363.         {   WriteFormat(file,"    DC.L    %s_bord%ld\n\n",&gadget->GadgetLabel,x);
  364.             XY = border->XY;
  365.         }
  366.         else
  367.         {   WriteFormat(file,"    DC.L    0\n\n");
  368.             break;
  369.         }
  370.     }
  371. }
  372.  
  373. /*
  374.  * write the assembler image
  375.  */
  376. static VOID WriteAsmImage(file,gadget,which)
  377.     BPTR            file;
  378.     struct MyGadget *gadget;
  379.     UBYTE           which;
  380. {
  381.     struct Image    *image;
  382.     register USHORT *data;
  383.     register COUNT  i,ii;
  384.     ULONG           data_size;
  385.  
  386.     if(which == RENDER) image = (struct Image *)gadget->Gadget.GadgetRender;
  387.     else                image = (struct Image *)gadget->Gadget.SelectRender;
  388.     data  = image->ImageData;
  389.  
  390.     if(which != STDPRP)
  391.     {   if(which == SELECT)
  392.           WriteFormat(file,"%s_hdata:\n",gadget->GadgetLabel);
  393.         else
  394.           WriteFormat(file,"%s_data:\n",gadget->GadgetLabel);
  395.         data_size = (RASSIZE(image->Width,image->Height) * image->Depth);
  396.         for(i=0;i<(data_size >> 1);i+=8)
  397.         {   WriteFormat(file,"    DC.W    ");
  398.             for(ii=0;ii<8;ii++)
  399.             {   if(i+ii < (data_size >> 1)) WriteFormat(file,"$%04lx,",data[i+ii]);
  400.             }
  401.             Seek(file,-1,OFFSET_CURRENT);
  402.             WriteFormat(file,"\n");
  403.         }
  404.         WriteFormat(file,"\n");
  405.     }
  406.     if(which == SELECT)
  407.       WriteFormat(file,"%s_himage:\n",&gadget->GadgetLabel);
  408.     else
  409.       WriteFormat(file,"%s_image:\n",&gadget->GadgetLabel);
  410.     WriteFormat(file,"    DC.W    %ld,%ld\n",image->LeftEdge,image->TopEdge);
  411.     WriteFormat(file,"    DC.W    %ld,%ld\n",image->Width,image->Height);
  412.     WriteFormat(file,"    DC.W    %ld\n",image->Depth);
  413.     if(which != STDPRP)
  414.     {   if(which == SELECT)
  415.           WriteFormat(file,"    DC.L    %s_hdata\n",&gadget->GadgetLabel);
  416.         else
  417.           WriteFormat(file,"    DC.L    %s_data\n",&gadget->GadgetLabel);
  418.     }
  419.     else WriteFormat(file,"    DC.L    0\n");
  420.     WriteFormat(file,"    DC.B    $%02lx\n",image->PlanePick);
  421.     WriteFormat(file,"    DC.B    $%02lx\n",image->PlaneOnOff);
  422.     WriteFormat(file,"    DC.L    0\n\n");
  423. }
  424.  
  425. /*
  426.  * write the assembler prop info structure
  427.  */
  428. static VOID WriteAsmPinfo(file,gadget)
  429.     BPTR            file;
  430.     struct MyGadget *gadget;
  431. {
  432.     struct PropInfo *info;
  433.  
  434.     info = (struct PropInfo *)gadget->Gadget.SpecialInfo;
  435.     WriteFormat(file,"%s_info:\n",&gadget->GadgetLabel);
  436.     WriteFormat(file,"    DC.W    ");
  437.     if(RAWINC)
  438.         WriteFormat(file,"$%04lx",info->Flags);
  439.     else
  440.         WritePFlags(file,info);
  441.     WriteFormat(file,"\n    DC.W    $%04lx\n",info->HorizPot);
  442.     WriteFormat(file,"    DC.W    $%04lx\n",info->VertPot);
  443.     WriteFormat(file,"    DC.W    $%04lx\n",info->HorizBody);
  444.     WriteFormat(file,"    DC.W    $%04lx\n",info->VertBody);
  445.     WriteFormat(file,"    DC.W    0,0,0,0,0,0\n\n");
  446. }
  447.  
  448. /*
  449.  * write the assembler string info structure
  450.  */
  451. static VOID WriteAsmSinfo(file,gadget)
  452.     BPTR            file;
  453.     struct MyGadget *gadget;
  454. {
  455.     struct StringInfo *info;
  456.  
  457.     info = (struct StringInfo *)gadget->Gadget.SpecialInfo;
  458.     WriteFormat(file,"%s_info:\n",&gadget->GadgetLabel);
  459.     WriteFormat(file,"    DC.L    %s_buf\n",&gadget->GadgetLabel);
  460.     if(info->UndoBuffer)
  461.        WriteFormat(file,"    DC.L    %s_ubuf\n",&gadget->GadgetLabel);
  462.     else
  463.        WriteFormat(file,"    DC.L    0\n");
  464.     WriteFormat(file,"    DC.W    0,%ld\n",info->MaxChars);
  465.     WriteFormat(file,"    DC.W    0,0,0,0,0,0\n");
  466.     WriteFormat(file,"    DC.L    0,0,0\n\n");
  467.     WriteFormat(file,"%s_buf:\n",&gadget->GadgetLabel);
  468.     if(strlen(info->Buffer))
  469.     {
  470.         WriteFormat(file,"    DC.B    '%s',0\n",info->Buffer);
  471.         WriteFormat(file,"    DCB.B   %ld,0\n",info->MaxChars - strlen((char *)info->Buffer) -1);
  472.     }
  473.     else
  474.         WriteFormat(file,"    DCB.B   %ld\n",info->MaxChars);
  475.     WriteFormat(file,"    CNOP    0,2\n\n");
  476.     if(info->UndoBuffer)
  477.     {   WriteFormat(file,"%s_ubuf:\n    DCB.B    %ld,0\n",&gadget->GadgetLabel,info->MaxChars);
  478.         WriteFormat(file,"    CNOP    0,2\n\n");
  479.     }
  480. }
  481.  
  482. /*
  483.  * write the assembler gadget structure
  484.  */
  485. static VOID WriteAsmGadget(file,gadget)
  486.     BPTR            file;
  487.     struct MyGadget *gadget;
  488. {
  489.     struct Gadget   *gad;
  490.     struct MyGadget *next;
  491.  
  492.     gad = &gadget->Gadget;
  493.  
  494.     WriteFormat(file,"%s_ID   EQU     %ld\n\n",&gadget->GadgetLabel,gad->GadgetID);
  495.  
  496.     WriteFormat(file,"%s:\n",&gadget->GadgetLabel);
  497.     if(gadget == Gadgets.Head)
  498.     {   if((TextGadget.GadgetText) OR
  499.            (Borders.TailPred != (struct MyGadget *)&Borders))
  500.         {   if(NOT REQUESTER) WriteFormat(file,"    DC.L    Render\n");
  501.             else WriteFormat(file,"    DC.L    0\n");
  502.         }
  503.         else WriteFormat(file,"    DC.L    0\n");
  504.     }
  505.     else
  506.        WriteFormat(file,"    DC.L    %s\n",&(gadget->Pred->GadgetLabel));
  507.     WriteFormat(file,"    DC.W    %ld,%ld\n",gad->LeftEdge,gad->TopEdge);
  508.     WriteFormat(file,"    DC.W    %ld,%ld\n",gad->Width,gad->Height);
  509.     WriteFormat(file,"    DC.W    ");
  510.     if(RAWINC)
  511.         WriteFormat(file,"$%04lx",gad->Flags);
  512.     else
  513.         WriteFlags(file,gadget);
  514.     WriteFormat(file,"\n    DC.W    ");
  515.     if(RAWINC)
  516.         WriteFormat(file,"$%04lx",gad->Activation);
  517.     else
  518.         WriteActivation(file,gadget);
  519.     WriteFormat(file,"\n    DC.W    ");
  520.     if(RAWINC)
  521.         WriteFormat(file,"$%04lx",gad->GadgetType);
  522.     else
  523.         WriteType(file,gadget);
  524.  
  525.     if((TestBits((ULONG)gad->Flags,GADGIMAGE)) ||
  526.        (TestBits((ULONG)gad->GadgetType,PROPGADGET)))
  527.       WriteFormat(file,"\n    DC.L    %s_image\n",&gadget->GadgetLabel);
  528.     else if(NOT TestBits((ULONG)gadget->SpecialFlags,NOBORDER))
  529.       WriteFormat(file,"\n    DC.L    %s_bord0\n",&gadget->GadgetLabel);
  530.     else
  531.       WriteFormat(file,"\n    DC.L    0\n");
  532.     if((TestBits((ULONG)gad->Flags,GADGHIMAGE)) AND
  533.        (NOT TestBits((ULONG)gad->Flags,GADGHBOX)))
  534.       WriteFormat(file,"    DC.L    %s_himage\n",&gadget->GadgetLabel);
  535.     else
  536.       WriteFormat(file,"    DC.L    0\n");
  537.     if(gad->GadgetText)
  538.       WriteFormat(file,"    DC.L    %s_text0,0\n",&gadget->GadgetLabel);
  539.     else
  540.       WriteFormat(file,"    DC.L    0,0\n");
  541.     if(gad->SpecialInfo)
  542.       WriteFormat(file,"    DC.L    %s_info\n",&gadget->GadgetLabel);
  543.     else
  544.       WriteFormat(file,"    DC.L    0\n");
  545.     WriteFormat(file,"    DC.W    %s_ID\n    DC.L    0\n\n",&gadget->GadgetLabel);
  546. }
  547.  
  548. /*
  549.  * write the assembler IntuitText structures
  550.  */
  551. static VOID WriteAsmTexts(file,gadget)
  552.     BPTR            file;
  553.     struct MyGadget *gadget;
  554. {
  555.     register struct IntuiText *itext;
  556.     COUNT    i=0;
  557.  
  558.     if((itext = gadget->Gadget.GadgetText))
  559.     {   WriteFormat(file,"%s_text%ld:\n",&gadget->GadgetLabel,i);
  560.         while(1)
  561.         {   WriteFormat(file,"    DC.B    %ld,%ld\n",itext->FrontPen,itext->BackPen);
  562.             WriteFormat(file,"    DC.B    ");
  563.             if(RAWINC)
  564.                 WriteFormat(file,"$%02lx",itext->DrawMode);
  565.             else
  566.                 WriteDrMd(file,itext->DrawMode,TRUE);
  567.             WriteFormat(file,"\n    DC.W    %ld,%ld\n",itext->LeftEdge,itext->TopEdge);
  568.             WriteFormat(file,"    DC.L    0\n");
  569.             WriteFormat(file,"    DC.L    %s_itext%ld\n",&gadget->GadgetLabel,i);
  570.             if(itext->NextText)
  571.               WriteFormat(file,"    DC.L    %s_text%ld\n\n",&gadget->GadgetLabel,i+1);
  572.             else
  573.               WriteFormat(file,"    DC.L    0\n\n");
  574.             WriteFormat(file,"%s_itext%ld:\n",&gadget->GadgetLabel,i++);
  575.             WriteFormat(file,"    DC.B    '%s',0\n",itext->IText);
  576.             WriteFormat(file,"    CNOP    0,2\n\n");
  577.             if(!(itext = itext->NextText)) break;
  578.             WriteFormat(file,"%s_text%ld\n",&gadget->GadgetLabel,i);
  579.         }
  580.     }
  581. }
  582.  
  583. /*
  584.  * write the assembler new screen structure
  585.  */
  586. static VOID WriteAsmScreen(file)
  587.     BPTR file;
  588. {
  589.     WriteFormat(file,"ns:\n");
  590.     WriteFormat(file,"    DC.W    0,0,%ld,%ld\n",MainScreen->Width,MainScreen->Height);
  591.     WriteFormat(file,"    DC.W    %ld\n",MainScreen->BitMap.Depth);
  592.     WriteFormat(file,"    DC.B    -1,-1\n");
  593.     if(MainScreen->BitMap.Depth == 5) WriteFormat(file,"    DC.W    0\n");
  594.     else
  595.     {   if(RAWINC)
  596.             WriteFormat(file,"    DC.W    $8000\n");
  597.         else
  598.             WriteFormat(file,"    DC.W    V_HIRES\n");
  599.     }
  600.     if(RAWINC)
  601.         WriteFormat(file,"    DC.W    $0001\n");
  602.     else
  603.         WriteFormat(file,"    DC.W    CUSTOMSCREEN\n");
  604.     WriteFormat(file,"    DC.L    0,0,0,0\n\n");
  605. }
  606.  
  607. /*
  608.  * write the assembler window/requester structure
  609.  */
  610. static VOID WriteAsmRW(file)
  611.     BPTR file;
  612. {
  613.     if(REQUESTER)
  614.     {   WriteFormat(file,"requester:\n    DC.L    0\n");
  615.         WriteFormat(file,"    DC.W    %ld,%ld,",(MainWindow->LeftEdge + MainWindow->BorderLeft),
  616.                                                 (MainWindow->TopEdge + MainWindow->BorderTop));
  617.         WriteFormat(file,"%ld,%ld\n",MainWindow->GZZWidth,MainWindow->GZZHeight);
  618.         if(GadgetCount)
  619.             WriteFormat(file,"    DC.W    0,0\n    DC.L    %s,",&Gadgets.TailPred->GadgetLabel);
  620.         else
  621.             WriteFormat(file,"    DC.W    0,0\n    DC.L    0");
  622.         if(Borders.TailPred != (struct MyGadget *)&Borders)
  623.           WriteFormat(file,"Border0_bord0\n");
  624.         else
  625.           WriteFormat(file,"0\n");
  626.         if(TextGadget.GadgetText) WriteFormat(file,"    DC.L    Render_text0\n");
  627.         else WriteFormat(file,"    DC.L    0\n");
  628.         WriteFormat(file,"    DC.W    0\n    DC.B    %ld\n",BackFill);
  629.         WriteFormat(file,"    DC.L    0\n    DCB.B   32,0\n    DC.L    0,0\n    DCB.B    36,0\n\n");
  630.     }
  631.     else
  632.     {   WriteFormat(file,"%s:\n",&wlb);
  633.         WriteFormat(file,"    DC.W    %ld,%ld,%ld,%ld\n",MainWindow->LeftEdge,MainWindow->TopEdge,
  634.                                                          MainWindow->Width,MainWindow->Height);
  635.         WriteFormat(file,"    DC.B    %ld,%ld\n",MainWindow->DetailPen,MainWindow->BlockPen);
  636.         WriteFormat(file,"    DC.L    ");
  637.         if(RAWINC)
  638.             WriteFormat(file,"$%08lx",IDCMPFlags);
  639.         else
  640.             WriteIFlags(file);
  641.         WriteFormat(file,"\n    DC.L    ");
  642.         if(RAWINC)
  643.             WriteFormat(file,"$%08lx",WindowFlags);
  644.         else
  645.             WriteWFlags(file);
  646.         WriteFormat(file,"\n");
  647.         if(HaveGad)
  648.             WriteFormat(file,"    DC.L    %s,0\n",Gadgets.TailPred->GadgetLabel);
  649.         else if(Borders.TailPred != (struct MyGadget *)&Borders)
  650.             WriteFormat(file,"    DC.L    Render,0\n");
  651.         else
  652.             WriteFormat(file,"    DC.L    0,0\n");
  653.         if(strlen((char *)&wdt))
  654.             WriteFormat(file,"    DC.L    %s_title\n",&wlb);
  655.         else
  656.             WriteFormat(file,"    DC.L    0\n");
  657.         WriteFormat(file,"    DC.L    0,0\n");
  658.         WriteFormat(file,"    DC.W    %ld,%ld,%ld,%ld,",MainWindow->MinWidth,
  659.                                                         MainWindow->MinHeight,
  660.                                                         MainWindow->MaxWidth,
  661.                                                         MainWindow->MaxHeight);
  662.         if(WBSCREEN)
  663.         {   if(RAWINC)
  664.                 WriteFormat(file,"$0001\n\n");
  665.             else
  666.                 WriteFormat(file,"WBENCHSCREEN\n\n");
  667.         }
  668.         else
  669.         {   if(RAWINC)
  670.                 WriteFormat(file,"$000F\n\n");
  671.             else
  672.                 WriteFormat(file,"CUSTOMSCREEN\n\n");
  673.         }
  674.         if(strlen((char *)&wdt))
  675.             WriteFormat(file,"%s_title:\n    DC.B    '%s',0\n    CNOP    0,2\n\n",&wlb,&wdt);
  676.     }
  677. }
  678.  
  679. /*
  680.  * write the assembler window/requester texts
  681.  */
  682. static VOID WriteAsmWDT(file)
  683.     BPTR file;
  684. {
  685.     register struct IntuiText *t, *t1;
  686.     register UCOUNT i = 0;
  687.  
  688.     if(NOT TextGadget.GadgetText) return;
  689.  
  690.     t = t1 = TextGadget.GadgetText;
  691.     WriteFormat(file,"Render_text%ld:\n",i);
  692.     while(1)
  693.     {   WriteFormat(file,"    DC.B    %ld,%ld\n",t->FrontPen,t->BackPen);
  694.         WriteFormat(file,"    DC.B    ");
  695.         if(RAWINC)
  696.             WriteFormat(file,"$%02lx",t->DrawMode);
  697.         else
  698.             WriteDrMd(file,t->DrawMode);
  699.         WriteFormat(file,"\n    DC.W    %ld,%ld\n",t->LeftEdge,t->TopEdge);
  700.         WriteFormat(file,"    DC.L    0\n");
  701.         WriteFormat(file,"    DC.L    Render_itext%ld\n",i);
  702.         if(t->NextText)
  703.           WriteFormat(file,"    DC.L    Render_text%ld\n\n",i+1);
  704.         else
  705.           WriteFormat(file,"    DC.L    0\n\n");
  706.         WriteFormat(file,"Render_itext%ld:\n",i++);
  707.         WriteFormat(file,"    DC.B    '%s',0\n",t->IText);
  708.         WriteFormat(file,"    CNOP    0,2\n\n");
  709.         if(!(t = t->NextText)) break;
  710.         WriteFormat(file,"Render_text%ld\n",i);
  711.     }
  712. }
  713.  
  714. /*
  715.  * write assembler special render gadget
  716.  */
  717. static VOID WriteAsmCRG(file)
  718.     BPTR file;
  719. {
  720.     if((TextGadget.GadgetText) OR
  721.        (Borders.TailPred != (struct MyGadget *)&Borders))
  722.     {   if(NOT REQUESTER)
  723.         {   WriteFormat(file,"Render:\n");
  724.            if(RAWINC)
  725.             WriteFormat(file,"    DC.L    0\n    DC.W    0,0,1,1,$0003,0,$0001\n");
  726.            else
  727.             WriteFormat(file,"    DC.L    0\n    DC.W    0,0,1,1,GADGHNONE,0,BOOLGADGET\n");
  728.            if(Borders.TailPred != (struct MyGadget *)&Borders)
  729.              WriteFormat(file,"    DC.L    Border0_bord0,");
  730.            else
  731.              WriteFormat(file,"    DC.L    0,");
  732.            if(TextGadget.GadgetText)
  733.              WriteFormat(file,"0,Render_text0,");
  734.            else
  735.              WriteFormat(file,"0,0,");
  736.              WriteFormat(file,"0,0\n    DC.W    0\n    DC.L    0\n\n");
  737.        }
  738.     }
  739. }
  740.  
  741. /*
  742.  * write the assembler border structures
  743.  */
  744. static VOID WriteAsmB(file)
  745.     BPTR file;
  746. {
  747.     register struct MyGadget *g;
  748.     register struct Border   *b;
  749.     register SHORT           *xy;
  750.     register UCOUNT           bc = 0,xyc;
  751.  
  752.     if(Borders.TailPred == (struct MyGadget *)&Borders) return;
  753.  
  754.     g = Borders.Head;
  755.  
  756.     while(1)
  757.     {
  758.         b = (struct Border *)g->Gadget.GadgetRender;
  759.         while(1)
  760.         {   xy = b->XY;
  761.             WriteFormat(file,"Border%ld_pairs%ld:\n    DC.W   ",bc,bc);
  762.             for(xyc = 0;xyc < (b->Count << 1);xyc++) WriteFormat(file,"%ld,",xy[xyc]);
  763.             Seek(file,-1,OFFSET_CURRENT);
  764.             WriteFormat(file,"\n");
  765.             bc++;
  766.             if(!(b = b->NextBorder)) break;
  767.         }
  768.         if((g = g->Succ) == (struct MyGadget *)&Borders.Tail) break;
  769.     }
  770.     WriteFormat(file,"\n");
  771.  
  772.     bc = 0;
  773.     g = Borders.Head;
  774.     while(1)
  775.     {   b = (struct Border *)g->Gadget.GadgetRender;
  776.         while(1)
  777.         {   WriteFormat(file,"Border%ld_bord%ld:\n",bc,bc);
  778.             WriteFormat(file,"    DC.W    %ld,%ld\n",g->Gadget.LeftEdge,g->Gadget.TopEdge);
  779.             if(RAWINC)
  780.                 WriteFormat(file,"    DC.B    %ld,0\n    DC.B    $00,%ld\n",b->FrontPen,b->Count);
  781.             else
  782.                 WriteFormat(file,"    DC.B    %ld,0\n    DC.B    RP_JAM1,%ld\n",b->FrontPen,b->Count);
  783.             WriteFormat(file,"    DC.L    Border%ld_pairs%ld,",bc,bc);
  784.             bc++;
  785.             if(!(b = b->NextBorder))
  786.             {   if(g->Succ == (struct MyGadget *)&Borders.Tail)
  787.                     WriteFormat(file,"0\n\n");
  788.                 else
  789.                     WriteFormat(file,"Border%ld_bord%ld\n\n",bc,bc);
  790.                 break;
  791.             }
  792.             else
  793.                 WriteFormat(file,"Border%ld_bord%ld\n\n",bc,bc);
  794.         }
  795.         if((g = g->Succ) == (struct MyGadget *)&Borders.Tail)
  796.             break;
  797.     }
  798. }
  799.  
  800. /*
  801.  * write the assembler source code
  802.  */
  803. VOID WriteAsmGadgets()
  804. {
  805.     BPTR                      file;
  806.     register struct MyGadget *gadget;
  807.     struct ColorMap          *cm;
  808.     COUNT                     i,ii;
  809.     USHORT                   *tab,cc;
  810.     ULONG                     rc,hg;
  811.     char                     *str;
  812.  
  813.     GenASM = TRUE;
  814.     HaveGad = is_gadget();
  815.  
  816.     strcpy((char *)IODir->fr_HeadLine,"Save Asm Source");
  817.     IODir->fr_Screen  = MainScreen;
  818.     IODir->fr_Caller  = MainWindow;
  819.     IODir->fr_Flags  |= FR_NoInfo;
  820.     rc = FileRequest(IODir);
  821.     strcpy((char *)&name,(char *)IODir->fr_DirName);
  822.     strcat((char *)&name,(char *)IODir->fr_FileName);
  823.  
  824.     if(rc == FREQ_CANCELED) return;
  825.     else if(rc)
  826.     {   Error("FileRequester won't open !");
  827.         return;
  828.     }
  829.     cm = MainScreen->ViewPort.ColorMap;
  830.     tab = (USHORT *)cm->ColorTable;
  831.     if(!(file = Open((char *)&name,MODE_NEWFILE)))
  832.     {  Error("Can't Open Write File !");
  833.        return;
  834.     }
  835.     SetWindowTitles(MainWindow,(char *)-1L,(char *)"Saving Assembler Source.....");
  836.     buisy();
  837.     disable_window();
  838.     un_gzz();
  839.     cc = (1 << MainScreen->BitMap.Depth);
  840.     WriteFormat(file,"*---------------------------------------------------\n");
  841.     WriteFormat(file,"* Gadgets created with GadgetEd V2.3\n");
  842.     WriteFormat(file,"* which is (c) Copyright 1990-91 by Jaba Development\n");
  843.     WriteFormat(file,"* written by Jan van den Baard\n");
  844.     WriteFormat(file,"*---------------------------------------------------\n\n");
  845.     if(NOT WBSCREEN)
  846.     {   WriteFormat(file,"Colors:\n");
  847.         for(ii=0;ii<cc;ii+=8)
  848.         {   WriteFormat(file,"    DC.W    ");
  849.             for(i=0;i<8;i++)
  850.               if((ii+i) < cc) WriteFormat(file,"$%04lx,",tab[ii+i]);
  851.             Seek(file,-1,OFFSET_CURRENT);
  852.             WriteFormat(file,"\n");
  853.         }
  854.         WriteFormat(file,"\n");
  855.     }
  856.     split();
  857.     WriteAsmB(file);
  858.     WriteAsmWDT(file);
  859.     WriteAsmCRG(file);
  860.     if(HaveGad)
  861.     {   for(gadget = Gadgets.Head;gadget->Succ;gadget = gadget->Succ)
  862.         {   if(TestBits((ULONG)gadget->Gadget.GadgetType,PROPGADGET))
  863.             {   WriteAsmPinfo(file,gadget);
  864.                 if(NOT TestBits((ULONG)gadget->Gadget.Flags,GADGIMAGE))
  865.                     WriteAsmImage(file,gadget,STDPRP);
  866.             }
  867.             if(TestBits((ULONG)gadget->Gadget.GadgetType,STRGADGET))
  868.                 WriteAsmSinfo(file,gadget);
  869.             if((NOT TestBits((ULONG)gadget->Gadget.Flags,GADGIMAGE)) AND
  870.                (NOT TestBits((ULONG)gadget->Gadget.GadgetType,PROPGADGET)) AND
  871.                (NOT TestBits((ULONG)gadget->SpecialFlags,NOBORDER)))
  872.                 WriteAsmBorder(file,gadget);
  873.             if(TestBits((ULONG)gadget->Gadget.Flags,GADGIMAGE))
  874.                 WriteAsmImage(file,gadget,RENDER);
  875.             if((TestBits((ULONG)gadget->Gadget.Flags,GADGHIMAGE)) AND
  876.                (NOT TestBits((ULONG)gadget->Gadget.Flags,GADGHBOX)))
  877.                 WriteAsmImage(file,gadget,SELECT);
  878.             if(gadget->Gadget.GadgetText)
  879.                 WriteAsmTexts(file,gadget);
  880.             WriteAsmGadget(file,gadget);
  881.             if(str = IoErrToStr())
  882.             {   enable_window();
  883.                 Close(file);
  884.                 Error(str);
  885.                 return;
  886.             }
  887.         }
  888.     }
  889.     gadget = Gadgets.TailPred;
  890.     if(NOT WBSCREEN) WriteAsmScreen(file);
  891.     WriteAsmRW(file);
  892.     if(NOT WBSCREEN)  WriteFormat(file,"\nCOLORCOUNT   EQU   %ld",cc);
  893.     if(NOT REQUESTER) { WriteFormat(file,"\nNEWWINDOW:   DC.L   %s",&wlb);
  894.                         WriteFormat(file,"\nWDBACKFILL   EQU    %ld",WDBackFill); }
  895.     else              WriteFormat(file,"\nREQUESTER:   DC.L   requester");
  896.     if(NOT WBSCREEN)  WriteFormat(file,"\nNEWSCREEN:   DC.L   ns");
  897.     if(HaveGad)
  898.         WriteFormat(file,"\nFIRSTGADGET: DC.L   %s",&Gadgets.TailPred->GadgetLabel);
  899.     if(TextGadget.GadgetText)
  900.         WriteFormat(file,"\nFIRSTTEXT:   DC.L   Render_text0");
  901.     if(Borders.TailPred != (struct MyGadget *)&Borders)
  902.         WriteFormat(file,"\nFIRSTBORDER: DC.L   Border0_bord0");
  903.     WriteFormat(file,"\n");
  904.     if(str = IoErrToStr()) Error(str);
  905.     Close(file);
  906.     join();
  907.     do_gzz();
  908.     enable_window();
  909.     ok();
  910.     return;
  911. }
  912.  
  913. #define STAT    prefs.static_structures
  914.  
  915. /*
  916.  * write the C border structure
  917.  */
  918. static VOID WriteCBorder(file,gadget)
  919.     BPTR            file;
  920.     struct MyGadget *gadget;
  921. {
  922.     struct Border *border;
  923.     SHORT         *XY;
  924.     COUNT          i,x=0;
  925.  
  926.     border = (struct Border *)gadget->Gadget.GadgetRender;
  927.     XY     = border->XY;
  928.     while(1)
  929.     {
  930.         if(STAT) WriteFormat(file,"static ");
  931.         WriteFormat(file,"SHORT %s_pairs%ld[] = {\n  ",&gadget->GadgetLabel,x++);
  932.         for(i=0;i<(border->Count << 1);i++) WriteFormat(file,"%ld,",XY[i]);
  933.         Seek(file,-1,OFFSET_CURRENT);
  934.         WriteFormat(file," };\n\n");
  935.         if(NOT(border = border->NextBorder)) break;
  936.         XY = border->XY;
  937.     }
  938.     border = (struct Border *)gadget->Gadget.GadgetRender;
  939.     XY     = border->XY;
  940.     x = 0;
  941.     if(STAT) WriteFormat(file,"static ");
  942.     if(border->NextBorder)
  943.         WriteFormat(file,"struct Border %s_bord[] = {\n",&gadget->GadgetLabel);
  944.     else
  945.         WriteFormat(file,"struct Border %s_bord = {\n",&gadget->GadgetLabel);
  946.     while(1)
  947.     {
  948.         WriteFormat(file,"  %ld,%ld,",border->LeftEdge,border->TopEdge);
  949.         WriteFormat(file,"%ld,%ld,",border->FrontPen,border->BackPen);
  950.         WriteDrMd(file,border->DrawMode,FALSE);
  951.         WriteFormat(file,",%ld,",border->Count);
  952.         WriteFormat(file,"(SHORT *)&%s_pairs%ld,",&gadget->GadgetLabel,x++);
  953.         if(border = border->NextBorder)
  954.             WriteFormat(file,"&%s_bord[%ld],\n",&gadget->GadgetLabel,x);
  955.         else
  956.         {   WriteFormat(file,"NULL };\n\n");
  957.             break;
  958.         }
  959.     }
  960. }
  961.  
  962. /*
  963.  * write the C image structure
  964.  */
  965. static VOID WriteCImage(file,gadget,which)
  966.     BPTR            file;
  967.     struct MyGadget *gadget;
  968.     UBYTE            which;
  969. {
  970.     struct Image *image;
  971.     register USHORT       *data;
  972.     register COUNT        i,ii;
  973.     ULONG        data_size;
  974.  
  975.     if(which == RENDER) image = (struct Image *)gadget->Gadget.GadgetRender;
  976.     else image = (struct Image *)gadget->Gadget.SelectRender;
  977.     data  = image->ImageData;
  978.     if(which != STDPRP)
  979.     {   if(STAT) WriteFormat(file,"static ");
  980.         if(which == SELECT)
  981.           WriteFormat(file,"USHORT %s_hdata[] = {\n",gadget->GadgetLabel);
  982.         else
  983.           WriteFormat(file,"USHORT %s_data[] = {\n",gadget->GadgetLabel);
  984.         data_size = (RASSIZE(image->Width,image->Height) * image->Depth);
  985.         for(i=0;i<(data_size >> 1);i+=8)
  986.         {   for(ii=0;ii<8;ii++)
  987.             {   if(i+ii < (data_size >> 1)) WriteFormat(file,"  0x%04lx,",data[i+ii]);
  988.             }
  989.             WriteFormat(file,"\n");
  990.         }
  991.         Seek(file,-2,OFFSET_CURRENT);
  992.         WriteFormat(file," }; \n\n");
  993.     }
  994.     if(STAT) WriteFormat(file,"static ");
  995.     if(which == SELECT)
  996.       WriteFormat(file,"struct Image %s_himage = {\n",&gadget->GadgetLabel);
  997.     else
  998.       WriteFormat(file,"struct Image %s_image = {\n",&gadget->GadgetLabel);
  999.     WriteFormat(file,"  %ld,%ld,",image->LeftEdge,image->TopEdge);
  1000.     WriteFormat(file,"%ld,%ld,",image->Width,image->Height);
  1001.     WriteFormat(file,"%ld,",image->Depth);
  1002.     if(which != STDPRP)
  1003.     {   if(which == SELECT)
  1004.           WriteFormat(file,"(USHORT *)&%s_hdata,",&gadget->GadgetLabel);
  1005.         else
  1006.           WriteFormat(file,"(USHORT *)&%s_data,",&gadget->GadgetLabel);
  1007.     }
  1008.     else
  1009.        WriteFormat(file,"NULL,");
  1010.     WriteFormat(file,"0x%02lx,",image->PlanePick);
  1011.     WriteFormat(file,"0x%02lx,",image->PlaneOnOff);
  1012.     WriteFormat(file,"NULL };\n\n");
  1013. }
  1014.  
  1015. /*
  1016.  * write the C PropInfo structure
  1017.  */
  1018. static VOID WriteCPinfo(file,gadget)
  1019.     BPTR            file;
  1020.     struct MyGadget *gadget;
  1021. {
  1022.     struct PropInfo *info;
  1023.  
  1024.     info = (struct PropInfo *)gadget->Gadget.SpecialInfo;
  1025.     if(STAT) WriteFormat(file,"static ");
  1026.     WriteFormat(file,"struct PropInfo %s_info = {\n  ",&gadget->GadgetLabel);
  1027.     WritePFlags(file,info);
  1028.     WriteFormat(file,",0x%04lx,",info->HorizPot);
  1029.     WriteFormat(file,"0x%04lx,",info->VertPot);
  1030.     WriteFormat(file,"0x%04lx,",info->HorizBody);
  1031.     WriteFormat(file,"0x%04lx,",info->VertBody);
  1032.     WriteFormat(file,"0,0,0,0,0,0 };\n\n");
  1033. }
  1034.  
  1035. /*
  1036.  * write the C StringInfo structure
  1037.  */
  1038. static VOID WriteCSinfo(file,gadget)
  1039.     BPTR            file;
  1040.     struct MyGadget *gadget;
  1041. {
  1042.     struct StringInfo *info;
  1043.  
  1044.     info = (struct StringInfo *)gadget->Gadget.SpecialInfo;
  1045.     if(STAT) WriteFormat(file,"static ");
  1046.     if(strlen(info->Buffer))
  1047.         WriteFormat(file,"UBYTE %s_buf[%ld] = %lc%s%lc;\n\n",&gadget->GadgetLabel,
  1048.                                                              info->MaxChars,'"',
  1049.                                                              info->Buffer,'"');
  1050.     else
  1051.         WriteFormat(file,"UBYTE %s_buf[%ld];\n\n",&gadget->GadgetLabel,info->MaxChars);
  1052.  
  1053.     if(info->UndoBuffer)
  1054.     {   if(STAT) WriteFormat(file,"static ");
  1055.         WriteFormat(file,"UBYTE %s_ubuf[%ld];\n\n",&gadget->GadgetLabel,info->MaxChars);
  1056.     }
  1057.     if(STAT) WriteFormat(file,"static ");
  1058.     WriteFormat(file,"struct StringInfo %s_info = {\n",&gadget->GadgetLabel);
  1059.     WriteFormat(file,"  (UBYTE *)&%s_buf,",&gadget->GadgetLabel);
  1060.     if(info->UndoBuffer)
  1061.        WriteFormat(file,"(UBYTE *)&%s_ubuf,",&gadget->GadgetLabel);
  1062.     else
  1063.        WriteFormat(file,"NULL,");
  1064.     WriteFormat(file,"0,%ld,",info->MaxChars);
  1065.     WriteFormat(file,"0,0,0,0,0,0,");
  1066.     WriteFormat(file,"NULL,NULL,NULL };\n\n");
  1067. }
  1068.  
  1069. /*
  1070.  * write the C Gadget structure
  1071.  */
  1072. static VOID WriteCGadget(file,gadget)
  1073.     BPTR            file;
  1074.     struct MyGadget *gadget;
  1075. {
  1076.     struct Gadget    *gad;
  1077.     struct MyGadget  *next;
  1078.     struct IntuiText *itext;
  1079.  
  1080.     gad = &gadget->Gadget;
  1081.  
  1082.     WriteFormat(file,"#define %s_ID    %ld\n\n",&gadget->GadgetLabel,gad->GadgetID);
  1083.     if(STAT) WriteFormat(file,"static ");
  1084.     WriteFormat(file,"struct Gadget %s = {\n  ",&gadget->GadgetLabel);
  1085.     if(gadget == Gadgets.Head)
  1086.     {   if(NOT REQUESTER)
  1087.         {   if((TextGadget.GadgetText) OR
  1088.                (Borders.TailPred != (struct MyGadget *)&Borders)) WriteFormat(file,"&Render,");
  1089.             else WriteFormat(file,"NULL,");
  1090.         }
  1091.         else WriteFormat(file,"NULL,");
  1092.     }
  1093.     else
  1094.        WriteFormat(file,"&%s,",&(gadget->Pred->GadgetLabel));
  1095.     WriteFormat(file,"%ld,%ld,",gad->LeftEdge,gad->TopEdge);
  1096.     WriteFormat(file,"%ld,%ld,\n  ",gad->Width,gad->Height);
  1097.     WriteFlags(file,gadget);
  1098.     WriteFormat(file,",\n  ");
  1099.     WriteActivation(file,gadget);
  1100.     WriteFormat(file,",\n  ");
  1101.     WriteType(file,gadget);
  1102.     if((TestBits((ULONG)gad->Flags,GADGIMAGE)) ||
  1103.        (TestBits((ULONG)gad->GadgetType,PROPGADGET)))
  1104.       WriteFormat(file,",\n  (APTR)&%s_image,",&gadget->GadgetLabel);
  1105.     else if(NOT TestBits((ULONG)gadget->SpecialFlags,NOBORDER))
  1106.     {   if(((struct Border *)gadget->Gadget.GadgetRender)->NextBorder)
  1107.             WriteFormat(file,",\n  (APTR)&%s_bord[0],",&gadget->GadgetLabel);
  1108.         else
  1109.             WriteFormat(file,",\n  (APTR)&%s_bord,",&gadget->GadgetLabel);
  1110.     }
  1111.     else
  1112.       WriteFormat(file,",\n  NULL,");
  1113.     if((TestBits((ULONG)gad->Flags,GADGHIMAGE)) AND
  1114.        (NOT TestBits((ULONG)gad->Flags,GADGHBOX)))
  1115.       WriteFormat(file,"(APTR)&%s_himage,\n  ",&gadget->GadgetLabel);
  1116.     else
  1117.       WriteFormat(file,"NULL,\n  ");
  1118.     if((itext = gad->GadgetText))
  1119.     {   if(itext->NextText)
  1120.           WriteFormat(file,"&%s_text[0],NULL,",&gadget->GadgetLabel);
  1121.         else
  1122.           WriteFormat(file,"&%s_text,NULL,",&gadget->GadgetLabel);
  1123.     }
  1124.     else WriteFormat(file,"NULL,NULL,");
  1125.     if(gad->SpecialInfo)
  1126.       WriteFormat(file,"(APTR)&%s_info,",&gadget->GadgetLabel);
  1127.     else
  1128.       WriteFormat(file,"NULL,");
  1129.     WriteFormat(file,"%s_ID,NULL };\n\n",&gadget->GadgetLabel);
  1130. }
  1131.  
  1132. /*
  1133.  * write the C IntuiText structures
  1134.  */
  1135. static VOID WriteCTexts(file,gadget)
  1136.     BPTR            file;
  1137.     struct MyGadget *gadget;
  1138. {
  1139.     register struct IntuiText *itext;
  1140.     COUNT    i=1;
  1141.  
  1142.     if((itext = gadget->Gadget.GadgetText))
  1143.     {   if(STAT) WriteFormat(file,"static ");
  1144.         if(itext->NextText)
  1145.           WriteFormat(file,"struct IntuiText %s_text[] = {\n",&gadget->GadgetLabel);
  1146.         else
  1147.           WriteFormat(file,"struct IntuiText %s_text = {\n",&gadget->GadgetLabel);
  1148.         while(1)
  1149.         {   WriteFormat(file,"  %ld,%ld,",itext->FrontPen,itext->BackPen);
  1150.             WriteDrMd(file,itext->DrawMode,FALSE);
  1151.             WriteFormat(file,",%ld,%ld,NULL,",itext->LeftEdge,itext->TopEdge);
  1152.             WriteFormat(file,"(UBYTE *)%lc%s%lc,",'"',itext->IText,'"');
  1153.             if(itext->NextText)
  1154.               WriteFormat(file,"&%s_text[%ld],\n  ",&gadget->GadgetLabel,i++);
  1155.             else
  1156.               WriteFormat(file,"NULL");
  1157.             if(!(itext = itext->NextText)) break;
  1158.        }
  1159.        WriteFormat(file," };\n\n");
  1160.     }
  1161. }
  1162.  
  1163. /*
  1164.  * write the C NewScreen structure
  1165.  */
  1166. static VOID WriteCScreen(file)
  1167.     BPTR file;
  1168. {
  1169.     if(STAT) WriteFormat(file,"static ");
  1170.     WriteFormat(file,"struct NewScreen ns = {\n");
  1171.     WriteFormat(file,"  0,0,%ld,%ld,",MainScreen->Width,MainScreen->Height);
  1172.     WriteFormat(file,"%ld,",MainScreen->BitMap.Depth);
  1173.     WriteFormat(file,"-1,-1,");
  1174.     if(MainScreen->BitMap.Depth == 5) WriteFormat(file,"NULL,");
  1175.     else WriteFormat(file,"HIRES,");
  1176.     WriteFormat(file,"CUSTOMSCREEN,NULL,NULL,NULL,NULL };\n\n");
  1177. }
  1178.  
  1179. /*
  1180.  * write the C window/requester structure
  1181.  */
  1182. static VOID WriteCRW(file)
  1183.     BPTR file;
  1184. {
  1185.     struct IntuiText *t;
  1186.     if(REQUESTER)
  1187.     {   if(STAT) WriteFormat(file,"static ");
  1188.         WriteFormat(file,"struct Requester requester = {\n  NULL,");
  1189.         WriteFormat(file,"%ld,%ld,",(MainWindow->LeftEdge + MainWindow->BorderLeft),
  1190.                                     (MainWindow->TopEdge + MainWindow->BorderTop));
  1191.         WriteFormat(file,"%ld,%ld,",MainWindow->GZZWidth,MainWindow->GZZHeight);
  1192.         if(HaveGad)
  1193.             WriteFormat(file,"0,0,&%s,",&Gadgets.TailPred->GadgetLabel);
  1194.         else
  1195.             WriteFormat(file,"0,0,NULL,");
  1196.         if(Borders.TailPred != (struct MyGadget *)&Borders)
  1197.         {   if(MultyB)
  1198.               WriteFormat(file,"&Border_bord[0],");
  1199.             else
  1200.               WriteFormat(file,"&Border_bord,");
  1201.         }
  1202.         else WriteFormat(file,"NULL,");
  1203.         if((t = TextGadget.GadgetText))
  1204.         {   if(t->NextText) WriteFormat(file,"&Render_text[0],");
  1205.             else WriteFormat(file,"&Render_text,");
  1206.         }
  1207.         else WriteFormat(file,"NULL,");
  1208.         WriteFormat(file,"NULL,%ld,",BackFill);
  1209.         WriteFormat(file,"NULL,NULL,NULL,NULL,NULL };\n\n");
  1210.     }
  1211.     else
  1212.     {   if(STAT) WriteFormat(file,"static ");
  1213.         WriteFormat(file,"struct NewWindow %s = {\n  ",&wlb);
  1214.         WriteFormat(file,"%ld,%ld,%ld,%ld,",MainWindow->LeftEdge,MainWindow->TopEdge,
  1215.                                             MainWindow->Width,MainWindow->Height);
  1216.         WriteFormat(file,"%ld,%ld,\n  ",MainWindow->DetailPen,MainWindow->BlockPen);
  1217.         WriteIFlags(file);
  1218.         WriteFormat(file,",\n  ");
  1219.         WriteWFlags(file);
  1220.         WriteFormat(file,",\n");
  1221.         if(HaveGad)
  1222.             WriteFormat(file,"  &%s,NULL,\n",Gadgets.TailPred->GadgetLabel);
  1223.         else if(Borders.TailPred != (struct MyGadget *)&Borders)
  1224.             WriteFormat(file,"  &Render,NULL,\n");
  1225.         else
  1226.             WriteFormat(file,"  NULL,NULL,\n");
  1227.         if(strlen((char *)&wdt))
  1228.             WriteFormat(file,"  (UBYTE *)%lc%s%lc,NULL,NULL,\n",'"',&wdt,'"');
  1229.         else
  1230.             WriteFormat(file,"  NULL,NULL,NULL,\n");
  1231.         WriteFormat(file,"  %ld,%ld,%ld,%ld,",MainWindow->MinWidth,
  1232.                                               MainWindow->MinHeight,
  1233.                                               MainWindow->MaxWidth,
  1234.                                               MainWindow->MaxHeight);
  1235.         if(WBSCREEN) WriteFormat(file,"WBENCHSCREEN };\n\n");
  1236.         else         WriteFormat(file,"CUSTOMSCREEN };\n\n");
  1237.     }
  1238. }
  1239.  
  1240. /*
  1241.  * write the C window/requester texts structures
  1242.  */
  1243. static VOID WriteCWDT(file)
  1244.     BPTR file;
  1245. {
  1246.     register struct IntuiText *t, *t1;
  1247.     register UCOUNT i = 1;
  1248.  
  1249.     if(NOT TextGadget.GadgetText) return;
  1250.  
  1251.     t = TextGadget.GadgetText;
  1252.     if(STAT) WriteFormat(file,"static ");
  1253.     if(t->NextText)
  1254.       WriteFormat(file,"struct IntuiText Render_text[] = {\n  ");
  1255.     else
  1256.       WriteFormat(file,"struct IntuiText Render_text = {\n  ");
  1257.     while(1)
  1258.     {   WriteFormat(file,"%ld,%ld,",t->FrontPen,t->BackPen);
  1259.         WriteDrMd(file,t->DrawMode,FALSE);
  1260.         WriteFormat(file,",%ld,%ld,NULL,",t->LeftEdge,t->TopEdge);
  1261.         WriteFormat(file,"(UBYTE *)%lc%s%lc,",'"',t->IText,'"');
  1262.         if(t->NextText)
  1263.           WriteFormat(file,"&Render_text[%ld],\n  ",i++);
  1264.         else
  1265.           WriteFormat(file,"NULL");
  1266.         if(!(t = t->NextText)) break;
  1267.     }
  1268.     WriteFormat(file," };\n\n");
  1269. }
  1270.  
  1271. /*
  1272.  * write the C special render gadget
  1273.  */
  1274. static VOID WriteCRG(file)
  1275.     BPTR file;
  1276. {
  1277.     struct IntuiText *t;
  1278.  
  1279.     if((TextGadget.GadgetText) OR
  1280.        (Borders.TailPred != (struct MyGadget *)&Borders))
  1281.     {   if(NOT REQUESTER)
  1282.         {   if(STAT) WriteFormat(file,"static ");
  1283.             WriteFormat(file,"struct Gadget Render = {\n  ");
  1284.             WriteFormat(file,"NULL,0,0,1,1,GADGHNONE,NULL,BOOLGADGET,\n");
  1285.  
  1286.             if(Borders.TailPred != (struct MyGadget *)&Borders)
  1287.             {   if(MultyB)
  1288.                   WriteFormat(file,"  (APTR)&Border_bord[0],NULL,");
  1289.                 else
  1290.                   WriteFormat(file,"  (APTR)&Border_bord,NULL,");
  1291.             }
  1292.             else WriteFormat(file,"  NULL,NULL,");
  1293.             if((t = TextGadget.GadgetText))
  1294.             {   if(t->NextText) WriteFormat(file,"&Render_text[0],");
  1295.                 else WriteFormat(file,"&Render_text,");
  1296.             }
  1297.             else WriteFormat(file,"NULL,");
  1298.             WriteFormat(file,"NULL,NULL,NULL,NULL };\n\n");
  1299.         }
  1300.     }
  1301. }
  1302.  
  1303. /*
  1304.  * write the C border structures
  1305.  */
  1306. static VOID WriteCB(file)
  1307.     BPTR file;
  1308. {
  1309.     register struct MyGadget *g;
  1310.     register struct Border   *b;
  1311.     register SHORT           *xy;
  1312.     register UCOUNT           bc = 0,xyc;
  1313.  
  1314.     if(Borders.TailPred == (struct MyGadget *)&Borders) return;
  1315.  
  1316.     g = Borders.Head;
  1317.  
  1318.     while(1)
  1319.     {
  1320.         b = (struct Border *)g->Gadget.GadgetRender;
  1321.         while(1)
  1322.         {   if(STAT) WriteFormat(file,"static ");
  1323.             xy = b->XY;
  1324.             WriteFormat(file,"SHORT Border%ld_pairs[] = {\n  ",bc);
  1325.             for(xyc = 0;xyc < (b->Count << 1);xyc++) WriteFormat(file,"%ld,",xy[xyc]);
  1326.             Seek(file,-1,OFFSET_CURRENT);
  1327.             WriteFormat(file," };\n");
  1328.             bc++;
  1329.             if(!(b = b->NextBorder)) break;
  1330.         }
  1331.         if((g = g->Succ) == (struct MyGadget *)&Borders.Tail) break;
  1332.     }
  1333.     WriteFormat(file,"\n");
  1334.  
  1335.     bc = 0;
  1336.     g = Borders.Head;
  1337.     b = (struct Border *)g->Gadget.GadgetRender;
  1338.     if(STAT) WriteFormat(file,"static ");
  1339.     if((b->NextBorder) OR (g->Succ != (struct MyGadget *)&Borders.Tail))
  1340.     {   WriteFormat(file,"struct Border Border_bord[] = {\n");
  1341.         MultyB = TRUE;
  1342.     }
  1343.     else
  1344.     {   WriteFormat(file,"struct Border Border_bord = {\n");
  1345.         MultyB = FALSE;
  1346.     }
  1347.     while(1)
  1348.     {
  1349.         while(1)
  1350.         {
  1351.             WriteFormat(file,"  %ld,%ld,",g->Gadget.LeftEdge,g->Gadget.TopEdge);
  1352.             WriteFormat(file,"%ld,0,JAM1,%ld,",b->FrontPen,b->Count);
  1353.             WriteFormat(file,"(SHORT *)&Border%ld_pairs,",bc);
  1354.             bc++;
  1355.             if(!(b = b->NextBorder))
  1356.             {   if(g->Succ == (struct MyGadget *)&Borders.Tail)
  1357.                     WriteFormat(file,"NULL };\n\n");
  1358.                 else
  1359.                     WriteFormat(file,"&Border_bord[%ld],\n",bc);
  1360.                 break;
  1361.             }
  1362.             else
  1363.                 WriteFormat(file,"&Border_bord[%ld],\n",bc);
  1364.         }
  1365.         if((g = g->Succ) == (struct MyGadget *)&Borders.Tail)
  1366.             break;
  1367.         b = (struct Border *)g->Gadget.GadgetRender;
  1368.     }
  1369. }
  1370.  
  1371. /*
  1372.  * write the C source code
  1373.  */
  1374. VOID WriteCGadgets()
  1375. {
  1376.     BPTR                      file;
  1377.     register struct MyGadget *gadget;
  1378.     struct ColorMap          *cm;
  1379.     COUNT                     i,ii;
  1380.     USHORT                   *tab,cc;
  1381.     ULONG                     rc;
  1382.     char                     *str;
  1383.  
  1384.     GenASM = FALSE;
  1385.     HaveGad = is_gadget();
  1386.  
  1387.     strcpy((char *)IODir->fr_HeadLine,"Save C Source");
  1388.     IODir->fr_Screen  = MainScreen;
  1389.     IODir->fr_Caller  = MainWindow;
  1390.     IODir->fr_Flags  |= FR_NoInfo;
  1391.     rc = FileRequest(IODir);
  1392.     strcpy((char *)&name,(char *)IODir->fr_DirName);
  1393.     strcat((char *)&name,(char *)IODir->fr_FileName);
  1394.  
  1395.     if(rc == FREQ_CANCELED) return;
  1396.     else if(rc)
  1397.     {   Error("FileRequester won't open !");
  1398.         return;
  1399.     }
  1400.     cm = MainScreen->ViewPort.ColorMap;
  1401.     tab = (USHORT *)cm->ColorTable;
  1402.     if(NOT(file = Open((char *)&name,MODE_NEWFILE)))
  1403.     {   Error("Can't open write file !");
  1404.         return;
  1405.     }
  1406.     SetWindowTitles(MainWindow,(char *)-1L,(char *)"Saving C Source.....");
  1407.     buisy();
  1408.     disable_window();
  1409.     un_gzz();
  1410.     cc = (1 << MainScreen->BitMap.Depth);
  1411.     WriteFormat(file,"/*---------------------------------------------------*\n");
  1412.     WriteFormat(file,"  Gadgets created with GadgetEd V2.3\n");
  1413.     WriteFormat(file,"  which is (c) Copyright 1990-91 by Jaba Development\n");
  1414.     WriteFormat(file,"  written by Jan van den Baard\n");
  1415.     WriteFormat(file," *---------------------------------------------------*/\n\n");
  1416.     if(NOT WBSCREEN)
  1417.     {   if(STAT) WriteFormat(file,"static ");
  1418.         WriteFormat(file,"USHORT Colors[] = {\n");
  1419.         for(ii=0;ii<cc;ii+=8)
  1420.         {   for(i=0;i<8;i++)
  1421.               if((ii+i) < cc) WriteFormat(file,"  0x%04lx,",tab[ii+i]);
  1422.             WriteFormat(file,"\n");
  1423.         }
  1424.         Seek(file,-2,OFFSET_CURRENT);
  1425.         WriteFormat(file," };\n\n");
  1426.     }
  1427.     split();
  1428.     WriteCB(file);
  1429.     WriteCWDT(file);
  1430.     WriteCRG(file);
  1431.     if(HaveGad)
  1432.     {   for(gadget = Gadgets.Head;gadget->Succ;gadget = gadget->Succ)
  1433.         {   if(TestBits((ULONG)gadget->Gadget.GadgetType,PROPGADGET))
  1434.             {   WriteCPinfo(file,gadget);
  1435.                 if(NOT TestBits((ULONG)gadget->Gadget.Flags,GADGIMAGE))
  1436.                     WriteCImage(file,gadget,STDPRP);
  1437.             }
  1438.             if(TestBits((ULONG)gadget->Gadget.GadgetType,STRGADGET))
  1439.                 WriteCSinfo(file,gadget);
  1440.             if((NOT TestBits((ULONG)gadget->Gadget.Flags,GADGIMAGE)) AND
  1441.                (NOT TestBits((ULONG)gadget->Gadget.GadgetType,PROPGADGET)) AND
  1442.                (NOT TestBits((ULONG)gadget->SpecialFlags,NOBORDER)))
  1443.                 WriteCBorder(file,gadget);
  1444.             if(TestBits((ULONG)gadget->Gadget.Flags,GADGIMAGE))
  1445.                 WriteCImage(file,gadget,RENDER);
  1446.             if((TestBits((ULONG)gadget->Gadget.Flags,GADGHIMAGE)) AND
  1447.                (NOT TestBits((ULONG)gadget->Gadget.Flags,GADGHBOX)))
  1448.                 WriteCImage(file,gadget,SELECT);
  1449.             if(gadget->Gadget.GadgetText)
  1450.                 WriteCTexts(file,gadget);
  1451.             WriteCGadget(file,gadget);
  1452.             if(str = IoErrToStr())
  1453.             {   Close(file);
  1454.                 enable_window();
  1455.                 Error(str);
  1456.                 return;
  1457.             }
  1458.         }
  1459.     }
  1460.     gadget = Gadgets.TailPred;
  1461.     if(NOT WBSCREEN) WriteCScreen(file);
  1462.     WriteCRW(file);
  1463.     if(NOT WBSCREEN)  WriteFormat(file,"\n#define COLORCOUNT  %ld",cc);
  1464.     if(NOT REQUESTER) { WriteFormat(file,"\n#define NEWWINDOW   &%s",&wlb);
  1465.                         WriteFormat(file,"\n#define WDBACKFILL   %ld",WDBackFill); }
  1466.     else              WriteFormat(file,"\n#define REQUESTER   &requester");
  1467.     if(NOT WBSCREEN)  WriteFormat(file,"\n#define NEWSCREEN   &ns");
  1468.     if(HaveGad)
  1469.         WriteFormat(file,"\n#define FIRSTGADGET &%s",&Gadgets.TailPred->GadgetLabel);
  1470.     if(TextGadget.GadgetText)
  1471.     {   WriteFormat(file,"\n#define FIRSTTEXT   &");
  1472.         if(TextGadget.GadgetText->NextText)
  1473.           WriteFormat(file,"Render_text[0]");
  1474.         else
  1475.           WriteFormat(file,"Render_text");
  1476.     }
  1477.     if(Borders.TailPred != (struct MyGadget *)&Borders)
  1478.     {   WriteFormat(file,"\n#define FIRSTBORDER &");
  1479.         if(MultyB)
  1480.           WriteFormat(file,"Border_bord[0]");
  1481.         else
  1482.         WriteFormat(file,"Border_bord");
  1483.     }
  1484.     WriteFormat(file,"\n");
  1485.     if(str = IoErrToStr()) Error(str);
  1486.     Close(file);
  1487.     join();
  1488.     do_gzz();
  1489.     enable_window();
  1490.     ok();
  1491.     return;
  1492. }
  1493.