Example #1
0
int main(void)
{
    vga_init();

    /* Create virtual screen. */
    vbuf = malloc(VWIDTH * VHEIGHT);
    gl_setcontextvirtual(VWIDTH, VHEIGHT, 1, 8, vbuf);

    /* Set Mode X-style 320x240x256. */
    vga_setmode(G320x240x256);
    gl_setrgbpalette();
    vga_clear();

    boxes();

    demo1();

    demo2();

    vga_setmode(G320x200x256);	/* Set linear 320x200x256. */
    gl_setrgbpalette();

    demo3();

    vga_setmode(TEXT);
    exit(0);
}
Example #2
0
File: demo.c Project: foo/ii
Surface* demo(void)
{
  /* return demo2(); */
  /* return demo3(); */
  /* return demo1(); */
  return demo1();
}
Example #3
0
void RTC_Basic(void)
{
    SystemInit();
	UART_Configuration(UART);
    __disable_irq();
    /* enable RTC interrupt */
    NVIC_ClearPendingIRQ(INTRTC_IRQn);
    TSB_CG->IMCGF = CG_IMCGC_RTC_EDGE;
    TSB_CG->IMCGF = CG_IMCGC_RTC_INTEN;
    NVIC_EnableIRQ(INTRTC_IRQn);

    Date_Struct.LeapYear = RTC_LEAP_YEAR_2;
    Date_Struct.Year = (uint8_t) 10;
    Date_Struct.Month = (uint8_t) 12;
    Date_Struct.Date = (uint8_t) 31;
    Date_Struct.Day = RTC_FRI;

    Time_Struct.HourMode = RTC_12_HOUR_MODE;
    Time_Struct.Hour = (uint8_t) 11;
    Time_Struct.AmPm = RTC_PM_MODE;
    Time_Struct.Min = (uint8_t) 59;
    Time_Struct.Sec = (uint8_t) 50;

    RTC_DisableClock();
    RTC_DisableAlarm();

    /* Reset RTC sec counter */
    RTC_ResetClockSec();
    /* Set RTC Time value */
    RTC_SetTimeValue(&Time_Struct);
    /* Set RTC Date value */
    RTC_SetDateValue(&Date_Struct);

    /* Enable 1Hz interrupt */
    RTC_SetAlarmOutput(RTC_PULSE_1_HZ);
    /* Enable RTCINT */
    RTC_SetRTCINT(ENABLE);
    __enable_irq();

    /* waiting for RTC register set finish */
    while (fRTCSetting_ok != 1U) {
        /* Do nothing */
    }
    fRTCSetting_ok = 0U;

    /* Enable RTC Clock function */
    RTC_EnableClock();

    while (1) {
        if (fRTCSetting_ok == 1U) {
            fRTCSetting_ok = 0U;
            demo0();
            demo1();
        } else {
            /* Do nothing */
        }
    }
}
Example #4
0
int main()
{
  /*
   * Call ppgbeg to initiate PGPLOT and open the output device; cpgbeg
   * will prompt the user to supply the device name and type.
   */
  if(cpgbeg(0, "?", 1, 1) != 1)
    exit(EXIT_FAILURE);
  cpgask(1);
  /*
   * Call each demo.
   */
  demo1();
  demo2();
  demo3();
  /*
   * Finally, call cpgend to terminate things properly.
   */
  cpgend();
  return EXIT_SUCCESS;
}
Example #5
0
int main(void) {

  int i;

  DWT_Init();

  KDC_5060R_init();

  ADC_SoftwareStartConvCmd(ADC1, ENABLE);

  DWT_Delay(1000000);
  demo1(0,TRUE,FALSE);
  KDC_5060R_text_all(TRUE,TRUE);
  DWT_Delay(5000000);
  demo1(0,FALSE,FALSE);
  KDC_5060R_text_all(FALSE,TRUE);
  DWT_Delay(1000000);
  demo1(0,TRUE,FALSE);
  KDC_5060R_text_all(TRUE,TRUE);
  DWT_Delay(1000000);
  demo1(0,FALSE,FALSE);
  KDC_5060R_text_all(FALSE,TRUE);
  DWT_Delay(1000000);
  demo1(0,TRUE,FALSE);
  KDC_5060R_text_all(TRUE,TRUE);
  DWT_Delay(1000000);
  demo1(0,FALSE,FALSE);
  KDC_5060R_text_all(FALSE,TRUE);
  DWT_Delay(1000000);

  for(i=0;i<10;i++) {
    KDC_5060R_digit(i,TRUE);
    DWT_Delay(200000);
  }
  KDC_5060R_digit_off(TRUE);

  KDC_5060R_text("HI WORLD",0,TRUE,TRUE);
  DWT_Delay(1000000);

  demo1(100000,TRUE,TRUE);
  DWT_Delay(1000000);
  demo1(100000,FALSE,TRUE);

  DWT_Delay(500000);
  demo1(0,TRUE,FALSE);
  KDC_5060R_send();

  DWT_Delay(500000);
  demo1(0,FALSE,FALSE);
  KDC_5060R_send();
  DWT_Delay(500000);
  demo1(0,TRUE,FALSE);
  KDC_5060R_send();
  DWT_Delay(500000);
  demo1(0,FALSE,FALSE);
  KDC_5060R_send();
  DWT_Delay(500000);
  demo1(0,TRUE,FALSE);
  KDC_5060R_send();
  DWT_Delay(500000);
  demo1(0,FALSE,FALSE);
  KDC_5060R_send();
  DWT_Delay(500000);
  demo1(0,TRUE,FALSE);
  KDC_5060R_send();
  DWT_Delay(500000);
  KDC_5060R_clear_text(TRUE);
  DWT_Delay(500000);

  KDC_5060R_text("HI WORLD",0,TRUE,TRUE);
  DWT_Delay(500000);
  KDC_5060R_clear_text(TRUE);
  DWT_Delay(500000);
  KDC_5060R_text("HI WORLD",0,TRUE,TRUE);
  DWT_Delay(500000);
  KDC_5060R_clear_text(TRUE);
  DWT_Delay(500000);
  KDC_5060R_text("HI WORLD",0,TRUE,TRUE);
  DWT_Delay(500000);

  KDC_5060R_symbol(SYMBOL_DOUBLE_COLON_1,FALSE,FALSE);
  KDC_5060R_symbol(SYMBOL_DOUBLE_COLON_2,FALSE,FALSE);
  KDC_5060R_symbol(SYMBOL_MINUS,FALSE,TRUE);

  KDC_5060R_text("kbiva.wordpress.com",0,TRUE,TRUE);
  DWT_Delay(2000000);

  for(i=0;i>=-11;i--) {
    KDC_5060R_text("kbiva.wordpress.com",i,TRUE,TRUE);
    DWT_Delay(200000);
  }
  DWT_Delay(1000000);
  for(i=-11;i<=0;i++) {
    KDC_5060R_text("kbiva.wordpress.com",i,TRUE,TRUE);
    DWT_Delay(200000);
  }
  DWT_Delay(2000000);

  demo1(0,FALSE,FALSE);
  KDC_5060R_clear_text(TRUE);

  while(1){

    KDC_5060R_receive();

    if(key_data[0]&KEY_3) {KDC_5060R_text("red",0,TRUE,TRUE);KDC_5060R_leds_red();}
    if(key_data[0]&KEY_2) KDC_5060R_text("Button 2",0,TRUE,TRUE);

    if(key_data[1]&KEY_1) KDC_5060R_text("Button 1",0,TRUE,TRUE);
    if(key_data[1]&KEY_4) {KDC_5060R_text("green",0,TRUE,TRUE);KDC_5060R_leds_green();}
    if(key_data[1]&KEY_VOL_UP) KDC_5060R_text("Vol Up",0,TRUE,TRUE);
    if(key_data[1]&KEY_VOL_DOWN) KDC_5060R_text("Vol Down",0,TRUE,TRUE);
    if(key_data[1]&KEY_ATT) KDC_5060R_text("Att",0,TRUE,TRUE);
    if(key_data[1]&KEY_5) {KDC_5060R_text("yellow",0,TRUE,TRUE);KDC_5060R_leds_yellow();}
    if(key_data[1]&KEY_6) {KDC_5060R_text("leds off",0,TRUE,TRUE);KDC_5060R_leds_off();}

    if(key_data[2]&KEY_PLAY) KDC_5060R_text("Play",0,TRUE,TRUE);
    if(key_data[2]&KEY_SRC) KDC_5060R_text("SRC",0,TRUE,TRUE);
    if(key_data[2]&KEY_SEEK_RIGHT) KDC_5060R_text("Seek >>",0,TRUE,TRUE);
    if(key_data[2]&KEY_DISP) KDC_5060R_text("DISP",0,TRUE,TRUE);
    if(key_data[2]&KEY_SEEK_LEFT) KDC_5060R_text("Seek <<",0,TRUE,TRUE);
    if(key_data[2]&KEY_FM) KDC_5060R_text("FM",0,TRUE,TRUE);
    if(key_data[2]&KEY_AM) KDC_5060R_text("AM",0,TRUE,TRUE);

    if(key_data[3]&KEY_TI) KDC_5060R_text("TI",0,TRUE,TRUE);
    if(key_data[3]&KEY_AUDIO) KDC_5060R_text("AUDIO",0,TRUE,TRUE);

    if(ADCConvertedValue[0]<2000) KDC_5060R_text("RESET",0,TRUE,TRUE);

    DWT_Delay(100000);
    KDC_5060R_clear_text(TRUE);
  }
}
Example #6
0
void docommand(char ch)
{
int count;
char dateb[7];
switch (ch)
       	{
	 case ARROWR : if (status.stockprice != 3 + 1) exit(0);goright(); break;
         case ARROWL : if (status.stockprice != 5 - 1) exit(0);goleft(); break;
	 case ARROWU : if (status.stockprice != 2 + 2) exit(0);goup(); break;
	 case ARROWD : if (status.stockprice != 3 + 1) exit(0);godown(); break;
	 case HOME :  leavecell(sys.cell);
		     if ((sys.screen == SCREEN1 || sys.screen == SCREEN3)
			  && page == PAGEDOWN)
		     {
		     sys.cell.row = 23;
		     sys.cell.col = MONTH;
		     }
		     else
                     if (sys.screen == SCREEN2)
		     {
		     sys.cell.row = 8;
		     sys.cell.col = SHARESPER;
		     }
		     else
		     {
		     sys.cell.row = 8;
		     sys.cell.col = MONTH;
		     }
		     entercell(sys.cell);
		     break;
	 case END :  leavecell(sys.cell);
		     if ((sys.screen == SCREEN1 || sys.screen == SCREEN3)
			  && page == PAGEDOWN)
		     {
		     sys.cell.row = 37;
		     sys.cell.col = MONTH;
		     }
		     else
                     if (sys.screen == SCREEN2)
		     {
		     sys.cell.row = 22;
		     sys.cell.col = SHARESPER;
		     }
		     else
		     {
		     sys.cell.row = 22;
		     sys.cell.col = MONTH;
		     }
		     entercell(sys.cell);
		     break;

	 case PGUP	: if ((sys.screen == SCREEN1 || sys.screen == SCREEN3)
			      && page == PAGEDOWN)
			{
			page = PAGEUP;
			if (sys.cell.row >= 8)
			sys.cell.row -= 15;
			disppage();
			}
			showall();
			entercell(sys.cell);
			break;
	 case PGDN	: if ((sys.screen == SCREEN1 || sys.screen == SCREEN3)
				&& page == PAGEUP)
			{
			page = PAGEDOWN;
			if (sys.cell.row >= 8)
			sys.cell.row += 15;
                        disppage();
			}
			showall();
			entercell(sys.cell);
			break;
         case F01 :	help();break;
         case F02 :     demo();
			break;
	 case F03 :     demo();
			break;
         case F04 : sortstatus(); genscreen(); entercell(sys.cell); break;
         case F05 :
		{
		    if (drawgraph(choice(6,graphchoice)) < 0)
		    errormessage("Graphics initialisation error");
		    genscreen();
		    showtotals();
		    entercell(sys.cell);
		 }
		    break;
         case F06 :
         	    leavecell(sys.cell);
		 switch (choice(3,screenchoice))
		 {
 		 case 1 :
		      if (tosavesys) savesys();
		      sys.screen = SCREEN1;
		      page = PAGEUP;
		      sys.cell.col = MONTH;
      		      sys.cell.row = 8;
		      sys.display = HELDS;
		      genscreen();
		      break;
		 case 2 :
		      sys.screen = SCREEN2;
		      sys.display = HELDS;
		      page = PAGEUP;
      		      sys.cell.row = 8;
		      sys.cell.col = EXPIRYDAY;
		      genscreen();
		      break;
		 case 3 :
		      if (tosavesys) savesys();
		      sys.cell.col = MONTH;
		      page = PAGEUP;
		      sys.screen = SCREEN3;
		      sys.display = INVVOL;
      		      sys.cell.row = 8;
		      wait();
		      if (recalcvolvalues)
		      calcallvol();
		      ready();
		      genscreen();
		      break;
		 }
		 showtotals();
		 entercell(sys.cell);
		 break;
            case F07 :
		   switch(choice(3,clearchoice))
		   {
		  case 1 :  if (sys.cell.row < 8 || sys.screen == SCREEN2) break;
			    wait();
			    clearrow();
				 calcall();
				 showall();
				 totals();
                              entercell(sys.cell);
			      break;
		   case 2 : wait();
			    switch( sys.cell.col)
			    {
                            case VOLC :
                            	case VALUEC :
				case VOLP :
				case DELTAC :
				case VALUEP :
                            	case DELTAP:
                            	case SHAREPRICE :break;
				case STOCKHELD : status.stockheld = 0; break;
				case VOLATILITY : status.volatility = 0.0;break;
				case INTEREST   : status.interest = 0.0; break;
				case  DATE      :
				case YEARMONTH :
				case SHARESPER : for (count =0;count <24; count++)
						   status.sizepay[count].sharesper = 1000;
						   break;               
				case EXPIRYDAY :
				case DAYSLEFT :
                            case MONTH : break;
                            case STRIKE : for (count = 0;count < 30; count++)
                                          {
					  status.data[count].strike = 0.0;
					  status.data[count].volc = 0.0;
					  status.data[count].volp = 0.0;
					  }
					  break;
				case MARKETC : for (count = 0;count < 30; count++)
                                        {
					status.data[count].marketc = 0.0;
					status.data[count].volc = 0.0;
					}
					  break;
				case HELDC :  for (count = 0;count < 30; count++)
					  status.data[count].heldc = 0;
					  break;
				case MARKETP : for (count = 0;count < 30; count++)
                                          {
					  status.data[count].marketp = 0.0;
					  status.data[count].volp = 0.0;
					  }
					  break;
				case HELDP :  for (count = 0;count < 30; count++)
					  status.data[count].heldp = 0;
					  break;
				case DIVIDENDDAY : for (count = 0;count < 24; count++)
					  status.sizepay[count].dday = 0;
					  break;
			        case DIVIDENDCENTS :  for (count = 0;count < 24; count++)
					  status.sizepay[count].payout = 0;
					  break;

			    }  wait();
				 calcall();
				 showall();
				 totals();  break;
			  case 3:   clearall();wait();   wait();
				 calcall();
				 showall();
				 totals();break;
			  /* clear all set shares per con */


		    }           showtotals();
				 ready();
				 entercell(sys.cell);
				 /* inverse vol now invalid */
		    break;


         case F08 :
			leavecell(sys.cell);
		   switch( choice(7, utilchoice))
		      {
			case 1 : getdir(); break;
			case 2 : bonusissue();
				 wait();
				 calcall();
				 showall();
				 totals();
				 showtotals();
				 ready();
				 break;
			case 3 : cashissue();
				 wait();
				 calcall();
				 showall();
				 totals();
				 showtotals();
				 ready();
				 break;
			 case 4: switch( choice(3,resolutionchoice))
				 {
				   case 1: numpts = 10; break;
				   case 2: numpts = 15; break;
				   case 3: numpts = 30; break;
				 }
                                    break;
			 case 5:switch (choice(3,printchoice))
				  {
				     case 1: printdetails(); break;
				     case 2: demo1();break;
				     case 3: demo1(); break;
					   } break;
			 case 6: filedelete(); break;
			 case 7 : reinstall();
		         }
			 entercell(sys.cell);
			 break;

         case F09 : switch (sys.screen)
			{
			case SCREEN1 :
			    leavecell(sys.cell);
			    if (sys.display == HELDS) sys.display = DELTAS;
			    else sys.display = HELDS;
		    	if (sys.cell.row >= 8)
		   	 sys.cell.col = MONTH;
		    	textcolor(sys.graphics.colors.heading);
		    	textbackground(sys.graphics.colors.databack);
		    	drawheadings();
		    	showall();
			showtotals();
		    	entercell(sys.cell);break;
			case SCREEN2 : break;
			case SCREEN3 :
			    leavecell(sys.cell);
			    if (sys.display == INVVOL) sys.display = OVERVALUED;
			    else sys.display = INVVOL;
 		    	    textcolor(sys.graphics.colors.heading);
		    	    textbackground(sys.graphics.colors.databack);
		    	    drawheadings();
		    	    showall();
			    showtotals();
		    	    entercell(sys.cell);break;
		       }
		    break;
         case F10 : switch (choice(3,quitchoice))
		    {
		    case 0 : break;
		    case 1 : wait();
	   		    textcolor(LIGHTGRAY);
			    textbackground(BLACK);
			    savesys();
			    clrscr();
			    gotoxy(2,2);
			    cprintf(" The Option Analyst is a product of");
			    gotoxy(2,3);
			    cprintf(" EFAM RESOURCES Pty. Ltd.\n");
			    retcursor();
			    exit(0);
			    break;
                    case 2 : demo();
			    break;
		    case 3 : break;
		    }
		    break;
	}
}
Example #7
0
void IO::consoleLoop(Board* board, SEARCHINFO* info) {
    printf("Welcome to TidesTicTactics in Console Mode!\n");
    info->POST_THINKING = true;
    setbuf(stdin, NULL);
    setbuf(stdin, NULL);
    int depth = 81;
    int movetime = 500; // 3 sec
    Coordinate move;
    char inBuf[80], command[80], modifier[80];
    Color engineSide = COLOR_NONE;
    Engine engine;
    Movelist movecheck;
    bool init = false;
    bool initX = true;
    Movelist movelist;

    while (true) {
        fflush(stdout);
        if ((board->toMove == engineSide || engineSide == COLOR_BOTH) && board->winner == COLOR_NONE) {
            info->starttime = GetTimeMs();
            info->depth = depth;
            if (movetime != 0) {
                info->timeset = true;
                info->stoptime = info->starttime + movetime;
            }
            engine.searchPosition(board, info, true);
            engineSide = COLOR_NONE;
        }
        // print prompt
        printf("");
        fflush(stdout);
        memset(&inBuf[0], 0, sizeof(inBuf));
        fflush(stdout);
        if(!fgets(inBuf, 80, stdin))
            continue;
        std::transform(inBuf, inBuf + 80 - 1, inBuf, [](unsigned char c) { return std::tolower(c); });
        sscanf(inBuf, "%s", command);

        if(!strcmp(command, "help")) {
            printf("\nCommands:\n");
            printf("quit - quit game\n");
            printf("force - will not move\n");
            printf("print - show board\n");
            printf("post - show thinking\n");
            printf("nopost - do not show thinking\n");
            printf("new - start new game\n");
            printf("go - set computer thinking\n");
            printf("depth x - set depth to x\n");
            printf("time x - set thinking time to x seconds (depth still applies if set)\n");
            printf("view - show current depth and movetime settings\n");
            printf("moves - show valid moves\n");
            printf("captures - show moves winning a board");
            printf("test x - load first x moves of demo");
            printf("test2 x - load first x moves of demo");
            printf("** note ** - to reset time and depth, set to 0\n");
            printf("enter moves using B1..9F1..9 notation\n\n\n");
            continue;
        }

        if(!strcmp(command, "moves")) {
            board->getMoves(&movecheck);
            if (movecheck.count == 0) {
                printf("No moves found");
            }
            for(int i = 0; i < movecheck.count; i++) {
                printf("%s ", PRMOVE(movecheck.moves[i].move).c_str());
            }
            printf("\n");
            continue;
        }

        if(!strcmp(command, "player")) {
            sscanf(inBuf, "player %s init", modifier);
            if(!strcmp(modifier, "one")) {
                init = true;
                initX = true;
            } else if(!strcmp(modifier, "two")) {
                init = true;
                initX = false;
            } else {
                printf("unknown player: %s\n", modifier);
            }
            continue;
        }

        if(!strcmp(command, "start")) {
            sscanf(inBuf, "start %s", modifier);
            if(!strcmp(modifier, "turns")) {
                init = false;
                board->toMove = COLOR_X;
                board->next = SQUARE_NONE;
            } else if(!strcmp(modifier, "game")) {
                init = true;
            } else {
                printf("unknown start modifier: %s\n", modifier);
            }
            continue;
        }

        if(!strcmp(command, "captures")) {
            board->getCaptureMoves(&movecheck);
            if (movecheck.count == 0) {
                printf("no captures found");
            }
            for(int i = 0; i < movecheck.count; i++) {
                printf("%s ", PRMOVE(movecheck.moves[i].move).c_str());
            }
            printf("\n");
            continue;
        }

        if(!strcmp(command, "eval")) {
            printf(board->printBoard().c_str());
            printf("\neval:%d",board->getScore());
            continue;
        }
        if(!strcmp(command, "quit")) {
            info->quit = true;
            break;
        }

        if(!strcmp(command, "post")) {
            info->POST_THINKING = true;
            continue;
        }

        if(!strcmp(command, "print")) {
            printf(board->printBoard().c_str());
            continue;
        }

        if(!strcmp(command, "nopost")) {
            info->POST_THINKING = false;
            continue;
        }

        if(!strcmp(command, "force")) {
            engineSide = COLOR_NONE;
            continue;
        }

        if(!strcmp(command, "demo")) {
            Color temp = COLOR_NONE;
            while (temp != board->toMove && board->winner == COLOR_NONE) {
                temp = board->toMove;
                info->starttime = GetTimeMs();
                info->depth = std::min(depth, MAXMOVES - board->movecount);
                if (movetime != 0) {
                    info->timeset = true;
                    info->stoptime = info->starttime + movetime;
                }
                engine.searchPosition(board, info, true);
                printf(board->printBoard().c_str());
                // printf("\nNONE\n");
                // printf(board->printBoard(COLOR_NONE).c_str());

            }
            continue;
        }

        if(!strcmp(command, "view")) {
            if(depth == 81) printf("depth not set ");
            else printf("depth %d",depth);

            if(movetime != 0) printf(" movetime %ds\n",movetime/1000);
            else printf(" movetime not set\n");

            continue;
        }

        if(!strcmp(command, "depth")) {
            sscanf(inBuf, "depth %d", &depth);
            if(depth==0) depth = 81;
            continue;
        }

        if(!strcmp(command, "test")) {
            engineSide = COLOR_NONE;
            while (board->movecount > 0)
                board->undo();
            int target;
            sscanf(inBuf, "test %d", &target);
            demo1(board, target);
            continue;
        }

        if(!strcmp(command, "test2")) {
            engineSide = COLOR_NONE;
            while (board->movecount > 0)
                board->undo();
            int target;
            sscanf(inBuf, "test2 %d", &target);
            demo2(board, target);
            continue;
        }

        if(!strcmp(command, "time")) {
            sscanf(inBuf, "time %d", &movetime);
            movetime *= 1000;
            continue;
        }

        if(!strcmp(command, "new")) {
            engineSide = COLOR_O;
            while (board->movecount > 0)
                board->undo();
            continue;
        }

        if(!strcmp(command, "go")) {
            engineSide = board->toMove;
            info->stopped = false;
            continue;
        }

        move = parseMove(inBuf);
        if(move == NOMOVE) {
            printf("command unknown:%s\n",inBuf);
            continue;
        }
        if(init) {
            if(initX) {
                board->toMove = COLOR_X;
                board->setupmove(move);
            } else {
                board->toMove = COLOR_O;
                board->setupmove(move);
            }
        } else {
            board->getMoves(&movelist);
            bool found = false;
            for (int i = 0; i < movelist.count; i++) {
                if (move == movelist.moves[i].move) {
                    found = true;
                    break;
                }
            }
            if (found)
                board->move(move);
            else {
                printf("INVALID MOVE: %s\n", PRMOVE(move).c_str());
                printf("%s", board->printBoard().c_str());
                break;
            }
        }
    }
    printf("Engine shutting down...\n");
}