コード例 #1
0
ファイル: ui.c プロジェクト: jeremysrand/a2bejwld
static void refreshLevel(tLevel level)
{
    bool waiting = true;
    
    videomode(VIDEOMODE_80x24);
    mixedTextMode();
    speakLevelComplete();
    
    gotoxy(0, 0);
    cprintf(      "               Completed level %u!!", level);
    cputsxy(0, 2, "               Press space to continue to the next level...");
    
    while (waiting) {
        switch (cgetc()) {
            case ' ':
                waiting = false;
                break;
                
            default:
                badThingHappened();
                break;
        }
    }
    
    showAndClearDblLoRes();
    speakGetReady();
}
コード例 #2
0
ファイル: ui.c プロジェクト: jeremysrand/a2bejwld
static void endGame(void)
{
    videomode(VIDEOMODE_80x24);
    mixedTextMode();
    
    speakNoMoreMoves();
    
    cputsxy(0, 0, "               No more moves  -  GAME OVER!!");
    gotoxy(0,1);
    cprintf(      "               You made it to level %u", getLevel());
    cputsxy(0, 3, "                    Play again (Y/N)?");
    
    while (true) {
        switch (cgetc()) {
            case 'y':
            case 'Y':
                return;
                
            case 'n':
            case 'N':
            case CH_ESC:
            case 'q':
            case 'Q':
                quitGame();
                break;
                
            default:
                badThingHappened();
                break;
        }
    }
}
コード例 #3
0
ファイル: contiki-main.c プロジェクト: AWRyder/contiki
/*-----------------------------------------------------------------------------------*/
void
main(void)
{
  struct ethernet_config *ethernet_config;

#if WITH_REBOOT
  rebootafterexit();
#endif /* WITH_REBOOT */

  videomode(VIDEOMODE_80COL);

  process_init();

#if 1
  ethernet_config = config_read("contiki.cfg");
#else
  {
    static struct ethernet_config config = {0xC0B0, "cs8900a.eth"};
    uip_ipaddr_t addr;

    uip_ipaddr(&addr, 192,168,0,128);
    uip_sethostaddr(&addr);

    uip_ipaddr(&addr, 255,255,255,0);
    uip_setnetmask(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_setdraddr(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    resolv_conf(&addr);

    ethernet_config = &config;
  }
#endif

  procinit_init();

  process_start((struct process *)&ethernet_process, (char *)ethernet_config);

  autostart_start(autostart_processes);

  log_message("Contiki up and running ...", "");
  
  while(1) {

    process_run();

    etimer_request_poll();

    clock_update();
  }
}
コード例 #4
0
ファイル: ui.c プロジェクト: jeremysrand/a2bejwld
static void quitGame(void)
{
    unshowDblLoRes();
    videomode(VIDEOMODE_40x24);
    clrscr();
    shutdownMouse();
    soundShutdown();
    
    uninitMachine();
    
    exit(0);
}
コード例 #5
0
ファイル: ui.c プロジェクト: jeremysrand/a2bejwld
void printInstructions(void)
{
    int seed = 0;
    
    unshowDblLoRes();
    videomode(VIDEOMODE_80x24);
    clrscr();
    printf(
          //      0000000001111111111222222222233333333334444444444555555555566666666667
          //      1234567890123456789012345678901234567890123456789012345678901234567890
           "                              Apple // Bejeweled             (" VERSION ")\n"
           "                                by Jeremy Rand\n"
           "\n"
           "     Use I-J-K-M, the arrow keys, joystick or mouse to move your selection.\n"
           "     Hold either apple key, joystick or mouse button and move your selection\n"
           "     to swap two jewels and match 3 or more jewels.  When you match three\n"
           "     jewels, they disappear and new jewels will drop from the top.\n"
           "\n"
           "     If you match four jewels or three jewels in two directions, then the\n"
           "     jewel does not disappear.  Match it again and it explodes taking more\n"
           "     jewels with it.  Match five jewels and a special jewel will appear.\n"
           "     Swap it with any other jewel and all jewels of that colour will\n"
           "     disappear.\n"
           "\n"
           "     When the score bar on the right fills, the board reloads and you level\n"
           "     up.  Play ends when no more matches can be made.\n"
           "\n"
           "                    Press Q or escape to quit at any time.\n"
           "                    Press R to start a new game.\n"
           "                    Press O to select options.\n"
           "                    Press H to get a hint.\n"
           "                    Press ? to see this info again.\n"
           "\n"
           "                           Press any key to start");
    
    // The amount of time the user waits to read the in
    while (!kbhit())
        seed++;
    
    srand(seed);
    
    switch (cgetc()) {
        case 'o':
        case 'O':
            selectOptions();
            break;
            
        default:
            break;
    }
    
    clrscr();
}
コード例 #6
0
ファイル: box.cpp プロジェクト: teritriano/bangameengine
bange::box::box(const char *config, int argc, char *argv[]){
    error = false;
    window = NULL;
    this->escapekey = sf::Keyboard::Escape;
    mouseDelta = 0;
    JoystickConnected = -1;
    JoystickDisconnected = -1;
    mouseEntered = false;
    windowFocus = false;
    vm = luaL_newstate();
    bange::PrepareVM(vm);
    //Create a lua table with arguments
    lua_createtable(vm, argc, 0);
    for (int i = 0; i < argc; i += 1){
        lua_pushstring(vm, argv[i]);
        lua_rawseti(vm, -2, i+1);
    }
    lua_setglobal(vm, "Args");
    //---
    if (luaL_dofile(vm, config)){
        std::cout << "bange(lua): Error reading config file \"" << config << "\": " << lua_tostring(vm, -1) << std::endl;
        error = true;
        return;
    }
    //Get Window dimensions
    sf::VideoMode videomode(640, 480);
    lua_Number wh = 0;
    if (vm::GetNumber(vm, "Width", wh)){
        videomode.Width = wh;}
    if (vm::GetNumber(vm, "Height", wh)){
        videomode.Height = wh;}
    //Get Title
    char title[128] = "BAN Game Engine";
    vm::GetString(vm, "Title", title, 128);
    //Set styles (fullscreen, close, resize, titlebar, none)
    unsigned long windowstyle = sf::Style::Close;
    //Set Window settings
    sf::ContextSettings contextsettings;
    //Create window
    window = new sf::RenderWindow(videomode, title, windowstyle, contextsettings);
    //Set FPS
    lua_Number FPS = 60;
    vm::GetNumber(vm, "FPS", FPS);
    window->SetFramerateLimit( static_cast<unsigned int>(FPS) );
    //Set KeyRepeat
    int keyrepeat = 0;
    vm::GetBoolean(vm, "KeyRepeat", keyrepeat);
    window->EnableKeyRepeat((bool)keyrepeat);
    //Set VerticalSync
    int verticalsync = 0;
    vm::GetBoolean(vm, "VerticalSync", verticalsync);
    window->EnableVerticalSync((bool)verticalsync);
    //Set EscapeKey
    lua_Number escapekey = 0;
    if (vm::GetNumber(vm, "EscapeKey", escapekey)){
        this->escapekey = static_cast<sf::Keyboard::Key>(escapekey);}
    //Store in lua environment this box
    lua_pushlightuserdata(vm, this);
    lua_setfield(vm, LUA_REGISTRYINDEX, "bange::box");
    //Store in lua environment box's window
    lua_pushlightuserdata(vm, this->window);
    lua_setfield(vm, LUA_REGISTRYINDEX, "bange::box::window");
    //Add packages
    if (bange::vm::GetTable(vm, "Packages")){
        lua_pushnil(vm);
        while(lua_next(vm, -2)){
            if (!lua_isstring(vm, -1)){
                lua_pop(vm, 1);
                continue;
            }
            if (PHYSFS_addToSearchPath(lua_tostring(vm, -1), 0) == 0){
                std::cout << "bange(physfs): " << lua_tostring(vm, -1) << ": " << PHYSFS_getLastError() << std::endl;
            }
            //next
            lua_pop(vm, 1);
        }
        lua_pop(vm, 1);
    }
    //Execute the run file
    char runfile[128] = "run.lua";
    vm::GetString(vm, "Run", runfile, 128);
    luaL_openlibs(vm);
    if (luaL_dofile(vm, runfile)){
        std::cout << "bange(lua): Error reading run file \"" << runfile << "\": " << lua_tostring(vm, -1) << std::endl;
        error = true;
        return;
    }
    std::cout << "Texture maximum size: " << sf::Texture::GetMaximumSize() << std::endl;
}
コード例 #7
0
ファイル: contiki-main.c プロジェクト: 21moons/contiki
void
main(int argc, char **argv)
{
  contiki_argc = argc;
  contiki_argv = argv;

#else /* WITH_ARGS */

void
main(void)
{

#endif /* WITH_ARGS */

  videomode(VIDEOMODE_80COL);

  process_init();

#if 1
  ethernet_config = config_read("contiki.cfg");
#else
  {
    static struct ethernet_config config = {0xDE08, "cs8900a.eth"};
    uip_ipaddr_t addr;

    uip_ipaddr(&addr, 192,168,0,128);
    uip_sethostaddr(&addr);

    uip_ipaddr(&addr, 255,255,255,0);
    uip_setnetmask(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_setdraddr(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    resolv_conf(&addr);

    ethernet_config = &config;
  }
#endif

#if (WITH_GUI && WITH_MOUSE)
  {
    static const uint8_t mouse_sprite[64] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x0F, 0xE0, 0x00, 0x0F, 0xC0, 0x00, 0x0F,
      0x80, 0x00, 0x0F, 0xC0, 0x00, 0x0D, 0xE0, 0x00,
      0x08, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x3C,
      0x00, 0x00, 0x1E, 0x00, 0x00, 0x0F, 0x00, 0x00,
      0x07, 0x80, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

    memcpy((void*)0x0E00, mouse_sprite, sizeof(mouse_sprite));
    *(uint8_t*)0x07F8 = 0x0E00 / 64;
    VIC.spr0_color = COLOR_WHITE;
  }
#endif /* WITH_GUI && WITH_MOUSE */

  procinit_init();

  process_start((struct process *)&ethernet_process, (char *)ethernet_config);

  autostart_start(autostart_processes);

  log_message("Contiki up and running ...", "");

  while(1) {

    process_run();

    etimer_request_poll();
  }
}
コード例 #8
0
ファイル: contiki-main.c プロジェクト: soohyunc/contiki-2.x
/*-----------------------------------------------------------------------------------*/
void
main(void)
{
  struct ethernet_config *ethernet_config;

  videomode(VIDEOMODE_80COL);

  close(STDIN_FILENO);
  close(STDOUT_FILENO);
#if !UIP_LOGGING && !LOG_CONF_ENABLED
  close(STDERR_FILENO);
#endif /* !UIP_LOGGING && !LOG_CONF_ENABLED */

  process_init();

#if 1
  ethernet_config = config_read("contiki.cfg");
#else
  {
    static struct ethernet_config config = {0xDE08, "cs8900a.eth"};
    uip_ipaddr_t addr;

    uip_ipaddr(&addr, 192,168,0,128);
    uip_sethostaddr(&addr);

    uip_ipaddr(&addr, 255,255,255,0);
    uip_setnetmask(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_setdraddr(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    resolv_conf(&addr);

    ethernet_config = &config;
  }
#endif

#if (WITH_GUI && WITH_MOUSE)
  {
    static const u8_t mouse_sprite[64] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x0F, 0xE0, 0x00, 0x0F, 0xC0, 0x00, 0x0F,
      0x80, 0x00, 0x0F, 0xC0, 0x00, 0x0D, 0xE0, 0x00,
      0x08, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x3C,
      0x00, 0x00, 0x1E, 0x00, 0x00, 0x0F, 0x00, 0x00,
      0x07, 0x80, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

    memcpy((void*)0x0E00, mouse_sprite, sizeof(mouse_sprite));
    *(u8_t*)0x07F8 = 0x0E00 / 64;
    VIC.spr0_color = COLOR_WHITE;
  }
#endif /* WITH_GUI && WITH_MOUSE */

  procinit_init();

  process_start((struct process *)&ethernet_process, (char *)ethernet_config);

  autostart_start(autostart_processes);

  log_message("Contiki up and running ...", "");
  
  while(1) {

    if(process_run() < 2) {

      etimer_request_poll();
    }
  }
}
コード例 #9
0
ファイル: HILIST.C プロジェクト: cloudify/pixpack
void    main    ( void )
{
	uint    pos,count;

	for( pos=0; pos<_MAX_POINT; pos++ )
	{
		point_list[ pos ].x= 320L << _FP;
		point_list[ pos ].y= 240L << _FP;
		point_list[ pos ].sx= ( rand() - rand() /2  ) * 16L;
		point_list[ pos ].sy= ( rand() - rand() /2  ) * 16L;
		point_list[ pos ].old_offset=0;
		point_list[ pos ].old_mask=255;
	}

	videomode(0x12);

	outpw( 0x3c4, 0x0f02 );

	while( !kbhit() )
	{
		wvbl();
		draw( point_list, _MAX_POINT, 0 );
		move( point_list, _MAX_POINT );
	}

	getch();

	morph_ifs();

	for( pos=0; pos<_MAX_POINT; pos++ )
	{
		point_list[ pos ].sx= ( ( ( long ) ( 65536.0 * ( 320.0 + 220 * sin ( ( double ) pos * 6.28 / _MAX_POINT ) ) ) ) - point_list[ pos ].x ) / ( 70 * 1 );
		point_list[ pos ].sy= ( ( ( long ) ( 65536.0 * ( 240.0 + 220 * cos ( ( double ) pos * 6.28 / _MAX_POINT ) ) ) ) - point_list[ pos ].y ) / ( 70 * 1 );
	}

	chaos();

	wait_count( 70 * 1 );

	for( pos=0; pos<_MAX_POINT; pos++ )
	{
		point_list[ pos ].sx= ( ( ( long ) ( 65536.0 * ( 320.0 + ( 220.0 * pos / _MAX_POINT ) * sin ( ( double ) pos * 6.28 * 8 / _MAX_POINT ) ) ) ) - point_list[ pos ].x ) / ( 70 * 1 );
		point_list[ pos ].sy= ( ( ( long ) ( 65536.0 * ( 240.0 + ( 220.0 * pos / _MAX_POINT ) * cos ( ( double ) pos * 6.28 * 8 / _MAX_POINT ) ) ) ) - point_list[ pos ].y ) / ( 70 * 1 );
	}

	chaos();

	wait_count( 70 * 1 );

	for( pos=0; pos<_MAX_POINT; pos++ )
	{
		point_list[ pos ].sx= ( ( ( long ) ( 65536.0 * ( 320.0 + ( 220.0 * pos / _MAX_POINT ) * cos ( ( double ) pos * 6.28 * 8 / _MAX_POINT ) ) ) ) - point_list[ pos ].x ) / ( 70 * 1 );
		point_list[ pos ].sy= ( ( ( long ) ( 65536.0 * ( 240.0 + ( 220.0 * pos / _MAX_POINT ) * sin ( ( double ) pos * 6.28 * 8 / _MAX_POINT ) ) ) ) - point_list[ pos ].y ) / ( 70 * 1 );
	}

	chaos();

	wait_count( 70 * 1 );

	while( !kbhit() )
	{
		wvbl();
		draw( point_list, _MAX_POINT, 0 );
		move_gravity ( point_list, _MAX_POINT, 65536L );
	}

	getch();

	while( !kbhit() )
	{
		wvbl();
		border( 1 );
		draw( point_list, _MAX_POINT, 0 );
		border( 2 );
		move( point_list, _MAX_POINT );
		border( 0 );
	}

	videomode(3);
}
コード例 #10
0
ファイル: w5100_udp_main.c プロジェクト: a2retro/ip65
void main(void)
{
  char key;

  videomode(VIDEOMODE_80COL);
  printf("Init\n");
  w5100_init(&parms);

  printf("(S)end or e(X)it\n");
  do
  {
    unsigned len;

    if (kbhit())
    {
      key = cgetc();
    }
    else
    {
      key = '\0';
    }

    if (key == 's')
    {
      unsigned i;

      len = 500;
      printf("Send Len %d To %d.%d.%d.%d", len, parms.serverip[0],
                                                parms.serverip[1],
                                                parms.serverip[2],
                                                parms.serverip[3]);
      while (!w5100_send_init(len))
      {
        printf("!");
      }
      for (i = 0; i < len; ++i)
      {
        w5100_send_byte(i);
      }
      w5100_send_done();
      printf(".\n");
    }

    len = w5100_recv_init();
    if (len)
    {
      unsigned i;

      printf("Recv Len %d From %d.%d.%d.%d", len, parms.serverip[0],
                                                  parms.serverip[1],
                                                  parms.serverip[2],
                                                  parms.serverip[3]);
      for (i = 0; i < len; ++i)
      {
        if ((i % 24) == 0)
        {
          printf("\n$%04X:", i);
        }
        printf(" %02X", w5100_recv_byte());
      }
      w5100_recv_done();
      printf(".\n");
    }
  }
  while (key != 'x');

  printf("Done\n");
}
コード例 #11
0
ファイル: ui.c プロジェクト: jeremysrand/a2bejwld
static bool pollKeyboard(void)
{
    bool result = false;
    uint8_t ch;
    
    if (!kbhit())
        return result;
    
    ch = cgetc();
    switch (ch) {
        case 'i':
        case 'I':
        case CH_CURS_UP:
            if (!isAppleButtonPressed()) {
                moveDir(DIR_UP);
                break;
            }
            // Fallthrough...
        case 139:
            result = swapDir(DIR_UP);
            break;
            
        case 'j':
        case 'J':
        case CH_CURS_LEFT:
            if (!isAppleButtonPressed()) {
                moveDir(DIR_LEFT);
                break;
            }
            // Fallthrough...
        case 136:
            result = swapDir(DIR_LEFT);
            break;
            
        case 'k':
        case 'K':
        case CH_CURS_RIGHT:
            if (!isAppleButtonPressed()) {
                moveDir(DIR_RIGHT);
                break;
            }
            // Fallthrough...
        case 149:
            result = swapDir(DIR_RIGHT);
            break;
            
        case 'm':
        case 'M':
        case CH_CURS_DOWN:
            if (!isAppleButtonPressed()) {
                moveDir(DIR_DOWN);
                break;
            }
            // Fallthrough...
        case 138:
            result = swapDir(DIR_DOWN);
            break;
            
        case CH_ESC:
        case 'q':
        case 'Q':
            if (gShouldSave) {
                videomode(VIDEOMODE_80x24);
                mixedTextMode();
                gotoxy(0, 0);
                cprintf("Saving your game so you can continue\r\n    later...");
                saveGame();
            }
            quitGame();
            break;
            
        case 'r':
        case 'R':
            refreshScore(0);
            startNewGame();
            gShouldSave = false;
            return true;
            
        case 'o':
        case 'O':
            selectOptions();
            showAndClearDblLoRes();
            drawBoard();
            break;
            
        case 'h':
        case 'H':
            getHint();
            break;
            
        case '?':
            printInstructions();
            showAndClearDblLoRes();
            drawBoard();
            break;
            
        default:
            badThingHappened();
            break;
    }
    
    return result;
}
コード例 #12
0
ファイル: ui.c プロジェクト: jeremysrand/a2bejwld
static void selectOptions(void)
{
    tGameOptions newOptions;
    
    unshowDblLoRes();
    videomode(VIDEOMODE_80x24);
    clrscr();
    
    memcpy(&newOptions, &gGameOptions, sizeof(newOptions));
    
    while (true) {
        clrscr();
        printf(
               //      0000000001111111111222222222233333333334444444444555555555566666666667
               //      1234567890123456789012345678901234567890123456789012345678901234567890
               "                               Apple // Bejeweled\n"
               "                                    Options\n"
               "\n"
               "                        J - Joystick control - %s\n"
               "                        M - Mouse control    - %s\n"
               "                        S - Sound            - %s\n",
               (newOptions.enableJoystick ? "Enable" : "Disabled"),
               (newOptions.enableMouse ? "Enable" : "Disabled"),
               (newOptions.enableSound ? "Enable" : "Disabled"));
        
        if (newOptions.enableSound) {
            if (newOptions.mockingBoardSlot > 0) {
                printf(
                       //      0000000001111111111222222222233333333334444444444555555555566666666667
                       //      1234567890123456789012345678901234567890123456789012345678901234567890
                       "                                MockingBoard - Slot %u\n"
                       "                                Speech Chip  - %s\n",
                       newOptions.mockingBoardSlot,
                       (newOptions.enableSpeechChip ? "Enable" : "Disable"));
            } else {
                printf(
                       //      0000000001111111111222222222233333333334444444444555555555566666666667
                       //      1234567890123456789012345678901234567890123456789012345678901234567890
                       "                                MockingBoard - Disabled\n");
            }
        }
        printf(
               //      0000000001111111111222222222233333333334444444444555555555566666666667
               //      1234567890123456789012345678901234567890123456789012345678901234567890
               "\n"
               "       Type a letter to change a setting or any other key to save settings\n"
               "       and continue");
        
        switch (cgetc()) {
            case 'j':
            case 'J':
                newOptions.enableJoystick = !newOptions.enableJoystick;
                if (newOptions.enableJoystick) {
                    newOptions.enableMouse = false;
                }
                break;
                
            case 'm':
            case 'M':
                newOptions.enableMouse = !newOptions.enableMouse;
                if (newOptions.enableMouse) {
                    newOptions.enableJoystick = false;
                }
                break;
                
            case 's':
            case 'S':
                getSoundOptions(&newOptions);
                break;
                
            default:
                applyNewOptions(&newOptions);
                clrscr();
                return;
        }
    }
}