Updating ROM library object
This commit is contained in:
@@ -4,6 +4,8 @@ namespace yaze {
|
||||
namespace Application {
|
||||
namespace Utils {
|
||||
|
||||
using namespace Graphics;
|
||||
|
||||
void ROM::LoadFromFile(const std::string& path) {
|
||||
std::cout << "filename: " << path << std::endl;
|
||||
std::ifstream stream(path, std::ios::in | std::ios::binary);
|
||||
@@ -32,6 +34,32 @@ int ROM::SnesToPc(int addr) {
|
||||
return (temp + 0x0);
|
||||
}
|
||||
|
||||
// TODO: FIXME
|
||||
int ROM::PcToSnes(int addr) {
|
||||
byte b[4];
|
||||
// = BitConverter.GetBytes(addr)
|
||||
b[2] = (byte)(b[2] * 2);
|
||||
|
||||
if (b[1] >= 0x80) {
|
||||
b[2] += 1;
|
||||
} else {
|
||||
b[1] += 0x80;
|
||||
}
|
||||
|
||||
//return BitConverter.ToInt32(b, 0);
|
||||
// snes always have + 0x8000 no matter what, the bank on pc is always / 2
|
||||
|
||||
return ((addr * 2) & 0xFF0000) + (addr & 0x7FFF) + 0x8000;
|
||||
}
|
||||
|
||||
int ROM::AddressFromBytes(byte addr1, byte addr2, byte addr3) {
|
||||
return (addr1 << 16) | (addr2 << 8) | addr3;
|
||||
}
|
||||
|
||||
short ROM::AddressFromBytes(byte addr1, byte addr2) {
|
||||
return (short)((addr1 << 8) | (addr2));
|
||||
}
|
||||
|
||||
void ROM::Write(int addr, byte value) { working_rom_[addr] = value; }
|
||||
|
||||
void ROM::WriteLong(int addr, int value) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Core/Constants.h"
|
||||
#include "Data/Tile.h"
|
||||
#include "Graphics/Tile.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace Application {
|
||||
@@ -19,29 +19,28 @@ namespace Utils {
|
||||
|
||||
using byte = unsigned char;
|
||||
using ushort = unsigned short;
|
||||
using namespace Data;
|
||||
|
||||
class ROM {
|
||||
public:
|
||||
int SnesToPc(int addr);
|
||||
int PcToSnes(int addr);
|
||||
int AddressFromBytes(byte addr1, byte addr2, byte addr3);
|
||||
short AddressFromBytes(byte addr1, byte addr2);
|
||||
ushort ReadShort(int addr);
|
||||
void Write(int addr, byte value);
|
||||
short ReadReverseShort(int addr);
|
||||
ushort ReadByte(int addr);
|
||||
short ReadRealShort(int addr);
|
||||
Tile16 ReadTile16(int addr);
|
||||
Graphics::Tile16 ReadTile16(int addr);
|
||||
void WriteShort(int addr, int value);
|
||||
int ReadLong(int addr);
|
||||
void WriteLong(int addr, int value) ;
|
||||
void WriteLong(int addr, int value);
|
||||
void LoadFromFile(const std::string& path);
|
||||
inline const char * GetRawData() {
|
||||
return working_rom_.data();
|
||||
}
|
||||
inline const char* GetRawData() { return working_rom_.data(); }
|
||||
|
||||
private:
|
||||
std::vector<char> original_rom_;
|
||||
std::vector<char> working_rom_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
Reference in New Issue
Block a user