TinyArcade/65536色で画面表示
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[戻る>TinyArcade]]
*画面表示 [#hd088e7c]
TinyScreenクラスがあるのでそれを使って画面を制御する。~
画面を65536色モードに設定して10x10のキャラクタを画面の真...
96*64*2バイトの画面の大きさと同じscreen_bufferを作成して...
16ビットRGBのバイトオーダーはビッグエンディアンなので注意...
TinyArcadeはリトルエンディアンなのでメモリに格納されると...
*サンプルプログラム [#l24a75f1]
#include <TinyScreen.h>
#define SCREEN_WIDTH 96
#define SCREEN_HEIGHT 64
#define BUFFER_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT)
#define BUFFER_BYTES (BUFFER_SIZE * 2)
#define COLOR16(r,g,b) ((((g<<3)&0xE)|(r>>3))<<8)+(b&0xF...
TinyScreen tiny_screen = TinyScreen(TinyScreenPlus);
unsigned short screen_buffer[BUFFER_SIZE];
// Character image
const unsigned short Hiyoko_1[10 * 10] =
{
0x0000, 0x0000, 0x0000, 0x9B06, 0x9B06, 0x9B06, 0x0000,...
0x0000, 0x0000, 0x9B06, 0x9B06, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x9B06, 0x0358, 0x0358, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x9B06, 0xFFFF, 0x0358, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x9B06, 0x0358, 0x0358, 0x9B06, 0x9F46, 0x9F46,...
0x9B03, 0x9B03, 0x9B03, 0x9B06, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x0000, 0x0000, 0x9B06, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x0000, 0x0000, 0x0000, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x0000, 0x0000, 0x0000, 0x9B03, 0x0000, 0x9B03,...
0x0000, 0x0000, 0x0000, 0x0000, 0x9B03, 0x0000, 0x9B03,...
};
void setup()
{
tiny_screen.begin();
// 65536 color mode
tiny_screen.setBitDepth(TSBitDepth16);
// Screen brightness
tiny_screen.setBrightness(7);
}
// Draw sprite no clip
void DrawSprite(const unsigned short* buffer, int x, int...
{
int scan_x;
int scan_y;
int source_address = 0;
int destination_address = SCREEN_WIDTH * y + x;
for(scan_y = 0; scan_y < height; ++ scan_y)
{
for(scan_x = 0; scan_x < width; ++ scan_x)
{
unsigned short color = buffer[source_address + scan_x];
if(static_cast<int>(color) != color_key)
{
screen_buffer[destination_address + scan_x] = color;
}
}
source_address += width;
destination_address += SCREEN_WIDTH;
}
}
void loop()
{
// Clear buffer
for(int i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; ++ i)
{
screen_buffer[i] = COLOR16(30, 30, 100);
}
// Draw sprite
DrawSprite(Hiyoko_1, 43, 27, 10, 10, 0);
// buffer to screen
tiny_screen.goTo(0, 0);
tiny_screen.setX(0, SCREEN_WIDTH - 1);
tiny_screen.setY(0, SCREEN_HEIGHT - 1);
tiny_screen.startData();
tiny_screen.writeBuffer(reinterpret_cast<unsigned char*...
tiny_screen.endTransfer();
}
*実行結果 [#bc109018]
#ref(ScreenSample3.jpg)
*サンプルプログラムのダウンロード [#b0ab03f7]
#ref(ScreenSample3.zip)~
終了行:
[[戻る>TinyArcade]]
*画面表示 [#hd088e7c]
TinyScreenクラスがあるのでそれを使って画面を制御する。~
画面を65536色モードに設定して10x10のキャラクタを画面の真...
96*64*2バイトの画面の大きさと同じscreen_bufferを作成して...
16ビットRGBのバイトオーダーはビッグエンディアンなので注意...
TinyArcadeはリトルエンディアンなのでメモリに格納されると...
*サンプルプログラム [#l24a75f1]
#include <TinyScreen.h>
#define SCREEN_WIDTH 96
#define SCREEN_HEIGHT 64
#define BUFFER_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT)
#define BUFFER_BYTES (BUFFER_SIZE * 2)
#define COLOR16(r,g,b) ((((g<<3)&0xE)|(r>>3))<<8)+(b&0xF...
TinyScreen tiny_screen = TinyScreen(TinyScreenPlus);
unsigned short screen_buffer[BUFFER_SIZE];
// Character image
const unsigned short Hiyoko_1[10 * 10] =
{
0x0000, 0x0000, 0x0000, 0x9B06, 0x9B06, 0x9B06, 0x0000,...
0x0000, 0x0000, 0x9B06, 0x9B06, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x9B06, 0x0358, 0x0358, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x9B06, 0xFFFF, 0x0358, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x9B06, 0x0358, 0x0358, 0x9B06, 0x9F46, 0x9F46,...
0x9B03, 0x9B03, 0x9B03, 0x9B06, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x0000, 0x0000, 0x9B06, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x0000, 0x0000, 0x0000, 0x9B06, 0x9B06, 0x9B06,...
0x0000, 0x0000, 0x0000, 0x0000, 0x9B03, 0x0000, 0x9B03,...
0x0000, 0x0000, 0x0000, 0x0000, 0x9B03, 0x0000, 0x9B03,...
};
void setup()
{
tiny_screen.begin();
// 65536 color mode
tiny_screen.setBitDepth(TSBitDepth16);
// Screen brightness
tiny_screen.setBrightness(7);
}
// Draw sprite no clip
void DrawSprite(const unsigned short* buffer, int x, int...
{
int scan_x;
int scan_y;
int source_address = 0;
int destination_address = SCREEN_WIDTH * y + x;
for(scan_y = 0; scan_y < height; ++ scan_y)
{
for(scan_x = 0; scan_x < width; ++ scan_x)
{
unsigned short color = buffer[source_address + scan_x];
if(static_cast<int>(color) != color_key)
{
screen_buffer[destination_address + scan_x] = color;
}
}
source_address += width;
destination_address += SCREEN_WIDTH;
}
}
void loop()
{
// Clear buffer
for(int i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; ++ i)
{
screen_buffer[i] = COLOR16(30, 30, 100);
}
// Draw sprite
DrawSprite(Hiyoko_1, 43, 27, 10, 10, 0);
// buffer to screen
tiny_screen.goTo(0, 0);
tiny_screen.setX(0, SCREEN_WIDTH - 1);
tiny_screen.setY(0, SCREEN_HEIGHT - 1);
tiny_screen.startData();
tiny_screen.writeBuffer(reinterpret_cast<unsigned char*...
tiny_screen.endTransfer();
}
*実行結果 [#bc109018]
#ref(ScreenSample3.jpg)
*サンプルプログラムのダウンロード [#b0ab03f7]
#ref(ScreenSample3.zip)~
ページ名: