mirror of
https://github.com/libretro/MesenCE.git
synced 2026-11-10 03:02:05 -10:00
* GB: Link cable support with two local consoles * GB: Fix crash when color blending is enabled * GB: Fix formatting * GB: Link UI fixes, control fixes, audio fixes Copied from Sour's branch. Also a separate change to use separate savefiles. * GB: Try to avoid crashes from buffer overflows * GB: Separate savefiles with linked multiplayer * GB: Add support for faster link speed * GB: Move enum to correct file * GB: Refactor, move serial transfer to function * -Fixed secondary console sometimes running far ahead of the main console when frame counters did not match (e.g because one console had their LCD disabled longer, etc.) This would cause buffer overflows in the audio buffer. -Fixed screen tearing when both consoles are not perfectly in sync (because of the LCD being disabled for a different amount of time, etc.) -Fixed main console not calling PlayQueuedAudio properly mid-frame -Reuse VS Dualsystem code to merge audio/video when possible/simple and moved that to AvMergeUtilities Some visual glitches can appear on the secondary screen (for GB) while rewinding, but this can't really be fixed. * Fixed warning (unused local variable) * Prevent loading single-console save states when in dual-console modes * Disable debugger for VS DualSystem's subconsole. Fixes issues when debugging VS DualSystem games * Code cleanup * Rework solution to disable debugger on second console to improve performance Added InternalRunFrame for nes & gb to avoid checking for the presence of the second console after each cpu instruction * Don't enable the linked GB option by default * Removed unused function * Netplay: Force game to reload after updating emulation settings when connecting to the server (or when the host changes game) This ensures that e.g the GB link cable setting is applied and that the game loads correctly, regardless of the client's link cable settings (otherwise the game could load without the link mode enabled, etc.) --------- Co-authored-by: Sour <[email protected]>
96 lines
2.3 KiB
C++
96 lines
2.3 KiB
C++
#pragma once
|
|
#include "pch.h"
|
|
#include "Debugger/DebugTypes.h"
|
|
#include "Utilities/ISerializable.h"
|
|
|
|
class Gameboy;
|
|
class GbCart;
|
|
class GbPpu;
|
|
class GbApu;
|
|
class GbCpu;
|
|
class GbTimer;
|
|
class GbDmaController;
|
|
|
|
class EmuSettings;
|
|
class Emulator;
|
|
class GbControlManager;
|
|
|
|
enum class MemoryOperationType;
|
|
|
|
class GbMemoryManager : public ISerializable
|
|
{
|
|
private:
|
|
Emulator* _emu = nullptr;
|
|
EmuSettings* _settings = nullptr;
|
|
GbControlManager* _controlManager = nullptr;
|
|
|
|
Gameboy* _gameboy = nullptr;
|
|
GbCart* _cart = nullptr;
|
|
GbCpu* _cpu = nullptr;
|
|
GbApu* _apu = nullptr;
|
|
GbPpu* _ppu = nullptr;
|
|
GbTimer* _timer = nullptr;
|
|
GbDmaController* _dmaController = nullptr;
|
|
|
|
uint8_t* _highRam = nullptr;
|
|
|
|
uint8_t* _reads[0x100] = {};
|
|
uint8_t* _writes[0x100] = {};
|
|
|
|
GbMemoryManagerState _state = {};
|
|
|
|
__forceinline void ExecTimerDmaSerial();
|
|
|
|
void RunSerialTransfer();
|
|
bool ExchangeSerialBits(bool serialBit);
|
|
|
|
public:
|
|
virtual ~GbMemoryManager();
|
|
|
|
GbMemoryManagerState& GetState();
|
|
|
|
void Init(Emulator* emu, Gameboy* gameboy, GbCart* cart, GbPpu* ppu, GbApu* apu, GbTimer* timer, GbDmaController* dmaController);
|
|
void MapRegisters(uint16_t start, uint16_t end, RegisterAccess access);
|
|
void Map(uint16_t start, uint16_t end, GbMemoryType type, uint32_t offset, bool readonly);
|
|
void Unmap(uint16_t start, uint16_t end);
|
|
void RefreshMappings();
|
|
|
|
void ExecMasterCycle();
|
|
void Exec();
|
|
|
|
template<MemoryOperationType type, GbOamCorruptionType oamCorruptionType = GbOamCorruptionType::Read>
|
|
uint8_t Read(uint16_t addr);
|
|
|
|
bool IsOamDmaRunning();
|
|
void WriteDma(uint16_t addr, uint8_t value);
|
|
uint8_t ReadDma(uint16_t addr);
|
|
|
|
template<MemoryOperationType type = MemoryOperationType::Write>
|
|
void Write(uint16_t addr, uint8_t value);
|
|
|
|
uint8_t PeekRegister(uint16_t addr);
|
|
uint8_t ReadRegister(uint16_t addr);
|
|
void WriteRegister(uint16_t addr, uint8_t value);
|
|
|
|
void ProcessCpuWrite(uint16_t addr, uint8_t value);
|
|
|
|
void RequestIrq(uint8_t source);
|
|
void ClearIrqRequest(uint8_t source);
|
|
uint8_t ProcessIrqRequests();
|
|
|
|
void ProcessHaltEnd();
|
|
|
|
void ToggleSpeed();
|
|
bool IsHighSpeed();
|
|
bool IsBootRomDisabled();
|
|
|
|
uint64_t GetApuCycleCount();
|
|
|
|
uint8_t DebugRead(uint16_t addr);
|
|
void DebugWrite(uint16_t addr, uint8_t value);
|
|
|
|
uint8_t* GetMappedBlock(uint16_t addr);
|
|
|
|
void Serialize(Serializer& s) override;
|
|
};
|