Commit b6a3bf7c authored by Léo Grange's avatar Léo Grange
Browse files

move VTs cursor management to text_display interface

parent 5f2fc986
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -9,6 +9,14 @@ size_t disp_mono_height() {
	return 64;
}


// TODO find a way to inline these functions AND to keep generic aspect
uint32 disp_mono_get_pixel(int x, int y, void *vram) {
	// no check on (x;y) to keep performances...
	return !!( ((char*)vram)[y*16 + x/8] & (1 << x%8));
}


void disp_mono_draw_bitmap(int x, int y, unsigned char *bitmap, short w, short h, void *vvram)
{
	unsigned char *vram = vvram;

device/display/T6K11/T6K11.h

deleted100644 → 0
+0 −25
Original line number Diff line number Diff line
#ifndef DISPLAY_T6K11_H
#define DISPLAY_T6K11_H


// real type of vram_t
typedef unsigned char *vram_t;
typedef int color_t;
struct _mono_bitmap {
	unsigned char *bitmap;
	int w;
	int h;
};
typedef struct _mono_bitmap bitmap_t;

// Colors Typedef :
#define PIXEL_WHITE	0
#define PIXEL_BLACK	1
#define PIXEL_XOR	2


// Return 0xFFFFFFFF if it's a dark color, 0x00000000 else
unsigned int mask_color();

#endif  //DISPLAY_T6K11_H
+5 −0
Original line number Diff line number Diff line
@@ -29,6 +29,11 @@ void disp_mono_copy_to_dd(void *vram);
 */
void disp_mono_set_pixel(int x, int y, uint32 color, void *vram);

/**
 * Read a pixel from the VRAM, and return its color.
 */
uint32 disp_mono_get_pixel(int x, int y, void *vram);

/**
 * Returns width/height of the display, in pixels.
 */
+40 −5
Original line number Diff line number Diff line
@@ -140,6 +140,18 @@ static const unsigned char _font_3x5[129][5] = {
};



// union used to be sure char_bmp is 4-bytes aligned
union bmp_fast_4x6{
	unsigned char char_bmp[6]; // 4*6 bitmap, containing character and borders
	unsigned int fast[2]; // for fast operations
};


// used to store/restore a single character area
static union bmp_fast_4x6 _stored_char;


void term_prim_write_character(unsigned int posx, unsigned int posy, int front_c, int back_c, char c, void *vram) {

	unsigned int backcolor, frontcolor;
@@ -152,11 +164,7 @@ void term_prim_write_character(unsigned int posx, unsigned int posy, int front_c
			&& (y>-5) && (y<64))
	{
		const unsigned char *raw_char;
		// union used to be sure char_bmp is 4-bytes aligned
		union {
			unsigned char char_bmp[6]; // 6*4 bitmap, containing character and borders
			unsigned int fast[2]; // for fast operations
		} bmp;
		union bmp_fast_4x6 bmp;

		if(c>=0)
			raw_char = _font_3x5[(int)c];
@@ -178,6 +186,33 @@ void term_prim_write_character(unsigned int posx, unsigned int posy, int front_c
}


void term_prim_store_character(unsigned int posx, unsigned int posy,
		void *vram)
{
	int x = posx * 4;
	int y = posy * 6;
	int i, j;

	// the algorithm used here is... hum... a bit stupid and slow?
	for(j=0; j<6; j++) {
		char curline = 0x00;
		for(i=0; i<4; i++) {
			curline |= (disp_mono_get_pixel(x+i, y+j, vram)) << i;
		}
		_stored_char.char_bmp[j] = curline;
	}
}


void term_prim_restore_character(unsigned int posx, unsigned int posy,
		void *vram)
{
	int x = posx * 4;
	int y = posy * 6;
	disp_mono_draw_bitmap(x, y, _stored_char.char_bmp, 4, 6, vram);
}


void term_prim_scroll_up(void *vram, int back_c) {
	int i;
	unsigned int *l_vram = (unsigned int*)vram;
+15 −1
Original line number Diff line number Diff line
@@ -7,11 +7,25 @@


#define FX9860_TERM_CURSOR_CHAR	((char)177)


/**
 * write a character with the terminal font
 */
void term_prim_write_character(unsigned int posx, unsigned int posy, int front_c, int back_c, char c, void *vram);
void term_prim_write_character(unsigned int posx, unsigned int posy,
		int front_c, int back_c, char c, void *vram);


/**
 * Special set of functions designed for cursor implementation.
 * Save/restore the VRAM content of a character location (saved internally
 * in a single slot, so each call to term_prim_store_character() destroy the
 * previously stored data).
 */
void term_prim_store_character(unsigned int posx, unsigned int posy,
		void *vram);
void term_prim_restore_character(unsigned int posx, unsigned int posy,
		void *vram);

/**
 * Scroll up the terminal display from 1 character high
Loading