getmenu () { if (! menu[0].len) initmenu (); getboxes (); VMPutString (LINES-1, 0, "\0011\16 \17 2\16 \17 3\16 \17 4\16 \17 5\16 \17 6\16 \17 7\16 \17 8\16 \17 9\16 \01710\16Quit \17\2"); for (;;) { drawhead (nmenu); for (;;) { drawmenu (&menu[nmenu]); hidecursor (); VSync (); switch (KeyGet ()) { default: VBeep (); continue; case cntrl (']'): /* redraw screen */ VRedraw (); continue; case cntrl ('M'): clrmenu (&menu[nmenu]); return (1); case cntrl ('J'): clrmenu (&menu[nmenu]); return (2); case cntrl ('C'): case cntrl ('['): case meta ('J'): /* f0 */ clrmenu (&menu[nmenu]); return (0); case meta ('r'): /* right */ clrmenu (&menu[nmenu]); if (! menu[++nmenu].mname) nmenu = 0; break; case meta ('l'): /* left */ clrmenu (&menu[nmenu]); if (--nmenu < 0) { for (nmenu=0; menu[nmenu].mname; ++nmenu); --nmenu; } break; case meta ('u'): /* up */ upmenu (&menu[nmenu]); continue; case meta ('d'): /* down */ downmenu (&menu[nmenu]); continue; } break; } } }
int loadmenu(void){ menu = 1; loadtexture("all","loading.jpg", 1,0,10); loadtexture("all","font.png", 4,0,0); loadtexture("all","fontoutline.png", 4,0,12); loadtexture("all","menu.jpg", 4,0,1); initmenu(); return 1; }
void initmouse(void) { char *s, *term; if ((term = getenv("TERM")) == NULL) { return; } if (strcmp(term, "emacsterm") == 0 || strcmp(term, "viterm") == 0) { mouse = EMACSTERM; } else if ((s = getenv("MOUSE")) != NULL && strcmp(s, "myx") == 0) { /* * the MOUSE enviroment variable is for 5620 terminal * programs that have mouse support but the TERM environment * variable is the same as a terminal without a mouse, such * as myx */ mouse = MYX; } if ((s = getenv("MOUSEMENU")) != NULL && strcmp(s, "none") == 0) { changemenu = NO; } initmenu(); }
int loadmenu(void){ menu = 1; loadtexture("all","loading.jpg", 1,0,10); loadtexture("all","font.png", 4,0,0); loadtexture("all","fontoutline.png", 4,0,12); if(!sayan) { loadtexture("all","menu.jpg", 4,0,1); initmenu(); }else if(sayan==1) { loadtexture("all","lose.jpg",4,0,1); initmenu1(); } else if(sayan==2) { loadtexture("all","win.jpg",4,0,1); initmenu2(); } return 1; }
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ int c; int oldf = 0; char *p; for (c = 0; c < 128; c++) keylookup[c] = c; processcommandline(); hinstance = hThisInstance; /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon(hThisInstance, "allegro_icon"); wincl.hIconSm = LoadIcon(hThisInstance, "allegro_icon"); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0; /* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ VERSION_STR, /* Title Text */ WS_OVERLAPPEDWINDOW/*&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX*/, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 640 + (GetSystemMetrics(SM_CXFIXEDFRAME) * 2), /* The programs width */ 480 + (GetSystemMetrics(SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 1, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ LoadMenu(hThisInstance, TEXT("MainMenu")), /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); ghwnd = hwnd; win_set_window(hwnd); allegro_init(); get_executable_name(exedir, 511); p = get_filename(exedir); p[0] = 0; config_load(); InitializeCriticalSection(&cs); /* Make the window visible on the screen */ ShowWindow (hwnd, nFunsterStil); initmenu(); mainthread = (HANDLE)_beginthread(_mainthread, 0, NULL); updatewindowtitle(); /* Run the message loop. It will run until GetMessage() returns 0 */ while (!quited) { // runbbc(); if (PeekMessage(&messages, NULL, 0, 0, PM_REMOVE)) { if (messages.message == WM_QUIT) { quited=1; } TranslateMessage(&messages); DispatchMessage(&messages); } else Sleep(10); if ((key[KEY_LCONTROL] || key[KEY_RCONTROL]) && key[KEY_END] && mousecapture) { ClipCursor(&oldclip); mousecapture = 0; updatewindowtitle(); } if (key[KEY_ALT] && key[KEY_ENTER] && fullscreen && !oldf) { EnterCriticalSection(&cs); fullscreen = 0; video_leavefullscreen(); LeaveCriticalSection(&cs); } else if (key[KEY_ALT] && key[KEY_ENTER] && !fullscreen && !oldf) { EnterCriticalSection(&cs); fullscreen = 1; video_enterfullscreen(); LeaveCriticalSection(&cs); } oldf = key[KEY_ALT] && key[KEY_ENTER]; } EnterCriticalSection(&cs); TerminateThread(mainthread, 0); main_close(); DeleteCriticalSection(&cs); return messages.wParam; }
/*--------------------------------------------------------- Function: menu Description: Build and manage menu. mode : Menu mode (MAINMENU or SHOPMENU). p : Build menu for PLAYER p. (Especially important for SHOPMENU) ---------------------------------------------------------*/ int menu(int mode, int p) { int dx, dy, db; // Accumulated cursor coordinates. int mb; int joy_x, joy_y, joy_fire; // Joystick values. int x, y, b; // Mouse coordinates. int request; static int key_allowed; Uint32 startTime = 0; // Initialize menu system. nowplayer = p; initmenu(); nowmenu = 0; // No menu active at the moment. strcpy(shopmenu[0].text, p ? "PLAYER 2" : "PLAYER 1"); switch (mode) { case MAINMENU: buildmenu(mainmenu); break; case SOUNDMENU: buildmenu(soundmenu); break; case SHOPMENU: buildmenu(shopmenu); break; } // Initialize some variables. joy_x = joy_y = joy_fire = 0; // Initialize "checkmenu". checkmenu(-1, 0, 0); x = MENUX + MENUXS/2; y = MENUY + MENUYS/2; do { startTime = SDL_GetTicks(); demo(); // Restore mouse pointer background. dx = dy = mb = b = 0; input_update(); if (joypad) { getjoypad(joy_x, joy_y, joy_fire); x += joy_x*4; y += joy_y*4; b += joy_fire; } getkeyboard(dx, dy, db); x += dx*4; y += dy*4; b += db; if (mouse && !(dx || dy)) { getmouse(dx, dy, mb); if((dx || dy)) getmousexy(mb, x, y); b += mb; } testlimits(x, y); //if (mouse) setmousexy(x, y); back->restore(); // Process events. if (!keys) key_allowed = 1; if (!keys_enabled) key_released = 0; // Send KEY PRESSED message to menu. if (!keys && key_released && key_released!=KEY_ESC) { if (nowmenu[0].action) nowmenu[0].action(M_KEY, key_released); key_released = 0; } // Send joypad messages. if (joy_enabled && button_released != -1) { if (nowmenu[0].action) nowmenu[0].action(M_JOYPAD, button_released); } // Send mouse messages. if (pointer_enabled) { if (request = checkmenu(b, x, y)) break; } // Build backoff menu if ESC has been pressed. if (key_allowed && key[KEY_ESC] && backoff) { buildmenu(backoff); key_allowed = 0; escape_wait(); } back->save(x, y); // Copy demo display to restricted area of screen render.drawTexture(&demoTexture, BORDER, 0, 16, 0, 4*32 + 16, YMAX); // Restore title logo. render.x_drawsprite(&sHead, 100, 12, 0); if (pointer_enabled) render.x_drawsprite(&sPointer, x, y, 0); render.update(); while(SDL_GetTicks() - startTime < 32) { SDL_Delay(1); } } while (!quit_requested); destroymenu(); // Shut down menu system. shutmenu(); return quit_requested ? M_QUIT : request; }
BOOL changestring(void) { char buf[PATLEN + 1]; /* input buffer */ char newfile[PATHLEN + 1]; /* new file name */ char oldfile[PATHLEN + 1]; /* old file name */ char linenum[NUMLEN + 1]; /* file line number */ char msg[MSGLEN + 1]; /* message */ FILE *script; /* shell script file */ BOOL anymarked = NO; /* any line marked */ MOUSEEVENT *p; /* mouse data */ int c, i; char *s; /* open the temporary file */ if ((script = fopen(temp2, "w")) == NULL) { cannotopen(temp2); return (NO); } /* create the line change indicators */ change = (BOOL *)mycalloc((unsigned)totallines, sizeof (BOOL)); changing = YES; initmenu(); /* until the quit command is entered */ for (;;) { /* display the current page of lines */ display(); same: /* get a character from the terminal */ (void) move(PRLINE, 0); (void) addstr( "Select lines to change (press the ? key for help): "); if ((c = mygetch()) == EOF || c == ctrl('D') || c == ctrl('Z')) { break; /* change lines */ } /* see if the input character is a command */ switch (c) { case ' ': /* display next page */ case '+': case ctrl('V'): case KEY_NPAGE: case '-': /* display previous page */ case KEY_PPAGE: case '!': /* shell escape */ case '?': /* help */ (void) command(c); break; case ctrl('L'): /* redraw screen */ case KEY_CLEAR: (void) command(c); goto same; case ESC: /* kept for backwards compatibility */ /* FALLTHROUGH */ case '\r': /* don't change lines */ case '\n': case KEY_ENTER: case KEY_BREAK: case ctrl('G'): clearprompt(); goto nochange; case '*': /* mark/unmark all displayed lines */ for (i = 0; topline + i < nextline; ++i) { mark(i); } goto same; case 'a': /* mark/unmark all lines */ for (i = 0; i < totallines; ++i) { if (change[i] == NO) { change[i] = YES; } else { change[i] = NO; } } /* show that all have been marked */ seekline(totallines); break; case ctrl('X'): /* mouse selection */ if ((p = getmouseevent()) == NULL) { goto same; /* unknown control sequence */ } /* if the button number is a scrollbar tag */ if (p->button == '0') { scrollbar(p); break; } /* find the selected line */ /* note: the selection is forced into range */ for (i = disprefs - 1; i > 0; --i) { if (p->y1 >= displine[i]) { break; } } mark(i); goto same; default: /* if a line was selected */ if (isdigit(c) && c != '0' && !mouse) { if (returnrequired == NO) { mark(c - '1'); } else { clearprompt(); (void) move(PRLINE, 0); (void) addstr(selectionprompt); if (getaline(buf, COLS - sizeof (selectionprompt), c, NO) > 0 && (i = atoi(buf)) > 0) { mark(i - 1); } } } goto same; } } /* for each line containing the old text */ (void) fprintf(script, "ed - <<\\!\nH\n"); *oldfile = '\0'; seekline(1); for (i = 0; fscanf(refsfound, "%s%*s%s%*[^\n]", newfile, linenum) == 2; ++i) { /* see if the line is to be changed */ if (change[i] == YES) { anymarked = YES; /* if this is a new file */ if (strcmp(newfile, oldfile) != 0) { /* make sure it can be changed */ if (access(newfile, WRITE) != 0) { (void) sprintf(msg, "Cannot write to file %s", newfile); putmsg(msg); anymarked = NO; break; } /* if there was an old file */ if (*oldfile != '\0') { (void) fprintf(script, "w\n"); /* save it */ } /* edit the new file */ (void) strcpy(oldfile, newfile); (void) fprintf(script, "e %s\n", oldfile); } /* output substitute command */ (void) fprintf(script, "%ss/", linenum); /* change */ for (s = pattern; *s != '\0'; ++s) { /* old text */ if (*s == '/') { (void) putc('\\', script); } (void) putc(*s, script); } (void) putc('/', script); /* to */ for (s = newpat; *s != '\0'; ++s) { /* new text */ if (strchr("/\\&", *s) != NULL) { (void) putc('\\', script); } (void) putc(*s, script); } (void) fprintf(script, "/gp\n"); /* and print */ } } (void) fprintf(script, "w\nq\n!\n"); /* write and quit */ (void) fclose(script); clearprompt(); /* if any line was marked */ if (anymarked == YES) { /* edit the files */ (void) refresh(); (void) fprintf(stderr, "Changed lines:\n\r"); (void) execute(shell, shell, temp2, (char *)NULL); askforreturn(); } nochange: changing = NO; initmenu(); free(change); seekline(topline); return (YES); /* clear any marks on exit without change */ }
/** * Program start point, build the windows GUI, initialise the emulator. * Enter the program main loop, and tidy up when finished. */ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { static const char szClassName[] = "WindowsApp"; MSG messages = {0}; /**< Here messages to the application are saved */ WNDCLASSEX wincl; /**< Data structure for the windowclass */ hinstance=hThisInstance; /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use custom icon and default mouse-pointer */ wincl.hIcon = LoadIcon(hThisInstance, "allegro_icon"); wincl.hIconSm = LoadIcon(hThisInstance, "allegro_icon"); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0; /* Load Menu from resources file */ menu=LoadMenu(hThisInstance,TEXT("MainMenu")); /* Add in CDROM links to the settings menu dynamically */ initmenu(); /* The class is registered, let's create the program*/ ghwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "RPCEmu v" VERSION, /* Title Text */ WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, /* overlapped window with no sizing frame */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 640 + (GetSystemMetrics(SM_CXFIXEDFRAME) * 2), /* The window width */ 480 + (GetSystemMetrics(SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION), /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ menu, /* Menu handle */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow (ghwnd, nFunsterStil); win_set_window(ghwnd); allegro_init(); /* allegro */ /* Allegro does not appear to read the window position until it receives a window move message. This results in the mousehack pointer being offset incorrectly until the window is moved. To workaround this issue, we generate a window move message to the window's current position. */ { WINDOWINFO wi; GetWindowInfo(ghwnd, &wi); PostMessage(ghwnd, WM_MOVE, 0, MAKELPARAM(wi.rcClient.left, wi.rcClient.top)); } /* Initialise the emulation and read the config file */ if (startrpcemu()) return -1; /* Initialise the podules */ opendlls(); /* Based on the contents of config file, dynamically update the Windows GUI items */ if (config.cdromtype > 2) { WindowProcedure(ghwnd, WM_COMMAND, IDM_CDROM_DISABLED + config.cdromtype, 0); } CheckMenuItem(menu, IDM_CDROM_DISABLED + config.cdromtype, MF_CHECKED); CheckMenuItem(menu, IDM_MOUSE_TWOBUTTON, config.mousetwobutton ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(menu, IDM_CPUIDLE, config.cpu_idle ? MF_CHECKED : MF_UNCHECKED); if (config.mousehackon) { CheckMenuItem(menu, IDM_MOUSE_FOL, MF_CHECKED); } else { CheckMenuItem(menu, IDM_MOUSE_CAP, MF_CHECKED); } /* Return the mouse clipping to normal on program exit */ atexit(releasemousecapture); // SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); install_int_ex(vblupdate, BPS_TO_TIMER(config.refresh)); drawscre=0; /* Program main loop */ while (!quited) { /* Execute the emulation */ execrpcemu(); /* Update title with mips speed */ if (updatemips) { char title[128]; if (mousehack) { sprintf(title, "RPCEmu v" VERSION " - MIPS: %.1f, AVG: %.1f", perf.mips, perf.mips_total / perf.mips_count); } else { sprintf(title, "RPCEmu v" VERSION " - MIPS: %.1f, AVG: %.1f - %s", perf.mips, perf.mips_total / perf.mips_count, (mousecapture) ? "Press CTRL-END to release mouse" : "Click to capture mouse"); } SetWindowText(ghwnd, title); updatemips=0; } if (handle_sigio) { handle_sigio = 0; sig_io(1); } /* Exit full screen? */ if ((key[KEY_LCONTROL] || key[KEY_RCONTROL]) && key[KEY_END] && fullscreen) { togglefullscreen(0); mousecapture=0; } /* Release mouse from mouse capture mode? */ if ((key[KEY_LCONTROL] || key[KEY_RCONTROL]) && key[KEY_END] && mousecapture && !config.mousehackon) { ClipCursor(&oldclip); mousecapture=0; updatemips=1; } /* Handle Windows events */ if (PeekMessage(&messages,NULL,0,0,PM_REMOVE)) { if (messages.message==WM_QUIT) { quited=1; } /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); } } /* Program has exited. Tidy up */ endrpcemu(); /* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; }
int gamekeys(void){ /* Key Handling */ while(SDL_PollEvent(&event)){ events(); switch(event.type){ case SDL_KEYDOWN: switch (event.key.keysym.sym){ case SDLK_UP: case SDLK_w: debugf("Key Pressed: Forward"); player.dir = -1; break; case SDLK_DOWN: case SDLK_s: debugf("Key Pressed: Backward"); player.dir = 1; break; case SDLK_LEFT: case SDLK_a: debugf("Key Pressed: Left"); player.rotdir = 1; break; case SDLK_RIGHT: case SDLK_d: debugf("Key Pressed: Right"); player.rotdir = -1; break; case SDLK_SPACE: debugf("Key Pressed: Brake"); brakes = 1; break; case SDLK_ESCAPE: case SDLK_q: menu = 1; initmenu(); break; default: break; } break; case SDL_KEYUP: switch (event.key.keysym.sym){ case SDLK_UP: /* Forward */ case SDLK_w: player.dir = 0; break; case SDLK_DOWN: /* Backward */ case SDLK_s: player.dir = 0; break; case SDLK_LEFT: case SDLK_a: /* Left */ if(player.rotdir == 1) /* Avoid Keylock */ player.rotdir = 0; break; case SDLK_RIGHT: case SDLK_d: /* Right */ if(player.rotdir == -1) /* Avoid Keylock */ player.rotdir = 0; break; case SDLK_SPACE: brakes = 0; break; default: break; } break; case SDL_QUIT: done = 1; break; default: break; } } return 1; }