Skip to content

Commit

Permalink
fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Mar 30, 2024
1 parent f2be26d commit c7685ba
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 41 deletions.
62 changes: 48 additions & 14 deletions RAVBA.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,70 @@ $ git submodule update --recursive
From a VS2019 x64 native tools command prompt
$ mkdir vsbuild
$ cd vsbuild
$ cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows -DENABLE_RETROACHIEVEMENTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_SYSTEM_VERSION=8.1 -T v141
$ cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL2_STATIC=ON -DSFML_STATIC_LIBRARIES=ON -DENABLE_RETROACHIEVEMENTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_SYSTEM_VERSION=8.1 -T v142
$ cmake --build .

This prepares a VS solution (VBA-M.sln) in the vsbuild directory that can be opened in Visual Studio.
Note that because this solution was generated by cmake, the only valid build configuration is Debug.

You can also build it from the VS2019 x64 command prompt as follows:
$ msbuild /m ALL_BUILD.vcxproj -p:Configuration=Debug
$ msbuild /m visualboyadvance-m.vcxproj -p:Configuration=Debug

==== Create release ====

Unfortunately, the vcpkg build creates a bunch of dependencies on libraries on whatever machine the build was performed on. In particular, when building on Windows 10, the resulting binary can only be run on Windows 10.

To work around this, we cross compile from linux. Using an Ubuntu VM, checkout the code, then run the following commands:

~/source/RAVBA$ export BUILD_ENV=mingw-w32
~/source/RAVBA$ ./installdeps MinGW-w64-i686
~/source/RAVBA$ git submodule update
~/source/RAVBA$ mkdir build && cd build
~/source/RAVBA/build$ /usr/lib/mxe/usr/bin/i686-w64-mingw32.static-cmake .. -DENABLE_SDL=ON -DENABLE_OPENAL=ON -DENABLE_RETROACHIEVEMENTS=ON -DCMAKE_SYSTEM_VERSION=7.0 -DENABLE_LTO=OFF -DENABLE_NLS=OFF -DENABLE_FFMPEG=OFF -DENABLE_ONLINEUPDATES=OFF
~/source/RAVBA$ export BUILD_ENV=mingw-w32
~/source/RAVBA$ ./installdeps --no-ffmpeg win32
~/source/RAVBA$ mkdir build && cd build
~/source/RAVBA/build$ /usr/lib/mxe/usr/bin/i686-w64-mingw32.static-cmake .. -DENABLE_SDL=ON -DENABLE_OPENAL=ON -DENABLE_RETROACHIEVEMENTS=ON -DCMAKE_SYSTEM_VERSION=7.0 -DENABLE_LTO=OFF -DENABLE_NLS=OFF -DENABLE_FFMPEG=OFF -DENABLE_ONLINEUPDATES=OFF

If you get an error about libssl.so.1.1 not being found:
$ mkdir $HOME/opt && cd $HOME/opt
$ wget https://www.openssl.org/source/openssl-1.1.1o.tar.gz
$ tar -zxvf openssl-1.1.1o.tar.gz
$ cd openssl-1.1.1o
$ ./config && make && make test
$ mkdir $HOME/opt/lib
$ mv $HOME/opt/openssl-1.1.1o/libcrypto.so.1.1 $HOME/opt/lib/
$ mv $HOME/opt/openssl-1.1.1o/libssl.so.1.1 $HOME/opt/lib/
$ export LD_LIBRARY_PATH=$HOME/opt/lib:$LD_LIBRARY_PATH

~/source/RAVBA$ make -j2

NOTE: the linux build process will not generate the RA_BuildVer.h file, so copy it from the Windows machine and manually update it to the correct version.
NOTE: the linux build process will not generate the src/wx/RA_BuildVer.h file, so copy it from the Windows machine and manually update it to the correct version.

#define RAVBA_VERSION "1.1.0.0"
#define RAVBA_VERSION_SHORT "1.1.0"
#define RAVBA_VERSION_MAJOR 1
#define RAVBA_VERSION_MINOR 1
#define RAVBA_VERSION_PATCH 0
#define RAVBA_VERSION_REVISION 0
#define RAVBA_VERSION_PRODUCT "1.1.0"

The one benefit of doing this is we end up with a single binary, whereas there's 7 or 8 additional DLLs generated in the Windows project.

For x64 build:

