• DMA転送により、まとめてスプライトの設定ができます。
  • (char *)0x0700は.cfgでDMAAREAとして設定したアドレスへのポインタです。
#include <kihon.h>
 
void ClearScreen()
{
	unsigned char i,pos[2];
	for (i = 0; i < 30; i++)
	{
		GetBackgroundAddress(0, 0, i, pos);
		FillBackground(*(pos + 0),*(pos + 1),32,32);
	}
}
 
 
// メイン処理
void NesMain()
{
    unsigned char i,j,first;
    static unsigned char cnt=0;
    const char bgpalette[] = {
        0x0f, 0x21, 0x11, 0x20, 0x0f, 0x21, 0x11, 0x20,
        0x0f, 0x21, 0x11, 0x20, 0x0f, 0x21, 0x11, 0x20 };
    const char sppalette[] = {
        0x0f, 0x0a, 0x37, 0x20, 0x0f, 0x0a, 0x25, 0x20,
        0x0f, 0x0a, 0x11, 0x20, 0x0f, 0x0a, 0x2a, 0x20 };
 
    InitPPU();
 
    SetPalette((char *)bgpalette ,0);
    SetPalette((char *)sppalette, 1);
    ClearScreen();
 
    SetPPU(0x08,0x1e);
 
    while (1) {
        VBlank();
        SetScroll( 0, 0);
        SendDMA(0x7);
 
        first = 1;
        for (i=0;i<6;i++) {
            for (j=1;j<5;j++) {
                SetDMA((char *)0x0700,first,i * 20,j * 10,i,0);
                first = 0;
            }
        }
    }
}
 
//NMI割り込み
void NMIProc(void)
{
}
 
  • .cfgの例
RAM:     start = $0400, size = $0400, type = rw, define = yes;
                                ↓
RAM:     start = $0400, size = $0300, type = rw, define = yes;
DMAAREA: start = $0700, size = $0100, type = rw, define = yes;
 
最終更新:2014年07月28日 21:49