| サイズ | 160*128 |
| フレームバッファ | 2 |
| 色/パレット | 32768色 |
| 伸縮回転 | 可能 |
mode5です。ポイントは画面のサイズが小さく160*128で、32768色。パレットは使わず、mode3のように2バイトを色データとしています。フレームバッファは2となっています。画面サイズが小さいため、画像は画面左上に表示されます。右側や下側などの表示されない領域は真っ黒のままで見栄えが悪いです。
#include "lib/gba.h"
#include "res.h"
//---------------------------------------------------------------------------
void WaitForVsync(void)
{
while(*(vu16*)0x4000006 >= 160) {};
while(*(vu16*)0x4000006 < 160) {};
}
//---------------------------------------------------------------------------
void Mode5SetFrame(u16* img, u32 f)
{
u16* fr;
if(f == 1)
{
fr = (u16*)0x6000000;
}
else
{
fr = (u16*)0x600A000;
}
u32 x, y;
for(y=0; y<128; y++)
{
for(x=0; x<160; x++)
{
fr[y*128+x] = img[y*128+x];
}
}
}
//---------------------------------------------------------------------------
int main(void)
{
// モード設定。フレーム2を指定
SetMode(MODE_5 | BG2_ENABLE | BACKBUFFER);
// 画像の読み込み
Mode5SetFrame((u16*)&frame1Bitmap, 1);
Mode5SetFrame((u16*)&frame2Bitmap, 2);
for(;;)
{
WaitForVsync();
}
}
モード5で、160x128の画像の表示(フレーム2と1)
#ref(): File not found: "clip_1.png" at page "tutorial.5"
#ref(): File not found: "clip_2.png" at page "tutorial.5"