Esempio n. 1
0
int BFM_BD1_newdata(int id, int data)
{
	int change = 0;
	int cursor;

	if ( bd1[id].user_def )
	{
		bd1[id].user_def--;

		bd1[id].user_data <<= 8;
		bd1[id].user_data |= data;

		if ( bd1[id].user_def )
		{
			return 0;
		}

	data = '@';
	change = BD1_setdata(id, bd1[id].user_def, data);
	}
	else
	{
	}

	switch ( data & 0xF0 )
	{
		case 0x80:	// 0x80 - 0x8F Set display blanking

		bd1[id].display_blanking = data & 0x0F;
		change = 1;
		break;

		case 0x90:	// 0x90 - 0x9F Set cursor pos

		bd1[id].cursor_pos = data & 0x0F;

		bd1[id].scroll_active = 0;
		if ( bd1[id].display_mode == 2 )
		{
			if ( bd1[id].cursor_pos >= bd1[id].window_end) bd1[id].scroll_active = 1;
		}
		break;

		case 0xA0:	// 0xA0 - 0xAF Set display mode

		bd1[id].display_mode = data &0x03;
		break;

		case 0xB0:	// 0xB0 - 0xBF Clear display area

		switch ( data & 0x03 )
		{
			case 0x00:	// clr nothing
			break;

			case 0x01:	// clr inside window

			if ( bd1[id].window_size > 0 )
			{
				memset( bd1[id].string+bd1[id].window_start, ' ',bd1[id].window_size );
			}
			break;

			case 0x02:	// clr outside window

			if ( bd1[id].window_size > 0 )
			{
				if ( bd1[id].window_start > 0 )
				{
					memset( bd1[id].string, ' ', bd1[id].window_start);
					for (cursor = 0; cursor < bd1[id].window_start; cursor++)
					{
						bd1[id].segments[cursor] = 0x0000;
					}
				}

				if (bd1[id].window_end < 15 )
				{
					memset( bd1[id].string+bd1[id].window_end, ' ', 15-bd1[id].window_end);
					for (cursor = bd1[id].window_end; cursor < 15-bd1[id].window_end; cursor++)
					{
						bd1[id].segments[cursor] = 0x0000;
					}

				}
			}
			case 0x03:	// clr entire display

			memset(bd1[id].string, ' ' , 16);
			for (cursor = 0; cursor < 16; cursor++)
			{
				bd1[id].segments[cursor] = 0x0000;
			}
			break;
		}
		change = 1;
		break;

		case 0xC0:	// 0xC0 - 0xCF Set flash rate

		bd1[id].flash_rate = data & 0x0F;
		break;

		case 0xD0:	// 0xD0 - 0xDF Set Flash control

		bd1[id].flash_control = data & 0x03;
		break;

		case 0xE0:	// 0xE0 - 0xEF Set window start pos

		bd1[id].window_start = data &0x0F;
		bd1[id].window_size  = (bd1[id].window_end - bd1[id].window_start)+1;
		break;

		case 0xF0:	// 0xF0 - 0xFF Set window end pos

		bd1[id].window_end   = data &0x0F;
		bd1[id].window_size  = (bd1[id].window_end - bd1[id].window_start)+1;

		bd1[id].scroll_active = 0;
		if ( bd1[id].display_mode == 2 )
		{
			if ( bd1[id].cursor_pos >= bd1[id].window_end)
			{
				bd1[id].scroll_active = 1;
				bd1[id].cursor_pos    = bd1[id].window_end;
			}
		}
		break;

		default:	// normal character

		change = BD1_setdata(id, BD1charset[data & 0x3F], data);
		break;
	}
	return change;
}
Esempio n. 2
0
int vfd_newdata(int id, int data)
{
	int change = 0;
	int cursor;

	switch ( vfds[id].type )
	{
		case VFDTYPE_BFMBD1:

		if ( vfds[id].user_def )
		{
			vfds[id].user_def--;

			vfds[id].user_data <<= 8;
			vfds[id].user_data |= data;

			if ( vfds[id].user_def )
			{
				return 0;
			}

		data = '@';
		change = BD1_setdata(id, vfds[id].user_def, data);
		}
		else
		{
		}

		switch ( data & 0xF0 )
		{
			case 0x80:	/* 0x80 - 0x8F Set display blanking */

			vfds[id].display_blanking = data & 0x0F;
			change = 1;
			break;

			case 0x90:	/* 0x90 - 0x9F Set cursor pos */

			vfds[id].cursor_pos = data & 0x0F;

			vfds[id].scroll_active = 0;
			if ( vfds[id].display_mode == 2 )
			{
				if ( vfds[id].cursor_pos >= vfds[id].window_end) vfds[id].scroll_active = 1;
			}
			break;

			case 0xA0:	/* 0xA0 - 0xAF Set display mode */

			vfds[id].display_mode = data &0x03;
			break;

			case 0xB0:	/* 0xB0 - 0xBF Clear display area */

			switch ( data & 0x03 )
			{
				case 0x00:	/* clr nothing */
				break;

				case 0x01:	/* clr inside window */

				if ( vfds[id].window_size > 0 )
					{
						memset( vfds[id].string+vfds[id].window_start, ' ',vfds[id].window_size );
					}
					break;

				case 0x02:	/* clr outside window */

				if ( vfds[id].window_size > 0 )
					{
						if ( vfds[id].window_start > 0 )
						{
							memset( vfds[id].string, ' ', vfds[id].window_start);
							for (cursor = 0; cursor < vfds[id].window_start; cursor++)
							{
								vfds[id].segments[cursor] = 0x0000;
							}
						}

						if (vfds[id].window_end < 15 )
						{
							memset( vfds[id].string+vfds[id].window_end, ' ', 15-vfds[id].window_end);
							for (cursor = vfds[id].window_end; cursor < 15-vfds[id].window_end; cursor++)
							{
								vfds[id].segments[cursor] = 0x0000;
							}

						}
					}
				case 0x03:	/* clr entire display */

				memset(vfds[id].string, ' ' , 16);
				for (cursor = 0; cursor < 16; cursor++)
				{
				vfds[id].segments[cursor] = 0x0000;
				}
				break;
			}
			change = 1;
			break;

			case 0xC0:	/* 0xC0 - 0xCF Set flash rate */

			vfds[id].flash_rate = data & 0x0F;
			break;

			case 0xD0:	/* 0xD0 - 0xDF Set Flash control */

			vfds[id].flash_control = data & 0x03;
			break;

			case 0xE0:	/* 0xE0 - 0xEF Set window start pos */

			vfds[id].window_start = data &0x0F;
			vfds[id].window_size  = (vfds[id].window_end - vfds[id].window_start)+1;
			break;

			case 0xF0:	/* 0xF0 - 0xFF Set window end pos */

			vfds[id].window_end   = data &0x0F;
			vfds[id].window_size  = (vfds[id].window_end - vfds[id].window_start)+1;

			vfds[id].scroll_active = 0;
			if ( vfds[id].display_mode == 2 )
			{
				if ( vfds[id].cursor_pos >= vfds[id].window_end)
				{
					vfds[id].scroll_active = 1;
					vfds[id].cursor_pos    = vfds[id].window_end;
				}
			}
			break;

			default:	/* normal character */

			change = BD1_setdata(id, BFMcharset[data & 0x3F], data);
			break;
		}
		break;

		case VFDTYPE_MSC1937:

		if ( data & 0x80 )
		{ /* Control data received */
			if ( (data & 0xF0) == 0xA0 ) /* 1010 xxxx */
			{ /* 1010 xxxx Buffer Pointer control */
				vfds[id].cursor_pos = poslut1937[data & 0x0F];
				logerror("CUR%d\n", vfds[id].cursor_pos);
			}
			else if ( (data & 0xF0) == 0xC0 ) /* 1100 xxxx */
				{ /* 1100 xxxx Set number of digits */
					data &= 0x07;

					if ( data == 0 ) vfds[id].window_size = 16;
					else             vfds[id].window_size = data+8;
					vfds[id].window_start = 0;
					vfds[id].window_end   = vfds[id].window_size-1;
				}
			else if ( (data & 0xE0) == 0xE0 ) /* 111x xxxx */
				{ /* 111x xxxx Set duty cycle ( brightness ) */
					vfds[id].brightness = (data & 0xF)*2;
					change = 1;
				}
			else if ( (data & 0xE0) == 0x80 ) /* 100x --- */
				{ /* 100x xxxx Test mode */
				}
		}
		else
		{ /* Display data */
			data &= 0x3F;
			change = 1;

			switch ( data )
			{
				case 0x2C: /* ; */
				case 0x2E: /* */

				vfds[id].segments[vfds[id].pcursor_pos] |= (1<<12);
				break;
				default :
				vfds[id].pcursor_pos = vfds[id].cursor_pos;
				vfds[id].string[ vfds[id].cursor_pos ] = OKI1937ASCII[data];
				vfds[id].segments[vfds[id].cursor_pos] = BFMcharset[data & 0x3F];

				vfds[id].cursor_pos++;
				if (  vfds[id].cursor_pos > vfds[id].window_end )
					{
						vfds[id].cursor_pos = 0;
					}
			}
		}
		break;
	}

	return change;
}