- if(player.q == (TILEWH/SPEED)+1 && player.d > 0 && (player.triggerx == 5 && player.triggery == 5)){ player.hp--; }
- //if(keyp(0x0E)) while(1){ if(xmsmalloc(24)) break; }\r
- }\r
-\r
- /* fade back to text mode */\r
- modexFadeOff(4, ptmp.palette);\r
- modexPalBlack();\r
- modexLeave();\r
- setkb(0);\r
- printf("Project 16 scroll.exe\n");\r
- printf("tx: %d\n", bg->tx);\r
- printf("ty: %d\n", bg->ty);\r
- printf("player.x: %d", player.x);
- if(player.hp==0) printf("%d wwww\n", player.y+8);\r
- else printf("\nplayer.y: %d\n", player.y);\r
- printf("player.tx: %d\n", player.tx);\r
- printf("player.ty: %d\n", player.ty);\r
- printf("player.triggx: %d\n", player.triggerx);\r
- printf("player.triggy: %d\n", player.triggery);
- printf("player.hp: %d\n", player.hp);\r
- printf("player.q: %d\n", player.q);\r
- printf("player.d: %d\n", player.d);\r
- printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");\r
- printf("temporary player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");\r
- printf("\n");
- xmsfree(&map);\r
- switch(detectcpu())\r
- {\r
- case 0: cpus = "8086/8088 or 186/88"; break;\r
- case 1: cpus = "286"; break;\r
- case 2: cpus = "386 or newer"; break;\r
- default: cpus = "internal error"; break;\r
- }\r
- printf("detected CPU type: %s\n", cpus);\r
- modexPalBlack();\r
- modexFadeOn(4, pal);\r
-}\r
-\r
-\r
-map_t\r
-allocMap(int w, int h) {\r
- map_t result;\r
-\r
- result.width =w;\r
- result.height=h;\r
- //if(initxms())
- result.data = malloc(sizeof(byte) * w * h);
- //else result.data = xmsmalloc(sizeof(byte) * w * h);\r
-\r
- return result;\r
-}\r
-\r
-\r
-void\r
-initMap(map_t *map) {\r
- /* just a place holder to fill out an alternating pattern */\r
- int x, y;\r
- int i;\r
- int tile = 1;
- //if(initxms())
- map->tiles = malloc(sizeof(tiles_t));\r
- //else map->tiles = xmsmalloc(sizeof(tiles_t));\r
-\r
- /* create the tile set */\r
- //if(initxms())
- map->tiles = malloc(sizeof(tiles_t));
- //else map->tiles->data = xmsmalloc(sizeof(bitmap_t));\r
- map->tiles->data->width = (TILEWH*2);\r
- map->tiles->data->height= TILEWH;
- //if(initxms())
- map->tiles->data->data = malloc((TILEWH*2)*TILEWH);\r
- //else map->tiles->data->data = xmsmalloc((TILEWH*2)*TILEWH);\r
- map->tiles->tileHeight = TILEWH;\r
- map->tiles->tileWidth =TILEWH;\r
- map->tiles->rows = 1;\r
- map->tiles->cols = 2;\r
-\r
- i=0;\r
- for(y=0; y<TILEWH; y++) {\r
- for(x=0; x<(TILEWH*2); x++) {\r
- if(x<TILEWH)\r
- map->tiles->data->data[i] = 28;//0x24;\r
- else\r
- map->tiles->data->data[i] = 0;//0x34;\r
- i++;\r
- }\r
- }\r
-\r
- i=0;\r
- for(y=0; y<map->height; y++) {\r
- for(x=0; x<map->width; x++) {\r
- map->data[i] = tile;\r
- tile = tile ? 0 : 1;\r
- i++;\r
- }\r
- tile = tile ? 0 : 1;\r
- }\r
-}\r
-\r
-\r
-void\r
-mapScrollRight(map_view_t *mv, byte offset) {\r
- word x, y; /* coordinate for drawing */\r
-\r
- /* increment the pixel position and update the page */\r
- mv->page->dx += offset;\r
-\r
- /* check to see if this changes the tile */\r
- if(mv->page->dx >= mv->dxThresh ) {\r
- /* go forward one tile */\r
- mv->tx++;\r
- /* Snap the origin forward */\r
- mv->page->data += 4;\r
- mv->page->dx = mv->map->tiles->tileWidth;\r
- //}\r
-\r
- /* draw the next column */\r
- x= SCREEN_WIDTH + mv->map->tiles->tileWidth;\r
- mapDrawCol(mv, mv->tx + 20 , mv->ty-1, x);\r
- }\r
-}\r
-\r
-\r
-void\r
-mapScrollLeft(map_view_t *mv, byte offset) {\r
- word x, y; /* coordinate for drawing */\r
-\r
- /* increment the pixel position and update the page */\r
- mv->page->dx -= offset;\r
-\r
- /* check to see if this changes the tile */\r
- if(mv->page->dx == 0) {\r
- /* go backward one tile */\r
- mv->tx--;\r
-\r
- /* Snap the origin backward */\r
- mv->page->data -= 4;\r
- mv->page->dx = mv->map->tiles->tileWidth;\r
- //}\r
- /* draw the next column */\r
- mapDrawCol(mv, mv->tx-1, mv->ty-1, 0);\r
- }\r
-}\r
-\r
-\r
-void\r
-mapScrollUp(map_view_t *mv, byte offset) {\r
- word x, y; /* coordinate for drawing */\r
-\r
- /* increment the pixel position and update the page */\r
- mv->page->dy -= offset;\r
-\r
- /* check to see if this changes the tile */\r
- if(mv->page->dy == 0 ) {\r
- /* go down one tile */\r
- mv->ty--;\r
- /* Snap the origin downward */\r
- mv->page->data -= mv->page->width*4;\r
- mv->page->dy = mv->map->tiles->tileHeight;\r
- //}\r
-\r
- /* draw the next row */\r
- y= 0;\r
- mapDrawRow(mv, mv->tx-1 , mv->ty-1, y);\r
- }\r
-}\r
-\r
-\r
-void\r
-mapScrollDown(map_view_t *mv, byte offset) {\r
- word x, y; /* coordinate for drawing */\r
-\r
- /* increment the pixel position and update the page */\r
- mv->page->dy += offset;\r
-\r
- /* check to see if this changes the tile */\r
- if(mv->page->dy >= mv->dyThresh ) {\r
- /* go down one tile */\r
- mv->ty++;\r
- /* Snap the origin downward */\r
- mv->page->data += mv->page->width*4;\r
- mv->page->dy = mv->map->tiles->tileHeight;\r
- //}\r
-\r
- /* draw the next row */\r
- y= SCREEN_HEIGHT + mv->map->tiles->tileHeight;\r
- mapDrawRow(mv, mv->tx-1 , mv->ty+15, y);\r
- }\r
-\r
-}\r
-\r
-\r
-void\r
-mapGoTo(map_view_t *mv, int tx, int ty) {\r
- int px, py;\r
- unsigned int i;\r
-\r
- /* set up the coordinates */\r
- mv->tx = tx;\r
- mv->ty = ty;\r
- mv->page->dx = mv->map->tiles->tileWidth;\r
- mv->page->dy = mv->map->tiles->tileHeight;\r
-\r
- /* set up the thresholds */\r
- mv->dxThresh = mv->map->tiles->tileWidth * 2;\r
- mv->dyThresh = mv->map->tiles->tileHeight * 2;\r
-\r
- /* draw the tiles */\r
- modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0);\r
- py=0;\r
- i=mv->ty * mv->map->width + mv->tx;\r
- for(ty=mv->ty-1; py < SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; ty++, py+=mv->map->tiles->tileHeight) {\r
- mapDrawRow(mv, tx-1, ty, py);\r
- i+=mv->map->width - tx;\r
- }\r
-}\r
-\r
-\r
-void\r
-mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) {\r
- word rx;\r
- word ry;\r
- rx = (i % t->cols) * t->tileWidth;\r
- ry = (i / t->cols) * t->tileHeight;\r
- modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, t->data);\r
-}\r
-\r
-\r
-void \r
-mapDrawRow(map_view_t *mv, int tx, int ty, word y) {\r
- word x;\r
- int i;\r
-\r
- /* the position within the map array */\r
- i=ty * mv->map->width + tx;\r
- for(x=0; x<SCREEN_WIDTH+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {\r
- if(i>=0) {\r
- /* we are in the map, so copy! */\r
- mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);\r
- }\r
- i++; /* next! */\r
- }\r
-}\r
-\r
-void \r
-mapDrawCol(map_view_t *mv, int tx, int ty, word x) {\r
- int y;\r
- int i;\r
-\r
- /* location in the map array */\r
- i=ty * mv->map->width + tx;\r
-\r
- /* We'll copy all of the columns in the screen, \r
- i + 1 row above and one below */\r
- for(y=0; y<SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {\r
- if(i>=0) {\r
- /* we are in the map, so copy away! */\r
- mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);\r
- }\r
- i += mv->map->width;\r
- }\r
-}