MCPcopy Create free account
hub / github.com/TASEmulators/fceux / DrawTextTransWH

Function DrawTextTransWH

src/drawing.cpp:405–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403char target[64][256];
404
405void DrawTextTransWH(uint8 *dest, int width, uint8 *textmsg, uint8 fgcolor, int max_w, int max_h, int border)
406{
407 int beginx=2, x=beginx;
408 int y=2;
409
410 memset(target, 0, 64 * 256);
411
412 assert(width==256);
413 if (max_w > 256) max_w = 256;
414 if (max_h > 64) max_h = 64;
415
416 int ch = 0, wid = 0, nx = 0, ny = 0, max_x = x, offs = 0;
417 int pixel_color;
418 for(; *textmsg; ++textmsg)
419 {
420 if(*textmsg == '\n')
421 {
422 // new line
423 x = beginx;
424 y += 8;
425 continue;
426 }
427 ch = FixJoedChar(*textmsg);
428 wid = Font6x7[ch * 8];
429
430 if ((x + wid) >= (int)width)
431 {
432 // wrap to new line
433 x = beginx;
434 y += 8;
435 }
436
437 for(ny = 0; ny < 7; ++ny)
438 {
439 uint8 d = Font6x7[ch * 8 + 1 + ny];
440 for(nx = 0; nx < wid; ++nx)
441 {
442 pixel_color = (d >> (7 - nx)) & 1;
443 if (pixel_color)
444 {
445 if (y + ny >= 62)
446 {
447 // Max border is 2, so the max safe y is 62 (since 64 is the max for the target array
448 goto textoverflow;
449 }
450 target[y + ny][x + nx] = 2;
451 } else
452 {
453 target[y + ny][x + nx] = 1;
454 }
455 }
456 }
457 // proceed to next char
458 x += wid;
459 if (max_x < x)
460 max_x = x;
461
462 }

Callers 1

DrawTextTransFunction · 0.85

Calls 1

FixJoedCharFunction · 0.70

Tested by

no test coverage detected