Example #1
0
int memory_save(int position)
{
	char filename[256];
	
	printf("Enter save file name: ");
	fgets(filename, 256, stdin);
	filename[strlen(filename) - 1] = '\0';
	if (sc_memorySave(filename) == 0) {
		refresh_gui(position);
		printf("File successfully saved");
		return 0;
	}
	else {
		printf("Cannot save file: %s", filename);
		return -1;
	}
}
Example #2
0
void check_mem()
{
    printf("memory tests--\n");
    int tmp = 0;
    sc_memoryInit();
    if (!sc_memorySet(15, 15)) {
        printf("Set pass\n");
        if (!sc_memoryGet(15, &tmp) && tmp == 15) {
            printf("Get pass\n");
            if (!sc_memorySave("mda")) {
                printf("Save pass\n");
                if (!sc_memoryLoad("mda") && memory[15] == 15) {
                    printf("Load pass\n**MEMTEST DONE**\n");
                } else
                    printf("Wrong loaded value\n");
            }
        } else
            printf("Wrong get value\n");
    }
    return;
}
Example #3
0
int main()
{
    signal (SIGALRM, signalhandler);
    signal (SIGUSR1, reset);

    nval.it_interval.tv_sec  = 1;
    nval.it_interval.tv_usec = 0;
    nval.it_value.tv_sec  = 1;
    nval.it_value.tv_usec = 0;	
	
    sc_regInit();
    termInit();
    ax = 0x0;
    ip = 0x0;

    enum Keys key = K_UNKNOWN;
	
	displayBorders();
    displayUI();
    
    f_key = 0;
    f_ign = 0;
    
    while (key != K_Q) {
		
		readKey (&key);
		
		if (key == K_T) {
			sc_regSet(IR, 0);
			alarm(0); 
			f_key = 0;
			cu();
		}
		
		if (!f_key) {
			if (key == K_R    )  {
				sc_regSet(IR, 1);
				sc_regSet(IF, 0);
			}
			
			sc_regGet(IR, &f_key);
			
			if (f_key) {
				timerStart();        
			}
			
			if (key == K_F5   ) user_input_ax();
			if (key == K_F6   ) user_input_ip();
			if (key == K_RIGHT) if (mem_ptr < 99) ++mem_ptr;
			if (key == K_LEFT ) if (mem_ptr >  0) --mem_ptr;
			if (key == K_UP   ) if (mem_ptr - 10 >=  0) mem_ptr -= 10;
			if (key == K_DOWN ) if (mem_ptr + 10 < 100) mem_ptr += 10;
			if (key == K_L	  ) sc_memoryLoad("memory.o");
			if (key == K_S	  ) sc_memorySave("memory.o");
			if (key == K_E	  ) user_input_mem(); 
			if (key == K_I) {
				displayBorders();
				displayUI();
				sc_memoryInit();
				sc_regInit();
			}
			displayUI ();
		}
		
	}
    
	return 0;
}