2018-08-01 16:03:16 +02:00
|
|
|
//
|
|
|
|
// Created by Wouter Groeneveld on 28/07/18.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef GBA_SPRITE_ENGINE_BACKGROUND_H
|
|
|
|
#define GBA_SPRITE_ENGINE_BACKGROUND_H
|
|
|
|
|
|
|
|
|
2018-08-08 13:00:27 +02:00
|
|
|
#include <libgba-sprite-engine/gba/tonc_types.h>
|
2018-08-01 16:03:16 +02:00
|
|
|
|
2019-12-12 13:54:17 +01:00
|
|
|
#define MAPLAYOUT_32X32 0
|
|
|
|
#define MAPLAYOUT_32X64 1
|
|
|
|
#define MAPLAYOUT_64X32 2
|
|
|
|
#define MAPLAYOUT_64X64 3
|
|
|
|
|
2018-08-01 16:03:16 +02:00
|
|
|
class Background {
|
|
|
|
private:
|
|
|
|
void buildRegister();
|
|
|
|
u32 getBgControlRegisterIndex();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const void *data;
|
|
|
|
const void *map;
|
|
|
|
int size, bgIndex;
|
2019-12-12 13:54:17 +01:00
|
|
|
int mapSize, mapLayout;
|
2018-08-01 16:03:16 +02:00
|
|
|
int screenBlockIndex, charBlockIndex;
|
|
|
|
|
|
|
|
public:
|
|
|
|
const int getScreenBlock() { return screenBlockIndex; }
|
|
|
|
const int getCharBlock() { return charBlockIndex; }
|
|
|
|
void useMapScreenBlock(int block) { screenBlockIndex = block; }
|
|
|
|
void scroll(int x, int y);
|
2019-07-31 18:15:03 +02:00
|
|
|
void scrollSpeed(int dx, int dy);
|
2018-08-01 16:03:16 +02:00
|
|
|
|
2019-12-12 13:54:17 +01:00
|
|
|
Background(int bgIndex, const void *data, int size, const void* map, int mapSize, int screenBlockIndex, int charBlockIndex, int mapLayout)
|
|
|
|
: Background(bgIndex, data, size, map, mapSize) {
|
|
|
|
this->screenBlockIndex = screenBlockIndex;
|
|
|
|
this->charBlockIndex = charBlockIndex;
|
|
|
|
this->mapLayout = mapLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
Background(int bgIndex, const void *data, int size, const void* map, int mapSize) : data(data), bgIndex(bgIndex), size(size), map(map), mapLayout(MAPLAYOUT_32X32),
|
|
|
|
screenBlockIndex(0), charBlockIndex(bgIndex), mapSize(mapSize) {}
|
2018-08-02 14:24:44 +02:00
|
|
|
virtual void persist();
|
2018-11-30 13:48:43 +01:00
|
|
|
void updateMap(const void* map);
|
2018-08-01 16:03:16 +02:00
|
|
|
void clearMap();
|
2018-11-29 16:06:59 +01:00
|
|
|
void clearData();
|
2018-08-01 16:03:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //GBA_SPRITE_ENGINE_BACKGROUND_H
|