Exemplo n.º 1
0
static void
update(
        float (* state)[NHOR][NVER],
        float (* state_next)[NHOR][NVER],
        float (* dstate)[NHOR][NVER],
        float (* dstate_next)[NHOR][NVER]
        ) {
    float dt = 0.01;
    float v, u, d2vdx2, d2vdy2, dvdt, dudt ,I;
    for (int idy = 0; idy < NVER; idy++) {
        for (int idx = 0; idx < NVER; idx++) {
            v = GET(0, 0);
            u = DGET(0, 0);
            d2vdx2 = (GET(0, 1) - 2*v + GET(0, -1));
            d2vdy2 = (GET(1, 0) - 2*v + GET(-1, 0));
            I = 2*(d2vdx2 + d2vdy2);
            if (I < 0) {
                I = 0;
            }
            dvdt = 0.04 * v*v + 5*v + 140 - u + I;
            dudt = 0.02 * (0.2*v - u);
            v = v + dvdt * dt;
            u = u + dudt * dt;
            if (v >= 30) {
                v = -65;
                if (u < 10) {
                    u = u + 8;
                }
            }
            NEXT(0, 0) = v;
            DNEXT(0, 0) = u;
        }
    }
}
Exemplo n.º 2
0
/* device_offset_adjust()
 *==========================================================================
 * Assign the linked list to the slits. Used in conjuction with Assign_Slit.
 * IN: FNODE *ptr:	The Head Pointer Node
 *     int   value:	The Index (base 0 ) into the linked list
 *     FNODE *array[]:	Text for the slider.
 */
void
device_offset_adjust( DEV_PTR ptr, int value, DEV_PTR array[] )
{
    DEV_PTR curptr;
    int   i;
    
    curptr = ptr;
    
     
    for( i = 0; i < value; i++ )
       curptr = DNEXT( curptr );
    Device_Assign_Slit( curptr, array );
}
Exemplo n.º 3
0
/* Get_Device_Index()
 *==========================================================================
 * Given the Parent FNODE pointer AND the FNODE pointer in question,
 * find its index into the linked list ( zero based ).
 * IN: FNODE *tptr:	The Parent FNODE pointer
 *     FNODE *ptr:	The FNODE pointer we want the index for.
 *
 * OUT: int:	The index into the linked list ( 0 based ) to the FNODE *ptr
 */
int
Get_Device_Index( DEV_PTR tptr, DEV_PTR ptr )
{
    DEV_PTR curptr;
    int   count = 0;
    
    curptr = tptr;
    while( curptr )
    {
         if( curptr == ptr )
         	 break;
         count++;
         curptr = DNEXT( curptr );
    }
    return( count );
}
Exemplo n.º 4
0
/* Undo_Fnodes()
 *==========================================================================
 * Deselects any Slits visible. Also, it goes down the slit ptr passed in,
 * and undo's any changes made to the filename.
 *
 * IN: 	FNODE *ptr:	Head Node pointer to the linked list.
 * 	BOOLEAN flag:	Defines which linked list to clear out.
 */
void
Undo_Dnodes( DEV_PTR ptr, int flag )
{
    DEV_PTR curptr;
    int     i;
    	
    curptr = ptr;
    while( curptr )
    {
        DFLAG( curptr ) = FALSE;   
        curptr = DNEXT( curptr );
    }
    
    for( i = 0; i < MAX_SLITS; i++ )
    {
        if( IsSelected( DCOVER0 + ( i * 6 ) ))
        {
            Deselect( DCOVER0 + ( i * 6 ) );
            Objc_draw( tree, DCOVER0 + ( i * 6 ) - 5, MAX_DEPTH, NULL );
        }    
    }    

    if( flag )
    {
      if( !IsDisabled( DMODIFY ) )
      {
        NoExit( DMODIFY );
        Disable( DMODIFY );

        RedrawObject( tree, DMODIFY );
      }

      if( !IsDisabled( DDELETE ) )
      {
         NoExit( DDELETE );
         Disable( DDELETE );

         RedrawObject( tree, DDELETE );
      }    
   }   
}
Exemplo n.º 5
0
/* Device_Assign_Slit()
 *==========================================================================
 *  Assigns the 6 slits visible an FNODE, where possible.
 * IN: FNODE *ptr:	Start assigning with this node
 *     FNODE *array[]:	A 5 slit pointer array.
 */
