#define FASTBUS
#include <rol.h>
VOIDFUNCPTR (null)__init__ = __init__;
#define SLOT 18
#define MODULES 4
#define ZERO 0
/* inline c-code */
 
void junk_start (int safdas)
{
	printf ("hahahaahah\n");
}
 
 /*end inline c-code */
static void __download()
{
    eprintf(0,"INFO: list compiled %s\n", DAYTIME);
    {
       static int ourTaskId=0;  
       if (taskIdSelf() != ourTaskId)
         {
           ourTaskId = taskIdSelf();
           fb_task_init_1();
         }
    }
    eprintf(0,"ALRM: ""nothing to download");

        hello ;
} /*end download */     

static void __prestart()
{
CTRIGINIT;
    fb_init_1 ();
    fb_frd_1(0,0,0,0,0,1,1,1,1,1); /* arb */
    IFERROR("hidden arbitrate");
    evnb = 0;
unsigned long index, temp, catid;
    eprintf(0,"INFO:""prestart data source type buffer");

    fb_init_1();
    index = 0 ;
{/* inline c-code */
     
	int x, y;
        for(x =0; x< 100; x++){
	   y = x;
        }
        /* doinn something dumb */
       x = y*y;
   
 }/*end inline c-code */
while( ( index <  MODULES) ){ 
    eprintf(0,"INFO:"attaching 10c6 in slot I4,"SLOT-index");

    padr   = SLOT-index ;
    sadr = 0 ;
    fb_fwd_1(padr,sadr,0xc000000,0,1,0,0,0,1,1);
      if (fb_errno != 0x800BC119){ 
          fb_rtn = "write 0xc000000" ;
          goto fooy;
      }
    }
    fb_frd_1(0,0,&temp,0,1,1,1,0,1,1);
    if (fb_errno != 0x800BC119){ 
        fb_rtn = "read into temp" ;
        goto fooy;
    }
   temp = *rol->dabufpi++;
    fb_frd_1(0,0,&catid,0,1,1,1,0,1,1);
    if (fb_errno != 0x800BC119){ 
        fb_rtn = "read into catid" ;
        goto fooy;
    }
   catid = *rol->dabufpi++;
    eprintf(0,"WARN: "after clear CSR = H8,"temp");

if(( index <  0) ) {
    fb_fwd_1(0,0,0x0814,0,1,1,1,0,1,1);
      if (fb_errno != 0x800BC119){ 
          fb_rtn = "write 0x0814" ;
          goto fooy;
      }
    }
}
else{
    fb_fwd_1(0,0,0x1013,0,1,1,1,0,1,1);
      if (fb_errno != 0x800BC119){ 
          fb_rtn = "write 0x1013" ;
          goto fooy;
      }
    }

}/*endif whole if block*/

if(( index == ZERO) ) {
    fb_fwd_1(0,0,0x0814,0,1,1,1,0,1,1);
      if (fb_errno != 0x800BC119){ 
          fb_rtn = "write 0x0814" ;
          goto fooy;
      }
    }
}
else if(( index == MODULES-1) ){
    fb_fwd_1(0,0,0x1014,0,1,1,1,0,1,1);
      if (fb_errno != 0x800BC119){ 
          fb_rtn = "write 0x1014" ;
          goto fooy;
      }
    }
}
else{
    fb_fwd_1(0,0,0x1814,0,1,1,1,0,1,1);
      if (fb_errno != 0x800BC119){ 
          fb_rtn = "write 0x1814" ;
          goto fooy;
      }
    }

}/*endif whole if block*/

    fb_frd_1(0,0,&temp,0,1,1,1,0,1,1);
    if (fb_errno != 0x800BC119){ 
        fb_rtn = "read into temp" ;
        goto fooy;
    }
   temp = *rol->dabufpi++;
    eprintf(0,"INFO:"after intialization CSR = H8,"temp");

    padr   = SLOT-index; 
    sadr = 1 ;
    fb_fwc_1(padr,sadr,0xce,0,1,0,0,0,1,1);
      if (fb_errno != 0x800BC119){ 
          fb_rtn = "write 0xce" ;
          goto fooy;
      }
    }
    sadr = 5 ;
    fb_frc_1(0,sadr,&temp,0,1,1,0,0,1,1);
    if (fb_errno != 0x800BC119){ 
        fb_rtn = "read into temp" ;
        goto fooy;
    }
   temp = *rol->dabufpi++;
    eprintf(0,"INFO:"super header H8,"temp");

    index++ ;
}/* end while loop */

    eprintf(0,"INFO:""FB hardware initialized -ready to go");

    if (__the_event__) WRITE_EVENT_;
    evnb = 0;
    rol->recNb = 0;
    return;
   fooy: 
    FB_REPORT_ERROR;
    RECOVER;
} /*end prestart */     

static void __end()
{
    eprintf(0,"INFO:""end list executing -- trigger disabled");

    if (__the_event__) WRITE_EVENT_;
    return;
   fooy: 
    FB_REPORT_ERROR;
    RECOVER;
} /* end end block */

static void __pause()
{
    eprintf(0,"INFO:""pause list executing -- trigger disabled");

    if (__the_event__) WRITE_EVENT_;
    return;
   fooy: 
    FB_REPORT_ERROR;
    RECOVER;
} /*end pause */
static void __go()
{

    eprintf(0,"INFO:""Go list executing");

    if (__the_event__) WRITE_EVENT_;
    return;
   fooy: 
    FB_REPORT_ERROR;
    RECOVER;
}

void timer0(int EVTYPE,int EVSOURCE)
{
    long EVENT_LENGTH;
    fptdisable ();
    intLevelSet (1);
    padr   = SLOT ;
    sadr = 2 ;
    fpbr(0); 
  *rol->dabufp = 0xFB000BAD;
  *rol->dabufp++;
    return;
  fooy: 
    FB_REPORT_ERROR;
} /*end trigger */

void timer0()
{
} /*end done */

static void status()
{
} /* end status */

