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

Function PutTextInternal

src/lua-engine.cpp:4314–4393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4312};
4313
4314static void PutTextInternal (const char *str, int len, short x, short y, int color, int backcolor)
4315{
4316 int Opac = (color >> 24) & 0xFF;
4317 int backOpac = (backcolor >> 24) & 0xFF;
4318 int origX = x;
4319
4320 if(!Opac && !backOpac)
4321 return;
4322
4323 while(*str && len && y < LUA_SCREEN_HEIGHT)
4324 {
4325 int c = *str++;
4326 while (x > LUA_SCREEN_WIDTH && c != '\n') {
4327 c = *str;
4328 if (c == '\0')
4329 break;
4330 str++;
4331 }
4332 if(c == '\n')
4333 {
4334 x = origX;
4335 y += 8;
4336 continue;
4337 }
4338 else if(c == '\t') // just in case
4339 {
4340 const int tabSpace = 8;
4341 x += (tabSpace-(((x-origX)/4)%tabSpace))*4;
4342 continue;
4343 }
4344 if((unsigned int)(c-32) >= 96)
4345 continue;
4346 const unsigned char* Cur_Glyph = (const unsigned char*)&Small_Font_Data + (c-32)*7*4;
4347
4348 for(int y2 = 0; y2 < 8; y2++)
4349 {
4350 unsigned int glyphLine = *((unsigned int*)Cur_Glyph + y2);
4351 for(int x2 = -1; x2 < 4; x2++)
4352 {
4353 int shift = x2 << 3;
4354 int mask = 0xFF << shift;
4355 int intensity = (glyphLine & mask) >> shift;
4356
4357 if(intensity && x2 >= 0 && y2 < 7)
4358 {
4359 //int xdraw = std::max(0,std::min(LUA_SCREEN_WIDTH - 1,x+x2));
4360 //int ydraw = std::max(0,std::min(LUA_SCREEN_HEIGHT - 1,y+y2));
4361 //gui_drawpixel_fast(xdraw, ydraw, color);
4362 gui_drawpixel_internal(x+x2, y+y2, color);
4363 }
4364 else if(backOpac)
4365 {
4366 for(int y3 = std::max<int>(0,y2-1); y3 <= std::min<int>(6,y2+1); y3++)
4367 {
4368 unsigned int glyphLine = *((unsigned int*)Cur_Glyph + y3);
4369 for(int x3 = std::max<int>(0,x2-1); x3 <= std::min<int>(3,x2+1); x3++)
4370 {
4371 int shift = x3 << 3;

Callers 1

LuaDisplayStringFunction · 0.85

Calls 1

gui_drawpixel_internalFunction · 0.85

Tested by

no test coverage detected