Skip to content

Commit

Permalink
Merge pull request #4 from Jamiras/x64
Browse files Browse the repository at this point in the history
update to latest RAIntegration
  • Loading branch information
Jamiras authored Oct 4, 2020
2 parents ab4037f + 31b955d commit ebb546b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion RAInterface
12 changes: 11 additions & 1 deletion RAVBA.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,20 @@ To work around this, we cross compile from linux. Using an Ubuntu VM, checkout t

~/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
~/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$ 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.

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
39 changes: 20 additions & 19 deletions src/wx/retroachievements.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "wxvbam.h"

#include "retroachievements.h"
#include "../../RAInterface/RA_Emulators.h"
#include "RA_BuildVer.h"

static void CausePause(bool pause)
Expand Down Expand Up @@ -168,28 +169,28 @@ extern uint8_t gbReadMemory(uint16_t address);
extern void gbWriteMemory(uint16_t address, uint8_t value);

// GB/GBC Basic byte reader/writer
static unsigned char ByteReader(size_t nOffs) { return gbReadMemory(nOffs); }
static void ByteWriter(size_t nOffs, unsigned char nVal) { gbWriteMemory(nOffs, nVal); }
static unsigned char ByteReader(unsigned int nOffs) { return gbReadMemory(nOffs); }
static void ByteWriter(unsigned int nOffs, unsigned char nVal) { gbWriteMemory(nOffs, nVal); }

// GBC Byte reader/writer offset by the size of the map until the end of the work RAM
static unsigned char PostRAMByteReader(size_t nOffs) { return gbReadMemory(nOffs + 0xE000); }
static void PostRAMByteWriter(size_t nOffs, unsigned char nVal) { gbWriteMemory(nOffs + 0xE000, nVal); }
static unsigned char PostRAMByteReader(unsigned int nOffs) { return gbReadMemory(nOffs + 0xE000); }
static void PostRAMByteWriter(unsigned int nOffs, unsigned char nVal) { gbWriteMemory(nOffs + 0xE000, nVal); }

// GBC RAM reader/writer targeting the first bank on work RAM
static unsigned char GBCFirstRAMBankReader(size_t nOffs) { return gbWram ? gbWram[nOffs + 0x1000] : 0; }
static void GBCFirstRAMBankWriter(size_t nOffs, unsigned char nVal) { if (gbWram) gbWram[nOffs + 0x1000] = nVal; }
static unsigned char GBCFirstRAMBankReader(unsigned int nOffs) { return gbWram ? gbWram[nOffs + 0x1000] : 0; }
static void GBCFirstRAMBankWriter(unsigned int nOffs, unsigned char nVal) { if (gbWram) gbWram[nOffs + 0x1000] = nVal; }

// GBC RAM reader/writer targeting work RAM banks 2-7
static unsigned char GBCBankedRAMReader(size_t nOffs) { return gbWram ? gbWram[nOffs + 0x2000] : 0; }
static void GBCBankedRAMWriter(size_t nOffs, unsigned char nVal) { if (gbWram) gbWram[nOffs + 0x2000] = nVal; }
static unsigned char GBCBankedRAMReader(unsigned int nOffs) { return gbWram ? gbWram[nOffs + 0x2000] : 0; }
static void GBCBankedRAMWriter(unsigned int nOffs, unsigned char nVal) { if (gbWram) gbWram[nOffs + 0x2000] = nVal; }

// GBA RAM reader/writer
static unsigned char GBAByteReaderInternalRAM(size_t nOffs) { return internalRAM ? internalRAM[nOffs] : 0; }
static void GBAByteWriterInternalRAM(size_t nOffs, unsigned char nVal) { if (internalRAM) internalRAM[nOffs] = nVal; }
static unsigned char GBAByteReaderInternalRAM(unsigned int nOffs) { return internalRAM ? internalRAM[nOffs] : 0; }
static void GBAByteWriterInternalRAM(unsigned int nOffs, unsigned char nVal) { if (internalRAM) internalRAM[nOffs] = nVal; }

