Reading back tiles from VDP

SGDK only sub forum

Moderator: Stef

Post Reply
Zontar
Very interested
Posts: 55
Joined: Fri Oct 21, 2011 8:58 pm

Reading back tiles from VDP

Post by Zontar » Sat Dec 19, 2015 10:52 pm

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?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Reading back tiles from VDP

Post by Stef » Sun Dec 20, 2015 11:49 am

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;
}

Post Reply