/* * ***************************************************************** * * * * * Copyright (c) Fast Corporation, 1997 * * * * * * All Rights Reserved. Unpublished rights reserved under * * * the copyright laws of the Japan. * * * * * * The software contained on this media is proprietary to * * * and embodies the confidential technology of Fast * * * Corporation. Possession, use, duplication or * * * dissemination of the software and media is authorized only * * * pursuant to a valid written license from Fast Corporation. * * * * * ***************************************************************** */ /* CSC90X 円周上の濃度グラフ表示 CIRWAVE.C */ /*[作成者]S.Kodama */ /* 目的: 関数: 履歴: Ver 1.0 98/11/13 Ver 1.1 99/10/29 旧ライブラリを削除(Lib_init_input_device/Lib_open_input_device/Lib_close_input_device) 注記:m_menu.hをインクルードして下さい。 m_menu.c及びm_note.cをリンクして下さい。 */ /* * Include compiler runtime library */ #include #include /* * Include CSC90X library */ #include "f_stdlib.h" #include "f_time.h" #include "f_gui.h" #include "f_stdio.h" #include "f_graph.h" #include "f_image.h" #include "f_pinf.h" #include "f_video.h" #include "f_system.h" #include "f_math.h" /* * Include CSC90X common local */ #include "m_menu.h" /* * プロトタイプ宣言 */ void main( void ); void main_menu_disp( void ); void disp_help( void ); void exec( void ); void sxx_selc( void ); void sxx_init( void ); void sxx_close( void ); void sxx_pad_draw( void ); int sxx_pad_in( void ); void user_proc( int, int, PARADIGM * ); void sxx_circle_set( void ); void sxx_circle_ido( void ); void sxx_circle_size( void ); void sxx_glaf_mem_write( void ); void sxx_glaf_write( void ); extern int message_note( void ); /* * メニュー項目 */ #define LANG_N 2 #define MAIN_MENU_N 4 static const char *str_main_menu[MAIN_MENU_N][LANG_N] = { { " EXEC ", " 実行 " }, { " PROC2 ", " 処理2 " }, { " PROC3 ", " 処理3 " }, { " PROC4 ", " 処理4 " } }; #define INIT_CUR_POS_X 255 #define INIT_CUR_POS_Y 239 #define YES 1 #define NO 0 #define FOREVER while( YES ) #define ON 1 #define OFF 0 #define MOUSE_XS 256 #define MOUSE_YS 240 #define PAD_XS 60 #define PAD_YS 455 #define PAD_XS1 250 #define PAD_YS1 425 #define ENGLISH 0 #define JAPANESE 1 #define PAD_CIRCLE 1 #define PAD_GLAF 2 #define PAD_END 3 #define PAD_FREERUN 4 #define PAD_FREEZE 5 #define G_X1 66 #define G_X2 446 #define G_Y1 380 #define G_Y2 130 #define INT_STAGE 127 /* add 93-3-3 */ #define EXECUTE 1 static int sys_language; static int pad_circle_xs, pad_circle_ys, pad_circle_xe, pad_circle_ye; static int pad_glaf_xs, pad_glaf_ys, pad_glaf_xe, pad_glaf_ye; static int pad_end_xs, pad_end_ys, pad_end_xe, pad_end_ye; static int pad_freerun_xs, pad_freerun_ys, pad_freerun_xe, pad_freerun_ye; static int pad_freeze_xs, pad_freeze_ys, pad_freeze_xe, pad_freeze_ye; static int save_cyusin_x; static int save_cyusin_y; static int save_cyusin_r; static int save_line_xs; static int save_line_xe; static int save_line_ys; static int save_line_ye; static int save_noudo[360]; static int pn; static int flag_g, flag_f, flag_m; static int i; static char *mem_base; int xpos; int ypos; int s_xpos; int s_ypos; /* * メイン */ void main( void ) { int sts; /* 初期メッセージ表示 */ if( NORMAL_RETURN != message_note() ) return; /* パラメタ初期化 */ xpos = INIT_CUR_POS_X; ypos = INIT_CUR_POS_Y; s_xpos = INIT_CUR_POS_X; s_ypos = INIT_CUR_POS_Y; /* 入力ビデオ制御 */ Lib_input_video_control( GRAY_PLANE ); /* ビデオ出力表示項目制御 */ Lib_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); /* ビデオ表示項目クリア */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); /* カーソル初期化 */ Lib_init_cursor(); /* メインメニューの表示 */ main_menu_disp(); /* マウスカーソルの表示 */ Lib_draw_cursor( INIT_CUR_POS_X, INIT_CUR_POS_Y ); /* メニュー制御 */ for (;;) { sts = 0; /* マウス位置読みとり */ sts = Lib_see_current_position( &xpos, &ypos ); if ( s_xpos != xpos || s_ypos != ypos ) { /* マウス表示位置移動 */ Lib_move_cursor( xpos, ypos ); s_xpos = xpos; s_ypos = ypos; } /* 処理振り分け */ if( CURSOR_EXECUTE == sts ) { if ( xpos > MENU_1_XS && xpos < MENU_1_XE && ypos > MENU_1_YS && ypos < MENU_1_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); exec(); /* 実行 */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); main_menu_disp(); } else if ( xpos > MENU_H_XS && xpos < MENU_H_XE && ypos > MENU_H_YS && ypos < MENU_H_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); disp_help(); /* ヘルプ */ main_menu_disp(); } else if ( xpos > MENU_E_XS && xpos < MENU_E_XE && ypos > MENU_E_YS && ypos < MENU_E_YE ) { break; /* 終了 */ } } } } /* * メインメニュー表示 */ static void main_menu_disp( void ) { int iLanguage; /* 日本語/英語表示文字列切替情報取得 */ iLanguage = Lib_get_disp_language(); /* 整列キー表示 -> ( m_menu.c ) */ SUB_menu_disp4he( (char *)str_main_menu[0][iLanguage], NULL, NULL, NULL ); } /* * ヘルプ表示 */ static void disp_help( void ) { Lib_chrdisp( 10, 8, "【機能\概要】 CIRWAVE" ); Lib_chrdisp( 11, 10, "円周上の濃度グラフ表\示" ); } /************************************************************************/ /* 実行 */ /************************************************************************/ void exec() { sxx_init(); Lib_gray_memory_cls( 0 ); Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); sxx_pad_draw(); sxx_selc(); } /************************************************************************/ /* プログラム初期化 */ /************************************************************************/ void sxx_init() { static int i; /*入力ビデオの選択 */ Lib_input_video_control( GRAY_PLANE ); /*表示プレーンの選択 */ Lib_display_control( GRAY_PLANE|LINE_PLANE|CHAR_PLANE ); Lib_freerun(); Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); sys_language = Lib_get_disp_language(); /* Lib_set_stage_no( INT_STAGE ); Lib_set_stage_input_file( VIDEO_CH0 ); Lib_set_stage_window( 0, 0, 511, 479 ); */ mem_base = ( char * )Lib_adrs_gray_memory( -1 ); save_cyusin_x = 256; save_cyusin_y = 240; save_cyusin_r = 30; save_line_xs = 261; save_line_xe = 251; save_line_ys = 245; save_line_ye = 235; for( i = 0; i < 360; i++) { save_noudo[i] = 0; } flag_g = OFF; flag_f = OFF; flag_m = OFF; } /************************************************************************/ /* 初期メニュー表示 */ /************************************************************************/ void sxx_selc() { static int sts; sts = ON; while ( sts == ON ) /* キ−が押されるまで */ { if (( pn = sxx_pad_in()) == PAD_CIRCLE ) { Lib_memory_clear( CHAR_PLANE | LINE_PLANE ); /* 図形のクリア */ flag_g = OFF; Lib_freerun(); sxx_pad_draw(); sxx_circle_set(); Lib_look_current_position( &xpos, &ypos ); Lib_move_cursor( xpos, ypos ); i =0; } /* If ( pn == PAD_CIRCLE ) */ else if ( pn == PAD_GLAF ) { Lib_drawline ( save_line_xs, save_cyusin_y, save_line_xe, save_cyusin_y ); Lib_drawline ( save_cyusin_x, save_line_ys, save_cyusin_x, save_line_ye ); Lib_drawcircle( save_cyusin_x, save_cyusin_y, save_cyusin_r ); /* 円・中心点 のWRITE */ flag_g = ON; flag_f = ON; sxx_pad_draw(); /* 濃度グラフ メニュ−WRITE */ Lib_freerun(); i = 0; sxx_glaf_mem_write(); /* 濃度グラフ のセット */ } else if ( pn == PAD_END ) /* 終了 */ { sts = OFF; Lib_freerun(); Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); return; } /* If ( pn == PAD_END ) */ if ( flag_g == ON ) { if ( pn == PAD_FREERUN ) { Lib_freerun(); flag_f = ON; } else if ( pn == PAD_FREEZE ) /* フリ−ズ */ { Lib_freeze( TRANSMIT ); for( i = 0; i < 360; i++ ) { sxx_glaf_write(); /* 濃度グラフ のセット */ } i = 0; flag_f = OFF; } if ( flag_f == ON ) { if ( i == 0 ) { Lib_freerun(); Lib_freeze( TRANSMIT ); flag_m = OFF; } sxx_glaf_write(); /* 濃度グラフ のセット */ i = i + 1; if ( i == 360 ) { i = 0; } } } } /* While ( sts == ON ) */ } /************************************************************************/ /* パッド表示      */ /************************************************************************/ void sxx_pad_draw( ) { static int w,h; Lib_get_key_size( 14, &w, &h ); pad_circle_xs = PAD_XS; pad_circle_ys = PAD_YS; pad_circle_xe = pad_circle_xs + w; pad_circle_ye = pad_circle_ys + h; pad_glaf_xs = pad_circle_xs + w; pad_glaf_ys = PAD_YS; pad_glaf_xe = pad_glaf_xs + w; pad_glaf_ye = pad_glaf_ys + h; pad_end_xs = pad_glaf_xs + w; pad_end_ys = PAD_YS; pad_end_xe = pad_end_xs + w; pad_end_ye = pad_end_ys + h; if ( sys_language == ENGLISH ) { Lib_display_key( pad_circle_xs,pad_circle_ys," CIRCLE ", 1); Lib_display_key( pad_glaf_xs, pad_glaf_ys, " GLAF ", 1); Lib_display_key( pad_end_xs, pad_end_ys, " END ", 1); } else { Lib_display_key( pad_circle_xs,pad_circle_ys," 円設定  ", 1); Lib_display_key( pad_glaf_xs, pad_glaf_ys, " 濃度グラフ ", 1); Lib_display_key( pad_end_xs, pad_end_ys, "  終了  ", 1); } if ( flag_g == ON ) { pad_freerun_xs = PAD_XS1; pad_freerun_ys = PAD_YS1; pad_freerun_xe = pad_freerun_xs + w; pad_freerun_ye = pad_freerun_ys + h; pad_freeze_xs = pad_freerun_xs + w; pad_freeze_ys = PAD_YS1; pad_freeze_xe = pad_freeze_xs + w; pad_freeze_ye = pad_freeze_ys + h; if ( sys_language == ENGLISH ) { Lib_display_key( pad_freerun_xs,pad_freerun_ys," FREERUN ", 1); Lib_display_key( pad_freeze_xs, pad_freeze_ys, " FREEZE ", 1); } else { Lib_display_key( pad_freerun_xs,pad_freerun_ys," フリ−ラン ", 1); Lib_display_key( pad_freeze_xs, pad_freeze_ys, " フリ−ズ ", 1); } } Lib_see_current_position( &xpos, &ypos ); s_xpos = xpos; s_ypos = ypos; } /************************************************************************/ /* パッド指定の状態入力   */ /************************************************************************/ int sxx_pad_in() { static int rt; if (!( s_xpos == xpos && s_ypos == ypos )) Lib_move_cursor( xpos, ypos ); s_xpos = xpos; s_ypos = ypos; if ((rt = Lib_see_current_position( &xpos, &ypos )) == EXECUTE) /* EXECUTEキ−が押されたら */ { if (( pad_circle_xs <= xpos && xpos <= pad_circle_xe ) && ( pad_circle_ys <= ypos && ypos <= pad_circle_ye )) /* 円設定 */ { if (sys_language == ENGLISH) { Lib_display_key( pad_circle_xs, pad_circle_ys," CIRCLE ", 2 ); } else { Lib_display_key( pad_circle_xs, pad_circle_ys," 円設定 ", 2 ); } return(PAD_CIRCLE); } else if (( pad_glaf_xs <= xpos && xpos <= pad_glaf_xe ) && ( pad_glaf_ys <= ypos && ypos <= pad_glaf_ye )) /* 濃度グラフ */ { if (sys_language == ENGLISH) { Lib_display_key( pad_glaf_xs, pad_glaf_ys," GLAF ", 2 ); } else { Lib_display_key( pad_glaf_xs, pad_glaf_ys," 濃度グラフ ", 2); } return(PAD_GLAF); } else if (( pad_end_xs <= xpos && xpos <= pad_end_xe ) && ( pad_end_ys <= ypos && ypos <= pad_end_ye )) /* 終了 */ { if (sys_language == ENGLISH) { Lib_display_key( pad_end_xs, pad_end_ys, " END ", 2 ); } else { Lib_display_key( pad_end_xs, pad_end_ys, "  終了  ", 2 ); } return(PAD_END); } else if ( flag_g == ON ) { if (( pad_freeze_xs <= xpos && xpos <= pad_freeze_xe ) && ( pad_freeze_ys <= ypos && ypos <= pad_freeze_ye )) /* フリ−ズ */ { if ( sys_language == ENGLISH ) { Lib_display_key( pad_freeze_xs, pad_freeze_ys," FREEZE ", 2 ); } else { Lib_display_key( pad_freeze_xs, pad_freeze_ys," フリ−ズ ", 2); } return(PAD_FREEZE); } else if (( pad_freerun_xs <= xpos && xpos <= pad_freerun_xe ) && ( pad_freerun_ys <= ypos && ypos <= pad_freerun_ye )) /* フリ−ラン */ { if ( sys_language == ENGLISH ) { Lib_display_key( pad_freerun_xs, pad_freerun_ys," FREERUN ", 2 ); } else { Lib_display_key( pad_freerun_xs, pad_freerun_ys," フリ−ラン ", 2 ); } return(PAD_FREERUN); } } } return(NO); } /************************************************************************/ /* */ /* */ /* 円設定・濃度グラフ セット */ /* */ /* */ /************************************************************************/ /************************************************************************/ /* (円設定項目選択メニュー) */ /************************************************************************/ void sxx_circle_set() { static int no; static int pad_level; pad_level = Lib_view_open( ); if ( sys_language == ENGLISH ) { Lib_view_set_title( pad_level, "CIRCLE. SET" ); Lib_view_set_null ( pad_level,10, 10, "CIRCLE MOVE ", 0 ); Lib_view_set_null ( pad_level,10, 40, "SIZE CHANGE ", 1 ); } else { Lib_view_set_title( pad_level, "円設定" ); Lib_view_set_null ( pad_level, 10, 10, " 円移動 ", 0 ); Lib_view_set_null ( pad_level, 10, 40, "サイズ変更", 1 ); } Lib_view_set_size( pad_level, 20, 320, 5, 5 ); Lib_set_paradigm ( pad_level, 1, START_TIMING, user_proc ); Lib_draw_command ( pad_level ); Lib_drawline ( save_line_xs, save_cyusin_y, save_line_xe, save_cyusin_y ); Lib_drawline ( save_cyusin_x, save_line_ys, save_cyusin_x, save_line_ye ); Lib_drawcircle( save_cyusin_x, save_cyusin_y, save_cyusin_r ); while ( 102 != ( no = Lib_process_command( pad_level ))) /* 終了キ−が押されるまで */ { switch( no ) { case 0: sxx_circle_ido( ); /* 円移動 */ break; case 1: sxx_circle_size( );/* サイズ変更 */ break; } } Lib_erase_menu( pad_level ); Lib_view_close( pad_level ); Lib_drawline ( save_line_xs, save_cyusin_y, save_line_xe, save_cyusin_y ); Lib_drawline ( save_cyusin_x, save_line_ys, save_cyusin_x, save_line_ye ); Lib_drawcircle( save_cyusin_x, save_cyusin_y, save_cyusin_r ); } /*********************************************************************/ void user_proc( Timing, numb, val ) int Timing; int numb; PARADIGM val[]; { } /************************************************************************/ /* 円の移動 */ /************************************************************************/ void sxx_circle_ido() { static int old_cyusin_x, old_cyusin_y, old_cyusin_r; static int old_line_xs, old_line_xe, old_line_ys, old_line_ye; static int sts, status; old_cyusin_x = save_cyusin_x; old_cyusin_y = save_cyusin_y; old_cyusin_r = save_cyusin_r; old_line_xs = save_line_xs; old_line_xe = save_line_xe; old_line_ys = save_line_ys; old_line_ye = save_line_ye; Lib_draw_cursor( save_cyusin_x, save_cyusin_y ); Lib_erase_cursor( ); /* カ−ソルの消去 */ sts = ON; while( sts == ON ) /* EXECUTEキ−が押されるまで */ { status = Lib_see_current_position( &save_cyusin_x, &save_cyusin_y ); if(( save_cyusin_x != old_cyusin_x) || ( save_cyusin_y != old_cyusin_y )) /* カ−ソルが動いたら */ { Lib_move_cursor( save_cyusin_x, save_cyusin_y ); Lib_erasline ( old_line_xs, old_cyusin_y, old_line_xe, old_cyusin_y ); Lib_erasline ( old_cyusin_x, old_line_ys, old_cyusin_x, old_line_ye ); Lib_erascircle ( old_cyusin_x, old_cyusin_y, old_cyusin_r ); save_line_xs = save_cyusin_x + 5; save_line_xe = save_cyusin_x - 5; save_line_ys = save_cyusin_y + 5; save_line_ye = save_cyusin_y - 5; Lib_drawline ( save_line_xs, save_cyusin_y, save_line_xe, save_cyusin_y ); Lib_drawline ( save_cyusin_x, save_line_ys, save_cyusin_x, save_line_ye ); Lib_drawcircle( save_cyusin_x, save_cyusin_y, save_cyusin_r ); old_cyusin_x = save_cyusin_x; old_cyusin_y = save_cyusin_y; old_line_xs = save_line_xs; old_line_xe = save_line_xe; old_line_ys = save_line_ys; old_line_ye = save_line_ye; } if( status == CURSOR_EXECUTE ) /* EXECUTEキ−が押されたら */ { sts=OFF; } } Lib_draw_cursor( save_cyusin_x, save_cyusin_y ); } /************************************************************************/ /* サイズ変更 */ /************************************************************************/ void sxx_circle_size() { static int new_size_x, new_size_y; static int old_size_x, old_size_y, old_size_r; static int sts, status, x, y; new_size_x = old_size_x = save_cyusin_x + save_cyusin_r; new_size_y = old_size_y = save_cyusin_y; old_size_r = save_cyusin_r; Lib_draw_cursor( save_cyusin_x + save_cyusin_r, save_cyusin_y ); sts = ON; while( sts == ON ) /* EXECUTEキ−が押されるまで */ { status = Lib_see_current_position( &new_size_x, &new_size_y ); if(( new_size_x != old_size_x ) || ( new_size_y != old_size_y )) /* カ−ソルが動いたら */ { Lib_move_cursor( new_size_x, new_size_y ); Lib_erascircle ( save_cyusin_x, save_cyusin_y, old_size_r ); x = save_cyusin_x - new_size_x; if( x < 0 ) { x = x * (-1); } y = save_cyusin_y - new_size_y; if( y < 0 ) { y = y * (-1); } save_cyusin_r = ( x * x ) + ( y * y ); save_cyusin_r = Lib_sqrt32( save_cyusin_r ); /* 円の半径の計算 */ Lib_drawcircle( save_cyusin_x, save_cyusin_y, save_cyusin_r ); old_size_x = new_size_x; old_size_y = new_size_y; old_size_r = save_cyusin_r; } if( status == CURSOR_EXECUTE ) /* EXECUTEキ−が押されたら */ { sts=OFF; } } Lib_draw_cursor( new_size_x, new_size_y ); } /************************************************************************/ /* 軸・メモリ WRITE */ /************************************************************************/ void sxx_glaf_mem_write() { static char string; static int su; Lib_drawline ( G_X1, G_Y1, G_X1, G_Y2 ); Lib_drawline ( G_X1, G_Y1, G_X2, G_Y1 ); /* グラフの軸 WRITE */ Lib_dispval ( 6, 9, 255 ); Lib_dispval ( 6, 12, 200 ); Lib_dispval ( 6, 19, 100 ); Lib_dispval ( 21, 25, 100 ); Lib_dispval ( 32, 25, 200 ); Lib_dispval ( 44, 25, 300 ); Lib_dispval ( 55, 25, 359 ); Lib_sprintf ( &string, "%d", su ); Lib_chrdisp ( 8, 25, &string ); /* グラフのメモリ WRITE */ Lib_kanjishift ( NORMAL_FONT, NORMAL_FONT, 0, 7, 130, "明" ); Lib_kanjishift ( NORMAL_FONT, NORMAL_FONT, 0, 7, 160, "↑" ); Lib_kanjishift ( NORMAL_FONT, NORMAL_FONT, 0, 7, 250, "濃" ); Lib_kanjishift ( NORMAL_FONT, NORMAL_FONT, 0, 7, 290, "度" ); Lib_kanjishift ( NORMAL_FONT, NORMAL_FONT, 0, 7, 370, "↓" ); Lib_kanjishift ( NORMAL_FONT, NORMAL_FONT, 0, 7, 400, "暗" ); Lib_kanjishift ( NORMAL_FONT, NORMAL_FONT, 0, 140, 420, "座  標 (円周) …… 中央右端を0度として" ); /* 文字 WRITE */ } /************************************************************************/ /* グラフ WRITE */ /************************************************************************/ void sxx_glaf_write() { static int x3, y3; static int angle; static int xs, xe, ys, ye; static char *fmp; register int x2, y2; /* 濃度の取り込み&グラフのセット */ angle = ( long )( i * 10 ); x2 = Lib_cosfunc( angle ); y2 = Lib_sinfunc( angle ); x2 = ( ( long )save_cyusin_r * ( long )x2 ) / 32767L; y2 = ( ( long )save_cyusin_r * ( long )y2 ) / 32767L; x3 = save_cyusin_x + x2 - 1; y3 = save_cyusin_y + y2 - 1; xs = i + 69; xe = i + 70; if ( i != 359 ) { Lib_erasline( xs + 1, save_noudo[i], xe + 1, save_noudo[i + 1] ) ; } if (( x3 < 0 ) || ( x3 >= 512 ) || ( y3 < 0 ) || ( y3 >= 480 )) /* ( 0 > x ) || ( x >= 512 ) & ( 0 > y ) || ( y >= 480 )*/ { ye = 400; save_noudo[i] = ye; flag_m = ON; } else { fmp = y3 * 512 + x3 + mem_base; ye = *fmp & 0x000000ff; ye = 400 - ye; if ( i == 0 ) { ys = ye; } else { if ( flag_m == OFF ) { ys = save_noudo[i - 1]; Lib_drawline( xs, ys, xe, ye ) ; /* グラフを描く */ } } save_noudo[i] = ye; flag_m = OFF; } }