-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GBA: Added option to enable a log API that should be compatible with …
…mGBA's
- Loading branch information
Showing
9 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
#include "pch.h" | ||
#include "Shared/MessageManager.h" | ||
|
||
class MgbaLogHandler | ||
{ | ||
private: | ||
uint8_t _enableMarker[2] = {}; | ||
bool _enabled = false; | ||
uint8_t _message[257] = {}; | ||
|
||
void UpdateEnableFlag() | ||
{ | ||
_enabled |= _enableMarker[1] == 0xC0 && _enableMarker[0] == 0xDE; | ||
} | ||
|
||
public: | ||
void Write(uint32_t addr, uint8_t value) | ||
{ | ||
if(_enabled && addr < 0xFFF700) { | ||
_message[addr & 0xFF] = value; | ||
} else if(addr == 0xFFF780) { | ||
_enableMarker[0] = value; | ||
UpdateEnableFlag(); | ||
} else if(addr == 0xFFF781) { | ||
_enableMarker[1] = value; | ||
UpdateEnableFlag(); | ||
} else if(addr == 0xFFF701) { | ||
if(_enabled && (value & 0x01)) { | ||
if(_message[0] != 0) { | ||
MessageManager::Log("[Debug] " + string((char*)_message)); | ||
} | ||
memset(_message, 0, sizeof(_message)); | ||
} | ||
} | ||
} | ||
|
||
uint8_t Read(uint32_t addr) | ||
{ | ||
switch(addr & 0x03) { | ||
case 0: return _enabled ? 0x1D : 0x00; | ||
case 1: return _enabled ? 0xEA : 0x00; | ||
default: return 0; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters