Skip to content

Commit 49561ec

Browse files
committed
feat: Add Windows UI components and memory management
- Add Windows window manager (FSTPWindowsWS) implementation - Create Windows-specific dialogs (About, Settings, Memory Locations) - Implement Windows clipboard support - Add memory mapping abstraction for Windows - Update main.cpp for Windows support - Modify FSTPAudioModule for cross-platform memory management
1 parent 1d4aa44 commit 49561ec

14 files changed

Lines changed: 777 additions & 9 deletions

source/modules/FSTPAudioModule/FSTPAudioModule_wrapper.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99
#include <chrono>
1010
#include <atomic>
1111

12-
// Headers for mmap
12+
// Headers for memory mapping
13+
#ifdef _WIN32
14+
#include "../FSTPMainModule/WSGUI/windows/FSTPMemoryMap.h"
15+
#include <io.h>
16+
#else
1317
#include <sys/mman.h>
1418
#include <unistd.h>
19+
#endif
1520
#include <fcntl.h>
1621
#include <cstdio>
1722

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef FSTP_BUILD_INFO_H
2+
#define FSTP_BUILD_INFO_H
3+
4+
// This file is auto-generated during build
5+
#define FSTP_VERSION "2026.01"
6+
#define FSTP_BUILD_NUMBER "854"
7+
#define FSTP_BUILD_DATE "17/10/2025"
8+
#define FSTP_CODE_NAME "Albatross"
9+
#define FSTP_BUILD_TYPE "Windows (SDL2/MinGW)"
10+
11+
#endif // FSTP_BUILD_INFO_H
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include "FSTPAboutDialog.h"
2+
#include "BuildInfo.h"
3+
#include <string>
4+
5+
FSTPAboutDialog::FSTPAboutDialog(HWND parentWindow)
6+
: hwndParent(parentWindow), hwndDialog(NULL), isVisible(false) {
7+
}
8+
9+
FSTPAboutDialog::~FSTPAboutDialog() {
10+
Hide();
11+
}
12+
13+
void FSTPAboutDialog::Show() {
14+
if (!hwndDialog) {
15+
// TODO: Create dialog using Windows API
16+
hwndDialog = CreateWindowEx(
17+
WS_EX_DLGMODALFRAME | WS_EX_TOPMOST,
18+
L"FSTPAboutDialogClass",
19+
L"About TapeXPlayer",
20+
WS_VISIBLE | WS_SYSMENU | WS_CAPTION,
21+
CW_USEDEFAULT, CW_USEDEFAULT,
22+
400, 300,
23+
hwndParent,
24+
NULL,
25+
GetModuleHandle(NULL),
26+
this
27+
);
28+
29+
if (hwndDialog) {
30+
isVisible = true;
31+
ShowWindow(hwndDialog, SW_SHOW);
32+
UpdateWindow(hwndDialog);
33+
}
34+
}
35+
}
36+
37+
void FSTPAboutDialog::Hide() {
38+
if (hwndDialog) {
39+
DestroyWindow(hwndDialog);
40+
hwndDialog = NULL;
41+
isVisible = false;
42+
}
43+
}
44+
45+
bool FSTPAboutDialog::IsVisible() const {
46+
return isVisible;
47+
}
48+
49+
INT_PTR CALLBACK FSTPAboutDialog::DialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
50+
switch (message) {
51+
case WM_INITDIALOG:
52+
return TRUE;
53+
54+
case WM_COMMAND:
55+
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
56+
EndDialog(hwnd, LOWORD(wParam));
57+
return TRUE;
58+
}
59+
break;
60+
61+
case WM_CLOSE:
62+
EndDialog(hwnd, IDCANCEL);
63+
return TRUE;
64+
}
65+
return FALSE;
66+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef FSTP_ABOUT_DIALOG_H
2+
#define FSTP_ABOUT_DIALOG_H
3+
4+
#include <windows.h>
5+
#include <SDL.h>
6+
#include "../FSTPWindowManager.h"
7+
8+
class FSTPAboutDialog {
9+
public:
10+
FSTPAboutDialog(HWND parentWindow);
11+
~FSTPAboutDialog();
12+
13+
void Show();
14+
void Hide();
15+
bool IsVisible() const;
16+
17+
private:
18+
HWND hwndDialog;
19+
HWND hwndParent;
20+
bool isVisible;
21+
22+
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
23+
};
24+
25+
#endif // FSTP_ABOUT_DIALOG_H
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#include "../FSTPScreenshotClipboard.h"
2+
#include <windows.h>
3+
4+
bool FSTPCopyScreenshotToClipboard(const uint8_t* rgbaData, int width, int height) {
5+
if (!rgbaData || width <= 0 || height <= 0) {
6+
return false;
7+
}
8+
9+
// Create DIB section
10+
BITMAPINFOHEADER bi = {0};
11+
bi.biSize = sizeof(BITMAPINFOHEADER);
12+
bi.biWidth = width;
13+
bi.biHeight = -height; // Negative height for top-down bitmap
14+
bi.biPlanes = 1;
15+
bi.biBitCount = 32;
16+
bi.biCompression = BI_RGB;
17+
18+
void* bits = nullptr;
19+
HBITMAP hBitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bi, DIB_RGB_COLORS, &bits, NULL, 0);
20+
if (!hBitmap) {
21+
return false;
22+
}
23+
24+
// Copy pixel data
25+
memcpy(bits, rgbaData, width * height * 4);
26+
27+
// Copy to clipboard
28+
if (OpenClipboard(NULL)) {
29+
EmptyClipboard();
30+
SetClipboardData(CF_BITMAP, hBitmap);
31+
CloseClipboard();
32+
return true;
33+
}
34+
35+
DeleteObject(hBitmap);
36+
return false;
37+
}
38+
39+
bool FSTPGetScreenshotFromClipboard(uint8_t** rgbaData, int* width, int* height) {
40+
if (!rgbaData || !width || !height) {
41+
return false;
42+
}
43+
44+
if (!OpenClipboard(NULL)) {
45+
return false;
46+
}
47+
48+
HBITMAP hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
49+
if (!hBitmap) {
50+
CloseClipboard();
51+
return false;
52+
}
53+
54+
BITMAP bm;
55+
GetObject(hBitmap, sizeof(BITMAP), &bm);
56+
57+
*width = bm.bmWidth;
58+
*height = bm.bmHeight;
59+
*rgbaData = new uint8_t[bm.bmWidth * bm.bmHeight * 4];
60+
61+
HDC hdc = GetDC(NULL);
62+
HDC hdcMem = CreateCompatibleDC(hdc);
63+
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBitmap);
64+
65+
BITMAPINFOHEADER bi = {0};
66+
bi.biSize = sizeof(BITMAPINFOHEADER);
67+
bi.biWidth = bm.bmWidth;
68+
bi.biHeight = -bm.bmHeight;
69+
bi.biPlanes = 1;
70+
bi.biBitCount = 32;
71+
bi.biCompression = BI_RGB;
72+
73+
GetDIBits(hdcMem, hBitmap, 0, bm.bmHeight, *rgbaData, (BITMAPINFO*)&bi, DIB_RGB_COLORS);
74+
75+
SelectObject(hdcMem, hOldBitmap);
76+
DeleteDC(hdcMem);
77+
ReleaseDC(NULL, hdc);
78+
79+
CloseClipboard();
80+
return true;
81+
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#include "FSTPMemoryLocationsWindow.h"
2+
#include <commctrl.h>
3+
#pragma comment(lib, "comctl32.lib")
4+
5+
FSTPMemoryLocationsWindow::FSTPMemoryLocationsWindow(HWND parentWindow)
6+
: hwndParent(parentWindow), hwndWindow(NULL), hwndList(NULL), isVisible(false) {
7+
}
8+
9+
FSTPMemoryLocationsWindow::~FSTPMemoryLocationsWindow() {
10+
Hide();
11+
}
12+
13+
void FSTPMemoryLocationsWindow::Show() {
14+
if (!hwndWindow) {
15+
// Register window class
16+
WNDCLASSEX wc = {0};
17+
wc.cbSize = sizeof(WNDCLASSEX);
18+
wc.lpfnWndProc = WindowProc;
19+
wc.hInstance = GetModuleHandle(NULL);
20+
wc.lpszClassName = L"FSTPMemoryLocationsWindowClass";
21+
RegisterClassEx(&wc);
22+
23+
// Create window
24+
hwndWindow = CreateWindowEx(
25+
0,
26+
L"FSTPMemoryLocationsWindowClass",
27+
L"Memory Locations",
28+
WS_OVERLAPPEDWINDOW,
29+
CW_USEDEFAULT, CW_USEDEFAULT,
30+
500, 400,
31+
hwndParent,
32+
NULL,
33+
GetModuleHandle(NULL),
34+
this
35+
);
36+
37+
if (hwndWindow) {
38+
CreateControls();
39+
isVisible = true;
40+
ShowWindow(hwndWindow, SW_SHOW);
41+
UpdateWindow(hwndWindow);
42+
}
43+
}
44+
}
45+
46+
void FSTPMemoryLocationsWindow::CreateControls() {
47+
// Initialize Common Controls
48+
INITCOMMONCONTROLSEX icex;
49+
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
50+
icex.dwICC = ICC_LISTVIEW_CLASSES;
51+
InitCommonControlsEx(&icex);
52+
53+
// Create ListView
54+
hwndList = CreateWindowEx(
55+
0,
56+
WC_LISTVIEW,
57+
L"",
58+
WS_CHILD | WS_VISIBLE | LVS_REPORT,
59+
0, 0, 0, 0, // Will be sized in WM_SIZE
60+
hwndWindow,
61+
(HMENU)1,
62+
GetModuleHandle(NULL),
63+
NULL
64+
);
65+
66+
// Add columns
67+
LVCOLUMN lvc;
68+
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
69+
70+
lvc.pszText = (LPWSTR)L"Address";
71+
lvc.cx = 100;
72+
ListView_InsertColumn(hwndList, 0, &lvc);
73+
74+
lvc.pszText = (LPWSTR)L"Value";
75+
lvc.cx = 100;
76+
ListView_InsertColumn(hwndList, 1, &lvc);
77+
78+
lvc.pszText = (LPWSTR)L"Description";
79+
lvc.cx = 200;
80+
ListView_InsertColumn(hwndList, 2, &lvc);
81+
82+
PopulateList();
83+
}
84+
85+
void FSTPMemoryLocationsWindow::PopulateList() {
86+
if (!hwndList) return;
87+
88+
ListView_DeleteAllItems(hwndList);
89+
90+
// TODO: Get actual memory locations from FSTPMemoryLocations
91+
// This is a placeholder implementation
92+
LVITEM lvi = {0};
93+
lvi.mask = LVIF_TEXT;
94+
lvi.iItem = 0;
95+
96+
// Example item
97+
lvi.iSubItem = 0;
98+
lvi.pszText = (LPWSTR)L"0x1000";
99+
ListView_InsertItem(hwndList, &lvi);
100+
101+
lvi.iSubItem = 1;
102+
lvi.pszText = (LPWSTR)L"0xFF";
103+
ListView_SetItem(hwndList, &lvi);
104+
105+
lvi.iSubItem = 2;
106+
lvi.pszText = (LPWSTR)L"Example Memory Location";
107+
ListView_SetItem(hwndList, &lvi);
108+
}
109+
110+
void FSTPMemoryLocationsWindow::Hide() {
111+
if (hwndWindow) {
112+
DestroyWindow(hwndWindow);
113+
hwndWindow = NULL;
114+
hwndList = NULL;
115+
isVisible = false;
116+
}
117+
}
118+
119+
void FSTPMemoryLocationsWindow::Update() {
120+
if (isVisible) {
121+
PopulateList();
122+
}
123+
}
124+
125+
bool FSTPMemoryLocationsWindow::IsVisible() const {
126+
return isVisible;
127+
}
128+
129+
LRESULT CALLBACK FSTPMemoryLocationsWindow::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
130+
switch (uMsg) {
131+
case WM_SIZE:
132+
if (HWND hwndList = GetDlgItem(hwnd, 1)) {
133+
SetWindowPos(hwndList, NULL,
134+
0, 0, LOWORD(lParam), HIWORD(lParam),
135+
SWP_NOZORDER);
136+
}
137+
return 0;
138+
139+
case WM_CLOSE:
140+
DestroyWindow(hwnd);
141+
return 0;
142+
143+
case WM_DESTROY:
144+
return 0;
145+
}
146+
return DefWindowProc(hwnd, uMsg, wParam, lParam);
147+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef FSTP_MEMORY_LOCATIONS_WINDOW_H
2+
#define FSTP_MEMORY_LOCATIONS_WINDOW_H
3+
4+
#include <windows.h>
5+
#include <SDL.h>
6+
#include "../FSTPMemoryLocations.h"
7+
8+
class FSTPMemoryLocationsWindow {
9+
public:
10+
FSTPMemoryLocationsWindow(HWND parentWindow);
11+
~FSTPMemoryLocationsWindow();
12+
13+
void Show();
14+
void Hide();
15+
void Update();
16+
bool IsVisible() const;
17+
18+
private:
19+
HWND hwndWindow;
20+
HWND hwndParent;
21+
HWND hwndList;
22+
bool isVisible;
23+
24+
void CreateControls();
25+
void PopulateList();
26+
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
27+
};
28+
29+
#endif // FSTP_MEMORY_LOCATIONS_WINDOW_H

0 commit comments

Comments
 (0)