Skip to content

Commit 6d9f01d

Browse files
committed
Windows Port: Minor fixes to allow builds on older Visual Studio versions.
1 parent 23805ba commit 6d9f01d

File tree

6 files changed

+73
-59
lines changed

6 files changed

+73
-59
lines changed

desmume/src/frontend/windows/aviout.cpp

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (C) 2006-2024 DeSmuME team
2+
Copyright (C) 2006-2025 DeSmuME team
33
44
This file is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -517,51 +517,13 @@ HRESULT AVIFileStream::WriteAllFrames()
517517

518518
NDSCaptureObject::NDSCaptureObject()
519519
{
520-
// Create the format structs.
521-
memset(&_bmpFormat, 0, sizeof(BITMAPINFOHEADER));
522-
_bmpFormat.biSize = 0x28;
523-
_bmpFormat.biPlanes = 1;
524-
_bmpFormat.biBitCount = 24;
525-
526-
memset(&_wavFormat, 0, sizeof(WAVEFORMATEX));
527-
528-
_pendingVideoBuffer = NULL;
529-
_pendingAudioBuffer = NULL;
530-
_pendingAudioWriteSize = NULL;
531-
_pendingBufferCount = 0;
532-
_currentBufferIndex = 0;
533-
534-
// Create the colorspace conversion threads.
535-
_numThreads = CommonSettings.num_cores;
536-
537-
if (_numThreads > MAX_CONVERT_THREADS)
538-
{
539-
_numThreads = MAX_CONVERT_THREADS;
540-
}
541-
else if (_numThreads < 2)
542-
{
543-
_numThreads = 0;
544-
}
545-
546-
for (size_t i = 0; i < _numThreads; i++)
547-
{
548-
memset(&_convertParam[i], 0, sizeof(VideoConvertParam));
549-
_convertParam[i].captureObj = this;
550-
551-
_convertThread[i] = new Task();
552-
_convertThread[i]->start(false);
553-
}
554-
555-
// Generate the AVI file streams.
556-
_fs = new AVIFileStream;
557-
558-
_fileWriteThread = new Task();
559-
_fileWriteThread->start(false);
520+
__InstanceInit();
560521
}
561522

562523
NDSCaptureObject::NDSCaptureObject(size_t frameWidth, size_t frameHeight, const WAVEFORMATEX *wfex)
563-
: NDSCaptureObject()
564524
{
525+
__InstanceInit();
526+
565527
_bmpFormat.biWidth = frameWidth;
566528
_bmpFormat.biHeight = frameHeight * 2;
567529
_bmpFormat.biSizeImage = _bmpFormat.biWidth * _bmpFormat.biHeight * 3;
@@ -623,6 +585,50 @@ NDSCaptureObject::NDSCaptureObject(size_t frameWidth, size_t frameHeight, const
623585
}
624586
}
625587

