示例#1
0
t_stat cpu_set_model (UNIT *uptr, int32 val, char *cptr, void *desc)
{
#if defined(HAVE_LIBSDL) 
char gbuf[CBUFSIZE];

if ((cptr == NULL) || (!*cptr))
    return SCPE_ARG;
cptr = get_glyph (cptr, gbuf, 0);
if (MATCH_CMD(gbuf, "MICROVAX") == 0) {
    sys_model = 0;
    vc_dev.flags = vc_dev.flags | DEV_DIS;               /* disable QVSS */
    lk_dev.flags = lk_dev.flags | DEV_DIS;               /* disable keyboard */
    vs_dev.flags = vs_dev.flags | DEV_DIS;               /* disable mouse */
    strcpy (sim_name, "MicroVAX I (KA610)");
    reset_all (0);                                       /* reset everything */
    }
else if (MATCH_CMD(gbuf, "VAXSTATION") == 0) {
    sys_model = 1;
    vc_dev.flags = vc_dev.flags & ~DEV_DIS;              /* enable QVSS */
    lk_dev.flags = lk_dev.flags & ~DEV_DIS;              /* enable keyboard */
    vs_dev.flags = vs_dev.flags & ~DEV_DIS;              /* enable mouse */
    strcpy (sim_name, "VAXStation I (KA610)");
    reset_all (0);                                       /* reset everything */
    }
else
    return SCPE_ARG;
return SCPE_OK;
#else
return SCPE_NOFNC;
#endif
}
示例#2
0
t_stat cpu_set_model (UNIT *uptr, int32 val, char *cptr, void *desc)
{
char gbuf[CBUFSIZE];

if ((cptr == NULL) || (!*cptr))
    return SCPE_ARG;
cptr = get_glyph (cptr, gbuf, 0);
if (MATCH_CMD(gbuf, "MICROVAX") == 0) {
    sys_model = 0;
#if defined(USE_SIM_VIDEO) && defined(HAVE_LIBSDL)
    vc_dev.flags = vc_dev.flags | DEV_DIS;               /* disable QVSS */
    lk_dev.flags = lk_dev.flags | DEV_DIS;               /* disable keyboard */
    vs_dev.flags = vs_dev.flags | DEV_DIS;               /* disable mouse */
#endif
    strcpy (sim_name, "MicroVAX I (KA610)");
    reset_all (0);                                       /* reset everything */
    }
else if (MATCH_CMD(gbuf, "VAXSTATION") == 0) {
#if defined(USE_SIM_VIDEO) && defined(HAVE_LIBSDL)
    sys_model = 1;
    vc_dev.flags = vc_dev.flags & ~DEV_DIS;              /* enable QVSS */
    lk_dev.flags = lk_dev.flags & ~DEV_DIS;              /* enable keyboard */
    vs_dev.flags = vs_dev.flags & ~DEV_DIS;              /* enable mouse */
    strcpy (sim_name, "VAXStation I (KA610)");
    reset_all (0);                                       /* reset everything */
#else
    return sim_messagef(SCPE_ARG, "Simulator built without Graphic Device Support");
#endif
    }
else
    return SCPE_ARG;
return SCPE_OK;
}
示例#3
0
void parser::parse_c(string ins)
{
      reset_all();
      size_t x=ins.find_first_of("=;");
      if(ins[x]=='=')   //if there is =(equal) part
      {
        size_t len=x-0;
	dest=ins.substr(0, len);   //in case of dest = comp ; jump
	size_t first_semi_colon=ins.find_first_of(";");
	if(first_semi_colon!=string::npos)   //we found semi colon so there is jump
	{
	   len = first_semi_colon - x -1;
	   comp=ins.substr(x+1,len);
           jump=ins.substr(first_semi_colon+1);
        }
        else    //no jump part
        {
           comp=ins.substr(x+1);
        }	   
      }
      if(ins[x]==';')  //if no equal part
      {
        size_t len=x-0;
	comp=ins.substr(0,len);
	jump=ins.substr(x+1);
      }	
}
示例#4
0
文件: sudoku.c 项目: rushi4444/sudoku
void main()
{
	int row,colum,value,k=0;
	reset_all();
	for(row=0;row<9;row++)
		for(colum=0;colum<9;colum++)
		{
			scanf("%d",&value);
			//value=starter(row,colum);
			if(value==0)
				continue;
			st_node(row,colum,value);
		}
	while(k<10)
	{
		check4row();
		check4col();
		check4box();
		thirdlogic();
		k++;
	}
	if(total<81)
		assume();
	print();
	getch();
}
示例#5
0
static void back_click_handler(ClickRecognizerRef recognizer, void *context) {
  if (s_state == BEGINNING_STATE) {
    window_stack_pop(true);
  } else if (s_state == CHECKING_CONTACT_STATE && has_contact) {
    // contact_try++;
    // get_contact();
    // has_contact = false;
  } else if (s_state == CREATING_FINAL_MESSAGE_STATE) {
    reset_all();

    snprintf(instruction_text, sizeof(instruction_text), "%s", "Choose recipient");
    text_layer_set_text(s_instruction_layer, instruction_text);

    primary_text[0] = '\0';
    text_layer_set_text(s_primary_layer, primary_text);
  } else if (s_state == CONFIRMING_FINAL_MESSAGE_STATE) {
    change_state(CREATING_FINAL_MESSAGE_STATE);

    dictated_message[0] = '\0';

    snprintf(instruction_text, sizeof(instruction_text), "%s", "Create message");
    snprintf(primary_text, sizeof(primary_text), "%s", contact_name);
    text_layer_set_text(s_instruction_layer, instruction_text);
    text_layer_set_text(s_primary_layer, primary_text);
    // dictated_message[0] = '\0';
    // snprintf(primary_text, sizeof(primary_text), "%s", dictated_message);
    // text_layer_set_text(s_primary_layer, primary_text);
    // change_state(CREATING_FINAL_MESSAGE_STATE);
  }
}
示例#6
0
int main() {
	int i, j, s, sum=0;
	UNDIRECTED first=NULL, min;
	printf("Enter number of vertices\n");
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		for(j=0;j<n;j++) {
			scanf("%d", &input[i][j]);
		}
	}
	printf("Enter source\n");
	scanf("%d", &s);
	reset_all();
	remove_element_array(vertex, &vindex, s);
	push_array(finished, &findex, s);
	while(findex<n-1) {
		for(i=0;i<=findex;i++) {
			for(j=0;j<=vindex;j++) {
				first=insert_ll(first, new_connection(finished[i], vertex[j]));
			
			}
		}
		min=find_minimum(first);
		push_array(finished, &findex, min->d);
		remove_element_array(vertex, &vindex, min->d);
		first=destroy_ll(first);
		sum+=distance(min->s, min->d);
		printf("%d->%d = %d\n", min->s, min->d, distance(min->s, min->d));
	}
	printf("Total distance = %d\n", sum);
	return 0;
}
bool zz_font_texture_d3d::invalidate_device_objects ()
{
	SAFE_RELEASE(_texture);
	SAFE_RELEASE(_surface);

	reset_all();

	return true;
}
示例#8
0
void search_not_chosen() {
  reset_all();

  snprintf(instruction_text, sizeof(instruction_text), "%s", "Choose recipient");
  text_layer_set_text(s_instruction_layer, instruction_text);

  primary_text[0] = '\0';
  text_layer_set_text(s_primary_layer, primary_text);
}
示例#9
0
/*
* Writes a byte to the pin register in 2 4 bit nibbles
* Uses append/remove functions such that it maintains current pin state
*/
void write_4_bits(int bits, int char_mode) {
	usleep(1000);

	reset_all();
	set_rs(char_mode);

	write_pins_append(bits>>4);

	pulse_enable();

	write_pins_remove(0xf);
	write_pins_append(bits&0xf);

	pulse_enable();

	usleep(500);
	reset_all();
}
示例#10
0
int32 con_halt (int32 code, int32 cc)
{
if ((vax610_boot_parse (0, cpu_boot_cmd) != SCPE_OK) || /* reparse the boot cmd */ 
    (reset_all (0) != SCPE_OK) ||                       /* reset the world */
    (cpu_boot (0, NULL) != SCPE_OK))                    /* set up boot code */
    ABORT (STOP_BOOT);                                  /* any error? */
sim_printf ("Rebooting...\n");
return cc;
}
示例#11
0
void parser::parse_a(string ins)
{
     reset_all();
     string tmp=ins.substr(1);   //get rid of '@'
     size_t found = tmp.find_first_not_of("0123456789"); 
     if(found==string::npos)  //number
 	this->number = stol(tmp);      
     else  //symbols         
 	symbol=tmp;
}
示例#12
0
SigFlags::SigFlags()
{
    int i;

    if (!initialized)
    {
        initialized = true;
        reset_all();
    }

    for (i = 0; i < _NSIG; i++)
    {
        handlers[i].set_num(i);
        handlers[i].set_function(SigFlags::generic_handler);
    }

    handlers[SIGILL].set_function(SigFlags::core_dump_handler);
    if (handlers[SIGILL].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGILL");

    handlers[SIGBUS].set_function(SigFlags::core_dump_handler);
    if (handlers[SIGBUS].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGBUS\n");

    handlers[SIGIO].set_function(SigFlags::core_dump_handler);
    if (handlers[SIGIO].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGIO\n");

    handlers[SIGXCPU].set_function(SigFlags::core_dump_handler);
    if (handlers[SIGXCPU].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGXCPU\n");

    handlers[SIGXFSZ].set_function(SigFlags::core_dump_handler);
    if (handlers[SIGXFSZ].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGXFSZ\n");

    if (handlers[SIGINT].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGINT\n");

    if (handlers[SIGTERM].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGTERM\n");

    if (handlers[SIGHUP].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGHUP\n");

    if (handlers[SIGCHLD].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGCHLD\n");

    if (handlers[SIGALRM].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGALRM\n");

    if (handlers[SIGPIPE].activate())
        fprintf(stderr,"SigFlags: unable to handle SIGPIPE\n");
}
示例#13
0
UT_Error UT_XML::parse (const UT_ByteBuf * pBB)
{
  UT_ASSERT (m_pListener || m_pExpertListener);
  UT_ASSERT (pBB);

  if ((pBB == 0) || ((m_pListener == 0) && (m_pExpertListener == 0))) return UT_ERROR;
  if (!reset_all ()) return UT_OUTOFMEM;

  const char * buffer = reinterpret_cast<const char *>(pBB->getPointer (0));
  UT_uint32 length = pBB->getLength ();

  return parse (buffer, length);
}
示例#14
0
UT_Error UT_XML::parse (const char * buffer, UT_uint32 length)
{
  if (!m_bSniffing)
    {
      UT_ASSERT (m_pListener || m_pExpertListener);
      if ((m_pListener == 0) && (m_pExpertListener == 0)) return UT_ERROR;
    }
  UT_ASSERT (buffer);
  if (buffer == 0 || length == 0) return UT_ERROR;

  if (!reset_all ()) return UT_OUTOFMEM;

  UT_Error ret = UT_OK;

  xmlParserCtxtPtr ctxt;

  xmlSAXHandler hdl;
  memset(&hdl, 0, sizeof(hdl));

  hdl.getEntity    = _getEntity;
  hdl.startElement = _startElement;
  hdl.endElement   = _endElement;
  hdl.characters   = _charData;
  hdl.error        = _errorSAXFunc;
  hdl.fatalError   = _fatalErrorSAXFunc;
  hdl.processingInstruction = _processingInstruction;
  hdl.comment      = _comment;
  hdl.cdataBlock   = _cdata;

  ctxt = xmlCreateMemoryParserCtxt (buffer, static_cast<int>(length));
  if (ctxt == NULL)
    {
      UT_DEBUGMSG (("Unable to create libxml2 memory context!\n"));
      return UT_ERROR;
    }
  memcpy(ctxt->sax, &hdl, sizeof(hdl));
  ctxt->userData = static_cast<void *>(this);

  m_bStopped = false;

  xmlParseDocument (ctxt);

  if (!ctxt->wellFormed) ret = UT_IE_IMPORTERROR;

  xmlDocPtr myXmlDoc = ctxt->myDoc;
  xmlFreeParserCtxt (ctxt);
  xmlFreeDoc(myXmlDoc);

  return ret;
}
示例#15
0
/*
* Requires that the LCD screen be connected to GPIO pins controlled by the supplied register in the following order:
*
* 0 - DB4
* 1 - DB5
* 2 - DB6
* 3 - DB7
* 4 - RS
* 5 - R/W
* 6 - E
* 7 - Nothing Connected (you can't use this pin)
*/
void lcdinit(int io_register, int pin_register, int device) {
	lcd_io_register = io_register;
	lcd_pin_register = pin_register;

	fd = wiringPiI2CSetup(device);

	// All pins output and off
	reset_all();

	// Initial display mode
	current_display_mode = 0x0C; // Display on, cursor off, blink off

	write_4_bits(0x33, 0); // Init
	write_4_bits(0x32, 0); // Init / Change to 4 bit mode
	write_4_bits(0x28, 0); // 2 lines, 5x7
	write_4_bits(current_display_mode, 0); // Set initial display mode
	write_4_bits(0x06, 0); // Shift cursor Right

	clear_screen();
}
示例#16
0
void parse_xml_buffer(const char *url, const char *buffer, int size,
			struct dive_table *table, GError **error)
{
	xmlDoc *doc;

	target_table = table;
	doc = xmlReadMemory(buffer, size, url, NULL, 0);
	if (!doc) {
		fprintf(stderr, _("Failed to parse '%s'.\n"), url);
		parser_error(error, _("Failed to parse '%s'"), url);
		return;
	}
	reset_all();
	dive_start();
#ifdef XSLT
	doc = test_xslt_transforms(doc, error);
#endif
	traverse(xmlDocGetRootElement(doc));
	dive_end();
	xmlFreeDoc(doc);
}
示例#17
0
	/**
		Assign all props to state.
	*/
	PropStateStore&
	assign_all(
		IO::PropState const state
	) noexcept {
		switch (state) {
		case IO::PropState::unsupplied:
			reset_all();
			break;
		case IO::PropState::original:
			m_states
				= (~m_supplied & mask_unsupplied_implied)
				| (m_supplied & all_mask_original)
			;
			break;
		case IO::PropState::modified:
			m_states
				= (~m_supplied & mask_unsupplied_implied)
				| (m_supplied & all_mask_modified)
			;
			break;
		}
		return *this;
	}
示例#18
0
UT_Error UT_XML::parse (const char * szFilename)
{
	UT_ASSERT (m_pListener || m_pExpertListener);
	UT_ASSERT (szFilename);
	
	if ((szFilename == 0) || ((m_pListener == 0) && (m_pExpertListener == 0))) return UT_ERROR;
	if (!reset_all ()) return UT_OUTOFMEM;
	
	UT_Error ret = UT_OK;
	
	DefaultReader defaultReader;
	Reader * reader = &defaultReader;
	if (m_pReader)
		reader = m_pReader;
	
	if (!reader->openFile (szFilename))
    {
		UT_DEBUGMSG (("Could not open file %s\n", szFilename));
		return UT_errnoToUTError ();
    }
	
	char buffer[2048];
	
	m_bStopped = false;
	
	xmlSAXHandler hdl;
	xmlParserCtxtPtr ctxt = 0;
	
	memset(&hdl, 0, sizeof(hdl));
	
	hdl.getEntity    = _getEntity;
	hdl.startElement = _startElement;
	hdl.endElement   = _endElement;
	hdl.characters   = _charData;
	hdl.error        = _errorSAXFunc;
	hdl.fatalError   = _fatalErrorSAXFunc;
	hdl.processingInstruction = _processingInstruction;
	hdl.comment      = _comment;
	hdl.cdataBlock   = _cdata;

	size_t length = reader->readBytes (buffer, sizeof (buffer));
	int done = (length < sizeof (buffer));
	
	if (length != 0)
    {
		ctxt = xmlCreatePushParserCtxt (&hdl, static_cast<void *>(this), buffer, static_cast<int>(length), szFilename);
		if (ctxt == NULL)
		{
			UT_DEBUGMSG (("Unable to create libxml2 push-parser context!\n"));
			reader->closeFile ();
			return UT_ERROR;
		}
		xmlSubstituteEntitiesDefault (1);
		UT_sint32 chucks = -1;
		while (!done && !m_bStopped)
		{
			chucks++;
			length = reader->readBytes (buffer, sizeof (buffer));
			UT_DEBUGMSG(("Done chunk %d length %zd \n",chucks,length));
			done = (length < sizeof (buffer));
			
			if (xmlParseChunk (ctxt, buffer, static_cast<int>(length), 0))
			{
			  if(getNumMinorErrors() > getNumRecoveredErrors())
			    {
				UT_DEBUGMSG (("Error - 1 parsing '%s' (Line: %d, Column: %d)\n", szFilename, xmlSAX2GetLineNumber(ctxt), xmlSAX2GetColumnNumber(ctxt)));
				ret = UT_IE_IMPORTERROR;
				break;
			    }
			}
		}
		if (ret == UT_OK)
		  if (!m_bStopped && (getNumMinorErrors() == 0))
			{
				if (xmlParseChunk (ctxt, "", 0, 1))
				{
					UT_DEBUGMSG (("Error -2 parsing '%s' (Line: %d, Column: %d)\n", szFilename, xmlSAX2GetLineNumber(ctxt), xmlSAX2GetColumnNumber(ctxt)));
					ret = UT_IE_IMPORTERROR;
				}
			}
		if (ret == UT_OK && (getNumMinorErrors() == 0))
			if (!ctxt->wellFormed && !m_bStopped) ret = UT_IE_IMPORTERROR; // How does stopping mid-file affect wellFormed?

		xmlDocPtr myXmlDoc = ctxt->myDoc;
		xmlFreeParserCtxt (ctxt);
		xmlFreeDoc(myXmlDoc);
    }
	else
    {
		UT_DEBUGMSG(("Empty file to parse - not sure how to proceed\n"));
    }
	
	reader->closeFile ();
	
	return ret;
}
示例#19
0
void parser::parse_label(string ins)
{
     reset_all();
}
示例#20
0
文件: FRACT.C 项目: k0gaMSX/legacy
main()
{
	float a,e,u,o,p,q,h,i,j,k,x,y;
	int f,t,z,s;
	static char warn[] = "ANY KEY QUITS";

	a = -1.1;	/* links  (-2..0) */
	e = .95;	/* rechts (0..2)  */
	u = -1.33;	/* onder  (-2..0) */
	o = 1.85;	/* boven  (0..2)  */
	f = 15; 	/* diepte (1..)   */

	x=((e-a)/(MAXX-1));
	y=((o-u)/(MAXY-1));

	p=a;
	q=o;
	screen(SCR);
	color(15,1,1);
	setpg(1,1);			/* teken op pagina 1 */
	cls();
	inispr(4);			/* sprites uit */
	glocate(10,200);

	for(z=0;z<strlen(warn);z++)
	  grpprt(warn[z],PSET); 	/* zet text op het scherm */

	for(z=1;z<9;z++)		/* verander paletkleuren */
	  setplt(z,(z-1)<<4);
	for(z=9;z<16;z++)
	  setplt(z,((7-(z-9))<<4)+((z-8)<<8));

	for(z=10;z<MAXY;z++)		/* verticale resolutie */
	{
	for(s=0;s<(MAXX);s++)		/* horizontale resolutie */
	{
	  t=0;
	  h=i=j=k=0;
lus:
	  if ((t==f) || ((j+k) >= 8))
	  {
	     pset(s,z,t,PSET);		/* pset (x,y,kleur,logop */
	     p += x;
	  }
	  else {
		  i *= h; i += i; i -= q; h = (j-k-p);
		  j = (h*h); k = (i*i); t++;
		  goto lus;
	       }
	} /* loop S */
	p=a;
	q -= y;
	if (kbhit())			/* indien toetsdruk */
	   {
	     reset_all();
	     exit(0);			/* eindig */
	   }
	}  /* loop Z */
	beep();
	z = getch();			/* wacht op toetsdruk */
	reset_all();
} /* main */
示例#21
0
int main(void)
{
    long r, lstlzz, error_code;
    int stkl, year;

    printf("\n/*************************");
    printf("\n * This is the C-program *");
    printf("\n *************************/\n");
    printf("\nLohnsteuer (german wage tax) (all amounts in Euro):\n");
    /*
     * Error-checking by return values is provided for every function.
     * Make sure, you always check them!  The library will not crash if
     * you set illegal values, you will get results but they will be wrong.
     * This is a feature not a bug.  Doing it this way, you can choose,
     * how to continue and what to do next.
     */
    for (year = get_first_year(); year <= get_last_year(); ++year) {
	printf("\nYear: %d\n", year);
	printf
	    ("     RE4       I      II     III      IV       V      VI\n");
	printf
	    ("--------------------------------------------------------\n");
	for (r = 2; r <= 24; ++r) {
	    printf("%8ld", r * 2500);
	    for (stkl = 1; stkl <= 6; ++stkl) {
		error_code = reset_all();
		if (error_code == no_error_code)
		    error_code = set_year(year);
		if (error_code == no_error_code)
		    error_code = set_lzz(1);
		/*
		 * The library expects all amounts in Euro-Cent.
		 * So we multiply by 100.
		 */
		if (error_code == no_error_code)
		    error_code = set_re4(r * 250000);
		if (error_code == no_error_code)
		    error_code = set_stkl(stkl);
		/*
		 * After all parameters are set we call the function
		 * which calculates the wage tax (Lohnsteuer)
		 */
		if (error_code == no_error_code)
		    error_code = calc_lst();
		/*
		   * As above: the library returns Euro-Cents:
		 */
		if (error_code == no_error_code)
		    lstlzz = get_lstlzz() / 100;
		if (error_code == no_error_code)
		    printf("%8ld", lstlzz);
		else
		    printf("   %s", "error");
	    }
	    printf("\n");
	};
	if (error_code != no_error_code) {
	    if (error_code == program_error_code)
		printf("Error: Program error.\n");
	    else if (error_code == tasking_error_code)
		printf("Error: Tasking error.\n");
	    else if (error_code == storage_error_code)
		printf("Error: Storage error.\n");
	    else if (error_code == constraint_error_code)
		printf
		    ("Error: Constraint Error (probably value out of range).\n");
	    else if (error_code == parameter_not_defined_error_code)
		printf("Error: Parameter not defined.\n");
	    else if (error_code == general_error_code)
		printf("Error: General error.\n");
	    else
		/*
		 * Should not be reached, all unknown errors should be caught
		 * by general_error.  If you get the following message, send
		 * me a bug-report.
		 */
		printf("Unknown error.\n");
	    error_code = no_error_code;
	}
    }
    /*
     * Now an example for the income tax.  Like above, you should always
     * check the return values.  I spare it here to keep the example short.
     */
    printf
	("\nEinkommensteuer (german income tax) (all amounts in Euro):\n");
    for (year = get_first_year(); year <= get_last_year(); ++year) {
	printf("\nYear: %d\n", year);
	printf("     ZVE        Grundtabelle    Splittingtabelle\n");
	printf("------------------------------------------------\n");
	for (r = 1; r <= 10; ++r) {
	    printf("%8ld", r * 10000);
	    reset_all();
	    set_year(year);
	    set_lzz(1);
	    set_zve(r * 1000000);
	    calc_est();
	    printf("%20ld", get_grundtab() / 100);
	    printf("%20ld\n", get_splittab() / 100);
	};
    }
    return 0;
}
示例#22
0
文件: pdp10_fe.c 项目: B-Rich/simh
/* Keep-alive service
 * If the 8080 detects the 'force reload' bit, it initiates a disk
 * boot.  IO is reset, but memory is preserved.
 *
 * If the keep-alive enable bit is set, the -10 updates the keep-alive
 * count field every second.  The 8080 also checks the word every second.
 * If the 8080 finds that the count hasn't changed for 15 consecutive seconds,
 * a Keep-Alive Failure is declared.  This forces the -10 to execute the
 * contents of exec location 71 to collect status and initiate error recovery.
 */
static t_stat kaf_svc (UNIT *uptr)
{
if (M[FE_KEEPA] & INT64_C(0020000000000)) {              /* KSRLD - "Forced" (actually, requested) reload */
    uint32 oldsw = sim_switches;
    DEVICE *bdev = NULL;
    int32 i;

    sim_switches &= ~SWMASK ('P');
    reset_all (4);                                      /* RESET IO starting with UBA */
    sim_switches = oldsw;

    M[FE_KEEPA] &= ~INT64_C(0030000177777);             /* Clear KAF, RLD, KPALIV & reason
                                                         * 8080 ucode actually clears HW 
                                                         * status too, but that's a bug. */
    M[FE_KEEPA] |= 02;                                  /* Reason = FORREL */
    fei_unit.buf = feo_unit.buf = 0;
    M[FE_CTYIN] = M[FE_CTYOUT] = 0;
    M[FE_KLININ] = M[FE_KLINOUT] = 0;

    /* The 8080 has the disk RH address & unit in its memory, even if
     * the previous boot was from tape.  It has no NVM, so the last opr
     * selection will do here.  The case of DS MT <rld> would require a
     * SET FE command.  It's not a common case.
     */

    /* The device may have been detached, disabled or reconfigured since boot time.
     * Therefore, search for it by CSR address & validate that it's bootable.
     * If there are problems, the processor is halted.
     */

    for (i = 0; fe_bootrh && (bdev = sim_devices[i]) != NULL; i++ ) {
        DIB *dibp = (DIB *)bdev->ctxt;
        if (dibp && (fe_bootrh >= dibp->ba) &&
           (fe_bootrh < (dibp->ba + dibp->lnt))) {
            break;
            }
        }

    fe_xct = 2;
    if ((bdev != NULL) && (fe_bootunit >= 0) && (fe_bootunit < (int32) bdev->numunits)) {
        UNIT *bunit = bdev->units + fe_bootunit;

        if (!(bunit->flags & UNIT_DIS) && (bunit->flags & UNIT_ATTABLE) && (bunit->flags & UNIT_ATT)) {
            if (bdev->boot (fe_bootunit, bdev) == SCPE_OK) /* boot the device */
                fe_xct = 1;
            }
        }
    }
else if (M[FE_KEEPA] & INT64_C(0010000000000)) {        /* KPACT */
    d10 kav = M[FE_KEEPA] & INT64_C(0000000177400);     /* KPALIV */
    if (kaf_unit.u3 != (int32)kav) {
        kaf_unit.u3 = (int32)kav;
        kaf_unit.u4 = 0;
        }
    else if (++kaf_unit.u4 >= 15) {
        kaf_unit.u4 = 0;
        M[FE_KEEPA] = (M[FE_KEEPA] & ~INT64_C(0000000000377)) | 01; /* RSN = KAF (leaves enabled) */
        fei_unit.buf = feo_unit.buf = 0;
        M[FE_CTYIN] = M[FE_CTYOUT] = 0;
        M[FE_KLININ] = M[FE_KLINOUT] = 0;
        fe_xct = 071;
        }
    }

sim_activate_after (&kaf_unit, kaf_unit.wait);
if (fe_xct == 2) {
    fe_xct = 0;
    return STOP_CONSOLE;
    }
return SCPE_OK;
}
示例#23
0
文件: tween.cpp 项目: 03050903/godot
void Tween::_tween_process(float p_delta) {

	_process_pending_commands();

	if (speed_scale == 0)
		return;
	p_delta *= speed_scale;

	pending_update ++;
	// if repeat and all interpolates was finished then reset all interpolates
	if(repeat) {
		bool all_finished = true;

		for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {

			InterpolateData& data = E->get();

			if(!data.finish) {
				all_finished = false;
				break;
			}
		}

		if(all_finished)
			reset_all();
	}

	for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {

		InterpolateData& data = E->get();
		if(!data.active || data.finish)
			continue;

		Object *object = ObjectDB::get_instance(data.id);
		if(object == NULL)
			continue;

		bool prev_delaying = data.elapsed <= data.delay;
		data.elapsed += p_delta;
		if(data.elapsed < data.delay)
			continue;
		else if(prev_delaying) {

			emit_signal("tween_start",object,data.key);
			_apply_tween_value(data, data.initial_val);
		}

		if(data.elapsed > (data.delay + data.times_in_sec)) {

			data.elapsed = data.delay + data.times_in_sec;
			data.finish = true;
		}

		switch(data.type)
		{
		case INTER_PROPERTY:
		case INTER_METHOD:
			break;
		case INTER_CALLBACK:
			if(data.finish) {

				Variant::CallError error;
				if (data.call_deferred) {

					switch (data.args) {
					case 0:
						object->call_deferred(data.key); break;
					case 1:
						object->call_deferred(data.key, data.arg[0]); break;
					case 2:
						object->call_deferred(data.key, data.arg[0], data.arg[1]); break;
					case 3:
						object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2]); break;
					case 4:
						object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3]); break;
					case 5:
						object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]); break;
					}

				}
				else {
					Variant *arg[5] = {
						&data.arg[0],
						&data.arg[1],
						&data.arg[2],
						&data.arg[3],
						&data.arg[4],
					};
					object->call(data.key, (const Variant **) arg, data.args, error);
				}
			}
			continue;
		}

		Variant result = _run_equation(data);
		emit_signal("tween_step",object,data.key,data.elapsed,result);

		_apply_tween_value(data, result);

		if (data.finish) {
			emit_signal("tween_complete",object,data.key);
			// not repeat mode, remove completed action
			if (!repeat)
				call_deferred("remove", object, data.key);
		}
	}
	pending_update --;
}
示例#24
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  // APP_LOG(APP_LOG_LEVEL_INFO, "recieved message");
  Tuple *connectionTestDict = dict_find(iterator, CONNECTION_TEST_KEY);
  if (s_state == BEGINNING_STATE && connectionTestDict) {
    is_connected = true;
    snprintf(primary_text, sizeof(primary_text), "%s", "Connected");
    text_layer_set_text(s_primary_layer, primary_text);
  }

  if (s_state == CHECKING_CONTACT_STATE) {
    Tuple *contactNamesDict = dict_find(iterator, CONTACT_NAMES_KEY);
    Tuple *contactNumbersDict = dict_find(iterator, CONTACT_NUMBERS_KEY);
    Tuple *contactIdsDict = dict_find(iterator, CONTACT_IDS_KEY);

    Tuple *contactNameDict = dict_find(iterator, CONTACT_NAME_KEY);
    Tuple *contactNumberDict = dict_find(iterator, CONTACT_NUMBER_KEY);

    if (contactNamesDict && contactNumbersDict && contactIdsDict) {
      // action_bar_layer_set_icon(s_actionbar, BUTTON_ID_UP, check_icon);
      // action_bar_layer_set_icon(s_actionbar, BUTTON_ID_DOWN, x_icon);

      search_contact_chooser_init();
      set_search_response((char *)contactNamesDict->value->cstring, (char *)contactNumbersDict->value->cstring, (char *)contactIdsDict->value->cstring);
    } else if (contactNameDict && contactNumberDict) {
      action_bar_layer_set_icon(s_actionbar, BUTTON_ID_UP, check_icon);
      action_bar_layer_set_icon(s_actionbar, BUTTON_ID_DOWN, x_icon);

      has_contact = true;
      snprintf(contact_name, sizeof(contact_name), "%s", (char *)contactNameDict->value->cstring);
      snprintf(contact_number, sizeof(contact_number), "%s", (char *)contactNumberDict->value->cstring);

      snprintf(instruction_text, sizeof(instruction_text), "%s", contact_name);
      snprintf(primary_text, sizeof(primary_text), "%s", contact_number);
      text_layer_set_text(s_instruction_layer, instruction_text);
      text_layer_set_text(s_primary_layer, primary_text);
    }
  }

  Tuple *recievedDict = dict_find(iterator, RECIEVED_FINAL_MESSAGE_KEY);
  if (s_state == SENDING_FINAL_MESSAGE_STATE && recievedDict) {
    change_state(FINAL_MESSAGE_STATE);
    
    snprintf(instruction_text, sizeof(instruction_text), "%s", recievedDict->value->cstring);
    snprintf(primary_text, sizeof(primary_text), "%s", "");
    text_layer_set_text(s_instruction_layer, instruction_text);
    text_layer_set_text(s_primary_layer, primary_text);
  }

  Tuple *messageConfirmationDict = dict_find(iterator, MESSAGE_CONFIRMATION_KEY);
  if (s_state == FINAL_MESSAGE_STATE && messageConfirmationDict) {
    reset_all();
    
    snprintf(instruction_text, sizeof(instruction_text), "%s", messageConfirmationDict->value->cstring);
    snprintf(primary_text, sizeof(primary_text), "%s", "Choose another recipient");
    text_layer_set_text(s_instruction_layer, instruction_text);
    text_layer_set_text(s_primary_layer, primary_text);

    if (are_strings_equal(messageConfirmationDict->value->cstring, "Sent")) {
      vibes_short_pulse();
    } else {
      static const uint32_t const segments[] = { 300, 200, 300 };
      VibePattern pat = {
        .durations = segments,
        .num_segments = ARRAY_LENGTH(segments),
      };
      vibes_enqueue_custom_pattern(pat);
    }
  }