#include #include "composite32-high4.h" #include "lib_composite32-high.h" //外付けクリスタル with PLL (15倍) #pragma config PMDL1WAY = OFF, IOL1WAY = OFF #pragma config FPLLIDIV = DIV_1, FPLLMUL = MUL_15, FPLLODIV = DIV_1 #pragma config FNOSC = PRIPLL, FSOSCEN = OFF, POSCMOD = XT, OSCIOFNC = OFF #pragma config FPBDIV = DIV_1, FWDTEN = OFF, JTAGEN = OFF, ICESEL = ICS_PGx1 const unsigned char bmp[14*13]={ 0,0,0,0,0,2,2,2,2,0,0,0,0,0, 0,0,0,2,2,2,2,2,2,2,2,0,0,0, 0,0,2,2,2,2,2,2,2,2,2,2,0,0, 0,2,2,2,7,7,2,2,2,2,7,7,2,0, 0,2,2,7,7,7,7,2,2,7,7,7,7,0, 0,2,2,7,7,8,8,2,2,7,7,8,8,0, 2,2,2,7,7,8,8,2,2,7,7,8,8,2, 2,2,2,2,7,7,2,2,2,2,7,7,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,0,2,2,2,0,0,2,2,2,0,2,2, 2,0,0,0,2,2,0,0,2,2,0,0,0,2 }; void main(void){ int x,dx; //ポートの初期設定 TRISA = 0x0010; // RA4は入力 CNPUA = 0x0010; // RA4をプルアップ ANSELA = 0x0000; // 全てデジタル TRISB = KEYSTART | KEYFIRE | KEYUP | KEYDOWN | KEYLEFT | KEYRIGHT;// ボタン接続ポート入力設定 CNPUBSET=KEYSTART | KEYFIRE | KEYUP | KEYDOWN | KEYLEFT | KEYRIGHT;// プルアップ設定 ANSELB = 0x0000; // 全てデジタル LATACLR=2;// RA1=0(ボタンモード) init_composite(); // ビデオ出力システムの初期化 x=0; //横位置 dx=1; //移動方向 while(1){ //キャラクター表示 putbmpmn(x,100,14,13,bmp); //60分の1秒ウェイト drawcount=0; while(drawcount==0) asm("wait"); //キャラクター消去 clrbmpmn(x,100,14,13); //横方向移動 x+=dx; //移動向き変更 if(x==200) dx=-1; else if(x==0) dx=1; } }