588+
void NDSCaptureObject::__InstanceInit()
589+
{
590+
// Create the format structs.
591+
memset(&_bmpFormat, 0, sizeof(BITMAPINFOHEADER));
592+
_bmpFormat.biSize = 0x28;
593+
_bmpFormat.biPlanes = 1;
594+
_bmpFormat.biBitCount = 24;
595+
596+
memset(&_wavFormat, 0, sizeof(WAVEFORMATEX));
597+
598+
_pendingVideoBuffer = NULL;
599+
_pendingAudioBuffer = NULL;
600+
_pendingAudioWriteSize = NULL;
601+
_pendingBufferCount = 0;
602+
_currentBufferIndex = 0;
603+
604+
// Create the colorspace conversion threads.
605+
_numThreads = CommonSettings.num_cores;
606+
607+
if (_numThreads > MAX_CONVERT_THREADS)
608+
{
609+
_numThreads = MAX_CONVERT_THREADS;
610+
}
611+
else if (_numThreads < 2)
612+
{
613+
_numThreads = 0;
614+
}
615+
616+
for (size_t i = 0; i < _numThreads; i++)
617+
{
618+
memset(&_convertParam[i], 0, sizeof(VideoConvertParam));
619+
_convertParam[i].captureObj = this;
620+
621+
_convertThread[i] = new Task();
622+
_convertThread[i]->start(false);
623+
}
624+
625+
// Generate the AVI file streams.
626+
_fs = new AVIFileStream;
627+
628+
_fileWriteThread = new Task();
629+
_fileWriteThread->start(false);
630+
}
631+
626632
NDSCaptureObject::~NDSCaptureObject()
627633
{
628634
this->_fileWriteThread->finish();

desmume/src/frontend/windows/aviout.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (C) 2009-2018 DeSmuME team
2+
Copyright (C) 2009-2025 DeSmuME team
33
44
This file is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -131,6 +131,9 @@ class AVIFileStream
131131

132132
class NDSCaptureObject
133133
{
134+
private:
135+
void __InstanceInit();
136+
134137
protected:
135138
AVIFileStream *_fs;
136139

desmume/src/frontend/windows/ddraw.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (C) 2018 DeSmuME team
2+
Copyright (C) 2018-2025 DeSmuME team
33
44
This file is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -31,6 +31,9 @@ const char *DDerrors[] = {
3131
DDRAW::DDRAW() :
3232
handle(NULL), clip(NULL)
3333
{
34+
systemMemory = false;
35+
vSync = false;
36+
3437
surface.primary = NULL;
3538
surface.back = NULL;
3639
memset(&surfDesc, 0, sizeof(surfDesc));

desmume/src/frontend/windows/ddraw.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (C) 2018 DeSmuME team
2+
Copyright (C) 2018-2025 DeSmuME team
33
44
This file is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -47,8 +47,8 @@ struct DDRAW
4747
DDSURFACEDESC2 surfDescBack;
4848
LPDIRECTDRAWCLIPPER clip;
4949

50-
bool systemMemory = false;
51-
bool vSync = false;
50+
bool systemMemory;
51+
bool vSync;
5252
};
5353

5454
#endif

desmume/src/frontend/windows/display.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ along with the this software. If not, see <http://www.gnu.org/licenses/>.
2525
#include "windriver.h"
2626
#include "winutil.h"
2727

28-
#include <cmath>
2928

3029
DDRAW ddraw;
3130
GLDISPLAY gldisplay;
@@ -816,7 +815,10 @@ void UpdateWndRects(HWND hwnd, RECT* newClientRect)
816815
POINT ptClient;
817816
RECT rc;
818817

819-
GapRect = {0,0,0,0};
818+
GapRect.left = 0;
819+
GapRect.top = 0;
820+
GapRect.right = 0;
821+
GapRect.bottom = 0;
820822

821823
bool maximized = IsZoomed(hwnd) != FALSE;
822824

@@ -847,8 +849,8 @@ void UpdateWndRects(HWND hwnd, RECT* newClientRect)
847849
wndHeight = (rc.right - rc.left);
848850

849851
ratio = ((float)wndHeight / (float)512);
850-
oneScreenHeight = (int)std::round(((float)GPU_FRAMEBUFFER_NATIVE_WIDTH * ratio));
851-
int oneScreenWidth = (int)std::round(((float)GPU_FRAMEBUFFER_NATIVE_HEIGHT * ratio));
852+
oneScreenHeight = (int)( ((float)GPU_FRAMEBUFFER_NATIVE_WIDTH * ratio) + 0.5f );
853+
int oneScreenWidth = (int)( ((float)GPU_FRAMEBUFFER_NATIVE_HEIGHT * ratio) + 0.5f );
852854
int vResizedScrOffset = 0;
853855

854856
// Main screen

desmume/src/frontend/windows/main.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3096,14 +3096,14 @@ LRESULT OpenFile()
30963096

30973097
ofn.lpstrFilter =
30983098
L"All Usable Files (*.nds, *.ds.gba, *.srl, *.zip, *.7z, *.rar, *.gz)\0*.nds;*.ds.gba;*.srl;*.zip;*.7z;*.rar;*.gz\0"
3099-
"NDS ROM file (*.nds,*.srl)\0*.nds;*.srl\0"
3100-
"NDS/GBA ROM File (*.ds.gba)\0*.ds.gba\0"
3101-
"Zipped NDS ROM file (*.zip)\0*.zip\0"
3102-
"7Zipped NDS ROM file (*.7z)\0*.7z\0"
3103-
"RARed NDS ROM file (*.rar)\0*.rar\0"
3104-
"GZipped NDS ROM file (*.gz)\0*.gz\0"
3105-
"Any file (*.*)\0*.*\0"
3106-
"\0"
3099+
L"NDS ROM file (*.nds,*.srl)\0*.nds;*.srl\0"
3100+
L"NDS/GBA ROM File (*.ds.gba)\0*.ds.gba\0"
3101+
L"Zipped NDS ROM file (*.zip)\0*.zip\0"
3102+
L"7Zipped NDS ROM file (*.7z)\0*.7z\0"
3103+
L"RARed NDS ROM file (*.rar)\0*.rar\0"
3104+
L"GZipped NDS ROM file (*.gz)\0*.gz\0"
3105+
L"Any file (*.*)\0*.*\0"
3106+
L"\0"
31073107
; //gzip doesnt actually work right now
31083108

31093109
ofn.nFilterIndex = 1;

0 commit comments

Comments
 (0)