seq::seq(int id, SUBDIV subdiv,  int steps, SEQ_LOOP_TYPE loop, bool reverse) : _id(id), _stopped(true)
{
    setchannel(Midi.midiChannel);
    setsubdiv(subdiv);
    setsteps(steps);
    setlooptype(loop);
    if(reverse) {
        setreverse(true);
        setposition(steps-1);
    } else {
        setreverse(false);
        setposition(0);
    }
    setbegin(0);
    if(steps <= MAX_STEPS) setend(steps-1);
    else setend(MAX_STEPS);
    for(int i = 0; i < MAX_STEPS; i++) {
        //        _notes[i] = 36 + 3 * i;
        _notes[i] = 0;
        _velocity[i] = 127;
    }
    setinternal(true);
    setexternal(true);
    _lastposition = 0;
}
Esempio n. 2
0
File: editcor.c Progetto: 8l/FUZIX
PROC
scroll(bool down)
{
    int i;

    if (count <= 0)
	count = dofscroll;
    strput(CURoff);
    if (down) {
	curr = min(bufmax-1, nextline(TRUE, curr, count));
	i = min(bufmax-1, nextline(TRUE, pend, count));
	if (i > pend)
	    scrollforward(i);
    }
    else {
	curr = bseekeol(max(0,nextline(FALSE, curr, count)));
	i = bseekeol(max(0,nextline(FALSE, ptop, count)));
	if (i < ptop)
	    if (canUPSCROLL)
		scrollback(i);
	    else {
		ptop = i;
		setend();
		redisplay(TRUE);
	    }
    }
    strput(CURon);
    setpos(skipws(curr));	/* initialize new position - first nonwhite */
    yp = setY(curr);
    mvcur(yp, xp);		/* go there */
}
Esempio n. 3
0
void Gfield::show( int num )
{
	char wn = 'y';
	system("cls");
	
	cout<< nm1<< " vs "<< nm2<< endl;
	
	// is it some winer?...
	if( wn != win( num ) )
	{
		
	if( check == '1' )
	{
		cout<< nm1<< " move"<< " 0"<< endl;
		check = '0';
	}

	else 
	{
		cout<< nm2<< " move"<< " X"<< endl;
		check = '1';
	}
	}
	
	else 
		if( check == '1')
		{
			cout<< nm2<< " is Winner!!!"<<endl;
			setend();
		}
		else if( check == '0' )
		{
			cout<< nm1<< " is Winner!!!"<<endl;
			setend();
		}
	
	for(int j = 0; j <= 6 ; j+=3 )
	{
		printf("\n");
		for( int i = 0; i < 9 / 3 ; i++ )
			{
				printf( "| %c |", field[ i + j ] );
			}

	}
	printf("\n");
}
Esempio n. 4
0
PROC
scrollback(int curr)
{
    mvcur(0,0);		/* move to the top line */
    do {
	ptop = bseekeol(ptop-1);
	strput(UpS);
	writeline(0, 0, ptop);
    } while (ptop > curr);
    setend();
}
Esempio n. 5
0
seq::seq(int id, SUBDIV subdiv,  int steps, int channel) : _id(id), _stopped(true)
{
    setchannel(channel);
    setsubdiv(subdiv);
    setsteps(steps);
    setlooptype(LOOP);
    setreverse(false);
    setposition(0);
    setbegin(0);
    if(steps <= MAX_STEPS) setend(steps-1);
    else setend(MAX_STEPS);
    for(int i = 0; i < MAX_STEPS; i++) {
        _notes[i] = 36 + 3 * i;
        _velocity[i] = 127;
    }
    setinternal(true);
    setexternal(true);
    _lastposition = 0;
    
}
Esempio n. 6
0
/* 
 * get_segment grabs another record segment from the data stream.
 * fio->scc will be set as follows:
 *	SCCMIDL		fio->segbits = fio_cnt (all or rest of data in fio
 *			buffer) and no EOR was found
 *	SCCFULL		an EOR was found
 *
 * return values are as follows:
 *	2	encountered end of data -> stat will be set
 *	1	encountered end of file -> stat will be set
 *	0	segment (or part) is received -> stat will NOT be set
 *	ERR	encountered an error -> stat will be set
 */
