From 632316eef0b5c82598c8f7ad1685720570eebcd6 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 30 May 2015 17:42:18 -0700 Subject: [PATCH] GBA: Export to ACT --- src/gba/supervisor/export.c | 24 ++++++++++++++++++++++++ src/gba/supervisor/export.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/gba/supervisor/export.c b/src/gba/supervisor/export.c index a0dbbecd6..4ef29174c 100644 --- a/src/gba/supervisor/export.c +++ b/src/gba/supervisor/export.c @@ -55,3 +55,27 @@ bool GBAExportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colo return true; } + +bool GBAExportPaletteACT(struct VFile* vf, size_t entries, const uint16_t* colors) { + if (entries > 256) { + return false; + } + size_t i; + for (i = 0; i < entries; ++i) { + uint8_t block[3] = { + GBA_R8(colors[i]), + GBA_G8(colors[i]), + GBA_B8(colors[i]), + }; + if (vf->write(vf, block, 3) < 3) { + return false; + } + } + for (; i < 256; ++i) { + uint8_t block[3] = { 0, 0, 0 }; + if (vf->write(vf, block, 3) < 3) { + return false; + } + } + return true; +} diff --git a/src/gba/supervisor/export.h b/src/gba/supervisor/export.h index 0db0836b0..024e17618 100644 --- a/src/gba/supervisor/export.h +++ b/src/gba/supervisor/export.h @@ -11,5 +11,6 @@ struct VFile; bool GBAExportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colors); +bool GBAExportPaletteACT(struct VFile* vf, size_t entries, const uint16_t* colors); #endif