bug: fix tile16 issue with toint16 method
This commit is contained in:
@@ -11,15 +11,15 @@ namespace gfx {
|
||||
|
||||
TileInfo GetTilesInfo(ushort tile) {
|
||||
// vhopppcc cccccccc
|
||||
ushort o = 0;
|
||||
ushort v = 0;
|
||||
ushort h = 0;
|
||||
auto tid = (ushort)(tile & 0x3FF);
|
||||
bool o = false;
|
||||
bool v = false;
|
||||
bool h = false;
|
||||
auto tid = (ushort)(tile & core::TileNameMask);
|
||||
auto p = (uchar)((tile >> 10) & 0x07);
|
||||
|
||||
o = (ushort)((tile & 0x2000) >> 13);
|
||||
h = (ushort)((tile & 0x4000) >> 14);
|
||||
v = (ushort)((tile & 0x8000) >> 15);
|
||||
o = ((tile & core::TilePriorityBit) == core::TilePriorityBit);
|
||||
h = ((tile & core::TileHFlipBit) == core::TileHFlipBit);
|
||||
v = ((tile & core::TileVFlipBit) == core::TileVFlipBit);
|
||||
|
||||
return TileInfo(tid, p, v, h, o);
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ using tile8 = struct tile8;
|
||||
class TileInfo {
|
||||
public:
|
||||
ushort id_;
|
||||
ushort over_;
|
||||
ushort vertical_mirror_;
|
||||
ushort horizontal_mirror_;
|
||||
bool over_;
|
||||
bool vertical_mirror_;
|
||||
bool horizontal_mirror_;
|
||||
uchar palette_;
|
||||
TileInfo() = default;
|
||||
TileInfo(ushort id, uchar palette, ushort v, ushort h, ushort o)
|
||||
TileInfo(ushort id, uchar palette, bool v, bool h, bool o)
|
||||
: id_(id),
|
||||
over_(o),
|
||||
vertical_mirror_(v),
|
||||
|
||||
@@ -77,7 +77,7 @@ class ROM {
|
||||
absl::StatusOr<Bytes> DecompressOverworld(int pos, int size);
|
||||
|
||||
absl::Status LoadAllGraphicsData();
|
||||
|
||||
|
||||
absl::StatusOr<Bytes> CreateAllGfxDataRaw();
|
||||
absl::Status CreateAllGraphicsData();
|
||||
|
||||
@@ -117,6 +117,10 @@ class ROM {
|
||||
}
|
||||
const uchar* operator&() { return rom_data_.data(); }
|
||||
|
||||
ushort toint16(int offset) {
|
||||
return (ushort)((rom_data_[offset + 1]) << 8) | rom_data_[offset];
|
||||
}
|
||||
|
||||
private:
|
||||
long size_ = 0;
|
||||
uchar title[21] = "ROM Not Loaded";
|
||||
|
||||
@@ -88,13 +88,13 @@ void Overworld::AssembleMap32Tiles() {
|
||||
void Overworld::AssembleMap16Tiles() {
|
||||
int tpos = core::map16Tiles;
|
||||
for (int i = 0; i < 4096; i += 1) {
|
||||
auto t0 = gfx::GetTilesInfo((uintptr_t)(rom_ + tpos));
|
||||
auto t0 = gfx::GetTilesInfo((rom_.toint16(tpos)));
|
||||
tpos += 2;
|
||||
auto t1 = gfx::GetTilesInfo((uintptr_t)(rom_ + tpos));
|
||||
auto t1 = gfx::GetTilesInfo((rom_.toint16(tpos)));
|
||||
tpos += 2;
|
||||
auto t2 = gfx::GetTilesInfo((uintptr_t)(rom_ + tpos));
|
||||
auto t2 = gfx::GetTilesInfo((rom_.toint16(tpos)));
|
||||
tpos += 2;
|
||||
auto t3 = gfx::GetTilesInfo((uintptr_t)(rom_ + tpos));
|
||||
auto t3 = gfx::GetTilesInfo((rom_.toint16(tpos)));
|
||||
tpos += 2;
|
||||
tiles16.emplace_back(t0, t1, t2, t3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user