Esempio n. 1
0
void addscore(int n,Sint4 score)
{
  scdat[n].score+=score;
  if (scdat[n].score>999999L)
    scdat[n].score=0;
  if (n==0)
    writenum(scdat[n].score,0,0,6,1);
  else
    if (scdat[n].score<100000L)
      writenum(scdat[n].score,236,0,6,1);
    else
      writenum(scdat[n].score,248,0,6,1);
  if (scdat[n].score>=scdat[n].nextbs+n &&   /* +n to reproduce original bug */
      scdat[n].score<1000000L) {
    if (getlives(n)<5 || unlimlives) {
      if (gauntlet)
        cgtime+=17897715L; /* 15 second time bonus instead of the life */
      else
        addlife(n);
      drawlives();
    }
    scdat[n].nextbs+=bonusscore;
  }
  incpenalty();
  incpenalty();
  incpenalty();
}
Esempio n. 2
0
int main(){
	int sem_id = semget(ftok(".",'s'), 1, IPC_CREAT|IPC_EXCL|0666);
	if(sem_id == -1){ printf("get err:%m\n"); return -1;}

	union semun sem_union;
	sem_union.val = 1;
	semctl(sem_id, 0, SETVAL, sem_union);

    struct sembuf sem_b;
    sem_b.sem_num = 0;
    sem_b.sem_op = -1;//P()
    sem_b.sem_flg = SEM_UNDO;
    struct sembuf sem_p;
    sem_p.sem_num = 0;
    sem_p.sem_op = 1;//V()
    sem_p.sem_flg = SEM_UNDO;


	int i = 0;
	for(i = 0; i < 10; ++i){
		semop(sem_id, &sem_b, 1);
		writenum(i);
		sleep(rand() % 3);
		writenum(i);
		sleep(rand() % 2);
		semop(sem_id, &sem_p, 1);	
	}

	sleep(10);

	union semun sem_del;
	semctl(sem_id, 0, IPC_RMID, sem_del);

	return 0;
}
Esempio n. 3
0
void drawscores(void)
{
  writenum(scdat[0].score,0,0,6,3);
  if (nplayers==2 || diggers==2)
    if (scdat[1].score<100000L)
      writenum(scdat[1].score,236,0,6,3);
    else
      writenum(scdat[1].score,248,0,6,3);
}
Esempio n. 4
0
void writecurscore(int col)
{
  if (curplayer==0)
    writenum(scdat[0].score,0,0,6,col);
  else
    if (scdat[1].score<100000L)
      writenum(scdat[1].score,236,0,6,col);
    else
      writenum(scdat[1].score,248,0,6,col);
}
Esempio n. 5
0
static void itDisplayIns52(uint16_t *buf, int n, int plInstMode)
{
	char col=plInstMode?0x07:"\x08\x08\x0B\x0A"[plInstUsed[n]];
	writestring(buf, 0, col, (!plInstMode&&plInstUsed[n])?"    \xfe##: ":"     ##: ", 9);
	writenum(buf, 5, col, n+1, 16, 2, 0);
	writestring(buf, 9, col, plInstr[n].name, 43);
}
Esempio n. 6
0
static void gmdDisplayIns33(unsigned short *buf, int n, int plInstMode)
{
	char col=plInstMode?0x07:"\x08\x08\x0B\x0A"[(unsigned)plInstUsed[n]];
	writestring(buf, 0, col, (!plInstMode&&plInstUsed[n])?"\xfe##: ":" ##: ", 5);
	writenum(buf, 1, col, n+1, 16, 2, 0);
	writestring(buf, 5, col, plInstr[n].name, 28);
}
Esempio n. 7
0
static void oplDrawGStrings(uint16_t (*buf)[CONSOLE_MAX_X])
{
      	long tim;

       	mcpDrawGStrings(buf);

	if (plPause)
		tim=(pausetime-starttime)/DOS_CLK_TCK;
	else
		tim=(dos_clock()-starttime)/DOS_CLK_TCK;

      	if (plScrWidth<128)
	{
		writestring(buf[1],  0, 0x09, " song .. of .. title: .......................... cpu:...% ",58);

		if (globinfo.title[0])
			writestring(buf[1], 22, 0x0F, globinfo.title, 26);
		_writenum(buf[1], 53, 0x0F, tmGetCpuUsage(), 10, 3);

		writenum(buf[1],  6, 0x0F, globinfo.currentSong, 16, 2, 0);
		writenum(buf[1], 12, 0x0F, globinfo.songs, 16, 2, 0);

		writestring(buf[2],  0, 0x09, " file \372\372\372\372\372\372\372\372.\372\372\372 author: ....................................... time: ..:.. ", 80);
		if (globinfo.author[0])
			writestring(buf[2], 27, 0x0F, globinfo.author, 39);

/*		writestring(buf[2],  6, 0x0F, currentmodname, _MAX_FNAME);
		writestring(buf[2], 14, 0x0F, currentmodext, _MAX_EXT);*/
		if (plPause)
			writestring(buf[2], 60, 0x0C, "paused", 6);
		writenum(buf[2], 73, 0x0F, (tim/60)%60, 10, 2, 1);
		writestring(buf[2], 75, 0x0F, ":", 1);
		writenum(buf[2], 76, 0x0F, tim%60, 10, 2, 0);
	} else {
		memset(buf[2]+128, 0, (plScrWidth-128)*sizeof(uint16_t));

		writestring(buf[1],  0, 0x09, "    song .. of .. title: .........................................................    cpu:...% ",95);
		writenum(buf[1],  9, 0x0F, globinfo.currentSong, 16, 2, 0);
		writenum(buf[1], 15, 0x0F, globinfo.songs, 16, 2, 0);
		_writenum(buf[1], 90, 0x0F, tmGetCpuUsage(), 10, 3);

		if (globinfo.title[0])
			writestring(buf[1], 25, 0x0F, globinfo.title, 57);

		writestring(buf[2],  0, 0x09, "    file \372\372\372\372\372\372\372\372.\372\372\372 author: ...................................................................                    time: ..:..   ", 132);
/*		writestring(buf[2],  9, 0x0F, currentmodname, _MAX_FNAME);
		writestring(buf[2], 17, 0x0F, currentmodext, _MAX_EXT);*/
		if (globinfo.author[0])
			writestring(buf[2], 30, 0x0F, globinfo.author, 67);
		if (plPause)
			writestring(buf[2], 100, 0x0C, "playback paused", 15);
		writenum(buf[2], 123, 0x0F, (tim/60)%60, 10, 2, 1);
		writestring(buf[2], 125, 0x0F, ":", 1);
		writenum(buf[2], 126, 0x0F, tim%60, 10, 2, 0);
	}

}
Esempio n. 8
0
static char*
writenum (char *dest, unsigned int value, int base, int width)
{
	static char *digits = "0123456789abcdef";
	
	if ( width > 0 || value != 0 ) {
		dest = writenum (dest, value / base, base, width-1);
		*dest++ = digits [value%base];	
	}	
	return (dest);
}
Esempio n. 9
0
static void itDisplayIns80(uint16_t *buf, int n, int plInstMode)
{
	char col;
	writestring(buf, 0, 0, "", 80);

	if (plBigInstNum[n]!=0xFF)
	{
		const struct it_instrument *ins=&plInstr[plBigInstNum[n]];
		col=plInstMode?0x07:"\x08\x08\x0B\x0A"[plInstUsed[plBigInstNum[n]]];
		writestring(buf, 0, col, (!plInstMode&&plInstUsed[plBigInstNum[n]])?"\xfe##: ":" ##: ", 5);
		writenum(buf, 1, col, plBigInstNum[n]+1, 16, 2, 0);
		writestring(buf, 5, col, ins->name, 31);
	}

	if (plBigSampNum[n]!=0xFFFF)
	{
		const struct it_sample *sm=&plModSamples[plBigSampNum[n]];
		const struct it_sampleinfo *si=&plSamples[sm->handle];

		col=plInstMode?0x07:"\x08\x08\x0B\x0A"[plSampUsed[plBigSampNum[n]]];
		writestring(buf, 34, col, (!plInstMode&&plSampUsed[plBigSampNum[n]])?"\xfe###: ":" ###: ", 6);
		writenum(buf, 35, col, plBigSampNum[n], 16, 3, 0);
		if (si->type&mcpSampLoop)
		{
			_writenum(buf, 40, col, si->loopend, 10, 6);
			_writenum(buf, 47, col, si->loopend-si->loopstart, 10, 6);
			if (si->type&mcpSampBiDi)
				writestring(buf, 53, col, "\x1D", 1);
		} else {
			_writenum(buf, 40, col, si->length, 10, 6);
			writestring(buf, 52, col, "-", 1);
		}
		writestring(buf, 55, col, (si->type&mcpSamp16Bit)?"16":" 8", 2);
		writestring(buf, 57, col, (si->type&mcpSampRedRate4)?"\xac":(si->type&mcpSampRedRate2)?"\xab":(si->type&mcpSampRedBits)?"!":" ", 2);

		if (!plInstShowFreq)
		{
			writestring(buf, 60, col, plNoteStr[(sm->normnote+60*256)>>8], 3);
			writenum(buf, 64, col, sm->normnote&0xFF, 16, 2, 0);
		} else
			if (plInstShowFreq==1)
Esempio n. 10
0
void IOdebug(const char *str, ... )
{
	int base, i, *p;
	char *s;
	va_list a;

	va_start(a,str);

	while( *str ) 
	{
		if( *str == '%' )
		{
			base = 10;
			switch( *(++str) )
			{
			default:
				IOputc(*str); 
				break;

			case 0:				/* "...%" = no \n */
				goto nonl;
								
			case 'c':			/* char		*/
				i = va_arg(a,int);
				IOputc(i);
				break;

			case 'x': base = 16;		/* hex 		*/
			case 'd':			/* decimal	*/
				i = va_arg(a,int);
				writenum(i,base);
				break;
				
			case 's':			/* string	*/
				s = va_arg(a,char *);
				if( s == NULL ) s = "<NULL string>";
			putstr:
				writestr(s);
				break;

			}
			str++;
		}
		else IOputc(*str++);
Esempio n. 11
0
void 
my_itoa ( char *buffer, word value )
{
	writenum (buffer, (unsigned)value,10,3);
}