「縦スクロール」の編集履歴(バックアップ)一覧はこちら

縦スクロール - (2016/10/20 (木) 16:45:27) の最新版との変更点

追加された行は緑色になります。

削除された行は赤色になります。

-裏で新しい背景を描きながら画面スクロールします。 -.asmを$01=Vertical Mirrorにしておきましょう。 //(チラつき防止、&color(red){本来逆にしなければならない筈}) -NMIProc内でif (bgx % 8 == ?) {}としていくつかに分けて処理しているのは負荷分担のためです。&br()まとめて処理すると表示が追いつかずに背景がきちんと出力されません。 -初期化の処理と画面切り替えのタイミングの見直しが必要かも。 #highlight(c){{{ #include <kihon.h> //NMI割り込み void NMIProc(void) { static unsigned char bgy=239,no=2,mode=0,wno,scr=0; unsigned char pos[2],y; if (bgy % 8 == 3) { if (mode) { scr = 0; } else { scr = 1; } y = bgy / 8; } if (bgy % 8 == 4) { wno = no; } if (bgy % 8 == 5) { GetBackgroundAddress(scr, 0, y, pos); FillBackground(*(pos + 0),*(pos + 1) ,wno,10); } if (bgy % 8 == 6) { GetBackgroundAddress(scr,10, y, pos); FillBackground(*(pos + 0),*(pos + 1) ,wno,10); } if (bgy % 8 == 7) { GetBackgroundAddress(scr,20, y, pos); FillBackground(*(pos + 0),*(pos + 1) ,wno,12); } if (bgy==0) { no++; mode^=1; if (mode) { SetPPU(0x8a,0x1e); } else { SetPPU(0x88,0x1e); } bgy = 239; SetScroll(0,bgy); } else { SetScroll(0,bgy); bgy--; } if (no > 9) { no=1; } } // メイン処理 void NesMain() { unsigned char i,pos[2]; const char bgpalette[] = { 0x0f, 0x21, 0x11, 0x20, 0x0f, 0x21, 0x11, 0x20, 0x0f, 0x21, 0x11, 0x20, 0x0f, 0x21, 0x11, 0x20 }; const char sppalette[] = { 0x0f, 0x30, 0x37, 0x20, 0x0f, 0x0a, 0x25, 0x20, 0x0f, 0x0a, 0x11, 0x20, 0x0f, 0x0a, 0x2a, 0x20 }; VBlank(); InitPPU(); // パレット設定 SetPalette((char *)bgpalette ,0); SetPalette((char *)sppalette, 1); for (i = 0; i < 30; i++) { GetBackgroundAddress(0, 0, i, pos); FillBackground(*(pos + 0), *(pos + 1), 1, 32); } SetPPU(0x88,0x1e); VBlank(); while (1); } }}}
-裏で新しい背景を描きながら画面スクロールします。 -&color(red){.asmを$00=Horizontal Mirrorにしておきましょう。} -NMIProc内でif (amari~) {}としていくつかに分けて処理しているのは負荷分散のためです。&br()まとめて処理すると画面がきちんと出力されない場合があります。 #highlight(c){{{ #include <kihon.h> char init; //NMI割り込み void NMIProc(void) { static unsigned char bgy,no,mode,wno,scr,amari; unsigned char pos[2],y; if (init) { bgy=239; no=2; mode=0; scr=1; init=0; } amari = bgy % 8; if (amari == 7) { y = bgy / 8; wno = no + 48; } else if (amari > 0) { GetBackgroundAddress(scr, (amari - 1) * 5, y, pos); FillBackground(*(pos + 0),*(pos + 1) ,wno,7); } if (bgy==0) { no++; mode^=1; scr^=1; bgy = 239; } else { bgy--; } if (mode) { SetPPU(0x8a,0x1e); } else { SetPPU(0x88,0x1e); } SetScroll(0,bgy); if (no > 9) { no=1; } } // メイン処理 void NesMain() { unsigned char i,j,pos[2]; const char bgpalette[] = { 0x0f, 0x21, 0x11, 0x20, 0x0f, 0x21, 0x11, 0x20, 0x0f, 0x21, 0x11, 0x20, 0x0f, 0x21, 0x11, 0x20 }; const char sppalette[] = { 0x0f, 0x30, 0x37, 0x20, 0x0f, 0x0a, 0x25, 0x20, 0x0f, 0x0a, 0x11, 0x20, 0x0f, 0x0a, 0x2a, 0x20 }; VBlank(); InitPPU(); // パレット設定 SetPalette((char *)bgpalette ,0); SetPalette((char *)sppalette, 1); init = 1; for (j = 0; j < 2; j++) { for (i = 0; i < 30; i++) { GetBackgroundAddress(1 - j, 0, i, pos); FillBackground(*(pos + 0), *(pos + 1), 48 + j, 32); } } SetPPU(0x88,0x1e); SetScroll(0,239); while (1); } }}}

表示オプション

横に並べて表示:
変化行の前後のみ表示: