Beispiel #1
0
/**
 * Write a string on screen
 *
 * \param str String
 */
void kprint(char *str)
{
    unsigned int i = 0;
    char c;

    while((c = str[i]) != '\0') {
        switch(c) {
        case '\n':
            if(py <= VIDEO_ROWS) {
                py++;
                if(py >= VIDEO_ROWS) {
                    scroll_screen();
                    py = VIDEO_ROWS-1;
                }
            }
            px = 0;
            break;

        case '\r':
            if(px > 0) px--;
            break;

        case '\b':
            if(px > 0) px--;
            writechar(' ', c_attr);
            px--;
            break;

        default:
            writechar(str[i], c_attr);
        }
        i++;
    }
    return;
}
Beispiel #2
0
Datei: port.c Projekt: jaw0/jlisp
/* composite ports */
void compputc(Obj p, int c){
	int i, l;
	Obj cp = CDR(p);
	
	switch (SUBSUBPORT(p)){
	  case COMP_T:
		writechar( CAR( cp ), c);
		writechar( CDR( cp ), c);
		break;
	  case COMP_BCAST:
		l = CLENGTH(cp);
		for(i=0; i<l; i++)
			writechar( CVECTOR(cp)[i], c);
		break;
	  case COMP_ECHO:
	  case COMP_2WAY:
		writechar( CDR(cp), c);
		break;
	  case COMP_SYNO:
		Fputc( MAKCHAR(c), getvalue(cp) );
		break;
	  case COMP_FUNC:
		funcall_1("#<internal:compputc>", CVECTOR(cp)[1], MAKCHAR(c));
		break;
	  default:
		break;
	}
}
Beispiel #3
0
static
void	_print_line( int fd, const char* file, int line ) {
	int	filefd;

	writestring(fd, "in file ");
	writestring(fd, file);
	writestring(fd, " at line ");
	writeint(fd, line);
	writechar(fd, ':');

#ifndef O_TEXT
#define O_TEXT 0
#endif
	if ( (filefd = open(file, O_RDONLY | O_TEXT )) != -1 ) {
		char	c;

		for ( ; line > 1; line -- ) {
			while ( readchar(filefd) != '\n' )
				;
		}

		do {
			writechar(fd, c = readchar(filefd));
		} while ( c != '\n' );
	} else {
		writestring(2, "Couldn't open ");
		writestring(2, file);
		writechar(2, '\n');
	}
}
Beispiel #4
0
//debug things
	static int uart_putchar(char c, _UNUSED_ FILE *stream){
	
		if(c == '\n') writechar('\r');
		writechar(c);
		
		return 0;
	}
