From 988043e73eb4222e8370043644c7e61fc281b105 Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Tue, 24 Jun 2025 21:29:47 +0800 Subject: [PATCH] add border for emulator --- emulator.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/emulator.c b/emulator.c index 8812622..c713c1a 100644 --- a/emulator.c +++ b/emulator.c @@ -7,8 +7,8 @@ #define BITMAP_WIDTH 400 #define BITMAP_HEIGHT 300 -#define WINDOW_WIDTH 420 -#define WINDOW_HEIGHT 340 +#define WINDOW_WIDTH 450 +#define WINDOW_HEIGHT 380 #define WINDOW_TITLE TEXT("Emurator") // Global variables @@ -162,6 +162,24 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) FillRect(hdc, &clientRect, bgBrush); DeleteObject(bgBrush); + // Calculate border position (same as bitmap position) + int scale = 1; + int drawX = (clientRect.right - BITMAP_WIDTH * scale) / 2; + int drawY = (clientRect.bottom - BITMAP_HEIGHT * scale) / 2; + + // Draw border around the bitmap area + HPEN borderPen = CreatePen(PS_DOT, 1, RGB(0, 0, 255)); + HPEN oldPen = SelectObject(hdc, borderPen); + HBRUSH oldBrush = SelectObject(hdc, GetStockObject(NULL_BRUSH)); // No fill + + Rectangle(hdc, drawX - 1, drawY - 1, + drawX + BITMAP_WIDTH * scale + 1, + drawY + BITMAP_HEIGHT * scale + 1); + + SelectObject(hdc, oldPen); + SelectObject(hdc, oldBrush); + DeleteObject(borderPen); + // Use the stored timestamp gui_data_t data = { .color = g_bwr_mode ? 2 : 1,