diff --git a/gba/cartest/src/cartest.cpp b/gba/cartest/src/cartest.cpp index 05d4f11..2ccc7bd 100644 --- a/gba/cartest/src/cartest.cpp +++ b/gba/cartest/src/cartest.cpp @@ -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) { diff --git a/gba/cartest/src/spriteloader.cpp b/gba/cartest/src/spriteloader.cpp new file mode 100644 index 0000000..cae3e1b --- /dev/null +++ b/gba/cartest/src/spriteloader.cpp @@ -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; +} diff --git a/gba/cartest/src/spriteloader.h b/gba/cartest/src/spriteloader.h new file mode 100644 index 0000000..a456ce9 --- /dev/null +++ b/gba/cartest/src/spriteloader.h @@ -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