void main() { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer (good dog) _disable_interrupt(); cron.seconds = 0; cron.minutes = 0; cron.hours = 0; alarm.seconds = 30; alarm.minutes = 2; alarm.hours = 0; initialize_leds(); initialize_lcd(); initialize_buttons(); initialize_timer_b(); initialize_timer_a1(); _enable_interrupt(); halLcdPrintLine(lcd_line, 0, OVERWRITE_TEXT); write_time_base(); write_cron(); while ( 1 ); }
static void init8(void) { /* Stop watchdog timer */ WDTCTL = WDTPW + WDTHOLD; /* Configure PMM */ SetVCore(3); /* Set global high power request enable */ { PMMCTL0_H = 0xA5; PMMCTL0_L |= PMMHPMRE; PMMCTL0_H = 0x00; } /* Enable 32kHz ACLK */ initialize_aclk(); /* Configure CPU clock for 12MHz */ initialize_cpu_12mhz(); /* Configure buttons for input */ initialize_buttons(); /* Initialize LCD */ initialize_lcd(); /* Write 'boot' to the screen without using display functions */ LCDM2 = 199; /* 'b' */ LCDM3 = 198; /* 'o' */ LCDM4 = 198; /* 'o' */ LCDM6 = 135; /* 't' */ /* configure watchdog interrupt timer, used for polling buttons */ { /* ACLK timer source, 250ms timer mode, resume watchdog */ WDTCTL = WDT_ADLY_250; /* Enable watchdog timer interrupts */ SFRIE1 |= WDTIE; } /* Enable global interrupts */ __enable_interrupt(); /* loop if no button is pressed, enter RFBSL if backlight is pressed */ do { _BIS_SR(LPM3_bits | GIE); if ((P2IN & ALL_BUTTONS) == BTN_BL_PIN) jump_to_rfbsl(); } while ((P2IN & ALL_BUTTONS) == 0); /* Disable them again, they will be re-enabled later on in main() */ __disable_interrupt(); }
GtkWidget* CreateHelpWindow (void) { GtkWidget *main_vbox; GtkWidget *main_view_scroller; GtkWidget *contents_view_scroller; GtkWidget *content_hpane; int width; int height; int x, y; int w = 0, h = 0; const char *pref; char title[100]; wHelpWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); width = gdk_screen_get_width( gtk_window_get_screen( (GtkWindow *)wHelpWindow )); height = gdk_screen_get_height( gtk_window_get_screen( (GtkWindow *)wHelpWindow )); pref = wPrefGetString( HTMLHELPSECTION, WINDOWSIZEPREFNAME ); if( pref ) { sscanf( pref, "%d %d", &w, &h ); if( w > width ) w = width; if( h > height ) h = height; } else { w = ( width * 2 )/ 5; h = height - 100; } pref = wPrefGetString( HTMLHELPSECTION, WINDOWPOSPREFNAME ); if( pref ) { sscanf( pref, "%d %d", &x, &y ); if( y > height - h ) y = height - h; if( x > width - w ) x = width - w; } else { x = ( width * 3 ) / 5 - 10; y = 70; } gtk_window_resize( (GtkWindow *)wHelpWindow, w, h ); gtk_window_move( (GtkWindow *)wHelpWindow, x, y ); gtk_window_set_title (GTK_WINDOW (wHelpWindow), "XTrkCad Help"); g_signal_connect( G_OBJECT( wHelpWindow ), "delete-event", G_CALLBACK( DestroyHelpWindow ), NULL ); main_view_scroller = gtk_scrolled_window_new(NULL, NULL); contents_view_scroller = gtk_scrolled_window_new(NULL, NULL); main_view = webkit_web_view_new(); contents_view = webkit_web_view_new(); // must be done here as it gets locked down later load_into_view ("contents.html", CONTENTS_VIEW); gtk_widget_set_size_request(GTK_WIDGET(wHelpWindow), x, y); main_vbox = gtk_vbox_new(FALSE, 5); gtk_container_add(GTK_CONTAINER(wHelpWindow), main_vbox); gtk_container_add(GTK_CONTAINER(main_view_scroller), main_view); gtk_container_add(GTK_CONTAINER(contents_view_scroller), contents_view); content_hpane = gtk_hpaned_new(); initialize_buttons(main_vbox, content_hpane); gtk_container_add(GTK_CONTAINER(content_hpane), contents_view_scroller); gtk_container_add(GTK_CONTAINER(content_hpane), main_view_scroller); gtk_box_pack_start(GTK_BOX(main_vbox), content_hpane, TRUE, TRUE, 0); gtk_paned_set_position(GTK_PANED(content_hpane), 370); g_signal_connect(contents_view, "navigation-policy-decision-requested", G_CALLBACK(contents_click_handler), G_OBJECT(main_view)); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (wHelpWindow, wHelpWindow, "wHelpWindow"); GLADE_HOOKUP_OBJECT (wHelpWindow, content_hpane, PANED ); GLADE_HOOKUP_OBJECT (wHelpWindow, contents_view, TOCVIEW ); GLADE_HOOKUP_OBJECT (wHelpWindow, main_view, CONTENTSVIEW ); return wHelpWindow; }
int main(int argc, char **argv) { unsigned short grafboard; extern int disk_error_handler(int errval, int ax, int bp, int si); char *p; allocatebuffers(); if (init_mem_err) { cprintf("\r\n\r\nSorry, not enough memory to run Toy Universes.\r\n"); return -1; } harderr(disk_error_handler); /* Find out if we have a VGA or EGA at all. */ grafboard = QueryGrafix(); if ((grafboard & 0x200) != 0x200) { printf("This programs requires EGA capability.\n"); exit(-1); } if (grafboard == 0xffff || InitGrafix(-EGA640x350) < 0) { printf("Metagraphics not installed. Execute the command:\n"); printf("metashel /i\n"); printf("and then try again.\n"); exit(-1); } vgaflag = -1; while (argc > 1) { if (argv[1][0] == '-') { switch (argv[1][1]) { case 'e': vgaflag = 0; break; case 'v': vgaflag = 1; break; } } argc--; argv++; } if (vgaflag == -1) { if ((grafboard & 0x300) == 0x300) vgaflag = 1; else vgaflag = 0; } Comm = QueryComm(); if (Comm == MsDriver) InitMouse(MsDriver); else if (Comm == MsCOM1) InitMouse(MsCOM1); else if (Comm == MsCOM2) InitMouse(MsCOM2); else if (Comm & 3) InitMouse(COM1); /* * Probably wrong. Need to check for MS mouse address in some special * way. */ randomize(); p = searchpath("system16.fnt"); if (p) LoadFont(p); installmode(); load_preset_palettes(); usepalette(); current_main_item = 0; usepalette(); TWICE(initialize_buttons()); ShowCursor(); if (allocatefailflag) ErrorBox("Not enough memory for hi-res."); /* Lets see if there is enough for a later gif */ if (!memok(20712L)) /* Added up mallocs in comprs.c */ ErrorBox("There may not be enough memory to save or view a Gif."); prog_init = 1; if (!setjmp(beatit)) { while (!exitflag) { rebuildflag = 0; if (newcaflag && !donescreenflag) { loadlookuptable(increment, maxstate); newcaflag = 0; } if (newcaoflag) { unsigned char *p1,*p2; static int firsttime = true; switch(caotype) { case CA_HODGE: p1 = (char *)HODGE_colortable; p2 = HODGE_ct; break; case CA_EAT: p1 = (char *)EAT_colortable; p2 = EAT_ct; break; case CA_TUBE: p1 = (char *)TUBE_colortable; p2 = TUBE_ct; break; case CA_NLUKY: p1 = (char *)NLUKY_colortable; p2 = NLUKY_ct; break; } memcpy(vgacolortable,p1,16*3); if (!hasVGA) memcpy(egacolortable,p2,16); if (!firsttime) { TWICE(initialize_numbers()); } else firsttime = false; usepalette(); newcaoflag = 0; current_main_item = -1; } if (blankflag) { blankbuffers(); blankflag = 0; } if (randomizeflag) { carandomize(); randomizeflag = 0; } while (!exitflag && !rebuildflag) { if (onestep || !stopped) { if (display_mode == HI) hiresupdate(); else loresupdate(); if (onestep) onestep--; } if (spinflag && (!stopped || (iteration++ > spinspeed))) { if (spinflag == 1) spinpalette(); else revspinpalette(); iteration = 0; } checkkeyboard(); if (newcaflag) rebuildflag = 1; } } } StopMouse(); StopEvent(); grayflag = 0; grayscale(); SetDisplay(TextPg0); return exitflag; }