• 0x00にセットしたスプライト(0爆弾)の描画のタイミングで、画面のスクロール速度を変えています。
  • 0爆弾に使用する画像には何らかの絵が描かれている必要があります。
  • .asmを$00=Horizontal Mirrorにしておきましょう。
#include <kihon.h>
 
typedef void (*func)(void);
func functhis;
 
void NMIProc(void){}
 
void DrawBG()
{
    unsigned char i,sky,pos1,pos2;
    unsigned int pos;
    pos = 0x2000;
    for (i = 0; i < 30; i++)
    {
        pos1 = (pos & 0xff00) >> 8;
        pos2 =  pos & 0x00ff;
        if (i < 15) { sky = 1; } else { sky = 0; }
        FillBackground(pos1,pos2,sky,32);
        pos += 0x20;
    }
}
 
void Scroll()
{
    static unsigned char i,j;
    static unsigned char bgx=0;
 
    VBlank();
    SetScroll( 0, 0);
 
    //0爆弾設置
    SetSprite(1,0,118,0,0);
 
    //0爆弾
    ZeroSprite();
 
    bgx++;
    SetScroll( bgx , 0);
 
    for (i = 2; i < 4; i++){
        for (j = 0; j < 150; j++){}
        SetScroll( bgx * i , 0);
    }
}
 
// メイン処理
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);
 
    DrawBG();
 
    SetPPU(0x08,0x1e);
 
    functhis = Scroll;
 
    while (1) {
        (functhis)();
    }
}
 
最終更新:2016年10月18日 19:59