~/source/RAVBA$ export BUILD_ENV=mingw-w64
~/source/RAVBA$ ./installdeps MinGW-w64-x86_64
~/source/RAVBA$ git submodule update
~/source/RAVBA$ mkdir build64 && cd build64
~/source/RAVBA/build64$ /usr/lib/mxe/usr/bin/x86_64-w64-mingw32.static-cmake .. -DENABLE_SDL=ON -DENABLE_OPENAL=ON -DENABLE_RETROACHIEVEMENTS=ON -DCMAKE_SYSTEM_VERSION=7.0 -DENABLE_LTO=OFF -DENABLE_NLS=OFF -DENABLE_FFMPEG=OFF -DENABLE_ONLINEUPDATES=OFF
~/source/RAVBA$ make -j2
~/source/RAVBA$ export BUILD_ENV=mingw-w64
~/source/RAVBA$ ./installdeps --no-ffmpeg win64
~/source/RAVBA$ mkdir build64 && cd build64
~/source/RAVBA/build64$ /usr/lib/mxe/usr/bin/x86_64-w64-mingw32.static-cmake .. -DENABLE_SDL=ON -DENABLE_OPENAL=ON -DENABLE_RETROACHIEVEMENTS=ON -DCMAKE_SYSTEM_VERSION=7.0 -DENABLE_LTO=OFF -DENABLE_NLS=OFF -DENABLE_FFMPEG=OFF -DENABLE_ONLINEUPDATES=OFF
~/source/RAVBA/build64$ make -j2


==== MXE ====
If you get an error about optional not being defined, it's because the default prebuilt MXE doesn't support c++17.
(See https://github.com/mxe/mxe/issues/2626). To work around that, you have to build mxe yourself.

~/source$ git clone https://github.com/mxe/mxe.git
~/source$ sudo apt-get install lzip python-is-python3
~/source$ cd mxe
~/source/mxe$ make MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' gcc zlib ffmpeg gettext sdl2 sfml openal wxwidgets
- this takes around an hour!
~/source/mxe$ cd ~/RAVBA/build64
~/source/RAVBA/build64$ export PATH=~/source/mxe/usr/bin:$PATH
~/source/RAVBA/build64$ x86_64-w64-mingw32.static-cmake .. -DENABLE_SDL=ON -DENABLE_OPENAL=ON -DENABLE_RETROACHIEVEMENTS=ON -DCMAKE_SYSTEM_VERSION=7.0 -DENABLE_LTO=OFF -DENABLE_NLS=OFF -DENABLE_FFMPEG=OFF -DENABLE_ONLINEUPDATES=OFF
~/source/RAVBA/build64$ make -j2
3 changes: 2 additions & 1 deletion src/gb/GB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3802,7 +3802,7 @@ void gbCleanUp()
#endif // !__LIBRETRO__
}

