add common function library

This commit is contained in:
scawful
2022-07-06 22:21:57 -04:00
parent 9e90fad9e1
commit 0c4eba08ad
2 changed files with 41 additions and 0 deletions

24
src/app/core/common.cc Normal file
View File

@@ -0,0 +1,24 @@
#include "common.h"
#include <cstdint>
namespace yaze {
namespace app {
namespace core {
unsigned int SnesToPc(unsigned int addr) {
if (addr >= 0x808000) {
addr -= 0x808000;
}
unsigned int temp = (addr & 0x7FFF) + ((addr / 2) & 0xFF8000);
return (temp + 0x0);
}
int AddressFromBytes(uint8_t addr1, uint8_t addr2, uint8_t addr3) {
return (addr1 << 16) | (addr2 << 8) | addr3;
}
} // namespace core
} // namespace app
} // namespace premia