3 #include <fastgraf.h>
\r
5 #include "tiles.h" /* NEEDS ACCESS BECAUSE OF ANIMS */
\r
7 extern int far *topography; /* BACKGROUND TILE LIST (ARRAY) */
\r
8 extern int far *terrain; /* FOREGROUND TILE LIST (ARRAY) */
\r
9 extern struct ANIMATION *anim_list[ANIM_LIST_TOTAL];
\r
11 int view_x=0, view_y=0; /* VIEW AREA (UPPER LEFT CORNER) */
\r
12 int viewpage=0; /* CURRENTLY VIEWED PAGE */
\r
16 * Redraws the screen view area. Returns 1 on successful scroll.
\r
19 int redraw (int draw_type)
\r
26 case NONFLIP_SCROLL_RIGHT:
\r
27 new_draw_type=SCROLL_RIGHT; pageflip=0; break;
\r
28 case NONFLIP_SCROLL_LEFT:
\r
29 new_draw_type=SCROLL_LEFT; pageflip=0; break;
\r
30 case NONFLIP_SCROLL_UP:
\r
31 new_draw_type=SCROLL_UP; pageflip=0; break;
\r
32 case NONFLIP_SCROLL_DOWN:
\r
33 new_draw_type=SCROLL_DOWN; pageflip=0; break;
\r
34 case NONFLIP_REFRESH:
\r
35 new_draw_type=REFRESH; pageflip=0; break;
\r
37 new_draw_type=draw_type; break;
\r
40 switch (new_draw_type)
\r
42 case REFRESH: /* Full Refresh */
\r
43 place_tile_block (0, 0, VIEW_WIDTH-1, VIEW_HEIGHT-1);
\r
47 if (view_y<=0) return 0; /* DON'T ALLOW TO SCROLL BEYOND WORLD */
\r
49 fg_transfer (0, SCREEN_WIDTH-1, 0, SCREEN_HEIGHT-TILE_HEIGHT-1, 0, SCREEN_HEIGHT-1, viewpage, !viewpage);
\r
50 place_tile_block (0, 0, VIEW_WIDTH-1, 0);
\r
54 if (view_y>=WORLD_HEIGHT-VIEW_HEIGHT) return 0; /* HEY! */
\r
56 fg_transfer (0, SCREEN_WIDTH-1, TILE_HEIGHT, SCREEN_HEIGHT-1, 0, SCREEN_HEIGHT-TILE_HEIGHT-1, viewpage, !viewpage);
\r
57 place_tile_block (0, VIEW_HEIGHT-1, VIEW_WIDTH-1, VIEW_HEIGHT-1);
\r
61 if (view_x<=0) return 0; /* DON'T ALLOW TO SCROLL BEYOND WORLD */
\r
63 fg_transfer (0, SCREEN_WIDTH-TILE_WIDTH-1, 0, SCREEN_HEIGHT-1, TILE_WIDTH, SCREEN_HEIGHT-1, viewpage, !viewpage);
\r
64 place_tile_block (0, 0, 0, VIEW_HEIGHT-1);
\r
68 if (view_x>=WORLD_WIDTH-VIEW_WIDTH) return 0; /* HEY! */
\r
70 fg_transfer (TILE_WIDTH, SCREEN_WIDTH-1, 0, SCREEN_HEIGHT-1, 0, SCREEN_HEIGHT-1, viewpage, !viewpage);
\r
71 place_tile_block (VIEW_WIDTH-1, 0, VIEW_WIDTH-1, VIEW_HEIGHT-1);
\r
75 if (view_x>=WORLD_WIDTH-VIEW_WIDTH) return redraw (SCROLL_UP);
\r
76 if (view_y<=0) return redraw(SCROLL_RIGHT);
\r
78 fg_transfer (TILE_WIDTH, SCREEN_WIDTH-1, 0, SCREEN_HEIGHT-TILE_HEIGHT-1, 0, SCREEN_HEIGHT-1, viewpage, !viewpage);
\r
79 place_tile_block (0, 0, VIEW_WIDTH-1, 0);
\r
80 place_tile_block (VIEW_WIDTH-1, 0, VIEW_WIDTH-1, VIEW_HEIGHT-1);
\r
84 if (view_x>=WORLD_WIDTH-VIEW_WIDTH) return redraw(SCROLL_DOWN);
\r
85 if (view_y>=WORLD_HEIGHT-VIEW_HEIGHT) return redraw(SCROLL_RIGHT);
\r
87 fg_transfer (TILE_WIDTH, SCREEN_WIDTH-1, TILE_HEIGHT, SCREEN_HEIGHT-1, 0, SCREEN_HEIGHT-TILE_HEIGHT-1, viewpage, !viewpage);
\r
88 place_tile_block (0, VIEW_HEIGHT-1, VIEW_WIDTH-1, VIEW_HEIGHT-1);
\r
89 place_tile_block (VIEW_WIDTH-1, 0, VIEW_WIDTH-1, VIEW_HEIGHT-1);
\r
93 if (view_x<=0) return redraw (SCROLL_DOWN);
\r
94 if (view_y>=WORLD_HEIGHT-VIEW_HEIGHT) return redraw(SCROLL_LEFT);
\r
96 fg_transfer (0, SCREEN_WIDTH-TILE_WIDTH-1, TILE_HEIGHT, SCREEN_HEIGHT-1, TILE_WIDTH, SCREEN_HEIGHT-TILE_HEIGHT-1, viewpage, !viewpage);
\r
97 place_tile_block (0, VIEW_HEIGHT-1, VIEW_WIDTH-1, VIEW_HEIGHT-1);
\r
98 place_tile_block (0, 0, 0, VIEW_HEIGHT-1);
\r
102 if (view_x<=0) return redraw (SCROLL_UP);
\r
103 if (view_y<=0) return redraw (SCROLL_LEFT);
\r
104 view_y--; view_x--;
\r
105 fg_transfer (0, SCREEN_WIDTH-TILE_WIDTH-1, 0, SCREEN_HEIGHT-TILE_HEIGHT-1, TILE_WIDTH, SCREEN_HEIGHT-1, viewpage, !viewpage);
\r
106 place_tile_block (0, 0, VIEW_WIDTH-1, 0);
\r
107 place_tile_block (0, 0, 0, VIEW_HEIGHT-1);
\r
113 viewpage=!viewpage; /* SWAP PAGES */
\r
114 fg_setvpage (viewpage);
\r
117 return 1; /* SUCCESSFUL SCROLL */
\r
122 * Redraws a rectangular region of the active (!shown) page with tiles.
\r
126 void place_tile_block (int x1, int y1, int x2, int y2)
\r
131 for (y=view_y+y1; y<=view_y+y2; y++)
\r
132 for (x=view_x+x1; x<=view_x+x2; x++)
\r
134 tile=terrain[WORLD_TILE(x,y)];
\r
136 /* DON'T PLACE FOREGROUND IF EMPTY */
\r
137 if (tile==EMPTY_TILE)
\r
138 pagecopy_tile_op (topography[WORLD_TILE(x,y)],VIEW_TILE(x-view_x,y-view_y), TILEPAGE, !viewpage);
\r
145 while (anim_list[a]->anm!=tile) a++;
\r
146 tile=anim_list[a]->current;
\r
149 pagecopy_tile_op (topography[WORLD_TILE(x,y)], VIEW_TILE(x-view_x,y-view_y), TILEPAGE, !viewpage);
\r
150 pagecopy_tile_tr (tile, VIEW_TILE(x-view_x,y-view_y), TILEPAGE, !viewpage);
\r
157 * Updates on the visual page a single world tile.
\r
160 void update_tile (int tile)
\r
162 register int viewtile;
\r
164 if (!is_viewable (tile)) return; /* DO NOT UPDATE THE UNSEEN */
\r
166 viewtile=VIEW_TILE(WORLD_TILE_X(tile)-view_x,WORLD_TILE_Y(tile)-view_y);
\r
168 if (terrain[tile]==EMPTY_TILE)
\r
169 pagecopy_tile_op (topography[tile], viewtile, TILEPAGE, viewpage);
\r
173 pagecopy_tile_op (topography[tile], MIXING_TILE, TILEPAGE, TILEPAGE);
\r
174 pagecopy_tile_tr (terrain[tile], MIXING_TILE, TILEPAGE, TILEPAGE);
\r
175 pagecopy_tile_op (MIXING_TILE, viewtile, TILEPAGE, viewpage);
\r