void
Device_Assign_Slit( DEV_PTR ptr, DEV_PTR array[] )
{
    int i;
    DEV_PTR curptr;
    
    curptr = ptr;
    for( i = 0; i < MAX_SLITS; i++ )
    {
        array[ i ] = NULL;

	Deselect( First_Obj + ( i * 6 ) + 5 );
	
	strcpy( Device_Array[i], fblank4 );
	TedText( First_Obj + ( i * 6 ) + 1 ) = Device_Array[i];
        TedText( First_Obj + ( i * 6 ) + 2 ) = fblank3;
        HideObj( First_Obj + ( i * 6 ) + 3 );	
        HideObj( First_Obj + ( i * 6 ) + 4 );	

        if( curptr )
        {
              array[i] = curptr;
              sprintf( Device_Array[i], "%d", DDEV( curptr ) );
	      TedText( First_Obj + ( i * 6 ) + 1 ) = Device_Array[i];
	      TedText( First_Obj + ( i * 6 ) + 2 ) = drivers[ DNAME( curptr )];


	      if( ( DTYPE( curptr ) == 'p' ) || ( DTYPE( curptr ) == 'P' ))
                 ShowObj( First_Obj + ( i * 6 ) + 3 );	

	      if( ( DTYPE( curptr ) == 'r' ) || ( DTYPE( curptr ) == 'R' ))
                 ShowObj( First_Obj + ( i * 6 ) + 4 );	
              curptr = DNEXT( curptr );	
        }  
    }
}
Exemplo n.º 6
0
/* DeleteDevice()
 * =======================================================================
 * Delete the Active Device in the Edit Device tree.
 */
void
DeleteDevice( void )
{
    GRECT   rect;
    DEV_PTR temp_device;
    
    wait_up();
    
    if( form_alert( 1, alert1 ) == 2 )
    {
       deselect( tree, EDELETE );
       return;
    }       
    if( device_count == 0 ) return;

    SetChangeFlag();
     
    temp_device = xdevice;
    if( DNEXT( xdevice ) )
        DPREV( DNEXT( xdevice ) ) = DPREV( xdevice );
        
    if( DPREV( xdevice ) )    
        DNEXT( DPREV( xdevice ) ) = DNEXT( xdevice );
    ClearDeviceFont( xdevice );
    
    
    /* Fix up device count */
    device_count--;
    
    /* Change display since we're looking at deleted a device 
     * We shall use xdevice - 1 if there is no device.
     */
     if( DNEXT( xdevice ) )
     	 xdevice = DNEXT( xdevice );
     else
         xdevice = DPREV( xdevice );
         
     DNEXT( temp_device ) = DPREV( temp_device ) = ( DEV_PTR )NULL;
     DDEV( temp_device ) = 0;    
         
     CurHotDriver = DNAME( xdevice );   
     NoExit( EDELETE );
     Disable( EDELETE );

     /* Display the device number in text form. */              
     sprintf( DeviceText, "%d", DDEV( xdevice ) );
     TedText( CURNUM ) = &DeviceText[0];

     /* Display the driver name in text form ( includes the .SYS ) */
     strcpy( DriverText, drivers[ DNAME( xdevice )] );
     TedText( CURNAME ) = &DriverText[0];

     /* Set the ROM/RES flags */
     Deselect( CURROM );
     Deselect( CURRES );
   
     if( DTYPE( xdevice ) == 'P' )	/* ROM driver - SCREEN.SYS */
        Select( CURROM );

     if( DTYPE( xdevice ) == 'R' )    /* Resident Driver */
   	Select( CURRES );

     Objc_draw( tree, CURNUM, MAX_DEPTH, NULL );
     Objc_draw( tree, CURNAME, MAX_DEPTH, NULL );
     Objc_draw( tree, CURROM, MAX_DEPTH, NULL );
     Objc_draw( tree, CURRES, MAX_DEPTH, NULL );

     /* turn on/off the EDELETE button here too */
     rect = ObRect( EDELETE  );
     objc_offset( tree, EDELETE, &rect.g_x, &rect.g_y );

     rect.g_x -= 3;
     rect.g_y -= 3;
     rect.g_w += 6;
     rect.g_h += 6;
        
     if( DDEV( xdevice ) > 9 )
     {
       MakeExit( EDELETE );
       Enable( EDELETE );
     }
     else
     {
       NoExit( EDELETE );
       Disable( EDELETE );           
     }
     Deselect( EDELETE );
     Objc_draw( tree, ROOT, MAX_DEPTH, &rect );
     
     /* Check if the device deleted is the current_device.
      * if so, we have to update the current_device to a new device.
      */
     if( temp_device == current_device )
     	 current_device = xdevice;
     	 
     if( temp_device == device_head )
         device_head = xdevice;	 
}
Exemplo n.º 7
0
/* CurDeviceUpDown()
 * =======================================================================
 * Handles the up/down buttons on displaying an active driver and device.
 * so that we can decide which driver to transfer fonts to.
 */