bool gbLoadRom(const char* filename) {
bool gbLoadRom(const char* filename, int* fileSize) {
int romSize = 0;

if (gbRom != nullptr) {
Expand All @@ -3814,6 +3814,7 @@ bool gbLoadRom(const char* filename) {
gbRom = utilLoad(filename, utilIsGBImage, nullptr, romSize);
if (!gbRom)
return false;
*fileSize = romSize;

g_gbBatteryError = false;

Expand Down
2 changes: 1 addition & 1 deletion src/gb/gb.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern uint16_t IFF;
int gbDis(char*, uint16_t);

// Attempts to load the ROM file at `filename`. Returns true on success.
bool gbLoadRom(const char* filename);
bool gbLoadRom(const char* filename, int* fileSize);
// Attempts to load the ROM at `romData`, with a size of `romSize`. This will
// make a copy of `romData`. Returns true on success.
bool gbLoadRomData(const char* romData, size_t romSize);
Expand Down
3 changes: 2 additions & 1 deletion src/sdl/SDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,8 @@ int main(int argc, char** argv)
cartridgeType = (int)type;

if (type == IMAGE_GB) {
failed = !gbLoadRom(szFile);
int rom_size;
failed = !gbLoadRom(szFile, &rom_size);
if (!failed) {
gbGetHardwareType();

Expand Down
4 changes: 2 additions & 2 deletions src/wx/cmdevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2080,8 +2080,8 @@ EVT_HANDLER(GeneralConfigure, "General options...")
int result = ShowModal(dlg);

#ifdef RETROACHIEVEMENTS
if (RA_HardcoreModeIsActive() && throttle < 100 && throttle != 0)
throttle = 100;
if (RA_HardcoreModeIsActive() && coreOptions.throttle < 100 && coreOptions.throttle != 0)
coreOptions.throttle = 100;
#endif

if (result == wxID_OK)
Expand Down
3 changes: 1 addition & 2 deletions src/wx/panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ double GetFilterScale() {
#define out_16 (systemColorDepth == 16)

} // namespace
>>>>>>> source

int emulating;

Expand Down Expand Up @@ -249,7 +248,7 @@ void GameArea::LoadGame(const wxString& name)
}

if (t == IMAGE_GB) {
if (!gbLoadRom(fn)) {
if (!gbLoadRom(fn, (int*)&rom_size)) {
wxString s;
s.Printf(_("Unable to load Game Boy ROM %s"), name.mb_str());
wxMessageDialog dlg(GetParent(), s, _("Problem loading file"), wxOK | wxICON_ERROR);
Expand Down
18 changes: 9 additions & 9 deletions src/wx/retroachievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static void CausePause(bool pause)
bool value;

MainFrame* mf = wxGetApp().frame;
mf->GetMenuOptionBool("Pause", value);
mf->GetMenuOptionBool("Pause", &value);
if (value != pause)
{
wxCommandEvent evh(wxEVT_COMMAND_MENU_SELECTED, XRCID("Pause"));
Expand Down Expand Up @@ -108,9 +108,9 @@ static void ResetEmulator()
systemStopGamePlayback();

// disabling the menu option prevents cheats from being evaluated each frame
if (cheatsEnabled)
if (coreOptions.cheatsEnabled)
{
cheatsEnabled = false;
coreOptions.cheatsEnabled = false;
mf->SetMenuOption("CheatsEnable", 0);
}

Expand All @@ -125,9 +125,9 @@ static void ResetEmulator()
}

// reset frame rate
throttle = 100;
coreOptions.throttle = 100;
if (mf->GetPanel()->game_type() != IMAGE_UNKNOWN)
soundSetThrottle(throttle);
soundSetThrottle(coreOptions.throttle);
}

static void LoadROM(const char* sFullPath) {}
Expand All @@ -152,16 +152,16 @@ void RA_Init(HWND hWnd)
if (RA_HardcoreModeIsActive())
{
// disable cheats
if (cheatsEnabled)
if (coreOptions.cheatsEnabled)
{
cheatsEnabled = false;
coreOptions.cheatsEnabled = false;
MainFrame* mf = wxGetApp().frame;
mf->SetMenuOption("CheatsEnable", 0);
}

// ensure throttle is not below 100%
if (throttle < 100)
throttle = 100;
if (coreOptions.throttle < 100)
coreOptions.throttle = 100;
}
}

Expand Down
18 changes: 7 additions & 11 deletions src/wx/wxvbam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "wayland.h"
#include "widgets/group-check-box.h"
#include "widgets/user-input-ctrl.h"
//#include "wxhead.h"
#include "wxhead.h"

#ifdef RETROACHIEVEMENTS
#include "retroachievements.h"
Expand Down Expand Up @@ -578,17 +578,14 @@ bool wxvbamApp::OnInit() {
if (is_maximized) {
frame->Maximize();
}

#ifdef RETROACHIEVEMENTS
RA_Init(frame->GetHWND());
#endif

if (is_fullscreen && wxGetApp().pending_load != wxEmptyString)
frame->ShowFullScreen(is_fullscreen);

if (isFullscreen && wxGetApp().pending_load != wxEmptyString)
frame->ShowFullScreen(isFullscreen);

frame->Show(true);

#ifndef NO_ONLINEUPDATES
Expand Down Expand Up @@ -1015,11 +1012,6 @@ int MainFrame::FilterEvent(wxEvent& event) {
command = gopts.shortcuts.CommandForInput(config::UserInput(joy_event));
}
}

if (command == 0) {
return wxEventFilter::Event_Skip;
}

#ifdef RETROACHIEVEMENTS
else if (event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED)
{
Expand All @@ -1032,6 +1024,10 @@ int MainFrame::FilterEvent(wxEvent& event) {
}
#endif

if (command == 0) {
return wxEventFilter::Event_Skip;
}

wxCommandEvent command_event(wxEVT_COMMAND_MENU_SELECTED, command);
command_event.SetEventObject(this);
this->GetEventHandler()->ProcessEvent(command_event);
Expand Down

0 comments on commit c7685ba

Please sign in to comment.