home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / h / hp11 / Amiga_Code / c / ami_amiga next >
Encoding:
Text File  |  1992-05-07  |  5.8 KB  |  229 lines

  1. /*-> c.ami_amiga  */
  2.  
  3. /*  Modifications for ANSI C under RISC-OS:
  4.  *
  5.  *     Date               Modification
  6.  *  11-may-90   modifications of headers
  7.  *  11-may-90   removal of non-relevant definitions
  8.  *  23-may-90   modification of display() and sizes
  9.  */
  10.  
  11. #include "string.h"
  12. #include "ctype.h"
  13.  
  14. #include "wimp.h"
  15. #include "wimpt.h"
  16. #include "win.h"
  17. #include "event.h"
  18. #include "menu.h"
  19. #include "dbox.h"
  20. #include "werr.h"
  21. #include "flex.h"
  22. #include "bbc.h"
  23. #include "coords.h"
  24.  
  25. #include "types.h"
  26. #include "hp11.h"
  27. #include "ami_amiga.h"
  28.  
  29. #define CHAROFFX 4 /* offset in display for first char */
  30. #define CHAROFFY 6
  31. #define CHARWIDTH 32 /* Size of char */
  32. #define CHARHEIGHT 26
  33.  
  34. #define CR 13
  35. #define BS 8
  36. #define ESC 27
  37.  
  38. /* Annunciator icon info */
  39. extern wimp_i        hp11_display, hp11_user, hp11_f, hp11_g;
  40. extern wimp_i        hp11_rad, hp11_grad, hp11_pgrm;
  41.  
  42. extern wimp_w  hp11_win_handle;
  43. extern dbox    hp11_dbox_handle;
  44.  
  45. extern struct Border *hp11char[]; /* Character descriptions (as connected
  46.   lines) */
  47.  
  48. /* Wait for latest key to be released, returns true if button released
  49.   over key (valid only for mouse) */
  50. BOOL RelKey()
  51. {
  52.   return(TRUE);
  53. }
  54.  
  55. /* Display s */
  56. void Display(s)
  57. register char *s;
  58. {
  59.    wimp_wstate    hp11_wind;
  60.    wimp_icon      hp11_disp;
  61.    wimp_redrawstr hp11_redraw;
  62.  
  63.    hp11_s = s;  /* set up global variable so event handler can find string */
  64.  
  65.    /* Find coords of display and mark as invalid.  This will cause the
  66.       Window Manager to clear the display and issue one or more redraw
  67.       requests.  These must be handled by the raw event handler. */
  68.    wimp_get_wind_state(hp11_win_handle, &hp11_window);
  69.    wimp_get_icon_info(hp11_win_handle, HP11_DISPLAY, &hp11_disp);
  70.  
  71. /* I'm not sure if this next bit is right
  72.                              -- shouldn't both boxes be the same? */
  73.    coords_box_toscreen(&hp11_disp.box, (coords_cvtstr *)&hp11_wind.o.box); 
  74.  
  75.    hp11_redraw.w = -1;
  76.    hp11_redraw.box.x0 = hp11_disp.box.x0;
  77.    hp11_redraw.box.y0 = hp11_disp.box.y0;
  78.    hp11_redraw.box.x1 = hp11_disp.box.x1;
  79.    hp11_redraw.box.y1 = hp11_disp.box.y1;
  80.    wimp_force_redraw(&hp11_redraw);
  81.  
  82. /* now set a flag to indicate to event handler what should be redrawn */
  83. }
  84.  
  85. void Display_2(wimp_redrawstr hp11_redraw)
  86. {
  87.    void DrawChar(struct Border *, int, int);
  88.  
  89.    int posx, posy;
  90.    int chr;
  91.    BOOL         redraw;
  92.    wimp_icon    hp11_disp;
  93.  
  94.    do {
  95.      wimp_get_rectangle(&hp11_redraw, &redraw);
  96.      while (redraw) {
  97.        /* Initial position */
  98.        wimp_get_icon_info(hp11_win_handle, HP11_DISPLAY, &hp11_disp);
  99.        /* I'm not sure if this next bit is right
  100.                              -- shouldn't both boxes be the same? */
  101.        coords_box_toscreen(&hp11_disp.box, (coords_cvtstr *)&hp11_redraw.box); 
  102.        posx = hp11_disp.box.x0 + CHAROFFX;
  103.        posy = hp11_disp.box.y1 - CHAROFFY;
  104.  
  105.        while (*hp11_s) {
  106.          switch (*hp11_s) { /* Position of char in char array */
  107.            case '0': case '1': case '2': case '3': case '4': case '5':
  108.            case '6': case '7': case '8': case '9': chr = *hp11_s - '0'; break;
  109.            case '-': chr = 10; break;
  110.            case 'E': chr = 11; break;
  111.            case 'r': chr = 12; break;
  112.            case 'o': chr = 13; break;
  113.            case 'R': chr = 14; break;
  114.            case 'u': chr = 15; break;
  115.            case 'n': chr = 16; break;
  116.            case 'i': chr = 17; break;
  117.            case 'g': chr = 18; break;
  118.            case '.': chr = 19; break;
  119.            case ',': chr = 20; break;
  120.            case 'P': chr = 21; break;
  121.            default:  chr = -1; break;
  122.          }
  123.          if (chr != -1)
  124.            DrawChar(hp11char[chr], posx, posy);
  125.          if (*hp11_s != '.' && *hp11_s != ',') posx += CHARWIDTH;
  126.          hp11_s++;
  127.        }
  128.      }
  129.    } while (redraw);
  130. }
  131.  
  132. void DrawChar(struct Border *hp11char, int posx, int posy)
  133. {
  134.   int            i, x;
  135.   WORD          *pos;
  136.   struct Border *stroke;
  137.  
  138.   stroke = hp11char;
  139.   do {
  140.     pos = stroke->SegDef;
  141.     for (i=1; i<4; i++, pos++) {
  142.       x = *pos;                       
  143.       bbc_move(posx+x, posy-*(++pos));
  144.       x = *(++pos);                   
  145.       bbc_draw(posx+x, posy-*(++pos));
  146.     }
  147.     stroke = stroke->NextSeg;
  148.   } while (stroke != NULL);
  149. }
  150.  
  151. /* Display the indicators */
  152. void Dispf(on)
  153. int on;
  154. {
  155.   if(on)
  156.     wimp_set_icon_state(hp11_win_handle,HP11_f,wimp_ISELECTED,wimp_ISELECTED);
  157.   else
  158.     wimp_set_icon_state(hp11_win_handle, HP11_f, 0, wimp_ISELECTED);
  159. }
  160.  
  161. void Dispg(on)
  162. int on;
  163. {
  164.   if(on)
  165.     wimp_set_icon_state(hp11_win_handle,HP11_g,wimp_ISELECTED,wimp_ISELECTED);
  166.   else
  167.     wimp_set_icon_state(hp11_win_handle, HP11_g, 0, wimp_ISELECTED);
  168. }
  169.  
  170. void DispUSER(on)
  171. int on;
  172. {
  173.   if(on)
  174.     wimp_set_icon_state(hp11_win_handle, HP11_USER, wimp_ISELECTED, 
  175.                                                                wimp_ISELECTED);
  176.   else
  177.     wimp_set_icon_state(hp11_win_handle, HP11_USER, 0, wimp_ISELECTED);
  178. }
  179.  
  180. void DispG(on)
  181. int on;
  182. {
  183.   if(on)
  184.     wimp_set_icon_state(hp11_win_handle, HP11_GRAD, wimp_ISELECTED,
  185.                                                                wimp_ISELECTED);
  186.   else
  187.     wimp_set_icon_state(hp11_win_handle, HP11_GRAD, 0, wimp_ISELECTED);
  188. }
  189.  
  190. void DispRAD(on)
  191. int on;
  192. {
  193.   if(on)
  194.     wimp_set_icon_state(hp11_win_handle, HP11_RAD, wimp_ISELECTED,
  195.                                                                wimp_ISELECTED);
  196.   else
  197.     wimp_set_icon_state(hp11_win_handle, HP11_RAD, 0, wimp_ISELECTED);
  198. }
  199.  
  200. void DispPRGM(on)
  201. int on;
  202. {
  203.   if(on)
  204.     wimp_set_icon_state(hp11_win_handle, HP11_PGRM, wimp_ISELECTED,
  205.                                                                wimp_ISELECTED);
  206.   else
  207.     wimp_set_icon_state(hp11_win_handle, HP11_PGRM, 0, wimp_ISELECTED);
  208. }
  209.  
  210. void beep(void)
  211. {
  212.    bbc_vdu(7);
  213. }
  214.  
  215. void EditOn(void){}
  216. void EditOff(void){}
  217. void sleep(void){}
  218. void MenusOn(void){}
  219. void MenusOff(void){}
  220. void ArcCleanUp(void){}
  221. void WaitSync(long tick)
  222. {
  223.   int x, y, i;
  224.  
  225.   for (i=1, i < (int)tick; i++) {
  226.     os_byte(19, &x, &y);
  227.   }
  228. }
  229.