Beispiel #5
0
Datei: port.c Projekt: jaw0/jlisp
int prnport(Obj p, Obj s, int h){
	int (*fnc)(Obj,Obj,int);
	int t = SUBPORT(p);

	fnc = pdesc[t].print;

	if(fnc)
		return fnc(p, s, h);
	else{
		writestr(s, "#<ioport:");
		if( RPORTP(p))
			writechar(s, 'R');
		if( WPORTP(p))
			writechar(s, 'W');
		if( SUBPORT(p)){
			writechar(s, '_');
			printnum(s, SUBPORT(p), 16, 0, 0);
			if( SUBSUBPORT(p)){
				writechar(s, ':');
				printnum(s, SUBSUBPORT(p), 16, 0, 0);
			}
		}
		writechar(s, '>');
		return 1;
	}
}
Beispiel #6
0
void LCD_Init()
{
writechar(UART_LCD,LCD_CMD);
writechar(UART_LCD,LCD_ON);
writechar(UART_LCD, LCD_SPECCMD);
writechar(UART_LCD, 157);
}
Beispiel #7
0
void UnPackSLZ(unsigned char *inbuffer, register FILE *outfile)
{
  short myTAG, mycount, myoffset;
  long int loop1;

  for(;;)  // loop forever (until goto occurs to break out of loop)
    {
      myTAG=*inbuffer++;
      for(loop1=0;(loop1!=8);loop1++)
        {
          if(myTAG&0x80)
            {
              if((mycount=*inbuffer++)==0)  // Check EXIT
                { goto skip2; } // goto's are gross but it's efficient :(
              else
                {
                  myoffset=HISTORY_SIZE-(((MASK_upper&mycount)*SHIFT_UPPER)+(*inbuffer++));
                  mycount&=MASK_lower;
                  mycount+=2;
                  while(mycount!=0)
                    {
                      writechar(LZ_history[(lzhist_offset+myoffset)&MASK_history],outfile);
                      mycount--;
                    }
                }
            }
          else
            { writechar(*inbuffer++,outfile); }
          myTAG+=myTAG;
        }
    }
skip2:
  return;
}
Beispiel #8
0
int puts(const char *s)
{
	while(*s) {
		writechar(*s);
		s++;
	}
	writechar('\n');
	return 1;
}
Beispiel #9
0
void print_on_lcd(char number)
{
	char highnumber = number >> 4;
	highnumber = highnumber & 0b00001111;
	char lownumber = number & 0b00001111;

	writechar(what_lcd_number(highnumber));
	writechar(what_lcd_number(lownumber));
	writechar(lcdspace);
}
Beispiel #10
0
int puts(const char *s)
{
	unsigned int oldmask;

	oldmask = irq_getmask();
	irq_setmask(IRQ_UART); // HACK: prevent UART data loss

	while(*s) {
		writechar(*s);
		s++;
	}
	writechar('\n');
	
	irq_setmask(oldmask);
	return 1;
}
Beispiel #11
0
void readstr(char *s, int size)
{
	char c;
	int ptr;
	
	ptr = 0;
	while(1) {
		c = readchar();
		switch(c) {
			case 0x7f:
			case 0x08:
				if(ptr > 0) {
					ptr--;
					putsnonl("\x08 \x08");
				}
				break;
			case '\r':
			case '\n':
				s[ptr] = 0x00;
				putsnonl("\n");
				return;
			default:
				writechar(c);
				s[ptr] = c;
				ptr++;
				break;
		}
	}
}
Beispiel #12
0
void putsnonl(const char *s)
{
	while(*s) {
		writechar(*s);
		s++;
	}
}
Beispiel #13
0
 /** Write a single character <code>c</code> and return the character
  * just written (or <code>EOF</code> on error.
  */
 int overflow (int c = EOF) {
    if ( c == EOF )
       return EOF;
    else {
       writechar(static_cast<char>(c));
       return traits_type::to_int_type(c);
    }
 }
