Page 1 of 1

Reading back tiles from VDP

Posted: Sat Dec 19, 2015 10:52 pm
by Zontar
Is it possible to "read back" tiles you've loaded into the VDP using SGDK?

If not, what MMIO ports and commands will get me access to the tiles already loaded into the Genesis VDP?

Re: Reading back tiles from VDP

Posted: Sun Dec 20, 2015 11:49 am
by Stef
SGDK do not have any methods to read back data in VRAM / CRAM or VSRAM but you can use the followings macros to do it :
GFX_READ_VRAM_ADDR(adr)
GFX_READ_CRAM_ADDR(adr)
GFX_READ_VSRAM_ADDR(adr)

For instance :

Code: Select all

void VDP_readTileData(u16 plan, u16 ind, u16 num, u32* dest)
{
    vu32 *plctrl;
    vu32 *pldata;
    u32 addr;
    u32 *d;

    VDP_setAutoInc(2);

    /* point to vdp port */
    plctrl = (u32 *) GFX_CTRL_PORT;
    pldata = (u32 *) GFX_DATA_PORT;

    addr = plan + (ind * 2);

    *plctrl = GFX_READ_VRAM_ADDR(addr);

    d = dest;    
    *d++ = *pldata;
    *d++ = *pldata;
    *d++ = *pldata;
    *d++ = *pldata;
    *d++ = *pldata;
    *d++ = *pldata;
    *d++ = *pldata;
    *d = *pldata;
}