• メインページ
  • データ構造
  • ファイル
  • ファイル一覧
  • グローバル

OpenSSM/screen.c

説明を見る。
00001 /**************************************************************************************************
00002     Title           : Screen Task
00003     Programmer      : Yosuke FURUSAWA.
00004     Copyright       : Copyright (C) 2008-2010 Yosuke FURUSAWA.
00005     Since           : 2008/12/15
00006 
00007     Filename        : screen.c
00008     Last up date    : 2010/08/13
00009     Kanji-Code      : Shift-JIS
00010     TAB Space       : 4
00011 **************************************************************************************************/
00012 
00013 
00014 /* Note:
00015 F1 〜 F12, PageUp, PageDownは、画面切り替えキーとしてシステムの予約とする
00016 DELは、キーリピートの変更キーとして予約
00017 
00018 キー入力処理については、再設計の余地あり...
00019 作りこむ時間がありませんでした...
00020 */
00021 
00022 
00023 /*================================================================================================
00024 ヘッダファイルをインクルード
00025 =================================================================================================*/
00026 #include <p24FJ64GA002.h>
00027 
00028 #include "types.h"
00029 
00030 #include "libvideo.h"
00031 #include "libuart.h"
00032 #include "librtc.h"
00033 #include "libadc.h"
00034 #include "libdac.h"
00035 #include "libeeprom.h"
00036 #include "libps2.h"
00037 
00038 #include "table.h"
00039 #include "ssm.h"
00040 #include "main.h"
00041 #include "extmeter.h"
00042 
00043 #include "screen.h"
00044 #include "config.h"
00045 
00046 
00047 /*================================================================================================
00048 マクロ定義
00049 =================================================================================================*/
00050 #define abs(a)                      (((a)>0) ? (a) : -(a))
00051 
00052 
00053 /*================================================================================================
00054 グローバル変数
00055 =================================================================================================*/
00056 /* 起動時の表示画面を保存するための変数. cf SCREEN_main(), SCREEN_setup_config() */
00057 static unsigned int backup;
00058 
00059 SCREEN_T screen;
00060 
00061 
00062 static METER_T meter[6];
00063 static GRAPH_T graph;
00064 static TRACK_T track;
00065 
00066 
00067 /*================================================================================================
00068 プロトタイプ宣言
00069 =================================================================================================*/
00070 static inline void SCREEN_meter1(void);
00071 static inline void SCREEN_meter2(void);
00072 static inline void SCREEN_meter3(void);
00073 static inline void SCREEN_meter4(void);
00074 static inline void SCREEN_meter5(void);
00075 static inline void SCREEN_meter6(void);
00076 static inline void SCREEN_setup_ssm(void);
00077 static inline void SCREEN_setup_video(void);
00078 static inline void SCREEN_setup_extmeter(void);
00079 static inline void SCREEN_setup_config(void);
00080 static inline void SCREEN_debug(void);
00081 static inline void SCREEN_version(void);
00082 static inline void SCREEN_lifegame(void);
00083 
00084 static inline void SCREEN_keybuf_clear(void);
00085 static inline unsigned char SCREEN_key_get(void);
00086 
00087 
00088 /**************************************************************************************************
00089 画面描画タスクの初期化
00090 **************************************************************************************************/
00091 void SCREEN_init(void)
00092 {
00093     screen.screen = 0x01;
00094     screen.screen_flag = SCREEN_INIT;
00095     screen.fps = 7;
00096 
00097     screen.track[0] = 2;
00098     screen.track[1] = 1;
00099 
00100     return;
00101 }
00102 
00103 
00104 /**************************************************************************************************
00105 画面描画タスクの初期化
00106 
00107 関数ポインタを使うと、ちょっと速くなる.
00108 **************************************************************************************************/
00109 BOOL SCREEN_main(void)
00110 {
00111     unsigned char key;
00112     static unsigned int tick = 0;
00113 
00114     if(RTC_get_ticks(tick, rtc.tick) < (10000 / screen.fps)) return(FALSE);
00115     tick = rtc.tick;
00116 
00117     /* 画面セレクト. F1 〜 F12の 12画面. うぉ、DOSっぽい */
00118     key = PS2_key_check();
00119     if(key >= KEY_F1 && key <= KEY_F12){
00120         screen.screen_flag = SCREEN_INIT;
00121         switch(PS2_key_get()){
00122         case KEY_F1:    screen.screen = 0x01;   break;
00123         case KEY_F2:    screen.screen = 0x02;   break;
00124         case KEY_F3:    screen.screen = 0x03;   break;
00125         case KEY_F4:    screen.screen = 0x04;   break;
00126         case KEY_F5:    screen.screen = 0x05;   break;
00127         case KEY_F6:    screen.screen = 0x06;   break;
00128         case KEY_F7:    screen.screen = 0x07;   break;
00129         case KEY_F8:    screen.screen = 0x08;   break;
00130         case KEY_F9:    screen.screen = 0x09;   break;
00131         case KEY_F10:   screen.screen = 0x0a;   break;
00132         case KEY_F11:   screen.screen = 0x0b;   break;
00133         case KEY_F12:   screen.screen = 0x0c;   break;
00134         }
00135 
00136     /* テンキー・キーボード用 */
00137     } else if(key == KEY_PAGEDOWN){
00138         PS2_key_get();
00139         screen.screen_flag = SCREEN_INIT;
00140         screen.screen--;
00141         if(screen.screen < 0x00) screen.screen = 0x00;
00142 
00143     } else if(key == KEY_PAGEUP){
00144         PS2_key_get();
00145         screen.screen_flag = SCREEN_INIT;
00146         screen.screen++;
00147         if(screen.screen > 0x0c) screen.screen = 0x0c;
00148 
00149     /* おまけ : キーリピートを切り替える */
00150     } else if(key == KEY_DEL){
00151         if(ps2.wait != 3000){
00152             ps2.wait = 3000;
00153             VIDEO_locate(0,1);
00154             VIDEO_putstr("Slow");
00155         } else {
00156             ps2.wait =  500;
00157             VIDEO_locate(0,1);
00158             VIDEO_putstr("Fast");
00159         }
00160         PS2_key_buf_clear();
00161     }
00162 
00163     /* 画面を表示する */
00164     switch(screen.screen){
00165     case 0x01:  SCREEN_meter1();                break;
00166     case 0x02:  SCREEN_meter2();                break;
00167     case 0x03:  SCREEN_meter3();                break;
00168     case 0x04:  SCREEN_meter4();                break;
00169     case 0x05:  SCREEN_meter5();                break;
00170     case 0x06:  SCREEN_meter6();                break;
00171     case 0x07:  SCREEN_setup_ssm();             break;
00172     case 0x08:  SCREEN_setup_video();           break;
00173     case 0x09:  SCREEN_setup_extmeter();        break;
00174     case 0x0a:  SCREEN_setup_config();          break;
00175     case 0x0b:  SCREEN_debug();                 break;
00176     case 0x0c:  SCREEN_version();               break;
00177     default:    screen.screen = 0x01;           break;          /* ここにきたらバグ */
00178     }
00179 
00180     /* 起動時の表示画面保存用 */
00181     if(screen.screen < 0x07) backup = screen.screen;
00182 
00183     return(TRUE);
00184 }
00185 
00186 
00187 /*-------------------------------------------------------------------------------------------------
00188 メータ表示1
00189 -------------------------------------------------------------------------------------------------*/
00190 static inline void SCREEN_meter1(void)
00191 {
00192     unsigned int tmp;
00193     int x, y;
00194 
00195     /* 画面初期化 */
00196     if(screen.screen_flag == SCREEN_INIT){
00197         screen.screen_flag = SCREEN_VIEW;
00198         screen.fps = 10;
00199         VIDEO_vram_clear(0x00);
00200 
00201         VIDEO_locate( 0, 0);    VIDEO_putstr("SSM Multi Monitor");
00202 
00203         VIDEO_locate( 7, 2);    VIDEO_putstr("rpm");
00204         VIDEO_locate( 7, 3);    VIDEO_putstr("km/h");
00205         VIDEO_locate( 7, 4);    VIDEO_putch ('%');
00206         VIDEO_locate( 7, 5);    VIDEO_putch ('s');
00207 
00208         VIDEO_locate(17, 2);    VIDEO_putstr("WAT");
00209         VIDEO_locate(17, 3);    VIDEO_putstr("AIR");
00210         VIDEO_locate(17, 4);    VIDEO_putch ('V');
00211         VIDEO_locate(17, 5);    VIDEO_putstr("km/L");
00212 
00213         VIDEO_locate(29, 2);    VIDEO_putstr("MAF");
00214         VIDEO_locate(29, 3);    VIDEO_putstr("AFR");
00215         VIDEO_locate(29, 4);    VIDEO_putstr("KNO");
00216         VIDEO_locate(29, 5);    VIDEO_putstr("IGN");
00217 
00218         VIDEO_locate( 6, 9);    VIDEO_putstr("kg/cm2");
00219 
00220         METER_init(&meter[0],  50, 50, 50);
00221         TRACK_init(&track,    105,  0, NTSC_WIDTH - 105, 90);
00222     }
00223 
00224     /* キーボード入力処理 */
00225     switch(SCREEN_key_get()){
00226     case KEY_UP:
00227     case KEY_DOWN:  screen.track[0] = (screen.track[0] + 1) % 3;    break;
00228     case KEY_LEFT:
00229     case KEY_RIGHT: screen.track[1] = (screen.track[1] + 1) % 3;    break;
00230     default:                                                        break;
00231     }
00232 
00233     /* ±2G -> ±1Gへ変換. あんまり賢くないコード... */
00234     x = (adc.adc[ screen.track[0] ] << 1) - 1024;
00235     y = (adc.adc[ screen.track[1] ] << 1) - 1024;
00236     x = -1 * x;
00237     if(x >  512) x =  512;
00238     if(x < -512) x = -512;
00239     if(y >  512) y =  512;
00240     if(y < -512) y = -512;
00241     x = (x + 512) / 10;
00242     y = (y + 512) / 10;
00243 
00244     /* 表示 */
00245     TRACK_putdata(&track, x, y);
00246     TRACK_draw_point(&track);
00247 /*
00248     VIDEO_locate(31,10);    VIDEO_putuint(screen.track[0], 1);
00249     VIDEO_locate(31,11);    VIDEO_putuint(screen.track[1], 1);
00250 */
00251     VIDEO_locate( 2, 2);    VIDEO_putuint(ssm_data.engine, 4);
00252     VIDEO_locate( 3, 3);    VIDEO_putuint(ssm_data.speed, 3);
00253     VIDEO_locate( 0, 4);    VIDEO_putdouble(ssm_data.throttle, 3, 1);
00254     VIDEO_locate( 5, 5);    VIDEO_putuint(ssm_data.shift, 1);
00255 
00256     VIDEO_locate(12, 2);    VIDEO_putint(ssm_data.coolant, 3);
00257     VIDEO_locate(12, 3);    VIDEO_putint(ssm_data.intakeair, 3);
00258     VIDEO_locate(11, 4);    VIDEO_putdouble(ssm_data.battery, 2, 1);
00259     VIDEO_locate(10, 5);    VIDEO_putdouble(ssm_data.fuel, 3, 1);
00260 
00261     VIDEO_locate(21, 2);    VIDEO_putdouble(ssm_data.maf, 4, 1);
00262     VIDEO_locate(21, 3);    VIDEO_putdouble(ssm_data.afr, 4, 1);
00263     VIDEO_locate(23, 4);    VIDEO_putdouble(ssm_data.knock, 2, 1);
00264     VIDEO_locate(23, 5);    VIDEO_putdouble(ssm_data.ignition, 2, 1);
00265 
00266     VIDEO_locate( 4, 8);    VIDEO_putdouble(ssm_data.boost, 1, 2);
00267 
00268     if(ssm_data.boost <= 0) tmp = (ssm_data.boost + 1.0) * 33.333;
00269     else                    tmp = 33.0 + ssm_data.boost  * 44.666;
00270     METER_draw(&meter[0], tmp);
00271 
00272     return;
00273 }
00274 
00275 
00276 /*-------------------------------------------------------------------------------------------------
00277 メータ表示2
00278 -------------------------------------------------------------------------------------------------*/
00279 static inline void SCREEN_meter2(void)
00280 {
00281     unsigned int tmp;
00282 
00283     /* 画面初期化 */
00284     if(screen.screen_flag == SCREEN_INIT){
00285         screen.screen_flag = SCREEN_VIEW;
00286         screen.fps = 10;
00287         VIDEO_vram_clear(0x00);
00288 
00289         VIDEO_locate( 0,  0);   VIDEO_putstr("Multi Meter");
00290         VIDEO_locate( 6,  4);   VIDEO_putstr("rpm");
00291         VIDEO_locate(18,  4);   VIDEO_putch ('%');
00292         VIDEO_locate(25,  4);   VIDEO_putstr("kg/cm2");
00293         VIDEO_locate( 4, 10);   VIDEO_putstr("km/h");
00294         VIDEO_locate(15, 10);   VIDEO_putstr("Water");
00295         VIDEO_locate(28, 10);   VIDEO_putstr("Air");
00296 
00297         METER_init(&meter[0],  40, 128, 40);
00298         METER_init(&meter[1], 128, 128, 40);
00299         METER_init(&meter[2], 215, 128, 40);
00300         METER_init(&meter[3],  40,  40, 40);
00301         METER_init(&meter[4], 128,  40, 40);
00302         METER_init(&meter[5], 215,  40, 40);
00303     }
00304 
00305 
00306     /* キーボード入力処理 */
00307     SCREEN_keybuf_clear();
00308 
00309     VIDEO_locate( 4, 3);    VIDEO_putuint(ssm_data.engine, 4);
00310     tmp = ((unsigned long)ssm_data.engine * 100) / 9999;
00311     METER_draw(&meter[0],    tmp);
00312 
00313     VIDEO_locate(16, 3);    VIDEO_putuint(ssm_data.throttle, 3);
00314     METER_draw(&meter[1],    ssm_data.throttle);
00315 
00316     VIDEO_locate(25, 3);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00317     if(ssm_data.boost <= 0) tmp = (ssm_data.boost + 1.0) * 33.333;
00318     else                tmp = 33.0 + ssm_data.boost  * 44.666;
00319     METER_draw(&meter[2],    tmp);
00320 
00321     VIDEO_locate( 5, 9);    VIDEO_putuint(ssm_data.speed, 3);
00322     tmp = ((unsigned int)ssm_data.speed * 100) / 255;
00323     METER_draw(&meter[3],    tmp);
00324 
00325     VIDEO_locate(15, 9);    VIDEO_putint(ssm_data.coolant, 3);
00326     tmp = (((unsigned int)ssm_data.coolant + 40) * 100) / 255;
00327     METER_draw(&meter[4],    tmp);
00328 
00329     VIDEO_locate(26, 9);    VIDEO_putint(ssm_data.intakeair, 3);
00330     tmp = (((unsigned int)ssm_data.intakeair + 40) * 100) / 255;
00331     METER_draw(&meter[5],    tmp);
00332 
00333     return;
00334 }
00335 
00336 
00337 /*-------------------------------------------------------------------------------------------------
00338 メータ表示3
00339 -------------------------------------------------------------------------------------------------*/
00340 static inline void SCREEN_meter3(void)
00341 {
00342     unsigned int tmp;
00343 
00344     /* 画面初期化 */
00345     if(screen.screen_flag == SCREEN_INIT){
00346         screen.screen_flag = SCREEN_VIEW;
00347         screen.fps = 10;
00348         VIDEO_vram_clear(0x00);
00349 
00350         VIDEO_locate( 0, 0);    VIDEO_putstr("Fuel Consumption Monitor");
00351 
00352         VIDEO_locate( 5, 4);    VIDEO_putstr("rpm");
00353         VIDEO_locate(13, 4);    VIDEO_putstr("km/h");
00354         VIDEO_locate( 2, 9);    VIDEO_putstr("kg/cm2");
00355         VIDEO_locate(15, 9);    VIDEO_putstr("%");
00356         VIDEO_locate( 5,11);    VIDEO_putstr("WAT");
00357         VIDEO_locate(14,11);    VIDEO_putstr("AIR");
00358 
00359         METER_init(&meter[0],  36, 132, 36);
00360         METER_init(&meter[1], 112, 132, 36);
00361         METER_init(&meter[2],  36,  57, 36);
00362         METER_init(&meter[3], 112,  57, 36);
00363 
00364         VIDEO_locate(28, 2);    VIDEO_putstr("Fe/h");
00365         VIDEO_locate(28, 3);    VIDEO_putstr("ml/s");
00366         VIDEO_locate(28, 4);    VIDEO_putstr("km/L");
00367         GRAPH_init(&graph, 152,   0, NTSC_WIDTH - 152, 100);
00368     }
00369 
00370     /* キーボード入力処理 */
00371     SCREEN_keybuf_clear();
00372 
00373     VIDEO_locate( 3, 3);    VIDEO_putuint(ssm_data.engine, 4);
00374     tmp = ((unsigned long)ssm_data.engine * 100) / 9999;
00375     METER_draw(&meter[0],    tmp);
00376 
00377     VIDEO_locate(13, 3);    VIDEO_putuint(ssm_data.speed, 3);
00378     tmp = ((unsigned int)ssm_data.speed * 100) / 255;
00379     METER_draw(&meter[1],    tmp);
00380 
00381     VIDEO_locate( 2, 8);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00382     if(ssm_data.boost <= 0) tmp = (ssm_data.boost + 1.0) * 33.333;
00383     else                tmp = 33.0 + ssm_data.boost  * 44.666;
00384     METER_draw(&meter[2],    tmp);
00385     
00386     VIDEO_locate(13, 8);    VIDEO_putuint(ssm_data.throttle, 3);
00387     METER_draw(&meter[3],    ssm_data.throttle);
00388 
00389     VIDEO_locate( 0,11);    VIDEO_putint(ssm_data.coolant, 3);
00390     VIDEO_locate( 9,11);    VIDEO_putint(ssm_data.intakeair, 3);
00391 
00392     VIDEO_locate(18, 2);    VIDEO_putdouble((ssm_data.fuel_rate * (double)ssm.price * 3.6), 4, 3);
00393     VIDEO_locate(19, 3);    VIDEO_putdouble( ssm_data.fuel_rate, 3, 3);
00394     VIDEO_locate(19, 4);    VIDEO_putdouble( ssm_data.fuel, 3, 3);
00395     GRAPH_putdata(&graph, (unsigned int)(ssm_data.fuel * 3.0));
00396     GRAPH_draw_line(&graph);
00397 
00398     return;
00399 }
00400 
00401 
00402 /*-------------------------------------------------------------------------------------------------
00403 メータ表示4
00404 -------------------------------------------------------------------------------------------------*/
00405 static inline void SCREEN_meter4(void)
00406 {
00407     unsigned int tmp;
00408 
00409     /* 画面初期化 */
00410     if(screen.screen_flag == SCREEN_INIT){
00411         screen.screen_flag = SCREEN_VIEW;
00412         screen.fps = 10;
00413         VIDEO_vram_clear(0x00);
00414 
00415         VIDEO_locate(20, 9);    VIDEO_putstr("rpm");
00416         VIDEO_locate(20,10);    VIDEO_putstr("km/h");
00417         VIDEO_locate(20,11);    VIDEO_putstr("km/L");
00418 
00419         VIDEO_locate(31, 9);    VIDEO_putch('%');
00420         VIDEO_locate(31,10);    VIDEO_putch('C');
00421         VIDEO_locate(31,11);    VIDEO_putch('s');
00422 
00423         METER_init(&meter[0], 50, 50, 50);
00424         VIDEO_locate( 5,10);    VIDEO_putstr("kg/cm2");
00425     }
00426 
00427     /* キーボード入力処理 */
00428     SCREEN_keybuf_clear();
00429 
00430     /* 表示 */
00431     if(ssm_data.boost <= 0) tmp = (ssm_data.boost + 1.0) * 33.333;
00432     else                    tmp = 33.0 + ssm_data.boost  * 44.666;
00433     METER_draw(&meter[0], tmp);
00434 
00435     VIDEO_locate( 4, 9);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00436 
00437 
00438     VIDEO_locate(15, 9);    VIDEO_putuint(ssm_data.engine, 4);
00439     VIDEO_locate(16,10);    VIDEO_putuint(ssm_data.speed, 3);
00440     VIDEO_locate(13,11);    VIDEO_putdouble(ssm_data.fuel, 3, 1);
00441 
00442 
00443     VIDEO_locate(24, 9);    VIDEO_putdouble(ssm_data.throttle, 3, 1);
00444     VIDEO_locate(27,10);    VIDEO_putuint(ssm_data.coolant, 3);
00445     VIDEO_locate(29,11);    VIDEO_putuint(ssm_data.shift, 1);
00446 
00447     return;
00448 }
00449 
00450 
00451 /*-------------------------------------------------------------------------------------------------
00452 メータ表示5
00453 -------------------------------------------------------------------------------------------------*/
00454 static inline void SCREEN_meter5(void)
00455 {
00456     int x, y;
00457 
00458     /* 画面初期化 */
00459     if(screen.screen_flag == SCREEN_INIT){
00460         screen.screen_flag = SCREEN_VIEW;
00461         screen.fps = 10;
00462         VIDEO_vram_clear(0x00);
00463 
00464         VIDEO_locate(20, 9);    VIDEO_putstr("rpm");
00465         VIDEO_locate(20,10);    VIDEO_putstr("km/h");
00466         VIDEO_locate(20,11);    VIDEO_putstr("kg/cm2");
00467 
00468         VIDEO_locate(31, 9);    VIDEO_putch('%');
00469         VIDEO_locate(31,10);    VIDEO_putch('C');
00470         VIDEO_locate(31,11);    VIDEO_putch('s');
00471 
00472         TRACK_init(&track, 0, 0, 100, 50);
00473     }
00474 
00475     /* キーボード入力処理 */
00476     switch(SCREEN_key_get()){
00477     case KEY_UP:
00478     case KEY_DOWN:  screen.track[0] = (screen.track[0] + 1) % 3;    break;
00479     case KEY_LEFT:
00480     case KEY_RIGHT: screen.track[1] = (screen.track[1] + 1) % 3;    break;
00481     default:                                            break;
00482     }
00483 
00484     /* ±2G -> ±1Gへ変換. あんまり賢くないコード... */
00485     x = (adc.adc[ screen.track[0] ] << 1) - 1024;
00486     y = (adc.adc[ screen.track[1] ] << 1) - 1024;
00487     x = -1 * x;
00488     if(x >  512) x =  512;
00489     if(x < -512) x = -512;
00490     if(y >  512) y =  512;
00491     if(y < -512) y = -512;
00492     x = (x + 512) / 10;
00493     y = (y + 512) / 10;
00494 
00495     /* 表示 */
00496     TRACK_putdata(&track, (1024 - adc.adc[ screen.track[0] ]) / 10, adc.adc[ screen.track[1] ] / 10);
00497     TRACK_draw_point(&track);
00498 
00499     VIDEO_locate(13, 9);    VIDEO_putuint(screen.track[0], 1);
00500     VIDEO_locate(13,10);    VIDEO_putuint(screen.track[1], 1);
00501 
00502     VIDEO_locate(15, 9);    VIDEO_putuint(ssm_data.engine, 4);
00503     VIDEO_locate(16,10);    VIDEO_putuint(ssm_data.speed, 3);
00504     VIDEO_locate(14,11);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00505 
00506     VIDEO_locate(24, 9);    VIDEO_putdouble(ssm_data.throttle, 3, 1);
00507     VIDEO_locate(27,10);    VIDEO_putuint(ssm_data.coolant, 3);
00508     VIDEO_locate(29,11);    VIDEO_putuint(ssm_data.shift, 1);
00509 
00510 
00511     return;
00512 }
00513 
00514 
00515 /*-------------------------------------------------------------------------------------------------
00516 メータ表示6
00517 -------------------------------------------------------------------------------------------------*/
00518 static inline void SCREEN_meter6(void)
00519 {
00520     /* 画面初期化 */
00521     if(screen.screen_flag == SCREEN_INIT){
00522         screen.screen_flag = SCREEN_VIEW;
00523         screen.fps = 10;
00524         VIDEO_vram_clear(0x00);
00525 
00526         VIDEO_locate( 9,11);    VIDEO_putstr("km/L");
00527 
00528         VIDEO_locate(20, 9);    VIDEO_putstr("rpm");
00529         VIDEO_locate(20,10);    VIDEO_putstr("km/h");
00530         VIDEO_locate(20,11);    VIDEO_putstr("kg/cm2");
00531 
00532         VIDEO_locate(31, 9);    VIDEO_putch('%');
00533         VIDEO_locate(31,10);    VIDEO_putch('C');
00534         VIDEO_locate(31,11);    VIDEO_putch('s');
00535 
00536         GRAPH_init(&graph, 0, 16, 108, 32);
00537     }
00538 
00539     /* キーボード入力処理 */
00540     SCREEN_keybuf_clear();
00541 
00542     /* 表示 */
00543     GRAPH_putdata(&graph, (unsigned int)ssm_data.fuel * 3);
00544     GRAPH_draw_line(&graph);
00545     VIDEO_locate(2,11);     VIDEO_putdouble(ssm_data.fuel, 3, 1);
00546 
00547     VIDEO_locate(15, 9);    VIDEO_putuint(ssm_data.engine, 4);
00548     VIDEO_locate(16,10);    VIDEO_putuint(ssm_data.speed, 3);
00549     VIDEO_locate(14,11);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00550 
00551     VIDEO_locate(24, 9);    VIDEO_putdouble(ssm_data.throttle, 3, 1);
00552     VIDEO_locate(27,10);    VIDEO_putuint(ssm_data.coolant, 3);
00553     VIDEO_locate(29,11);    VIDEO_putuint(ssm_data.shift, 1);
00554 
00555     return;
00556 }
00557 
00558 
00559 /*-------------------------------------------------------------------------------------------------
00560 SSMの設定
00561 -------------------------------------------------------------------------------------------------*/
00562 static inline void SCREEN_setup_ssm(void)
00563 {
00564     static char cursol;
00565     char run = 0;
00566     char i;
00567 
00568     /* 画面初期化 */
00569     if(screen.screen_flag == SCREEN_INIT){
00570         screen.screen_flag = SCREEN_VIEW;
00571         screen.fps = 20;
00572         VIDEO_vram_clear(0x00);
00573         cursol = 0;
00574 
00575         VIDEO_locate( 0, 0);    VIDEO_putstr("SSM Setup");
00576         VIDEO_locate(16, 0);    VIDEO_putstr("UART1");
00577         VIDEO_locate(24, 0);    VIDEO_putstr("UART2");
00578 
00579         VIDEO_locate( 1, 2);    VIDEO_putstr("MODE");
00580 
00581         VIDEO_locate( 1, 4);    VIDEO_putstr("TIRE Width");
00582         VIDEO_locate( 1, 5);    VIDEO_putstr("TIRE Flat");
00583         VIDEO_locate( 1, 6);    VIDEO_putstr("TIRE Inch");
00584         VIDEO_locate( 1, 7);    VIDEO_putstr("TIRE Circle");
00585         VIDEO_locate( 1, 8);    VIDEO_putstr("Fuel Price");
00586         VIDEO_locate( 1, 9);    VIDEO_putstr("SSM Wait");
00587         VIDEO_locate( 1,10);    VIDEO_putstr("SSM Cycle");
00588         VIDEO_locate( 1,11);    VIDEO_putstr("SSM Error");
00589 
00590         VIDEO_locate(20, 4);    VIDEO_putstr("Final");
00591         VIDEO_locate(20, 5);    VIDEO_putstr("1st");
00592         VIDEO_locate(20, 6);    VIDEO_putstr("2nd");
00593         VIDEO_locate(20, 7);    VIDEO_putstr("3rd");
00594         VIDEO_locate(20, 8);    VIDEO_putstr("4th");
00595         VIDEO_locate(20, 9);    VIDEO_putstr("5th");
00596         VIDEO_locate(20,10);    VIDEO_putstr("6th");
00597         VIDEO_locate(20,11);    VIDEO_putstr("7th");
00598     }
00599 
00600     /* キーボード入力処理 */
00601     switch(SCREEN_key_get()){
00602     case KEY_UP:        cursol--;       break;
00603     case KEY_DOWN:      cursol++;       break;
00604     case KEY_LEFT:      run = -1;       break;
00605     case KEY_RIGHT:     run =  1;       break;
00606     default:                            break;
00607     }
00608 
00609     /* カーソル確認/表示 */
00610     if(cursol <  0) cursol =  0;
00611     if(cursol > 16) cursol = 16;
00612 
00613     VIDEO_locate(0, 2);
00614     if(cursol == 0)     VIDEO_putch('>');
00615     else                VIDEO_putch(' ');
00616 
00617     for(i = 1; i < 9; i++){
00618         VIDEO_locate(0, 3 + i);
00619         if(cursol == i) VIDEO_putch('>');
00620         else            VIDEO_putch(' ');
00621     }
00622     for(; i < 17; i++){
00623         VIDEO_locate(19, i - 5);
00624         if(cursol == i) VIDEO_putch('>');
00625         else            VIDEO_putch(' ');
00626     }
00627 
00628     /* 実行 */
00629     if(run == -1 || run == 1){
00630         switch(cursol){
00631         case  0:
00632             if(run == -1)   ssm.mode = SSM_MODE_OPENSSM;
00633             else            ssm.mode = SSM_MODE_OPENPORT;
00634             break;
00635 
00636         case  1:    ssm.tire_width += run;                      break;
00637         case  2:    ssm.tire_flat += run;                       break;
00638         case  3:    ssm.tire_inch += run;                       break;
00639 
00640         case  5:    ssm.price += run;                           break;
00641         case  6:    ssm.wait += run;                            break;
00642 
00643         case  9:    ssm.gear_ratio[0] += (double)run * 0.001;   break;
00644         case 10:    ssm.gear_ratio[1] += (double)run * 0.001;   break;
00645         case 11:    ssm.gear_ratio[2] += (double)run * 0.001;   break;
00646         case 12:    ssm.gear_ratio[3] += (double)run * 0.001;   break;
00647         case 13:    ssm.gear_ratio[4] += (double)run * 0.001;   break;
00648         case 14:    ssm.gear_ratio[5] += (double)run * 0.001;   break;
00649         case 15:    ssm.gear_ratio[6] += (double)run * 0.001;   break;
00650         case 16:    ssm.gear_ratio[7] += (double)run * 0.001;   break;
00651         default:                                                break;
00652         }
00653 
00654         ssm.tire_circle = SSM_TIRE_R(ssm.tire_width, ssm.tire_flat, ssm.tire_inch);
00655     }
00656 
00657 
00658     /* 表示 */
00659     VIDEO_locate( 6, 2);
00660     switch(ssm.mode){
00661     case SSM_MODE_OPENSSM:  VIDEO_putstr("OpenSSM ");   break;
00662     case SSM_MODE_OPENPORT:
00663     default:
00664                             VIDEO_putstr("OpenPort");   break;
00665     }
00666 
00667     VIDEO_locate(16, 1);    VIDEO_putdouble(UART1_get_baud() / 1000.0, 3, 1);   VIDEO_putch('k');
00668     VIDEO_locate(25, 1);    VIDEO_putdouble(UART2_get_baud() / 1000.0, 3, 1);   VIDEO_putch('k');
00669 
00670     VIDEO_locate(16, 2);    VIDEO_putuint(UART1_get_sendbuf(), 3);  VIDEO_putch('/');   VIDEO_putuint(UART1_TX_BUFFER_SIZE, 3);
00671     VIDEO_locate(16, 3);    VIDEO_putuint(UART1_get_recvbuf(), 3);  VIDEO_putch('/');   VIDEO_putuint(UART1_RX_BUFFER_SIZE, 3);
00672 
00673     VIDEO_locate(25, 2);    VIDEO_putuint(UART2_get_sendbuf(), 3);  VIDEO_putch('/');   VIDEO_putuint(UART2_TX_BUFFER_SIZE, 3);
00674     VIDEO_locate(25, 3);    VIDEO_putuint(UART2_get_recvbuf(), 3);  VIDEO_putch('/');   VIDEO_putuint(UART2_RX_BUFFER_SIZE, 3);
00675 
00676     VIDEO_locate(14, 4);    VIDEO_putuint(ssm.tire_width, 4);
00677     VIDEO_locate(15, 5);    VIDEO_putuint(ssm.tire_flat, 3);
00678     VIDEO_locate(15, 6);    VIDEO_putuint(ssm.tire_inch, 3);
00679     VIDEO_locate(13, 7);    VIDEO_putuint(ssm.tire_circle, 5);
00680     VIDEO_locate(13, 8);    VIDEO_putuint(ssm.price, 5);
00681     VIDEO_locate(13, 9);    VIDEO_putuint(ssm.wait, 5);
00682     VIDEO_locate(13,10);    VIDEO_putuint(ssm.cycle, 5);
00683     VIDEO_locate(13,11);    VIDEO_putuint(ssm.error, 5);
00684 
00685     VIDEO_locate(26, 4);    VIDEO_putdouble(ssm.gear_ratio[0], 1, 3);
00686     VIDEO_locate(26, 5);    VIDEO_putdouble(ssm.gear_ratio[1], 1, 3);
00687     VIDEO_locate(26, 6);    VIDEO_putdouble(ssm.gear_ratio[2], 1, 3);
00688     VIDEO_locate(26, 7);    VIDEO_putdouble(ssm.gear_ratio[3], 1, 3);
00689     VIDEO_locate(26, 8);    VIDEO_putdouble(ssm.gear_ratio[4], 1, 3);
00690     VIDEO_locate(26, 9);    VIDEO_putdouble(ssm.gear_ratio[5], 1, 3);
00691     VIDEO_locate(26,10);    VIDEO_putdouble(ssm.gear_ratio[6], 1, 3);
00692     VIDEO_locate(26,11);    VIDEO_putdouble(ssm.gear_ratio[7], 1, 3);
00693 
00694     return;
00695 }
00696 
00697 
00698 /*-------------------------------------------------------------------------------------------------
00699 ビデオの設定
00700 -------------------------------------------------------------------------------------------------*/
00701 static inline void SCREEN_setup_video(void)
00702 {
00703     static char cursol;
00704     char run = 0;
00705     unsigned int i;
00706 
00707     /* 画面初期化 */
00708     if(screen.screen_flag == SCREEN_INIT){
00709         screen.screen_flag = SCREEN_VIEW;
00710         screen.fps = 5;
00711         VIDEO_vram_clear(0x00);
00712         cursol = 0;
00713 
00714         VIDEO_locate( 1, 1);    VIDEO_putstr("NTSC Setup");
00715 
00716         VIDEO_locate( 1, 2);    VIDEO_putstr("line");
00717         VIDEO_locate( 1, 3);    VIDEO_putstr("line_sync");
00718         VIDEO_locate( 1, 4);    VIDEO_putstr("line_space");
00719         VIDEO_locate( 1, 5);    VIDEO_putstr("line_video");
00720         VIDEO_locate( 1, 6);    VIDEO_putstr("horizon");
00721         VIDEO_locate( 1, 7);    VIDEO_putstr("serration");
00722         VIDEO_locate( 1, 8);    VIDEO_putstr("equalizing");
00723         VIDEO_locate( 1, 9);    VIDEO_putstr("left_space");
00724         VIDEO_locate( 1,10);    VIDEO_putstr("width");
00725 
00726         VIDEO_locate(12, 1);    VIDEO_putstr("Monitor");
00727         VIDEO_locate(20, 1);    VIDEO_putstr("Superimpose");
00728 
00729         /* 白枠 */
00730         VIDEO_line(             1,               1, NTSC_WIDTH - 2,               1);
00731         VIDEO_line(             1,               1,              1, NTSC_HEIGHT - 1);
00732         VIDEO_line(NTSC_WIDTH - 2,               1, NTSC_WIDTH - 2, NTSC_HEIGHT - 1);
00733         VIDEO_line(             1, NTSC_HEIGHT - 1, NTSC_WIDTH - 2, NTSC_HEIGHT - 1);
00734 
00735         VIDEO_line(             2,               2, NTSC_WIDTH - 3,               2);
00736         VIDEO_line(             2,               2,              2, NTSC_HEIGHT - 2);
00737         VIDEO_line(NTSC_WIDTH - 3,               2, NTSC_WIDTH - 3, NTSC_HEIGHT - 2);
00738         VIDEO_line(             2, NTSC_HEIGHT - 2, NTSC_WIDTH - 3, NTSC_HEIGHT - 2);
00739 
00740         VIDEO_line(             3,               3, NTSC_WIDTH - 4,               3);
00741         VIDEO_line(             3,               3,              3, NTSC_HEIGHT - 3);
00742         VIDEO_line(NTSC_WIDTH - 4,               3, NTSC_WIDTH - 4, NTSC_HEIGHT - 3);
00743         VIDEO_line(             3, NTSC_HEIGHT - 3, NTSC_WIDTH - 4, NTSC_HEIGHT - 3);
00744 
00745         VIDEO_line(             4,               4, NTSC_WIDTH - 5,               4);
00746         VIDEO_line(             4,               4,              4, NTSC_HEIGHT - 4);
00747         VIDEO_line(NTSC_WIDTH - 5,               4, NTSC_WIDTH - 5, NTSC_HEIGHT - 4);
00748         VIDEO_line(             4, NTSC_HEIGHT - 4, NTSC_WIDTH - 5, NTSC_HEIGHT - 4);
00749     }
00750 
00751 
00752     /* キーボード入力処理 */
00753     switch(SCREEN_key_get()){
00754     case KEY_UP:        cursol--;       break;
00755     case KEY_DOWN:      cursol++;       break;
00756     case KEY_LEFT:      run = -1;       break;
00757     case KEY_RIGHT:     run =  1;       break;
00758     default:                            break;
00759     }
00760 
00761     /* カーソル確認/表示 */
00762     if(cursol <  0) cursol =  0;
00763     if(cursol > 17) cursol = 17;
00764     for(i = 0; i < 9; i++){
00765         VIDEO_locate(13, 2 + i);
00766         if(cursol == i) VIDEO_putch('>');
00767         else            VIDEO_putch(' ');
00768     }
00769     for(; i < 18; i++){
00770         VIDEO_locate(25, i - 7);
00771         if(cursol == i) VIDEO_putch('>');
00772         else            VIDEO_putch(' ');
00773     }
00774 
00775     /* 実行 */
00776     if(run == -1 || run == 1){
00777         switch(cursol){
00778         case  0:    ntsc.monitor.line += run;                   break;
00779         case  1:    ntsc.monitor.line_sync += run;              break;
00780         case  2:    ntsc.monitor.line_space_top += run;         break;
00781         case  3:    ntsc.monitor.line_video += run;             break;
00782         case  4:    ntsc.monitor.horizon_pulse += run;          break;
00783         case  5:    ntsc.monitor.serration_pulse += run;        break;
00784         case  6:    ntsc.monitor.equalizing_pulse += run;       break;
00785         case  7:    ntsc.monitor.left_space += run;             break;
00786         case  8:    ntsc.monitor.video_width += run;            break;
00787         case  9:    ntsc.superimpose.line += run;               break;
00788         case 10:    ntsc.superimpose.line_sync += run;          break;
00789         case 11:    ntsc.superimpose.line_space_top += run;     break;
00790         case 12:    ntsc.superimpose.line_video += run;         break;
00791         case 13:    ntsc.superimpose.horizon_pulse += run;      break;
00792         case 14:    ntsc.superimpose.serration_pulse += run;    break;
00793         case 15:    ntsc.superimpose.equalizing_pulse += run;   break;
00794         case 16:    ntsc.superimpose.left_space += run;         break;
00795         case 17:    ntsc.superimpose.video_width += run;        break;
00796         default:                                                break;
00797         }
00798     }
00799 
00800     /* 表示 */
00801     VIDEO_locate(14, 2);    VIDEO_putuint(ntsc.monitor.line, 5);
00802     VIDEO_locate(14, 3);    VIDEO_putuint(ntsc.monitor.line_sync, 5);
00803     VIDEO_locate(14, 4);    VIDEO_putuint(ntsc.monitor.line_space_top, 5);
00804     VIDEO_locate(14, 5);    VIDEO_putuint(ntsc.monitor.line_video, 5);
00805     VIDEO_locate(14, 6);    VIDEO_putuint(ntsc.monitor.horizon_pulse, 5);
00806     VIDEO_locate(14, 7);    VIDEO_putuint(ntsc.monitor.serration_pulse, 5);
00807     VIDEO_locate(14, 8);    VIDEO_putuint(ntsc.monitor.equalizing_pulse, 5);
00808     VIDEO_locate(14, 9);    VIDEO_putuint(ntsc.monitor.left_space, 5);
00809     VIDEO_locate(14,10);    VIDEO_putuint(ntsc.monitor.video_width, 5);
00810 
00811     VIDEO_locate(26, 2);    VIDEO_putuint(ntsc.superimpose.line, 5);
00812     VIDEO_locate(26, 3);    VIDEO_putuint(ntsc.superimpose.line_sync, 5);
00813     VIDEO_locate(26, 4);    VIDEO_putuint(ntsc.superimpose.line_space_top, 5);
00814     VIDEO_locate(26, 5);    VIDEO_putuint(ntsc.superimpose.line_video, 5);
00815     VIDEO_locate(26, 6);    VIDEO_putuint(ntsc.superimpose.horizon_pulse, 5);
00816     VIDEO_locate(26, 7);    VIDEO_putuint(ntsc.superimpose.serration_pulse, 5);
00817     VIDEO_locate(26, 8);    VIDEO_putuint(ntsc.superimpose.equalizing_pulse, 5);
00818     VIDEO_locate(26, 9);    VIDEO_putuint(ntsc.superimpose.left_space, 5);
00819     VIDEO_locate(26,10);    VIDEO_putuint(ntsc.superimpose.video_width, 5);
00820 
00821     return;
00822 }
00823 
00824 
00825 /*-------------------------------------------------------------------------------------------------
00826 外付けメータの設定
00827 -------------------------------------------------------------------------------------------------*/
00828 static inline void SCREEN_setup_extmeter(void)
00829 {
00830     static unsigned char target = 0;
00831     static char cursol;
00832     char run = 0;
00833     unsigned int i;
00834 
00835     /* 画面初期化 */
00836     if(screen.screen_flag == SCREEN_INIT){
00837         screen.screen_flag = SCREEN_VIEW;
00838         screen.fps = 10;
00839         VIDEO_vram_clear(0x00);
00840         cursol = 0;
00841 
00842         target = extmeter.target;
00843 
00844         VIDEO_locate( 0, 0);    VIDEO_putstr("External Meter Setup");
00845 
00846         VIDEO_locate( 1, 2);    VIDEO_putstr("TARGET");
00847         VIDEO_locate( 1, 4);    VIDEO_putstr("0x0f");
00848         VIDEO_locate( 1, 5);    VIDEO_putstr("0x1f");
00849         VIDEO_locate( 1, 6);    VIDEO_putstr("0x2f");
00850         VIDEO_locate( 1, 7);    VIDEO_putstr("0x3f");
00851         VIDEO_locate( 1, 8);    VIDEO_putstr("0x4f");
00852         VIDEO_locate( 1, 9);    VIDEO_putstr("0x5f");
00853         VIDEO_locate( 1,10);    VIDEO_putstr("0x6f");
00854         VIDEO_locate( 1,11);    VIDEO_putstr("0x7f");
00855         VIDEO_locate(16, 4);    VIDEO_putstr("0x8f");
00856         VIDEO_locate(16, 5);    VIDEO_putstr("0x9f");
00857         VIDEO_locate(16, 6);    VIDEO_putstr("0xaf");
00858         VIDEO_locate(16, 7);    VIDEO_putstr("0xbf");
00859         VIDEO_locate(16, 8);    VIDEO_putstr("0xcf");
00860         VIDEO_locate(16, 9);    VIDEO_putstr("0xdf");
00861         VIDEO_locate(16,10);    VIDEO_putstr("0xef");
00862         VIDEO_locate(16,11);    VIDEO_putstr("0xff");
00863     }
00864 
00865     /* キーボード入力処理 */
00866     switch(SCREEN_key_get()){
00867     case KEY_UP:        cursol--;       break;
00868     case KEY_DOWN:      cursol++;       break;
00869     case KEY_LEFT:      run = -1;       break;
00870     case KEY_RIGHT:     run =  1;       break;
00871     default:                            break;
00872     }
00873 
00874     /* カーソル確認/表示 */
00875     if(cursol <  0) cursol =  0;
00876     if(cursol > 17) cursol = 17;
00877     for(i = 0; i < 10; i++){
00878         VIDEO_locate( 0, 2 + i);
00879         if(cursol == i) VIDEO_putch('>');
00880         else            VIDEO_putch(' ');
00881     }
00882     for(; i < 18; i++){
00883         VIDEO_locate(15, 4 + i - 10);
00884         if(cursol == i) VIDEO_putch('>');
00885         else            VIDEO_putch(' ');
00886     }
00887 
00888     /* 実行 */
00889     switch(cursol){
00890     case  0:
00891         extmeter.target = target;
00892         if(run == -1 || run == 1){
00893             target += run;
00894             if(target < 1) target = 1;
00895             if(target > 6) target = 6;
00896             EXTMETER_init(target);
00897         }
00898         break;
00899 
00900     case  1:
00901         extmeter.target = target;
00902         break;
00903 
00904     default:
00905         extmeter.target  = EXTMETER_SETTING;
00906         extmeter.setting = ((cursol - 2) << 4) + 0x0f;
00907         if(run == -1 || run == 1){
00908             switch(target){
00909             case EXTMETER_ENGINE:       extmeter.map[ cursol - 2 ] += 100 * run;        break;
00910             case EXTMETER_BOOST:        extmeter.map[ cursol - 2 ] += 0.01 * run;       break;
00911             case EXTMETER_THROTTLE:     extmeter.map[ cursol - 2 ] += 0.1 * run;        break;
00912             case EXTMETER_SPEED:
00913             case EXTMETER_COOLANT:
00914             case EXTMETER_INTAKEAIR:
00915                                         extmeter.map[ cursol - 2 ] += 1 * run;          break;
00916             default:                                                                    break;
00917             }
00918         }
00919 
00920         break;
00921     }
00922 
00923     /* 表示 */
00924     VIDEO_locate( 8, 2);
00925     switch(extmeter.target){
00926     case EXTMETER_SETTING:      VIDEO_putstr("-SETTING MODE-");     break;
00927     case EXTMETER_SPEED:        VIDEO_putstr("Vechile Speed ");     break;
00928     case EXTMETER_ENGINE:       VIDEO_putstr("Engine Speed  ");     break;
00929     case EXTMETER_BOOST:        VIDEO_putstr("Boost Meter   ");     break;
00930     case EXTMETER_THROTTLE:     VIDEO_putstr("Throttle      ");     break;
00931     case EXTMETER_COOLANT:      VIDEO_putstr("Coolant Temp  ");     break;
00932     case EXTMETER_INTAKEAIR:    VIDEO_putstr("IntakeAir Temp");     break;
00933     default:                                                        break;
00934     }
00935     for(i = 0; i < 8; i++){
00936         VIDEO_locate( 6, 4 + i);
00937         VIDEO_putdouble(extmeter.map[i], 4, 2);
00938     }
00939     for(; i < 16; i++){
00940         VIDEO_locate(21, 4 + i - 8);
00941         VIDEO_putdouble(extmeter.map[i], 4, 2);
00942     }
00943 
00944     return;
00945 }
00946 
00947 
00948 /*-------------------------------------------------------------------------------------------------
00949 環境設定の保存と読み出し
00950 -------------------------------------------------------------------------------------------------*/
00951 static inline void SCREEN_setup_config(void)
00952 {
00953     static char cursol;
00954     char run = 0;
00955     unsigned int i;
00956 
00957     /* 画面初期化 */
00958     if(screen.screen_flag == SCREEN_INIT){
00959         screen.screen_flag = SCREEN_VIEW;
00960         screen.fps = 5;
00961         VIDEO_vram_clear(0x00);
00962 
00963         cursol = 0;
00964 
00965         VIDEO_locate( 0, 0);    VIDEO_putstr("Configuration Setup");
00966 
00967         VIDEO_locate( 1, 2);    VIDEO_putstr("Load");
00968         VIDEO_locate( 1, 3);    VIDEO_putstr("Save");
00969         VIDEO_locate( 1, 4);    VIDEO_putstr("Initialize");
00970     }
00971 
00972     /* キーボード入力処理 */
00973     switch(SCREEN_key_get()){
00974     case KEY_UP:        cursol--;       break;
00975     case KEY_DOWN:      cursol++;       break;
00976     case KEY_ENTER:     run = 1;        break;
00977     default:                            break;
00978     }
00979 
00980     /* カーソル確認/表示 */
00981     if(cursol < 0) cursol = 0;
00982     if(cursol > 2) cursol = 2;
00983     for(i = 0; i < 3; i++){
00984         VIDEO_locate( 0, 2 + i);
00985         if(cursol == i) VIDEO_putch('>');
00986         else            VIDEO_putch(' ');
00987     }
00988 
00989     /* 実行 */
00990     if(run == 1){
00991         switch(cursol){
00992         case 0:
00993             VIDEO_locate( 5, 6);        VIDEO_putstr("Now Loading...");
00994             if(CONFIG_load()){
00995                 VIDEO_locate( 5, 6);    VIDEO_putstr("Load Success  ");
00996             } else {
00997                 VIDEO_locate( 5, 6);    VIDEO_putstr("Load Failed   ");
00998             }
00999             screen.screen = 0x0a;
01000             screen.screen_flag = SCREEN_VIEW;
01001             break;
01002 
01003         case 1:
01004             screen.screen = backup;
01005             screen.screen_flag = SCREEN_INIT;
01006             VIDEO_locate( 5, 6);        VIDEO_putstr("Now Saving... ");
01007             if(CONFIG_save()){
01008                 VIDEO_locate( 5, 6);    VIDEO_putstr("Save Success  ");
01009             } else {
01010                 VIDEO_locate( 5, 6);    VIDEO_putstr("Save Failed   ");
01011             }
01012             screen.screen = 0x0a;
01013             screen.screen_flag = SCREEN_VIEW;
01014             break;
01015 
01016         case 2:
01017             SSM_init();
01018             SCREEN_init();
01019             screen.screen = 0x0a;
01020             screen.screen_flag = SCREEN_VIEW;
01021             EXTMETER_init(EXTMETER_BOOST);
01022             VIDEO_locate( 5, 6);        VIDEO_putstr("Init Success  ");
01023             break;
01024 
01025         default:
01026             break;
01027         }
01028     }
01029 
01030 
01031     return;
01032 }
01033 
01034 
01035 /*-------------------------------------------------------------------------------------------------
01036 デバック用情報表示画面
01037 -------------------------------------------------------------------------------------------------*/
01038 static inline void SCREEN_debug(void)
01039 {
01040     /* 画面初期化 */
01041     if(screen.screen_flag == SCREEN_INIT){
01042         screen.screen_flag = SCREEN_VIEW;
01043         screen.fps = 10;
01044         VIDEO_vram_clear(0x00);
01045 
01046         VIDEO_locate( 0, 0);    VIDEO_putstr("DEBUG Monitor");
01047 
01048         VIDEO_locate( 0, 2);    VIDEO_putstr("PortA");
01049         VIDEO_locate( 0, 3);    VIDEO_putstr("PortB");
01050         VIDEO_locate( 0, 4);    VIDEO_putstr("DAC");
01051         VIDEO_locate( 0, 5);    VIDEO_putstr("ADC-0");
01052         VIDEO_locate( 0, 6);    VIDEO_putstr("ADC-1");
01053         VIDEO_locate( 0, 7);    VIDEO_putstr("ADC-2");
01054         VIDEO_locate( 0, 9);    VIDEO_putstr("Last");
01055         VIDEO_locate( 0,10);    VIDEO_putstr("Cycle");
01056         VIDEO_locate( 0,11);    VIDEO_putstr("Error");
01057 
01058         VIDEO_locate(11, 2);    VIDEO_putstr("Speed");
01059         VIDEO_locate(11, 3);    VIDEO_putstr("Engine");
01060         VIDEO_locate(11, 4);    VIDEO_putstr("Throttle");
01061         VIDEO_locate(11, 5);    VIDEO_putstr("Boost");
01062         VIDEO_locate(11, 6);    VIDEO_putstr("Gear");
01063         VIDEO_locate(11, 7);    VIDEO_putstr("Temp");
01064         VIDEO_locate(11, 8);    VIDEO_putstr("Battery");
01065         VIDEO_locate(11, 9);    VIDEO_putstr("MAF");
01066         VIDEO_locate(11,10);    VIDEO_putstr("AF Rate");
01067         VIDEO_locate(11,11);    VIDEO_putstr("IG/Knock");
01068 
01069         VIDEO_locate(26, 2);    VIDEO_putstr("km/h");
01070         VIDEO_locate(26, 3);    VIDEO_putstr("rpm");
01071         VIDEO_locate(26, 4);    VIDEO_putch('%');
01072         VIDEO_locate(26, 5);    VIDEO_putstr("kg/cm2");
01073         VIDEO_locate(26, 6);    VIDEO_putstr("Shift");
01074         VIDEO_locate(26, 7);    VIDEO_putstr("C");
01075         VIDEO_locate(26, 8);    VIDEO_putstr("V");
01076         VIDEO_locate(26, 9);    VIDEO_putstr("g/s");
01077         VIDEO_locate(26,10);    VIDEO_putstr("A/F");
01078         VIDEO_locate(26,11);    VIDEO_putstr("deg");
01079     }
01080 
01081     SCREEN_keybuf_clear();
01082 
01083     /* 描画 */
01084     VIDEO_locate( 14,0);
01085     VIDEO_putuint(rtc.day, 5);
01086     VIDEO_putch(' ');
01087     VIDEO_putuint(rtc.hour, 2);
01088     VIDEO_putch(':');
01089     VIDEO_putuint(rtc.min, 2);
01090     VIDEO_putch(':');
01091     VIDEO_putuint(rtc.sec, 2);
01092     VIDEO_putch('.');
01093     VIDEO_putuint(rtc.msec, 3);
01094 
01095     VIDEO_locate( 6, 2);
01096     VIDEO_puthex(PORTA >> 8);   VIDEO_puthex(PORTA);
01097 
01098     VIDEO_locate( 6, 3);
01099     VIDEO_puthex(PORTB >> 8);   VIDEO_puthex(PORTB);
01100 
01101     VIDEO_locate( 6, 4);
01102     VIDEO_putch('0');   VIDEO_putch('0');   VIDEO_puthex(dac);
01103 
01104     VIDEO_locate( 6, 5);
01105     VIDEO_puthex(adc.adc[0] >> 8);  VIDEO_puthex(adc.adc[0]);
01106 
01107     VIDEO_locate( 6, 6);
01108     VIDEO_puthex(adc.adc[1] >> 8);  VIDEO_puthex(adc.adc[1]);
01109 
01110     VIDEO_locate( 6, 7);
01111     VIDEO_puthex(adc.adc[2] >> 8);  VIDEO_puthex(adc.adc[2]);
01112 
01113     VIDEO_locate( 6, 9);
01114     VIDEO_puthex(ssm.last >> 8);    VIDEO_puthex(ssm.last);
01115 
01116     VIDEO_locate( 6,10);
01117     VIDEO_puthex(ssm.cycle >> 8);   VIDEO_puthex(ssm.cycle);
01118 
01119     VIDEO_locate( 6,11);
01120     VIDEO_puthex(ssm.error >> 8);   VIDEO_puthex(ssm.error);
01121 
01122     VIDEO_locate(22, 2);
01123     VIDEO_putuint(ssm_data.speed, 3);
01124 
01125     VIDEO_locate(21, 3);
01126     VIDEO_putuint(ssm_data.engine, 4);
01127 
01128     VIDEO_locate(19, 4);
01129     VIDEO_putdouble(ssm_data.throttle, 3,1);
01130 
01131     VIDEO_locate(20, 5);
01132     VIDEO_putdouble(ssm_data.boost, 0, 2);
01133 
01134     VIDEO_locate(24, 6);
01135     VIDEO_putuint(ssm_data.shift, 1);
01136 
01137     VIDEO_locate(20, 7);
01138     VIDEO_putuint(ssm_data.coolant, 2);
01139     VIDEO_putch('/');
01140     VIDEO_putuint(ssm_data.intakeair, 2);
01141 
01142     VIDEO_locate(20, 8);
01143     VIDEO_putdouble(ssm_data.battery, 2, 1);
01144 
01145     VIDEO_locate(20, 9);
01146     VIDEO_putuint(ssm_data.maf, 5);
01147 
01148     VIDEO_locate(20,10);
01149     VIDEO_putdouble(ssm_data.afr, 2, 1);
01150 
01151     VIDEO_locate(20,11);
01152     VIDEO_putuint(ssm_data.ignition, 2);
01153     VIDEO_putch('/');
01154     VIDEO_putuint(ssm_data.knock, 2);
01155 
01156     return;
01157 }
01158 
01159 
01160 /*-------------------------------------------------------------------------------------------------
01161 基板情報表示画面
01162 -------------------------------------------------------------------------------------------------*/
01163 static inline void SCREEN_version(void)
01164 {
01165     /* 画面初期化 */
01166     if(screen.screen_flag == SCREEN_INIT){
01167         screen.screen_flag = SCREEN_VIEW;
01168         screen.fps = 5;
01169         VIDEO_vram_clear(0x00);
01170 
01171         VIDEO_locate(0, 0);
01172         VIDEO_putstr("Product Infomation");
01173 
01174         VIDEO_locate(0, 2);
01175         VIDEO_putstr("Board name    : ");
01176         VIDEO_putstr(info.board_name);
01177 
01178         VIDEO_locate(0, 3);
01179         VIDEO_putstr("Board build   : Koki ");
01180         VIDEO_putuint(info.board_year, 4);  VIDEO_putch('/');   VIDEO_putuint(info.board_month, 2); VIDEO_putch('/');   VIDEO_putuint(info.board_day, 2);
01181 
01182         VIDEO_locate(0, 4);
01183         VIDEO_putstr("Firmware Ver. : ");
01184         VIDEO_putuint(info.firmware_major, 2);  VIDEO_putch('.');   VIDEO_putuint(info.firmware_minor, 2);  VIDEO_putch('.');   VIDEO_putuint(info.firmware_revision, 3);
01185 
01186         VIDEO_locate(0, 5);
01187         VIDEO_putstr("Firmware build: Koki ");
01188         VIDEO_putuint(info.firmware_year, 4);   VIDEO_putch('/');   VIDEO_putuint(info.firmware_month, 2);  VIDEO_putch('/');   VIDEO_putuint(info.firmware_day, 2);
01189 
01190         VIDEO_locate(0, 6);
01191         VIDEO_putstr("Board S/N     : ");
01192         VIDEO_putstr(info.serial);
01193 
01194         VIDEO_locate(0, 8); VIDEO_putstr(info.project);
01195         VIDEO_locate(0, 9); VIDEO_putstr(info.web);
01196         VIDEO_locate(0,10); VIDEO_putstr(info.mail);
01197         VIDEO_locate(0,11); VIDEO_putstr(info.copyright);
01198 
01199     }
01200 
01201     SCREEN_keybuf_clear();
01202     return;
01203 }
01204 
01205 
01206 /*-------------------------------------------------------------------------------------------------
01207 おまけ、23/3 ライフゲームもどき 兼 スクリーンセーバー
01208 -------------------------------------------------------------------------------------------------*/
01209 static inline void SCREEN_lifegame(void)
01210 {
01211     static unsigned int y, stage;
01212     unsigned int x, check;
01213 
01214     /* 画面初期化 */
01215     if(screen.screen_flag == SCREEN_INIT){
01216         screen.screen_flag = SCREEN_VIEW;
01217         screen.fps = 60;
01218         y = 1;
01219         stage = 0;
01220     }
01221 
01222     SCREEN_keybuf_clear();
01223 
01224     if(y >= NTSC_HEIGHT - 1){
01225         y = 1;
01226         stage++;
01227     }
01228     if(y < (unsigned int)FONTX2_get_ascii_height()){
01229         VIDEO_locate(27, 0);
01230         VIDEO_putuint(stage, 5);
01231     }
01232 
01233     /* 探索 */
01234     for(x = 1; x < NTSC_WIDTH - 1; x++){
01235         /* メモリに余裕がないので、ラインを捨てながら描く */
01236         check = VIDEO_get_point(x - 1, y - 1)
01237               + VIDEO_get_point(x - 1, y    )
01238               + VIDEO_get_point(x - 1, y + 1)
01239               + VIDEO_get_point(x    , y - 1)
01240               + VIDEO_get_point(x    , y + 1)
01241               + VIDEO_get_point(x + 1, y - 1)
01242               + VIDEO_get_point(x + 1, y    )
01243               + VIDEO_get_point(x + 1, y + 1);
01244 
01245         if(check == 3){
01246             VIDEO_point(x,y);
01247         } else {
01248             if(check != 2) VIDEO_point_(x,y);
01249         }
01250     }
01251 
01252     y++;
01253 
01254     return;
01255 }
01256 
01257 
01258 /*-------------------------------------------------------------------------------------------------
01259 使わないキーを読み込み、バッファを捨てる.
01260 -------------------------------------------------------------------------------------------------*/
01261 static inline void SCREEN_keybuf_clear(void)
01262 {
01263     switch(PS2_key_check()){
01264     case KEY_F1:
01265     case KEY_F2:
01266     case KEY_F3:
01267     case KEY_F4:
01268     case KEY_F5:
01269     case KEY_F6:
01270     case KEY_F7:
01271     case KEY_F8:
01272     case KEY_F9:
01273     case KEY_F10:
01274     case KEY_F11:
01275     case KEY_F12:
01276     case KEY_PAGEUP:
01277     case KEY_PAGEDOWN:
01278     case KEY_DEL:
01279         break;
01280 
01281     default:
01282         PS2_key_get();
01283         break;
01284     }
01285 
01286     return;
01287 }
01288 
01289 
01290 /*-------------------------------------------------------------------------------------------------
01291 各スクリーンでキー入力が必要なときに使う
01292 -------------------------------------------------------------------------------------------------*/
01293 static inline unsigned char SCREEN_key_get(void)
01294 {
01295     switch(PS2_key_check()){
01296     case KEY_F1:
01297     case KEY_F2:
01298     case KEY_F3:
01299     case KEY_F4:
01300     case KEY_F5:
01301     case KEY_F6:
01302     case KEY_F7:
01303     case KEY_F8:
01304     case KEY_F9:
01305     case KEY_F10:
01306     case KEY_F11:
01307     case KEY_F12:
01308     case KEY_PAGEUP:
01309     case KEY_PAGEDOWN:
01310     case KEY_DEL:
01311         return(KEY_NOP);
01312         break;
01313 
01314     default:
01315         return(PS2_key_get());
01316         break;
01317     }
01318 
01319     /* ここにきたらバグ */
01320     return(KEY_NOP);
01321 }

OpenSSMに対してSat Aug 14 2010 03:23:43に生成されました。  doxygen 1.7.1