Example #1
0
// some text output code (printable characters only)
// with very limited formatting, \r, \n
void putstring(char *s) {
	while (*s) {
		unsigned char tmp = *s;
		switch (tmp) {
		case '\r':
			nTextPos = nTextRow;
			break;

		case '\n':
			scrn_scroll();
			nTextPos = nTextRow;
			break;

		default:
			if ((tmp < 32) || (tmp >= 127)) tmp='.';
			vdpchar(nTextPos, tmp);
			nTextPos++;
			if (nTextPos > nTextEnd) {
				scrn_scroll();
				nTextPos = nTextRow;
			}
			break;
		}
		s++;
	}
}
Example #2
0
File: scrn.c Project: regina/jonix
/*  ----------------------------------------------------
 *  Function:       scrn_putc
 *  --------------------------------------------------*/
void scrn_putc(char c){

    unsigned char cu    = (unsigned char) c;

    /*
     * Horizontal Tab
     */
    if(cu == '\t'){
        xpos = (xpos + tab_width) & ~(tab_width - 1);
    }

    /*
     * Carriage Return
     */
    else if(cu == '\r'){
        xpos    = 0;
    }

    /*
     * Line Feed
     */
    else if(cu == '\n'){
        xpos    = 0;
        ypos    += 1;
    }

    /*
     * Backspace
     */
    else if(cu == 0x08){
        if(xpos > 0){
            xpos--;
        }
    }

    /*
     * Printable character
     */
    else if(cu >= ' '){

        uint16_t *vidmem_ptr  = (uint16_t *) VIDEO_MEMORY_BASE;
        vidmem_ptr  += xpos + SCREEN_WIDTH*ypos;

        *vidmem_ptr = cu | (attribute << 8);

        xpos    += 1;
    }

    if(xpos >= SCREEN_WIDTH){
        xpos    = 0;
        ypos    += 1;
    }

    if(ypos >= SCREEN_HEIGHT){
        scrn_scroll();
    }

    scrn_move_hw_cursor();
}