static void roms_init( HWND hwndDlg, LPARAM lParam ) { size_t i; struct callback_info *info; info = ( struct callback_info * ) lParam; for( i = 0; i < info->n; i++ ) add_rom( hwndDlg, info->start, i ); /* Move the OK and Cancel buttons */ RECT rect; rect.left = 25; rect.top = ( info->n * 30 ) + 5; rect.right = 25 + 50; rect.bottom = ( info->n * 30 ) + 5 + 14; MapDialogRect( hwndDlg, &rect ); MoveWindow( GetDlgItem( hwndDlg, IDOK ), rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, FALSE ); rect.left = 85; rect.top = ( info->n * 30 ) + 5; rect.right = 85 + 50; rect.bottom = ( info->n * 30 ) + 5 + 14; MapDialogRect( hwndDlg, &rect ); MoveWindow( GetDlgItem( hwndDlg, IDCANCEL ), rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, FALSE ); /* resize the dialog as needed */ RECT window_rect, client_rect; GetWindowRect( hwndDlg, &window_rect ); GetClientRect( hwndDlg, &client_rect ); rect.left = 0; rect.top = 0; rect.right = 163; rect.bottom = ( info->n * 30 ) + 24; MapDialogRect( hwndDlg, &rect ); /* rect now contains the size of the client area in pixels, now add window's absolute position on the screen */ rect.left += window_rect.left; rect.top += window_rect.top; /* now just add the difference between client area and window area */ rect.right += ( window_rect.right - window_rect.left ) - ( client_rect.right - client_rect.left ); rect.bottom += ( window_rect.bottom - window_rect.top ) - ( client_rect.bottom - client_rect.top ); /* MoveWindow doesn't really take rect, instead it's X, Y, sizeX and sizeY */ MoveWindow( hwndDlg, rect.left, rect.top, rect.right, rect.bottom, FALSE ); }
int main(int argc, char **argv) { int i; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-rom")) { if (++i == argc) usage(); if (++i == argc) usage(); FILE *rom = fopen(argv[i], "r"); if (!rom) { fprintf(stderr, "Could not open ROM file: '%s'\n", argv[i]); return 1; } add_rom(argv[i-1], rom); fclose(rom); } else if (!strcmp(argv[i], "-n")) { if (++i == argc) usage(); steps = atoi(argv[i]); } else if (!strcmp(argv[i], "-in")) { if (++i == argc) usage(); infile = argv[i]; } else if (!strcmp(argv[i], "-out")) { if (++i == argc) usage(); outfile = argv[i]; } else { filename = argv[i]; } } if (filename == NULL) usage(); // Load program FILE *p_in; p_in = fopen(filename, "r"); if (!p_in) { fprintf(stderr, "Error: could not open file %s for input.\n", filename); return 1; } t_program* program = load_dumb_netlist(p_in); fclose(p_in); // Setup input and outputs FILE *input = stdin, *output = stdout; if (infile != NULL) { input = fopen(infile, "r"); if (!infile) { fprintf(stderr, "Error: could not open file %s for input.\n", infile); return 1; } } if (outfile != NULL) { output = fopen(outfile, "w"); if (!output) { fprintf(stderr, "Error: could not open file %s for output.\n", outfile); return 1; } } // Run t_machine *machine = init_machine(program); machine_banner(machine, output); i = 0; while (i < steps || steps == 0) { read_inputs(machine, input); machine_step(machine); write_outputs(machine, output); i++; } // Cleanup if (input != stdin) fclose(input); if (output != stdout) fclose(output); // No need to free memory, the OS deletes everything anyways when the process ends. return 0; }
void pci_device::add_rom_from_region() { add_rom(m_region->base(), m_region->bytes()); }