From e4b1947aefda21552f3cb0b40802e29c7626cb40 Mon Sep 17 00:00:00 2001 From: tangstad Date: Mon, 5 Dec 2005 22:26:22 +0000 Subject: [PATCH] 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... --- gba/cartest/src/cartest.cpp | 18 +----------------- gba/cartest/src/spriteloader.cpp | 17 +++++++++++++++++ gba/cartest/src/spriteloader.h | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 gba/cartest/src/spriteloader.cpp create mode 100644 gba/cartest/src/spriteloader.h 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