add common function library
This commit is contained in:
24
src/app/core/common.cc
Normal file
24
src/app/core/common.cc
Normal 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
|
||||||
17
src/app/core/common.h
Normal file
17
src/app/core/common.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef YAZE_CORE_COMMON_H
|
||||||
|
#define YAZE_CORE_COMMON_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace core {
|
||||||
|
|
||||||
|
unsigned int SnesToPc(unsigned int addr);
|
||||||
|
int AddressFromBytes(uint8_t addr1, uint8_t addr2, uint8_t addr3);
|
||||||
|
|
||||||
|
} // namespace core
|
||||||
|
} // namespace app
|
||||||
|
} // namespace premia
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user