「縦スクロール」の編集履歴(バックアップ)一覧はこちら
「縦スクロール」(2016/10/22 (土) 21:30:53) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
-裏で新しい背景を描きながら画面スクロールします。
-&color(red){.asmを$00=Horizontal Mirrorにしておきましょう。}
-NMIProc内でif (bgx % 8 == ?) {}としていくつかに分けて処理しているのは負荷分散のためです。&br()まとめて処理すると画面がきちんと出力されない場合があります。
#highlight(c){{{
#include <kihon.h>
char init;
//NMI割り込み
void NMIProc(void)
{
static unsigned char bgy,no,mode,wno,scr;
unsigned char pos[2],y;
if (init) {
bgy=239;
no=2;
mode=0;
scr=1;
init=0;
}
if (bgy % 8 == 7) {
y = bgy / 8;
wno = no + 48;
}
if (bgy % 8 == 6) {
GetBackgroundAddress(scr, 0, y, pos);
FillBackground(*(pos + 0),*(pos + 1) ,wno,5);
}
if (bgy % 8 == 5) {
GetBackgroundAddress(scr, 5, y, pos);
FillBackground(*(pos + 0),*(pos + 1) ,wno,5);
}
if (bgy % 8 == 4) {
GetBackgroundAddress(scr,10, y, pos);
FillBackground(*(pos + 0),*(pos + 1) ,wno,5);
}
if (bgy % 8 == 3) {
GetBackgroundAddress(scr,15, y, pos);
FillBackground(*(pos + 0),*(pos + 1) ,wno,5);
}
if (bgy % 8 == 2) {
GetBackgroundAddress(scr,20, y, pos);
FillBackground(*(pos + 0),*(pos + 1) ,wno,6);
}
if (bgy % 8 == 1) {
GetBackgroundAddress(scr,26, y, pos);
FillBackground(*(pos + 0),*(pos + 1) ,wno,6);
}
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);
}
}}}
-裏で新しい背景を描きながら画面スクロールします。
-&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);
}
}}}