returns.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include <grass/display.h>
  2. #include "graphics.h"
  3. #include <stdio.h>
  4. #define GETEM if (notgotem) getem()
  5. static int notgotem = 1;
  6. static int wind_top;
  7. static int wind_bot;
  8. static int wind_rite;
  9. static int wind_left;
  10. static int getem(void);
  11. int get_wind_bot(void)
  12. {
  13. GETEM;
  14. return (wind_bot);
  15. }
  16. int get_wind_top(void)
  17. {
  18. GETEM;
  19. return (wind_top);
  20. }
  21. int get_wind_rite(void)
  22. {
  23. GETEM;
  24. return (wind_rite);
  25. }
  26. int get_wind_left(void)
  27. {
  28. GETEM;
  29. return (wind_left);
  30. }
  31. int get_map_bot(void)
  32. {
  33. GETEM;
  34. return (wind_bot);
  35. }
  36. int get_map_top(void)
  37. {
  38. register float tmp1, tmp2, tmp3;
  39. GETEM;
  40. if (notgotem) {
  41. getem();
  42. notgotem = 0;
  43. }
  44. tmp1 = (float)wind_bot;
  45. tmp2 = (float)wind_top;
  46. tmp3 = tmp1 + WINDOW_PROP_SCREEN_Y * (tmp2 - tmp1);
  47. return ((int)tmp3);
  48. }
  49. int get_map_left(void)
  50. {
  51. register float tmp1, tmp2, tmp3;
  52. GETEM;
  53. tmp1 = (float)wind_left;
  54. tmp2 = (float)wind_rite;
  55. tmp3 = tmp2 - WINDOW_PROP_SCREEN_X * (tmp2 - tmp1);
  56. return ((int)tmp3);
  57. }
  58. int get_map_rite(void)
  59. {
  60. GETEM;
  61. return (wind_rite);
  62. }
  63. int get_wind_y_pos(float position)
  64. {
  65. register float tmp1, tmp2, tmp3;
  66. GETEM;
  67. tmp1 = (float)wind_top;
  68. tmp2 = (float)wind_bot;
  69. tmp3 = tmp1 + position * (tmp2 - tmp1);
  70. return ((int)tmp3);
  71. }
  72. int get_wind_x_pos(float position)
  73. {
  74. register float tmp1, tmp2, tmp3;
  75. GETEM;
  76. tmp1 = (float)wind_left;
  77. tmp2 = (float)wind_rite;
  78. tmp3 = tmp1 + position * (tmp2 - tmp1);
  79. return ((int)tmp3);
  80. }
  81. static int getem(void)
  82. {
  83. D_get_screen_window(&wind_top, &wind_bot, &wind_left, &wind_rite);
  84. notgotem = 0;
  85. return 0;
  86. }