void FPS_Draw(MDFN_Surface *target, const int xpos, const int ypos) { if(!isactive) return; const uint32 bg_color = target->MakeColor(0, 0, 0); const uint32 text_color = target->MakeColor(0xFF, 0xFF, 0xFF); char virtfps[64], drawnfps[64], blitfps[64]; CalcFramerates(virtfps, drawnfps, blitfps, 64); MDFN_DrawRectangleFill(target->pixels, target->pitch32, xpos, ypos, bg_color, bg_color, box_width, box_height); DrawTextTrans(target->pixels + xpos + ypos * target->pitch32, target->pitch32 << 2, box_width, (UTF8*)virtfps, text_color, FALSE, TRUE); DrawTextTrans(target->pixels + xpos + (ypos + 7) * target->pitch32, target->pitch32 << 2, box_width, (UTF8*)drawnfps, text_color, FALSE, TRUE); DrawTextTrans(target->pixels + xpos + (ypos + 7 * 2) * target->pitch32, target->pitch32 << 2, box_width, (UTF8*)blitfps, text_color, FALSE, TRUE); }
void DrawStateMovieRow(SDL_Surface *surface, int *nstatus, int cur, int recently_saved, uint8 *text) { uint32 *XBuf = (uint32 *)surface->pixels; uint32 pitch32 = surface->pitch >> 2; int x, y; for(y=0; y<40; y++) for(x=0;x<230;x++) XBuf[x + y * pitch32] = MK_COLOR_A(surface, 0x00, 0x00, 0x00, 170); // nstatus for(int i = 1; i < 11; i++) { char stringie[2]; uint32 bordercol; if(cur == (i % 10)) bordercol = MK_COLOR_A(surface, 0x60, 0x20, 0xb0, 0xFF); else bordercol = MK_COLOR_A(surface, 0, 0, 0, 0xFF); stringie[0] = '0' + (i % 10); stringie[1] = 0; //if(nstatus[i % 10]) { uint32 rect_bg_color = MK_COLOR_A(surface, 0x00, 0x00, 0x00, 0xFF); if(nstatus[i % 10]) { rect_bg_color = MK_COLOR_A(surface, 0x00, 0x38, 0x28, 0xFF); if(recently_saved == (i % 10)) rect_bg_color = MK_COLOR_A(surface, 0x48, 0x00, 0x34, 0xFF); } MDFN_DrawRectangleFill(XBuf, pitch32, (i - 1) * 23, 0, bordercol, rect_bg_color, 23, 18 + 1); } //else // MDFN_DrawRectangle(XBuf, pitch32, (i - 1) * 23, 0, bordercol, 23, 18 + 1); DrawTextTransShadow(XBuf + (i - 1) * 23 + 7, pitch32 << 2, 230, (UTF8*)stringie, MK_COLOR_A(surface, 0xE0, 0xFF, 0xE0, 0xFF), MK_COLOR_A(surface, 0x00, 0x00, 0x00, 0xFF), FALSE); } DrawTextTransShadow(XBuf + 20 * pitch32, pitch32 << 2, 230, text, MK_COLOR_A(surface, 0xE0, 0xFF, 0xE0, 0xFF), MK_COLOR_A(surface, 0x00, 0x00, 0x00, 0xFF), TRUE); }
// Call this function from the main thread void MemDebugger_Draw(MDFN_Surface *surface, const MDFN_Rect *rect, const MDFN_Rect *screen_rect) { if(!IsActive) return; const MDFN_PixelFormat pf_cache = surface->format; uint32 *pixels = surface->pixels; uint32 pitch32 = surface->pitchinpix; const uint64 zemod = SizeCache[CurASpace]; LockGameMutex(1); DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)ASpace->long_name, MK_COLOR_A(0x20, 0xFF, 0x20, 0xFF), 1, 1); pixels += 10 * pitch32; uint32 A; uint32 Ameow; // A meow for a cat if(ASpacePos[CurASpace] < 128) A = (SizeCache[CurASpace] - 128 + ASpacePos[CurASpace]) % SizeCache[CurASpace]; else A = ASpacePos[CurASpace] - 128; Ameow = A &~ 0xF; int numrows = zemod / 16; if(numrows > 16) numrows = 16; else if(numrows < 4) numrows = 4; for(int y = 0; y < numrows; y++) { uint8 byte_buffer[16]; char abuf[32]; Ameow %= zemod; ASpace->GetAddressSpaceBytes(ASpace->name, Ameow, 16, byte_buffer); if(zemod <= (1 << 16)) trio_snprintf(abuf, 32, "%04X:", Ameow); else if(zemod <= (1 << 24)) trio_snprintf(abuf, 32, "%06X:", Ameow); else trio_snprintf(abuf, 32, "%08X:", Ameow); uint32 alen; uint32 addr_color = MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF); if(Ameow == (ASpacePos[CurASpace] & ~0xF)) addr_color = MK_COLOR_A(0x80, 0xB0, 0xFF, 0xFF); alen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)abuf, addr_color, 0, 1); alen += 3; for(int x = 0; x < 16; x++) { uint32 bcolor = MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF); uint32 acolor = MK_COLOR_A(0xA0, 0xA0, 0xA0, 0xFF); char quickbuf[16]; uint32 test_match_pos; uint8 ascii_str[2]; ascii_str[1] = 0; ascii_str[0] = byte_buffer[x]; if(ascii_str[0] < 0x20 || ascii_str[0] >= 128) ascii_str[0] = '.'; trio_snprintf(quickbuf, 16, "%02X", byte_buffer[x]); test_match_pos = ASpacePos[CurASpace] % zemod; if(InMarkMode) { if(MarkModeBegin < test_match_pos && Ameow < test_match_pos && Ameow >= MarkModeBegin) { if(InTextArea) { acolor = MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF); bcolor = MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF); } else { acolor = MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF); bcolor = MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF); } } } if(Ameow == test_match_pos) { if(InEditMode) if(SDL_GetTicks() & 0x80) { int pix_offset = alen; if(InTextArea) pix_offset += 16 * 12 + x * 5; else pix_offset += (LowNib ? 5 : 0) + x * 12; DrawTextTrans(pixels + pix_offset, surface->pitchinpix << 2, rect->w, (UTF8*)"▉", MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1); } if(InTextArea) { acolor = MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF); bcolor = MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF); } else { acolor = MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF); bcolor = MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF); } } // hex display DrawTextTrans(pixels + alen + x * 12, surface->pitchinpix << 2, rect->w, (UTF8*)quickbuf, bcolor, 0, 1); // ASCII display DrawTextTrans(pixels + alen + 16 * 12 + x * 5, surface->pitchinpix << 2, rect->w, (UTF8 *)ascii_str, acolor, 0, 1); Ameow++; } pixels += 9 * pitch32; } { char cpstr[32]; uint32 curpos = ASpacePos[CurASpace]; uint8 zebytes[4]; uint32 tmpval; curpos %= zemod; ASpace->GetAddressSpaceBytes(ASpace->name, curpos, 4, zebytes); pixels += 8 + 5 * pitch32; if(zemod <= (1 << 16)) trio_snprintf(cpstr, 32, "%04X", curpos); else if(zemod <= (1 << 24)) trio_snprintf(cpstr, 32, "%06X", curpos); else trio_snprintf(cpstr, 32, "%08X", curpos); uint32 cpplen; uint32 cplen; cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"Cursor position: ", MK_COLOR_A(0xa0, 0xa0, 0xFF, 0xFF), 0, 1); cplen = DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1); if(GoGoPowerDD[CurASpace]) { char ggddstr[32]; if(zemod <= (1 << 16)) trio_snprintf(ggddstr, 32, "%04X", curpos - GoGoPowerDD[CurASpace]); else if(zemod <= (1 << 24)) trio_snprintf(ggddstr, 32, "%06X", curpos - GoGoPowerDD[CurASpace]); else trio_snprintf(ggddstr, 32, "%08X", curpos - GoGoPowerDD[CurASpace]); DrawTextTrans(pixels + cpplen + cplen + 8, surface->pitchinpix << 2, rect->w, (UTF8*)ggddstr, MK_COLOR_A(0xFF, 0x80, 0x80, 0xFF), 0, 1); } pixels += 5 + 10 * pitch32; tmpval = zebytes[0]; trio_snprintf(cpstr, 32, "%02x(%u, %d)", tmpval, (uint8)tmpval, (int8)tmpval); cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"1-byte value: ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1); DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1); pixels += 10 * pitch32; if(ASpace->IsWave && SizeCache[CurASpace] <= 128 && ASpace->WaveBits <= 6) { const int32 wf_size = SizeCache[CurASpace]; uint8 waveform[wf_size]; const int32 pcm_max = (1 << ASpace->WaveBits) - 1; DrawTextTrans(pixels - 5, surface->pitchinpix << 2, rect->w, (UTF8 *)"Full waveform:", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1); pixels += 9 * pitch32; MDFN_DrawRectangleFill(pixels, surface->pitchinpix, 0, 0, MK_COLOR_A(0xA0,0xA0,0xA0,0xFF), MK_COLOR_A(0,0,0,0xFF), 2 + wf_size * 2 + 2, 2 + (pcm_max + 1) + 2); ASpace->GetAddressSpaceBytes(ASpace->name, 0, wf_size, waveform); for(int i = 0; i < wf_size; i++) { int32 delta; int32 current; int32 previous; current = waveform[i]; previous = waveform[(i + wf_size - 1) % wf_size]; delta = current - previous; for(int y = previous; y != current; y += delta / abs(delta)) pixels[2 + i * 2 + 0 + (2 + (pcm_max - y)) * surface->pitchinpix] = MK_COLOR_A(0x00,0xA0,0x00,0xFF); pixels[2 + i * 2 + 0 + (2 + (pcm_max - current)) * surface->pitchinpix] = MK_COLOR_A(0x00,0xA0,0x00,0xFF); pixels[2 + i * 2 + 1 + (2 + (pcm_max - current)) * surface->pitchinpix] = MK_COLOR_A(0x00,0xA0,0x00,0xFF); } } else { tmpval = zebytes[0] | (zebytes[1] << 8); trio_snprintf(cpstr, 32, "%04x(%u, %d)", tmpval, (uint16)tmpval, (int16)tmpval); cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"2-byte value(LSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1); DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1); pixels += 10 * pitch32; tmpval = zebytes[0] | (zebytes[1] << 8) | (zebytes[2] << 16) | (zebytes[3] << 24); trio_snprintf(cpstr, 32, "%08x(%u, %d)", tmpval, (uint32)tmpval, (int32)tmpval); cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"4-byte value(LSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1); DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1); pixels += 10 * pitch32; tmpval = zebytes[1] | (zebytes[0] << 8); trio_snprintf(cpstr, 32, "%04x(%u, %d)", tmpval, (uint16)tmpval, (int16)tmpval); cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"2-byte value(MSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1); DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1); pixels += 10 * pitch32; tmpval = zebytes[3] | (zebytes[2] << 8) | (zebytes[1] << 16) | (zebytes[0] << 24); trio_snprintf(cpstr, 32, "%08x(%u, %d)", tmpval, (uint32)tmpval, (int32)tmpval); cpplen = DrawTextTrans(pixels, surface->pitchinpix << 2, rect->w, (UTF8*)"4-byte value(MSB): ", MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, 1); DrawTextTrans(pixels + cpplen, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr , MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, 1); trio_snprintf(cpstr, 32, "%s text: ", GameCode); cpplen = DrawTextTrans(pixels + 10 * pitch32, surface->pitchinpix << 2, rect->w, (UTF8*)cpstr, MK_COLOR_A(0xA0, 0xA0, 0xFF, 0xFF), 0, MDFN_FONT_5x7); { char rawbuf[64]; char textbuf[256]; ASpace->GetAddressSpaceBytes(ASpace->name, curpos, 64, (uint8*)rawbuf); size_t ibl, obl, obl_start; char *inbuf, *outbuf; ibl = 64; obl_start = obl = 255; // Hehe, ugly maximum estimation! inbuf = rawbuf; outbuf = textbuf; iconv(ict_to_utf8, (ICONV_CONST char **)&inbuf, &ibl, &outbuf, &obl); textbuf[obl_start - obl] = 0; DrawTextTrans(pixels + 8 * pitch32 + cpplen, surface->pitchinpix << 2, rect->w - cpplen - 13, (UTF8*)textbuf, MK_COLOR_A(0xFF, 0xFF, 0xFF, 0xFF), 0, MDFN_FONT_9x18_18x18); } } } LockGameMutex(0); if(InPrompt) myprompt->Draw(surface, rect); else if(myprompt) { delete myprompt; myprompt = NULL; } if(error_string) { if(SDL_GetTicks() >= (error_time + 4000)) { free(error_string); error_string = NULL; } else { DrawTextTrans((uint32*)surface->pixels + (rect->h - 7) * pitch32, surface->pitchinpix << 2, rect->w, (UTF8*)error_string, MK_COLOR_A(0xFF, 0x00, 0x00, 0xFF), 1, 1); } } }