home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / lib / objcol2 / sample / test1.c next >
Encoding:
C/C++ Source or Header  |  1995-08-12  |  2.1 KB  |  121 lines

  1. /* Sample of "button.o", linked with button.o vircon.o symbol.o
  2.                                                      SAKU    */
  3.  
  4. #include <stdio.h>
  5. #include <egb.h>
  6. #include "button.h"
  7. #include "vircon.h"
  8.  
  9. typedef struct
  10. {
  11.     char    name[16];    /* name */
  12.     int        inp;        /* Intelligence Point */
  13.     int        stp;        /* Strength Point */
  14.     int        lup;        /* Luck Point */
  15.     int        spp;        /* Speed Point */
  16.     int        rep;        /* Reputation Point */
  17.     int        money;        /* money */
  18. } THIEF;
  19.  
  20. typedef struct
  21. {
  22.     char    stor[16];
  23.     char    master[16];
  24.     int        sort;
  25.     int        money;
  26.     int        scale;
  27.     int        person;
  28.     int        key;
  29. } STORE;
  30.  
  31. char    egbwork[1536];
  32. char    moswork[4096];
  33.  
  34. void    egbInit();
  35. void    egbTerm();
  36. void    mouseInit();
  37. void    mouseTerm();
  38. void    graphicInit();
  39. void    menuLoop( int, int, int );
  40.  
  41. char    rootcom[4][8] = { "外出", "情報", "盗め", "機能\0" };
  42. char    *mes[] = { "外出", "情報", "盗め", "機能\0", "ボタン外" };
  43.  
  44. void    main()
  45. {
  46.     int        sw,mx,my;
  47.     int        b[4];
  48.     int        i;
  49.  
  50.     egbInit();
  51.     mouseInit();
  52.  
  53.     BT_init( egbwork );
  54.     VC_init( egbwork, 0, 64, 40, 4, 15, 1 );
  55.     for( i=0; i<4; i++ )
  56.         b[i] = BT_create( 1, i*48, 0, 48, 20, rootcom[i] );
  57.     sw = 0;
  58.     while( sw != 2 )
  59.     {
  60.         MOS_rdpos( &sw, &mx, &my );
  61.         for( i=0; i<4; i++ )
  62.             menuLoop( b[i], mx, my );
  63.         if( sw == 1 )
  64.         {
  65.             int        com = 4;
  66.             for( i=0; i<4; i++ )
  67.                 if( BT_check( b[i], mx, my ) == BTC_ON )
  68.                     com = i;
  69.             VC_printf( "(%d,%d):%s\n", L_INT, mx, L_INT, my, POINTER, mes[com] );
  70.         }
  71.     }
  72.     for( i=0; i<4; i++ )
  73.         BT_disappear( b[i] );
  74.  
  75.     mouseTerm();
  76.     egbTerm();
  77.     return;
  78. }
  79.  
  80. void    egbInit()
  81. {
  82.     EGB_init( egbwork, 1536 );
  83.     EGB_resolution( egbwork, 0, 3 );
  84.     EGB_resolution( egbwork, 1, 3 );
  85.     EGB_displayPage( egbwork, 0, 3 );
  86.     EGB_writePage( egbwork, 1 );
  87.     return;
  88. }
  89.  
  90. void    egbTerm()
  91. {
  92.     MOS_screenterm( egbwork );
  93.     return;
  94. }
  95.  
  96. void    mouseInit()
  97. {
  98.     MOS_start( moswork, 4096 );
  99.     MOS_sysIcon( 81, 0, 0, 0 );
  100.     MOS_writePage( 0 );
  101.     MOS_color( 0, 15 );
  102.     MOS_disp( 1 );
  103.     return;
  104. }
  105.  
  106. void    mouseTerm()
  107. {
  108.     MOS_disp( 0 );
  109.     MOS_end();
  110.     return;
  111. }
  112.  
  113. void    menuLoop( int b1, int cx, int cy )
  114. {
  115.     if( BT_check( b1, cx, cy ) == BTC_ON )
  116.         BT_reverse( b1, 1 );
  117.     else
  118.         BT_reverse( b1, 0 );
  119.     return;
  120. }
  121.