「NMI割り込み」の編集履歴(バックアップ)一覧に戻る

NMI割り込み - (2014/07/28 (月) 22:12:19) のソース

-while文の中でVBlank待ちをしなくても、.asmで宣言した処理(NMIProc)が毎回実行されます。
#highlight(c){{{
#include <kihon.h>

// メイン処理
void NesMain()
{
    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);

    //NMI割り込みの設定(flag1の7bitを1に)
    SetPPU(0x80,0x1e);

    while (1);
}

//NMI割り込み
void NMIProc(void)
{
    static unsigned char x = 50;
    x++;
    SetSprite(1,x,100,1,0);
}
}}}