示例#1
0
文件: d.c 项目: varun-verma11/IMPS
void executeUserCommand(char *assembly, char *bin, struct Processor *proc, char **tokens) {
  printf("\n token 0 --> %s \n",tokens[0]);
  if (strcmp(tokens[0], "reg")==0) {
    tokens++;
    printReg(proc, tokens);
  }
  else if (strcmp(tokens[0], "mem")==0) {
    tokens++;
    printMemory(proc, tokens);
  }
  else if (strcmp(tokens[0], "pc")==0) {
    printPC(proc);
  }
  else if (strcmp(tokens[0], "search")==0) {
    tokens++;
    search(proc, tokens);
  }
  else if (strcmp(tokens[0], "stp")==0) {
    step(proc);
  }
  else if (strcmp(tokens[0], "list")==0) {
    printLine(assembly, ((proc->pc)/4)+1);
  }
  else if (strcmp(tokens[0], "--help")==0) {
    system("cat help.txt | less");
  } else if (strcmp(tokens[0], "run")==0) {
    char cmd[] = "./emulate ";
    *cmd = *strcat(cmd,bin);
    printf("%s\n",cmd);
    system(cmd);
  }
}
示例#2
0
void executeUserCommand(char *fp, struct Processor *proc, char **tokens) {
  if (strcmp(tokens[0], "reg")==0) {
    tokens++;
    printReg(proc, tokens);
  }
  else if (strcmp(tokens[0], "mem")==0) {
    tokens++;
    printMemory(proc, tokens);
  }
  else if (strcmp(tokens[0], "pc")==0) {
    printPC(proc);
  }
  else if (strcmp(tokens[0], "search")==0) {
    tokens++;
    search(proc, tokens);
  }
  else if (strcmp(tokens[0], "stp")==0) {
    step(proc);
  }
  else if (strcmp(tokens[0], "list")==0) {
    printLine(fp, ((proc->pc)/4)+1);
  }
  else if (strcmp(tokens[0], "--help")==0) {
    system("cat help.txt | less");
  }
}
示例#3
0
int executeUserCommand(char *assembly, char *bin, struct Processor *proc, char **tokens, int *breakPoints) {
  if (strcmp(tokens[0], "reg")==0) {
    tokens++;
    printReg(proc, tokens);
    return 0;
  } else if (strcmp(tokens[0], "mem")==0) {
    tokens++;
    printMemory(proc, tokens);
    return 0;
  } else if (strcmp(tokens[0], "pc")==0) {
    printPC(proc);
    return 0;
  } else if (strcmp(tokens[0], "search")==0) {
    tokens++;
    search(proc, tokens);
    return 0;
  } else if (strcmp(tokens[0], "stp")==0) {
    step(proc);
    return 0;
  } else if (strcmp(tokens[0], "list")==0) {
    listInstruction(assembly, ((proc->pc)/4)+1);
    return 0;
  } else if (strcmp(tokens[0], "--help")==0) {
    system("cat help.txt | less");
    return 0;
  } else if (strcmp(tokens[0], "run")==0) {
    run(proc,breakPoints);
    return 0;
  } else if (strcmp(tokens[0],"q")==0) {
    return confirmToQuit();
  } else if (strcmp(tokens[0],"break")==0) {
    setBreakPoints(breakPoints,tokens+1);
    return 0;
  }
  return 0;
}
示例#4
0
int main (int argc, char *argv[])
{
	int i;
	SDL_Event event;
	SDL_Surface *screen;
	struct chip8_state s;
	
	init(&s);
	atexit(SDL_Quit);
	if ((ptrGame=fopen(argv[1],"rb"))==NULL)
	{
		printf("No se puede abrir el archivo\n");
	}
	else
	{
		if (SDL_Init(SDL_INIT_VIDEO)<0)
		{
			printf("No se pudo iniciar SDL: %s\n", SDL_GetError());
			exit(1);
		}
		screen=SDL_SetVideoMode(640,320, 8, SDL_HWSURFACE);
		if (screen == NULL) 
		{
			printf("No se puede inicializar el modo gráfico: %s\n",SDL_GetError());
			exit(1);
		}
		i=fread(&(s.data[512]),1,SIZEMEM,ptrGame)+0x200;
		printf("%d bytes loaded\n", i-0x200);
		fclose(ptrGame);
		#ifdef TODEBUG
		int j;
		for(j=0x200; j<i; j++)
		{
			printf("%02X ",s.data[j]);
		}
		printf("\n");
		#endif
		int x=0;
		while(x==0&&s.PC<i+1)
		{
			ResetTimeBase();
			#ifdef TODEBUG
			printPC(&s);
			printReg(&s);
			if(getchar()==27){x=1;}
			#else
			while (SDL_PollEvent(&event))
			{
				if (event.type == SDL_QUIT) {x=1;}
				if (event.type == SDL_KEYDOWN) 
				{
					if (event.key.keysym.sym == SDLK_ESCAPE) 
					{
						x=1;
					} 
				}
			}
			#endif
			exec(&s);
			if(s.draw) drawscrn(&s,screen);
			s.keypress=keypressed();
			s.draw=0;
			s.PC+=2;
			
			if(s.DT!=0){s.DT--;}
			if(s.ST!=0){s.ST--;}
			
			do {
				frametime=CurrentTime();
			} while (frametime<4);
		}
	}
	return 0;
}