And here's my code:(wait for the GIF to become ready)
1) Enable the finish event. (CSR = 2)
2) Wait for the finish event to occur.
3) Disable the finish event. (CSR = 0)
(set the address and size of the transfer)
4) Set transmission parameters. (bitbltbuf, trxpos, trxreg, trxdir)
(perform the actual transfer)
5) Set the BUSDIR register to local -> host mode. (BUSDIR = 1)
6) Read data from the host interface.
7) Set the BUSDIR register back to host -> local mode. (BUSDIR = 0)
When this code is actually run, it messes up the draw environment or something because all I end up with is a static screen and a buffer full of zeros.graph_wait_finish();
// Set the transmission parameters.
dma_packet_clear(&graph_packet);
dma_packet_append(&graph_packet, GIF_SET_TAG(4, 1, 0, 0, GIF_TAG_PACKED, 1));
dma_packet_append(&graph_packet, 0x0E);
dma_packet_append(&graph_packet, GIF_SET_BITBLTBUF(address >> 8, width >> 6, psm, 0, 0, 0));
dma_packet_append(&graph_packet, GIF_REG_BITBLTBUF);
dma_packet_append(&graph_packet, GIF_SET_TRXPOS(0, 0, 0, 0, 0));
dma_packet_append(&graph_packet, GIF_REG_TRXPOS);
dma_packet_append(&graph_packet, GIF_SET_TRXREG(width, height));
dma_packet_append(&graph_packet, GIF_REG_TRXREG);
dma_packet_append(&graph_packet, GIF_SET_TRXDIR(1));
dma_packet_append(&graph_packet, GIF_REG_TRXDIR);
dma_packet_send(&graph_packet, DMA_CHANNEL_GIF);
dma_channel_wait(DMA_CHANNEL_GIF, 100000);
// local -> host
*VIF1_REG_STAT = (1 << 23); // VIF1 -> MEMORY
GS_REG_BUSDIR = GS_SET_BUSDIR(1);
// Read in the data.
dma_channel_receive(DMA_CHANNEL_VIF1, data, data_size);
dma_channel_wait(DMA_CHANNEL_VIF1, 1000000);
FlushCache(0);
// host -> local
*VIF1_REG_STAT = 0; // MEMORY -> VIF1
GS_REG_BUSDIR = GS_SET_BUSDIR(0);
I've been looking at the screenshot code in the debug lib inside ps2sdk, but it has never seemed to want to work for me - it locks up somewhere inside. I figured following the gsuser guide would be a better approach.
It wasn't. :)
Help?