void S5L8900X_framebuffer_init(void) { char tempbuf[16]; /* * Technically, iBoot should initialize this.. Haven't bothered * to reverse this part properly, if you're using a 16-bit panel, then use * the 'rgb565' boot-argument if you care about a working framebuffer... */ PE_state.video.v_depth = 4 * (8); // 32bpp if (PE_parse_boot_argn("rgb565", tempbuf, sizeof(tempbuf))) { PE_state.video.v_depth = 2 * (8); // 16bpp } kprintf(KPRINTF_PREFIX "framebuffer initialized\n"); /* * Enable early framebuffer. */ //if (PE_parse_boot_argn("-early-fb-debug", tempbuf, sizeof(tempbuf))) { initialize_screen((void *) &PE_state.video, kPEAcquireScreen); //} if (PE_parse_boot_argn("-graphics-mode", tempbuf, sizeof(tempbuf))) { initialize_screen((void *) &PE_state.video, kPEGraphicsMode); } else { initialize_screen((void *) &PE_state.video, kPETextMode); } return; }
void RealView_framebuffer_init(void) { gRealviewPl111Base = ml_io_map(REALVIEW_PL111_BASE, PAGE_SIZE); /* * The hardware demands a framebuffer, but the framebuffer has to be given * in a hardware address. */ void *framebuffer = pmap_steal_memory(1024 * 768 * 4); void *framebuffer_phys = pmap_extract(kernel_pmap, framebuffer); uint32_t depth = 2; uint32_t width = 1024; uint32_t height = 768; uint32_t pitch = (width * depth); uint32_t fb_length = (pitch * width); uint32_t timingRegister, controlRegister; /* * Set framebuffer address */ HARDWARE_REGISTER(gRealviewPl111Base + PL111_UPPER_FB) = framebuffer_phys; HARDWARE_REGISTER(gRealviewPl111Base + PL111_LOWER_FB) = framebuffer_phys; /* * Initialize timings to 1024x768x16 */ HARDWARE_REGISTER(gRealviewPl111Base + PL111_TIMINGS_0) = LCDTIMING0_PPL(width); HARDWARE_REGISTER(gRealviewPl111Base + PL111_TIMINGS_1) = LCDTIMING1_LPP(height); /* * Enable the TFT/LCD Display */ HARDWARE_REGISTER(gRealviewPl111Base + PL111_CONTROL) = LCDCONTROL_LCDEN | LCDCONTROL_LCDTFT | LCDCONTROL_LCDPWR | LCDCONTROL_LCDBPP(5); PE_state.video.v_baseAddr = (unsigned long) framebuffer_phys; PE_state.video.v_rowBytes = width * 4; PE_state.video.v_width = width; PE_state.video.v_height = height; PE_state.video.v_depth = 4 * (8); // 16bpp kprintf(KPRINTF_PREFIX "framebuffer initialized\n"); bzero(framebuffer, (pitch * height)); char tempbuf[16]; if (PE_parse_boot_argn("-graphics-mode", tempbuf, sizeof(tempbuf))) { /* * BootX like framebuffer. */ memset(framebuffer, 0xb9, PE_state.video.v_rowBytes * PE_state.video.v_height); initialize_screen((void *) &PE_state.video, kPEGraphicsMode); } else { initialize_screen((void *) &PE_state.video, kPETextMode); } }
void main() { initialize_screen(); menu(); }
void RealView_framebuffer_init(void) { gRealviewPl111Base = ml_io_map(REALVIEW_PL111_BASE, PAGE_SIZE); /* * The hardware demands a framebuffer, but the framebuffer has to be given * in a hardware address. */ void* framebuffer = pmap_steal_memory(1024 * 768 * 4); void* framebuffer_phys = pmap_get_phys(kernel_pmap, framebuffer); uint32_t depth = 2; uint32_t width = 1024; uint32_t height = 768; uint32_t pitch = (width * depth); uint32_t fb_length = (pitch * width); uint32_t timingRegister, controlRegister; /* Set framebuffer address */ HARDWARE_REGISTER(gRealviewPl111Base + PL111_UPPER_FB) = framebuffer_phys; HARDWARE_REGISTER(gRealviewPl111Base + PL111_LOWER_FB) = framebuffer_phys; /* Initialize timings to 1024x768x16 */ HARDWARE_REGISTER(gRealviewPl111Base + PL111_TIMINGS_0) = LCDTIMING0_PPL(width); HARDWARE_REGISTER(gRealviewPl111Base + PL111_TIMINGS_1) = LCDTIMING1_LPP(height); /* Enable the TFT/LCD Display */ HARDWARE_REGISTER(gRealviewPl111Base + PL111_CONTROL) = LCDCONTROL_LCDEN | LCDCONTROL_LCDTFT | LCDCONTROL_LCDPWR | LCDCONTROL_LCDBPP(4); PE_state.video.v_baseAddr = (unsigned long)framebuffer_phys; PE_state.video.v_rowBytes = width * 2; PE_state.video.v_width = width; PE_state.video.v_height = height; PE_state.video.v_depth = 2 * (8); // 16bpp kprintf(KPRINTF_PREFIX "framebuffer initialized\n"); bzero(framebuffer, (pitch * height)); initialize_screen((void*)&PE_state.video, kPEAcquireScreen); initialize_screen((void*)&PE_state.video, kPEEnableScreen); }
// The initialization method for this module void Init_CMouse() { CMouse = rb_define_module("CMouse"); rb_define_singleton_method(CMouse, "get_mouse_x", method_get_mouse_x, 0); rb_define_singleton_method(CMouse, "get_mouse_y", method_get_mouse_y, 0); rb_define_singleton_method(CMouse, "set_mouse_rel", method_set_mouse_rel, 2); rb_define_singleton_method(CMouse, "set_mouse_abs", method_set_mouse_abs, 2); rb_define_singleton_method(CMouse, "left_click", method_left_click, 0); initialize_screen(); }
int PE_initialize_console( PE_Video * info, int op ) { static int last_console = -1; if (info) { info->v_offset = 0; info->v_length = 0; info->v_display = GRAPHICS_MODE; } switch ( op ) { case kPEDisableScreen: initialize_screen(info, op); kprintf("kPEDisableScreen %d\n", last_console); if (!console_is_serial()) last_console = switch_to_serial_console(); break; case kPEEnableScreen: initialize_screen(info, op); if (info) PE_state.video = *info; kprintf("kPEEnableScreen %d\n", last_console); if( last_console != -1) switch_to_old_console( last_console); break; case kPEBaseAddressChange: if (info) PE_state.video = *info; /* fall thru */ default: initialize_screen(info, op); break; } return 0; }
void st::_app::sdl_poll::run() { SDL_Surface* image = NULL; // Could, should this be a member? Should I just have a // standard loop that I can start up. I'll refactor this // soonish. bool quit = false; initialize_screen( "Event Test" ); image = load_image( "x.png" ); apply_surface(0, 0, image); flip(); // Will need to rework event loop somehow... start(); free_surface( image ); }
void st::_app::lesson10::run() { initialize_screen(); m_background = load_image("keystates-background.png"); m_font = load_font("lazy.ttf", 28); apply_surface(0,0,m_background); m_upmessage = TTF_RenderText_Solid( font(), "Up", textcolor() ); m_downmessage = TTF_RenderText_Solid( font(), "Down", textcolor() ); m_leftmessage = TTF_RenderText_Solid( font(), "Left", textcolor() ); m_rightmessage = TTF_RenderText_Solid( font(), "Right",textcolor() ); flip(); start(); }
int main(void) { SysTick_Init(); startSSI0(); initialize_screen(BACKLIGHT_ON); while(1) { clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_LEFT_TOP); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_CENTRE_TOP); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_RIGHT_TOP); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_LEFT_CENTRE); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_CENTRE_CENTRE); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_RIGHT_CENTRE); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_LEFT_BOTTOM); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_CENTRE_BOTTOM); SysTick_Wait50ms(200); clear_screen(); screen_write("Hi!\nHow are you?",ALIGN_RIGHT_BOTTOM); SysTick_Wait50ms(200); int i=0; for(i=0;i<5;i++) { clear_screen(); screen_write("Welcome",ALIGN_RANDOM); SysTick_Wait50ms(200); } } return 0; }
void setup() { Serial.begin(9600); Serial.println("Starting..."); delay(500); Serial.flush(); // There can be nasty leftover bits. initialize_screen(); initialize_sd_card(); initialize_joystick(); initialize_map(); // Want to start viewing window in the center of the map move_window( (map_box[current_map_num].W + map_box[current_map_num].E) / 2, (map_box[current_map_num].N + map_box[current_map_num].S) / 2); // with cursor in the middle of the window move_cursor_to( screen_map_x + display_window_width / 2, screen_map_y + display_window_height / 2); // Draw the initial screen and cursor first_time = 1; // Now initialize and enable the zoom buttons. pinMode(zoom_out_pin, INPUT); // Zoom out. digitalWrite(zoom_out_pin, HIGH); pinMode(zoom_in_pin, INPUT); // Zoom in. digitalWrite(zoom_in_pin, HIGH); // Initialize interrupt routines attached to zoom buttons. attachInterrupt(zoom_in_interrupt, handle_zoom_in, FALLING); attachInterrupt(zoom_out_interrupt, handle_zoom_out, FALLING); #ifdef DEBUG_MEMORY Serial.print("Available mem:"); Serial.println(AVAIL_MEM); #endif }
void st::_app::lesson4::run() { SDL_Surface* image = NULL; // Could, should this be a member? Should I just have a // standard loop that I can start up. I'll refactor this // soonish. SDL_Event event; bool quit = false; initialize_screen( "Event Test" ); image = load_image( "x.png" ); apply_surface(0, 0, image); flip(); // Will need to rework event loop somehow... while ( quit == false ) { while ( SDL_PollEvent(&event) ) { if ( event.type == SDL_QUIT ) { quit = true; } } } free_surface( image ); }
int spinupJS( char *fname ) { open_story( fname ); configure( V1, V8 ); #else int main( int argc, char *argv[] ) { process_arguments( argc, argv ); configure( V1, V8 ); initialize_screen( ); #endif load_cache( ); z_restart( ); #ifdef EMSCRIPTEN interpreter_status = 1; return 0; }
/* -------- code */ void do_preferences( void) { struct screen_mode_data mode= graphics_preferences->screen_mode; GDSpec old_spec= graphics_preferences->device_spec; handle_preferences(); if (!EqualGDSpec(&graphics_preferences->device_spec, &old_spec) || mode.bit_depth != graphics_preferences->screen_mode.bit_depth || mode.acceleration != graphics_preferences->screen_mode.acceleration) { paint_window_black(); initialize_screen(&graphics_preferences->screen_mode); /* Re fade in, so that we get the proper colortable loaded.. */ display_main_menu(); } else if (memcmp(&mode, &graphics_preferences->screen_mode, sizeof(struct screen_mode_data))) { change_screen_mode(&graphics_preferences->screen_mode, FALSE); } return; }
int tricam_process(int argc, char *argv[]) { int i, j, w, h, bpp; bytemap_t *up_image, *mid_image, *dn_image; bytemap_t *gray, *se; bitmap_t *up_roi, *mid_roi, *dn_roi; bitmap_t *bin, *roi, *tmp; char *fn, *ptr; real_t value; FILE *fd; label_info_t *label_info; dwordmap_t *labelmap; point_t *centroid; int label, area; uint8_t vmin, vmax; real_t vmean; bytemap_t *op1, *op2, *op3; char *path; int next_option; char *token1, *token2, *token3; real_t cutup = -2550000, cutdown = -4748; program_name = argv[0]; do { next_option = getopt_long(argc, argv, short_options, long_options, NULL); switch (next_option) { case 'h': print_usage(stdout, 0); break; case 'o': token1 = strdup(optarg); break; case 's': token2 = strdup(optarg); break; case 'd': token3 = strdup(optarg); break; case 'f': cutup = strtod(optarg, NULL); break; case 't': cutdown = strtod(optarg, NULL); break; case 'v': verbose = 1; break; case 'n': path = strdup(optarg); break; case '?': print_usage(stderr, 1); break; case -1: break; default: abort(); } } while (next_option != -1); // printf("(%s - %s) / %s, %lf, %lf, %s\n", token1, token2, token3, cutup, cutdown, path); w = WIDTH; h = HEIGHT; bpp = BPP; initialize_screen(w, h, bpp); up_image = bytemap_new(w, h); mid_image = bytemap_new(w, h); dn_image = bytemap_new(w, h); gray = bytemap_new(w, h); up_roi = bitmap_new(w, h); mid_roi = bitmap_new(w, h); dn_roi = bitmap_new(w, h); bin = bitmap_new(w, h); tmp = bitmap_new(w, h); roi = bitmap_new(w, h); se = bytemap_new(3, 3); bytemap_fill(se, 0, 0, 3, 3, 1); labelmap = dwordmap_new(w, h); path = (char *)malloc(256 * sizeof(char)); // Up display image //////////////////// strcpy(path, argv[1]); strcat(path, "_up.bmp"); fn = strrchr(path, '/') + 1; printf("Filename: %s\n", fn); printf("Display image\n"); load_and_display_BMP(path); read_bytemap_in_screen(up_image, NULL, NULL); bytemap_clear(gray); bytemap_copy(gray, UP_DX, UP_DY, up_image, 0, 0, w, h); write_bytemap_to_screen(gray, gray, gray); wait_keyhit(); printf("Mean filtering \n"); mean_smooth(up_image, gray, 3); write_bytemap_to_screen(up_image, up_image, up_image); wait_keyhit(); //////////////////////////////////////// // MID display image /////////////////// strcpy(path, argv[1]); strcat(path, "_mid.bmp"); fn = strrchr(path, '/') + 1; printf("Filename: %s\n", fn); printf("Display image\n"); load_and_display_BMP(path); read_bytemap_in_screen(mid_image, NULL, NULL); bytemap_clear(gray); bytemap_copy(gray, MID_DX, MID_DY, mid_image, 0, 0, w, h); write_bytemap_to_screen(gray, gray, gray); wait_keyhit(); printf("Mean filtering \n"); mean_smooth(mid_image, gray, 3); write_bytemap_to_screen(mid_image, mid_image, mid_image); wait_keyhit(); ///////////////////////////////////////// // DN display image ///////////////////// strcpy(path, argv[1]); strcat(path, "_dn.bmp"); fn = strrchr(path, '/') + 1; printf("filename: %s\n", fn); printf("Display image\n"); load_and_display_BMP(path); read_bytemap_in_screen(dn_image, NULL, NULL); bytemap_clear(gray); bytemap_copy(gray, DN_DX, DN_DY, dn_image, 0, 0, w, h); write_bytemap_to_screen(gray, gray, gray); wait_keyhit(); printf("Mean filtering \n"); mean_smooth(dn_image, gray, 3); write_bytemap_to_screen(dn_image, dn_image, dn_image); wait_keyhit(); /////////////////////////////////////// printf("Up Image thresholding\n"); bytemap_threshold(bin, up_image, UP_FROM, UP_TO); write_bitmap_to_screen(bin, bin, bin); wait_keyhit(); printf("Big blobs greping\n"); bitmap_clear(roi); label_info = label_info_new(); labeling(labelmap, label_info, bin, NEIGHBOR_8); for (label = 0; label < label_info_get_count(label_info); label++) { label_info_glimpse(&area, label, label_info); //printf("area:%d\n", area); if (area > 3000) { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (dwordmap_get_value(labelmap, j, i) == label) { bitmap_set_value(roi, j, i); } } } } } label_info_destroy(label_info); write_bitmap_to_screen(roi, roi, roi); wait_keyhit(); printf("Fill holes\n"); bitmap_complement(bin, roi); labeling_grep_big_blob(roi, bin); bitmap_complement(bin, roi); write_bitmap_to_screen(bin, bin, bin); wait_keyhit(); printf("Image Morphology\n"); binary_closing(tmp, bin, se); binary_opening(up_roi, tmp, se); write_bitmap_to_screen(up_roi, up_roi, up_roi); wait_keyhit(); /////////////////////////////////////// printf("Mid Image thresholding\n"); bytemap_threshold(bin, mid_image, MID_FROM, MID_TO); write_bitmap_to_screen(bin, bin, bin); wait_keyhit(); printf("Big blobs greping\n"); bitmap_clear(roi); label_info = label_info_new(); labeling(labelmap, label_info, bin, NEIGHBOR_8); for (label = 0; label < label_info_get_count(label_info); label++) { label_info_glimpse(&area, label, label_info); //printf("area:%d\n", area); if (area > 3000) { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (dwordmap_get_value(labelmap, j, i) == label) { bitmap_set_value(roi, j, i); } } } } } label_info_destroy(label_info); write_bitmap_to_screen(roi, roi, roi); wait_keyhit(); printf("Fill holes\n"); bitmap_complement(bin, roi); labeling_grep_big_blob(roi, bin); bitmap_complement(bin, roi); write_bitmap_to_screen(bin, bin, bin); wait_keyhit(); printf("Image Morphology\n"); binary_closing(tmp, bin, se); binary_opening(mid_roi, tmp, se); write_bitmap_to_screen(mid_roi, mid_roi, mid_roi); wait_keyhit(); /////////////////////////////////////////////////// printf("Dn Image thresholding\n"); bytemap_threshold(bin, dn_image, DN_FROM, DN_TO); write_bitmap_to_screen(bin, bin, bin); wait_keyhit(); printf("Big blobs greping\n"); bitmap_clear(roi); label_info = label_info_new(); labeling(labelmap, label_info, bin, NEIGHBOR_8); for (label = 0; label < label_info_get_count(label_info); label++) { label_info_glimpse(&area, label, label_info); //printf("area:%d\n", area); if (area > 3000) { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (dwordmap_get_value(labelmap, j, i) == label) { bitmap_set_value(roi, j, i); } } } } } label_info_destroy(label_info); write_bitmap_to_screen(roi, roi, roi); wait_keyhit(); printf("Fill holes\n"); bitmap_complement(bin, roi); labeling_grep_big_blob(roi, bin); bitmap_complement(bin, roi); write_bitmap_to_screen(bin, bin, bin); wait_keyhit(); printf("Image Morphology\n"); binary_closing(tmp, bin, se); binary_opening(dn_roi, tmp, se); write_bitmap_to_screen(dn_roi, dn_roi, dn_roi); wait_keyhit(); /////////////////////////////////////////////// bitmap_clear(roi); bitmap_or(roi, up_roi); bitmap_or(roi, mid_roi); bitmap_or(roi, dn_roi); write_bitmap_to_screen(up_roi, mid_roi, dn_roi); wait_keyhit(); write_bitmap_to_screen(roi, roi, roi); wait_keyhit(); /* //write_bitmap_to_screen(up_roi, mid_roi, dn_roi); //read_bytemap_in_screen(up_image, mid_image, dn_image); strcpy(path, argv[1]); strcat(path, "_up_roi.bmp"); save_bytemap_as_BMP(up_image, path); strcpy(path, argv[1]); strcat(path, "_mid_roi.bmp"); save_bytemap_as_BMP(mid_image, path); strcpy(path, argv[1]); strcat(path, "_dn_roi.bmp"); save_bytemap_as_BMP(dn_image, path); read_bytemap_in_screen(gray, NULL, NULL); strcpy(path, argv[1]); strcat(path, "_roi.bmp"); save_bytemap_as_BMP(gray, path); */ #if 0 // up image statistic ///////////////////////// bytemap_get_min_max_on_roi(&vmin, &vmax, up_image, roi); bytemap_get_mean_on_roi(&vmean, up_image, roi); printf("Up image statistics are min: %d, mean: %lf, max: %d\n", vmin, vmean, vmax); fd = fopen("up_stat.txt", "a+"); fprintf(fd, "%d, %lf, %d\n", vmin, vmean, vmax); fclose(fd); //////////////////////////////////////////////// // mid image statistic ///////////////////////// bytemap_get_min_max_on_roi(&vmin, &vmax, mid_image, roi); bytemap_get_mean_on_roi(&vmean, mid_image, roi); printf("Mid image statistics are min: %d, mean: %lf, max: %d\n", vmin, vmean, vmax); fd = fopen("mid_stat.txt", "a+"); fprintf(fd, "%d, %lf, %d\n", vmin, vmean, vmax); fclose(fd); ///////////////////////////////////////////////// // dn image statistic /////////////////////////// bytemap_get_min_max_on_roi(&vmin, &vmax, dn_image, roi); bytemap_get_mean_on_roi(&vmean, dn_image, roi); printf("Dn image statistics are min: %d, mean: %lf, max: %d\n", vmin, vmean, vmax); fd = fopen("dn_stat.txt", "a+"); fprintf(fd, "%d, %lf, %d\n", vmin, vmean, vmax); fclose(fd); ///////////////////////////////////////////////// return 0; #endif #if 1 // Up image normalization printf("Up-Image global normalization\n"); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (bitmap_isset(roi, j, i)) { value = bytemap_get_value(up_image, j, i); if (value < UP_MEAN) { value = round(128.0 / (UP_MEAN - UP_MIN) * (value - UP_MIN)); } else { value = round(128.0 / (UP_MAX - UP_MEAN) * (value - UP_MEAN) + 128.0); } if (value < 0) value = 0; if (value > 255) value = 255; bytemap_put_value(value, up_image, j, i); } else { bytemap_put_value(0, up_image, j, i); } } } write_bytemap_to_screen(up_image, up_image, up_image); strcpy(path, argv[1]); strcat(path, "_up_normal.bmp"); save_bytemap_as_gray_BMP(up_image, path); wait_keyhit(); ////////////////////////////////////////// // Mid image normalization printf("MID-Image global normalization\n"); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (bitmap_isset(roi, j, i)) { value = bytemap_get_value(mid_image, j, i); if (value < MID_MEAN) { value = round(128.0 / (MID_MEAN - MID_MIN) * (value - MID_MIN)); } else { value = round(128.0 / (MID_MAX - MID_MEAN) * (value - MID_MEAN) + 128.0); } if (value < 0) value = 0; if (value > 255) value = 255; bytemap_put_value(value, mid_image, j, i); } else { bytemap_put_value(0, mid_image, j, i); } } } write_bytemap_to_screen(mid_image, mid_image, mid_image); strcpy(path, argv[1]); strcat(path, "_mid_normal.bmp"); save_bytemap_as_gray_BMP(mid_image, path); wait_keyhit(); /////////////////////////////////////////////// // Dn image normalization printf("Dn image global normalization\n"); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (bitmap_isset(roi, j, i)) { value = bytemap_get_value(dn_image, j, i); if (value < DN_MEAN) { value = round(128.0 / (DN_MEAN - DN_MIN) * (value - DN_MIN)); } else { value = round(128.0 / (DN_MAX - DN_MEAN) * (value - DN_MEAN) + 128.0); } if (value < 0) value = 0; if (value > 255) value = 255; bytemap_put_value(value, dn_image, j, i); } else { bytemap_put_value(0, dn_image, j, i); } } } write_bytemap_to_screen(dn_image, dn_image, dn_image); strcpy(path, argv[1]); strcat(path, "_dn_normal.bmp"); save_bytemap_as_gray_BMP(dn_image, path); wait_keyhit(); //////////////////////////////////////////// return 0; #endif #if 0 printf("Image subtraction between DN and MID for bruise-detection\n"); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (bitmap_isset(roi, j, i)) { value = ((real_t)bytemap_get_value(dn_image, j, i) - (real_t)bytemap_get_value(mid_image, j, i) + 255.0) / 2.0; if (value < 0) value = 0; if (value > 255) value = 255; bytemap_put_value(value, gray, j, i); } else { bytemap_put_value(0, gray, j, i); } } } write_bytemap_to_screen(gray, gray, gray); wait_keyhit(); bytemap_threshold(bin, gray, 142, 255); write_bitmap_to_screen(bin, bin, bin); wait_keyhit(); printf("Image subtraction between UP and MID for spot-detection\n"); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (bitmap_isset(roi, j, i)) { value = ((real_t)bytemap_get_value(up_image, j, i) - (real_t)bytemap_get_value(mid_imageb, j, i) + 255.0) / 2.0; if (value < 0) value = 0; if (value > 255) value = 255; bytemap_put_value(value, gray, j, i); } else { bytemap_put_value(0, gray, j, i); } } } write_bytemap_to_screen(gray, gray, gray); wait_keyhit(); bytemap_threshold(bin, gray, 1, 110); write_bitmap_to_screen(bin, bin, bin); wait_keyhit(); #endif dwordmap_destroy(labelmap); bytemap_destroy(se); return 0; bitmap_destroy(roi); bitmap_destroy(tmp); bitmap_destroy(bin); bitmap_destroy(dn_roi); bitmap_destroy(mid_roi); bitmap_destroy(up_roi); bytemap_destroy(gray); bytemap_destroy(dn_image); bytemap_destroy(mid_image); bytemap_destroy(up_image); return 0; }
//***************************************************************************** // // Play the Colossal Cave Adventure game using either an Ethernet telnet // connection or a USB CDC serial connection. // //***************************************************************************** int main(void) { // // Set the clocking to run from the PLL at 80 MHz. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Enable the UART. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioInit(0); // // Print out a greeting. // UARTprintf("\033[2JColossal Cave Adventure\n"); UARTprintf("-----------------------\n"); UARTprintf("Connect to either the USB virtual COM port or\n"); UARTprintf("telnet into the Ethernet port in order to play.\n\n"); // // Enable the GPIO that is used for the on-board push button. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_4); ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // // Enable the GPIO that is used for the on-board LED. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0); ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, 0); // // Configure SysTick for a periodic interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKHZ); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Enable processor interrupts. // ROM_IntMasterEnable(); // // Initialize the Ethernet and USB interfaces. // EnetIFInit(); USBIFInit(); // // Provide a working area to the memory allocator. // bpool(g_pucPool, sizeof(g_pucPool)); // // Configure the Z-machine interpreter. // configure(V1, V5); // // Initialize the Z-machine screen interface. // initialize_screen(); // // Pre-fill the Z-machine interpreter's cache. // load_cache(); // // Loop forever. // while(1) { // // Wait until a connection has been made via either the Ethernet or USB // interfaces. // while(g_ulGameIF == GAME_IF_NONE) { } // // Turn on the LED to indicate that the game is in progress. // ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_PIN_0); // // Loop until the game has been exited. Repeat this loop if the game // exited because the restart button was pressed. // do { // // Take the Z-machine interpreter out of the halt state. // halt = 0; // // Set the restart flag to zero. // g_ulRestart = 0; // // Restart the Z-machine interpreter. // restart(); // // Run the Z-machine interpreter until it halts. // interpret(); } while(g_ulRestart); // // Turn off the LED to indicate that the game has finished. // ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, 0); // // Close down the Ethernet connection if it was being used to play the // game. // if(g_ulGameIF == GAME_IF_ENET) { EnetIFClose(); } // // Forget the interface used to play the game so that the selection // process will be repeated. // g_ulGameIF = GAME_IF_NONE; } }