1 #include "src\scroll.h"
2 #include "src\lib\modex16.h"
5 #include "src\lib\dos_kb.h"
6 #include "src\lib\wtest\wtest.c"
8 //word far *clock= (word far*) 0x046C; /* 18.2hz clock */
11 allocMap(int w, int h) {
16 result.data = malloc(sizeof(byte) * w * h);
24 /* just a place holder to fill out an alternating pattern */
28 map->tiles = malloc(sizeof(tiles_t));
30 /* create the tile set */
31 map->tiles->data = malloc(sizeof(bitmap_t));
32 map->tiles->data->width = (TILEWH*2);
33 map->tiles->data->height= TILEWH;
34 map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
35 map->tiles->tileHeight = TILEWH;
36 map->tiles->tileWidth =TILEWH;
41 for(y=0; y<TILEWH; y++) {
42 for(x=0; x<(TILEWH*2); x++) {
44 map->tiles->data->data[i] = 28;//0x24;
46 map->tiles->data->data[i] = 0;//0x34;
52 for(y=0; y<map->height; y++) {
53 for(x=0; x<map->width; x++) {
64 mapScrollRight(map_view_t *mv, byte offset, short lp) {
65 word x, y; /* coordinate for drawing */
67 /* increment the pixel position and update the page */
68 mv->page->dx += offset;
70 /* check to see if this changes the tile */
71 if(mv->page->dx >= mv->dxThresh ) {
72 /* go forward one tile */
74 /* Snap the origin forward */
76 mv->page->dx = mv->map->tiles->tileWidth;
79 /* draw the next column */
80 x= SCREEN_WIDTH + mv->map->tiles->tileWidth;
82 mapDrawCol(mv, mv->tx + 20 , mv->ty-1, x, mv->page->dx);
88 mapScrollLeft(map_view_t *mv, byte offset, short lp) {
89 word x, y; /* coordinate for drawing */
91 /* increment the pixel position and update the page */
92 mv->page->dx -= offset;
94 /* check to see if this changes the tile */
95 if(mv->page->dx == 0) {
96 /* go backward one tile */
99 /* Snap the origin backward */
101 mv->page->dx = mv->map->tiles->tileWidth;
103 /* draw the next column */
105 mapDrawCol(mv, mv->tx-1, mv->ty-1, 0, mv->page->dx);
111 mapScrollUp(map_view_t *mv, byte offset, short lp) {
112 word x, y; /* coordinate for drawing */
114 /* increment the pixel position and update the page */
115 mv->page->dy -= offset;
117 /* check to see if this changes the tile */
118 if(mv->page->dy == 0 ) {
119 /* go down one tile */
121 /* Snap the origin downward */
122 mv->page->data -= mv->page->width*4;
123 mv->page->dy = mv->map->tiles->tileHeight;
126 /* draw the next row */
129 mapDrawRow(mv, mv->tx-1 , mv->ty-1, y, mv->page->dy);
135 mapScrollDown(map_view_t *mv, byte offset, short lp) {
136 word x, y; /* coordinate for drawing */
138 /* increment the pixel position and update the page */
139 mv->page->dy += offset;
141 /* check to see if this changes the tile */
142 if(mv->page->dy >= mv->dyThresh ) {
143 /* go down one tile */
145 /* Snap the origin downward */
146 mv->page->data += mv->page->width*4;
147 mv->page->dy = mv->map->tiles->tileHeight;
150 /* draw the next row */
151 y= SCREEN_HEIGHT + mv->map->tiles->tileHeight;
153 mapDrawRow(mv, mv->tx-1 , mv->ty+15, y, mv->page->dy);
160 mapGoTo(map_view_t *mv, int tx, int ty) {
164 /* set up the coordinates */
167 mv->page->dx = mv->map->tiles->tileWidth;
168 mv->page->dy = mv->map->tiles->tileHeight;
170 /* set up the thresholds */
171 mv->dxThresh = mv->map->tiles->tileWidth * 2;
172 mv->dyThresh = mv->map->tiles->tileHeight * 2;
175 modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0);
177 i=mv->ty * mv->map->width + mv->tx;
178 for(ty=mv->ty-1; py < SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; ty++, py+=mv->map->tiles->tileHeight) {
179 mapDrawWRow(mv, tx-1, ty, py);
180 i+=mv->map->width - tx;
186 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) {
189 rx = (i % t->cols) * t->tileWidth;
190 ry = (i / t->cols) * t->tileHeight;
191 modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, t->data);
196 mapDrawRow(map_view_t *mv, int tx, int ty, word y, word poopoffset) {
200 //printf("y: %d\n", poopoffset);
201 /* the position within the map array */
202 i=ty * mv->map->width + tx;
203 for(x=poopoffset; x<(SCREEN_WIDTH+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
205 /* we are in the map, so copy! */
206 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
214 mapDrawCol(map_view_t *mv, int tx, int ty, word x, word poopoffset) {
218 //printf("x: %d\n", poopoffset);
219 /* location in the map array */
220 i=ty * mv->map->width + tx;
222 /* We'll copy all of the columns in the screen,
223 i + 1 row above and one below */
224 for(y=poopoffset; y<(SCREEN_HEIGHT+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
226 /* we are in the map, so copy away! */
227 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
234 mapDrawWRow(map_view_t *mv, int tx, int ty, word y) {
238 /* the position within the map array */
239 i=ty * mv->map->width + tx;
240 for(x=0; x<SCREEN_WIDTH+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
242 /* we are in the map, so copy! */
243 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
250 mapDrawWCol(map_view_t *mv, int tx, int ty, word x) {
254 /* location in the map array */
255 i=ty * mv->map->width + tx;
257 /* We'll copy all of the columns in the screen,
258 i + 1 row above and one below */
259 for(y=0; y<SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
261 /* we are in the map, so copy away! */
262 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
269 animatePlayer(map_view_t *src, map_view_t *dest, /*map_view_t *top, */short d1, short d2, int x, int y, int ls, int lp, bitmap_t *bmp)
271 short dire=32*d1; //direction
272 short qq; //scroll offset
275 else qq = ((lp)*SPEED);
299 modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40);
300 if(2>ls && ls>=1) { modexDrawSpriteRegion(dest->page, x, y, 48, dire, 24, 32, bmp); }else
301 if(3>ls && ls>=2) { modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); }else
302 if(4>ls && ls>=3) { modexDrawSpriteRegion(dest->page, x, y, 0, dire, 24, 32, bmp); }else
303 if(5>ls && ls>=4) { modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); }
304 //TODO: mask copy //modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40);
305 //modexClearRegion(top->page, 66, 66, 2, 40, 0);
306 //modexCopyPageRegion(dest->page, top->page, 66, 66, 66, 66, 2, 40);
307 //turn this off if XT
308 if(detectcpu() > 0) modexWaitBorder();