gfx.c
changeset 1390 e7cdf3ce0fb6
parent 1357 0a4c07b68673
child 1806 5a55d508c23e
equal deleted inserted replaced
1389:fe967eec43d1 1390:e7cdf3ce0fb6
   242 // 11-14 -
   242 // 11-14 -
   243 // 15-31 - 17 colors
   243 // 15-31 - 17 colors
   244 
   244 
   245 
   245 
   246 enum {
   246 enum {
   247 	ASCII_LETTERSTART = 32,
       
   248 
       
   249 	ASCII_SETX = 1,
   247 	ASCII_SETX = 1,
   250 	ASCII_SETXY = 2,
   248 	ASCII_SETXY = 2,
   251 
   249 
   252 	ASCII_TINYFONT = 8,
   250 	ASCII_TINYFONT = 8,
   253 	ASCII_BIGFONT = 9,
   251 	ASCII_BIGFONT = 9,
   307 		w = 0;
   305 		w = 0;
   308 		last_space = NULL;
   306 		last_space = NULL;
   309 
   307 
   310 		for(;;) {
   308 		for(;;) {
   311 			c = *str++;
   309 			c = *str++;
   312 			if (c == ' ') last_space = str;
   310 			if (c == ASCII_LETTERSTART) last_space = str;
   313 
   311 
   314 			if (c >= ASCII_LETTERSTART) {
   312 			if (c >= ASCII_LETTERSTART) {
   315 				w += _stringwidth_table[base + ((byte)c) - 0x20];
   313 				w += GetCharacterWidth(base + (byte)c);
   316 				if (w > maxw) {
   314 				if (w > maxw) {
   317 					str = last_space;
   315 					str = last_space;
   318 					if (str == NULL)
   316 					if (str == NULL)
   319 						return num + (base << 16);
   317 						return num + (base << 16);
   320 					break;
   318 					break;
   426 	}
   424 	}
   427 }
   425 }
   428 
   426 
   429 int GetStringWidth(const char *str)
   427 int GetStringWidth(const char *str)
   430 {
   428 {
   431 	int w = -1;
   429 	int w = 0;
   432 	byte c;
   430 	byte c;
   433 	int base = _stringwidth_base;
   431 	int base = _stringwidth_base;
   434 
   432 	for (c = *str; c != '\0'; c = *(++str)) {
   435 	for(;;) {
       
   436 		c = *str++;
       
   437 		if (c == 0)
       
   438 			return w;
       
   439 		if (c >= ASCII_LETTERSTART) {
   433 		if (c >= ASCII_LETTERSTART) {
   440 			w += _stringwidth_table[base + c - ASCII_LETTERSTART];
   434 			w += GetCharacterWidth(base + c);
   441 		} else {
   435 		} else {
   442 			if (c == ASCII_SETX) str++;
   436 			if (c == ASCII_SETX) str++;
   443 			else if (c == ASCII_SETXY) str += 2;
   437 			else if (c == ASCII_SETXY) str += 2;
   444 			else if (c == ASCII_TINYFONT) base = 224;
   438 			else if (c == ASCII_TINYFONT) base = 224;
   445 			else if (c == ASCII_BIGFONT) base = 448;
   439 			else if (c == ASCII_BIGFONT) base = 448;
   446 		}
   440 		}
   447 	}
   441 	}
       
   442 	return w;
   448 }
   443 }
   449 
   444 
   450 void DrawFrameRect(int left, int top, int right, int bottom, int ctab, int flags) {
   445 void DrawFrameRect(int left, int top, int right, int bottom, int ctab, int flags) {
   451 	byte color_2 = _color_list[ctab].window_color_1a;
   446 	byte color_2 = _color_list[ctab].window_color_1a;
   452 	byte color_interior = _color_list[ctab].window_color_bga;
   447 	byte color_interior = _color_list[ctab].window_color_bga;
   529 		if (c >= ASCII_LETTERSTART) {
   524 		if (c >= ASCII_LETTERSTART) {
   530 			if (x >= dpi->left + dpi->width) goto skip_char;
   525 			if (x >= dpi->left + dpi->width) goto skip_char;
   531 			if (x + 26 >= dpi->left) {
   526 			if (x + 26 >= dpi->left) {
   532 				GfxMainBlitter(GetSprite(base + 2 + c - ASCII_LETTERSTART), x, y, 1);
   527 				GfxMainBlitter(GetSprite(base + 2 + c - ASCII_LETTERSTART), x, y, 1);
   533 			}
   528 			}
   534 			x += _stringwidth_table[base + c - ' '];
   529 			x += GetCharacterWidth(base + c);
   535 		} else if (c == ASCII_NL) { // newline = {}
   530 		} else if (c == ASCII_NL) { // newline = {}
   536 			x = xo;
   531 			x = xo;
   537 			y += 10;
   532 			y += 10;
   538 			if (base != 0) {
   533 			if (base != 0) {
   539 				y -= 4;
   534 				y -= 4;