void
CurDeviceUpDown( int button )
{
   MRETS mk;
   DEV_PTR  olddev;
   GRECT rect;
      
   select( tree, button );
   do
   {
      olddev = xdevice;
      
      if( button == CURUP )
      {
         if( DNEXT( xdevice ) )
             xdevice = DNEXT( xdevice );
      }
      else
      {
         if( DPREV( xdevice ) )
             xdevice = DPREV( xdevice );
      }

      if( olddev != xdevice )
      {
        sprintf( DeviceText, "%d", DDEV( xdevice ) );
        TedText( CURNUM ) = &DeviceText[0];
        
        CurHotDriver = DNAME( xdevice );
        strcpy( DriverText, drivers[ DNAME( xdevice )] );
        TedText( CURNAME ) = &DriverText[0];

	/* Take care of the ROM/RES flags */
	Deselect( CURROM );
	Deselect( CURRES );
	
	if( DTYPE( xdevice ) == 'P' )	/* ROM driver */
	     Select( CURROM );
	
	if( DTYPE( xdevice ) == 'R' )	/* Resident Driver */
	     Select( CURRES );
	
        Objc_draw( tree, CURNUM, MAX_DEPTH, NULL );
        Objc_draw( tree, CURNAME, MAX_DEPTH, NULL );
        Objc_draw( tree, CURROM, MAX_DEPTH, NULL );
        Objc_draw( tree, CURRES, MAX_DEPTH, NULL );

	/* Let's check and redraw the DELETE driver key only
	 * when the device # is >= 9 so that it won't blink.
	 */
	if( DDEV( xdevice ) >= 9 )
	{
          /* turn on/off the EDELETE button here too */
          rect = ObRect( EDELETE  );
          objc_offset( tree, EDELETE, &rect.g_x, &rect.g_y );

	  rect.g_x -= 3;
	  rect.g_y -= 3;
	  rect.g_w += 6;
	  rect.g_h += 6;
        
          if( DDEV( xdevice ) > 9 )
          {
             MakeExit( EDELETE );
             Enable( EDELETE );
          }
          else
          {
             NoExit( EDELETE );
	     Disable( EDELETE );           
          }
          Objc_draw( tree, ROOT, MAX_DEPTH, &rect );
        }  
      }  
      Evnt_timer( 100L );
      
      Graf_mkstate( &mk );
   }while( mk.buttons );
   
   deselect( tree, button );
}
Exemplo n.º 8
0
/* XDeviceUpDown()
 * =======================================================================
 * Handles the up/down buttons on displaying an active driver and device.
 * so that we can decide which driver to transfer fonts to.
 */
void
XDeviceUpDown( int button )
{
   MRETS mk;
   DEV_PTR olddev;
   GRECT rect;
      
   select( tree, button );
   do
   {
      olddev = cur_device;
      
      if( button == OXUP )
      {
         if( DNEXT( cur_device ) )
             cur_device = DNEXT( cur_device );
      }
      else
      {
         if( DPREV( cur_device ) )
             cur_device = DPREV( cur_device );
      }

      if( olddev != cur_device )
      {
        sprintf( Device_Text, "%d", DDEV( cur_device ) );
        TedText( OXDEVICE ) = &Device_Text[0];
        
        strcpy( Driver_Text, drivers[ DNAME( cur_device )] );
	strip_period( &Driver_Text[0] );
	        
        TedText( OXDRIVER ) = &Driver_Text[0];
        
        ClearListFlags();
        SetListFlags();   
        mover_setup( bit_list, bit_count - DFCOUNT( cur_device ),
		     OBASE, OSLIDE, OUP, ODOWN,
		     OLINE0, OLINE5, OLBASE, Cur_Slit );
        
        Objc_draw( tree, OXDEVICE, MAX_DEPTH, NULL );
        Objc_draw( tree, OXDRIVER, MAX_DEPTH, NULL );
        Objc_draw( tree, OLBASE, MAX_DEPTH, NULL );
        Objc_draw( tree, OBASE, MAX_DEPTH, NULL );
        
        
        /* turn on/off the XTRANSFR button here too */
        rect = ObRect( XTRANSFR );
        objc_offset( tree, XTRANSFR, &rect.g_x, &rect.g_y );

	rect.g_x -= 3;
	rect.g_y -= 3;
	rect.g_w += 6;
	rect.g_h += 6;

        if( IsChanged( bit_list ) )
        {
           MakeExit( XTRANSFR );
           Enable( XTRANSFR );
        }
        else
        {
           NoExit( XTRANSFR );
	   Disable( XTRANSFR );           
        }
        Objc_draw( tree, ROOT, MAX_DEPTH, &rect );
      }  
      Evnt_timer( 100L );
      
      current_device = cur_device;	/* let's make them equal */
      
      Graf_mkstate( &mk );
   }while( mk.buttons );
   
   deselect( tree, button );
}