Add more complete implementation for custom new/delete, add panic

This commit is contained in:
2017-10-14 03:13:26 -05:00
parent dd4556e4e1
commit 70cee81406
15 changed files with 293 additions and 28 deletions

View File

@@ -11,5 +11,31 @@
namespace nostalgia {
namespace world {
Zone::Zone() {
m_bounds.x = -1;
m_bounds.y = -1;
m_bounds.width = -1;
m_bounds.height = -1;
}
void Zone::draw(core::Context *ctx) {
}
size_t Zone::size() {
return sizeof(Zone) + m_bounds.width * m_bounds.height * sizeof(TileDef);
}
TileDef *Zone::tiles() {
return (TileDef*) (this + 1);
}
TileDef *Zone::tile(int row, int column) {
return &tiles()[row * m_bounds.width + column];
}
void Zone::setTile(int row, int column, TileDef *td) {
tiles()[row * m_bounds.width + column] = *td;
}
}
}

View File

@@ -10,13 +10,58 @@
#include <ox/std/types.hpp>
#include <nostalgia/common/common.hpp>
#include <nostalgia/core/core.hpp>
namespace nostalgia {
namespace world {
struct TileDef {
uint16_t bgTile;
};
template<typename T>
ox::Error ioOp(T *io, TileDef *obj) {
ox::Error err = 0;
io->setFields(1);
err |= io->op("bgTile", &obj->bgTile);
return err;
}
struct ZoneDef {
int width = 0;
int height = 0;
uint16_t tileMap;
int32_t width = 0;
int32_t height = 0;
};
class Zone {
private:
common::Bounds m_bounds;
public:
Zone();
void draw(core::Context *ctx);
size_t size();
TileDef *tiles();
TileDef *tile(int row, int column);
void setTile(int row, int column, TileDef *td);
};
class Region {
private:
Zone *m_zones;
public:
};
}