int write(int file, char *ptr, int len) {
    int todo;

    for (todo = len; todo; --todo) {
        writechar(*ptr++);
    }
    return(len);
}
Beispiel #15
0
static
void	writeint (int fd, int i ) {
	int	place = 10000;

	if ( i < 0 ) {
		writechar(fd, '-');
		i = -i;
	}

	while ( place > 0 ) {
		int	digit = i / place;

		writechar(fd, '0' + (char) digit );
		i -= digit * place;
		place /= 10;
	}
}
Beispiel #16
0
void loop(int c)
{
  int d;
  for (d=0; d<c; d++)
  {
    writeint(d);
    writechar('\n');
  }
}
Beispiel #17
0
void
flushsector(int c)
{
    int		i;

    for (i = (bufptr - buf); i < SECTORSIZE; i++) writechar(c);
    writesector(buf);
    bufptr = buf;
}
Beispiel #18
0
W
__putc (W ch, FILE *port)
{
  UB	buf[1];

  buf[0] = ch;
  writechar (port->device, dev_recv, buf, 1);
  return (ch);
}
Beispiel #19
0
int main(int argc, char* argv[])
{
  char* x = "Hello world\n";
  writestring(x);
  writeint(12345);
  writechar('\n');
  loop(1000);
  return 0;
}
Beispiel #20
0
W
putc (W ch, FILE *port)
{
  port->buf[port->count] = ch;
  port->count++;

  if (ch == '\n')
    {
      writechar (port->device, dev_recv, port->buf, port->count);
      port->count = 0;
    }
  else if (port->count >= port->bufsize)
    {
      writechar (port->device, dev_recv, port->buf, port->count);
      port->count = 0;
    }

  return (ch);
}
Beispiel #21
0
int prnstr(Obj a, Obj stream, int how){
	int i, c;
	char *foo, buf[8];
	
	if(how){
		writestr(stream, "\"");
		for(i=0; i< CLENGTH(a); i++){
			c = CCHARS(a)[i];
			foo = spec_repr(c, 1);
			if(foo)
				writestr(stream, foo);
			else
				writechar(stream, c);
		}
		writestr(stream, "\"");
	}else{
		for(i=0; i< CLENGTH(a); i++)
			writechar(stream, CCHARS(a)[i]);
	}
	return 1;
}
Beispiel #22
0
void bootcompile( void )
{
	for( skip_space(); flag; skip_space() ) {
		get_name();
		find();
//		if( !flag ) {printf( "not found \n"); exit(1);}
if( !flag ) { writechar( 'Z' ); for(;;); }
		*--sp = (cell) &cptr; append();
	}
	ascii_to_literal( "exit" );
	find(); *--sp = (cell) &cptr ; append();
}
Beispiel #23
0
int
main(void)
{
	int c;
	bool leading = true;

	while ((c = readchar()) != EOF) {
		if (isspace(c))
			/* Save whitespace. */
			savewhite(c, leading);
		else {
			/* Reprint whitespace and print regular character. */
			printwhite();
			writechar(c);
			leading = false;
		}
	}
	/* Terminate non-empty files with a newline. */
	if (!leading)
		writechar('\n');
	return (0);
}
Beispiel #24
0
void putsnonl(const char *s)
{
	unsigned int oldmask;

	oldmask = irq_getmask();
	irq_setmask(IRQ_UART); // HACK: prevent UART data loss
	
	while(*s) {
		writechar(*s);
		s++;
	}
	
	irq_setmask(oldmask);
}
Beispiel #25
0
Datei: port.c Projekt: jaw0/jlisp
int compgetc(Obj p){
	int c;
	Obj cp = CDR(p), r;

	switch (SUBSUBPORT(p)){
	  case COMP_T:
	  case COMP_ECHO:
		c = readchar( CAR(cp));
		writechar( CDR(cp), c);
		break;
	  case COMP_2WAY:
		c = readchar( CAR(cp));
		break;
	  case COMP_CONCAT:
		c = readchar( CAR(cp));
		if( c == EOF ){
			/* go to next component */
			CDR(p) = CDR(cp);
			if( NULLP(CDR(p))){
				CAR(p) = IC_NIL;
				c = EOF;
			}else{
				c = compgetc(p);
			}
		}
		break;
	  case COMP_SYNO:
		r = Fgetc( getvalue(cp));
		if( r == IC_EOF )
			return EOF;
		if( !ICHARP(r) )
			return JLERROR("#<internal:compgetc>", r, "synonym-port returned a non-char");
		c = CCHAR(r);
		break;
	  case COMP_FUNC:
		r = funcall_0("#<internal:compgetc>", CVECTOR(cp)[0]);
		if( r == IC_EOF )
			return EOF;
		if( !ICHARP(r) )
			return JLERROR("#<internal:compgetc>", r, "function-port returned a non-char");
		c = CCHAR(r);
		break;
	  default:
		c = EOF;
		break;
	}
	return c;
}
Beispiel #26
0
bool ShootingPrintHitGraphic(COORD location, int timeshit)
{
	COORD consize = getconsize();

	if (location.X < 0 || location.X >= consize.X || location.Y < 0 || location.Y > consize.Y)
		return false;

	if(timeshit >= SHOOTING_SILHOUETTE_HITMARKERSNUM)
	{
		timeshit = SHOOTING_SILHOUETTE_HITMARKERSNUM - 1;
	}
	char toprint = g_Shooting_HitMarkers[timeshit];
	setcursor(location.X, location.Y);
	writechar(toprint);
	return true;
}
Beispiel #27
0
/*
 * Write bytes into the buffer
 * (buffer, string) -> integer
 */
