Split SpriteLoader into its own files... attempt to make things better, but maybe it just makes it harder to get an overview of the code...
This commit is contained in:
parent
b06fef8700
commit
e4b1947aef
|
@ -16,6 +16,7 @@
|
|||
#include "car_bin.h"
|
||||
#include "car_blue_bin.h"
|
||||
#include "smoke_bin.h"
|
||||
#include "spriteloader.h"
|
||||
|
||||
#include "sinlut.h"
|
||||
|
||||
|
@ -158,23 +159,6 @@ public:
|
|||
int speed, angle;
|
||||
};
|
||||
|
||||
class SpriteLoader {
|
||||
u32 free_space;
|
||||
u16 sprite_index;
|
||||
public:
|
||||
SpriteLoader() {
|
||||
free_space = (u32)BITMAP_OBJ_BASE_ADR;
|
||||
sprite_index = 512;
|
||||
}
|
||||
u16 load_from_memory(const void *source, u8 blocks) {
|
||||
int bytes = blocks*8;
|
||||
CpuFastSet(source, (void*)free_space, COPY32 | bytes/4);
|
||||
free_space += bytes;
|
||||
u16 pre_index = sprite_index;
|
||||
sprite_index += blocks * 2 / 8;
|
||||
return pre_index;
|
||||
}
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "spriteloader.h"
|
||||
#include "gba_sprites.h"
|
||||
#include "gba_systemcalls.h"
|
||||
|
||||
SpriteLoader::SpriteLoader() {
|
||||
free_space = (u32)BITMAP_OBJ_BASE_ADR;
|
||||
sprite_index = 512;
|
||||
}
|
||||
|
||||
u16 SpriteLoader::load_from_memory(const void *source, u8 blocks) {
|
||||
int bytes = blocks*8;
|
||||
CpuFastSet(source, (void*)free_space, COPY32 | bytes/4);
|
||||
free_space += bytes;
|
||||
u16 pre_index = sprite_index;
|
||||
sprite_index += blocks * 2 / 8;
|
||||
return pre_index;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef SPRITELOADER_H
|
||||
#define SPRITELOADER_H
|
||||
|
||||
#include "gba_types.h"
|
||||
|
||||
class SpriteLoader {
|
||||
u32 free_space;
|
||||
u16 sprite_index;
|
||||
public:
|
||||
SpriteLoader();
|
||||
u16 load_from_memory(const void *source, u8 blocks);
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue