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

Function LuaDrawTextTransWH

src/lua-engine.cpp:4564–4634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4562}
4563
4564void LuaDrawTextTransWH(const char *str, size_t l, int &x, int y, uint32 color, uint32 backcolor)
4565{
4566 int Opac = (color >> 24) & 0xFF;
4567 int backOpac = (backcolor >> 24) & 0xFF;
4568 int origX = x;
4569
4570 if(!Opac && !backOpac)
4571 return;
4572
4573 size_t len = l;
4574 //int defaultAlpha = std::max<int>(0, std::min<int>(transparencyModifier, 255));
4575 int diffx;
4576 int diffy = std::max<int>(0, std::min<int>(7, LUA_SCREEN_HEIGHT - y));
4577
4578 while(*str && len && y < LUA_SCREEN_HEIGHT)
4579 {
4580 int c = *str++;
4581 while (x >= LUA_SCREEN_WIDTH && c != '\n') {
4582 c = *str;
4583 if (c == '\0')
4584 break;
4585 str++;
4586 if (!(--len))
4587 break;
4588 }
4589 if(c == '\n')
4590 {
4591 x = origX;
4592 y += 8;
4593 diffy = std::max<int>(0, std::min<int>(7, LUA_SCREEN_HEIGHT - y));
4594 continue;
4595 }
4596 else if(c == '\t') // just in case
4597 {
4598 const int tabSpace = 8;
4599 x += (tabSpace-(((x-origX)/8)%tabSpace))*8;
4600 continue;
4601 }
4602
4603 diffx = std::max<int>(0, std::min<int>(7, LUA_SCREEN_WIDTH - x));
4604 int ch = FixJoedChar(c);
4605 int wid = std::min<int>(diffx, JoedCharWidth(c));
4606
4607 for(int y2 = 0; y2 < diffy; y2++)
4608 {
4609 uint8 d = FCEUFont[ch*8 + 1+y2];
4610 for(int x2 = 0; x2 < wid; x2++)
4611 {
4612 int c = (d >> (7-x2)) & 1;
4613 if(c)
4614 gui_drawpixel_internal(x+x2, y+y2, color);
4615 else
4616 gui_drawpixel_internal(x+x2, y+y2, backcolor);
4617 }
4618 }
4619
4620 // halo
4621 if(diffy >= 7)

Callers 1

gui_textFunction · 0.85

Calls 3

JoedCharWidthFunction · 0.85
gui_drawpixel_internalFunction · 0.85
FixJoedCharFunction · 0.70

Tested by

no test coverage detected