・マップ表示を1周り大きくしよう
現在,横7×縦5でマップ表示を行なっている。
良く見ると,上下左右に1キャラクター分のスペースがある。
そこに半分のコマを表示して,少しでもマップを大きく表示したい。
……ちょっと考えたが,特に良い方法は思い浮かばなかった。
とりあえず,力押しの方法を取る事にした(^^;
rMapView関数にてマップ表示を行なっている。
ここに,一番外側に,もう1重キャラクタを表示する処理を追加する事にする。
void rMapView(int x, int y){
/*x,y位置を中心にマップ表示*/
int i, j;
unsigned char a;
for(j=0; j < 5; j++){
for(i=0; i < 7; i++){
/*マップデータを引き出す*/
a=md[(y + j - 2) * 50 + (x + i - 3)];
rMapC(a, i, j);
}
}
/*マップをもう1重描く*/
a=md[(y - 3) * 52 + (x - 4)];
rMapC(a + 1700, 0, 0);
for(i=0; i < 7; i++){
a=md[(y - 3) * 52 + (x + i - 3)];
rMapC(a + 1800, i, 0);
}
a=md[(y - 3) * 52 + (x + 4)];
rMapC(a + 1900, 0, 0);
for(j=0; j < 5; j++){
a=md[(y + j - 2) * 52 + (x + 4)];
rMapC(a + 1600, 0, j);
}
a=md[(y + 3) * 52 + (x + 4)];
rMapC(a + 1300, 0, 0);
for(i=6; i > -1; i--){
a=md[(y + 3) * 52 + (x + i - 3)];
rMapC(a + 1200, i, 0);
}
a=md[(y + 3) * 52 + (x - 4)];
rMapC(a + 1100, 0, 0);
for(j=4; j > -1; j--){
a=md[(y + j - 2) * 52 + (x - 4)];
rMapC(a + 1400, 0, j);
}
/*中心位置表示*/
rCenterPoint();
}
左上から右回りに表示してみました。
rMap関数への引数へは,テンキー数値位置×100を足して区別する事にしました。
例えば,左上の場合は7×100,上の場合は8×100と言った感じです。
問題は rMap関数なのですが,switch文に +1100〜+1900を追加する必要があります。
それだけでは無く,キャラクタ番号定義をこれら全てに行なう必要もある。
つまり,
キャラクタ番号を,全キャラクタに対して下記のような定義を追加する。
unsigned chara_mc01s[]={ 8, 9, 10, 11};
unsigned chara_mc01s1100[]={9}; /*左下*/
unsigned chara_mc01s1200[]={8, 9}; /*下*/
unsigned chara_mc01s1300[]={8}; /*右下*/
unsigned chara_mc01s1400[]={9, 11}; /*左*/
unsigned chara_mc01s1600[]={8, 10}; /*右*/
unsigned chara_mc01s1700[]={11}; /*左上*/
unsigned chara_mc01s1800[]={10, 11}; /*上*/
unsigned chara_mc01s1900[]={10}; /*右上*/
rMap関数に,これも全キャラクタに対して下記のソースを追加する。
case 1:
screen_set_char(SCREEN1, x * 2 + 2, y * 2 + 2, 2, 2, chara_mc01s);
break;
case 1 + 1100: /*左下*/
screen_set_char(SCREEN1, 1, 12, 1, 1, chara_mc01s1100);
break;
case 1 + 1200: /*下*/
screen_set_char(SCREEN1, x * 2 + 2, 12, 2, 1, chara_mc01s1200);
break;
case 1 + 1300: /*右下*/
screen_set_char(SCREEN1, 16, 12, 1, 1, chara_mc01s1300);
break;
case 1 + 1400: /*左*/
screen_set_char(SCREEN1, 1, y * 2 + 2, 1, 2, chara_mc01s1400);
break;
case 1 + 1600: /*右*/
screen_set_char(SCREEN1, 16, y * 2 + 2, 1, 2, chara_mc01s1600);
break;
case 1 + 1700: /*左上*/
screen_set_char(SCREEN1, 1, 1, 1, 1, chara_mc01s1700);
break;
case 1 + 1800: /*上*/
screen_set_char(SCREEN1, x * 2 + 2, 1, 2, 1, chara_mc01s1800);
break;
case 1 + 1900: /*右上*/
screen_set_char(SCREEN1, 16, 1, 1, 1, chara_mc01s1900);
break;
バカっぽい方法ですね。ですから最初に力押しで行くと宣言したのです(^^;
良い方法がすぐに思い付かなかったらとりあえず力押しで行って,そのうち良い方法を思い付いたら書き替える。
一生懸命考えても時間のムダである。寝て起きたら解決している事が多いです。
言い訳はこのぐらいにして(^^;
実際にこの力押し作業を行なう前に,PART2のマップデータに入れ替えたいと思います。
・データの入れ替え
基本的にシステムそのものは同じですので,変数名も同じようにする事で手間を省きます。
bmp_mcXXs変数と,chara_mcXXs変数を下記のように置き換えます。
/*Mapキャラ*/
unsigned short bmp_mc01s[]={
0x00FE, 0x28D6, 0x8877, 0x9A65, 0x02FD, 0x18E7, 0xE817, 0x05FA,
0x056A, 0x423D, 0x18E7, 0x817E, 0x04FB, 0x23DC, 0x40BF, 0x28D7,
0x9867, 0x05DA, 0x01FE, 0x2857, 0x728D, 0x8A75, 0x04FB, 0x00FF,
0x956A, 0x4AB5, 0x10CF, 0x00FF, 0xBA45, 0x2BD4, 0x906F, 0x04FB};
unsigned short bmp_mc02s[]={
0x00FF, 0x00EF, 0x00BB, 0x00FF, 0x00AF, 0x00D5, 0x00EF, 0x00BD,
0x00FE, 0x00EF, 0x00FB, 0x00FF, 0x007F, 0x00FF, 0x00DF, 0x007F,
0x0077, 0x00FE, 0x00BF, 0x007F, 0x00FF, 0x00B7, 0x00DD, 0x003F,
0x00F5, 0x00DE, 0x00FF, 0x00B5, 0x00EE, 0x00FB, 0x00BF, 0x00FD};
unsigned short bmp_mc04s[]={
0x3FC0, 0xEF10, 0xBB44, 0x7F80, 0xFB04, 0xFB04, 0xEC13, 0xEF10,
0xBD42, 0xBD42, 0xAF50, 0xDA25, 0xFF00, 0xFC02, 0xFE01, 0xFF00,
0xEF10, 0xF708, 0x7F80, 0xFF00, 0xDF20, 0xFE01, 0xFF00, 0xFF00,
0xFF00, 0xFE01, 0xFE01, 0xF608, 0xFE01, 0xEC13, 0xF40B, 0xFD02};
unsigned short bmp_mc06s[]={
0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xDD22, 0xFF00, 0xFF00, 0xFF00,
0xFC03, 0xFE01, 0xFC03, 0x7C83, 0xFD02, 0xFD02, 0xFC03, 0xFD02,
0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00,
0xFA05, 0xFC03, 0xF807, 0xF906, 0xFC03, 0xFC02, 0xF807, 0xF807};
unsigned short bmp_mc08s[]={
0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,
0x00FE, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,
0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,
0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF};
unsigned short bmp_mc09s[]={
0x00A2, 0x00FD, 0x00C2, 0x0094, 0x0055, 0x0044, 0x0029, 0x0053,
0x00A2, 0x00BF, 0x00CB, 0x0093, 0x00BD, 0x00A6, 0x00AD, 0x005B,
0x0094, 0x004B, 0x0055, 0x00A9, 0x0015, 0x00D4, 0x0013, 0x0064,
0x00A6, 0x00DB, 0x0055, 0x00AB, 0x00B6, 0x00DB, 0x0055, 0x00AB};
unsigned short bmp_mc10s[]={
0x00DA, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,
0x0050, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,
0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF,
0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF, 0x00FF};
unsigned short bmp_mc12s[]={
0x00FF, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00,
0x20D7, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFD02,
0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFF00, 0xFE01, 0xFF00, 0xFF00,
0xFF00, 0xF609, 0xFB04, 0xFD02, 0xFF00, 0xFF00, 0x7F80, 0xFB04};
/*Mapキャラ番号*/
unsigned chara_mc01s[]={ 8, 9, 10, 11};
unsigned chara_mc01s1100[]={9}; /*左下*/
unsigned chara_mc01s1200[]={8, 9}; /*下*/
unsigned chara_mc01s1300[]={8}; /*右下*/
unsigned chara_mc01s1400[]={9, 11}; /*左*/
unsigned chara_mc01s1600[]={8, 10}; /*右*/
unsigned chara_mc01s1700[]={11}; /*左上*/
unsigned chara_mc01s1800[]={10, 11}; /*上*/
unsigned chara_mc01s1900[]={10}; /*右上*/
unsigned chara_mc02s[]={12, 13, 14, 15};
unsigned chara_mc02s1100[]={13}; /*左下*/
unsigned chara_mc02s1200[]={12, 13}; /*下*/
unsigned chara_mc02s1300[]={12}; /*右下*/
unsigned chara_mc02s1400[]={13, 15}; /*左*/
unsigned chara_mc02s1600[]={12, 14}; /*右*/
unsigned chara_mc02s1700[]={15}; /*左上*/
unsigned chara_mc02s1800[]={14, 15}; /*上*/
unsigned chara_mc02s1900[]={14}; /*右上*/
unsigned chara_mc04s[]={20, 21, 22, 23};
unsigned chara_mc04s1100[]={21}; /*左下*/
unsigned chara_mc04s1200[]={20, 21}; /*下*/
unsigned chara_mc04s1300[]={20}; /*右下*/
unsigned chara_mc04s1400[]={21, 23}; /*左*/
unsigned chara_mc04s1600[]={20, 22}; /*右*/
unsigned chara_mc04s1700[]={23}; /*左上*/
unsigned chara_mc04s1800[]={22, 23}; /*上*/
unsigned chara_mc04s1900[]={22}; /*右上*/
unsigned chara_mc06s[]={28, 29, 30, 31};
unsigned chara_mc06s1100[]={29}; /*左下*/
unsigned chara_mc06s1200[]={28, 29}; /*下*/
unsigned chara_mc06s1300[]={28}; /*右下*/
unsigned chara_mc06s1400[]={29, 31}; /*左*/
unsigned chara_mc06s1600[]={28, 30}; /*右*/
unsigned chara_mc06s1700[]={31}; /*左上*/
unsigned chara_mc06s1800[]={30, 31}; /*上*/
unsigned chara_mc06s1900[]={30}; /*右上*/
unsigned chara_mc08s[]={36, 37, 38, 39};
unsigned chara_mc08s1100[]={37}; /*左下*/
unsigned chara_mc08s1200[]={36, 37}; /*下*/
unsigned chara_mc08s1300[]={36}; /*右下*/
unsigned chara_mc08s1400[]={37, 39}; /*左*/
unsigned chara_mc08s1600[]={36, 38}; /*右*/
unsigned chara_mc08s1700[]={39}; /*左上*/
unsigned chara_mc08s1800[]={38, 39}; /*上*/
unsigned chara_mc08s1900[]={38}; /*右上*/
unsigned chara_mc09s[]={40, 41, 42, 43};
unsigned chara_mc09s1100[]={41}; /*左下*/
unsigned chara_mc09s1200[]={40, 41}; /*下*/
unsigned chara_mc09s1300[]={40}; /*右下*/
unsigned chara_mc09s1400[]={41, 43}; /*左*/
unsigned chara_mc09s1600[]={40, 42}; /*右*/
unsigned chara_mc09s1700[]={43}; /*左上*/
unsigned chara_mc09s1800[]={42, 43}; /*上*/
unsigned chara_mc09s1900[]={42}; /*右上*/
unsigned chara_mc10s[]={44, 45, 46, 47};
unsigned chara_mc10s1100[]={45}; /*左下*/
unsigned chara_mc10s1200[]={44, 45}; /*下*/
unsigned chara_mc10s1300[]={44}; /*右下*/
unsigned chara_mc10s1400[]={45, 47}; /*左*/
unsigned chara_mc10s1600[]={44, 46}; /*右*/
unsigned chara_mc10s1700[]={47}; /*左上*/
unsigned chara_mc10s1800[]={46, 47}; /*上*/
unsigned chara_mc10s1900[]={46}; /*右上*/
unsigned chara_mc12s[]={52, 53, 54, 55};
unsigned chara_mc12s1100[]={53}; /*左下*/
unsigned chara_mc12s1200[]={52, 53}; /*下*/
unsigned chara_mc12s1300[]={52}; /*右下*/
unsigned chara_mc12s1400[]={53, 55}; /*左*/
unsigned chara_mc12s1600[]={52, 54}; /*右*/
unsigned chara_mc12s1700[]={55}; /*左上*/
unsigned chara_mc12s1800[]={54, 55}; /*上*/
unsigned chara_mc12s1900[]={54}; /*右上*/
ああ,データ定義が長いですねぇ……。
次はファイルサイズを縮める方法を研究するので,丁度いいかな。
void rSetMapC(void){
/*Mapキャラ設定*/
font_set_colordata( 8, 2*2, bmp_mc01s);
font_set_colordata(12, 2*2, bmp_mc02s);
font_set_colordata(20, 2*2, bmp_mc04s);
font_set_colordata(28, 2*2, bmp_mc06s);
font_set_colordata(36, 2*2, bmp_mc08s);
font_set_colordata(40, 2*2, bmp_mc09s);
font_set_colordata(44, 2*2, bmp_mc10s);
font_set_colordata(52, 2*2, bmp_mc12s);
}
キャラクタ設定は,余計な文を削るので,これだけになります。
元々Mapキャラクタを減らして,描き変え処理を簡略化した事がPART2の特徴の1つでした。
void rMapC(unsigned char hMode, int x, int y){
/*キャラクタを表示*/
switch (hMode){
case 1:
screen_set_char(SCREEN1, x * 2 + 2, y * 2 + 2, 2, 2, chara_mc01s);
break;
case 1 + 1100: /*左下*/
screen_set_char(SCREEN1, 1, 12, 1, 1, chara_mc01s1100);
break;
case 1 + 1200: /*下*/
screen_set_char(SCREEN1, x * 2 + 2, 12, 2, 1, chara_mc01s1200);
break;
case 1 + 1300: /*右下*/
screen_set_char(SCREEN1, 16, 12, 1, 1, chara_mc01s1300);
break;
case 1 + 1400: /*左*/
screen_set_char(SCREEN1, 1, y * 2 + 2, 1, 2, chara_mc01s1400);
break;
case 1 + 1600: /*右*/
screen_set_char(SCREEN1, 16, y * 2 + 2, 1, 2, chara_mc01s1600);
break;
case 1 + 1700: /*左上*/
screen_set_char(SCREEN1, 1, 1, 1, 1, chara_mc01s1700);
break;
case 1 + 1800: /*上*/
screen_set_char(SCREEN1, x * 2 + 2, 1, 2, 1, chara_mc01s1800);
break;
case 1 + 1900: /*右上*/
screen_set_char(SCREEN1, 16, 1, 1, 1, chara_mc01s1900);
break;
case 2:
screen_set_char(SCREEN1, x * 2 + 2, y * 2 + 2, 2, 2, chara_mc02s);
break;
case 2 + 1100: /*左下*/
screen_set_char(SCREEN1, 1, 12, 1, 1, chara_mc02s1100);
break;
case 2 + 1200: /*下*/
screen_set_char(SCREEN1, x * 2 + 2, 12, 2, 1, chara_mc02s1200);
break;
case 2 + 1300: /*右下*/
screen_set_char(SCREEN1, 16, 12, 1, 1, chara_mc02s1300);
break;
case 2 + 1400: /*左*/
screen_set_char(SCREEN1, 1, y * 2 + 2, 1, 2, chara_mc02s1400);
break;
case 2 + 1600: /*右*/
screen_set_char(SCREEN1, 16, y * 2 + 2, 1, 2, chara_mc02s1600);
break;
case 2 + 1700: /*左上*/
screen_set_char(SCREEN1, 1, 1, 1, 1, chara_mc02s1700);
break;
case 2 + 1800: /*上*/
screen_set_char(SCREEN1, x * 2 + 2, 1, 2, 1, chara_mc02s1800);
break;
case 2 + 1900: /*右上*/
screen_set_char(SCREEN1, 16, 1, 1, 1, chara_mc02s1900);
break;
case 4:
screen_set_char(SCREEN1, x * 2 + 2, y * 2 + 2, 2, 2, chara_mc04s);
break;
case 4 + 1100: /*左下*/
screen_set_char(SCREEN1, 1, 12, 1, 1, chara_mc04s1100);
break;
case 4 + 1200: /*下*/
screen_set_char(SCREEN1, x * 2 + 2, 12, 2, 1, chara_mc04s1200);
break;
case 4 + 1300: /*右下*/
screen_set_char(SCREEN1, 16, 12, 1, 1, chara_mc04s1300);
break;
case 4 + 1400: /*左*/
screen_set_char(SCREEN1, 1, y * 2 + 2, 1, 2, chara_mc04s1400);
break;
case 4 + 1600: /*右*/
screen_set_char(SCREEN1, 16, y * 2 + 2, 1, 2, chara_mc04s1600);
break;
case 4 + 1700: /*左上*/
screen_set_char(SCREEN1, 1, 1, 1, 1, chara_mc04s1700);
break;
case 4 + 1800: /*上*/
screen_set_char(SCREEN1, x * 2 + 2, 1, 2, 1, chara_mc04s1800);
break;
case 4 + 1900: /*右上*/
screen_set_char(SCREEN1, 16, 1, 1, 1, chara_mc04s1900);
break;
case 6:
screen_set_char(SCREEN1, x * 2 + 2, y * 2 + 2, 2, 2, chara_mc06s);
break;
case 6 + 1100: /*左下*/
screen_set_char(SCREEN1, 1, 12, 1, 1, chara_mc06s1100);
break;
case 6 + 1200: /*下*/
screen_set_char(SCREEN1, x * 2 + 2, 12, 2, 1, chara_mc06s1200);
break;
case 6 + 1300: /*右下*/
screen_set_char(SCREEN1, 16, 12, 1, 1, chara_mc06s1300);
break;
case 6 + 1400: /*左*/
screen_set_char(SCREEN1, 1, y * 2 + 2, 1, 2, chara_mc06s1400);
break;
case 6 + 1600: /*右*/
screen_set_char(SCREEN1, 16, y * 2 + 2, 1, 2, chara_mc06s1600);
break;
case 6 + 1700: /*左上*/
screen_set_char(SCREEN1, 1, 1, 1, 1, chara_mc06s1700);
break;
case 6 + 1800: /*上*/
screen_set_char(SCREEN1, x * 2 + 2, 1, 2, 1, chara_mc06s1800);
break;
case 6 + 1900: /*右上*/
screen_set_char(SCREEN1, 16, 1, 1, 1, chara_mc06s1900);
break;
case 8:
screen_set_char(SCREEN1, x * 2 + 2, y * 2 + 2, 2, 2, chara_mc08s);
break;
case 8 + 1100: /*左下*/
screen_set_char(SCREEN1, 1, 12, 1, 1, chara_mc08s1100);
break;
case 8 + 1200: /*下*/
screen_set_char(SCREEN1, x * 2 + 2, 12, 2, 1, chara_mc08s1200);
break;
case 8 + 1300: /*右下*/
screen_set_char(SCREEN1, 16, 12, 1, 1, chara_mc08s1300);
break;
case 8 + 1400: /*左*/
screen_set_char(SCREEN1, 1, y * 2 + 2, 1, 2, chara_mc08s1400);
break;
case 8 + 1600: /*右*/
screen_set_char(SCREEN1, 16, y * 2 + 2, 1, 2, chara_mc08s1600);
break;
case 8 + 1700: /*左上*/
screen_set_char(SCREEN1, 1, 1, 1, 1, chara_mc08s1700);
break;
case 8 + 1800: /*上*/
screen_set_char(SCREEN1, x * 2 + 2, 1, 2, 1, chara_mc08s1800);
break;
case 8 + 1900: /*右上*/
screen_set_char(SCREEN1, 16, 1, 1, 1, chara_mc08s1900);
break;
case 9:
screen_set_char(SCREEN1, x * 2 + 2, y * 2 + 2, 2, 2, chara_mc09s);
break;
case 9 + 1100: /*左下*/
screen_set_char(SCREEN1, 1, 12, 1, 1, chara_mc09s1100);
break;
case 9 + 1200: /*下*/
screen_set_char(SCREEN1, x * 2 + 2, 12, 2, 1, chara_mc09s1200);
break;
case 9 + 1300: /*右下*/
screen_set_char(SCREEN1, 16, 12, 1, 1, chara_mc09s1300);
break;
case 9 + 1400: /*左*/
screen_set_char(SCREEN1, 1, y * 2 + 2, 1, 2, chara_mc09s1400);
break;
case 9 + 1600: /*右*/
screen_set_char(SCREEN1, 16, y * 2 + 2, 1, 2, chara_mc09s1600);
break;
case 9 + 1700: /*左上*/
screen_set_char(SCREEN1, 1, 1, 1, 1, chara_mc09s1700);
break;
case 9 + 1800: /*上*/
screen_set_char(SCREEN1, x * 2 + 2, 1, 2, 1, chara_mc09s1800);
break;
case 9 + 1900: /*右上*/
screen_set_char(SCREEN1, 16, 1, 1, 1, chara_mc09s1900);
break;
case 10:
screen_set_char(SCREEN1, x * 2 + 2, y * 2 + 2, 2, 2, chara_mc10s);
break;
case 10 + 1100: /*左下*/
screen_set_char(SCREEN1, 1, 12, 1, 1, chara_mc10s1100);
break;
case 10 + 1200: /*下*/
screen_set_char(SCREEN1, x * 2 + 2, 12, 2, 1, chara_mc10s1200);
break;
case 10 + 1300: /*右下*/
screen_set_char(SCREEN1, 16, 12, 1, 1, chara_mc10s1300);
break;
case 10 + 1400: /*左*/
screen_set_char(SCREEN1, 1, y * 2 + 2, 1, 2, chara_mc10s1400);
break;
case 10 + 1600: /*右*/
screen_set_char(SCREEN1, 16, y * 2 + 2, 1, 2, chara_mc10s1600);
break;
case 10 + 1700: /*左上*/
screen_set_char(SCREEN1, 1, 1, 1, 1, chara_mc10s1700);
break;
case 10 + 1800: /*上*/
screen_set_char(SCREEN1, x * 2 + 2, 1, 2, 1, chara_mc10s1800);
break;
case 10 + 1900: /*右上*/
screen_set_char(SCREEN1, 16, 1, 1, 1, chara_mc10s1900);
break;
case 12:
screen_set_char(SCREEN1, x * 2 + 2, y * 2 + 2, 2, 2, chara_mc12s);
break;
case 12 + 1100: /*左下*/
screen_set_char(SCREEN1, 1, 12, 1, 1, chara_mc12s1100);
break;
case 12 + 1200: /*下*/
screen_set_char(SCREEN1, x * 2 + 2, 12, 2, 1, chara_mc12s1200);
break;
case 12 + 1300: /*右下*/
screen_set_char(SCREEN1, 16, 12, 1, 1, chara_mc12s1300);
break;
case 12 + 1400: /*左*/
screen_set_char(SCREEN1, 1, y * 2 + 2, 1, 2, chara_mc12s1400);
break;
case 12 + 1600: /*右*/
screen_set_char(SCREEN1, 16, y * 2 + 2, 1, 2, chara_mc12s1600);
break;
case 12 + 1700: /*左上*/
screen_set_char(SCREEN1, 1, 1, 1, 1, chara_mc12s1700);
break;
case 12 + 1800: /*上*/
screen_set_char(SCREEN1, x * 2 + 2, 1, 2, 1, chara_mc12s1800);
break;
case 12 + 1900: /*右上*/
screen_set_char(SCREEN1, 16, 1, 1, 1, chara_mc12s1900);
break;
}
}
実際にコーディングしてみると,そのバカさ加減が良く分かりますね(^^;
将来的に多重スクロールさせたいので,SCREEN1に表示するようにしてみました。
/*マップ定義*/
unsigned char md[]={
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,8,8,8,1,8,8,8,1,8,8,1,8,8,8,8,8,8,1,8,1,8,1,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,1,1,1,1,1,1,
1,1,1,1,1,2,2,2,12,2,2,8,1,1,8,1,4,1,1,4,1,2,12,2,12,2,10,12,2,12,2,12,2,12,2,12,8,1,8,1,8,1,8,1,8,1,1,1,1,1,1,1,
1,1,1,1,1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1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
};
マップですね。前作同様,奇数は通れなくて,偶数は通れます。
void main(void){
unsigned short hRet;
int x, y;
int i;
display_control(DCM_SCR1 | DCM_SCR2 | DCM_SPR);
font_set_colordata(100, 1, bmp_space);
screen_fill_char(SCREEN1, 0, 0, 28, 18, 100);
screen_fill_char(SCREEN2, 0, 0, 28, 18, 100 + 2048);
/*枠表示*/
rWakuSet();
rWakuView();
rSetMapC();
gHidukeFlag=0;
for(i=0; i < cSinarioMax; i++){
gSinarioFlag[i]=0;
}
x=46;
y=34;
for ( ; ; ){
rMapView(x, y);
rSinario(x, y);
hRet=rKeyin();
switch (hRet){
case cBOT_X1:
if (md[(y - 1) * 50 + x] % 2 == 0)
y--;
break;
case cBOT_X2:
if (md[y * 50 + (x + 1)] % 2 == 0)
x++;
break;
case cBOT_X3:
if (md[(y + 1) * 50 + x] % 2 == 0)
y++;
break;
case cBOT_X4:
if (md[y * 50 + (x - 1)] % 2 == 0)
x--;
break;
case cBOT_START:
goto EndJump;
break;
}
}
EndJump:;
}
最後に main関数のスタート位置を変更して完了。
・Warning: byte overflow
コンパイルすると,こんなワーニングが出た(;_;)
主語が無いゾ,おい!! 何のバイトがオーバーフロウしたんだ!?
自分がプログラムを組む際には,こういうエラーメッセージは作らないようにしよう。人のフリ見て我がフリ直せと……
とりあえず,ワーニングなので見なかった事にする(^^;
起動すると,わけのわからないマップが表示された。
しまった! マップの横幅が変わったのか?
それに,追加したはずの1重多くしたマップの部分が表示されていない。
要するに,rMapView関数を書き替えるのを忘れていたのでした(^^;
void rMapView(int x, int y){
/*x,y位置を中心にマップ表示*/
int i, j;
unsigned char a;
for(j=0; j < 5; j++){
for(i=0; i < 7; i++){
/*マップデータを引き出す*/
a=md[(y + j - 2) * 52 + (x + i - 3)];
rMapC(a, i, j);
}
}
/*マップをもう1重描く*/
a=md[(y - 3) * 50 + (x - 4)];
rMapC(a + 1700, 0, 0);
for(i=0; i < 7; i++){
a=md[(y - 3) * 50 + (x + i - 3)];
rMapC(a + 1800, i, 0);
}
a=md[(y - 3) * 50 + (x + 4)];
rMapC(a + 1900, 0, 0);
for(j=0; j < 5; j++){
a=md[(y + j - 2) * 50 + (x + 4)];
rMapC(a + 1600, 0, j);
}
a=md[(y + 3) * 50 + (x + 4)];
rMapC(a + 1300, 0, 0);
for(i=6; i > 1; i--){
a=md[(y + 3) * 50 + (x + i - 3)];
rMapC(a + 1200, i, 0);
}
a=md[(y + 3) * 50 + (x - 4)];
rMapC(a + 1100, 0, 0);
for(j=5; j > 1; j--){
a=md[(y + j - 2) * 50 + (x + 4)];
rMapC(a + 1400, 0, j);
}
/*中心位置表示*/
rCenterPoint();
}
実行してみると,マップ表示の上部が変になる。
それも,PART1では異常の無かったところも含まれていた(?)
徹底調査をしたところ,原因が判明した。
rMapC関数に送る際,PART1の時は小さな数値しか扱わなかった為,関数宣言を unsigned char型で行なっていた。
ところが,PART2では1周り分大きく表示する為,大きな数値を送る事にした。
つまり,Warning: byte overflowは,関数呼び出し時の引数が,宣言したサイズを越えている事を示していたのだった。
void rMapC(int hMode, int x, int y){
と宣言し直すと直った。
やはり,ワーニングは無視してはダメですね(^^;
これで無事動作するようになった。
やはり,少しでもマップ表示が広い方が良いですね(^_^)
方法はダサくても,プレイヤが満足すればそれで良いのだ(早くもっと良い方法を考えろって(^^;;)