DMA streaming images from cartridge
Posted: Sun Jan 18, 2026 12:36 pm
I'm trying to stream animation frames, but I'm seeing tile-junk between frames.
Apparently, the tilemap is updating faster than the tile graphics.
How can I synchronize them without resorting to double buffering?
By the way, the images in my resources are symmetrical. But the compression method is set FAST.
I want to use a minimum VRAM in this case.
Apparently, the tilemap is updating faster than the tile graphics.
How can I synchronize them without resorting to double buffering?
By the way, the images in my resources are symmetrical. But the compression method is set FAST.
I want to use a minimum VRAM in this case.
Code: Select all
// main.c
#include <genesis.h>
#include "res/gfx.h" // сгенерируется rescomp'ом из gfx.res
#define NUM_FRAMES 7
static const Image *roads[NUM_FRAMES] = {
&road_tex1,
&road_tex2,
&road_tex3,
&road_tex4,
&road_tex5,
&road_tex6,
&road_tex7
};
int main()
{
// Инициализация экрана (по умолчанию 320x224)
VDP_setScreenWidth320(); // опционально
VDP_setPlaneSize(64, 32, TRUE); // теперь с третьим аргументом setupVram
// Если все кадры используют одну и ту же палитру — загрузим её единожды в PAL0
PAL_setPalette(PAL0, roads[0]->palette->data, DMA);
// Отрисуем первый кадр
VDP_drawImageEx(BG_B, roads[0],
TILE_ATTR_FULL(PAL0, 0, FALSE, FALSE, 1),
0, 0,
0, // не загружать палитру (мы уже установили PAL0)
DMA);
int frame = 0;
int tick = 0;
while(1)
{
frame++;
if (frame >= NUM_FRAMES) frame = 0;
//VDP_clearPlane(BG_B, TRUE);
VDP_drawImageEx(BG_B, roads[frame],
TILE_ATTR_FULL(PAL0, 0, FALSE, FALSE, 1),
0, 0,
0, // 0 = не загружать палитру
// DMA_QUEUE_COPY);
DMA);
SYS_doVBlankProcess(); // ждём VBlank (параллельно DMA завершает переносы)
}
return 0;
}