home *** CD-ROM | disk | FTP | other *** search
- #include "ext.h"
- #include <ctype.h>
-
- init_screen()
- {
- int a, b;
- char row, col;
-
- tc_setup();
-
- for (a = 1; a <= 28; ++a)
- {
- for (b = 1; b <= 28; ++b)
- if (!off_map(a,b))
- disp_hex(a, b, '7');
- }
-
- disp_craters();
-
- /* refresh the screen */
-
- refresh();
- }
-
- to_xy(lhex, rhex, row, col)
- char lhex, rhex, *row, *col;
- {
- *row = (lhex - rhex) + 7;
- *col = 50 - (lhex + rhex);
- }
-
- off_map(a, b)
- char a, b;
- {
- char row, col;
-
- to_xy(a, b, &row, &col);
- if (col < 0 || col > 38 || row < 0 || row > 14) return(TRUE);
- else return(FALSE);
- }
-
- off_obstructed(a, b)
- char a, b;
- {
- char row, col;
-
- to_xy(a, b, &row, &col);
- if (col < 10 || col > 38 || row < 0 || row > 14) return(TRUE);
- else return(FALSE);
- }
-
- disp_hex(a, b, c)
- char a, b, c;
- {
- char row, col;
-
- to_xy(a, b, &row, &col);
- movecur(row, col * 2 + 1);
- Amiga_putchar(c);
- }
-
- update_hex(a, b)
- char a, b;
- {
- int i;
-
- if (ogre.l_hex == a && ogre.r_hex == b)
- {
- disp_ogre();
- return;
- }
-
- for (i = 0; i < n_units; ++i)
- if (unit[i].l_hex == a && unit[i].r_hex == b && unit[i].status !=
- DESTROYED)
- {
- disp_unit(i);
- return;
- }
-
- if (blocked(a, b))
- {
- disp_hex(a, b, '*');
- return;
- }
- disp_hex(a, b, '7');
- }
-
- disp_unit(i)
- int i;
- {
- char a, b;
-
- a = unit[i].l_hex;
- b = unit[i].r_hex;
- switch(unit[i].status)
- {
- case OK:
- switch (unit[i].type)
- {
- case INFANTRY:
- disp_hex(a, b, '0' + unit[i].attack);
- break;
- default:
- disp_hex(a, b, unit[i].type);
- break;
- }
- break;
-
- case DISABLED:
- disp_hex(a, b, tolower(unit[i].type));
- break;
-
- case DESTROYED:
- disp_hex(a, b, '7');
- break;
- }
- }
-
- disp_ogre(i)
- int i;
- {
- /* these are Amiga console control strings for changing colour */
-
- static char black_on[] =
- {
- 0x9b, '1', ';', '3', '2', ';', '4', '0', 'm', '\0'
- };
- static char black_off[] =
- {
- 0x9b, '0', ';', '3', '1', ';', '4', '0', 'm', '\0'
- };
- char a, b;
-
- a = ogre.l_hex;
- b = ogre.r_hex;
-
- Amiga_puts(black_on);
- disp_hex(a, b, 'O');
- Amiga_puts(black_off);
- }
-
- movecur_hex(a, b)
- char a, b;
- {
- char row, col;
-
- to_xy(a, b, &row, &col);
- movecur(row, col * 2 + 1);
- }
-
- movecur_unit(i)
- int i;
- {
- movecur_hex(unit[i].l_hex, unit[i].r_hex);
- }
-
- #define ABS(i) (((i) < 0) ? -(i) : (i))
- #define BIGINT 32767
-
- range(a1, b1, a2, b2)
- char a1, a2, b1, b2;
- {
- char diff1, diff2, temp;
- int subrange[3], min, i, rangesum;
-
- diff1 = a1 - b1;
- diff2 = a2 - b2;
-
- subrange[0] = ABS(a1 - a2);
- subrange[1] = ABS(b1 - b2);
- subrange[2] = ABS(diff1 - diff2);
-
- min = 0;
- for (i = 1; i < 3; ++i)
- if (subrange[i] < subrange[min]) min = i;
-
- rangesum = subrange[min];
- temp = subrange[min];
- subrange[min] = subrange[2];
- subrange[2] = temp;
- min = 0;
- for (i = 1; i < 2; ++i)
- if (subrange[i] < subrange[min]) min = i;
-
- rangesum += subrange[min];
- return(rangesum);
- }
-
- static struct
- {
- char l_hex, r_hex;
- }
- craters[] =
- {
- 17, 16,
- 19, 13,
- 13, 18,
- 14, 15,
- 13, 15,
- 15, 10,
- 9, 15,
- 10, 12,
- 7, 14,
- 11, 10,
- 14, 7,
- 12, 6,
- 7, 10,
- 8, 6,
- 4, 9,
- 9, 4,
- 9, 3,
- };
-
- #define NCRATERS (sizeof(craters) / 2 * sizeof(char))
-
- blocked(a, b)
- char a, b;
- {
- int i;
-
- for (i = 0; i < NCRATERS; ++i)
- if (craters[i].l_hex == a && craters[i].r_hex == b) return(TRUE);
- return(FALSE);
- }
-
- disp_craters()
- {
- int i;
-
- for (i = 0; i < NCRATERS; ++i)
- disp_hex(craters[i].l_hex, craters[i].r_hex, '*');
- }
-
- describe_action(action, i)
- char *action;
- int i;
- {
- char c[80];
-
- switch(unit[i].type)
- {
- case HOWITZER:
- movecur(16, 1);
- eeol(16);
- sprintf(c, "%s howitzer (%d/%d D%d M%d)", action,
- unit[i].attack, unit[i].range, unit[i].defend,
- unit[i].moves_left);
- Amiga_puts(c);
- break;
-
- case MSLTANK:
- movecur(16, 1);
- eeol(16);
- sprintf(c, "%s missile tank (%d/%d D%d M%d)", action,
- unit[i].attack, unit[i].range, unit[i].defend,
- unit[i].moves_left);
- Amiga_puts(c);
- break;
-
- case GEV:
- movecur(16, 1);
- eeol(16);
- sprintf(c, "%s GEV (%d/%d D%d M%d)", action,
- unit[i].attack, unit[i].range, unit[i].defend,
- unit[i].moves_left);
- Amiga_puts(c);
- break;
-
- case HVYTANK:
- movecur(16, 1);
- eeol(16);
- sprintf(c, "%s heavy tank (%d/%d D%d M%d)", action,
- unit[i].attack, unit[i].range, unit[i].defend,
- unit[i].moves_left);
- Amiga_puts(c);
- break;
-
- case INFANTRY:
- movecur(16, 1);
- eeol(16);
- sprintf(c, "%s infantry (%d/%d D%d M%d)", action,
- unit[i].attack, unit[i].range, unit[i].defend,
- unit[i].moves_left);
- Amiga_puts(c);
- break;
-
- }
- }
-
- /* routines display() and display_xy() have been removed */
-