static int
get_segment(struct fdinfo *fio, struct ffsw *stat)
	{
	long 	tword;
	int	left; 
	ssize_t	ret;

	unsigned char 	*cp;

	bitptr tbptr;

	struct text_f *text_info;

	text_info = (struct text_f *)fio->lyr_info;
	fio->lastscc = fio->scc;
/*
 *	If buffer is empty, or not enough to hold entire EOF marker,
 *	get more data.
 */
	if (fio->_cnt == 0 || fio->_cnt < text_info->eof_len)
		{
/*
 *		If num of bits not enough to hold EOF, move remainder
 *		to base of buffer and read in at base+remainder.  Adjust
 *		pointers and counts accordingly.
 */
		left = 0;
		if (fio->_cnt > 0)
			{
			bitptr tptr;

			left = fio->_cnt;
/*
 *			Move tail of data to the first word of the
 *			buffer (right justified).
 */
			GET_BITS(tword, fio->_ptr, left);
			SET_BPTR(tptr, fio->_base);
			PUT_BITS(tptr, tword, left);
			SET_BPTR(fio->_ptr, INC_BPTR(fio->_base, left));
			}
		else
			fio->_ptr = fio->_base;	/* reset _ptr */
		zero = 0;
		READBLK(ret, fio, (size_t)((uint64)fio->maxblksize >> 3), 
			stat, PARTIAL, &zero);
/*
 *		Add back in the 'extra' data
 */
		fio->_ptr = fio->_base;	/* reset _ptr */
		fio->_cnt = fio->_cnt + left;

		if (ret < (ssize_t)0)
			return(ERR);
		if (zero != 0)
			ERETURN(stat, FDC_ERR_UBC, 0);

		if (fio->_cnt == 0) /* must be at EOD */
			{
			return(setend(fio, stat));
			}
		}
Esempio n. 7
0
set()
{
	register char *cp;
	register struct option *op;
	register int c;
	bool no;
	extern short ospeed;

	setnoaddr();
	if (skipend()) {
		if (peekchar() != EOF)
			ignchar();
		propts();
		return;
	}
	do {
		cp = optname;
		do {
			if (cp < &optname[ONMSZ - 2])
				*cp++ = getchar();
		} while (isalnum(peekchar()));
		*cp = 0;
		cp = optname;
		if (eq("all", cp)) {
			if (inopen)
				pofix();
			prall();
			goto next;
		}
		no = 0;
		if (cp[0] == 'n' && cp[1] == 'o') {
			cp += 2;
			no++;
		}
		/* Implement w300, w1200, and w9600 specially */
		if (eq(cp, "w300")) {
			if (ospeed >= B1200) {
dontset:
				ignore(getchar());	/* = */
				ignore(getnum());	/* value */
				continue;
			}
			cp = "window";
		} else if (eq(cp, "w1200")) {
			if (ospeed < B1200 || ospeed >= B2400)
				goto dontset;
			cp = "window";
		} else if (eq(cp, "w9600")) {
			if (ospeed < B2400)
				goto dontset;
			cp = "window";
		}
		for (op = options; op < &options[NOPTS]; op++)
			if (eq(op->oname, cp) || op->oabbrev && eq(op->oabbrev, cp))
				break;
		if (op->oname == 0)
			serror("%s: No such option@- 'set all' gives all option values", cp);
		c = skipwh();
		if (peekchar() == '?') {
			ignchar();
printone:
			propt(op);
			noonl();
			goto next;
		}
		if (op->otype == ONOFF) {
			op->ovalue = 1 - no;
			if (op == &options[PROMPT])
				oprompt = 1 - no;
			goto next;
		}
		if (no)
			serror("Option %s is not a toggle", op->oname);
		if (c != 0 || setend())
			goto printone;
		if (getchar() != '=')
			serror("Missing =@in assignment to option %s", op->oname);
		switch (op->otype) {

		case NUMERIC:
			if (!isdigit(peekchar()))
				error("Digits required@after =");
			op->ovalue = getnum();
			if (value(TABSTOP) <= 0)
				value(TABSTOP) = TABS;
			if (op == &options[WINDOW]) {
				if (value(WINDOW) >= LINES)
					value(WINDOW) = LINES-1;
				vsetsiz(value(WINDOW));
			}
			break;

		case STRING:
		case OTERM:
			cp = optname;
			while (!setend()) {
				if (cp >= &optname[ONMSZ])
					error("String too long@in option assignment");
				/* adb change:  allow whitepace in strings */
				if( (*cp = getchar()) == '\\')
					if( peekchar() != EOF)
						*cp = getchar();
				cp++;
			}
			*cp = 0;
			if (op->otype == OTERM) {
/*
 * At first glance it seems like we shouldn't care if the terminal type
 * is changed inside visual mode, as long as we assume the screen is
 * a mess and redraw it. However, it's a much harder problem than that.
 * If you happen to change from 1 crt to another that both have the same
 * size screen, it's OK. But if the screen size if different, the stuff
 * that gets initialized in vop() will be wrong. This could be overcome
 * by redoing the initialization, e.g. making the first 90% of vop into
 * a subroutine. However, the most useful case is where you forgot to do
 * a setenv before you went into the editor and it thinks you're on a dumb
 * terminal. Ex treats this like hardcopy and goes into HARDOPEN mode.
 * This loses because the first part of vop calls oop in this case.
 * The problem is so hard I gave up. I'm not saying it can't be done,
 * but I am saying it probably isn't worth the effort.
 */
				if (inopen)
error("Can't change type of terminal from within open/visual");
				setterm(optname);
			} else {
				CP(op->osvalue, optname);
				op->odefault = 1;
			}
			break;
		}
next:
		flush();
	} while (!skipend());
	eol();
}
Esempio n. 8
0
File: editcor.c Progetto: 8l/FUZIX
PROC
docommand(cmdtype cmd)
{
    cmdtype movecmd;	/* movement command for y, d, c */
    char    cmdch;
    int     oldc;	/* old count */
    int     endp;	/* end position before change */
    extern bool s_wrapped;

    resetX();				/* un-derange the cursor */
    oldc = newc = -1;
    endY = yp;
    newend = disp = curr;
    ok = TRUE;				/* so far everything is working */
    cmdch = ch;
    if (cmd != UNDO_C && cmd != YANK_C) {
	if (macro<0)
	    zerostack(&undo);
	if (redoing != TRUE) {
	    rcp = rcb;		/* point at start of redo buffer */
	    if (count > 1) {	/* put in a count? */
		numtoa(rcb,count);
		rcp += strlen(rcb);
	    }
	    *rcp++ = cmdch;	/* the command char goes in... */
	    xerox = TRUE;	/* hoist the magical flags */
	}
    }

    if (cmd <= YANK_C) {
	readchar();
	if (ch >= '0' && ch <= '9') {
	    oldc = count;
	    gcount();				/* get a new count */
	    if (cmd == ADJUST_C)		/* special for >>,<< wierdness */
		swap(&count, &oldc);		/* reverse sw & count */
	    else
		count = count*max(oldc,1);	/* combine them */
	}
	if (ch == cmdch) {		/* diddle lines */
	    yank.lines = TRUE;
	    endp = nextline(TRUE, curr, count);
	    curr = bseekeol(curr);
	    disp = curr;
	}
	else {				/* diddle 'things' */
	    yank.lines = FALSE;
	    movecmd = movemap[ch];

	    if (ok = (findCP(curr,&endp,movecmd) == LEGALMOVE)) {
		if (curr > endp) {
		    swap(&curr,&endp);
		    ok = (cmd != CHANGE_C);
		}
		if (adjcurr[movecmd])
		    curr++;
		if (adjendp[movecmd])
		    endp++;
	    }
	    if (!ok) {
		if (ch != ESC)
		    error();
		goto killredo;
	    }
	}
	
	endY = setY(endp);
	newend = curr;
	disp = curr;
	switch (cmd) {
	    case DELETE_C:
		ok = deletion(curr, endp);
		break;
	    case ADJUST_C:
		adjuster((cmdch == '<'), endp-1, oldc);
		break;
	    case CHANGE_C:
		if (endp <= pend+1) {
		    mvcur(setY(endp-1), setX(endp-1));
		    printch('$');
		    mvcur(yp, xp);
		}
		if (deletion(curr, endp))
		    ok = ((newend = insertion(1, 0, &disp, &endY, TRUE)) >= 0);
		else
		    ok = FALSE;
		break;
	    case YANK_C:
		if (!doyank(curr, endp))
		    error();
		return 0;	/* xerox will not be true, nor will redoing */
	}

    }
    else {
	endp = curr;
	endY = yp;

	switch (cmd) {
	    case I_AT_NONWHITE:
	    case A_AT_END:
	    case APPEND_C:
	    case INSERT_C:		/* variations on insert */
		if (cmd != INSERT_C) {
		    if (cmd == APPEND_C)
			curr = min(curr+1, lend);
		    else if (cmd == A_AT_END)
			curr = lend;
		    else /* if (cmd == I_AT_NONWHITE) */
			curr = skipws(lstart);
		    xp = setX(curr);
		    mvcur(yp,xp);
		}
		newend = insertion(count, 0, &disp, &endY, TRUE);
		ok = (newend >= 0);
		break;
	    case OPEN_C:
	    case OPENUP_C:
		newend = insertion(1,setstep[ (cmd==OPENUP_C)&1 ],
						&disp,&endY,TRUE)-1;
		ok = (newend >= 0);
		break;
	    case REPLACE_C:
	    case TWIDDLE_C:
		if (cmd == REPLACE_C) {
		    if ((cmdch = readchar()) == ESC)
			goto killredo;
		}
		if (findCP(curr, &endp, GO_RIGHT) == LEGALMOVE)
		    squiggle(endp-1, cmdch, (cmd==REPLACE_C));
		break;
	    case PUT_BEFORE:
	    case PUT_AFTER:
		ok = put(cmd==PUT_AFTER);
		break;
	    case BIG_REPL_C:
		bigreplace();
		break;
	    case RESUBST_C:
		ok = FALSE;
		if (dst[0] != 0) {
		    newend = chop(curr, &lend, TRUE, &ok);
		    if (newend >= 0) {
			endY = setY(newend+strlen(dst));
			ok = TRUE;
		    }
		}
		break;
	    case JOIN_C:
		join(count);		/* join lines */
		break;
	    case UNDO_C:			/* undo last modification */
		ok = fixcore(&newend) >= 0;
		disp = newend;
		endY = MAGICNUMBER;
		break;
	}
    }

    if (ok) {
	setpos((newc<0)?newend:newc);
	setend();
	if (curr < ptop || curr > pend) {
	    yp = settop(12);
	    redisplay(TRUE);
	}
	else {
	    yp = setY(curr);
	    if (endY != setY(newend))	/* shuffled lines */
		refresh(setY(disp), setX(disp), disp, pend, TRUE);
	    else			/* refresh to end position */
		refresh(setY(disp), setX(disp), disp, newend, FALSE);
	}
	if (curr >= bufmax && bufmax > 0) {	/* adjust off end of buffer */
	    setpos(bufmax-1);
	    yp = setY(curr);
	}
	if (s_wrapped) {
	    prompt(FALSE, "search wrapped around end of buffer");
	    s_wrapped = 0;
	}
	else
	    clrprompt();
	modified = TRUE;
    }
    else {
	error();
killredo:
	rcb[0] = 0;
    }
    mvcur(yp, xp);
    if (xerox)
	*rcp = 0;	/* terminate the redo */
    redoing = FALSE;
    xerox = FALSE;
    core[bufmax] = EOL;
}