Add relative scroll to backgrounds

This commit is contained in:
Jorim Tielemans 2019-07-31 18:15:03 +02:00
parent 454c5f7db7
commit f353c89172
2 changed files with 7 additions and 1 deletions

View File

@ -25,9 +25,10 @@ public:
const int getCharBlock() { return charBlockIndex; }
void useMapScreenBlock(int block) { screenBlockIndex = block; }
void scroll(int x, int y);
void scrollSpeed(int dx, int dy);
Background(int bgIndex, const void *data, int size, const void* map, int mapSize) : data(data), bgIndex(bgIndex), size(size), map(map),
screenBlockIndex(0), charBlockIndex(0), mapSize(mapSize) {}
screenBlockIndex(0), charBlockIndex(0), mapSize(mapSize) {}
virtual void persist();
void updateMap(const void* map);
void clearMap();

View File

@ -78,4 +78,9 @@ void Background::buildRegister() {
void Background::scroll(int x, int y) {
REG_BG_OFS[bgIndex].x = x;
REG_BG_OFS[bgIndex].y = y;
}
void Background::scrollSpeed(int dx, int dy) {
REG_BG_OFS[bgIndex].x += dx;
REG_BG_OFS[bgIndex].y += dy;
}