int nextfreetrack(){ int skiptherest = 0; for(int i = 1; i <= 0xff; i++){ for(int j = 0; j < tune->tracklen; j++){ if(tune->trk[i].line[j].note) skiptherest = 1; for(int k = 0; k < 2; k++){ if(tune->trk[i].line[j].cmd[k]) skiptherest = 1; if(tune->trk[i].line[j].param[k]) skiptherest = 1; } // skip the rest of this track? if(skiptherest){ skiptherest = 0; break; } // this track is free, so return the index if(j == (tune->tracklen)-1) return i; } } setdisplay("nextfreetrack() failed somehow.."); return -1; }
int nextfreeinstr(){ for(int i = 1; i <= 0xff; i++){ if(instrument[i].line[0].cmd == '0') return i; } setdisplay("nextfreeinstr() failed somehow.."); return -1; }
void information_window(void) { /* * Developer information window. Explains how * to use the developer mode with the game and * what it is useful for. */ WINDOW *vin; initscr(); refresh(); noecho(); int height = 18, width = 65; int starty = (LINES - height) / 2; /* Calculating for a center placement */ int startx = (COLS - width) / 2; /* of the window */ vin=newwin(height,width,starty,startx); wmove(vin,0,0); setdisplay(vin, " Developer information window "); wprintw(vin, " The developer control panel is a very interesting place to go\n" " about doing business with this game. There are a few options \n" " that you can use to change how you interact with the game and\n" " how the game interacts with you. In order to use the game in \n" " ways it is not intended to be used by the general public. To \n" " enable the developer mode (which also enables the developer \n" " control panel and removed the * around it), you must run the \n" " game with developer-mode as the first parameter. This mode is\n" " not enableable from within normal mode or during the game. It\n" " holds the enabled effect when restored from a save but it not\n" " if you restart the game in normal mode. If you rely on a seed\n" " you can specify a seed value from the command line after the \n" " developer mode argument. The developer control panel is risky\n" " and not reccommended for all users. This panel will change by\n" " demand. Press any key to return. " ); wrefresh(vin); getch_(); cldisplay(vin); delwin(vin); endwin(); }
/* vi cmdline mode */ void cmdlinemode(void){ u16 c; int len; keypad(stdscr, TRUE); currmode = PM_CMDLINE; strncat(cmdstr, ":", 100); for(;;){ drawgui(); c = nextchar(); switch(c){ case KEY_ESCAPE: //cmdstr = ""; currmode = PM_NORMAL; goto end; case ENTER: _parsecmd(cmdstr); goto end; #ifndef WINDOWS case BACKSPACE: setdisplay("\\o/"); cmdstr[strlen(cmdstr)-1] = '\0'; break; #endif case '\t': break; default: len = strlen(cmdstr); cmdstr[len++] = c; cmdstr[len++] = '\0'; break; } } end: strcpy(cmdstr, ""); keypad(stdscr, FALSE); return; }
/* dis_setup display program flag */ int initfid(int dis_setup) /******************/ { setArraydis(0); if (init2d_getfidparms(dis_setup)) return ERROR; if (dis_setup == 2) { if (setplotter()) return ERROR; saved_dis_setup = 2; } else if (dis_setup) { if (setdisplay()) return ERROR; saved_dis_setup = 1; } if (dis_setup) { if (init2d_getchartparms(1)) return ERROR; if (exp_factors(0)) return ERROR; normalize = 1.0; /* preliminary value */ } if (block_pars(dim1count(), COMPLEX/2)) return ERROR; return COMPLETE; }
/* fdimname frequency dimension */ int select_init(int get_rev, int dis_setup, int fdimname, int doheaders, int docheck2d, int dospecpars, int doblockpars, int dophasefile) { int setstatus; int hypercomplex; setArraydis(0); /*************************************************************** * Obtain header information from the datafile and phasefile. * ***************************************************************/ if (doheaders) { if (dataheaders(1, 1)) return(ERROR); } if (docheck2d) { if (check2d(get_rev)) return(ERROR); /* set d2flag, revflag, ni, and dimension_name under certain conditions */ } else { dimension_name = 0; /* use entered value for name of dimension */ } if (dospecpars) { if (!fdimname) fdimname = dimension_name; if (getspecparms(dis_setup, fdimname)) return(ERROR); } if (dis_setup == 2) { if (setplotter()) return(ERROR); saved_dis_setup = 2; } else if (dis_setup) { if (setdisplay()) return(ERROR); saved_dis_setup = 1; } /*************************************** * Initialize the display parameters. * ***************************************/ if (dis_setup) { if (init2d_getchartparms(dospecpars)) return(ERROR); if (exp_factors(1)) return(ERROR); normalize = 1.0; /* preliminary value */ } /******************************************* * Compute the relevant block parameters. * *******************************************/ if (doblockpars) { if ( block_pars(datahead.nblocks, getdatatype(datahead.status)) ) return(ERROR); } /******************************************************* * Put in new phasefile header depending upon whether * * data therein can be phased in any dimension and * * whether REVFLAG is TRUE or FALSE. * *******************************************************/ if (dophasefile) { if ((~phasehead.status) & S_SPEC) /* Is the phasefile ok? */ { setstatus = datahead.status & (~(S_HYPERCOMPLEX|S_COMPLEX)); hypercomplex = (datahead.status & S_HYPERCOMPLEX); if (revflag) { new_phasefile(&phasehead, d2flag, nblocks, fn1, fn, setstatus, hypercomplex); } else { new_phasefile(&phasehead, d2flag, nblocks, fn, fn1, setstatus, hypercomplex); } } if (verify_fn_data()) { Werrprintf( "mismatch between fn parameter and phase file value" ); return( ERROR ); } p11_saveDisCmd(); } return(COMPLETE); }
void developer_settings_window(void) { /* * Developer control panel * This is what we will use to control * developer stuff that we make public * to help debug the program like thread * hooks, pointer references, and pauses */ WINDOW *vin; initscr(); refresh(); noecho(); int height = 7, width = 42; int wheight = 11, wwidth = 42; vin = phyrrus9::nwin::wcreatewin(wheight, wwidth); wmove(vin,0,0); char tmpc; //first, before we can allow this to happen we need to display //a warning so the user knows we mean business. setdisplay(vin, " Developer settings"); wprintw(vin, " Warning, this is the developer console\n" " this is not something to play with. so\n" " please be careful. This panel will let\n" " you do things beyond your far dreams, \n" " which makes it dangerous. If you don't\n" " know how to handle this, press Q now, \n" " If you know the risks, and you wish to\n" " proceed, press any other key."); wrefresh(vin); tmpc = getch_(); if (tmpc != 'Q') { while (tmpc != '4') { phyrrus9::nwin::wresizewindow(vin, height, width); setdisplay(vin, " Developer settings"); wprintw(vin, " 1. Game settings\n"); wprintw(vin, " 2. Engine settings\n", env.cheats); wprintw(vin, " 3. Developer mods\n"); wprintw(vin, " 4. Return "); wrefresh(vin); tmpc = getch_(); if (tmpc == '1') { setdisplay(vin, " Game settings"); wprintw(vin, " Enable cheats?\n"); wprintw(vin, " Old: %.1d\n", env.cheats); wprintw(vin, " New: "); wrefresh(vin); tmpc = getch_(); env.cheats = tmpc - 48; wrefresh(vin); setdisplay(vin, " Developer settings"); wprintw(vin, " Enable fog?\n"); wprintw(vin, " Old: %.1d\n", env.showmap); wprintw(vin, " New: "); wrefresh(vin); tmpc = getch_(); env.showmap = tmpc - 48; } if (tmpc == '2') { while (tmpc != 'z') { phyrrus9::nwin::wresizewindow(vin, height + 2, width); setdisplay(vin, " Engine settings"); wprintw(vin, " a. Modify save file location\n"); wprintw(vin, " b. Modify map location\n"); wprintw(vin, " y. Disable developer mode\n"); wprintw(vin, " z. Return to developer menu. "); wrefresh(vin); tmpc = getch_(); werase(vin); wrefresh(vin); wresize(vin, height, width); wrefresh(vin); if (tmpc == 'a') { phyrrus9::nwin::wresizewindow(vin, height + 1, width); char * tempstr = new char[30]; setdisplay(vin, " Engine save file"); wprintw(vin, " Current: %s\n", env.savefile.c_str()); wprintw(vin, " Please enter a new name. You\n"); wprintw(vin, " will not see this until pressing\n"); wprintw(vin, " the enter key. "); wrefresh(vin); scanf("%s", tempstr); env.savefile = tempstr; delete tempstr; werase(vin); wrefresh(vin); wresize(vin, height, width); setdisplay(vin, " Engine save file"); wprintw(vin, " Save file: %s\n", env.savefile.c_str()); wprintw(vin, " Press any key to return\n "); wrefresh(vin); getch_(); werase(vin); wrefresh(vin); wresize(vin, height, width); wrefresh(vin); } if (tmpc == 'b') { setdisplay(vin, " Modify map location"); wprintw(vin, " Please enter the map location\n :"); wrefresh(vin); int _location; cin >> _location; setdisplay(vin, " Modify map location"); wprintw(vin, " Map location: %d\n", _location); wprintw(vin, " Current value: %c\n", env.map[_location]); wprintw(vin, " New value: "); wrefresh(vin); env.map[_location] = getch_(); setdisplay(vin, " Map location modified"); wprintw(vin, " Map position: %d\n", _location); wprintw(vin, " Value: %c\n", env.map[_location]); wprintw(vin, " Press any key to return... "); wrefresh(vin); getch_(); werase(vin); } if (tmpc == 'y') { setdisplay(vin, " Disable developer mode"); wprintw(vin, " Are you sure you want to do this?\n"); wprintw(vin, " Please enter 1 (yes) or 0 (no)\n"); wprintw(vin, " :"); wrefresh(vin); char c = getch_(); if (c == '1') { env.developer_mode = false; env.can_enable_developer_mode = true; } } } werase(vin); } if (tmpc == '3') { int dmheight = 7; int dmwidth = 50; dmheight += env.modcount; phyrrus9::nwin::wresizewindow(vin, dmheight, dmwidth); setdisplay(vin, " Developer mods"); wprintw(vin, " Please select mod to enable.\n"); wprintw(vin, " Enabled mods cannot be disabled (yet)\n"); wprintw(vin, " * denotes an enabled mod\n"); if (env.modcount > 0) { for (int i = 0; i < env.modcount; i++) { wprintw(vin, " %d Name: %s", i + 1, env.modlist[i].name); if (env.modlist[i].enabled == true) { wprintw(vin, "*"); } wprintw(vin, "\n"); } wprintw(vin, " :"); wrefresh(vin); char modnum = 0; do { modnum = getch_(); } while (modnum < '0' && modnum > env.modcount + 48); int mod_number = char_int(modnum) - 1; if (env.modlist[mod_number].enabled == false) { phyrrus9::nwin::wresizewindow(vin, 4 + env.modcount, 35); setdisplay(vin, " Mod enabled"); wprintw(vin, " %s enabled\n", env.modlist[mod_number].name); env.modlist[mod_number].enabled = true; enablemod(mod_number); } else { phyrrus9::nwin::wresizewindow(vin, 4, 35); setdisplay(vin, " Error!"); wprintw(vin, " %s is already enabled\n", env.modlist[mod_number].name); } } wrefresh(vin); getch_(); } } }
/* normal mode */ void normalmode(int c){ int i; // don't save the action for repeat if it's a movement or a repeat, or // something else that doesnt make sense to repeat if(c != 'h' && c != 'j' && c != 'k' && c != 'l' && c != CTRL('D') && c != CTRL('U') && c != CTRL('H') && c != CTRL('L') && c != 'H' && c != 'M' && c != 'L' && c != 'g' && c != 'G' && c != '.'){ lastaction = c; lastrepeatnum = cmdrepeatnum; } for(i=0; i<cmdrepeatnum; i++){ switch(c){ /* add line */ case 'a': act_addline(); break; case '.': // if the last command was a replace, just insert the last thing // inserted instead of calling insertmode() if(lastaction == 'r') _insertc(lastinsert); else normalmode(lastaction); cmdrepeatnum = lastrepeatnum; break; case KEY_ESCAPE: disptick = 0; jammermode(); break; case CTRL('Y'): switch(currtab){ case 0: if(songoffs>0){ if(songy==getmaxy(stdscr)-3+songoffs) songy--; songoffs--; } break; case 1: if(trackoffs>0){ if(tracky==getmaxy(stdscr)-3+trackoffs) tracky--; trackoffs--; } break; case 2: if(instroffs>0){ if(instry==getmaxy(stdscr)-3+instroffs) instry--; instroffs--; } break; } break; case CTRL('E'): switch(currtab){ case 0: if(songy<=tune->songlen-2){ if(songy==songoffs) songy++; songoffs++; } break; case 1: if(tracky<=(tune->tracklen)-2){ if(tracky==trackoffs) tracky++; trackoffs++; } break; case 2: if(instry<=instrument[currinstr].length-2){ if(instry==instroffs) instry++; instroffs++; } break; } break; case 'H': switch(currtab){ case 0: songy = songoffs; break; case 1: tracky = trackoffs; break; case 2: instry = instroffs; break; } break; // the second cases (to the right of the colon) for M and L // took some serious guesswork, so I'm not sure if they're // correct but they seem to work. case 'M': switch(currtab){ case 0: songy = (tune->songlen <= getmaxy(stdscr)-2)? tune->songlen/2 : ((getmaxy(stdscr)-6)/2) + songoffs; break; case 1: tracky = (tune->tracklen <= getmaxy(stdscr)-2)? tune->tracklen/2 : ((getmaxy(stdscr)-6)/2) + trackoffs; break; case 2: instry = (instrument[currinstr].length <= getmaxy(stdscr)-2)? instrument[currinstr].length/2 : ((getmaxy(stdscr)-6)/2) + instroffs; break; } break; case 'L': switch(currtab){ case 0: songy = (tune->songlen <= getmaxy(stdscr)-2)? tune->songlen-1 : getmaxy(stdscr)-3+songoffs; break; case 1: tracky = (tune->tracklen <= getmaxy(stdscr)-2)? tune->tracklen-1 : getmaxy(stdscr)-3+trackoffs; break; case 2: instry = (instrument[currinstr].length <= getmaxy(stdscr)-2)? instrument[currinstr].length-1 : getmaxy(stdscr)-3+instroffs; break; } break; case 'g': if(nextchar() == 'g'){ act_mvtop(); } break; case 'G': act_mvbottom(); break; // yank case 'y': c = nextchar(); switch(c){ case 'y': //tclip = malloc(1); if(currtab == 0){ tcliplen = 1; memcpy(&tclip, &tune->sng[songy], sizeof(struct songline)); }else if(currtab == 1){ tcliplen = 1; memcpy(&tclip, &tune->trk[currtrack].line[tracky], sizeof(struct trackline)); }else if(currtab == 2){ icliplen = 1; memcpy(&iclip, &instrument[currinstr].line[instry], sizeof(struct instrline)); } break; case 'j': //tclip = malloc(2); if(currtab == 0){ tcliplen = 2; memcpy(&tclip[0], &tune->sng[songy], sizeof(struct songline)); act_mvdown(); memcpy(&tclip[1], &tune->sng[songy], sizeof(struct songline)); }else if(currtab == 1){ tcliplen = 2; memcpy(&tclip[0], &tune->trk[currtrack].line[tracky], sizeof(struct trackline)); act_mvdown(); memcpy(&tclip[1], &tune->trk[currtrack].line[tracky], sizeof(struct trackline)); }else if(currtab == 2){ icliplen = 2; memcpy(&iclip[0], &instrument[currinstr].line[instry], sizeof(struct instrline)); act_mvdown(); memcpy(&iclip[1], &instrument[currinstr].line[instry], sizeof(struct instrline)); } break; case 'k': //tclip = malloc(2); if(currtab == 0){ tcliplen = 2; memcpy(&tclip[1], &tune->sng[songy], sizeof(struct songline)); act_mvup(); memcpy(&tclip[0], &tune->sng[songy], sizeof(struct songline)); }else if(currtab == 1){ tcliplen = 2; memcpy(&tclip[1], &tune->trk[currtrack].line[tracky], sizeof(struct trackline)); act_mvup(); memcpy(&tclip[0], &tune->trk[currtrack].line[tracky], sizeof(struct trackline)); }else if(currtab == 2){ icliplen = 2; memcpy(&iclip[1], &instrument[currinstr].line[instry], sizeof(struct instrline)); act_mvup(); memcpy(&iclip[0], &instrument[currinstr].line[instry], sizeof(struct instrline)); } break; } break; //paste case 'p': if(currtab == 0){ if(tune->songlen < 256){ for(int i = 0; i < tcliplen; i++){ // insert new line memmove(&tune->sng[songy + 2], &tune->sng[songy + 1], sizeof(struct songline) * (tune->songlen - songy - 1)); songy++; tune->songlen++; memset(&tune->sng[songy], 0, sizeof(struct songline)); // paste to new line memcpy(&tune->sng[songy], &tclip[i], sizeof(struct songline)); } } }else if(currtab == 1){ for(int i = 0; i < tcliplen; i++){ memcpy(&tune->trk[currtrack].line[tracky], &tclip[i], sizeof(struct trackline)); if(tracky < (tune->tracklen)-step) tracky += step; else tracky = (tune->tracklen)-1; } }else if(currtab == 2){ if(instrument[currinstr].length < 256){ // insert new line for(int i = 0; i < icliplen; i++){ struct instrument *in = &instrument[currinstr]; instry++; memmove(&in->line[instry + 1], &in->line[instry + 0], sizeof(struct instrline) * (in->length - instry)); in->length++; in->line[instry].cmd = '0'; in->line[instry].param = 0; // paste to new line memcpy(&instrument[currinstr].line[instry], &iclip[i], sizeof(struct instrline)); } } //if(instry < instrument[currinstr].length-1) instry++; } break; // copy everything in the current phrase or instrument into the next free one case '^': if(currtab == 1){ f = nextfreetrack(); memcpy(&tune->trk[f], &tune->trk[currtrack], sizeof(struct track)); currtrack = f; }else if(currtab == 2){ f = nextfreeinstr(); memcpy(&instrument[f], &instrument[currinstr], sizeof(struct instrument)); currinstr = f; } break; // TODO: Y and P can be removed after we make visual mode // copy whole phrase or instrument case 'Y': if(currtab == 1){ memcpy(&tclip, &tune->trk[currtrack], sizeof(struct track)); }else if(currtab == 2){ memcpy(&iclip, &instrument[currinstr], sizeof(struct instrument)); } break; // paste whole phrase or instrument case 'P': if(currtab == 1){ memcpy(&tune->trk[currtrack], &tclip, sizeof(struct track)); }else if(currtab == 2){ memcpy(&instrument[currinstr], &iclip, sizeof(struct instrument)); } break; /* delete line */ // TODO: clean this SHIT up // TODO: add an ACT_ function for delete case 'd': c = nextchar(); switch(c){ case 'd': act_delline(); break; case 'k': if(currtab == 2){ struct instrument *in = &instrument[currinstr]; instry--; int i; for(i=0; i<2; i++){ if(in->length > 1){ memmove(&in->line[instry + 0], &in->line[instry + 1], sizeof(struct instrline) * (in->length - instry - 1)); in->length--; if(instry >= in->length) instry = in->length - 1; } } }else if(currtab == 0){ songy--; int i; for(i=0; i<2; i++){ if(tune->songlen > 1){ memmove(&tune->sng[songy + 0], &tune->sng[songy + 1], sizeof(struct songline) * (tune->songlen - songy - 1)); tune->songlen--; if(songy >= tune->songlen) songy = tune->songlen - 1; } } } break; case 'j': if(currtab == 2){ struct instrument *in = &instrument[currinstr]; int i; for(i=0; i<2; i++){ if(in->length > 1){ memmove(&in->line[instry + 0], &in->line[instry + 1], sizeof(struct instrline) * (in->length - instry - 1)); in->length--; if(instry >= in->length) instry = in->length - 1; } } }else if(currtab == 0){ int i; for(i=0; i<2; i++){ if(tune->songlen > 1){ memmove(&tune->sng[songy + 0], &tune->sng[songy + 1], sizeof(struct songline) * (tune->songlen - songy - 1)); tune->songlen--; if(songy >= tune->songlen) songy = tune->songlen - 1; } } } break; } break; /* undo */ case 'u': act_undo(); /* Clear */ case 'x': act_clronething(); break; case 'X': act_clritall(); break; case ENTER: if(currtab != 2){ if(currtab == 1){ silence(); startplaytrack(currtrack); }else if(currtab == 0){ silence(); startplaysong(songy); } } break; case 'Z': c = nextchar(); switch(c){ case 'Z': lft_savefile(filename); erase(); refresh(); endwin(); exit(0); break; case 'Q': erase(); refresh(); endwin(); exit(0); break; } break; /* Enter command mode */ case ':': cmdlinemode(); break; case ' ': silence(); tune->plonked = 0; break; // TODO: make an act_ function for '`' case '`': if(currtab == 0){ int t = tune->sng[songy].track[songx / 4]; if(t) currtrack = t; currtab = 1; if(playtrack){ startplaytrack(currtrack); } }else if((currtab == 1) && ((trackx == 2) || (trackx == 3))){ int i = tune->trk[currtrack].line[tracky].instr; if(i) currinstr = i; currtab = 2; } else if(currtab == 1){ currtab = 0; }else if(currtab == 2){ currtab = 1; } break; /* Enter insert mode */ case 'i': insertmode(); break; /* Enter visual mode */ case 'v': visualmode(); break; /* Enter visual line mode */ case 'V': visuallinemode(); break; /* enter jammer mode */ case CTRL('A'): jammermode(); break; /* Add new line and enter insert mode */ case 'o': act_addline(); insertmode(); break; case 'h': case KEY_LEFT: act_mvleft(); break; case 'j': case KEY_DOWN: act_mvdown(); break; case 'k': case KEY_UP: act_mvup(); break; case 'l': case KEY_RIGHT: act_mvright(); break; case '<': if(octave) octave--; break; case '>': if(octave < 8) octave++; break; case '{': if(currtrack > 1) currtrack--; break; case '}': if(currtrack < 255) currtrack++; break; case 'J': if(currtab == 0){ if( (songx%4) < 2){ act_trackdec(); }else{ act_transpdec(); } }else if(currtab == 1){ switch(trackx){ case 0: act_notedec(); break; case 1: act_octavedec(); break; case 2: act_instrdec(); break; case 3: act_instrdec(); break; case 4: act_fxdec(); break; case 5: case 6: act_paramdec(); break; case 7: act_fxdec(); break; case 8: case 9: act_paramdec(); break; default: setdisplay("in J"); break; } }else if(currtab == 2){ switch(instrx){ case 0: act_fxdec(); break; case 1: if(instrument[currinstr].line[instry].cmd == '+' || instrument[currinstr].line[instry].cmd == '='){ act_notedec(); }else{ act_paramdec(); } break; case 2: if(instrument[currinstr].line[instry].cmd == '+' || instrument[currinstr].line[instry].cmd == '='){ act_notedec(); }else{ act_paramdec(); } break; } } break; case 'K': if(currtab == 0){ if( (songx%4) < 2){ act_trackinc(); }else{ act_transpinc(); } }else if(currtab == 1){ switch(trackx){ case 0: act_noteinc(); break; case 1: act_octaveinc(); break; case 2: act_instrinc(); break; case 3: act_instrinc(); break; case 4: act_fxinc(); break; case 5: case 6: act_paraminc(); break; case 7: act_fxinc(); break; case 8: case 9: act_paraminc(); break; default: setdisplay("in K"); break; } }else if(currtab == 2){ switch(instrx){ case 0: act_fxinc(); break; case 1: if(instrument[currinstr].line[instry].cmd == '+' || instrument[currinstr].line[instry].cmd == '='){ act_noteinc(); }else{ act_paraminc(); } break; case 2: if(instrument[currinstr].line[instry].cmd == '+' || instrument[currinstr].line[instry].cmd == '='){ act_noteinc(); }else{ act_paraminc(); } break; } } break; case CTRL('J'): if(currtab == 2){ act_viewinstrdec(); }else if(currtab == 1){ act_viewtrackdec(); } break; case CTRL('K'): if(currtab == 2){ act_viewinstrinc(); }else if(currtab == 1){ act_viewtrackinc(); } break; case '[': act_viewinstrdec(); break; case ']': act_viewinstrinc(); break; case '(': callbacktime++; break; case ')': callbacktime--; break; case '-': if(step > 0) step--; break; case '=': if(step < 0x0f) step++; break; case CTRL('H'): currtab--; if(currtab < 0) currtab = 2; break; case CTRL('L'): currtab++; currtab %= 3; break; case KEY_TAB: currtab++; currtab %= 3; break; case CTRL('U'): act_bigmvup(); break; case CTRL('D'): act_bigmvdown(); break; /*case CTRL('P'): vimode = false; break;*/ // replace case 'r': _insertc(nextchar()); break; default: break; } // end switch } // end for cmdrepeatnum = 1; cmdrepeat = 0; }
void _parsecmd(char cmd[]){ //if(cmd[1] == 'w'){ //switch(strcmp(cmd, if(strcmp(cmd, ":w") == 0){ lft_savefile(filename); saved = 1; }else if(strcmp(cmd, ":q") == 0){ if(!saved){ setdisplay("no write since last change! use :q! to override"); }else{ erase(); refresh(); endwin(); exit(0); } }else if(strcmp(cmd, ":q!") == 0){ erase(); refresh(); endwin(); exit(0); }else if(strcmp(cmd, ":write") == 0){ lft_savefile(filename); saved = 1; }else if(strcmp(cmd, ":wq") == 0 || strcmp(cmd, ":x") == 0){ lft_savefile(filename); saved = 1; erase(); refresh(); endwin(); exit(0); }else if(strcmp(cmd, ":quit") == 0){ erase(); refresh(); endwin(); exit(0); }else if(cmd[1]=='e' && cmd[2]==' '){ // if the file doesn't exist, clear the song if(lft_loadfile(cmd+3)){ initsonglines(); inittracks(); initinstrs(); } //yucky if statement below.....probably better way to do it // maybe this is better?? }else if(!strncmp(cmd+1,"save ",5)){ lft_saveinstrument(cmd+6); setdisplay("d-_-b saved ins! d-_-b"); }else if(!strncmp(cmd+1,"load ",5)){ lft_loadinstrument(cmd+6); setdisplay("d-_-b loaded ins! d-_-b"); }else if( _isnumber((char *)cmd+1,isxdigit) ){ unsigned int goton = 1; xtoi(cmd+1,&goton); switch(currtab){ case 0: songy = (goton>tune->songlen)? tune->songlen-1 : goton; break; case 1: currtrack = (goton>0xff)? 0xff : goton; break; case 2: currinstr = (goton>0xff)? 0xff : goton; break; } }else if(cmd[1] == 'c' && cmd[2] == ' '){ strncpy(comment, cmd+3, sizeof(comment)); }else setdisplay("not a tracker command!"); return; }