summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2013-05-06 09:30:59 +0200
committerTreeki <treeki@gmail.com>2013-05-06 09:30:59 +0200
commita990b07cb580eb8847621b4f4b4ac9797b0b5c26 (patch)
tree07b2bd81bb21b82e64abbff148805df6acea1b45
parentd49bbad1a8fe6f57e0a4ae706e7788d5b0d643e2 (diff)
downloadkamek-a990b07cb580eb8847621b4f4b4ac9797b0b5c26.tar.gz
kamek-a990b07cb580eb8847621b4f4b4ac9797b0b5c26.zip
optimised copying for animated tiles
-rw-r--r--animtiles.yaml6
-rw-r--r--src/animtiles.cpp17
2 files changed, 23 insertions, 0 deletions
diff --git a/animtiles.yaml b/animtiles.yaml
index 3f8f8ab..879693b 100644
--- a/animtiles.yaml
+++ b/animtiles.yaml
@@ -20,3 +20,9 @@ hooks:
addr_ntsc: 0xdeadbeef
addr_pal: 0x80087544
data: '3880 1000' # 128 tiles should be enough for anyone
+
+ - name: AnimTileOptimisedCopy
+ type: branch_insn
+ branch_type: bl
+ src_addr_pal: 0x80087AD0
+ target_func: 'CopyAnimTile'
diff --git a/src/animtiles.cpp b/src/animtiles.cpp
index 4213e6a..53a204b 100644
--- a/src/animtiles.cpp
+++ b/src/animtiles.cpp
@@ -51,3 +51,20 @@ void DoTiles(void* self) {
void DestroyTiles(void *self) {
FreeFile(&fh);
}
+
+
+extern "C" void CopyAnimTile(u8 *target, int tileNum, u8 *source, int frameNum) {
+ int tileRow = tileNum >> 5; // divided by 32
+ int tileColumn = tileNum & 31; // modulus by 32
+
+ u8 *baseRow = target + (tileRow * 2 * 32 * 1024);
+ u8 *baseTile = baseRow + (tileColumn * 32 * 4 * 2);
+
+ u8 *sourceRow = source + (frameNum * 2 * 32 * 32);
+
+ for (int i = 0; i < 8; i++) {
+ memcpy(baseTile, sourceRow, 32*4*2);
+ baseTile += (2 * 4 * 1024);
+ sourceRow += (2 * 32 * 4);
+ }
+}