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

横スクロール」(2016/10/22 (土) 22:05:24) の最新版変更点

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

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

-裏で新しい背景を描きながら画面スクロールします。 -SetPPUにてflag1の2bit目を1(32bitインクリメント)にして背景を縦一列に出力しています。 -&color(red){.asmを$01=Vertical Mirrorにしておきましょう。} -その他は基本縦スクロールの処理と同じですが、背景を書き換えている様子が見切れるのを防ぐため、スクロールよりも8ドット遅れて背景を書き換えるように少し変更を加えています。 #highlight(c){{{ #include <kihon.h> char init; //NMI割り込み void NMIProc(void) { static unsigned char bgx,no,mode,wno[2],scr,amari,flg; unsigned char pos[2],x[2]; if (init) { bgx=0; no=2; mode=1; scr=0; init=0; flg=0; } amari = bgx % 8; if (bgx==8) { flg=1; if (mode) { scr=0; } else { scr=2; } } if (amari == 1) { x[1] = x[0]; x[0] = bgx / 8; wno[1] = wno[0]; wno[0] = no + 48; } else if (amari > 0 && flg) { GetBackgroundAddress(scr, x[1], (amari - 2) * 5 , pos); FillBackground(*(pos + 0),*(pos + 1) ,wno[1],5); } if (bgx==255) { no++; mode^=1; } bgx++; if (mode) { SetPPU(0x8c,0x1e); } else { SetPPU(0x8d,0x1e); } SetScroll(bgx,0); 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, 0x0a, 0x37, 0x20, 0x0f, 0x0a, 0x25, 0x20, 0x0f, 0x0a, 0x11, 0x20, 0x0f, 0x0a, 0x2a, 0x20 }; VBlank(); InitPPU(); init = 1; // パレット設定 SetPalette((char *)bgpalette ,0); SetPalette((char *)sppalette, 1); for (j = 0; j < 2; j++) { for (i = 0; i < 30; i++) { GetBackgroundAddress(j * 2, 0, i, pos); FillBackground(*(pos + 0), *(pos + 1), 48 + j, 32); } } SetPPU(0x8c,0x1e); while (1); } }}}
-裏で新しい背景を描きながら画面スクロールします。 -SetPPUにてflag1の2bit目を1(32bitインクリメント)にして背景を縦一列に出力しています。 -&color(red){.asmを$01=Vertical Mirrorにしておきましょう。} -その他は基本縦スクロールの処理と同じですが、背景を書き換えている様子が見切れるのを防ぐため、スクロールよりも8ドット遅れて背景を書き換えるように変更を加えています。 #highlight(c){{{ #include <kihon.h> char init; //NMI割り込み void NMIProc(void) { static unsigned char bgx,no,mode,wno[2],scr,amari,flg; unsigned char pos[2],x[2]; if (init) { bgx=0; no=2; mode=1; scr=0; init=0; flg=0; } amari = bgx % 8; if (bgx==8) { flg=1; if (mode) { scr=0; } else { scr=2; } } if (amari == 1) { x[1] = x[0]; x[0] = bgx / 8; wno[1] = wno[0]; wno[0] = no + 48; } else if (amari > 0 && flg) { GetBackgroundAddress(scr, x[1], (amari - 2) * 5 , pos); FillBackground(*(pos + 0),*(pos + 1) ,wno[1],5); } if (bgx==255) { no++; mode^=1; } bgx++; if (mode) { SetPPU(0x8c,0x1e); } else { SetPPU(0x8d,0x1e); } SetScroll(bgx,0); 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, 0x0a, 0x37, 0x20, 0x0f, 0x0a, 0x25, 0x20, 0x0f, 0x0a, 0x11, 0x20, 0x0f, 0x0a, 0x2a, 0x20 }; VBlank(); InitPPU(); init = 1; // パレット設定 SetPalette((char *)bgpalette ,0); SetPalette((char *)sppalette, 1); for (j = 0; j < 2; j++) { for (i = 0; i < 30; i++) { GetBackgroundAddress(j * 2, 0, i, pos); FillBackground(*(pos + 0), *(pos + 1), 48 + j, 32); } } SetPPU(0x8c,0x1e); while (1); } }}}

表示オプション

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