int rb_write(lua_State *L) {
	size_t l, w = 0;
	ringbuffer *b = luaL_checkudata(L, 1, "ringbuffer_mt");
	const char *s = luaL_checklstring(L, 2, &l);

	/* Does `l` bytes fit? */
	if((l + b->blen) > b->alen) {
		lua_pushnil(L);
		return 1;
	}

	while(l-- > 0) {
		writechar(b, *s++);
		w++;
	}

	modpos(b);

	lua_pushinteger(L, w);

	return 1;
}
Beispiel #28
0
int main(int argc, char **argv)
{
  int numbits = 6;
  int digit;
  const char *digits = base64digits;
  char *p, *pd, string[BUFSIZ];

  if (argc != 2) {
    printf("usage: %s file\n", argv[0]);
    exit(0);
  }
  if (freopen(argv[1], "r", stdin) == NULL) {
    fprintf(stderr, "file %s not found\n", argv[1]);
    exit(1);
  }
  strcpy(string, argv[1]);

  pd = p  = string;
  while ((p = strchr(p, '/')) != NULL)
    pd=p++;
  p = strchr(pd, '.');
  if (p != NULL)
    *p = '\0';

  printf("const char *%s_au = \"\\\n", pd);

  digit = readbits (numbits, &numbits);
  while (numbits > 0) {
    writechar (digits[digit]);
    digit = readbits (numbits, &numbits);
  }
  padoutput();
  printf("\";\n");

  return 0;
}
Beispiel #29
0
void get_nowait( void )
{
	extern char * const init_source[];
	static char * const *source_block = init_source;
	static char *source_char;
	static char inbuf[INBUFSZ];
	static char *ibp;
	static char *const inbuf_source[] = { inbuf, 0 };
	
	flag = 1;	/* assume success */
	
	if( abort_input ) {
		have_ungotten = 0;
		source_block = inbuf_source + 1;	/* null */
		ibp = 0;
		abort_input = 0;
	}
	
	if( have_ungotten ) {
		*--sp = ungotten;
		have_ungotten = 0;
		return;
	}
	
	while( *source_block ) {		/* get input from memory */
	
		if( !source_char ) {		/* point to start of block */
			source_char = *source_block;
		}
		
		if( *source_char ) {		/* hey, we got one! */
			*--sp = *source_char++;
			return;
		}
		
		/* 
		at this point, we have a null character, so
		attempt to move to next block.
		*/
		
		source_block += 1;
		source_char = 0;
	}
	
		
	/* If we get here, there is no more input in memory,
	so grab a line from the input stream */
				
	if( ibp == 0 ) {	/* start new line */
		ibp = inbuf;
		if( FlowPrompt >= 0 ) writechar( FlowPrompt );
	}
	
	if( char_ready() ) {
		char c = readchar();
			
		if( c == '\n' ) {	/* end of line */
			*ibp++ = c;
			*ibp++ = 0;
			ibp = 0;
			source_block = inbuf_source;
			get_nowait();	/* tail recursion */
			return;
		}
		
		/* if we reach here, we won't have a char to return */
		
		flag = 0;
			
		if( c == '\b' ) {
			writechar( ' ' );
			if( ibp > inbuf ) {	/* backspace, erase last */
				writechar( '\b' );
				ibp -= 1;
			}
			return;
		}
			
		if( ibp >= inbuf + INBUFSZ - 3 ) {	/* buffer full */
			writechar( 7 );			/* bell */
			return;
		}
			
		*ibp++ = c;
	}
	
	flag = 0;	/* fail */
}
Beispiel #30
0
void put( void )
{
    writechar( *sp++ );
	flag = 1;
}