int startupmenu(int i) { while (1) { drawbox(5, STARTUP_Y-2, 22, STARTUP_N+4, NULL); printmenuhelp(19); i = startup_menu(i-1, 8, STARTUP_Y); # ifndef TTY_SOCKET if (!i) break; # else if (i==2 && !select_2p_tty(24, STARTUP_Y+1)) continue; if (!i) { clearbox(0, 6, 0, 16); if ((i = menu_checkinvit(1, 7)) == -1) { i = 1; continue; } if (!i) break; } setcurs_end(); cleartoeol(); textgfx_entermenu(); # endif clearbox(0, 6, 0, 16); break; } return i; }
static int hiscore_congrats(const char **menu) { char name[8] = " "; int x = 9; int y = _HEIGHT_24L ? 7 : 3; setwcurs(0, 9, y); while (is_outside_screen(x+26, 0)) x--; drawbox(x, y, 26, 9, "CONGRATULATIONS!"); setcurs(x+2, y+2); printstr("You have a highscore!"); newln(x+2); printstr("Please enter your name"); entername: switch (hiscore_entername_menu(name, menu, x+4, y+4)) { case 0: return 0; case 1: if (savehiscore(name)) { if (x > 7) clearbox(33, y, 2, 9); return hiscorebox(menu, 9, y); } setcurs(x+2, y+2); printstr("ERROR! Could not save"); newln(x+2); printstr("score to file. "); goto entername; case 2: clearbox(32, y, 0, 9); return 1; } }
int startupmenu(int i) { while (1) { print_vitetris_ver(19, 4); newln(0); newln(19); printstr("Written by"); newln(19); printstr("Victor Nilsson"); newln(19); printstr("2007-2009"); i = startup_menu(i-1, 1, 4); # ifndef TTY_SOCKET if (!i) break; # else if (i==2 && !select_2p_tty(17, 5)) continue; if (!i && (i = menu_checkinvit(1, 4)) == -1) { i = 1; continue; } if (!i) break; setcurs_end(); printf("\033[K"); # endif clearbox(0, 4, 0, menuheight-4); break; } return i; }
void handleRowanMultichoice(u8 index) { u16 id; //task *tasks = (task *) 0x3005090; int (*freebox)(u8) = (int (*)(void)) 0x0810F4D8 + 1; int (*clearbox)(u16) = (int (*)(void)) 0x08003E3C + 1; int (*finalbox)(u8, u8) = (int (*)(void)) 0x80F6F54 + 1; u8 (*multichoiceGetResponse)() = (u8 (*)(void)) 0x0810FA04 + 1; id = tasks[index].args[0xD]; switch(multichoiceGetResponse()) { case 0: //tasks[index].function = (u32) 0x0812EF50 + 1; //break; case 1: //tasks[index].function = (u32) 0x0812F4A8 + 1; //break; case 2: // All three are needed to clear the multichoice. Also clears textbox freebox(1); clearbox(id); finalbox(0, 1); tasks[index].args[6] = 0x1E; tasks[index].function = (u32) thisWorld; break; } }
void options_menu(const char **items, int n, menuhandler f, int x, int y) { const char *menu[8] = {"Input Setup", "-"}; char tetr_colors[18] = "Tetromino Colours"; menuhandler handlers[8] = {rarrow_menuitem}; int i = 1; memcpy(&menu[2], items, n*sizeof(char *)); while (i <= n) handlers[++i] = f; #if !NO_BLOCKSTYLES menu[++i] = "Block Style"; handlers[i] = f; n++; #endif menu[++i] = "Board BG"; handlers[i] = op_bgdot; spellword(tetr_colors+10); menu[++i] = tetr_colors; handlers[i] = rarrow_menuitem; n += 4; i = 0; while (i = openmenu(menu, n, i, x, y, handlers)) { i--; if (!i) { f(op_inputsetup_select(x, y), &i); inputdevs_player[0] = 0; } else if (i == n-1) tetrom_colors_menu(x, y+i+1); else if (!handlers[i](STARTBTN, &i)) break; } clearbox(x, y, 0, n); }
static void tetrom_colors_menu(int x, int y) { const char *menu[7] = {"I", "J", "L", "O", "S", "T", "Z"}; menuhandler handlers[7] = { op_tcolor, op_tcolor, op_tcolor, op_tcolor, op_tcolor_gt4, op_tcolor_gt4, op_tcolor_gt4 }; int i = 0; if (y+6 >= term_height) y -= 7; drawbox(x, y, 19, 6, (char *) 0); x++; y++; drawmenu(menu, 4, 0, x, y, handlers); drawmenu(menu+4, 3, -1, x+9, y, handlers+4); autorep_a_b_btns = 1; while (1) { setcurs(x, y+i%4); refreshwin(-1); switch (handle_menuitem_2cols(menu, 7, &i, 4, x, y+i%4, handlers, getkeypress_block(SINGLE_PL))) { case 0: case 2: autorep_a_b_btns = 0; if (i >= 4) x -= 9; clearbox(x-1, y-1, 19, 6); return; case 3: x += i>=4 ? 9 : -9; setcurs(x, y+i%4); printmenuitem(menu[i], 1); } } }
void optionsmenu() { const char *items[2] = {"Fullscreen", "Line Drawing"}; draw_options_box(); options_menu(items, 2, op_handler, 3, 9); clearbox(1, 7, 0, 11); }
void hiscorelist() { int y = 7; if (term_height < 22) y--; show_hiscorelist(1, y); clearbox(0, y, 0, 12); }
int gamemenu() { int i = 1; #ifdef TWOPLAYER int h; if (!TWOPLAYER_MODE || game->mode & MODE_NETWORK) h = GAMEMENU_LENGTH+4; else { h = 17; while (menuheight < h) newln(2); } while (1) { i = game_menu(0, 1, 4); if (i==4) inputsetup_box(0, 1, 4); else break; } if (!i) clearbox(0, 4, 0, h-4); #else while (1) { i = game_menu(i-1, 1, 4); if (i==4) { setcurs(0, 13); printf("\033[K"); inputsetup_box(0, 1, 4); i = 1; } else if (i < GAMEMENU_LENGTH-1) break; else { clearbox(0, 4, 0, GAMEMENU_LENGTH); if (i == GAMEMENU_LENGTH-1) optionsmenu(); else hiscorelist(); } } #endif return i; }
int dropdownlist(const char **items, int n, int i, int x, int y) { int w = getdropdownwidth(items, n); int j; while (is_outside_screen(0, y+n+1)) y--; setattr_standout(); drawbox(x, y, w+2, n+2, NULL); x++; y++; setcurs(x, y); for (j = 0; j < n; j++) { printdropdownitem(items[j], i==j, w); newln(x); } while (1) { setcurs(x-1, y+i); refreshwin(-1); switch (getkeypress_block(SINGLE_PL) & 0xFF) { case STARTBTN: case A_BTN: goto out; case 'q': exit(0); case MVUP: if (!i) continue; j = -1; break; case '\t': if (i == n-1) { j = -i; break; } case MVDOWN: if (i < n-1) { j = 1; break; } case MVRIGHT: continue; default: i = -1; goto out; } setcurs(x, y+i); printdropdownitem(items[i], 0, w); i += j; setcurs(x, y+i); printdropdownitem(items[i], 1, w); } out: clearbox(x-1, y-1, w+2, n+2); return i+1; }
int gamemenu() { int i = 0; #ifdef TWOPLAYER while (1) { if (!TWOPLAYER_MODE) show_hiscorelist5(5, GAMEMENU_LENGTH+9, 0); i = game_menu(0, 1, 7); if (i != 4) break; clearbox(5, GAMEMENU_LENGTH+9, 0, 5); inputsetup_box(0, 1, 7); } if (!i) clearbox(0, 7, 0, 14); #else while (1) { printmenuhelp(19); i = game_menu(i, 1, 7); if (!i) break; clearbox(0, 7, 0, GAMEMENU_LENGTH); if (i != 4 && i < GAMEMENU_LENGTH-1) break; clearbox(0, 19, 0, 3); switch (i) { case 4: inputsetup_box(0, 1, 7); i = 0; continue; case GAMEMENU_LENGTH-1: optionsmenu(); break; default: hiscorelist(); } i--; } #endif return i; }
static int op_handler(int k, int *pos) { const struct termopt opt = {ASCII, "CP437 ASCII", "drawing"}; int i = *pos-2; if (i < 0) { if (k) { clearbox(0, 16, 0, 4); inputsetup_box(k-1, 1, 7); } draw_options_box(); return 1; } if (!i) { if (k == MVLEFT) i = 0; else if (k == MVRIGHT) i = 1; else { i = !getopt_int("", "fullscreen"); if (k == A_BTN) i = !i; else if (k) return 0; } printmenuitem_options("yes no", i); if (k) { union val v; v.integ = !i; setoption("", "fullscreen", v, 0); } i = 1; } else if (i == 1) { if (!k) { get_xy(&k, &i); setcurs(2, i+5); putnchars(HLINE, 28); help_alt_enter(); setcurs(k, i); k = 0; } i = term_optionhandler(k, &opt); } #ifndef NO_BLOCKSTYLES else i = select_blockstyle(k); #endif if (i == 3) { draw_tetris_logo(0, 0); draw_options_box(); } return i; }
void inputsetup_box(int pl, int x, int y) { int h = 8; #ifdef JOYSTICK if (num_joyst) h++; #endif clearbox(x-1, y, 0, h+4); printhelp(x+2, y+h+2); setcurs(x, y); printmenuitem("Input Setup", 1); #ifdef TWOPLAYER if (!pl) printstr(" single"); printstr(" player"); if (pl) putch(pl+'0'); #endif drawbox(x, y+1, 31, h, NULL); inputsetup_menu(pl, x+1, y+2); clearbox(x, y, 0, h+4); }
int gamemenu() { int i = 0; #ifdef TWOPLAYER int y = 7; while (1) { if (!TWOPLAYER_MODE) { if (term_height >= 23) show_hiscorelist5(5, GAMEMENU_LENGTH+9, 0); } else if (term_height < 23) { setcurs(1, 4); cleartoeol(); y = 5; } i = game_menu(0, 1, y); if (i != 4) break; wclrtobot(window); inputsetup_box(0, 1, 7); } if (!i) { setcurs(1, 4); wclrtobot(window); print_vitetris_ver(19, 4); } #else while (1) { printmenuhelp(19); i = game_menu(i, 1, 7); if (!i) break; clearbox(0, 7, 0, GAMEMENU_LENGTH); if (i != 4 && i < GAMEMENU_LENGTH-1) break; wclrtobot(window); switch (i) { case 4: inputsetup_box(0, 1, 7); i = 0; continue; case GAMEMENU_LENGTH-1: optionsmenu(); break; default: hiscorelist(); } i--; } #endif return i; }
void refreshwin(int win) { static int redraw; struct player *p; if (redraw) return; #ifdef TWOPLAYER if ((win == 1 || win == 2) && !game_running) { p = &game->player[win-1]; #else if (win == 1 && !game_running) { p = &player1; #endif redraw = 1; if (game_paused) redrawboard(p, 19); else redrawboard(p, 3); redraw = 0; } refreshscreen(); } /* only used for clearing window showing next tetromino and game screen */ void clearwin(int win) { int h; setwcurs(win, 0, 0); if (win >= WIN_NEXT) clearbox(0, 0, 8, 2); else { margin_x = 0; h = term_height; if (h < 24 && h > 21) h = 21; clearbox(0, 0, 0, h); } }
static int hiscorebox(const char **menu, int x, int y) { int i = 0; while (i < 10 && hiscores[i].score >= player1.score) i++; if (i < 10) i++; while (is_outside_screen(x+24, 0)) x--; drawbox(x, y, 24, 11, "HIGHSCORES"); x += 2; show_hiscorelist5(x, y+2, i); exit(0); //WILLIAMICED if (playagain_menu(menu, x+2, y+8)) { clearbox(x+21, y, 0, 11); return 1; } return 0; }
void hiscorelist() { show_hiscorelist(1, 7); clearbox(0, 7, 0, 12); }
void hiscorelist() { menuheight = 6; show_hiscorelist(1, 4); clearbox(0, 4, 0, menuheight-4); }
void clearwinsave(int win) { int h; setwcurs(win, 0, 0); clearbox(-20, 18, 12, 2); }
int init_pan_or_recalc(int do_zoomout) /* decide to recalc, or to chg worklist & pan */ { int i,j,row,col,y,alignmask,listfull; if (zwidth == 0.0) return(0); /* no zoombox, leave calc_status as is */ /* got a zoombox */ if ((alignmask=check_pan()-1) < 0) { calc_status = 0; /* can't pan, trigger recalc */ return(0); } if (zbx == 0.0 && zby == 0.0) { clearbox(); return(0); } /* box is full screen, leave calc_status as is */ col = (int)(zbx*(dxsize+PIXELROUND)); /* calc dest col,row of topleft pixel */ row = (int)(zby*(dysize+PIXELROUND)); if (do_zoomout) { /* invert row and col */ row = 0-row; col = 0-col; } if ((row&alignmask) != 0 || (col&alignmask) != 0) { calc_status = 0; /* not on useable pixel alignment, trigger recalc */ return(0); } /* pan */ num_worklist = 0; if (calc_status == 2) { start_resume(); get_resume(sizeof(int),&num_worklist,sizeof(worklist),worklist,0); } /* don't do end_resume! we might still change our mind */ /* adjust existing worklist entries */ for (i=0; i<num_worklist; ++i) { worklist[i].yystart -= row; worklist[i].yystop -= row; worklist[i].yybegin -= row; worklist[i].xxstart -= col; worklist[i].xxstop -= col; } /* add worklist entries for the new edges */ listfull = i = 0; j = ydots-1; if (row < 0) { listfull |= add_worklist(0,xdots-1,0,0-row-1,0,0,0); i = 0 - row; } if (row > 0) { listfull |= add_worklist(0,xdots-1,ydots-row,ydots-1,ydots-row,0,0); j = ydots - row - 1; } if (col < 0) listfull |= add_worklist(0,0-col-1,i,j,i,0,0); if (col > 0) listfull |= add_worklist(xdots-col,xdots-1,i,j,i,0,0); if (listfull != 0) { static FCODE msg[] = {"\ Tables full, can't pan current image.\n\ Cancel resumes old image, continue pans and calculates a new one."}; if (stopmsg(2,msg)) { zwidth = 0; /* cancel the zoombox */ drawbox(1); } else calc_status = 0; /* trigger recalc */ return(0); } /* now we're committed */ calc_status = 2; clearbox(); if (row > 0) /* move image up */ for (y=0; y<ydots; ++y) move_row(y+row,y,col); else /* move image down */ for (y=ydots; --y>=0;) move_row(y+row,y,col); fix_worklist(); /* fixup any out of bounds worklist entries */ alloc_resume(sizeof(worklist)+10,1); /* post the new worklist */ put_resume(sizeof(int),&num_worklist,sizeof(worklist),worklist,0); return(0); }
void drawbox(int drawit) { struct coords tl,bl,tr,br; /* dot addr of topleft, botleft, etc */ double tmpx,tmpy,dx,dy,rotcos,rotsin,ftemp1,ftemp2; double fxwidth,fxskew,fydepth,fyskew,fxadj; bf_t bffxwidth, bffxskew, bffydepth, bffyskew, bffxadj; int saved; if (zwidth==0) { /* no box to draw */ if (boxcount!=0) { /* remove the old box from display */ clearbox(); /* asm routine */ boxcount = 0; } reset_zoom_corners(); return; } if(bf_math) { saved = save_stack(); bffxwidth = alloc_stack(rbflength+2); bffxskew = alloc_stack(rbflength+2); bffydepth = alloc_stack(rbflength+2); bffyskew = alloc_stack(rbflength+2); bffxadj = alloc_stack(rbflength+2); } ftemp1 = PI*zrotate/72; /* convert to radians */ rotcos = cos(ftemp1); /* sin & cos of rotation */ rotsin = sin(ftemp1); /* do some calcs just once here to reduce fp work a bit */ fxwidth = sxmax-sx3rd; fxskew = sx3rd-sxmin; fydepth = sy3rd-symax; fyskew = symin-sy3rd; fxadj = zwidth*zskew; if(bf_math) { /* do some calcs just once here to reduce fp work a bit */ sub_bf(bffxwidth,bfsxmax,bfsx3rd); sub_bf(bffxskew,bfsx3rd,bfsxmin); sub_bf(bffydepth,bfsy3rd,bfsymax); sub_bf(bffyskew,bfsymin,bfsy3rd); floattobf(bffxadj, fxadj); } /* calc co-ords of topleft & botright corners of box */ tmpx = zwidth/-2+fxadj; /* from zoombox center as origin, on xdots scale */ tmpy = zdepth*finalaspectratio/2; dx = (rotcos*tmpx - rotsin*tmpy) - tmpx; /* delta x to rotate topleft */ dy = tmpy - (rotsin*tmpx + rotcos*tmpy); /* delta y to rotate topleft */ /* calc co-ords of topleft */ ftemp1 = zbx + dx + fxadj; ftemp2 = zby + dy/finalaspectratio; tl.x = (int)(ftemp1*(dxsize+PIXELROUND)); /* screen co-ords */ tl.y = (int)(ftemp2*(dysize+PIXELROUND)); xxmin = sxmin + ftemp1*fxwidth + ftemp2*fxskew; /* real co-ords */ yymax = symax + ftemp2*fydepth + ftemp1*fyskew; if(bf_math) { calc_corner(bfxmin,bfsxmin,ftemp1,bffxwidth,ftemp2,bffxskew); calc_corner(bfymax,bfsymax,ftemp2,bffydepth,ftemp1,bffyskew); } /* calc co-ords of bottom right */ ftemp1 = zbx + zwidth - dx - fxadj; ftemp2 = zby - dy/finalaspectratio + zdepth; br.x = (int)(ftemp1*(dxsize+PIXELROUND)); br.y = (int)(ftemp2*(dysize+PIXELROUND)); xxmax = sxmin + ftemp1*fxwidth + ftemp2*fxskew; yymin = symax + ftemp2*fydepth + ftemp1*fyskew; if(bf_math) { calc_corner(bfxmax,bfsxmin,ftemp1,bffxwidth,ftemp2,bffxskew); calc_corner(bfymin,bfsymax,ftemp2,bffydepth,ftemp1,bffyskew); } /* do the same for botleft & topright */ tmpx = zwidth/-2 - fxadj; tmpy = 0.0-tmpy; dx = (rotcos*tmpx - rotsin*tmpy) - tmpx; dy = tmpy - (rotsin*tmpx + rotcos*tmpy); ftemp1 = zbx + dx - fxadj; ftemp2 = zby + dy/finalaspectratio + zdepth; bl.x = (int)(ftemp1*(dxsize+PIXELROUND)); bl.y = (int)(ftemp2*(dysize+PIXELROUND)); xx3rd = sxmin + ftemp1*fxwidth + ftemp2*fxskew; yy3rd = symax + ftemp2*fydepth + ftemp1*fyskew; if(bf_math) { calc_corner(bfx3rd,bfsxmin,ftemp1,bffxwidth,ftemp2,bffxskew); calc_corner(bfy3rd,bfsymax,ftemp2,bffydepth,ftemp1,bffyskew); restore_stack(saved); } ftemp1 = zbx + zwidth - dx + fxadj; ftemp2 = zby - dy/finalaspectratio; tr.x = (int)(ftemp1*(dxsize+PIXELROUND)); tr.y = (int)(ftemp2*(dysize+PIXELROUND)); if (boxcount!=0) { /* remove the old box from display */ clearbox(); /* asm routine */ boxcount = 0; } if (drawit) { /* caller wants box drawn as well as co-ords calc'd */ #ifndef XFRACT /* build the list of zoom box pixels */ addbox(tl); addbox(tr); /* corner pixels */ addbox(bl); addbox(br); drawlines(tl,tr,bl.x-tl.x,bl.y-tl.y); /* top & bottom lines */ drawlines(tl,bl,tr.x-tl.x,tr.y-tl.y); /* left & right lines */ #else boxx[0] = tl.x + sxoffs; boxy[0] = tl.y + syoffs; boxx[1] = tr.x + sxoffs; boxy[1] = tr.y + syoffs; boxx[2] = br.x + sxoffs; boxy[2] = br.y + syoffs; boxx[3] = bl.x + sxoffs; boxy[3] = bl.y + syoffs; boxcount = 1; #endif dispbox(); /* asm routine to paint it */ } }