#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);
}