// GBA work RAM reader/writer
static unsigned char GBAByteReaderWorkRAM(size_t nOffs) { return workRAM ? workRAM[nOffs] : 0; }
static void GBAByteWriterWorkRAM(size_t nOffs, unsigned char nVal) { if (workRAM) workRAM[nOffs] = nVal; }
static unsigned char GBAByteReaderWorkRAM(unsigned int nOffs) { return workRAM ? workRAM[nOffs] : 0; }
static void GBAByteWriterWorkRAM(unsigned int nOffs, unsigned char nVal) { if (workRAM) workRAM[nOffs] = nVal; }

void RA_OnLoadNewRom(ConsoleID nConsole, uint8_t* rom, size_t size, const char* filename)
{
Expand All @@ -199,23 +200,23 @@ void RA_OnLoadNewRom(ConsoleID nConsole, uint8_t* rom, size_t size, const char*
switch (nConsole)
{
case GB:
RA_InstallMemoryBank(0, (void*)ByteReader, (void*)ByteWriter, 0x10000);
RA_InstallMemoryBank(0, ByteReader, ByteWriter, 0x10000);
break;

case GBC:
// GBC has a weird quirk where the memory from $D000-$DFFF is a virtual block of memory pointing at one of the work RAM banks.
// Bits 0-2 of $FF70 indicate which bank is currently accessible to the program in the $D000-$DFFF range.
// Since that makes it hard to work with the memory in that region when building/running achievements, the memory exposed to
// the achievements in $D000-$DFFF is always the first bank. The remaining banks are exposed in virtual memory above $10000.
RA_InstallMemoryBank(0, (void*)ByteReader, (void*)ByteWriter, 0xD000); // Direct mapping ($0000-$CFFF)
RA_InstallMemoryBank(1, (void*)GBCFirstRAMBankReader, (void*)GBCFirstRAMBankWriter, 0x1000); // First bank ($D000-$DFFF)
RA_InstallMemoryBank(2, (void*)PostRAMByteReader, (void*)PostRAMByteWriter, 0x2000); // Direct mapping ($E000-$FFFF)
RA_InstallMemoryBank(3, (void*)GBCBankedRAMReader, (void*)GBCBankedRAMWriter, 0x6000); // RAM banks 2-7 ($10000-$15FFF)
RA_InstallMemoryBank(0, ByteReader, ByteWriter, 0xD000); // Direct mapping ($0000-$CFFF)
RA_InstallMemoryBank(1, GBCFirstRAMBankReader, GBCFirstRAMBankWriter, 0x1000); // First bank ($D000-$DFFF)
RA_InstallMemoryBank(2, PostRAMByteReader, PostRAMByteWriter, 0x2000); // Direct mapping ($E000-$FFFF)
RA_InstallMemoryBank(3, GBCBankedRAMReader, GBCBankedRAMWriter, 0x6000); // RAM banks 2-7 ($10000-$15FFF)
break;

case GBA:
RA_InstallMemoryBank(0, (void*)GBAByteReaderInternalRAM, (void*)GBAByteWriterInternalRAM, 0x8000);
RA_InstallMemoryBank(1, (void*)GBAByteReaderWorkRAM, (void*)GBAByteWriterWorkRAM, 0x40000);
RA_InstallMemoryBank(0, GBAByteReaderInternalRAM, GBAByteWriterInternalRAM, 0x8000);
RA_InstallMemoryBank(1, GBAByteReaderWorkRAM, GBAByteWriterWorkRAM, 0x40000);
break;
}

Expand Down
1 change: 1 addition & 0 deletions src/wx/retroachievements.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __RETROACHIEVEMENTS_H_

#include "../../RAInterface/RA_Interface.h"
#include "../../RAInterface/RA_Consoles.h"

void RA_Init(HWND hWnd);
void RA_ProcessInputs();
Expand Down

0 comments on commit ebb546b

Please sign in to comment.