int main(int argc, char* argv[]) { int done; deviceEntry* gpu; ramBlock* mainRAM; romBlock* monitorROM; interfaceChip* userInterface; //Start SDL SDL_Init( SDL_INIT_EVERYTHING ); SDL_ShowCursor( SDL_DISABLE ); atexit(SDL_Quit); printf("SDL started.\n"); gpu = gpu_create(0xFC00); if(gpu == NULL) return 0; mainRAM = ram_create(0x1000, 0xF7FF); monitorROM = rom_create(0x0000, 0x0FFF, "monitor.rom"); userInterface = interface_create(0xFFFE); cpu_addDevice(mainRAM->device); cpu_addDevice(monitorROM->device); cpu_addDevice(gpu); cpu_addDevice(userInterface->device); cpu_reset(); while(cpu_cycle(2000)){ interface_pollKeyboard(); gpu_redraw(); //<- this is slowing execution down a lot. We should really put it on a 30-60hz timer. } gpu_redraw(); printf("CPU halted.", "Notice"); ram_unload(); rom_unload(); interface_unload(); gpu_unload(); cpu_unloadDevices(); SDL_Quit(); return 0; }
void state_menu_init(void *ptr) { glClearColor(0, 0, 0, 1); textbox_t *textbox_title = textbox_create( 50, 10, 300, 100, "BLOCKS", TEXTBOX_COLOR_GREEN, TEXTBOX_FONT_ROBOTO_BOLDITALIC, TEXTBOX_FONT_SIZE_HUGE, 0); textbox_play = textbox_create( 50, 100, 120, 32, "Play!", TEXTBOX_COLOR_BLUE, TEXTBOX_FONT_ROBOTO_REGULAR, TEXTBOX_FONT_SIZE_MEDIUM, TEXTBOX_FLAG_CENTER_V); textbox_load = textbox_create( 50, 130, 120, 32, "Load", TEXTBOX_COLOR_BLUE, TEXTBOX_FONT_ROBOTO_REGULAR, TEXTBOX_FONT_SIZE_MEDIUM, TEXTBOX_FLAG_CENTER_V); textbox_quit = textbox_create( 50, 190, 120, 32, "Quit", TEXTBOX_COLOR_BLUE, TEXTBOX_FONT_ROBOTO_REGULAR, TEXTBOX_FONT_SIZE_MEDIUM, TEXTBOX_FLAG_CENTER_V); ui = interface_create(0); interface_attach_textbox(ui, textbox_title); ui_play = interface_attach_textbox(ui, textbox_play); ui_load = interface_attach_textbox(ui, textbox_load); ui_quit = interface_attach_textbox(ui, textbox_quit); }
/*============ INITIAL SETUP ============================*/ fitinfo* setup_models(int *models) { static fitinfo fit[MODELS]; static Real incoh_w[1] = {1.}; /* Start with equal weighting */ static model *incoh_m[1]; int i; fitpars *pars = &fit[0].pars; fitpars *freepars = &fit[1].pars; for (i=0; i < MODELS; i++) fit_init(&fit[i]); fit[0].number_incoherent = 1; fit[0].incoherent_models = incoh_m; fit[0].incoherent_weights = incoh_w; incoh_m[0] = &fit[1].m; *models = 1; /* Load the data for each model */ fit_data(&fit[0],"wc02.yor"); fit_data(&fit[1],"wc03.yor"); /* Initialize instrument parameters for each model.*/ for (i=0; i < MODELS; i++) { const Real L = 5.0042,dLoL=0.020,d=1890.0; Real Qlo,Tlo, dTlo,dToT,s1,s2; Qlo=0.0154,Tlo=0.35; s1=0.21, s2=s1; dTlo=resolution_dT(s1,s2,d); dToT=resolution_dToT(s1,s2,d,Tlo); data_resolution_fv(&fit[i].dataA,L,dLoL,Qlo,dTlo,dToT); fit[i].beam.lambda = L; fit[i].beam.background = 1e-10; interface_create(&fit[i].rm, "erf", erf_interface, 30); } /*============= MODEL =====================================*/ /* Add layers: d (thickness, �), rho (Nb, �-2), mu (absorption, �?), rough (interlayer roughness, �) */ for (i=0; i < MODELS; i++) { model_layer(&fit[i].m, 0.000, 2.07e-6, 0.0e-8, 10.00); /* 0 substrate */ model_layer(&fit[i].m, 12.000, 3.60e-6, 0.0e-8, 10.00); /* 1 oxide */ model_layer(&fit[i].m, 5.800, 3.8e-6, 0.0e-8, 10.00); /* 2 chromium */ model_layer(&fit[i].m, 90.70, 4.50e-6, 0.0e-8, 10.00); /* 3 gold */ model_layer(&fit[i].m, 18.00, 1.00e-6, 0.0e-8, 10.00); /* 4 spacer */ model_layer(&fit[i].m, 14.00, -0.2e-6, 0.0e-8, 10.00); /* 5 alkyl tails */ model_layer(&fit[i].m, 100.0, 6.35e-6, 0.0e-8, 10.00); /* 6 solvent */ } rho_spacer=0.50e-6; rho_alkyl=-0.40e-6; vol_fract_spacer=0.9; vol_fract_alkyl=0.99; global_rough=10.0; /*correct solvent layers for different models*/ /* fit[3].m.d[3] = ... */ fit[1].m.rho[6]=3.4e-6; /*=============== FIT PARAMETERS ===============================*/ /* Specify which parameters are your fit parameters. Parameters are fitted * to be the same in all datasets by default */ pars_add(pars, "d_oxide", &(fit[0].m.d[1]), 8., 30.); pars_add(pars, "d_chromium", &(fit[0].m.d[2]), 5., 30.); pars_add(pars, "rho_chromium", &(fit[0].m.rho[2]), 3.0e-6, 4.5e-6); pars_add(pars, "rough_cr_au", &(fit[0].m.rough[3]), 5.,30.); pars_add(pars, "d_gold", &(fit[0].m.d[3]), 40., 150.); pars_add(pars, "rho_gold", &(fit[0].m.rho[3]), 4.0e-6, 4.5e-6); pars_add(pars, "d_spacer", &(fit[0].m.d[4]), 10., 30.); pars_add(pars, "rho_spacer", &(rho_spacer), 0e-6, 0.5e-6); pars_add(pars, "vol_fract_spacer", &(vol_fract_spacer), 0., 1.); pars_add(pars, "d_alkyl", &(fit[0].m.d[5]), 10., 17.); pars_add(pars, "rho_alkyl", &(rho_alkyl), -0.5e-6, 0.0e-6); pars_add(pars, "vol_fract_alkyl", &(vol_fract_alkyl), 0., 1.); pars_add(pars, "rho_solv_0", &(fit[0].m.rho[fit[0].m.n-1]), 6.0e-6, 6.35e-6); pars_add(pars, "rho_solv_1", &(fit[1].m.rho[fit[1].m.n-1]), 3.0e-6, 4.5e-6); pars_add(pars, "global_rough", &(global_rough), 8.0, 15.0); pars_add(pars, "model_weight",&(incoh_w[0]), 0., 1.); /* Build a list of 'free parameters' in fit[1].pars. These are * parameters for which the values are aloowed to differ from those * in model 0. By default all values in all models are the same unless * specified here. The range data is not useful, so set it to [0,1]. */ pars_add(freepars, "rho_solv_1", &(fit[1].m.rho[fit[1].m.n-1]), 0., 1.); pars_add(freepars, "rough_cr_au", &(fit[0].m.rough[3]), 0., 1.); constraints = constr_models; return fit; }